]> icculus.org git repositories - dana/openbox.git/blob - openbox/client.h
speed up workspace switching by causing the minimal number of expose events (none...
[dana/openbox.git] / openbox / client.h
1 #ifndef __client_h
2 #define __client_h
3
4 #include "geom.h"
5 #include "stacking.h"
6 #include <glib.h>
7 #include <X11/Xlib.h>
8
9 struct ClientWrap;
10 struct Frame;
11
12
13 /*! Holds an icon in ARGB format */
14 typedef struct Icon {
15     unsigned long w, h;
16     unsigned long *data;
17 } Icon;
18      
19 /*! The MWM Hints as retrieved from the window property
20   This structure only contains 3 elements, even though the Motif 2.0
21   structure contains 5. We only use the first 3, so that is all gets
22   defined.
23 */
24 typedef struct MwmHints {
25     /*! A bitmask of Client::MwmFlags values */
26     unsigned long flags;
27     /*! A bitmask of Client::MwmFunctions values */
28     unsigned long functions;
29     /*! A bitmask of Client::MwmDecorations values */
30     unsigned long decorations;
31 } MwmHints;
32 /*! The number of elements in the Client::MwmHints struct */
33 #define MWM_ELEMENTS 3
34      
35 /*! Possible flags for MWM Hints (defined by Motif 2.0) */
36 typedef enum {
37     MwmFlag_Functions   = 1 << 0, /*!< The MMW Hints define funcs */
38     MwmFlag_Decorations = 1 << 1  /*!< The MWM Hints define decor */
39 } MwmFlags;
40
41 /*! Possible functions for MWM Hints (defined by Motif 2.0) */
42 typedef enum {
43     MwmFunc_All      = 1 << 0, /*!< All functions */
44     MwmFunc_Resize   = 1 << 1, /*!< Allow resizing */
45     MwmFunc_Move     = 1 << 2, /*!< Allow moving */
46     MwmFunc_Iconify  = 1 << 3, /*!< Allow to be iconfied */
47     MwmFunc_Maximize = 1 << 4  /*!< Allow to be maximized */
48     /*MwmFunc_Close    = 1 << 5 /!< Allow to be closed */
49 } MwmFunctions;
50
51 /*! Possible decorations for MWM Hints (defined by Motif 2.0) */
52 typedef enum {
53     MwmDecor_All      = 1 << 0, /*!< All decorations */
54     MwmDecor_Border   = 1 << 1, /*!< Show a border */
55     MwmDecor_Handle   = 1 << 2, /*!< Show a handle (bottom) */
56     MwmDecor_Title    = 1 << 3, /*!< Show a titlebar */
57     /*MwmDecor_Menu     = 1 << 4, /!< Show a menu */
58     MwmDecor_Iconify  = 1 << 5, /*!< Show an iconify button */
59     MwmDecor_Maximize = 1 << 6  /*!< Show a maximize button */
60 } MemDecorations;
61
62 /*! Corners of the client window, used for anchor positions */
63 typedef enum {
64     Corner_TopLeft,
65     Corner_TopRight,
66     Corner_BottomLeft,
67     Corner_BottomRight
68 } Corner;
69
70 /*! Possible window types */
71 typedef enum {
72     Type_Desktop, /*!< A desktop (bottom-most window) */
73     Type_Dock,    /*!< A dock bar/panel window */
74     Type_Toolbar, /*!< A toolbar window, pulled off an app */
75     Type_Menu,    /*!< An unpinned menu from an app */
76     Type_Utility, /*!< A small utility window such as a palette */
77     Type_Splash,  /*!< A splash screen window */
78     Type_Dialog,  /*!< A dialog window */
79     Type_Normal   /*!< A normal application window */
80 } WindowType;
81
82 /*! The things the user can do to the client window */
83 typedef enum {
84     Func_Resize     = 1 << 0, /*!< Allow resizing */
85     Func_Move       = 1 << 1, /*!< Allow moving */
86     Func_Iconify    = 1 << 2, /*!< Allow to be iconified */
87     Func_Maximize   = 1 << 3, /*!< Allow to be maximized */
88     Func_Shade      = 1 << 4, /*!< Allow to be shaded */
89     Func_Fullscreen = 1 << 5, /*!< Allow to be made fullscreen */
90     Func_Close      = 1 << 6  /*!< Allow to be closed */
91 } Function;
92
93 /*! The decorations the client window wants to be displayed on it */
94 typedef enum {
95     Decor_Titlebar    = 1 << 0, /*!< Display a titlebar */
96     Decor_Handle      = 1 << 1, /*!< Display a handle (bottom) */
97     Decor_Border      = 1 << 2, /*!< Display a border */
98     Decor_Icon        = 1 << 3, /*!< Display the window's icon */
99     Decor_Iconify     = 1 << 4, /*!< Display an iconify button */
100     Decor_Maximize    = 1 << 5, /*!< Display a maximize button */
101     /*! Display a button to toggle the window's placement on
102       all desktops */
103     Decor_AllDesktops = 1 << 6,
104     Decor_Close       = 1 << 7  /*!< Display a close button */
105 } Decoration;
106
107
108 typedef struct Client {
109     Window  window;
110
111     struct Frame *frame;
112
113     /*! The number of unmap events to ignore on the window */
114     int ignore_unmaps;
115
116     /*! The id of the group the window belongs to */
117     Window  group;
118     /*! Whether or not the client is a transient window. This is guaranteed to 
119       be TRUE if transient_for != NULL, but not guaranteed to be FALSE if
120       transient_for == NULL. */
121     gboolean transient;
122     /*! The client which this client is a transient (child) for */
123     struct Client *transient_for;
124     /*! The clients which are transients (children) of this client */
125     GSList *transients;
126     /*! The desktop on which the window resides (0xffffffff for all
127       desktops) */
128     unsigned int desktop;
129
130     /*! Normal window title */
131     gchar *title;
132     /*! Window title when iconified */
133     gchar *icon_title;
134
135     /*! The application that created the window */
136     gchar *res_name;
137     /*! The class of the window, can used for grouping */
138     gchar *res_class;
139     /*! The specified role of the window, used for identification */
140     gchar *role;
141
142     /*! The type of window (what its function is) */
143     WindowType type;
144
145     /*! Position and size of the window
146       This will not always be the actual position of the window on screen, it
147       is, rather, the position requested by the client, to which the window's
148       gravity is applied.
149     */
150     Rect    area;
151
152     /*! The window's strut
153       The strut defines areas of the screen that are marked off-bounds for
154       window placement. In theory, where this window exists.
155     */
156     Strut   strut;
157      
158     /*! The logical size of the window
159       The "logical" size of the window is refers to the user's perception of
160       the size of the window, and is the value that should be displayed to the
161       user. For example, with xterms, this value it the number of characters
162       being displayed in the terminal, instead of the number of pixels.
163     */
164     Size   logical_size;
165
166     /*! Width of the border on the window.
167       The window manager will set this to 0 while the window is being managed,
168       but needs to restore it afterwards, so it is saved here.
169     */
170     guint border_width;
171
172     /*! The minimum aspect ratio the client window can be sized to.
173       A value of 0 means this is ignored.
174     */
175     float min_ratio;
176     /*! The maximum aspect ratio the client window can be sized to.
177       A value of 0 means this is ignored.
178     */
179     float max_ratio;
180   
181     /*! The minimum size of the client window
182       If the min is > the max, then the window is not resizable
183     */
184     Size min_size;
185     /*! The maximum size of the client window
186       If the min is > the max, then the window is not resizable
187     */
188     Size max_size;
189     /*! The size of increments to resize the client window by */
190     Size size_inc;
191     /*! The base size of the client window
192       This value should be subtracted from the window's actual size when
193       displaying its size to the user, or working with its min/max size
194     */
195     Size base_size;
196
197     /*! Window decoration and functionality hints */
198     MwmHints mwmhints;
199   
200     /*! Where to place the decorated window in relation to the undecorated
201       window */
202     int gravity;
203
204     /*! The state of the window, one of WithdrawnState, IconicState, or
205       NormalState */
206     long wmstate;
207
208     /*! True if the client supports the delete_window protocol */
209     gboolean delete_window;
210   
211     /*! Was the window's position requested by the application? if not, we
212       should place the window ourselves when it first appears */
213     gboolean positioned;
214   
215     /*! Can the window receive input focus? */
216     gboolean can_focus;
217     /*! Urgency flag */
218     gboolean urgent;
219     /*! Notify the window when it receives focus? */
220     gboolean focus_notify;
221     /*! Does the client window have the input focus? */
222     gboolean focused;
223
224     /*! The window uses shape extension to be non-rectangular? */
225     gboolean shaped;
226
227     /*! The window is modal, so it must be processed before any windows it is
228       related to can be focused */
229     gboolean modal;
230     /*! Only the window's titlebar is displayed */
231     gboolean shaded;
232     /*! The window is iconified */
233     gboolean iconic;
234     /*! The window is maximized to fill the screen vertically */
235     gboolean max_vert;
236     /*! The window is maximized to fill the screen horizontally */
237     gboolean max_horz;
238     /*! The window should not be displayed by pagers */
239     gboolean skip_pager;
240     /*! The window should not be displayed by taskbars */
241     gboolean skip_taskbar;
242     /*! The window is a 'fullscreen' window, and should be on top of all
243       others */
244     gboolean fullscreen;
245     /*! The window should be on top of other windows of the same type.
246       above takes priority over below. */
247     gboolean above;
248     /*! The window should be underneath other windows of the same type.
249       above takes priority over below. */
250     gboolean below;
251
252     /*! The layer in which the window will be stacked, windows in lower layers
253       are always below windows in higher layers. */
254     StackLayer layer;
255
256     /*! A bitmask of values in the Decoration enum
257       The values in the variable are the decorations that the client wants to
258       be displayed around it.
259     */
260     int decorations;
261
262     /*! A bitmask of values in the Decoration enum.
263       Specifies the decorations that should NOT be displayed on the client.
264     */
265     int disabled_decorations;
266
267     /*! A bitmask of values in the Function enum
268       The values in the variable specify the ways in which the user is allowed
269       to modify this window.
270     */
271     int functions;
272
273     /*! Icons for the client as specified on the client window */
274     Icon *icons;
275     /*! The number of icons in icons */
276     int nicons;
277
278     /*! The icon for the client specified in the WMHints or the KWM hints */
279     Pixmap pixmap_icon;
280     /*! The mask for the pixmap_icon, or None if its not masked */
281     Pixmap pixmap_icon_mask;
282
283     /* The instance of the wrapper class if one exists */
284     struct ClientWrap *wrap;
285 } Client;
286
287 extern GSList *client_list;
288 extern GHashTable *client_map;
289
290 void client_startup();
291 void client_shutdown();
292
293 /*! Manages all existing windows */
294 void client_manage_all();
295 /*! Manages a given window */
296 void client_manage(Window win);
297 /*! Unmanages all managed windows */
298 void client_unmanage_all();
299 /*! Unmanages a given client */
300 void client_unmanage(Client *client);
301
302 /*! Sets the client list on the root window from the client_list */
303 void client_set_list();
304
305 /*! Reapplies the maximized state to the window
306   Use this to make the window readjust its maximized size to new
307   surroundings (struts, etc). */
308 void client_remaximize(Client *self);
309
310 /*! Shows the window if it should be shown, or hides it
311   Used when changing desktops, the window's state, etc. */
312 void client_showhide(Client *self);
313
314 /*! Determines if the client should be shown or hidden currently.
315   @return TRUE if it should be visible; otherwise, FALSE.
316 */
317 gboolean client_should_show(Client *self);
318
319 /*! Returns if the window should be treated as a normal window.
320   Some windows (desktops, docks, splash screens) have special rules applied
321   to them in a number of places regarding focus or user interaction. */
322 gboolean client_normal(Client *self);
323
324 /*! Move and/or resize the window.
325   This also maintains things like the client's minsize, and size increments.
326   @param anchor The corner to keep in the same position when resizing.
327   @param x The x coordiante of the new position for the client.
328   @param y The y coordiante of the new position for the client.
329   @param w The width component of the new size for the client.
330   @param h The height component of the new size for the client.
331   @param user Specifies whether this is a user-requested change or a
332               program requested change. For program requested changes, the
333               constraints are not checked.
334   @param final If user is true, then this should specify if this is a final
335                configuration. e.g. Final should be FALSE if doing an
336                interactive move/resize, and then be TRUE for the last call
337                only.
338 */
339 void client_configure(Client *self, Corner anchor, int x, int y, int w, int h,
340                       gboolean user, gboolean final);
341
342 /*! Fullscreen's or unfullscreen's the client window
343   @param fs true if the window should be made fullscreen; false if it should
344             be returned to normal state.
345   @param savearea true to have the client's current size and position saved;
346                   otherwise, they are not. You should not save when mapping a
347                   new window that is set to fullscreen. This has no effect
348                   when restoring a window from fullscreen.
349 */
350 void client_fullscreen(Client *self, gboolean fs, gboolean savearea);
351
352 /*! Iconifies or uniconifies the client window
353   @param iconic true if the window should be iconified; false if it should be
354                 restored.
355   @param curdesk If iconic is FALSE, then this determines if the window will
356                  be uniconified to the current viewable desktop (true) or to
357                  its previous desktop (false)
358 */
359 void client_iconify(Client *self, gboolean iconic, gboolean curdesk);
360
361 /*! Maximize or unmaximize the client window
362   @param max true if the window should be maximized; false if it should be
363              returned to normal size.
364   @param dir 0 to set both horz and vert, 1 to set horz, 2 to set vert.
365   @param savearea true to have the client's current size and position saved;
366                   otherwise, they are not. You should not save when mapping a
367                   new window that is set to fullscreen. This has no effect
368                   when unmaximizing a window.
369 */
370 void client_maximize(Client *self, gboolean max, int dir,
371                      gboolean savearea);
372
373 /*! Shades or unshades the client window
374   @param shade true if the window should be shaded; false if it should be
375                unshaded.
376 */
377 void client_shade(Client *self, gboolean shade);
378
379 /*! Request the client to close its window. */
380 void client_close(Client *self);
381
382 /*! Sends the window to the specified desktop */
383 void client_set_desktop(Client *self, unsigned int target);
384
385 /*! Return a modal child of the client window
386     @return A modal child of the client window, or 0 if none was found.
387 */
388 Client *client_find_modal_child(Client *self);
389
390 /*! Validate client, by making sure no Destroy or Unmap events exist in
391   the event queue for the window.
392   @return true if the client is valid; false if the client has already
393           been unmapped/destroyed, and so is invalid.
394 */
395 gboolean client_validate(Client *self);
396
397 /*! Sets the wm_state to the specified value */
398 void client_set_wm_state(Client *self, long state);
399
400 /*! Adjusts the window's net_state
401   This should not be called as part of the window mapping process! It is for
402   use when updating the state post-mapping.<br>
403   client_apply_startup_state is used to do the same things during the mapping
404   process.
405 */
406 void client_set_state(Client *self, Atom action, long data1, long data2);
407
408 /*! Attempt to focus the client window */
409 gboolean client_focus(Client *self);
410
411 /*! Remove focus from the client window */
412 void client_unfocus(Client *self);
413
414 /*! Calculates the stacking layer for the client window */
415 void client_calc_layer(Client *self);
416
417 /*! Updates the window's transient status, and any parents of it */
418 void client_update_transient_for(Client *self);
419 /*! Update the protocols that the window supports and adjusts things if they
420   change */
421 void client_update_protocols(Client *self);
422 /*! Updates the WMNormalHints and adjusts things if they change */
423 void client_update_normal_hints(Client *self);
424
425 /*! Updates the WMHints and adjusts things if they change
426   @param initstate Whether to read the initial_state property from the
427                    WMHints. This should only be used during the mapping
428                    process.
429 */
430 void client_update_wmhints(Client *self);
431 /*! Updates the window's title */
432 void client_update_title(Client *self);
433 /*! Updates the window's icon title */
434 void client_update_icon_title(Client *self);
435 /*! Updates the window's application name and class */
436 void client_update_class(Client *self);
437 /*! Updates the strut for the client */
438 void client_update_strut(Client *self);
439 /*! Updates the window's icons */
440 void client_update_icons(Client *self);
441 /*! Updates the window's kwm icon */
442 void client_update_kwm_icon(Client *self);
443
444 /*! Set up what decor should be shown on the window and what functions should
445   be allowed (Client::decorations and Client::functions).
446   This also updates the NET_WM_ALLOWED_ACTIONS hint.
447 */
448 void client_setup_decor_and_functions(Client *self);
449
450 /*! Retrieves the window's type and sets Client->type */
451 void client_get_type(Client *self);
452
453 #endif