]> icculus.org git repositories - mikachu/openbox.git/blob - openbox/client.h
support for transients of groups
[mikachu/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     struct Frame *frame;
116
117     /*! The number of unmap events to ignore on the window */
118     int ignore_unmaps;
119
120     /*! The id of the group the window belongs to */
121     struct Group *group;
122     /*! Whether or not the client is a transient window. This is guaranteed to 
123       be TRUE if transient_for != NULL, but not guaranteed to be FALSE if
124       transient_for == NULL. */
125     gboolean transient;
126     /*! The client which this client is a transient (child) for */
127     struct Client *transient_for;
128     /*! The clients which are transients (children) of this client */
129     GSList *transients;
130     /*! The desktop on which the window resides (0xffffffff for all
131       desktops) */
132     unsigned int desktop;
133
134     /*! Normal window title */
135     gchar *title;
136     /*! Window title when iconified */
137     gchar *icon_title;
138
139     /*! The application that created the window */
140     gchar *name;
141     /*! The class of the window, can used for grouping */
142     gchar *class;
143     /*! The specified role of the window, used for identification */
144     gchar *role;
145
146     /*! The type of window (what its function is) */
147     WindowType type;
148
149     /*! Position and size of the window
150       This will not always be the actual position of the window on screen, it
151       is, rather, the position requested by the client, to which the window's
152       gravity is applied.
153     */
154     Rect    area;
155
156     /*! The window's strut
157       The strut defines areas of the screen that are marked off-bounds for
158       window placement. In theory, where this window exists.
159     */
160     Strut   strut;
161      
162     /*! The logical size of the window
163       The "logical" size of the window is refers to the user's perception of
164       the size of the window, and is the value that should be displayed to the
165       user. For example, with xterms, this value it the number of characters
166       being displayed in the terminal, instead of the number of pixels.
167     */
168     Size   logical_size;
169
170     /*! Width of the border on the window.
171       The window manager will set this to 0 while the window is being managed,
172       but needs to restore it afterwards, so it is saved here.
173     */
174     guint border_width;
175
176     /*! The minimum aspect ratio the client window can be sized to.
177       A value of 0 means this is ignored.
178     */
179     float min_ratio;
180     /*! The maximum aspect ratio the client window can be sized to.
181       A value of 0 means this is ignored.
182     */
183     float max_ratio;
184   
185     /*! The minimum size of the client window
186       If the min is > the max, then the window is not resizable
187     */
188     Size min_size;
189     /*! The maximum size of the client window
190       If the min is > the max, then the window is not resizable
191     */
192     Size max_size;
193     /*! The size of increments to resize the client window by */
194     Size size_inc;
195     /*! The base size of the client window
196       This value should be subtracted from the window's actual size when
197       displaying its size to the user, or working with its min/max size
198     */
199     Size base_size;
200
201     /*! Window decoration and functionality hints */
202     MwmHints mwmhints;
203   
204     /*! Where to place the decorated window in relation to the undecorated
205       window */
206     int gravity;
207
208     /*! The state of the window, one of WithdrawnState, IconicState, or
209       NormalState */
210     long wmstate;
211
212     /*! True if the client supports the delete_window protocol */
213     gboolean delete_window;
214   
215     /*! Was the window's position requested by the application? if not, we
216       should place the window ourselves when it first appears */
217     gboolean positioned;
218   
219     /*! Can the window receive input focus? */
220     gboolean can_focus;
221     /*! Urgency flag */
222     gboolean urgent;
223     /*! Notify the window when it receives focus? */
224     gboolean focus_notify;
225
226     /*! The window uses shape extension to be non-rectangular? */
227     gboolean shaped;
228
229     /*! The window is modal, so it must be processed before any windows it is
230       related to can be focused */
231     gboolean modal;
232     /*! Only the window's titlebar is displayed */
233     gboolean shaded;
234     /*! The window is iconified */
235     gboolean iconic;
236     /*! The window is maximized to fill the screen vertically */
237     gboolean max_vert;
238     /*! The window is maximized to fill the screen horizontally */
239     gboolean max_horz;
240     /*! The window should not be displayed by pagers */
241     gboolean skip_pager;
242     /*! The window should not be displayed by taskbars */
243     gboolean skip_taskbar;
244     /*! The window is a 'fullscreen' window, and should be on top of all
245       others */
246     gboolean fullscreen;
247     /*! The window should be on top of other windows of the same type.
248       above takes priority over below. */
249     gboolean above;
250     /*! The window should be underneath other windows of the same type.
251       above takes priority over below. */
252     gboolean below;
253
254     /*! The layer in which the window will be stacked, windows in lower layers
255       are always below windows in higher layers. */
256     StackLayer layer;
257
258     /*! A bitmask of values in the Decoration enum
259       The values in the variable are the decorations that the client wants to
260       be displayed around it.
261     */
262     int decorations;
263
264     /*! A bitmask of values in the Decoration enum.
265       Specifies the decorations that should NOT be displayed on the client.
266     */
267     int disabled_decorations;
268
269     /*! A bitmask of values in the Function enum
270       The values in the variable specify the ways in which the user is allowed
271       to modify this window.
272     */
273     int functions;
274
275     /*! Saved decorations from before becoming fullscreen */
276     int pre_fs_decor;
277
278     /*! Saved functions from before becoming fullscreen */
279     int pre_fs_func;
280
281     /*! Icons for the client as specified on the client window */
282     Icon *icons;
283     /*! The number of icons in icons */
284     int nicons;
285
286     /*! The icon for the client specified in the WMHints or the KWM hints */
287     Pixmap pixmap_icon;
288     /*! The mask for the pixmap_icon, or None if its not masked */
289     Pixmap pixmap_icon_mask;
290 } Client;
291
292 extern GList *client_list;
293 extern GHashTable *client_map;
294
295 void client_startup();
296 void client_shutdown();
297
298 /*! Manages all existing windows */
299 void client_manage_all();
300 /*! Manages a given window */
301 void client_manage(Window win);
302 /*! Unmanages all managed windows */
303 void client_unmanage_all();
304 /*! Unmanages a given client */
305 void client_unmanage(Client *client);
306
307 /*! Sets the client list on the root window from the client_list */
308 void client_set_list();
309
310 /*! Reapplies the maximized state to the window
311   Use this to make the window readjust its maximized size to new
312   surroundings (struts, etc). */
313 void client_remaximize(Client *self);
314
315 /*! Determines if the client should be shown or hidden currently.
316   @return TRUE if it should be visible; otherwise, FALSE.
317 */
318 gboolean client_should_show(Client *self);
319
320 /*! Returns if the window should be treated as a normal window.
321   Some windows (desktops, docks, splash screens) have special rules applied
322   to them in a number of places regarding focus or user interaction. */
323 gboolean client_normal(Client *self);
324
325 /* Returns if the window is focused */
326 gboolean client_focused(Client *self);
327
328 /*! Move and/or resize the window.
329   This also maintains things like the client's minsize, and size increments.
330   @param anchor The corner to keep in the same position when resizing.
331   @param x The x coordiante of the new position for the client.
332   @param y The y coordiante of the new position for the client.
333   @param w The width component of the new size for the client.
334   @param h The height component of the new size for the client.
335   @param user Specifies whether this is a user-requested change or a
336               program requested change. For program requested changes, the
337               constraints are not checked.
338   @param final If user is true, then this should specify if this is a final
339                configuration. e.g. Final should be FALSE if doing an
340                interactive move/resize, and then be TRUE for the last call
341                only.
342 */
343 void client_configure(Client *self, Corner anchor, int x, int y, int w, int h,
344                       gboolean user, gboolean final);
345
346 /*! Fullscreen's or unfullscreen's the client window
347   @param fs true if the window should be made fullscreen; false if it should
348             be returned to normal state.
349   @param savearea true to have the client's current size and position saved;
350                   otherwise, they are not. You should not save when mapping a
351                   new window that is set to fullscreen. This has no effect
352                   when restoring a window from fullscreen.
353 */
354 void client_fullscreen(Client *self, gboolean fs, gboolean savearea);
355
356 /*! Iconifies or uniconifies the client window
357   @param iconic true if the window should be iconified; false if it should be
358                 restored.
359   @param curdesk If iconic is FALSE, then this determines if the window will
360                  be uniconified to the current viewable desktop (true) or to
361                  its previous desktop (false)
362 */
363 void client_iconify(Client *self, gboolean iconic, gboolean curdesk);
364
365 /*! Maximize or unmaximize the client window
366   @param max true if the window should be maximized; false if it should be
367              returned to normal size.
368   @param dir 0 to set both horz and vert, 1 to set horz, 2 to set vert.
369   @param savearea true to have the client's current size and position saved;
370                   otherwise, they are not. You should not save when mapping a
371                   new window that is set to fullscreen. This has no effect
372                   when unmaximizing a window.
373 */
374 void client_maximize(Client *self, gboolean max, int dir,
375                      gboolean savearea);
376
377 /*! Shades or unshades the client window
378   @param shade true if the window should be shaded; false if it should be
379                unshaded.
380 */
381 void client_shade(Client *self, gboolean shade);
382
383 /*! Request the client to close its window */
384 void client_close(Client *self);
385
386 /*! Kill the client off violently */
387 void client_kill(Client *self);
388
389 /*! Sends the window to the specified desktop
390   @param donthide If TRUE, the window will not be shown/hidden after its
391          desktop has been changed. Generally this should be FALSE. */
392 void client_set_desktop(Client *self, guint target, gboolean donthide);
393
394 /*! Return a modal child of the client window
395     @return A modal child of the client window, or 0 if none was found.
396 */
397 Client *client_find_modal_child(Client *self);
398
399 /*! Validate client, by making sure no Destroy or Unmap events exist in
400   the event queue for the window.
401   @return true if the client is valid; false if the client has already
402           been unmapped/destroyed, and so is invalid.
403 */
404 gboolean client_validate(Client *self);
405
406 /*! Sets the wm_state to the specified value */
407 void client_set_wm_state(Client *self, long state);
408
409 /*! Adjusts the window's net_state
410   This should not be called as part of the window mapping process! It is for
411   use when updating the state post-mapping.<br>
412   client_apply_startup_state is used to do the same things during the mapping
413   process.
414 */
415 void client_set_state(Client *self, Atom action, long data1, long data2);
416
417 /* Given a Client, find the client that focus would actually be sent to if
418    you wanted to give focus to the specified Client. Will return the same
419    Client passed to it or another Client if appropriate. */
420 Client *client_focus_target(Client *self);
421
422 /* Returns if a client can be focused or not */
423 gboolean client_focusable(Client *self);
424
425 /*! Attempt to focus the client window */
426 gboolean client_focus(Client *self);
427
428 /*! Remove focus from the client window */
429 void client_unfocus(Client *self);
430
431 /*! Calculates the stacking layer for the client window */
432 void client_calc_layer(Client *self);
433
434 /*! Updates the window's transient status, and any parents of it */
435 void client_update_transient_for(Client *self);
436 /*! Update the protocols that the window supports and adjusts things if they
437   change */
438 void client_update_protocols(Client *self);
439 /*! Updates the WMNormalHints and adjusts things if they change */
440 void client_update_normal_hints(Client *self);
441
442 /*! Updates the WMHints and adjusts things if they change
443   @param initstate Whether to read the initial_state property from the
444                    WMHints. This should only be used during the mapping
445                    process.
446 */
447 void client_update_wmhints(Client *self);
448 /*! Updates the window's title */
449 void client_update_title(Client *self);
450 /*! Updates the window's icon title */
451 void client_update_icon_title(Client *self);
452 /*! Updates the window's application name and class */
453 void client_update_class(Client *self);
454 /*! Updates the strut for the client */
455 void client_update_strut(Client *self);
456 /*! Updates the window's icons */
457 void client_update_icons(Client *self);
458 /*! Updates the window's kwm icon */
459 void client_update_kwm_icon(Client *self);
460
461 /*! Set up what decor should be shown on the window and what functions should
462   be allowed (Client::decorations and Client::functions).
463   This also updates the NET_WM_ALLOWED_ACTIONS hint.
464 */
465 void client_setup_decor_and_functions(Client *self);
466
467 /*! Retrieves the window's type and sets Client->type */
468 void client_get_type(Client *self);
469
470 Icon *client_icon(Client *self, int w, int h);
471
472 #endif