]> icculus.org git repositories - mikachu/openbox.git/blob - openbox/frame.h
add a slight delay to the focus/desktop switch dialogs. so if you hit the key really...
[mikachu/openbox.git] / openbox / frame.h
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3    frame.h for the Openbox window manager
4    Copyright (c) 2006        Mikael Magnusson
5    Copyright (c) 2003-2007   Dana Jansens
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    See the COPYING file for a copy of the GNU General Public License.
18 */
19
20 #ifndef __frame_h
21 #define __frame_h
22
23 #include "geom.h"
24 #include "render/render.h"
25
26 typedef struct _ObFrame ObFrame;
27
28 struct _ObClient;
29
30 typedef enum {
31     OB_FRAME_CONTEXT_NONE,
32     OB_FRAME_CONTEXT_DESKTOP,
33     OB_FRAME_CONTEXT_CLIENT,
34     OB_FRAME_CONTEXT_TITLEBAR,
35     OB_FRAME_CONTEXT_HANDLE,
36     OB_FRAME_CONTEXT_FRAME,
37     OB_FRAME_CONTEXT_BLCORNER,
38     OB_FRAME_CONTEXT_BRCORNER,
39     OB_FRAME_CONTEXT_TLCORNER,
40     OB_FRAME_CONTEXT_TRCORNER,
41     OB_FRAME_CONTEXT_MAXIMIZE,
42     OB_FRAME_CONTEXT_ALLDESKTOPS,
43     OB_FRAME_CONTEXT_SHADE,
44     OB_FRAME_CONTEXT_ICONIFY,
45     OB_FRAME_CONTEXT_ICON,
46     OB_FRAME_CONTEXT_CLOSE,
47     /*! This is a special context, which occurs while dragging a window in
48       a move/resize */
49     OB_FRAME_CONTEXT_MOVE_RESIZE,
50     OB_FRAME_NUM_CONTEXTS
51 } ObFrameContext;
52
53 /*! The decorations the client window wants to be displayed on it */
54 typedef enum {
55     OB_FRAME_DECOR_TITLEBAR    = 1 << 0, /*!< Display a titlebar */
56     OB_FRAME_DECOR_HANDLE      = 1 << 1, /*!< Display a handle (bottom) */
57     OB_FRAME_DECOR_GRIPS       = 1 << 2, /*!< Display grips in the handle */
58     OB_FRAME_DECOR_BORDER      = 1 << 3, /*!< Display a border */
59     OB_FRAME_DECOR_ICON        = 1 << 4, /*!< Display the window's icon */
60     OB_FRAME_DECOR_ICONIFY     = 1 << 5, /*!< Display an iconify button */
61     OB_FRAME_DECOR_MAXIMIZE    = 1 << 6, /*!< Display a maximize button */
62     /*! Display a button to toggle the window's placement on
63       all desktops */
64     OB_FRAME_DECOR_ALLDESKTOPS = 1 << 7,
65     OB_FRAME_DECOR_SHADE       = 1 << 8, /*!< Displays a shade button */
66     OB_FRAME_DECOR_CLOSE       = 1 << 9  /*!< Display a close button */
67 } ObFrameDecorations;
68
69 struct _ObFrame
70 {
71     struct _ObClient *client;
72
73     Window    window;
74     Window    plate;
75
76     Strut     size;
77     Rect      area;
78     gboolean  visible;
79
80     guint     decorations;
81     gboolean  max_horz;
82
83     Window    inner;  /*!< The window for drawing the inner client border */
84     Window    title;
85     Window    label;
86     Window    max;
87     Window    close;
88     Window    desk;
89     Window    shade;
90     Window    icon;
91     Window    iconify;
92     Window    handle;
93     Window    lgrip;
94     Window    rgrip;
95
96     Window    tltresize;
97     Window    tllresize;
98     Window    trtresize;
99     Window    trrresize;
100
101     Colormap  colormap;
102
103     RrAppearance *a_unfocused_title;
104     RrAppearance *a_focused_title;
105     RrAppearance *a_unfocused_label;
106     RrAppearance *a_focused_label;
107     RrAppearance *a_icon;
108     RrAppearance *a_unfocused_handle;
109     RrAppearance *a_focused_handle;
110
111     Strut     innersize;
112
113     GSList   *clients;
114
115     gint      width;         /* title and handle */
116     gint      label_width;
117     gint      icon_x;        /* x-position of the window icon button */
118     gint      label_x;       /* x-position of the window title */
119     gint      iconify_x;     /* x-position of the window iconify button */
120     gint      desk_x;        /* x-position of the window all-desktops button */
121     gint      shade_x;       /* x-position of the window shade button */
122     gint      max_x;         /* x-position of the window maximize button */
123     gint      close_x;       /* x-position of the window close button */
124     gint      bwidth;        /* border width */
125     gint      rbwidth;       /* title border width */
126     gint      cbwidth_x;     /* client border width */
127     gint      cbwidth_y;     /* client border width */
128
129     gboolean  max_press;
130     gboolean  close_press;
131     gboolean  desk_press;
132     gboolean  shade_press;
133     gboolean  iconify_press;
134     gboolean  max_hover;
135     gboolean  close_hover;
136     gboolean  desk_hover;
137     gboolean  shade_hover;
138     gboolean  iconify_hover;
139
140     gboolean  focused;
141
142     gboolean  flashing;
143     gboolean  flash_on;
144     GTimeVal  flash_end;
145 };
146
147 ObFrame *frame_new(struct _ObClient *c);
148 void frame_show(ObFrame *self);
149 void frame_hide(ObFrame *self);
150 void frame_adjust_theme(ObFrame *self);
151 void frame_adjust_shape(ObFrame *self);
152 void frame_adjust_area(ObFrame *self, gboolean moved,
153                        gboolean resized, gboolean fake);
154 void frame_adjust_client_area(ObFrame *self);
155 void frame_adjust_state(ObFrame *self);
156 void frame_adjust_focus(ObFrame *self, gboolean hilite);
157 void frame_adjust_title(ObFrame *self);
158 void frame_adjust_icon(ObFrame *self);
159 void frame_grab_client(ObFrame *self, struct _ObClient *client);
160 void frame_release_client(ObFrame *self, struct _ObClient *client);
161
162 ObFrameContext frame_context_from_string(const gchar *name);
163
164 ObFrameContext frame_context(struct _ObClient *self, Window win);
165
166 /*! Applies gravity to the client's position to find where the frame should
167   be positioned.
168   @return The proper coordinates for the frame, based on the client.
169 */
170 void frame_client_gravity(ObFrame *self, gint *x, gint *y, gint w, gint h);
171
172 /*! Reversly applies gravity to the frame's position to find where the client
173   should be positioned.
174     @return The proper coordinates for the client, based on the frame.
175 */
176 void frame_frame_gravity(ObFrame *self, gint *x, gint *y, gint w, gint h);
177
178 void frame_flash_start(ObFrame *self);
179 void frame_flash_stop(ObFrame *self);
180
181 #endif