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