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