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