]> Dogcows Code - chaz/openbox/blob - openbox/client.h
4d6ee56c6d9aef95e160aab234cd37bd85415b07
[chaz/openbox] / 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 _ObFrame;
14 struct _ObGroup;
15 struct _ObSessionState;
16
17 typedef struct _ObClient ObClient;
18 typedef struct _ObClientIcon ObClientIcon;
19
20 /* The value in client.transient_for indicating it is a transient for its
21 group instead of for a single window */
22 #define OB_TRAN_GROUP ((void*)~0l)
23
24 /*! Holds an icon in ARGB format */
25 struct _ObClientIcon
26 {
27 gint width;
28 gint height;
29 RrPixel32 *data;
30 };
31
32 /*! Possible window types */
33 typedef enum
34 {
35 OB_CLIENT_TYPE_DESKTOP, /*!< A desktop (bottom-most window) */
36 OB_CLIENT_TYPE_DOCK, /*!< A dock bar/panel window */
37 OB_CLIENT_TYPE_TOOLBAR, /*!< A toolbar window, pulled off an app */
38 OB_CLIENT_TYPE_MENU, /*!< An unpinned menu from an app */
39 OB_CLIENT_TYPE_UTILITY, /*!< A small utility window such as a palette */
40 OB_CLIENT_TYPE_SPLASH, /*!< A splash screen window */
41 OB_CLIENT_TYPE_DIALOG, /*!< A dialog window */
42 OB_CLIENT_TYPE_NORMAL /*!< A normal application window */
43 } ObClientType;
44
45 /*! The things the user can do to the client window */
46 typedef enum
47 {
48 OB_CLIENT_FUNC_RESIZE = 1 << 0, /*!< Allow user resizing */
49 OB_CLIENT_FUNC_MOVE = 1 << 1, /*!< Allow user moving */
50 OB_CLIENT_FUNC_ICONIFY = 1 << 2, /*!< Allow to be iconified */
51 OB_CLIENT_FUNC_MAXIMIZE = 1 << 3, /*!< Allow to be maximized */
52 OB_CLIENT_FUNC_SHADE = 1 << 4, /*!< Allow to be shaded */
53 OB_CLIENT_FUNC_FULLSCREEN = 1 << 5, /*!< Allow to be made fullscreen */
54 OB_CLIENT_FUNC_CLOSE = 1 << 6 /*!< Allow to be closed */
55 } ObFunctions;
56
57 struct _ObClient
58 {
59 ObWindow obwin;
60
61 Window window;
62
63 /*! The window's decorations. NULL while the window is being managed! */
64 struct _ObFrame *frame;
65
66 /*! The number of unmap events to ignore on the window */
67 int ignore_unmaps;
68
69 /*! The id of the group the window belongs to */
70 struct _ObGroup *group;
71
72 /*! Saved session data to apply to this client */
73 struct _ObSessionState *session;
74
75 /*! Whether or not the client is a transient window. This is guaranteed to
76 be TRUE if transient_for != NULL, but not guaranteed to be FALSE if
77 transient_for == NULL. */
78 gboolean transient;
79 /*! The client which this client is a transient (child) for.
80 A value of TRAN_GROUP signifies that the window is a transient for all
81 members of its ObGroup, and is not a valid pointer to be followed in this
82 case.
83 */
84 ObClient *transient_for;
85 /*! The clients which are transients (children) of this client */
86 GSList *transients;
87 /*! The desktop on which the window resides (0xffffffff for all
88 desktops) */
89 guint desktop;
90
91 /*! The startup id for the startup-notification protocol. This will be
92 NULL if a startup id is not set. */
93 gchar *startup_id;
94
95 /*! Normal window title */
96 gchar *title;
97 /*! The count for the title. When another window with the same title
98 exists, a count will be appended to it. */
99 guint title_count;
100 /*! Window title when iconified */
101 gchar *icon_title;
102
103 /*! The application that created the window */
104 gchar *name;
105 /*! The class of the window, can used for grouping */
106 gchar *class;
107 /*! The specified role of the window, used for identification */
108 gchar *role;
109 /*! The session client id for the window. *This can be NULL!* */
110 gchar *sm_client_id;
111
112 /*! The type of window (what its function is) */
113 ObClientType type;
114
115 /*! Position and size of the window
116 This will not always be the actual position of the window on screen, it
117 is, rather, the position requested by the client, to which the window's
118 gravity is applied.
119 */
120 Rect area;
121
122 /*! The window's strut
123 The strut defines areas of the screen that are marked off-bounds for
124 window placement. In theory, where this window exists.
125 */
126 StrutPartial strut;
127
128 /*! The logical size of the window
129 The "logical" size of the window is refers to the user's perception of
130 the size of the window, and is the value that should be displayed to the
131 user. For example, with xterms, this value it the number of characters
132 being displayed in the terminal, instead of the number of pixels.
133 */
134 Size logical_size;
135
136 /*! Width of the border on the window.
137 The window manager will set this to 0 while the window is being managed,
138 but needs to restore it afterwards, so it is saved here.
139 */
140 guint border_width;
141
142 /*! The minimum aspect ratio the client window can be sized to.
143 A value of 0 means this is ignored.
144 */
145 float min_ratio;
146 /*! The maximum aspect ratio the client window can be sized to.
147 A value of 0 means this is ignored.
148 */
149 float max_ratio;
150
151 /*! The minimum size of the client window
152 If the min is > the max, then the window is not resizable
153 */
154 Size min_size;
155 /*! The maximum size of the client window
156 If the min is > the max, then the window is not resizable
157 */
158 Size max_size;
159 /*! The size of increments to resize the client window by */
160 Size size_inc;
161 /*! The base size of the client window
162 This value should be subtracted from the window's actual size when
163 displaying its size to the user, or working with its min/max size
164 */
165 Size base_size;
166
167 /*! Window decoration and functionality hints */
168 ObMwmHints mwmhints;
169
170 /*! Where to place the decorated window in relation to the undecorated
171 window */
172 int gravity;
173
174 /*! The state of the window, one of WithdrawnState, IconicState, or
175 NormalState */
176 long wmstate;
177
178 /*! True if the client supports the delete_window protocol */
179 gboolean delete_window;
180
181 /*! Was the window's position requested by the application? if not, we
182 should place the window ourselves when it first appears */
183 gboolean positioned;
184
185 /*! Can the window receive input focus? */
186 gboolean can_focus;
187 /*! Urgency flag */
188 gboolean urgent;
189 /*! Notify the window when it receives focus? */
190 gboolean focus_notify;
191
192 /*! The window uses shape extension to be non-rectangular? */
193 gboolean shaped;
194
195 /*! The window is modal, so it must be processed before any windows it is
196 related to can be focused */
197 gboolean modal;
198 /*! Only the window's titlebar is displayed */
199 gboolean shaded;
200 /*! The window is iconified */
201 gboolean iconic;
202 /*! The window is maximized to fill the screen vertically */
203 gboolean max_vert;
204 /*! The window is maximized to fill the screen horizontally */
205 gboolean max_horz;
206 /*! The window should not be displayed by pagers */
207 gboolean skip_pager;
208 /*! The window should not be displayed by taskbars */
209 gboolean skip_taskbar;
210 /*! The window is a 'fullscreen' window, and should be on top of all
211 others */
212 gboolean fullscreen;
213 /*! The window should be on top of other windows of the same type.
214 above takes priority over below. */
215 gboolean above;
216 /*! The window should be underneath other windows of the same type.
217 above takes priority over below. */
218 gboolean below;
219
220 /*! The layer in which the window will be stacked, windows in lower layers
221 are always below windows in higher layers. */
222 ObStackingLayer layer;
223
224 /*! A bitmask of values in the ObFrameDecorations enum
225 The values in the variable are the decorations that the client wants to
226 be displayed around it.
227 */
228 guint decorations;
229
230 /*! A user option. When this is set to FALSE the client will not ever
231 be decorated.
232 */
233 gboolean decorate;
234
235 /*! A bitmask of values in the ObFunctions enum
236 The values in the variable specify the ways in which the user is allowed
237 to modify this window.
238 */
239 guint functions;
240
241 /*! Icons for the client as specified on the client window */
242 ObClientIcon *icons;
243 /*! The number of icons in icons */
244 guint nicons;
245 };
246
247 extern GList *client_list;
248
249 void client_startup(gboolean reconfig);
250 void client_shutdown(gboolean reconfig);
251
252 void client_add_destructor(GDestroyNotify func);
253 void client_remove_destructor(GDestroyNotify func);
254
255 /*! Manages all existing windows */
256 void client_manage_all();
257 /*! Manages a given window */
258 void client_manage(Window win);
259 /*! Unmanages all managed windows */
260 void client_unmanage_all();
261 /*! Unmanages a given client */
262 void client_unmanage(ObClient *client);
263
264 /*! Sets the client list on the root window from the client_list */
265 void client_set_list();
266
267 /*! Determines if the client should be shown or hidden currently.
268 @return TRUE if it should be visible; otherwise, FALSE.
269 */
270 gboolean client_should_show(ObClient *self);
271
272 /*! Returns if the window should be treated as a normal window.
273 Some windows (desktops, docks, splash screens) have special rules applied
274 to them in a number of places regarding focus or user interaction. */
275 gboolean client_normal(ObClient *self);
276
277 /* Returns if the window is focused */
278 gboolean client_focused(ObClient *self);
279
280 #define client_move(self, x, y) \
281 client_configure(self, OB_CORNER_TOPLEFT, x, y, \
282 self->area.width, self->area.height, \
283 TRUE, TRUE)
284 #define client_resize(self, w, h) \
285 client_configure(self, OB_CORNER_TOPLEFT, self->area.x, self->area.y, \
286 w, h, TRUE, TRUE)
287 #define client_move_resize(self, x, y, w, h) \
288 client_configure(self, OB_CORNER_TOPLEFT, x, y, w, h, TRUE, TRUE)
289
290 #define client_configure(self, anchor, x, y, w, h, user, final) \
291 client_configure_full(self, anchor, x, y, w, h, user, final, FALSE)
292
293 /*! Move and/or resize the window.
294 This also maintains things like the client's minsize, and size increments.
295 @param anchor The corner to keep in the same position when resizing.
296 @param x The x coordiante of the new position for the client.
297 @param y The y coordiante of the new position for the client.
298 @param w The width component of the new size for the client.
299 @param h The height component of the new size for the client.
300 @param user Specifies whether this is a user-requested change or a
301 program requested change. For program requested changes, the
302 constraints are not checked.
303 @param final If user is true, then this should specify if this is a final
304 configuration. e.g. Final should be FALSE if doing an
305 interactive move/resize, and then be TRUE for the last call
306 only.
307 @param force_reply Send a ConfigureNotify to the client regardless of if
308 the position changed.
309 */
310 void client_configure_full(ObClient *self, ObCorner anchor,
311 int x, int y, int w, int h,
312 gboolean user, gboolean final,
313 gboolean force_reply);
314
315 void client_reconfigure(ObClient *self);
316
317 /*! Finds coordinates to keep a client on the screen.
318 @param self The client
319 @param x The x coord of the client, may be changed.
320 @param y The y coord of the client, may be changed.
321 @param w The width of the client.
322 @param w The height of the client.
323 @param rude Be rude about it. If false, it is only moved if it is entirely
324 not visible. If true, then make sure the window is inside the
325 struts if possible.
326 @return true if the client was moved to be on-screen; false if not.
327 */
328 gboolean client_find_onscreen(ObClient *self, int *x, int *y, int w, int h,
329 gboolean rude);
330
331 /*! Moves a client so that it is on screen if it is entirely out of the
332 viewable screen.
333 @param self The client to move
334 @param rude Be rude about it. If false, it is only moved if it is entirely
335 not visible. If true, then make sure the window is inside the
336 struts if possible.
337 */
338 void client_move_onscreen(ObClient *self, gboolean rude);
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(ObClient *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(ObClient *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(ObClient *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(ObClient *self, gboolean shade);
376
377 /*! Request the client to close its window */
378 void client_close(ObClient *self);
379
380 /*! Kill the client off violently */
381 void client_kill(ObClient *self);
382
383 /*! Sends the window to the specified desktop
384 @param donthide If TRUE, the window will not be shown/hidden after its
385 desktop has been changed. Generally this should be FALSE. */
386 void client_set_desktop(ObClient *self, guint target, gboolean donthide);
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(ObClient *self);
394
395 /*! Sets the wm_state to the specified value */
396 void client_set_wm_state(ObClient *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(ObClient *self, Atom action, long data1, long data2);
405
406 /* Given a ObClient, find the client that focus would actually be sent to if
407 you wanted to give focus to the specified ObClient. Will return the same
408 ObClient passed to it or another ObClient if appropriate. */
409 ObClient *client_focus_target(ObClient *self);
410
411 /*! Returns what client_focus would return if passed the same client, but
412 without focusing it or modifying the focus order lists. */
413 gboolean client_can_focus(ObClient *self);
414
415 /*! Attempt to focus the client window */
416 gboolean client_focus(ObClient *self);
417
418 /*! Remove focus from the client window */
419 void client_unfocus(ObClient *self);
420
421 /*! Activates the client for use, focusing, uniconifying it, etc. To be used
422 when the user deliberately selects a window for use.
423 @param here If true, then the client is brought to the current desktop;
424 otherwise, the desktop is changed to where the client lives.
425 */
426 void client_activate(ObClient *self, gboolean here);
427
428 /*! Calculates the stacking layer for the client window */
429 void client_calc_layer(ObClient *self);
430
431 /*! Updates the window's transient status, and any parents of it */
432 void client_update_transient_for(ObClient *self);
433 /*! Update the protocols that the window supports and adjusts things if they
434 change */
435 void client_update_protocols(ObClient *self);
436 /*! Updates the WMNormalHints and adjusts things if they change */
437 void client_update_normal_hints(ObClient *self);
438
439 /*! Updates the WMHints and adjusts things if they change
440 @param initstate Whether to read the initial_state property from the
441 WMHints. This should only be used during the mapping
442 process.
443 */
444 void client_update_wmhints(ObClient *self);
445 /*! Updates the window's title and icon title */
446 void client_update_title(ObClient *self);
447 /*! Updates the window's application name and class */
448 void client_update_class(ObClient *self);
449 /*! Updates the strut for the client */
450 void client_update_strut(ObClient *self);
451 /*! Updates the window's icons */
452 void client_update_icons(ObClient *self);
453
454 /*! Set up what decor should be shown on the window and what functions should
455 be allowed (ObClient::decorations and ObClient::functions).
456 This also updates the NET_WM_ALLOWED_ACTIONS hint.
457 */
458 void client_setup_decor_and_functions(ObClient *self);
459
460 /*! Retrieves the window's type and sets ObClient->type */
461 void client_get_type(ObClient *self);
462
463 ObClientIcon *client_icon(ObClient *self, int w, int h);
464
465 /*! Searches a client's transients for a focused window. The function does not
466 check for the passed client, only for its transients.
467 If no focused transient is found, NULL is returned.
468 */
469 ObClient *client_search_focus_tree(ObClient *self);
470
471 /*! Searches a client's transient tree for a focused window. The function
472 searches up the tree and down other branches as well as the passed client's.
473 If no focused client is found, NULL is returned.
474 */
475 ObClient *client_search_focus_tree_full(ObClient *self);
476
477 /*! Return a modal child of the client window that can be focused.
478 @return A modal child of the client window that can be focused, or 0 if
479 none was found.
480 */
481 ObClient *client_search_modal_child(ObClient *self);
482
483 ObClient *client_search_top_transient(ObClient *self);
484
485 ObClient *client_search_transient(ObClient *self, ObClient *search);
486
487 /*! Return the "closest" client in the given direction */
488 ObClient *client_find_directional(ObClient *c, ObDirection dir);
489
490 /*! Return the closest edge in the given direction */
491 int client_directional_edge_search(ObClient *c, ObDirection dir);
492
493 /*! Set a client window to be above/below other clients.
494 @layer < 0 indicates the client should be placed below other clients.<br>
495 = 0 indicates the client should be placed with other clients.<br>
496 > 0 indicates the client should be placed above other clients.
497 */
498 void client_set_layer(ObClient *self, int layer);
499
500 guint client_monitor(ObClient *self);
501
502 void client_update_sm_client_id(ObClient *self);
503
504 #endif
This page took 0.06158 seconds and 4 git commands to generate.