1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 client.c for the Openbox window manager
4 Copyright (c) 2006 Mikael Magnusson
5 Copyright (c) 2003-2007 Dana Jansens
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 See the COPYING file for a copy of the GNU General Public License.
22 #include "startupnotify.h"
26 #include "moveresize.h"
29 #include "extensions.h"
39 #include "menuframe.h"
42 #include "render/render.h"
49 #include <X11/Xutil.h>
51 /*! The event mask to grab on client windows */
52 #define CLIENT_EVENTMASK (PropertyChangeMask | StructureNotifyMask | \
55 #define CLIENT_NOPROPAGATEMASK (ButtonPressMask | ButtonReleaseMask | \
60 ObClientDestructor func
;
64 GList
*client_list
= NULL
;
66 static GSList
*client_destructors
= NULL
;
68 static void client_get_all(ObClient
*self
);
69 static void client_toggle_border(ObClient
*self
, gboolean show
);
70 static void client_get_startup_id(ObClient
*self
);
71 static void client_get_area(ObClient
*self
);
72 static void client_get_desktop(ObClient
*self
);
73 static void client_get_state(ObClient
*self
);
74 static void client_get_layer(ObClient
*self
);
75 static void client_get_shaped(ObClient
*self
);
76 static void client_get_mwm_hints(ObClient
*self
);
77 static void client_get_gravity(ObClient
*self
);
78 static void client_get_client_machine(ObClient
*self
);
79 static void client_get_colormap(ObClient
*self
);
80 static void client_get_transientness(ObClient
*self
);
81 static void client_change_allowed_actions(ObClient
*self
);
82 static void client_change_state(ObClient
*self
);
83 static void client_change_wm_state(ObClient
*self
);
84 static void client_apply_startup_state(ObClient
*self
, gint x
, gint y
);
85 static void client_restore_session_state(ObClient
*self
);
86 static void client_restore_session_stacking(ObClient
*self
);
87 static ObAppSettings
*client_get_settings_state(ObClient
*self
);
88 static void client_update_transient_tree(ObClient
*self
,
89 ObGroup
*oldgroup
, ObGroup
*newgroup
,
93 void client_startup(gboolean reconfig
)
100 void client_shutdown(gboolean reconfig
)
104 void client_add_destructor(ObClientDestructor func
, gpointer data
)
106 Destructor
*d
= g_new(Destructor
, 1);
109 client_destructors
= g_slist_prepend(client_destructors
, d
);
112 void client_remove_destructor(ObClientDestructor func
)
116 for (it
= client_destructors
; it
; it
= g_slist_next(it
)) {
117 Destructor
*d
= it
->data
;
118 if (d
->func
== func
) {
120 client_destructors
= g_slist_delete_link(client_destructors
, it
);
126 void client_set_list()
128 Window
*windows
, *win_it
;
130 guint size
= g_list_length(client_list
);
132 /* create an array of the window ids */
134 windows
= g_new(Window
, size
);
136 for (it
= client_list
; it
; it
= g_list_next(it
), ++win_it
)
137 *win_it
= ((ObClient
*)it
->data
)->window
;
141 PROP_SETA32(RootWindow(ob_display
, ob_screen
),
142 net_client_list
, window
, (gulong
*)windows
, size
);
151 void client_foreach_transient(ObClient *self, ObClientForeachFunc func, gpointer data)
155 for (it = self->transients; it; it = g_slist_next(it)) {
156 if (!func(it->data, data)) return;
157 client_foreach_transient(it->data, func, data);
161 void client_foreach_ancestor(ObClient *self, ObClientForeachFunc func, gpointer data)
163 if (self->transient_for) {
164 if (self->transient_for != OB_TRAN_GROUP) {
165 if (!func(self->transient_for, data)) return;
166 client_foreach_ancestor(self->transient_for, func, data);
170 for (it = self->group->members; it; it = g_slist_next(it))
171 if (it->data != self &&
172 !((ObClient*)it->data)->transient_for) {
173 if (!func(it->data, data)) return;
174 client_foreach_ancestor(it->data, func, data);
181 void client_manage_all()
186 XWindowAttributes attrib
;
188 XQueryTree(ob_display
, RootWindow(ob_display
, ob_screen
),
189 &w
, &w
, &children
, &nchild
);
191 /* remove all icon windows from the list */
192 for (i
= 0; i
< nchild
; i
++) {
193 if (children
[i
] == None
) continue;
194 wmhints
= XGetWMHints(ob_display
, children
[i
]);
196 if ((wmhints
->flags
& IconWindowHint
) &&
197 (wmhints
->icon_window
!= children
[i
]))
198 for (j
= 0; j
< nchild
; j
++)
199 if (children
[j
] == wmhints
->icon_window
) {
207 for (i
= 0; i
< nchild
; ++i
) {
208 if (children
[i
] == None
)
210 if (XGetWindowAttributes(ob_display
, children
[i
], &attrib
)) {
211 if (attrib
.override_redirect
) continue;
213 if (attrib
.map_state
!= IsUnmapped
)
214 client_manage(children
[i
]);
220 void client_manage(Window window
)
224 XWindowAttributes attrib
;
225 XSetWindowAttributes attrib_set
;
227 gboolean activate
= FALSE
;
228 ObAppSettings
*settings
;
233 /* check if it has already been unmapped by the time we started mapping.
234 the grab does a sync so we don't have to here */
235 if (XCheckTypedWindowEvent(ob_display
, window
, DestroyNotify
, &e
) ||
236 XCheckTypedWindowEvent(ob_display
, window
, UnmapNotify
, &e
))
238 XPutBackEvent(ob_display
, &e
);
240 ob_debug("Trying to manage unmapped window. Aborting that.\n");
242 return; /* don't manage it */
245 /* make sure it isn't an override-redirect window */
246 if (!XGetWindowAttributes(ob_display
, window
, &attrib
) ||
247 attrib
.override_redirect
)
250 return; /* don't manage it */
253 /* is the window a docking app */
254 if ((wmhint
= XGetWMHints(ob_display
, window
))) {
255 if ((wmhint
->flags
& StateHint
) &&
256 wmhint
->initial_state
== WithdrawnState
)
258 dock_add(window
, wmhint
);
266 ob_debug("Managing window: %lx\n", window
);
268 /* choose the events we want to receive on the CLIENT window */
269 attrib_set
.event_mask
= CLIENT_EVENTMASK
;
270 attrib_set
.do_not_propagate_mask
= CLIENT_NOPROPAGATEMASK
;
271 XChangeWindowAttributes(ob_display
, window
,
272 CWEventMask
|CWDontPropagate
, &attrib_set
);
275 /* create the ObClient struct, and populate it from the hints on the
277 self
= g_new0(ObClient
, 1);
278 self
->obwin
.type
= Window_Client
;
279 self
->window
= window
;
281 /* non-zero defaults */
282 self
->wmstate
= WithdrawnState
; /* make sure it gets updated first time */
284 self
->desktop
= screen_num_desktops
; /* always an invalid value */
285 self
->user_time
= focus_client
? focus_client
->user_time
: CurrentTime
;
287 client_get_all(self
);
288 /* per-app settings override stuff, and return the settings for other
290 settings
= client_get_settings_state(self
);
291 /* the session should get the last say */
292 client_restore_session_state(self
);
294 client_calc_layer(self
);
297 Time t
= sn_app_started(self
->startup_id
, self
->class);
298 if (t
) self
->user_time
= t
;
301 /* update the focus lists, do this before the call to change_state or
302 it can end up in the list twice! */
303 focus_order_add_new(self
);
305 /* remove the client's border (and adjust re gravity) */
306 client_toggle_border(self
, FALSE
);
308 /* specify that if we exit, the window should not be destroyed and should
309 be reparented back to root automatically */
310 XChangeSaveSet(ob_display
, window
, SetModeInsert
);
312 /* create the decoration frame for the client window */
313 self
->frame
= frame_new(self
);
315 frame_grab_client(self
->frame
, self
);
317 /* do this after we have a frame.. it uses the frame to help determine the
318 WM_STATE to apply. */
319 client_change_state(self
);
323 stacking_add_nonintrusive(CLIENT_AS_WINDOW(self
));
324 client_restore_session_stacking(self
);
326 /* focus the new window? */
327 if (ob_state() != OB_STATE_STARTING
&&
329 /* this means focus=true for window is same as config_focus_new=true */
330 ((config_focus_new
|| (settings
&& settings
->focus
== 1)) ||
331 client_search_focus_parent(self
)) &&
332 /* this checks for focus=false for the window */
333 (!settings
|| settings
->focus
!= 0) &&
334 /* note the check against Type_Normal/Dialog, not client_normal(self),
335 which would also include other types. in this case we want more
336 strict rules for focus */
337 (self
->type
== OB_CLIENT_TYPE_NORMAL
||
338 self
->type
== OB_CLIENT_TYPE_DIALOG
))
343 /* get the current position */
347 /* figure out placement for the window */
348 if (ob_state() == OB_STATE_RUNNING
) {
351 transient
= place_client(self
, &newx
, &newy
, settings
);
353 /* make sure the window is visible. */
354 client_find_onscreen(self
, &newx
, &newy
,
357 /* non-normal clients has less rules, and
358 windows that are being restored from a
359 session do also. we can assume you want
360 it back where you saved it. Clients saying
361 they placed themselves are subjected to
362 harder rules, ones that are placed by
363 place.c or by the user are allowed partially
364 off-screen and on xinerama divides (ie,
365 it is up to the placement routines to avoid
366 the xinerama divides) */
368 (((self
->positioned
& PPosition
) &&
369 !(self
->positioned
& USPosition
)) &&
370 client_normal(self
) &&
374 /* do this after the window is placed, so the premax/prefullscreen numbers
376 also, this moves the window to the position where it has been placed
378 ob_debug("placing window 0x%x at %d, %d with size %d x %d\n",
379 self
->window
, newx
, newy
, self
->area
.width
, self
->area
.height
);
380 client_apply_startup_state(self
, newx
, newy
);
382 mouse_grab_for_client(self
, TRUE
);
385 guint32 last_time
= focus_client
?
386 focus_client
->user_time
: CurrentTime
;
388 /* This is focus stealing prevention */
389 ob_debug_type(OB_DEBUG_FOCUS
,
390 "Want to focus new window 0x%x with time %u "
392 self
->window
, self
->user_time
, last_time
);
394 /* if it's on another desktop */
395 if (!(self
->desktop
== screen_desktop
|| self
->desktop
== DESKTOP_ALL
)
396 && /* the timestamp is from before you changed desktops */
397 self
->user_time
&& screen_desktop_user_time
&&
398 !event_time_after(self
->user_time
, screen_desktop_user_time
))
401 ob_debug_type(OB_DEBUG_FOCUS
,
402 "Not focusing the window because its on another "
405 /* If something is focused, and it's not our parent... */
406 else if (focus_client
&& client_search_focus_parent(self
) == NULL
)
408 /* If time stamp is old, don't steal focus */
409 if (self
->user_time
&& last_time
&&
410 !event_time_after(self
->user_time
, last_time
))
413 ob_debug_type(OB_DEBUG_FOCUS
,
414 "Not focusing the window because the time is "
417 /* Don't steal focus from globally active clients.
418 I stole this idea from KWin. It seems nice.
420 if (!(focus_client
->can_focus
|| focus_client
->focus_notify
)) {
422 ob_debug_type(OB_DEBUG_FOCUS
,
423 "Not focusing the window because a globally "
424 "active client has focus\n");
429 ob_debug_type(OB_DEBUG_FOCUS
,
430 "Focus stealing prevention activated for %s with "
431 "time %u (last time %u)\n",
432 self
->title
, self
->user_time
, last_time
);
433 /* if the client isn't focused, then hilite it so the user
435 client_hilite(self
, TRUE
);
439 /* This may look rather odd. Well it's because new windows are added
440 to the stacking order non-intrusively. If we're not going to focus
441 the new window or hilite it, then we raise it to the top. This will
442 take affect for things that don't get focused like splash screens.
443 Also if you don't have focus_new enabled, then it's going to get
444 raised to the top. Legacy begets legacy I guess?
449 /* this has to happen before we try focus the window, but we want it to
450 happen after the client's stacking has been determined or it looks bad
454 /* use client_focus instead of client_activate cuz client_activate does
455 stuff like switch desktops etc and I'm not interested in all that when
456 a window maps since its not based on an action from the user like
457 clicking a window to activate it. so keep the new window out of the way
460 client_activate(self
, FALSE
, TRUE
);
462 /* add to client list/map */
463 client_list
= g_list_append(client_list
, self
);
464 g_hash_table_insert(window_map
, &self
->window
, self
);
466 /* this has to happen after we're in the client_list */
467 if (STRUT_EXISTS(self
->strut
))
468 screen_update_areas();
470 /* update the list hints */
473 ob_debug("Managed window 0x%lx (%s)\n", window
, self
->class);
476 void client_unmanage_all()
478 while (client_list
!= NULL
)
479 client_unmanage(client_list
->data
);
482 void client_unmanage(ObClient
*self
)
487 ob_debug("Unmanaging window: %lx (%s) (%s)\n", self
->window
, self
->class,
488 self
->title
? self
->title
: "");
490 g_assert(self
!= NULL
);
492 /* we dont want events no more. do this before hiding the frame so we
493 don't generate more events */
494 XSelectInput(ob_display
, self
->window
, NoEventMask
);
496 frame_hide(self
->frame
);
497 /* flush to send the hide to the server quickly */
500 /* ignore enter events from the unmap so it doesnt mess with the focus */
501 event_ignore_queued_enters();
503 mouse_grab_for_client(self
, FALSE
);
505 /* remove the window from our save set */
506 XChangeSaveSet(ob_display
, self
->window
, SetModeDelete
);
508 /* update the focus lists */
509 focus_order_remove(self
);
510 if (client_focused(self
)) {
511 /* don't leave an invalid focus_client */
515 client_list
= g_list_remove(client_list
, self
);
516 stacking_remove(self
);
517 g_hash_table_remove(window_map
, &self
->window
);
519 /* once the client is out of the list, update the struts to remove its
521 if (STRUT_EXISTS(self
->strut
))
522 screen_update_areas();
524 for (it
= client_destructors
; it
; it
= g_slist_next(it
)) {
525 Destructor
*d
= it
->data
;
526 d
->func(self
, d
->data
);
529 /* tell our parent(s) that we're gone */
530 if (self
->transient_for
== OB_TRAN_GROUP
) { /* transient of group */
531 for (it
= self
->group
->members
; it
; it
= g_slist_next(it
))
532 if (it
->data
!= self
)
533 ((ObClient
*)it
->data
)->transients
=
534 g_slist_remove(((ObClient
*)it
->data
)->transients
, self
);
535 } else if (self
->transient_for
) { /* transient of window */
536 self
->transient_for
->transients
=
537 g_slist_remove(self
->transient_for
->transients
, self
);
540 /* tell our transients that we're gone */
541 for (it
= self
->transients
; it
; it
= g_slist_next(it
)) {
542 if (((ObClient
*)it
->data
)->transient_for
!= OB_TRAN_GROUP
) {
543 ((ObClient
*)it
->data
)->transient_for
= NULL
;
544 client_calc_layer(it
->data
);
548 /* remove from its group */
550 group_remove(self
->group
, self
);
554 /* restore the window's original geometry so it is not lost */
558 if (self
->fullscreen
)
559 a
= self
->pre_fullscreen_area
;
560 else if (self
->max_horz
|| self
->max_vert
) {
561 if (self
->max_horz
) {
562 a
.x
= self
->pre_max_area
.x
;
563 a
.width
= self
->pre_max_area
.width
;
565 if (self
->max_vert
) {
566 a
.y
= self
->pre_max_area
.y
;
567 a
.height
= self
->pre_max_area
.height
;
571 /* give the client its border back */
572 client_toggle_border(self
, TRUE
);
574 self
->fullscreen
= self
->max_horz
= self
->max_vert
= FALSE
;
575 self
->decorations
= 0; /* unmanaged windows have no decor */
577 client_move_resize(self
, a
.x
, a
.y
, a
.width
, a
.height
);
580 /* reparent the window out of the frame, and free the frame */
581 frame_release_client(self
->frame
, self
);
584 if (ob_state() != OB_STATE_EXITING
) {
585 /* these values should not be persisted across a window
587 PROP_ERASE(self
->window
, net_wm_desktop
);
588 PROP_ERASE(self
->window
, net_wm_state
);
589 PROP_ERASE(self
->window
, wm_state
);
591 /* if we're left in an unmapped state, the client wont be mapped. this
592 is bad, since we will no longer be managing the window on restart */
593 XMapWindow(ob_display
, self
->window
);
596 ob_debug("Unmanaged window 0x%lx\n", self
->window
);
598 /* free all data allocated in the client struct */
599 g_slist_free(self
->transients
);
600 for (j
= 0; j
< self
->nicons
; ++j
)
601 g_free(self
->icons
[j
].data
);
602 if (self
->nicons
> 0)
605 g_free(self
->icon_title
);
609 g_free(self
->client_machine
);
610 g_free(self
->sm_client_id
);
613 /* update the list hints */
617 static ObAppSettings
*client_get_settings_state(ObClient
*self
)
619 ObAppSettings
*settings
= NULL
;
622 for (it
= config_per_app_settings
; it
; it
= g_slist_next(it
)) {
623 ObAppSettings
*app
= it
->data
;
625 if ((app
->name
&& !app
->class && !strcmp(app
->name
, self
->name
))
626 || (app
->class && !app
->name
&& !strcmp(app
->class, self
->class))
627 || (app
->class && app
->name
&& !strcmp(app
->class, self
->class)
628 && !strcmp(app
->name
, self
->name
)))
630 ob_debug("Window matching: %s\n", app
->name
);
631 /* Match if no role was specified in the per app setting, or if the
632 * string matches the beginning of the role, since apps like to set
633 * the role to things like browser-window-23c4b2f */
635 || !strncmp(app
->role
, self
->role
, strlen(app
->role
)))
645 if (settings
->shade
!= -1)
646 self
->shaded
= !!settings
->shade
;
647 if (settings
->decor
!= -1)
648 self
->undecorated
= !settings
->decor
;
649 if (settings
->iconic
!= -1)
650 self
->iconic
= !!settings
->iconic
;
651 if (settings
->skip_pager
!= -1)
652 self
->skip_pager
= !!settings
->skip_pager
;
653 if (settings
->skip_taskbar
!= -1)
654 self
->skip_taskbar
= !!settings
->skip_taskbar
;
656 if (settings
->max_vert
!= -1)
657 self
->max_vert
= !!settings
->max_vert
;
658 if (settings
->max_horz
!= -1)
659 self
->max_horz
= !!settings
->max_horz
;
661 if (settings
->fullscreen
!= -1)
662 self
->fullscreen
= !!settings
->fullscreen
;
664 if (settings
->desktop
< screen_num_desktops
665 || settings
->desktop
== DESKTOP_ALL
)
666 self
->desktop
= settings
->desktop
;
668 if (settings
->layer
== -1) {
672 else if (settings
->layer
== 0) {
676 else if (settings
->layer
== 1) {
684 static void client_restore_session_state(ObClient
*self
)
688 if (!(it
= session_state_find(self
)))
691 self
->session
= it
->data
;
693 RECT_SET_POINT(self
->area
, self
->session
->x
, self
->session
->y
);
694 self
->positioned
= PPosition
;
695 if (self
->session
->w
> 0)
696 self
->area
.width
= self
->session
->w
;
697 if (self
->session
->h
> 0)
698 self
->area
.height
= self
->session
->h
;
699 XResizeWindow(ob_display
, self
->window
,
700 self
->area
.width
, self
->area
.height
);
702 self
->desktop
= (self
->session
->desktop
== DESKTOP_ALL
?
703 self
->session
->desktop
:
704 MIN(screen_num_desktops
- 1, self
->session
->desktop
));
705 PROP_SET32(self
->window
, net_wm_desktop
, cardinal
, self
->desktop
);
707 self
->shaded
= self
->session
->shaded
;
708 self
->iconic
= self
->session
->iconic
;
709 self
->skip_pager
= self
->session
->skip_pager
;
710 self
->skip_taskbar
= self
->session
->skip_taskbar
;
711 self
->fullscreen
= self
->session
->fullscreen
;
712 self
->above
= self
->session
->above
;
713 self
->below
= self
->session
->below
;
714 self
->max_horz
= self
->session
->max_horz
;
715 self
->max_vert
= self
->session
->max_vert
;
718 static void client_restore_session_stacking(ObClient
*self
)
722 if (!self
->session
) return;
724 it
= g_list_find(session_saved_state
, self
->session
);
725 for (it
= g_list_previous(it
); it
; it
= g_list_previous(it
)) {
728 for (cit
= client_list
; cit
; cit
= g_list_next(cit
))
729 if (session_state_cmp(it
->data
, cit
->data
))
732 client_calc_layer(self
);
733 stacking_below(CLIENT_AS_WINDOW(self
),
734 CLIENT_AS_WINDOW(cit
->data
));
740 void client_move_onscreen(ObClient
*self
, gboolean rude
)
742 gint x
= self
->area
.x
;
743 gint y
= self
->area
.y
;
744 if (client_find_onscreen(self
, &x
, &y
,
746 self
->area
.height
, rude
)) {
747 client_move(self
, x
, y
);
751 gboolean
client_find_onscreen(ObClient
*self
, gint
*x
, gint
*y
, gint w
, gint h
,
755 gint ox
= *x
, oy
= *y
;
756 gboolean rudel
= rude
, ruder
= rude
, rudet
= rude
, rudeb
= rude
;
759 all_a
= screen_area(self
->desktop
);
760 mon_a
= screen_area_monitor(self
->desktop
, client_monitor(self
));
762 /* get where the frame would be */
763 frame_client_gravity(self
->frame
, x
, y
, w
, h
);
765 /* get the requested size of the window with decorations */
766 fw
= self
->frame
->size
.left
+ w
+ self
->frame
->size
.right
;
767 fh
= self
->frame
->size
.top
+ h
+ self
->frame
->size
.bottom
;
769 /* This makes sure windows aren't entirely outside of the screen so you
770 can't see them at all.
771 It makes sure 10% of the window is on the screen at least. At don't let
772 it move itself off the top of the screen, which would hide the titlebar
773 on you. (The user can still do this if they want too, it's only limiting
776 XXX watch for xinerama dead areas...
778 if (client_normal(self
)) {
779 if (!self
->strut
.right
&& *x
+ fw
/10 >= all_a
->x
+ all_a
->width
- 1)
780 *x
= all_a
->x
+ all_a
->width
- fw
/10;
781 if (!self
->strut
.bottom
&& *y
+ fh
/10 >= all_a
->y
+ all_a
->height
- 1)
782 *y
= all_a
->y
+ all_a
->height
- fh
/10;
783 if (!self
->strut
.left
&& *x
+ fw
*9/10 - 1 < all_a
->x
)
784 *x
= all_a
->x
- fw
*9/10;
785 if (!self
->strut
.top
&& *y
+ fh
*9/10 - 1 < all_a
->y
)
786 *y
= all_a
->y
- fw
*9/10;
789 /* If rudeness wasn't requested, then figure out of the client is currently
790 entirely on the screen. If it is, and the position isn't changing by
791 request, and it is enlarging, then be rude even though it wasn't
794 Point oldtl
, oldtr
, oldbl
, oldbr
;
795 Point newtl
, newtr
, newbl
, newbr
;
798 POINT_SET(oldtl
, self
->frame
->area
.x
, self
->frame
->area
.y
);
799 POINT_SET(oldbr
, self
->frame
->area
.x
+ self
->frame
->area
.width
- 1,
800 self
->frame
->area
.y
+ self
->frame
->area
.height
- 1);
801 POINT_SET(oldtr
, oldbr
.x
, oldtl
.y
);
802 POINT_SET(oldbl
, oldtl
.x
, oldbr
.y
);
804 POINT_SET(newtl
, *x
, *y
);
805 POINT_SET(newbr
, *x
+ fw
- 1, *y
+ fh
- 1);
806 POINT_SET(newtr
, newbr
.x
, newtl
.y
);
807 POINT_SET(newbl
, newtl
.x
, newbr
.y
);
809 /* is it moving or just resizing from some corner? */
810 stationary
= (POINT_EQUAL(oldtl
, newtl
) || POINT_EQUAL(oldtr
, newtr
) ||
811 POINT_EQUAL(oldbl
, newbl
) || POINT_EQUAL(oldbr
, newbr
));
813 /* if left edge is growing */
814 if (stationary
&& newtl
.x
< oldtl
.x
)
816 /* if right edge is growing */
817 if (stationary
&& newtr
.x
> oldtr
.x
)
819 /* if top edge is growing */
820 if (stationary
&& newtl
.y
< oldtl
.y
)
822 /* if bottom edge is growing */
823 if (stationary
&& newbl
.y
> oldbl
.y
)
827 /* This here doesn't let windows even a pixel outside the struts/screen.
828 * When called from client_manage, programs placing themselves are
829 * forced completely onscreen, while things like
830 * xterm -geometry resolution-width/2 will work fine. Trying to
831 * place it completely offscreen will be handled in the above code.
832 * Sorry for this confused comment, i am tired. */
833 if (fw
<= mon_a
->width
) {
834 if (rudel
&& !self
->strut
.left
&& *x
< mon_a
->x
) *x
= mon_a
->x
;
835 if (ruder
&& !self
->strut
.right
&& *x
+ fw
> mon_a
->x
+ mon_a
->width
)
836 *x
= mon_a
->x
+ mon_a
->width
- fw
;
838 if (fh
<= mon_a
->height
) {
839 if (rudet
&& !self
->strut
.top
&& *y
< mon_a
->y
) *y
= mon_a
->y
;
840 if (rudeb
&& !self
->strut
.bottom
&& *y
+ fh
> mon_a
->y
+ mon_a
->height
)
841 *y
= mon_a
->y
+ mon_a
->height
- fh
;
844 /* get where the client should be */
845 frame_frame_gravity(self
->frame
, x
, y
, w
, h
);
847 return ox
!= *x
|| oy
!= *y
;
850 static void client_toggle_border(ObClient
*self
, gboolean show
)
852 /* adjust our idea of where the client is, based on its border. When the
853 border is removed, the client should now be considered to be in a
855 when re-adding the border to the client, the same operation needs to be
857 gint oldx
= self
->area
.x
, oldy
= self
->area
.y
;
858 gint x
= oldx
, y
= oldy
;
859 switch(self
->gravity
) {
861 case NorthWestGravity
:
863 case SouthWestGravity
:
865 case NorthEastGravity
:
867 case SouthEastGravity
:
868 if (show
) x
-= self
->border_width
* 2;
869 else x
+= self
->border_width
* 2;
876 if (show
) x
-= self
->border_width
;
877 else x
+= self
->border_width
;
880 switch(self
->gravity
) {
882 case NorthWestGravity
:
884 case NorthEastGravity
:
886 case SouthWestGravity
:
888 case SouthEastGravity
:
889 if (show
) y
-= self
->border_width
* 2;
890 else y
+= self
->border_width
* 2;
897 if (show
) y
-= self
->border_width
;
898 else y
+= self
->border_width
;
905 XSetWindowBorderWidth(ob_display
, self
->window
, self
->border_width
);
907 /* set border_width to 0 because there is no border to add into
908 calculations anymore */
909 self
->border_width
= 0;
911 XSetWindowBorderWidth(ob_display
, self
->window
, 0);
915 static void client_get_all(ObClient
*self
)
917 client_get_area(self
);
918 client_get_mwm_hints(self
);
920 /* The transient-ness of a window is used to pick a type, but the type can
921 also affect transiency.
923 Dialogs are always made transients for their group if they have one.
925 I also have made non-application type windows be transients for their
926 group (eg utility windows).
928 client_get_transientness(self
);
929 client_get_type(self
);/* this can change the mwmhints for special cases */
930 client_get_state(self
);
932 client_update_wmhints(self
);
933 /* this may have already been called from client_update_wmhints */
934 if (self
->transient_for
== NULL
)
935 client_update_transient_for(self
);
936 client_get_startup_id(self
);
937 client_get_desktop(self
);/* uses transient data/group/startup id if a
938 desktop is not specified */
939 client_get_shaped(self
);
941 client_get_layer(self
); /* if layer hasn't been specified, get it from
942 other sources if possible */
945 /* a couple type-based defaults for new windows */
947 /* this makes sure that these windows appear on all desktops */
948 if (self
->type
== OB_CLIENT_TYPE_DESKTOP
)
949 self
->desktop
= DESKTOP_ALL
;
952 client_update_protocols(self
);
954 client_get_gravity(self
); /* get the attribute gravity */
955 client_update_normal_hints(self
); /* this may override the attribute
958 /* got the type, the mwmhints, the protocols, and the normal hints
959 (min/max sizes), so we're ready to set up the decorations/functions */
960 client_setup_decor_and_functions(self
);
963 client_update_sync_request_counter(self
);
965 client_get_client_machine(self
);
966 client_get_colormap(self
);
967 client_update_title(self
);
968 client_update_class(self
);
969 client_update_sm_client_id(self
);
970 client_update_strut(self
);
971 client_update_icons(self
);
972 client_update_user_time(self
);
975 static void client_get_startup_id(ObClient
*self
)
977 if (!(PROP_GETS(self
->window
, net_startup_id
, utf8
, &self
->startup_id
)))
979 PROP_GETS(self
->group
->leader
,
980 net_startup_id
, utf8
, &self
->startup_id
);
983 static void client_get_area(ObClient
*self
)
985 XWindowAttributes wattrib
;
988 ret
= XGetWindowAttributes(ob_display
, self
->window
, &wattrib
);
989 g_assert(ret
!= BadWindow
);
991 RECT_SET(self
->area
, wattrib
.x
, wattrib
.y
, wattrib
.width
, wattrib
.height
);
992 POINT_SET(self
->root_pos
, wattrib
.x
, wattrib
.y
);
993 self
->border_width
= wattrib
.border_width
;
995 ob_debug("client area: %d %d %d %d\n", wattrib
.x
, wattrib
.y
,
996 wattrib
.width
, wattrib
.height
);
999 static void client_get_desktop(ObClient
*self
)
1001 guint32 d
= screen_num_desktops
; /* an always-invalid value */
1003 if (PROP_GET32(self
->window
, net_wm_desktop
, cardinal
, &d
)) {
1004 if (d
>= screen_num_desktops
&& d
!= DESKTOP_ALL
)
1005 self
->desktop
= screen_num_desktops
- 1;
1009 gboolean trdesk
= FALSE
;
1011 if (self
->transient_for
) {
1012 if (self
->transient_for
!= OB_TRAN_GROUP
) {
1013 self
->desktop
= self
->transient_for
->desktop
;
1018 for (it
= self
->group
->members
; it
; it
= g_slist_next(it
))
1019 if (it
->data
!= self
&&
1020 !((ObClient
*)it
->data
)->transient_for
) {
1021 self
->desktop
= ((ObClient
*)it
->data
)->desktop
;
1028 /* try get from the startup-notification protocol */
1029 if (sn_get_desktop(self
->startup_id
, &self
->desktop
)) {
1030 if (self
->desktop
>= screen_num_desktops
&&
1031 self
->desktop
!= DESKTOP_ALL
)
1032 self
->desktop
= screen_num_desktops
- 1;
1034 /* defaults to the current desktop */
1035 self
->desktop
= screen_desktop
;
1040 static void client_get_layer(ObClient
*self
)
1042 if (!(self
->above
|| self
->below
)) {
1044 /* apply stuff from the group */
1048 for (it
= self
->group
->members
; it
; it
= g_slist_next(it
)) {
1049 ObClient
*c
= it
->data
;
1050 if (c
!= self
&& !client_search_transient(self
, c
) &&
1051 client_normal(self
) && client_normal(c
))
1054 (c
->above
? 1 : (c
->below
? -1 : 0)));
1068 g_assert_not_reached();
1075 static void client_get_state(ObClient
*self
)
1080 if (PROP_GETA32(self
->window
, net_wm_state
, atom
, &state
, &num
)) {
1082 for (i
= 0; i
< num
; ++i
) {
1083 if (state
[i
] == prop_atoms
.net_wm_state_modal
)
1085 else if (state
[i
] == prop_atoms
.net_wm_state_shaded
)
1086 self
->shaded
= TRUE
;
1087 else if (state
[i
] == prop_atoms
.net_wm_state_hidden
)
1088 self
->iconic
= TRUE
;
1089 else if (state
[i
] == prop_atoms
.net_wm_state_skip_taskbar
)
1090 self
->skip_taskbar
= TRUE
;
1091 else if (state
[i
] == prop_atoms
.net_wm_state_skip_pager
)
1092 self
->skip_pager
= TRUE
;
1093 else if (state
[i
] == prop_atoms
.net_wm_state_fullscreen
)
1094 self
->fullscreen
= TRUE
;
1095 else if (state
[i
] == prop_atoms
.net_wm_state_maximized_vert
)
1096 self
->max_vert
= TRUE
;
1097 else if (state
[i
] == prop_atoms
.net_wm_state_maximized_horz
)
1098 self
->max_horz
= TRUE
;
1099 else if (state
[i
] == prop_atoms
.net_wm_state_above
)
1101 else if (state
[i
] == prop_atoms
.net_wm_state_below
)
1103 else if (state
[i
] == prop_atoms
.net_wm_state_demands_attention
)
1104 self
->demands_attention
= TRUE
;
1105 else if (state
[i
] == prop_atoms
.ob_wm_state_undecorated
)
1106 self
->undecorated
= TRUE
;
1113 static void client_get_shaped(ObClient
*self
)
1115 self
->shaped
= FALSE
;
1117 if (extensions_shape
) {
1122 XShapeSelectInput(ob_display
, self
->window
, ShapeNotifyMask
);
1124 XShapeQueryExtents(ob_display
, self
->window
, &s
, &foo
,
1125 &foo
, &ufoo
, &ufoo
, &foo
, &foo
, &foo
, &ufoo
,
1127 self
->shaped
= (s
!= 0);
1132 void client_get_transientness(ObClient
*self
)
1135 if (XGetTransientForHint(ob_display
, self
->window
, &t
))
1136 self
->transient
= TRUE
;
1139 void client_update_transient_for(ObClient
*self
)
1142 ObClient
*target
= NULL
;
1144 if (XGetTransientForHint(ob_display
, self
->window
, &t
)) {
1145 self
->transient
= TRUE
;
1146 if (t
!= self
->window
) { /* cant be transient to itself! */
1147 target
= g_hash_table_lookup(window_map
, &t
);
1148 /* if this happens then we need to check for it*/
1149 g_assert(target
!= self
);
1150 if (target
&& !WINDOW_IS_CLIENT(target
)) {
1151 /* this can happen when a dialog is a child of
1152 a dockapp, for example */
1156 /* THIS IS SO ANNOYING ! ! ! ! Let me explain.... have a seat..
1158 Setting the transient_for to Root is actually illegal, however
1159 applications from time have done this to specify transient for
1162 Now you can do that by being a TYPE_DIALOG and not setting
1163 the transient_for hint at all on your window. But people still
1164 use Root, and Kwin is very strange in this regard.
1166 KWin 3.0 will not consider windows with transient_for set to
1167 Root as transient for their group *UNLESS* they are also modal.
1168 In that case, it will make them transient for the group. This
1169 leads to all sorts of weird behavior from KDE apps which are
1170 only tested in KWin. I'd like to follow their behavior just to
1171 make this work right with KDE stuff, but that seems wrong.
1173 if (!target
&& self
->group
) {
1174 /* not transient to a client, see if it is transient for a
1176 if (t
== RootWindow(ob_display
, ob_screen
)) {
1177 /* window is a transient for its group! */
1178 target
= OB_TRAN_GROUP
;
1182 } else if (self
->type
== OB_CLIENT_TYPE_DIALOG
||
1183 self
->type
== OB_CLIENT_TYPE_TOOLBAR
||
1184 self
->type
== OB_CLIENT_TYPE_MENU
||
1185 self
->type
== OB_CLIENT_TYPE_UTILITY
)
1187 self
->transient
= TRUE
;
1189 target
= OB_TRAN_GROUP
;
1191 self
->transient
= FALSE
;
1193 client_update_transient_tree(self
, self
->group
, self
->group
,
1194 self
->transient_for
, target
);
1195 self
->transient_for
= target
;
1199 static void client_update_transient_tree(ObClient
*self
,
1200 ObGroup
*oldgroup
, ObGroup
*newgroup
,
1201 ObClient
* oldparent
,
1202 ObClient
*newparent
)
1207 /* No change has occured */
1208 if (oldgroup
== newgroup
&& oldparent
== newparent
) return;
1210 /** Remove the client from the transient tree wherever it has changed **/
1212 /* If the window is becoming a direct transient for a window in its group
1213 then that window can't be a child of this window anymore */
1214 if (oldparent
!= newparent
&&
1215 newparent
!= NULL
&& newparent
!= OB_TRAN_GROUP
&&
1216 newparent
->transient_for
== OB_TRAN_GROUP
&&
1217 newgroup
!= NULL
&& newgroup
== oldgroup
)
1219 self
->transients
= g_slist_remove(self
->transients
, newparent
);
1223 /* If the group changed then we need to remove any old group transient
1224 windows from our children. But if we're transient for the group, then
1225 other group transients are not our children. */
1226 if (oldgroup
!= newgroup
&& oldgroup
!= NULL
&&
1227 oldparent
!= OB_TRAN_GROUP
)
1229 for (it
= self
->transients
; it
; it
= next
) {
1230 next
= g_slist_next(it
);
1232 if (c
->group
== oldgroup
)
1233 self
->transients
= g_slist_delete_link(self
->transients
, it
);
1237 /* If we used to be transient for a group and now we are not, or we're
1238 transient for a new group, then we need to remove ourselves from all
1240 if (oldparent
== OB_TRAN_GROUP
&& (oldgroup
!= newgroup
||
1241 oldparent
!= newparent
))
1243 for (it
= oldgroup
->members
; it
; it
= g_slist_next(it
)) {
1245 if (c
!= self
&& (!c
->transient_for
||
1246 c
->transient_for
!= OB_TRAN_GROUP
))
1247 c
->transients
= g_slist_remove(c
->transients
, self
);
1250 /* If we used to be transient for a single window and we are no longer
1251 transient for it, then we need to remove ourself from its children */
1252 else if (oldparent
!= NULL
&& oldparent
!= OB_TRAN_GROUP
&&
1253 oldparent
!= newparent
)
1254 oldparent
->transients
= g_slist_remove(oldparent
->transients
, self
);
1257 /** Re-add the client to the transient tree wherever it has changed **/
1259 /* If we're now transient for a group and we weren't transient for it
1260 before then we need to add ourselves to all our new parents */
1261 if (newparent
== OB_TRAN_GROUP
&& (oldgroup
!= newgroup
||
1262 oldparent
!= newparent
))
1264 for (it
= oldgroup
->members
; it
; it
= g_slist_next(it
)) {
1266 if (c
!= self
&& (!c
->transient_for
||
1267 c
->transient_for
!= OB_TRAN_GROUP
))
1268 c
->transients
= g_slist_append(c
->transients
, self
);
1271 /* If we are now transient for a single window which we weren't before,
1272 we need to add ourselves to its children
1274 WARNING: Cyclical transient ness is possible if two windows are
1275 transient for eachother.
1277 else if (newparent
!= NULL
&& newparent
!= OB_TRAN_GROUP
&&
1278 newparent
!= oldparent
&&
1279 /* don't make ourself its child if it is already our child */
1280 !client_is_direct_child(self
, newparent
))
1281 newparent
->transients
= g_slist_append(newparent
->transients
, self
);
1283 /* If the group changed then we need to add any new group transient
1284 windows to our children. But if we're transient for the group, then
1285 other group transients are not our children.
1287 WARNING: Cyclical transient-ness is possible. For e.g. if:
1288 A is transient for the group
1289 B is a member of the group and transient for A
1291 if (oldgroup
!= newgroup
&& newgroup
!= NULL
&&
1292 newparent
!= OB_TRAN_GROUP
)
1294 for (it
= newgroup
->members
; it
; it
= g_slist_next(it
)) {
1296 if (c
!= self
&& c
->transient_for
== OB_TRAN_GROUP
&&
1297 /* Don't make it our child if it is already our parent */
1298 !client_is_direct_child(c
, self
))
1300 self
->transients
= g_slist_append(self
->transients
, c
);
1306 static void client_get_mwm_hints(ObClient
*self
)
1311 self
->mwmhints
.flags
= 0; /* default to none */
1313 if (PROP_GETA32(self
->window
, motif_wm_hints
, motif_wm_hints
,
1315 if (num
>= OB_MWM_ELEMENTS
) {
1316 self
->mwmhints
.flags
= hints
[0];
1317 self
->mwmhints
.functions
= hints
[1];
1318 self
->mwmhints
.decorations
= hints
[2];
1324 void client_get_type(ObClient
*self
)
1331 if (PROP_GETA32(self
->window
, net_wm_window_type
, atom
, &val
, &num
)) {
1332 /* use the first value that we know about in the array */
1333 for (i
= 0; i
< num
; ++i
) {
1334 if (val
[i
] == prop_atoms
.net_wm_window_type_desktop
)
1335 self
->type
= OB_CLIENT_TYPE_DESKTOP
;
1336 else if (val
[i
] == prop_atoms
.net_wm_window_type_dock
)
1337 self
->type
= OB_CLIENT_TYPE_DOCK
;
1338 else if (val
[i
] == prop_atoms
.net_wm_window_type_toolbar
)
1339 self
->type
= OB_CLIENT_TYPE_TOOLBAR
;
1340 else if (val
[i
] == prop_atoms
.net_wm_window_type_menu
)
1341 self
->type
= OB_CLIENT_TYPE_MENU
;
1342 else if (val
[i
] == prop_atoms
.net_wm_window_type_utility
)
1343 self
->type
= OB_CLIENT_TYPE_UTILITY
;
1344 else if (val
[i
] == prop_atoms
.net_wm_window_type_splash
)
1345 self
->type
= OB_CLIENT_TYPE_SPLASH
;
1346 else if (val
[i
] == prop_atoms
.net_wm_window_type_dialog
)
1347 self
->type
= OB_CLIENT_TYPE_DIALOG
;
1348 else if (val
[i
] == prop_atoms
.net_wm_window_type_normal
)
1349 self
->type
= OB_CLIENT_TYPE_NORMAL
;
1350 else if (val
[i
] == prop_atoms
.kde_net_wm_window_type_override
) {
1351 /* prevent this window from getting any decor or
1353 self
->mwmhints
.flags
&= (OB_MWM_FLAG_FUNCTIONS
|
1354 OB_MWM_FLAG_DECORATIONS
);
1355 self
->mwmhints
.decorations
= 0;
1356 self
->mwmhints
.functions
= 0;
1358 if (self
->type
!= (ObClientType
) -1)
1359 break; /* grab the first legit type */
1364 if (self
->type
== (ObClientType
) -1) {
1365 /*the window type hint was not set, which means we either classify
1366 ourself as a normal window or a dialog, depending on if we are a
1368 if (self
->transient
)
1369 self
->type
= OB_CLIENT_TYPE_DIALOG
;
1371 self
->type
= OB_CLIENT_TYPE_NORMAL
;
1375 void client_update_protocols(ObClient
*self
)
1378 guint num_return
, i
;
1380 self
->focus_notify
= FALSE
;
1381 self
->delete_window
= FALSE
;
1383 if (PROP_GETA32(self
->window
, wm_protocols
, atom
, &proto
, &num_return
)) {
1384 for (i
= 0; i
< num_return
; ++i
) {
1385 if (proto
[i
] == prop_atoms
.wm_delete_window
)
1386 /* this means we can request the window to close */
1387 self
->delete_window
= TRUE
;
1388 else if (proto
[i
] == prop_atoms
.wm_take_focus
)
1389 /* if this protocol is requested, then the window will be
1390 notified whenever we want it to receive focus */
1391 self
->focus_notify
= TRUE
;
1393 else if (proto
[i
] == prop_atoms
.net_wm_sync_request
)
1394 /* if this protocol is requested, then resizing the
1395 window will be synchronized between the frame and the
1397 self
->sync_request
= TRUE
;
1405 void client_update_sync_request_counter(ObClient
*self
)
1409 if (PROP_GET32(self
->window
, net_wm_sync_request_counter
, cardinal
, &i
)) {
1410 self
->sync_counter
= i
;
1412 self
->sync_counter
= None
;
1416 static void client_get_gravity(ObClient
*self
)
1418 XWindowAttributes wattrib
;
1421 ret
= XGetWindowAttributes(ob_display
, self
->window
, &wattrib
);
1422 g_assert(ret
!= BadWindow
);
1423 self
->gravity
= wattrib
.win_gravity
;
1426 void client_get_colormap(ObClient
*self
)
1428 XWindowAttributes wa
;
1430 if (XGetWindowAttributes(ob_display
, self
->window
, &wa
))
1431 client_update_colormap(self
, wa
.colormap
);
1434 void client_update_colormap(ObClient
*self
, Colormap colormap
)
1436 self
->colormap
= colormap
;
1439 void client_update_normal_hints(ObClient
*self
)
1443 gint oldgravity
= self
->gravity
;
1446 self
->min_ratio
= 0.0f
;
1447 self
->max_ratio
= 0.0f
;
1448 SIZE_SET(self
->size_inc
, 1, 1);
1449 SIZE_SET(self
->base_size
, 0, 0);
1450 SIZE_SET(self
->min_size
, 0, 0);
1451 SIZE_SET(self
->max_size
, G_MAXINT
, G_MAXINT
);
1453 /* get the hints from the window */
1454 if (XGetWMNormalHints(ob_display
, self
->window
, &size
, &ret
)) {
1455 /* normal windows can't request placement! har har
1456 if (!client_normal(self))
1458 self
->positioned
= (size
.flags
& (PPosition
|USPosition
));
1460 if (size
.flags
& PWinGravity
) {
1461 self
->gravity
= size
.win_gravity
;
1463 /* if the client has a frame, i.e. has already been mapped and
1464 is changing its gravity */
1465 if (self
->frame
&& self
->gravity
!= oldgravity
) {
1466 /* move our idea of the client's position based on its new
1468 client_convert_gravity(self
, oldgravity
,
1469 &self
->area
.x
, &self
->area
.y
,
1470 self
->area
.width
, self
->area
.height
);
1474 if (size
.flags
& PAspect
) {
1475 if (size
.min_aspect
.y
)
1477 (gfloat
) size
.min_aspect
.x
/ size
.min_aspect
.y
;
1478 if (size
.max_aspect
.y
)
1480 (gfloat
) size
.max_aspect
.x
/ size
.max_aspect
.y
;
1483 if (size
.flags
& PMinSize
)
1484 SIZE_SET(self
->min_size
, size
.min_width
, size
.min_height
);
1486 if (size
.flags
& PMaxSize
)
1487 SIZE_SET(self
->max_size
, size
.max_width
, size
.max_height
);
1489 if (size
.flags
& PBaseSize
)
1490 SIZE_SET(self
->base_size
, size
.base_width
, size
.base_height
);
1492 if (size
.flags
& PResizeInc
&& size
.width_inc
&& size
.height_inc
)
1493 SIZE_SET(self
->size_inc
, size
.width_inc
, size
.height_inc
);
1497 void client_setup_decor_and_functions(ObClient
*self
)
1499 /* start with everything (cept fullscreen) */
1501 (OB_FRAME_DECOR_TITLEBAR
|
1502 OB_FRAME_DECOR_HANDLE
|
1503 OB_FRAME_DECOR_GRIPS
|
1504 OB_FRAME_DECOR_BORDER
|
1505 OB_FRAME_DECOR_ICON
|
1506 OB_FRAME_DECOR_ALLDESKTOPS
|
1507 OB_FRAME_DECOR_ICONIFY
|
1508 OB_FRAME_DECOR_MAXIMIZE
|
1509 OB_FRAME_DECOR_SHADE
|
1510 OB_FRAME_DECOR_CLOSE
);
1512 (OB_CLIENT_FUNC_RESIZE
|
1513 OB_CLIENT_FUNC_MOVE
|
1514 OB_CLIENT_FUNC_ICONIFY
|
1515 OB_CLIENT_FUNC_MAXIMIZE
|
1516 OB_CLIENT_FUNC_SHADE
|
1517 OB_CLIENT_FUNC_CLOSE
);
1519 if (!(self
->min_size
.width
< self
->max_size
.width
||
1520 self
->min_size
.height
< self
->max_size
.height
))
1521 self
->functions
&= ~OB_CLIENT_FUNC_RESIZE
;
1523 switch (self
->type
) {
1524 case OB_CLIENT_TYPE_NORMAL
:
1525 /* normal windows retain all of the possible decorations and
1526 functionality, and are the only windows that you can fullscreen */
1527 self
->functions
|= OB_CLIENT_FUNC_FULLSCREEN
;
1530 case OB_CLIENT_TYPE_DIALOG
:
1531 case OB_CLIENT_TYPE_UTILITY
:
1532 /* these windows cannot be maximized */
1533 self
->functions
&= ~OB_CLIENT_FUNC_MAXIMIZE
;
1536 case OB_CLIENT_TYPE_MENU
:
1537 case OB_CLIENT_TYPE_TOOLBAR
:
1538 /* these windows get less functionality */
1539 self
->functions
&= ~(OB_CLIENT_FUNC_ICONIFY
| OB_CLIENT_FUNC_RESIZE
);
1542 case OB_CLIENT_TYPE_DESKTOP
:
1543 case OB_CLIENT_TYPE_DOCK
:
1544 case OB_CLIENT_TYPE_SPLASH
:
1545 /* none of these windows are manipulated by the window manager */
1546 self
->decorations
= 0;
1547 self
->functions
= 0;
1551 /* Mwm Hints are applied subtractively to what has already been chosen for
1552 decor and functionality */
1553 if (self
->mwmhints
.flags
& OB_MWM_FLAG_DECORATIONS
) {
1554 if (! (self
->mwmhints
.decorations
& OB_MWM_DECOR_ALL
)) {
1555 if (! ((self
->mwmhints
.decorations
& OB_MWM_DECOR_HANDLE
) ||
1556 (self
->mwmhints
.decorations
& OB_MWM_DECOR_TITLE
)))
1558 /* if the mwm hints request no handle or title, then all
1559 decorations are disabled, but keep the border if that's
1561 if (self
->mwmhints
.decorations
& OB_MWM_DECOR_BORDER
)
1562 self
->decorations
= OB_FRAME_DECOR_BORDER
;
1564 self
->decorations
= 0;
1569 if (self
->mwmhints
.flags
& OB_MWM_FLAG_FUNCTIONS
) {
1570 if (! (self
->mwmhints
.functions
& OB_MWM_FUNC_ALL
)) {
1571 if (! (self
->mwmhints
.functions
& OB_MWM_FUNC_RESIZE
))
1572 self
->functions
&= ~OB_CLIENT_FUNC_RESIZE
;
1573 if (! (self
->mwmhints
.functions
& OB_MWM_FUNC_MOVE
))
1574 self
->functions
&= ~OB_CLIENT_FUNC_MOVE
;
1575 /* dont let mwm hints kill any buttons
1576 if (! (self->mwmhints.functions & OB_MWM_FUNC_ICONIFY))
1577 self->functions &= ~OB_CLIENT_FUNC_ICONIFY;
1578 if (! (self->mwmhints.functions & OB_MWM_FUNC_MAXIMIZE))
1579 self->functions &= ~OB_CLIENT_FUNC_MAXIMIZE;
1581 /* dont let mwm hints kill the close button
1582 if (! (self->mwmhints.functions & MwmFunc_Close))
1583 self->functions &= ~OB_CLIENT_FUNC_CLOSE; */
1587 if (!(self
->functions
& OB_CLIENT_FUNC_SHADE
))
1588 self
->decorations
&= ~OB_FRAME_DECOR_SHADE
;
1589 if (!(self
->functions
& OB_CLIENT_FUNC_ICONIFY
))
1590 self
->decorations
&= ~OB_FRAME_DECOR_ICONIFY
;
1591 if (!(self
->functions
& OB_CLIENT_FUNC_RESIZE
))
1592 self
->decorations
&= ~OB_FRAME_DECOR_GRIPS
;
1594 /* can't maximize without moving/resizing */
1595 if (!((self
->functions
& OB_CLIENT_FUNC_MAXIMIZE
) &&
1596 (self
->functions
& OB_CLIENT_FUNC_MOVE
) &&
1597 (self
->functions
& OB_CLIENT_FUNC_RESIZE
))) {
1598 self
->functions
&= ~OB_CLIENT_FUNC_MAXIMIZE
;
1599 self
->decorations
&= ~OB_FRAME_DECOR_MAXIMIZE
;
1602 /* kill the handle on fully maxed windows */
1603 if (self
->max_vert
&& self
->max_horz
)
1604 self
->decorations
&= ~OB_FRAME_DECOR_HANDLE
;
1606 /* finally, the user can have requested no decorations, which overrides
1607 everything (but doesnt give it a border if it doesnt have one) */
1608 if (self
->undecorated
) {
1609 if (config_theme_keepborder
)
1610 self
->decorations
&= OB_FRAME_DECOR_BORDER
;
1612 self
->decorations
= 0;
1615 /* if we don't have a titlebar, then we cannot shade! */
1616 if (!(self
->decorations
& OB_FRAME_DECOR_TITLEBAR
))
1617 self
->functions
&= ~OB_CLIENT_FUNC_SHADE
;
1619 /* now we need to check against rules for the client's current state */
1620 if (self
->fullscreen
) {
1621 self
->functions
&= (OB_CLIENT_FUNC_CLOSE
|
1622 OB_CLIENT_FUNC_FULLSCREEN
|
1623 OB_CLIENT_FUNC_ICONIFY
);
1624 self
->decorations
= 0;
1627 client_change_allowed_actions(self
);
1630 /* adjust the client's decorations, etc. */
1631 client_reconfigure(self
);
1635 static void client_change_allowed_actions(ObClient
*self
)
1640 /* desktop windows are kept on all desktops */
1641 if (self
->type
!= OB_CLIENT_TYPE_DESKTOP
)
1642 actions
[num
++] = prop_atoms
.net_wm_action_change_desktop
;
1644 if (self
->functions
& OB_CLIENT_FUNC_SHADE
)
1645 actions
[num
++] = prop_atoms
.net_wm_action_shade
;
1646 if (self
->functions
& OB_CLIENT_FUNC_CLOSE
)
1647 actions
[num
++] = prop_atoms
.net_wm_action_close
;
1648 if (self
->functions
& OB_CLIENT_FUNC_MOVE
)
1649 actions
[num
++] = prop_atoms
.net_wm_action_move
;
1650 if (self
->functions
& OB_CLIENT_FUNC_ICONIFY
)
1651 actions
[num
++] = prop_atoms
.net_wm_action_minimize
;
1652 if (self
->functions
& OB_CLIENT_FUNC_RESIZE
)
1653 actions
[num
++] = prop_atoms
.net_wm_action_resize
;
1654 if (self
->functions
& OB_CLIENT_FUNC_FULLSCREEN
)
1655 actions
[num
++] = prop_atoms
.net_wm_action_fullscreen
;
1656 if (self
->functions
& OB_CLIENT_FUNC_MAXIMIZE
) {
1657 actions
[num
++] = prop_atoms
.net_wm_action_maximize_horz
;
1658 actions
[num
++] = prop_atoms
.net_wm_action_maximize_vert
;
1661 PROP_SETA32(self
->window
, net_wm_allowed_actions
, atom
, actions
, num
);
1663 /* make sure the window isn't breaking any rules now */
1665 if (!(self
->functions
& OB_CLIENT_FUNC_SHADE
) && self
->shaded
) {
1666 if (self
->frame
) client_shade(self
, FALSE
);
1667 else self
->shaded
= FALSE
;
1669 if (!(self
->functions
& OB_CLIENT_FUNC_ICONIFY
) && self
->iconic
) {
1670 if (self
->frame
) client_iconify(self
, FALSE
, TRUE
);
1671 else self
->iconic
= FALSE
;
1673 if (!(self
->functions
& OB_CLIENT_FUNC_FULLSCREEN
) && self
->fullscreen
) {
1674 if (self
->frame
) client_fullscreen(self
, FALSE
);
1675 else self
->fullscreen
= FALSE
;
1677 if (!(self
->functions
& OB_CLIENT_FUNC_MAXIMIZE
) && (self
->max_horz
||
1679 if (self
->frame
) client_maximize(self
, FALSE
, 0);
1680 else self
->max_vert
= self
->max_horz
= FALSE
;
1684 void client_reconfigure(ObClient
*self
)
1686 /* by making this pass FALSE for user, we avoid the emacs event storm where
1687 every configurenotify causes an update in its normal hints, i think this
1688 is generally what we want anyways... */
1689 client_configure(self
, self
->area
.x
, self
->area
.y
,
1690 self
->area
.width
, self
->area
.height
, FALSE
, TRUE
);
1693 void client_update_wmhints(ObClient
*self
)
1697 /* assume a window takes input if it doesnt specify */
1698 self
->can_focus
= TRUE
;
1700 if ((hints
= XGetWMHints(ob_display
, self
->window
)) != NULL
) {
1703 if (hints
->flags
& InputHint
)
1704 self
->can_focus
= hints
->input
;
1706 /* only do this when first managing the window *AND* when we aren't
1708 if (ob_state() != OB_STATE_STARTING
&& self
->frame
== NULL
)
1709 if (hints
->flags
& StateHint
)
1710 self
->iconic
= hints
->initial_state
== IconicState
;
1713 self
->urgent
= (hints
->flags
& XUrgencyHint
);
1714 if (self
->urgent
&& !ur
)
1715 client_hilite(self
, TRUE
);
1716 else if (!self
->urgent
&& ur
&& self
->demands_attention
)
1717 client_hilite(self
, FALSE
);
1719 if (!(hints
->flags
& WindowGroupHint
))
1720 hints
->window_group
= None
;
1722 /* did the group state change? */
1723 if (hints
->window_group
!=
1724 (self
->group
? self
->group
->leader
: None
))
1726 ObGroup
*oldgroup
= self
->group
;
1728 /* remove from the old group if there was one */
1729 if (self
->group
!= NULL
) {
1730 group_remove(self
->group
, self
);
1734 /* add ourself to the group if we have one */
1735 if (hints
->window_group
!= None
) {
1736 self
->group
= group_add(hints
->window_group
, self
);
1739 /* Put ourselves into the new group's transient tree, and remove
1740 ourselves from the old group's */
1741 client_update_transient_tree(self
, oldgroup
, self
->group
,
1742 self
->transient_for
,
1743 self
->transient_for
);
1745 /* Lastly, being in a group, or not, can change if the window is
1746 transient for anything.
1748 The logic for this is:
1749 self->transient = TRUE always if the window wants to be
1750 transient for something, even if transient_for was NULL because
1751 it wasn't in a group before.
1753 If transient_for was NULL and oldgroup was NULL we can assume
1754 that when we add the new group, it will become transient for
1757 If transient_for was OB_TRAN_GROUP, then it must have already
1758 had a group. If it is getting a new group, the above call to
1759 client_update_transient_tree has already taken care of
1760 everything ! If it is losing all group status then it will
1761 no longer be transient for anything and that needs to be
1764 if (self
->transient
&&
1765 ((self
->transient_for
== NULL
&& oldgroup
== NULL
) ||
1766 (self
->transient_for
== OB_TRAN_GROUP
&& !self
->group
)))
1767 client_update_transient_for(self
);
1770 /* the WM_HINTS can contain an icon */
1771 client_update_icons(self
);
1777 void client_update_title(ObClient
*self
)
1780 gchar
*visible
= NULL
;
1782 g_free(self
->title
);
1785 if (!PROP_GETS(self
->window
, net_wm_name
, utf8
, &data
)) {
1786 /* try old x stuff */
1787 if (!(PROP_GETS(self
->window
, wm_name
, locale
, &data
)
1788 || PROP_GETS(self
->window
, wm_name
, utf8
, &data
))) {
1789 if (self
->transient
) {
1791 GNOME alert windows are not given titles:
1792 http://developer.gnome.org/projects/gup/hig/draft_hig_new/windows-alert.html
1794 data
= g_strdup("");
1796 data
= g_strdup("Unnamed Window");
1800 if (self
->client_machine
) {
1801 visible
= g_strdup_printf("%s (%s)", data
, self
->client_machine
);
1806 PROP_SETS(self
->window
, net_wm_visible_name
, visible
);
1807 self
->title
= visible
;
1810 frame_adjust_title(self
->frame
);
1812 /* update the icon title */
1814 g_free(self
->icon_title
);
1817 if (!PROP_GETS(self
->window
, net_wm_icon_name
, utf8
, &data
))
1818 /* try old x stuff */
1819 if (!(PROP_GETS(self
->window
, wm_icon_name
, locale
, &data
) ||
1820 PROP_GETS(self
->window
, wm_icon_name
, utf8
, &data
)))
1821 data
= g_strdup(self
->title
);
1823 PROP_SETS(self
->window
, net_wm_visible_icon_name
, data
);
1824 self
->icon_title
= data
;
1827 void client_update_class(ObClient
*self
)
1832 if (self
->name
) g_free(self
->name
);
1833 if (self
->class) g_free(self
->class);
1834 if (self
->role
) g_free(self
->role
);
1836 self
->name
= self
->class = self
->role
= NULL
;
1838 if (PROP_GETSS(self
->window
, wm_class
, locale
, &data
)) {
1840 self
->name
= g_strdup(data
[0]);
1842 self
->class = g_strdup(data
[1]);
1847 if (PROP_GETS(self
->window
, wm_window_role
, locale
, &s
))
1850 if (self
->name
== NULL
) self
->name
= g_strdup("");
1851 if (self
->class == NULL
) self
->class = g_strdup("");
1852 if (self
->role
== NULL
) self
->role
= g_strdup("");
1855 void client_update_strut(ObClient
*self
)
1859 gboolean got
= FALSE
;
1862 if (PROP_GETA32(self
->window
, net_wm_strut_partial
, cardinal
,
1866 STRUT_PARTIAL_SET(strut
,
1867 data
[0], data
[2], data
[1], data
[3],
1868 data
[4], data
[5], data
[8], data
[9],
1869 data
[6], data
[7], data
[10], data
[11]);
1875 PROP_GETA32(self
->window
, net_wm_strut
, cardinal
, &data
, &num
)) {
1881 /* use the screen's width/height */
1882 a
= screen_physical_area();
1884 STRUT_PARTIAL_SET(strut
,
1885 data
[0], data
[2], data
[1], data
[3],
1886 a
->y
, a
->y
+ a
->height
- 1,
1887 a
->x
, a
->x
+ a
->width
- 1,
1888 a
->y
, a
->y
+ a
->height
- 1,
1889 a
->x
, a
->x
+ a
->width
- 1);
1895 STRUT_PARTIAL_SET(strut
, 0, 0, 0, 0,
1896 0, 0, 0, 0, 0, 0, 0, 0);
1898 if (!STRUT_EQUAL(strut
, self
->strut
)) {
1899 self
->strut
= strut
;
1901 /* updating here is pointless while we're being mapped cuz we're not in
1902 the client list yet */
1904 screen_update_areas();
1908 void client_update_icons(ObClient
*self
)
1914 for (i
= 0; i
< self
->nicons
; ++i
)
1915 g_free(self
->icons
[i
].data
);
1916 if (self
->nicons
> 0)
1917 g_free(self
->icons
);
1920 if (PROP_GETA32(self
->window
, net_wm_icon
, cardinal
, &data
, &num
)) {
1921 /* figure out how many valid icons are in here */
1923 while (num
- i
> 2) {
1927 if (i
> num
|| w
*h
== 0) break;
1931 self
->icons
= g_new(ObClientIcon
, self
->nicons
);
1933 /* store the icons */
1935 for (j
= 0; j
< self
->nicons
; ++j
) {
1938 w
= self
->icons
[j
].width
= data
[i
++];
1939 h
= self
->icons
[j
].height
= data
[i
++];
1941 if (w
*h
== 0) continue;
1943 self
->icons
[j
].data
= g_new(RrPixel32
, w
* h
);
1944 for (x
= 0, y
= 0, t
= 0; t
< w
* h
; ++t
, ++x
, ++i
) {
1949 self
->icons
[j
].data
[t
] =
1950 (((data
[i
] >> 24) & 0xff) << RrDefaultAlphaOffset
) +
1951 (((data
[i
] >> 16) & 0xff) << RrDefaultRedOffset
) +
1952 (((data
[i
] >> 8) & 0xff) << RrDefaultGreenOffset
) +
1953 (((data
[i
] >> 0) & 0xff) << RrDefaultBlueOffset
);
1962 if ((hints
= XGetWMHints(ob_display
, self
->window
))) {
1963 if (hints
->flags
& IconPixmapHint
) {
1965 self
->icons
= g_new(ObClientIcon
, self
->nicons
);
1966 xerror_set_ignore(TRUE
);
1967 if (!RrPixmapToRGBA(ob_rr_inst
,
1969 (hints
->flags
& IconMaskHint
?
1970 hints
->icon_mask
: None
),
1971 &self
->icons
[self
->nicons
-1].width
,
1972 &self
->icons
[self
->nicons
-1].height
,
1973 &self
->icons
[self
->nicons
-1].data
)){
1974 g_free(&self
->icons
[self
->nicons
-1]);
1977 xerror_set_ignore(FALSE
);
1983 /* set the default icon onto the window
1984 in theory, this could be a race, but if a window doesn't set an icon
1985 or removes it entirely, it's not very likely it is going to set one
1986 right away afterwards */
1987 if (self
->nicons
== 0) {
1988 RrPixel32
*icon
= ob_rr_theme
->def_win_icon
;
1991 data
= g_new(gulong
, 48*48+2);
1992 data
[0] = data
[1] = 48;
1993 for (i
= 0; i
< 48*48; ++i
)
1994 data
[i
+2] = (((icon
[i
] >> RrDefaultAlphaOffset
) & 0xff) << 24) +
1995 (((icon
[i
] >> RrDefaultRedOffset
) & 0xff) << 16) +
1996 (((icon
[i
] >> RrDefaultGreenOffset
) & 0xff) << 8) +
1997 (((icon
[i
] >> RrDefaultBlueOffset
) & 0xff) << 0);
1998 PROP_SETA32(self
->window
, net_wm_icon
, cardinal
, data
, 48*48+2);
2000 } else if (self
->frame
)
2001 /* don't draw the icon empty if we're just setting one now anyways,
2002 we'll get the property change any second */
2003 frame_adjust_icon(self
->frame
);
2006 void client_update_user_time(ObClient
*self
)
2010 if (PROP_GET32(self
->window
, net_wm_user_time
, cardinal
, &time
)) {
2011 /* we set this every time, not just when it grows, because in practice
2012 sometimes time goes backwards! (ntpdate.. yay....) so.. if it goes
2013 backward we don't want all windows to stop focusing. we'll just
2014 assume noone is setting times older than the last one, cuz that
2015 would be pretty stupid anyways
2017 self
->user_time
= time
;
2020 ob_debug("window %s user time %u\n", self->title, time);
2025 static void client_get_client_machine(ObClient
*self
)
2028 gchar localhost
[128];
2030 g_free(self
->client_machine
);
2032 if (PROP_GETS(self
->window
, wm_client_machine
, locale
, &data
)) {
2033 gethostname(localhost
, 127);
2034 localhost
[127] = '\0';
2035 if (strcmp(localhost
, data
))
2036 self
->client_machine
= data
;
2040 static void client_change_wm_state(ObClient
*self
)
2045 old
= self
->wmstate
;
2047 if (self
->shaded
|| self
->iconic
|| !self
->frame
->visible
)
2048 self
->wmstate
= IconicState
;
2050 self
->wmstate
= NormalState
;
2052 if (old
!= self
->wmstate
) {
2053 PROP_MSG(self
->window
, kde_wm_change_state
,
2054 self
->wmstate
, 1, 0, 0);
2056 state
[0] = self
->wmstate
;
2058 PROP_SETA32(self
->window
, wm_state
, wm_state
, state
, 2);
2062 static void client_change_state(ObClient
*self
)
2064 gulong netstate
[11];
2069 netstate
[num
++] = prop_atoms
.net_wm_state_modal
;
2071 netstate
[num
++] = prop_atoms
.net_wm_state_shaded
;
2073 netstate
[num
++] = prop_atoms
.net_wm_state_hidden
;
2074 if (self
->skip_taskbar
)
2075 netstate
[num
++] = prop_atoms
.net_wm_state_skip_taskbar
;
2076 if (self
->skip_pager
)
2077 netstate
[num
++] = prop_atoms
.net_wm_state_skip_pager
;
2078 if (self
->fullscreen
)
2079 netstate
[num
++] = prop_atoms
.net_wm_state_fullscreen
;
2081 netstate
[num
++] = prop_atoms
.net_wm_state_maximized_vert
;
2083 netstate
[num
++] = prop_atoms
.net_wm_state_maximized_horz
;
2085 netstate
[num
++] = prop_atoms
.net_wm_state_above
;
2087 netstate
[num
++] = prop_atoms
.net_wm_state_below
;
2088 if (self
->demands_attention
)
2089 netstate
[num
++] = prop_atoms
.net_wm_state_demands_attention
;
2090 if (self
->undecorated
)
2091 netstate
[num
++] = prop_atoms
.ob_wm_state_undecorated
;
2092 PROP_SETA32(self
->window
, net_wm_state
, atom
, netstate
, num
);
2095 frame_adjust_state(self
->frame
);
2098 ObClient
*client_search_focus_tree(ObClient
*self
)
2103 for (it
= self
->transients
; it
; it
= g_slist_next(it
)) {
2104 if (client_focused(it
->data
)) return it
->data
;
2105 if ((ret
= client_search_focus_tree(it
->data
))) return ret
;
2110 ObClient
*client_search_focus_tree_full(ObClient
*self
)
2112 if (self
->transient_for
) {
2113 if (self
->transient_for
!= OB_TRAN_GROUP
) {
2114 return client_search_focus_tree_full(self
->transient_for
);
2117 gboolean recursed
= FALSE
;
2119 for (it
= self
->group
->members
; it
; it
= g_slist_next(it
))
2120 if (!((ObClient
*)it
->data
)->transient_for
) {
2122 if ((c
= client_search_focus_tree_full(it
->data
)))
2131 /* this function checks the whole tree, the client_search_focus_tree~
2132 does not, so we need to check this window */
2133 if (client_focused(self
))
2135 return client_search_focus_tree(self
);
2138 static ObStackingLayer
calc_layer(ObClient
*self
)
2142 if (self
->fullscreen
&&
2143 (client_focused(self
) || client_search_focus_tree(self
)))
2144 l
= OB_STACKING_LAYER_FULLSCREEN
;
2145 else if (self
->type
== OB_CLIENT_TYPE_DESKTOP
)
2146 l
= OB_STACKING_LAYER_DESKTOP
;
2147 else if (self
->type
== OB_CLIENT_TYPE_DOCK
) {
2148 if (self
->below
) l
= OB_STACKING_LAYER_NORMAL
;
2149 else l
= OB_STACKING_LAYER_ABOVE
;
2151 else if (self
->above
) l
= OB_STACKING_LAYER_ABOVE
;
2152 else if (self
->below
) l
= OB_STACKING_LAYER_BELOW
;
2153 else l
= OB_STACKING_LAYER_NORMAL
;
2158 static void client_calc_layer_recursive(ObClient
*self
, ObClient
*orig
,
2159 ObStackingLayer min
, gboolean raised
)
2161 ObStackingLayer old
, own
;
2165 own
= calc_layer(self
);
2166 self
->layer
= MAX(own
, min
);
2168 for (it
= self
->transients
; it
; it
= g_slist_next(it
))
2169 client_calc_layer_recursive(it
->data
, orig
,
2171 raised
? raised
: self
->layer
!= old
);
2173 if (!raised
&& self
->layer
!= old
)
2174 if (orig
->frame
) { /* only restack if the original window is managed */
2175 stacking_remove(CLIENT_AS_WINDOW(self
));
2176 stacking_add(CLIENT_AS_WINDOW(self
));
2180 void client_calc_layer(ObClient
*self
)
2187 /* transients take on the layer of their parents */
2188 it
= client_search_all_top_parents(self
);
2190 for (; it
; it
= g_slist_next(it
))
2191 client_calc_layer_recursive(it
->data
, orig
, 0, FALSE
);
2194 gboolean
client_should_show(ObClient
*self
)
2198 if (client_normal(self
) && screen_showing_desktop
)
2201 if (self->transient_for) {
2202 if (self->transient_for != OB_TRAN_GROUP)
2203 return client_should_show(self->transient_for);
2207 for (it = self->group->members; it; it = g_slist_next(it)) {
2208 ObClient *c = it->data;
2209 if (c != self && !c->transient_for) {
2210 if (client_should_show(c))
2217 if (self
->desktop
== screen_desktop
|| self
->desktop
== DESKTOP_ALL
)
2223 void client_show(ObClient
*self
)
2226 if (client_should_show(self
)) {
2227 frame_show(self
->frame
);
2230 /* According to the ICCCM (sec 4.1.3.1) when a window is not visible, it
2231 needs to be in IconicState. This includes when it is on another
2234 client_change_wm_state(self
);
2237 void client_hide(ObClient
*self
)
2239 if (!client_should_show(self
)) {
2240 frame_hide(self
->frame
);
2243 /* According to the ICCCM (sec 4.1.3.1) when a window is not visible, it
2244 needs to be in IconicState. This includes when it is on another
2247 client_change_wm_state(self
);
2250 void client_showhide(ObClient
*self
)
2253 if (client_should_show(self
)) {
2254 frame_show(self
->frame
);
2257 frame_hide(self
->frame
);
2260 /* According to the ICCCM (sec 4.1.3.1) when a window is not visible, it
2261 needs to be in IconicState. This includes when it is on another
2264 client_change_wm_state(self
);
2267 gboolean
client_normal(ObClient
*self
) {
2268 return ! (self
->type
== OB_CLIENT_TYPE_DESKTOP
||
2269 self
->type
== OB_CLIENT_TYPE_DOCK
||
2270 self
->type
== OB_CLIENT_TYPE_SPLASH
);
2273 gboolean
client_application(ObClient
*self
)
2275 return (self
->type
== OB_CLIENT_TYPE_NORMAL
||
2276 self
->type
== OB_CLIENT_TYPE_DIALOG
);
2279 static void client_apply_startup_state(ObClient
*self
, gint x
, gint y
)
2281 gboolean pos
= FALSE
; /* has the window's position been configured? */
2284 /* save the position, and set self->area for these to use */
2290 /* set the desktop hint, to make sure that it always exists */
2291 PROP_SET32(self
->window
, net_wm_desktop
, cardinal
, self
->desktop
);
2293 /* these are in a carefully crafted order.. */
2296 self
->iconic
= FALSE
;
2297 client_iconify(self
, TRUE
, FALSE
);
2299 if (self
->fullscreen
) {
2300 self
->fullscreen
= FALSE
;
2301 client_fullscreen(self
, TRUE
);
2304 if (self
->undecorated
) {
2305 self
->undecorated
= FALSE
;
2306 client_set_undecorated(self
, TRUE
);
2309 self
->shaded
= FALSE
;
2310 client_shade(self
, TRUE
);
2312 if (self
->demands_attention
) {
2313 self
->demands_attention
= FALSE
;
2314 client_hilite(self
, TRUE
);
2317 if (self
->max_vert
&& self
->max_horz
) {
2318 self
->max_vert
= self
->max_horz
= FALSE
;
2319 client_maximize(self
, TRUE
, 0);
2321 } else if (self
->max_vert
) {
2322 self
->max_vert
= FALSE
;
2323 client_maximize(self
, TRUE
, 2);
2325 } else if (self
->max_horz
) {
2326 self
->max_horz
= FALSE
;
2327 client_maximize(self
, TRUE
, 1);
2331 /* if the client didn't get positioned yet, then do so now
2332 call client_move even if the window is not being moved anywhere, because
2333 when we reparent it and decorate it, it is getting moved and we need to
2334 be telling it so with a ConfigureNotify event.
2337 /* use the saved position */
2340 client_move(self
, x
, y
);
2343 /* nothing to do for the other states:
2352 void client_convert_gravity(ObClient
*self
, gint gravity
, gint
*x
, gint
*y
,
2355 gint oldg
= self
->gravity
;
2357 /* get the frame's position from the requested stuff */
2358 self
->gravity
= gravity
;
2359 frame_client_gravity(self
->frame
, x
, y
, w
, h
);
2360 self
->gravity
= oldg
;
2362 /* get the client's position in its true gravity from that */
2363 frame_frame_gravity(self
->frame
, x
, y
, w
, h
);
2366 void client_try_configure(ObClient
*self
, gint
*x
, gint
*y
, gint
*w
, gint
*h
,
2367 gint
*logicalw
, gint
*logicalh
,
2370 Rect desired_area
= {*x
, *y
, *w
, *h
};
2372 /* make the frame recalculate its dimentions n shit without changing
2373 anything visible for real, this way the constraints below can work with
2374 the updated frame dimensions. */
2375 frame_adjust_area(self
->frame
, TRUE
, TRUE
, TRUE
);
2377 /* work within the prefered sizes given by the window */
2378 if (!(*w
== self
->area
.width
&& *h
== self
->area
.height
)) {
2379 gint basew
, baseh
, minw
, minh
;
2381 /* base size is substituted with min size if not specified */
2382 if (self
->base_size
.width
|| self
->base_size
.height
) {
2383 basew
= self
->base_size
.width
;
2384 baseh
= self
->base_size
.height
;
2386 basew
= self
->min_size
.width
;
2387 baseh
= self
->min_size
.height
;
2389 /* min size is substituted with base size if not specified */
2390 if (self
->min_size
.width
|| self
->min_size
.height
) {
2391 minw
= self
->min_size
.width
;
2392 minh
= self
->min_size
.height
;
2394 minw
= self
->base_size
.width
;
2395 minh
= self
->base_size
.height
;
2398 /* if this is a user-requested resize, then check against min/max
2401 /* smaller than min size or bigger than max size? */
2402 if (*w
> self
->max_size
.width
) *w
= self
->max_size
.width
;
2403 if (*w
< minw
) *w
= minw
;
2404 if (*h
> self
->max_size
.height
) *h
= self
->max_size
.height
;
2405 if (*h
< minh
) *h
= minh
;
2410 /* keep to the increments */
2411 *w
/= self
->size_inc
.width
;
2412 *h
/= self
->size_inc
.height
;
2414 /* you cannot resize to nothing */
2415 if (basew
+ *w
< 1) *w
= 1 - basew
;
2416 if (baseh
+ *h
< 1) *h
= 1 - baseh
;
2418 /* save the logical size */
2419 *logicalw
= self
->size_inc
.width
> 1 ? *w
: *w
+ basew
;
2420 *logicalh
= self
->size_inc
.height
> 1 ? *h
: *h
+ baseh
;
2422 *w
*= self
->size_inc
.width
;
2423 *h
*= self
->size_inc
.height
;
2428 /* adjust the height to match the width for the aspect ratios.
2429 for this, min size is not substituted for base size ever. */
2430 *w
-= self
->base_size
.width
;
2431 *h
-= self
->base_size
.height
;
2433 if (!self
->fullscreen
) {
2434 if (self
->min_ratio
)
2435 if (*h
* self
->min_ratio
> *w
) {
2436 *h
= (gint
)(*w
/ self
->min_ratio
);
2438 /* you cannot resize to nothing */
2441 *w
= (gint
)(*h
* self
->min_ratio
);
2444 if (self
->max_ratio
)
2445 if (*h
* self
->max_ratio
< *w
) {
2446 *h
= (gint
)(*w
/ self
->max_ratio
);
2448 /* you cannot resize to nothing */
2451 *w
= (gint
)(*h
* self
->min_ratio
);
2456 *w
+= self
->base_size
.width
;
2457 *h
+= self
->base_size
.height
;
2460 /* gets the frame's position */
2461 frame_client_gravity(self
->frame
, x
, y
, *w
, *h
);
2463 /* these positions are frame positions, not client positions */
2465 /* set the size and position if fullscreen */
2466 if (self
->fullscreen
) {
2470 i
= screen_find_monitor(&desired_area
);
2471 a
= screen_physical_area_monitor(i
);
2478 user
= FALSE
; /* ignore if the client can't be moved/resized when it
2479 is entering fullscreen */
2480 } else if (self
->max_horz
|| self
->max_vert
) {
2484 i
= screen_find_monitor(&desired_area
);
2485 a
= screen_area_monitor(self
->desktop
, i
);
2487 /* set the size and position if maximized */
2488 if (self
->max_horz
) {
2490 *w
= a
->width
- self
->frame
->size
.left
- self
->frame
->size
.right
;
2492 if (self
->max_vert
) {
2494 *h
= a
->height
- self
->frame
->size
.top
- self
->frame
->size
.bottom
;
2497 /* maximizing is not allowed if the user can't move+resize the window
2501 /* gets the client's position */
2502 frame_frame_gravity(self
->frame
, x
, y
, *w
, *h
);
2504 /* these override the above states! if you cant move you can't move! */
2506 if (!(self
->functions
& OB_CLIENT_FUNC_MOVE
)) {
2510 if (!(self
->functions
& OB_CLIENT_FUNC_RESIZE
)) {
2511 *w
= self
->area
.width
;
2512 *h
= self
->area
.height
;
2521 void client_configure_full(ObClient
*self
, gint x
, gint y
, gint w
, gint h
,
2522 gboolean user
, gboolean final
,
2523 gboolean force_reply
)
2525 gint oldw
, oldh
, oldrx
, oldry
;
2526 gboolean send_resize_client
;
2527 gboolean moved
= FALSE
, resized
= FALSE
, rootmoved
= FALSE
;
2528 guint fdecor
= self
->frame
->decorations
;
2529 gboolean fhorz
= self
->frame
->max_horz
;
2530 gint logicalw
, logicalh
;
2532 /* find the new x, y, width, and height (and logical size) */
2533 client_try_configure(self
, &x
, &y
, &w
, &h
, &logicalw
, &logicalh
, user
);
2535 /* set the logical size if things changed */
2536 if (!(w
== self
->area
.width
&& h
== self
->area
.height
))
2537 SIZE_SET(self
->logical_size
, logicalw
, logicalh
);
2539 /* figure out if we moved or resized or what */
2540 moved
= x
!= self
->area
.x
|| y
!= self
->area
.y
;
2541 resized
= w
!= self
->area
.width
|| h
!= self
->area
.height
;
2543 oldw
= self
->area
.width
;
2544 oldh
= self
->area
.height
;
2545 RECT_SET(self
->area
, x
, y
, w
, h
);
2547 /* for app-requested resizes, always resize if 'resized' is true.
2548 for user-requested ones, only resize if final is true, or when
2549 resizing in redraw mode */
2550 send_resize_client
= ((!user
&& resized
) ||
2552 (resized
&& config_resize_redraw
))));
2554 /* if the client is enlarging, then resize the client before the frame */
2555 if (send_resize_client
&& user
&& (w
> oldw
|| h
> oldh
)) {
2556 XResizeWindow(ob_display
, self
->window
, MAX(w
, oldw
), MAX(h
, oldh
));
2557 /* resize the plate to show the client padding color underneath */
2558 frame_adjust_client_area(self
->frame
);
2561 /* find the frame's dimensions and move/resize it */
2562 if (self
->decorations
!= fdecor
|| self
->max_horz
!= fhorz
)
2563 moved
= resized
= TRUE
;
2564 if (moved
|| resized
)
2565 frame_adjust_area(self
->frame
, moved
, resized
, FALSE
);
2567 /* find the client's position relative to the root window */
2568 oldrx
= self
->root_pos
.x
;
2569 oldry
= self
->root_pos
.y
;
2570 rootmoved
= (oldrx
!= (signed)(self
->frame
->area
.x
+
2571 self
->frame
->size
.left
-
2572 self
->border_width
) ||
2573 oldry
!= (signed)(self
->frame
->area
.y
+
2574 self
->frame
->size
.top
-
2575 self
->border_width
));
2577 if (force_reply
|| ((!user
|| (user
&& final
)) && rootmoved
))
2581 POINT_SET(self
->root_pos
,
2582 self
->frame
->area
.x
+ self
->frame
->size
.left
-
2584 self
->frame
->area
.y
+ self
->frame
->size
.top
-
2585 self
->border_width
);
2587 event
.type
= ConfigureNotify
;
2588 event
.xconfigure
.display
= ob_display
;
2589 event
.xconfigure
.event
= self
->window
;
2590 event
.xconfigure
.window
= self
->window
;
2592 /* root window real coords */
2593 event
.xconfigure
.x
= self
->root_pos
.x
;
2594 event
.xconfigure
.y
= self
->root_pos
.y
;
2595 event
.xconfigure
.width
= w
;
2596 event
.xconfigure
.height
= h
;
2597 event
.xconfigure
.border_width
= 0;
2598 event
.xconfigure
.above
= self
->frame
->plate
;
2599 event
.xconfigure
.override_redirect
= FALSE
;
2600 XSendEvent(event
.xconfigure
.display
, event
.xconfigure
.window
,
2601 FALSE
, StructureNotifyMask
, &event
);
2604 /* if the client is shrinking, then resize the frame before the client */
2605 if (send_resize_client
&& (!user
|| (w
<= oldw
|| h
<= oldh
))) {
2606 /* resize the plate to show the client padding color underneath */
2607 frame_adjust_client_area(self
->frame
);
2609 XResizeWindow(ob_display
, self
->window
, w
, h
);
2615 void client_fullscreen(ObClient
*self
, gboolean fs
)
2619 if (!(self
->functions
& OB_CLIENT_FUNC_FULLSCREEN
) || /* can't */
2620 self
->fullscreen
== fs
) return; /* already done */
2622 self
->fullscreen
= fs
;
2623 client_change_state(self
); /* change the state hints on the client */
2624 client_calc_layer(self
); /* and adjust out layer/stacking */
2627 self
->pre_fullscreen_area
= self
->area
;
2628 /* if the window is maximized, its area isn't all that meaningful.
2629 save it's premax area instead. */
2630 if (self
->max_horz
) {
2631 self
->pre_fullscreen_area
.x
= self
->pre_max_area
.x
;
2632 self
->pre_fullscreen_area
.width
= self
->pre_max_area
.width
;
2634 if (self
->max_vert
) {
2635 self
->pre_fullscreen_area
.y
= self
->pre_max_area
.y
;
2636 self
->pre_fullscreen_area
.height
= self
->pre_max_area
.height
;
2639 /* these are not actually used cuz client_configure will set them
2640 as appropriate when the window is fullscreened */
2645 if (self
->pre_fullscreen_area
.width
> 0 &&
2646 self
->pre_fullscreen_area
.height
> 0)
2648 x
= self
->pre_fullscreen_area
.x
;
2649 y
= self
->pre_fullscreen_area
.y
;
2650 w
= self
->pre_fullscreen_area
.width
;
2651 h
= self
->pre_fullscreen_area
.height
;
2652 RECT_SET(self
->pre_fullscreen_area
, 0, 0, 0, 0);
2654 /* pick some fallbacks... */
2655 a
= screen_area_monitor(self
->desktop
, 0);
2656 x
= a
->x
+ a
->width
/ 4;
2657 y
= a
->y
+ a
->height
/ 4;
2663 client_setup_decor_and_functions(self
);
2665 client_move_resize(self
, x
, y
, w
, h
);
2667 /* try focus us when we go into fullscreen mode */
2671 static void client_iconify_recursive(ObClient
*self
,
2672 gboolean iconic
, gboolean curdesk
)
2675 gboolean changed
= FALSE
;
2678 if (self
->iconic
!= iconic
) {
2679 ob_debug("%sconifying window: 0x%lx\n", (iconic
? "I" : "Uni"),
2683 if (self
->functions
& OB_CLIENT_FUNC_ICONIFY
) {
2684 self
->iconic
= iconic
;
2686 /* update the focus lists.. iconic windows go to the bottom of
2687 the list, put the new iconic window at the 'top of the
2689 focus_order_to_top(self
);
2694 self
->iconic
= iconic
;
2696 if (curdesk
&& self
->desktop
!= screen_desktop
&&
2697 self
->desktop
!= DESKTOP_ALL
)
2698 client_set_desktop(self
, screen_desktop
, FALSE
);
2700 /* this puts it after the current focused window */
2701 focus_order_remove(self
);
2702 focus_order_add_new(self
);
2709 client_change_state(self
);
2710 client_showhide(self
);
2711 if (STRUT_EXISTS(self
->strut
))
2712 screen_update_areas();
2715 /* iconify all direct transients, and deiconify all transients
2717 for (it
= self
->transients
; it
; it
= g_slist_next(it
))
2718 if (it
->data
!= self
)
2719 if (client_is_direct_child(self
, it
->data
) || !iconic
)
2720 client_iconify_recursive(it
->data
, iconic
, curdesk
);
2723 void client_iconify(ObClient
*self
, gboolean iconic
, gboolean curdesk
)
2725 /* move up the transient chain as far as possible first */
2726 self
= client_search_top_parent(self
);
2727 client_iconify_recursive(self
, iconic
, curdesk
);
2730 void client_maximize(ObClient
*self
, gboolean max
, gint dir
)
2734 g_assert(dir
== 0 || dir
== 1 || dir
== 2);
2735 if (!(self
->functions
& OB_CLIENT_FUNC_MAXIMIZE
)) return; /* can't */
2737 /* check if already done */
2739 if (dir
== 0 && self
->max_horz
&& self
->max_vert
) return;
2740 if (dir
== 1 && self
->max_horz
) return;
2741 if (dir
== 2 && self
->max_vert
) return;
2743 if (dir
== 0 && !self
->max_horz
&& !self
->max_vert
) return;
2744 if (dir
== 1 && !self
->max_horz
) return;
2745 if (dir
== 2 && !self
->max_vert
) return;
2748 /* we just tell it to configure in the same place and client_configure
2749 worries about filling the screen with the window */
2752 w
= self
->area
.width
;
2753 h
= self
->area
.height
;
2756 if ((dir
== 0 || dir
== 1) && !self
->max_horz
) { /* horz */
2757 RECT_SET(self
->pre_max_area
,
2758 self
->area
.x
, self
->pre_max_area
.y
,
2759 self
->area
.width
, self
->pre_max_area
.height
);
2761 if ((dir
== 0 || dir
== 2) && !self
->max_vert
) { /* vert */
2762 RECT_SET(self
->pre_max_area
,
2763 self
->pre_max_area
.x
, self
->area
.y
,
2764 self
->pre_max_area
.width
, self
->area
.height
);
2769 a
= screen_area_monitor(self
->desktop
, 0);
2770 if ((dir
== 0 || dir
== 1) && self
->max_horz
) { /* horz */
2771 if (self
->pre_max_area
.width
> 0) {
2772 x
= self
->pre_max_area
.x
;
2773 w
= self
->pre_max_area
.width
;
2775 RECT_SET(self
->pre_max_area
, 0, self
->pre_max_area
.y
,
2776 0, self
->pre_max_area
.height
);
2778 /* pick some fallbacks... */
2779 x
= a
->x
+ a
->width
/ 4;
2783 if ((dir
== 0 || dir
== 2) && self
->max_vert
) { /* vert */
2784 if (self
->pre_max_area
.height
> 0) {
2785 y
= self
->pre_max_area
.y
;
2786 h
= self
->pre_max_area
.height
;
2788 RECT_SET(self
->pre_max_area
, self
->pre_max_area
.x
, 0,
2789 self
->pre_max_area
.width
, 0);
2791 /* pick some fallbacks... */
2792 y
= a
->y
+ a
->height
/ 4;
2798 if (dir
== 0 || dir
== 1) /* horz */
2799 self
->max_horz
= max
;
2800 if (dir
== 0 || dir
== 2) /* vert */
2801 self
->max_vert
= max
;
2803 client_change_state(self
); /* change the state hints on the client */
2805 client_setup_decor_and_functions(self
);
2807 client_move_resize(self
, x
, y
, w
, h
);
2810 void client_shade(ObClient
*self
, gboolean shade
)
2812 if ((!(self
->functions
& OB_CLIENT_FUNC_SHADE
) &&
2813 shade
) || /* can't shade */
2814 self
->shaded
== shade
) return; /* already done */
2816 self
->shaded
= shade
;
2817 client_change_state(self
);
2818 client_change_wm_state(self
); /* the window is being hidden/shown */
2819 /* resize the frame to just the titlebar */
2820 frame_adjust_area(self
->frame
, FALSE
, FALSE
, FALSE
);
2823 void client_close(ObClient
*self
)
2827 if (!(self
->functions
& OB_CLIENT_FUNC_CLOSE
)) return;
2829 /* in the case that the client provides no means to requesting that it
2830 close, we just kill it */
2831 if (!self
->delete_window
)
2835 XXX: itd be cool to do timeouts and shit here for killing the client's
2837 like... if the window is around after 5 seconds, then the close button
2838 turns a nice red, and if this function is called again, the client is
2842 ce
.xclient
.type
= ClientMessage
;
2843 ce
.xclient
.message_type
= prop_atoms
.wm_protocols
;
2844 ce
.xclient
.display
= ob_display
;
2845 ce
.xclient
.window
= self
->window
;
2846 ce
.xclient
.format
= 32;
2847 ce
.xclient
.data
.l
[0] = prop_atoms
.wm_delete_window
;
2848 ce
.xclient
.data
.l
[1] = event_curtime
;
2849 ce
.xclient
.data
.l
[2] = 0l;
2850 ce
.xclient
.data
.l
[3] = 0l;
2851 ce
.xclient
.data
.l
[4] = 0l;
2852 XSendEvent(ob_display
, self
->window
, FALSE
, NoEventMask
, &ce
);
2855 void client_kill(ObClient
*self
)
2857 XKillClient(ob_display
, self
->window
);
2860 void client_hilite(ObClient
*self
, gboolean hilite
)
2862 if (self
->demands_attention
== hilite
)
2863 return; /* no change */
2865 /* don't allow focused windows to hilite */
2866 self
->demands_attention
= hilite
&& !client_focused(self
);
2867 if (self
->frame
!= NULL
) { /* if we're mapping, just set the state */
2868 if (self
->demands_attention
)
2869 frame_flash_start(self
->frame
);
2871 frame_flash_stop(self
->frame
);
2872 client_change_state(self
);
2876 void client_set_desktop_recursive(ObClient
*self
,
2877 guint target
, gboolean donthide
)
2882 if (target
!= self
->desktop
) {
2884 ob_debug("Setting desktop %u\n", target
+1);
2886 g_assert(target
< screen_num_desktops
|| target
== DESKTOP_ALL
);
2888 /* remove from the old desktop(s) */
2889 focus_order_remove(self
);
2891 old
= self
->desktop
;
2892 self
->desktop
= target
;
2893 PROP_SET32(self
->window
, net_wm_desktop
, cardinal
, target
);
2894 /* the frame can display the current desktop state */
2895 frame_adjust_state(self
->frame
);
2896 /* 'move' the window to the new desktop */
2898 client_showhide(self
);
2899 /* raise if it was not already on the desktop */
2900 if (old
!= DESKTOP_ALL
)
2902 if (STRUT_EXISTS(self
->strut
))
2903 screen_update_areas();
2905 /* add to the new desktop(s) */
2906 if (config_focus_new
)
2907 focus_order_to_top(self
);
2909 focus_order_to_bottom(self
);
2912 /* move all transients */
2913 for (it
= self
->transients
; it
; it
= g_slist_next(it
))
2914 if (it
->data
!= self
)
2915 if (client_is_direct_child(self
, it
->data
))
2916 client_set_desktop_recursive(it
->data
, target
, donthide
);
2919 void client_set_desktop(ObClient
*self
, guint target
, gboolean donthide
)
2921 self
= client_search_top_parent(self
);
2922 client_set_desktop_recursive(self
, target
, donthide
);
2925 gboolean
client_is_direct_child(ObClient
*parent
, ObClient
*child
)
2927 while (child
!= parent
&&
2928 child
->transient_for
&& child
->transient_for
!= OB_TRAN_GROUP
)
2929 child
= child
->transient_for
;
2930 return child
== parent
;
2933 ObClient
*client_search_modal_child(ObClient
*self
)
2938 for (it
= self
->transients
; it
; it
= g_slist_next(it
)) {
2939 ObClient
*c
= it
->data
;
2940 if ((ret
= client_search_modal_child(c
))) return ret
;
2941 if (c
->modal
) return c
;
2946 gboolean
client_validate(ObClient
*self
)
2950 XSync(ob_display
, FALSE
); /* get all events on the server */
2952 if (XCheckTypedWindowEvent(ob_display
, self
->window
, DestroyNotify
, &e
) ||
2953 XCheckTypedWindowEvent(ob_display
, self
->window
, UnmapNotify
, &e
)) {
2954 XPutBackEvent(ob_display
, &e
);
2961 void client_set_wm_state(ObClient
*self
, glong state
)
2963 if (state
== self
->wmstate
) return; /* no change */
2967 client_iconify(self
, TRUE
, TRUE
);
2970 client_iconify(self
, FALSE
, TRUE
);
2975 void client_set_state(ObClient
*self
, Atom action
, glong data1
, glong data2
)
2977 gboolean shaded
= self
->shaded
;
2978 gboolean fullscreen
= self
->fullscreen
;
2979 gboolean undecorated
= self
->undecorated
;
2980 gboolean max_horz
= self
->max_horz
;
2981 gboolean max_vert
= self
->max_vert
;
2982 gboolean modal
= self
->modal
;
2983 gboolean iconic
= self
->iconic
;
2984 gboolean demands_attention
= self
->demands_attention
;
2987 if (!(action
== prop_atoms
.net_wm_state_add
||
2988 action
== prop_atoms
.net_wm_state_remove
||
2989 action
== prop_atoms
.net_wm_state_toggle
))
2990 /* an invalid action was passed to the client message, ignore it */
2993 for (i
= 0; i
< 2; ++i
) {
2994 Atom state
= i
== 0 ? data1
: data2
;
2996 if (!state
) continue;
2998 /* if toggling, then pick whether we're adding or removing */
2999 if (action
== prop_atoms
.net_wm_state_toggle
) {
3000 if (state
== prop_atoms
.net_wm_state_modal
)
3001 action
= modal
? prop_atoms
.net_wm_state_remove
:
3002 prop_atoms
.net_wm_state_add
;
3003 else if (state
== prop_atoms
.net_wm_state_maximized_vert
)
3004 action
= self
->max_vert
? prop_atoms
.net_wm_state_remove
:
3005 prop_atoms
.net_wm_state_add
;
3006 else if (state
== prop_atoms
.net_wm_state_maximized_horz
)
3007 action
= self
->max_horz
? prop_atoms
.net_wm_state_remove
:
3008 prop_atoms
.net_wm_state_add
;
3009 else if (state
== prop_atoms
.net_wm_state_shaded
)
3010 action
= shaded
? prop_atoms
.net_wm_state_remove
:
3011 prop_atoms
.net_wm_state_add
;
3012 else if (state
== prop_atoms
.net_wm_state_skip_taskbar
)
3013 action
= self
->skip_taskbar
?
3014 prop_atoms
.net_wm_state_remove
:
3015 prop_atoms
.net_wm_state_add
;
3016 else if (state
== prop_atoms
.net_wm_state_skip_pager
)
3017 action
= self
->skip_pager
?
3018 prop_atoms
.net_wm_state_remove
:
3019 prop_atoms
.net_wm_state_add
;
3020 else if (state
== prop_atoms
.net_wm_state_hidden
)
3021 action
= self
->iconic
?
3022 prop_atoms
.net_wm_state_remove
:
3023 prop_atoms
.net_wm_state_add
;
3024 else if (state
== prop_atoms
.net_wm_state_fullscreen
)
3025 action
= fullscreen
?
3026 prop_atoms
.net_wm_state_remove
:
3027 prop_atoms
.net_wm_state_add
;
3028 else if (state
== prop_atoms
.net_wm_state_above
)
3029 action
= self
->above
? prop_atoms
.net_wm_state_remove
:
3030 prop_atoms
.net_wm_state_add
;
3031 else if (state
== prop_atoms
.net_wm_state_below
)
3032 action
= self
->below
? prop_atoms
.net_wm_state_remove
:
3033 prop_atoms
.net_wm_state_add
;
3034 else if (state
== prop_atoms
.net_wm_state_demands_attention
)
3035 action
= self
->demands_attention
?
3036 prop_atoms
.net_wm_state_remove
:
3037 prop_atoms
.net_wm_state_add
;
3038 else if (state
== prop_atoms
.ob_wm_state_undecorated
)
3039 action
= undecorated
? prop_atoms
.net_wm_state_remove
:
3040 prop_atoms
.net_wm_state_add
;
3043 if (action
== prop_atoms
.net_wm_state_add
) {
3044 if (state
== prop_atoms
.net_wm_state_modal
) {
3046 } else if (state
== prop_atoms
.net_wm_state_maximized_vert
) {
3048 } else if (state
== prop_atoms
.net_wm_state_maximized_horz
) {
3050 } else if (state
== prop_atoms
.net_wm_state_shaded
) {
3052 } else if (state
== prop_atoms
.net_wm_state_skip_taskbar
) {
3053 self
->skip_taskbar
= TRUE
;
3054 } else if (state
== prop_atoms
.net_wm_state_skip_pager
) {
3055 self
->skip_pager
= TRUE
;
3056 } else if (state
== prop_atoms
.net_wm_state_hidden
) {
3058 } else if (state
== prop_atoms
.net_wm_state_fullscreen
) {
3060 } else if (state
== prop_atoms
.net_wm_state_above
) {
3062 self
->below
= FALSE
;
3063 } else if (state
== prop_atoms
.net_wm_state_below
) {
3064 self
->above
= FALSE
;
3066 } else if (state
== prop_atoms
.net_wm_state_demands_attention
) {
3067 demands_attention
= TRUE
;
3068 } else if (state
== prop_atoms
.ob_wm_state_undecorated
) {
3072 } else { /* action == prop_atoms.net_wm_state_remove */
3073 if (state
== prop_atoms
.net_wm_state_modal
) {
3075 } else if (state
== prop_atoms
.net_wm_state_maximized_vert
) {
3077 } else if (state
== prop_atoms
.net_wm_state_maximized_horz
) {
3079 } else if (state
== prop_atoms
.net_wm_state_shaded
) {
3081 } else if (state
== prop_atoms
.net_wm_state_skip_taskbar
) {
3082 self
->skip_taskbar
= FALSE
;
3083 } else if (state
== prop_atoms
.net_wm_state_skip_pager
) {
3084 self
->skip_pager
= FALSE
;
3085 } else if (state
== prop_atoms
.net_wm_state_hidden
) {
3087 } else if (state
== prop_atoms
.net_wm_state_fullscreen
) {
3089 } else if (state
== prop_atoms
.net_wm_state_above
) {
3090 self
->above
= FALSE
;
3091 } else if (state
== prop_atoms
.net_wm_state_below
) {
3092 self
->below
= FALSE
;
3093 } else if (state
== prop_atoms
.net_wm_state_demands_attention
) {
3094 demands_attention
= FALSE
;
3095 } else if (state
== prop_atoms
.ob_wm_state_undecorated
) {
3096 undecorated
= FALSE
;
3100 if (max_horz
!= self
->max_horz
|| max_vert
!= self
->max_vert
) {
3101 if (max_horz
!= self
->max_horz
&& max_vert
!= self
->max_vert
) {
3103 if (max_horz
== max_vert
) { /* both going the same way */
3104 client_maximize(self
, max_horz
, 0);
3106 client_maximize(self
, max_horz
, 1);
3107 client_maximize(self
, max_vert
, 2);
3111 if (max_horz
!= self
->max_horz
)
3112 client_maximize(self
, max_horz
, 1);
3114 client_maximize(self
, max_vert
, 2);
3117 /* change fullscreen state before shading, as it will affect if the window
3119 if (fullscreen
!= self
->fullscreen
)
3120 client_fullscreen(self
, fullscreen
);
3121 if (shaded
!= self
->shaded
)
3122 client_shade(self
, shaded
);
3123 if (undecorated
!= self
->undecorated
)
3124 client_set_undecorated(self
, undecorated
);
3125 if (modal
!= self
->modal
) {
3126 self
->modal
= modal
;
3127 /* when a window changes modality, then its stacking order with its
3128 transients needs to change */
3131 if (iconic
!= self
->iconic
)
3132 client_iconify(self
, iconic
, FALSE
);
3134 if (demands_attention
!= self
->demands_attention
)
3135 client_hilite(self
, demands_attention
);
3137 client_change_state(self
); /* change the hint to reflect these changes */
3140 ObClient
*client_focus_target(ObClient
*self
)
3142 ObClient
*child
= NULL
;
3144 child
= client_search_modal_child(self
);
3145 if (child
) return child
;
3149 gboolean
client_can_focus(ObClient
*self
)
3153 /* choose the correct target */
3154 self
= client_focus_target(self
);
3156 if (!self
->frame
->visible
)
3159 if (!(self
->can_focus
|| self
->focus_notify
))
3162 /* do a check to see if the window has already been unmapped or destroyed
3163 do this intelligently while watching out for unmaps we've generated
3164 (ignore_unmaps > 0) */
3165 if (XCheckTypedWindowEvent(ob_display
, self
->window
,
3166 DestroyNotify
, &ev
)) {
3167 XPutBackEvent(ob_display
, &ev
);
3170 while (XCheckTypedWindowEvent(ob_display
, self
->window
,
3171 UnmapNotify
, &ev
)) {
3172 if (self
->ignore_unmaps
) {
3173 self
->ignore_unmaps
--;
3175 XPutBackEvent(ob_display
, &ev
);
3183 gboolean
client_focus(ObClient
*self
)
3185 /* choose the correct target */
3186 self
= client_focus_target(self
);
3188 if (!client_can_focus(self
)) {
3189 if (!self
->frame
->visible
) {
3190 /* update the focus lists */
3191 focus_order_to_top(self
);
3196 ob_debug_type(OB_DEBUG_FOCUS
,
3197 "Focusing client \"%s\" at time %u\n",
3198 self
->title
, event_curtime
);
3200 if (self
->can_focus
) {
3201 /* This can cause a BadMatch error with CurrentTime, or if an app
3202 passed in a bad time for _NET_WM_ACTIVE_WINDOW. */
3203 xerror_set_ignore(TRUE
);
3204 XSetInputFocus(ob_display
, self
->window
, RevertToPointerRoot
,
3206 xerror_set_ignore(FALSE
);
3209 if (self
->focus_notify
) {
3211 ce
.xclient
.type
= ClientMessage
;
3212 ce
.xclient
.message_type
= prop_atoms
.wm_protocols
;
3213 ce
.xclient
.display
= ob_display
;
3214 ce
.xclient
.window
= self
->window
;
3215 ce
.xclient
.format
= 32;
3216 ce
.xclient
.data
.l
[0] = prop_atoms
.wm_take_focus
;
3217 ce
.xclient
.data
.l
[1] = event_curtime
;
3218 ce
.xclient
.data
.l
[2] = 0l;
3219 ce
.xclient
.data
.l
[3] = 0l;
3220 ce
.xclient
.data
.l
[4] = 0l;
3221 XSendEvent(ob_display
, self
->window
, FALSE
, NoEventMask
, &ce
);
3225 ob_debug("%sively focusing %lx at %d\n",
3226 (self
->can_focus
? "act" : "pass"),
3227 self
->window
, (gint
) event_curtime
);
3230 /* Cause the FocusIn to come back to us. Important for desktop switches,
3231 since otherwise we'll have no FocusIn on the queue and send it off to
3232 the focus_backup. */
3233 XSync(ob_display
, FALSE
);
3237 void client_activate(ObClient
*self
, gboolean here
, gboolean user
)
3239 guint32 last_time
= focus_client
? focus_client
->user_time
: CurrentTime
;
3241 /* XXX do some stuff here if user is false to determine if we really want
3242 to activate it or not (a parent or group member is currently
3245 ob_debug_type(OB_DEBUG_FOCUS
,
3246 "Want to activate window 0x%x with time %u (last time %u), "
3248 self
->window
, event_curtime
, last_time
,
3249 (user
? "user" : "application"));
3251 if (!user
&& event_curtime
&& last_time
&&
3252 !event_time_after(event_curtime
, last_time
))
3254 client_hilite(self
, TRUE
);
3256 if (event_curtime
!= CurrentTime
)
3257 self
->user_time
= event_curtime
;
3259 /* if using focus_delay, stop the timer now so that focus doesn't
3261 event_halt_focus_delay();
3263 if (client_normal(self
) && screen_showing_desktop
)
3264 screen_show_desktop(FALSE
);
3266 client_iconify(self
, FALSE
, here
);
3267 if (self
->desktop
!= DESKTOP_ALL
&&
3268 self
->desktop
!= screen_desktop
)
3271 client_set_desktop(self
, screen_desktop
, FALSE
);
3273 screen_set_desktop(self
->desktop
);
3274 } else if (!self
->frame
->visible
)
3275 /* if its not visible for other reasons, then don't mess
3279 client_shade(self
, FALSE
);
3283 /* we do this as an action here. this is rather important. this is
3284 because we want the results from the focus change to take place
3285 BEFORE we go about raising the window. when a fullscreen window
3286 loses focus, we need this or else the raise wont be able to raise
3287 above the to-lose-focus fullscreen window. */
3292 void client_raise(ObClient
*self
)
3294 action_run_string("Raise", self
, CurrentTime
);
3297 void client_lower(ObClient
*self
)
3299 action_run_string("Lower", self
, CurrentTime
);
3302 gboolean
client_focused(ObClient
*self
)
3304 return self
== focus_client
;
3307 static ObClientIcon
* client_icon_recursive(ObClient
*self
, gint w
, gint h
)
3310 /* si is the smallest image >= req */
3311 /* li is the largest image < req */
3312 gulong size
, smallest
= 0xffffffff, largest
= 0, si
= 0, li
= 0;
3314 if (!self
->nicons
) {
3315 ObClientIcon
*parent
= NULL
;
3317 if (self
->transient_for
) {
3318 if (self
->transient_for
!= OB_TRAN_GROUP
)
3319 parent
= client_icon_recursive(self
->transient_for
, w
, h
);
3322 for (it
= self
->group
->members
; it
; it
= g_slist_next(it
)) {
3323 ObClient
*c
= it
->data
;
3324 if (c
!= self
&& !c
->transient_for
) {
3325 if ((parent
= client_icon_recursive(c
, w
, h
)))
3335 for (i
= 0; i
< self
->nicons
; ++i
) {
3336 size
= self
->icons
[i
].width
* self
->icons
[i
].height
;
3337 if (size
< smallest
&& size
>= (unsigned)(w
* h
)) {
3341 if (size
> largest
&& size
<= (unsigned)(w
* h
)) {
3346 if (largest
== 0) /* didnt find one smaller than the requested size */
3347 return &self
->icons
[si
];
3348 return &self
->icons
[li
];
3351 const ObClientIcon
* client_icon(ObClient
*self
, gint w
, gint h
)
3354 static ObClientIcon deficon
;
3356 if (!(ret
= client_icon_recursive(self
, w
, h
))) {
3357 deficon
.width
= deficon
.height
= 48;
3358 deficon
.data
= ob_rr_theme
->def_win_icon
;
3364 void client_set_layer(ObClient
*self
, gint layer
)
3368 self
->above
= FALSE
;
3369 } else if (layer
== 0) {
3370 self
->below
= self
->above
= FALSE
;
3372 self
->below
= FALSE
;
3375 client_calc_layer(self
);
3376 client_change_state(self
); /* reflect this in the state hints */
3379 void client_set_undecorated(ObClient
*self
, gboolean undecorated
)
3381 if (self
->undecorated
!= undecorated
) {
3382 self
->undecorated
= undecorated
;
3383 client_setup_decor_and_functions(self
);
3384 /* Make sure the client knows it might have moved. Maybe there is a
3385 * better way of doing this so only one client_configure is sent, but
3386 * since 125 of these are sent per second when moving the window (with
3387 * user = FALSE) i doubt it matters much.
3389 client_configure(self
, self
->area
.x
, self
->area
.y
,
3390 self
->area
.width
, self
->area
.height
, TRUE
, TRUE
);
3391 client_change_state(self
); /* reflect this in the state hints */
3395 guint
client_monitor(ObClient
*self
)
3397 return screen_find_monitor(&self
->frame
->area
);
3400 ObClient
*client_search_top_parent(ObClient
*self
)
3402 while (self
->transient_for
&& self
->transient_for
!= OB_TRAN_GROUP
&&
3403 client_normal(self
))
3404 self
= self
->transient_for
;
3408 GSList
*client_search_all_top_parents(ObClient
*self
)
3412 /* move up the direct transient chain as far as possible */
3413 while (self
->transient_for
&& self
->transient_for
!= OB_TRAN_GROUP
)
3414 self
= self
->transient_for
;
3416 if (!self
->transient_for
)
3417 ret
= g_slist_prepend(ret
, self
);
3421 g_assert(self
->group
);
3423 for (it
= self
->group
->members
; it
; it
= g_slist_next(it
)) {
3424 ObClient
*c
= it
->data
;
3426 if (!c
->transient_for
&& client_normal(c
))
3427 ret
= g_slist_prepend(ret
, c
);
3430 if (ret
== NULL
) /* no group parents */
3431 ret
= g_slist_prepend(ret
, self
);
3437 ObClient
*client_search_focus_parent(ObClient
*self
)
3439 if (self
->transient_for
) {
3440 if (self
->transient_for
!= OB_TRAN_GROUP
) {
3441 if (client_focused(self
->transient_for
))
3442 return self
->transient_for
;
3446 for (it
= self
->group
->members
; it
; it
= g_slist_next(it
)) {
3447 ObClient
*c
= it
->data
;
3449 /* checking transient_for prevents infinate loops! */
3450 if (c
!= self
&& !c
->transient_for
)
3451 if (client_focused(c
))
3460 ObClient
*client_search_parent(ObClient
*self
, ObClient
*search
)
3462 if (self
->transient_for
) {
3463 if (self
->transient_for
!= OB_TRAN_GROUP
) {
3464 if (self
->transient_for
== search
)
3469 for (it
= self
->group
->members
; it
; it
= g_slist_next(it
)) {
3470 ObClient
*c
= it
->data
;
3472 /* checking transient_for prevents infinate loops! */
3473 if (c
!= self
&& !c
->transient_for
)
3483 ObClient
*client_search_transient(ObClient
*self
, ObClient
*search
)
3487 for (sit
= self
->transients
; sit
; sit
= g_slist_next(sit
)) {
3488 if (sit
->data
== search
)
3490 if (client_search_transient(sit
->data
, search
))
3496 void client_update_sm_client_id(ObClient
*self
)
3498 g_free(self
->sm_client_id
);
3499 self
->sm_client_id
= NULL
;
3501 if (!PROP_GETS(self
->window
, sm_client_id
, locale
, &self
->sm_client_id
) &&
3503 PROP_GETS(self
->group
->leader
, sm_client_id
, locale
,
3504 &self
->sm_client_id
);
3507 #define WANT_EDGE(cur, c) \
3510 if(!client_normal(cur)) \
3512 if(screen_desktop != cur->desktop && cur->desktop != DESKTOP_ALL) \
3516 if(cur->layer < c->layer && !config_resist_layers_below) \
3519 #define HIT_EDGE(my_edge_start, my_edge_end, his_edge_start, his_edge_end) \
3520 if ((his_edge_start >= my_edge_start && \
3521 his_edge_start <= my_edge_end) || \
3522 (my_edge_start >= his_edge_start && \
3523 my_edge_start <= his_edge_end)) \
3526 /* finds the nearest edge in the given direction from the current client
3527 * note to self: the edge is the -frame- edge (the actual one), not the
3530 gint
client_directional_edge_search(ObClient
*c
, ObDirection dir
, gboolean hang
)
3532 gint dest
, monitor_dest
;
3533 gint my_edge_start
, my_edge_end
, my_offset
;
3540 a
= screen_area(c
->desktop
);
3541 monitor
= screen_area_monitor(c
->desktop
, client_monitor(c
));
3544 case OB_DIRECTION_NORTH
:
3545 my_edge_start
= c
->frame
->area
.x
;
3546 my_edge_end
= c
->frame
->area
.x
+ c
->frame
->area
.width
;
3547 my_offset
= c
->frame
->area
.y
+ (hang
? c
->frame
->area
.height
: 0);
3549 /* default: top of screen */
3550 dest
= a
->y
+ (hang
? c
->frame
->area
.height
: 0);
3551 monitor_dest
= monitor
->y
+ (hang
? c
->frame
->area
.height
: 0);
3552 /* if the monitor edge comes before the screen edge, */
3553 /* use that as the destination instead. (For xinerama) */
3554 if (monitor_dest
!= dest
&& my_offset
> monitor_dest
)
3555 dest
= monitor_dest
;
3557 for(it
= client_list
; it
&& my_offset
!= dest
; it
= g_list_next(it
)) {
3558 gint his_edge_start
, his_edge_end
, his_offset
;
3559 ObClient
*cur
= it
->data
;
3563 his_edge_start
= cur
->frame
->area
.x
;
3564 his_edge_end
= cur
->frame
->area
.x
+ cur
->frame
->area
.width
;
3565 his_offset
= cur
->frame
->area
.y
+
3566 (hang
? 0 : cur
->frame
->area
.height
);
3568 if(his_offset
+ 1 > my_offset
)
3571 if(his_offset
< dest
)
3574 HIT_EDGE(my_edge_start
, my_edge_end
, his_edge_start
, his_edge_end
)
3577 case OB_DIRECTION_SOUTH
:
3578 my_edge_start
= c
->frame
->area
.x
;
3579 my_edge_end
= c
->frame
->area
.x
+ c
->frame
->area
.width
;
3580 my_offset
= c
->frame
->area
.y
+ (hang
? 0 : c
->frame
->area
.height
);
3582 /* default: bottom of screen */
3583 dest
= a
->y
+ a
->height
- (hang
? c
->frame
->area
.height
: 0);
3584 monitor_dest
= monitor
->y
+ monitor
->height
-
3585 (hang
? c
->frame
->area
.height
: 0);
3586 /* if the monitor edge comes before the screen edge, */
3587 /* use that as the destination instead. (For xinerama) */
3588 if (monitor_dest
!= dest
&& my_offset
< monitor_dest
)
3589 dest
= monitor_dest
;
3591 for(it
= client_list
; it
&& my_offset
!= dest
; it
= g_list_next(it
)) {
3592 gint his_edge_start
, his_edge_end
, his_offset
;
3593 ObClient
*cur
= it
->data
;
3597 his_edge_start
= cur
->frame
->area
.x
;
3598 his_edge_end
= cur
->frame
->area
.x
+ cur
->frame
->area
.width
;
3599 his_offset
= cur
->frame
->area
.y
+
3600 (hang
? cur
->frame
->area
.height
: 0);
3603 if(his_offset
- 1 < my_offset
)
3606 if(his_offset
> dest
)
3609 HIT_EDGE(my_edge_start
, my_edge_end
, his_edge_start
, his_edge_end
)
3612 case OB_DIRECTION_WEST
:
3613 my_edge_start
= c
->frame
->area
.y
;
3614 my_edge_end
= c
->frame
->area
.y
+ c
->frame
->area
.height
;
3615 my_offset
= c
->frame
->area
.x
+ (hang
? c
->frame
->area
.width
: 0);
3617 /* default: leftmost egde of screen */
3618 dest
= a
->x
+ (hang
? c
->frame
->area
.width
: 0);
3619 monitor_dest
= monitor
->x
+ (hang
? c
->frame
->area
.width
: 0);
3620 /* if the monitor edge comes before the screen edge, */
3621 /* use that as the destination instead. (For xinerama) */
3622 if (monitor_dest
!= dest
&& my_offset
> monitor_dest
)
3623 dest
= monitor_dest
;
3625 for(it
= client_list
; it
&& my_offset
!= dest
; it
= g_list_next(it
)) {
3626 gint his_edge_start
, his_edge_end
, his_offset
;
3627 ObClient
*cur
= it
->data
;
3631 his_edge_start
= cur
->frame
->area
.y
;
3632 his_edge_end
= cur
->frame
->area
.y
+ cur
->frame
->area
.height
;
3633 his_offset
= cur
->frame
->area
.x
+
3634 (hang
? 0 : cur
->frame
->area
.width
);
3636 if(his_offset
+ 1 > my_offset
)
3639 if(his_offset
< dest
)
3642 HIT_EDGE(my_edge_start
, my_edge_end
, his_edge_start
, his_edge_end
)
3645 case OB_DIRECTION_EAST
:
3646 my_edge_start
= c
->frame
->area
.y
;
3647 my_edge_end
= c
->frame
->area
.y
+ c
->frame
->area
.height
;
3648 my_offset
= c
->frame
->area
.x
+ (hang
? 0 : c
->frame
->area
.width
);
3650 /* default: rightmost edge of screen */
3651 dest
= a
->x
+ a
->width
- (hang
? c
->frame
->area
.width
: 0);
3652 monitor_dest
= monitor
->x
+ monitor
->width
-
3653 (hang
? c
->frame
->area
.width
: 0);
3654 /* if the monitor edge comes before the screen edge, */
3655 /* use that as the destination instead. (For xinerama) */
3656 if (monitor_dest
!= dest
&& my_offset
< monitor_dest
)
3657 dest
= monitor_dest
;
3659 for(it
= client_list
; it
&& my_offset
!= dest
; it
= g_list_next(it
)) {
3660 gint his_edge_start
, his_edge_end
, his_offset
;
3661 ObClient
*cur
= it
->data
;
3665 his_edge_start
= cur
->frame
->area
.y
;
3666 his_edge_end
= cur
->frame
->area
.y
+ cur
->frame
->area
.height
;
3667 his_offset
= cur
->frame
->area
.x
+
3668 (hang
? cur
->frame
->area
.width
: 0);
3670 if(his_offset
- 1 < my_offset
)
3673 if(his_offset
> dest
)
3676 HIT_EDGE(my_edge_start
, my_edge_end
, his_edge_start
, his_edge_end
)
3679 case OB_DIRECTION_NORTHEAST
:
3680 case OB_DIRECTION_SOUTHEAST
:
3681 case OB_DIRECTION_NORTHWEST
:
3682 case OB_DIRECTION_SOUTHWEST
:
3683 /* not implemented */
3685 g_assert_not_reached();
3686 dest
= 0; /* suppress warning */
3691 ObClient
* client_under_pointer()
3695 ObClient
*ret
= NULL
;
3697 if (screen_pointer_pos(&x
, &y
)) {
3698 for (it
= stacking_list
; it
; it
= g_list_next(it
)) {
3699 if (WINDOW_IS_CLIENT(it
->data
)) {
3700 ObClient
*c
= WINDOW_AS_CLIENT(it
->data
);
3701 if (c
->frame
->visible
&&
3702 RECT_CONTAINS(c
->frame
->area
, x
, y
)) {
3712 gboolean
client_has_group_siblings(ObClient
*self
)
3714 return self
->group
&& self
->group
->members
->next
;
3717 gboolean
client_has_application_group_siblings(ObClient
*self
)
3721 if (!self
->group
) return FALSE
;
3723 for (it
= self
->group
->members
; it
; it
= g_slist_next(it
)) {
3724 ObClient
*c
= it
->data
;
3725 if (c
!= self
&& client_application(c
))