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