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