6 #include "moveresize.h"
8 #include "extensions.h"
19 #include "render/render.h"
22 #include <X11/Xutil.h>
24 /*! The event mask to grab on client windows */
25 #define CLIENT_EVENTMASK (PropertyChangeMask | FocusChangeMask | \
28 #define CLIENT_NOPROPAGATEMASK (ButtonPressMask | ButtonReleaseMask | \
31 GList *client_list = NULL;
33 static void client_get_all(ObClient *self);
34 static void client_toggle_border(ObClient *self, gboolean show);
35 static void client_get_area(ObClient *self);
36 static void client_get_desktop(ObClient *self);
37 static void client_get_state(ObClient *self);
38 static void client_get_shaped(ObClient *self);
39 static void client_get_mwm_hints(ObClient *self);
40 static void client_get_gravity(ObClient *self);
41 static void client_showhide(ObClient *self);
42 static void client_change_allowed_actions(ObClient *self);
43 static void client_change_state(ObClient *self);
44 static void client_apply_startup_state(ObClient *self);
51 void client_shutdown()
55 void client_set_list()
57 Window *windows, *win_it;
59 guint size = g_list_length(client_list);
61 /* create an array of the window ids */
63 windows = g_new(Window, size);
65 for (it = client_list; it != NULL; it = it->next, ++win_it)
66 *win_it = ((ObClient*)it->data)->window;
70 PROP_SETA32(RootWindow(ob_display, ob_screen),
71 net_client_list, window, (guint32*)windows, size);
80 void client_foreach_transient(ObClient *self, ObClientForeachFunc func, void *data)
84 for (it = self->transients; it; it = it->next) {
85 if (!func(it->data, data)) return;
86 client_foreach_transient(it->data, func, data);
90 void client_foreach_ancestor(ObClient *self, ObClientForeachFunc func, void *data)
92 if (self->transient_for) {
93 if (self->transient_for != OB_TRAN_GROUP) {
94 if (!func(self->transient_for, data)) return;
95 client_foreach_ancestor(self->transient_for, func, data);
99 for (it = self->group->members; it; it = it->next)
100 if (it->data != self &&
101 !((ObClient*)it->data)->transient_for) {
102 if (!func(it->data, data)) return;
103 client_foreach_ancestor(it->data, func, data);
110 void client_manage_all()
112 unsigned int i, j, nchild;
115 XWindowAttributes attrib;
117 XQueryTree(ob_display, RootWindow(ob_display, ob_screen),
118 &w, &w, &children, &nchild);
120 /* remove all icon windows from the list */
121 for (i = 0; i < nchild; i++) {
122 if (children[i] == None) continue;
123 wmhints = XGetWMHints(ob_display, children[i]);
125 if ((wmhints->flags & IconWindowHint) &&
126 (wmhints->icon_window != children[i]))
127 for (j = 0; j < nchild; j++)
128 if (children[j] == wmhints->icon_window) {
136 for (i = 0; i < nchild; ++i) {
137 if (children[i] == None)
139 if (XGetWindowAttributes(ob_display, children[i], &attrib)) {
140 if (attrib.override_redirect) continue;
142 if (attrib.map_state != IsUnmapped)
143 client_manage(children[i]);
148 /* stack them as they were on startup!
149 why with stacking_lower? Why, because then windows who aren't in the
150 stacking list are on the top where you can see them instead of buried
152 for (i = startup_stack_size; i > 0; --i) {
155 w = startup_stack_order[i-1];
156 obw = g_hash_table_lookup(window_map, &w);
158 g_assert(WINDOW_IS_CLIENT(obw));
159 stacking_lower(CLIENT_AS_WINDOW(obw));
162 g_free(startup_stack_order);
163 startup_stack_order = NULL;
164 startup_stack_size = 0;
166 if (config_focus_new) {
169 active = g_hash_table_lookup(window_map, &startup_active);
171 g_assert(WINDOW_IS_CLIENT(active));
172 if (!client_focus(WINDOW_AS_CLIENT(active)))
173 focus_fallback(OB_FOCUS_FALLBACK_NOFOCUS);
175 focus_fallback(OB_FOCUS_FALLBACK_NOFOCUS);
179 void client_manage(Window window)
183 XWindowAttributes attrib;
184 XSetWindowAttributes attrib_set;
186 gboolean activate = FALSE;
190 /* check if it has already been unmapped by the time we started mapping
191 the grab does a sync so we don't have to here */
192 if (XCheckTypedWindowEvent(ob_display, window, DestroyNotify, &e) ||
193 XCheckTypedWindowEvent(ob_display, window, UnmapNotify, &e)) {
194 XPutBackEvent(ob_display, &e);
197 return; /* don't manage it */
200 /* make sure it isn't an override-redirect window */
201 if (!XGetWindowAttributes(ob_display, window, &attrib) ||
202 attrib.override_redirect) {
204 return; /* don't manage it */
207 /* is the window a docking app */
208 if ((wmhint = XGetWMHints(ob_display, window))) {
209 if ((wmhint->flags & StateHint) &&
210 wmhint->initial_state == WithdrawnState) {
211 dock_add(window, wmhint);
219 g_message("Managing window: %lx", window);
221 /* choose the events we want to receive on the CLIENT window */
222 attrib_set.event_mask = CLIENT_EVENTMASK;
223 attrib_set.do_not_propagate_mask = CLIENT_NOPROPAGATEMASK;
224 XChangeWindowAttributes(ob_display, window,
225 CWEventMask|CWDontPropagate, &attrib_set);
228 /* create the ObClient struct, and populate it from the hints on the
230 self = g_new(ObClient, 1);
231 self->obwin.type = Window_Client;
232 self->window = window;
233 client_get_all(self);
235 /* remove the client's border (and adjust re gravity) */
236 client_toggle_border(self, FALSE);
238 /* specify that if we exit, the window should not be destroyed and should
239 be reparented back to root automatically */
240 XChangeSaveSet(ob_display, window, SetModeInsert);
242 /* create the decoration frame for the client window */
243 self->frame = frame_new();
245 frame_grab_client(self->frame, self);
247 client_apply_startup_state(self);
251 /* add to client list/map */
252 client_list = g_list_append(client_list, self);
253 g_hash_table_insert(window_map, &self->window, self);
255 /* update the focus lists */
256 focus_order_add_new(self);
258 /* focus the new window? */
259 if (ob_state() != OB_STATE_STARTING && config_focus_new &&
260 /* note the check against Type_Normal/Dialog, not client_normal(self),
261 which would also include other types. in this case we want more
262 strict rules for focus */
263 (self->type == OB_CLIENT_TYPE_NORMAL ||
264 self->type == OB_CLIENT_TYPE_DIALOG))
266 if (self->desktop != screen_desktop)
268 /* activate the window */
269 stacking_add(CLIENT_AS_WINDOW(self));
274 gboolean group_foc = FALSE;
279 for (it = self->group->members; it; it = it->next)
281 if (client_focused(it->data))
289 (!self->transient_for && (!self->group ||
290 !self->group->members->next))) ||
291 client_search_focus_tree_full(self) ||
293 !client_normal(focus_client))
295 /* activate the window */
296 stacking_add(CLIENT_AS_WINDOW(self));
301 /* try to not get in the way */
302 stacking_add_nonintrusive(CLIENT_AS_WINDOW(self));
308 stacking_add(CLIENT_AS_WINDOW(self));
311 dispatch_client(Event_Client_New, self, 0, 0);
313 /* make sure the window is visible */
314 client_move_onscreen(self);
316 screen_update_areas();
318 client_showhide(self);
320 /* use client_focus instead of client_activate cuz client_activate does
321 stuff like switch desktops etc and I'm not interested in all that when
322 a window maps since its not based on an action from the user like
323 clicking a window to activate is. so keep the new window out of the way
325 if (activate) client_focus(self);
327 /* update the list hints */
330 dispatch_client(Event_Client_Mapped, self, 0, 0);
332 g_message("Managed window 0x%lx (%s)", window, self->class);
335 void client_unmanage_all()
337 while (client_list != NULL)
338 client_unmanage(client_list->data);
341 /* called by client_unmanage() to close any menus referencing this client */
342 void client_close_menus(gpointer key, gpointer value, gpointer self)
344 if (((ObMenu *)value)->client == (ObClient *)self)
345 menu_hide((ObMenu *)value);
348 void client_unmanage(ObClient *self)
353 g_message("Unmanaging window: %lx (%s)", self->window, self->class);
355 dispatch_client(Event_Client_Destroy, self, 0, 0);
356 g_assert(self != NULL);
358 /* remove the window from our save set */
359 XChangeSaveSet(ob_display, self->window, SetModeDelete);
361 /* we dont want events no more */
362 XSelectInput(ob_display, self->window, NoEventMask);
364 frame_hide(self->frame);
366 client_list = g_list_remove(client_list, self);
367 stacking_remove(self);
368 g_hash_table_remove(window_map, &self->window);
370 /* update the focus lists */
371 focus_order_remove(self);
373 /* once the client is out of the list, update the struts to remove it's
375 screen_update_areas();
377 /* tell our parent(s) that we're gone */
378 if (self->transient_for == OB_TRAN_GROUP) { /* transient of group */
381 for (it = self->group->members; it; it = it->next)
382 if (it->data != self)
383 ((ObClient*)it->data)->transients =
384 g_slist_remove(((ObClient*)it->data)->transients, self);
385 } else if (self->transient_for) { /* transient of window */
386 self->transient_for->transients =
387 g_slist_remove(self->transient_for->transients, self);
390 /* tell our transients that we're gone */
391 for (it = self->transients; it != NULL; it = it->next) {
392 if (((ObClient*)it->data)->transient_for != OB_TRAN_GROUP) {
393 ((ObClient*)it->data)->transient_for = NULL;
394 client_calc_layer(it->data);
398 if (moveresize_client == self)
399 moveresize_end(TRUE);
401 /* close any windows that are attached to this window */
402 g_hash_table_foreach(menu_hash, client_close_menus, self);
405 if (focus_client == self) {
408 /* focus the last focused window on the desktop, and ignore enter
409 events from the unmap so it doesnt mess with the focus */
410 while (XCheckTypedEvent(ob_display, EnterNotify, &e));
411 client_unfocus(self);
414 /* remove from its group */
416 group_remove(self->group, self);
420 /* dispatch the unmapped event */
421 dispatch_client(Event_Client_Unmapped, self, 0, 0);
422 g_assert(self != NULL);
424 /* give the client its border back */
425 client_toggle_border(self, TRUE);
427 /* reparent the window out of the frame, and free the frame */
428 frame_release_client(self->frame, self);
431 if (ob_state() != OB_STATE_EXITING) {
432 /* these values should not be persisted across a window
434 prop_erase(self->window, prop_atoms.net_wm_desktop);
435 prop_erase(self->window, prop_atoms.net_wm_state);
437 /* if we're left in an iconic state, the client wont be mapped. this is
438 bad, since we will no longer be managing the window on restart */
440 XMapWindow(ob_display, self->window);
444 g_message("Unmanaged window 0x%lx", self->window);
446 /* free all data allocated in the client struct */
447 g_slist_free(self->transients);
448 for (j = 0; j < self->nicons; ++j)
449 g_free(self->icons[j].data);
450 if (self->nicons > 0)
453 g_free(self->icon_title);
459 /* update the list hints */
463 void client_move_onscreen(ObClient *self)
466 int x = self->frame->area.x, y = self->frame->area.y;
468 /* XXX watch for xinerama dead areas */
469 a = screen_area(self->desktop);
470 if (x >= a->x + a->width - 1)
471 x = a->x + a->width - self->frame->area.width;
472 if (y >= a->y + a->height - 1)
473 y = a->y + a->height - self->frame->area.height;
474 if (x + self->frame->area.width - 1 < a->x)
476 if (y + self->frame->area.height - 1< a->y)
479 frame_frame_gravity(self->frame, &x, &y); /* get where the client
481 client_configure(self, OB_CORNER_TOPLEFT, x, y,
482 self->area.width, self->area.height,
486 static void client_toggle_border(ObClient *self, gboolean show)
488 /* adjust our idea of where the client is, based on its border. When the
489 border is removed, the client should now be considered to be in a
491 when re-adding the border to the client, the same operation needs to be
493 int oldx = self->area.x, oldy = self->area.y;
494 int x = oldx, y = oldy;
495 switch(self->gravity) {
497 case NorthWestGravity:
499 case SouthWestGravity:
501 case NorthEastGravity:
503 case SouthEastGravity:
504 if (show) x -= self->border_width * 2;
505 else x += self->border_width * 2;
512 if (show) x -= self->border_width;
513 else x += self->border_width;
516 switch(self->gravity) {
518 case NorthWestGravity:
520 case NorthEastGravity:
522 case SouthWestGravity:
524 case SouthEastGravity:
525 if (show) y -= self->border_width * 2;
526 else y += self->border_width * 2;
533 if (show) y -= self->border_width;
534 else y += self->border_width;
541 XSetWindowBorderWidth(ob_display, self->window, self->border_width);
543 /* move the client so it is back it the right spot _with_ its
545 if (x != oldx || y != oldy)
546 XMoveWindow(ob_display, self->window, x, y);
548 XSetWindowBorderWidth(ob_display, self->window, 0);
552 static void client_get_all(ObClient *self)
554 /* update EVERYTHING!! */
556 self->ignore_unmaps = 0;
560 self->title = self->icon_title = NULL;
561 self->title_count = 1;
562 self->name = self->class = self->role = NULL;
563 self->wmstate = NormalState;
564 self->transient = FALSE;
565 self->transients = NULL;
566 self->transient_for = NULL;
568 self->urgent = FALSE;
569 self->positioned = FALSE;
570 self->decorate = TRUE;
574 client_get_area(self);
575 client_update_transient_for(self);
576 client_update_wmhints(self);
577 client_get_desktop(self);
578 client_get_state(self);
579 client_get_shaped(self);
581 client_get_mwm_hints(self);
582 client_get_type(self);/* this can change the mwmhints for special cases */
584 client_update_protocols(self);
586 client_get_gravity(self); /* get the attribute gravity */
587 client_update_normal_hints(self); /* this may override the attribute
590 /* got the type, the mwmhints, the protocols, and the normal hints
591 (min/max sizes), so we're ready to set up the decorations/functions */
592 client_setup_decor_and_functions(self);
594 client_update_title(self);
595 client_update_class(self);
596 client_update_strut(self);
597 client_update_icons(self);
599 client_change_state(self);
602 static void client_get_area(ObClient *self)
604 XWindowAttributes wattrib;
607 ret = XGetWindowAttributes(ob_display, self->window, &wattrib);
608 g_assert(ret != BadWindow);
610 RECT_SET(self->area, wattrib.x, wattrib.y, wattrib.width, wattrib.height);
611 self->border_width = wattrib.border_width;
614 static void client_get_desktop(ObClient *self)
616 guint32 d = screen_num_desktops; /* an always-invalid value */
618 if (PROP_GET32(self->window, net_wm_desktop, cardinal, &d)) {
619 if (d >= screen_num_desktops && d != DESKTOP_ALL)
620 self->desktop = screen_num_desktops - 1;
624 gboolean trdesk = FALSE;
626 if (self->transient_for) {
627 if (self->transient_for != OB_TRAN_GROUP) {
628 self->desktop = self->transient_for->desktop;
633 for (it = self->group->members; it; it = it->next)
634 if (it->data != self &&
635 !((ObClient*)it->data)->transient_for) {
636 self->desktop = ((ObClient*)it->data)->desktop;
643 /* defaults to the current desktop */
644 self->desktop = screen_desktop;
647 if (self->desktop != d) {
648 /* set the desktop hint, to make sure that it always exists */
649 PROP_SET32(self->window, net_wm_desktop, cardinal, self->desktop);
653 static void client_get_state(ObClient *self)
658 self->modal = self->shaded = self->max_horz = self->max_vert =
659 self->fullscreen = self->above = self->below = self->iconic =
660 self->skip_taskbar = self->skip_pager = FALSE;
662 if (PROP_GETA32(self->window, net_wm_state, atom, &state, &num)) {
664 for (i = 0; i < num; ++i) {
665 if (state[i] == prop_atoms.net_wm_state_modal)
667 else if (state[i] == prop_atoms.net_wm_state_shaded)
669 else if (state[i] == prop_atoms.net_wm_state_hidden)
671 else if (state[i] == prop_atoms.net_wm_state_skip_taskbar)
672 self->skip_taskbar = TRUE;
673 else if (state[i] == prop_atoms.net_wm_state_skip_pager)
674 self->skip_pager = TRUE;
675 else if (state[i] == prop_atoms.net_wm_state_fullscreen)
676 self->fullscreen = TRUE;
677 else if (state[i] == prop_atoms.net_wm_state_maximized_vert)
678 self->max_vert = TRUE;
679 else if (state[i] == prop_atoms.net_wm_state_maximized_horz)
680 self->max_horz = TRUE;
681 else if (state[i] == prop_atoms.net_wm_state_above)
683 else if (state[i] == prop_atoms.net_wm_state_below)
691 static void client_get_shaped(ObClient *self)
693 self->shaped = FALSE;
695 if (extensions_shape) {
700 XShapeSelectInput(ob_display, self->window, ShapeNotifyMask);
702 XShapeQueryExtents(ob_display, self->window, &s, &foo,
703 &foo, &ufoo, &ufoo, &foo, &foo, &foo, &ufoo,
705 self->shaped = (s != 0);
710 void client_update_transient_for(ObClient *self)
715 if (XGetTransientForHint(ob_display, self->window, &t)) {
716 self->transient = TRUE;
717 if (t != self->window) { /* cant be transient to itself! */
718 c = g_hash_table_lookup(window_map, &t);
719 /* if this happens then we need to check for it*/
721 g_assert(!c || WINDOW_IS_CLIENT(c));
723 if (!c && self->group) {
724 /* not transient to a client, see if it is transient for a
726 if (t == self->group->leader ||
728 t == RootWindow(ob_display, ob_screen)) {
729 /* window is a transient for its group! */
735 self->transient = FALSE;
737 /* if anything has changed... */
738 if (c != self->transient_for) {
739 if (self->transient_for == OB_TRAN_GROUP) { /* transient of group */
742 /* remove from old parents */
743 for (it = self->group->members; it; it = it->next)
744 if (it->data != self &&
745 !((ObClient*)it->data)->transient_for)
746 ((ObClient*)it->data)->transients =
747 g_slist_remove(((ObClient*)it->data)->transients, self);
748 } else if (self->transient_for != NULL) { /* transient of window */
749 /* remove from old parent */
750 self->transient_for->transients =
751 g_slist_remove(self->transient_for->transients, self);
753 self->transient_for = c;
754 if (self->transient_for == OB_TRAN_GROUP) { /* transient of group */
757 /* add to new parents */
758 for (it = self->group->members; it; it = it->next)
759 if (it->data != self &&
760 !((ObClient*)it->data)->transient_for)
761 ((ObClient*)it->data)->transients =
762 g_slist_append(((ObClient*)it->data)->transients, self);
764 /* remove all transients which are in the group, that causes
765 circlular pointer hell of doom */
766 for (it = self->group->members; it; it = it->next) {
768 for (sit = self->transients; sit; sit = next) {
770 if (sit->data == it->data)
771 self->transients = g_slist_remove(self->transients,
775 } else if (self->transient_for != NULL) { /* transient of window */
776 /* add to new parent */
777 self->transient_for->transients =
778 g_slist_append(self->transient_for->transients, self);
783 static void client_get_mwm_hints(ObClient *self)
788 self->mwmhints.flags = 0; /* default to none */
790 if (PROP_GETA32(self->window, motif_wm_hints, motif_wm_hints,
792 if (num >= OB_MWM_ELEMENTS) {
793 self->mwmhints.flags = hints[0];
794 self->mwmhints.functions = hints[1];
795 self->mwmhints.decorations = hints[2];
801 void client_get_type(ObClient *self)
808 if (PROP_GETA32(self->window, net_wm_window_type, atom, &val, &num)) {
809 /* use the first value that we know about in the array */
810 for (i = 0; i < num; ++i) {
811 if (val[i] == prop_atoms.net_wm_window_type_desktop)
812 self->type = OB_CLIENT_TYPE_DESKTOP;
813 else if (val[i] == prop_atoms.net_wm_window_type_dock)
814 self->type = OB_CLIENT_TYPE_DOCK;
815 else if (val[i] == prop_atoms.net_wm_window_type_toolbar)
816 self->type = OB_CLIENT_TYPE_TOOLBAR;
817 else if (val[i] == prop_atoms.net_wm_window_type_menu)
818 self->type = OB_CLIENT_TYPE_MENU;
819 else if (val[i] == prop_atoms.net_wm_window_type_utility)
820 self->type = OB_CLIENT_TYPE_UTILITY;
821 else if (val[i] == prop_atoms.net_wm_window_type_splash)
822 self->type = OB_CLIENT_TYPE_SPLASH;
823 else if (val[i] == prop_atoms.net_wm_window_type_dialog)
824 self->type = OB_CLIENT_TYPE_DIALOG;
825 else if (val[i] == prop_atoms.net_wm_window_type_normal)
826 self->type = OB_CLIENT_TYPE_NORMAL;
827 else if (val[i] == prop_atoms.kde_net_wm_window_type_override) {
828 /* prevent this window from getting any decor or
830 self->mwmhints.flags &= (OB_MWM_FLAG_FUNCTIONS |
831 OB_MWM_FLAG_DECORATIONS);
832 self->mwmhints.decorations = 0;
833 self->mwmhints.functions = 0;
835 if (self->type != (ObClientType) -1)
836 break; /* grab the first legit type */
841 if (self->type == (ObClientType) -1) {
842 /*the window type hint was not set, which means we either classify
843 ourself as a normal window or a dialog, depending on if we are a
846 self->type = OB_CLIENT_TYPE_DIALOG;
848 self->type = OB_CLIENT_TYPE_NORMAL;
852 void client_update_protocols(ObClient *self)
857 self->focus_notify = FALSE;
858 self->delete_window = FALSE;
860 if (PROP_GETA32(self->window, wm_protocols, atom, &proto, &num_return)) {
861 for (i = 0; i < num_return; ++i) {
862 if (proto[i] == prop_atoms.wm_delete_window) {
863 /* this means we can request the window to close */
864 self->delete_window = TRUE;
865 } else if (proto[i] == prop_atoms.wm_take_focus)
866 /* if this protocol is requested, then the window will be
867 notified whenever we want it to receive focus */
868 self->focus_notify = TRUE;
874 static void client_get_gravity(ObClient *self)
876 XWindowAttributes wattrib;
879 ret = XGetWindowAttributes(ob_display, self->window, &wattrib);
880 g_assert(ret != BadWindow);
881 self->gravity = wattrib.win_gravity;
884 void client_update_normal_hints(ObClient *self)
888 int oldgravity = self->gravity;
891 self->min_ratio = 0.0f;
892 self->max_ratio = 0.0f;
893 SIZE_SET(self->size_inc, 1, 1);
894 SIZE_SET(self->base_size, 0, 0);
895 SIZE_SET(self->min_size, 0, 0);
896 SIZE_SET(self->max_size, G_MAXINT, G_MAXINT);
898 /* get the hints from the window */
899 if (XGetWMNormalHints(ob_display, self->window, &size, &ret)) {
900 self->positioned = !!(size.flags & (PPosition|USPosition));
902 if (size.flags & PWinGravity) {
903 self->gravity = size.win_gravity;
905 /* if the client has a frame, i.e. has already been mapped and
906 is changing its gravity */
907 if (self->frame && self->gravity != oldgravity) {
908 /* move our idea of the client's position based on its new
910 self->area.x = self->frame->area.x;
911 self->area.y = self->frame->area.y;
912 frame_frame_gravity(self->frame, &self->area.x, &self->area.y);
916 if (size.flags & PAspect) {
917 if (size.min_aspect.y)
918 self->min_ratio = (float)size.min_aspect.x / size.min_aspect.y;
919 if (size.max_aspect.y)
920 self->max_ratio = (float)size.max_aspect.x / size.max_aspect.y;
923 if (size.flags & PMinSize)
924 SIZE_SET(self->min_size, size.min_width, size.min_height);
926 if (size.flags & PMaxSize)
927 SIZE_SET(self->max_size, size.max_width, size.max_height);
929 if (size.flags & PBaseSize)
930 SIZE_SET(self->base_size, size.base_width, size.base_height);
932 if (size.flags & PResizeInc)
933 SIZE_SET(self->size_inc, size.width_inc, size.height_inc);
937 void client_setup_decor_and_functions(ObClient *self)
939 /* start with everything (cept fullscreen) */
940 self->decorations = (OB_FRAME_DECOR_TITLEBAR |
941 OB_FRAME_DECOR_HANDLE |
942 OB_FRAME_DECOR_GRIPS |
943 OB_FRAME_DECOR_BORDER |
944 OB_FRAME_DECOR_ICON |
945 OB_FRAME_DECOR_ALLDESKTOPS |
946 OB_FRAME_DECOR_ICONIFY |
947 OB_FRAME_DECOR_MAXIMIZE |
948 OB_FRAME_DECOR_SHADE);
949 self->functions = (OB_CLIENT_FUNC_RESIZE |
950 OB_CLIENT_FUNC_MOVE |
951 OB_CLIENT_FUNC_ICONIFY |
952 OB_CLIENT_FUNC_MAXIMIZE |
953 OB_CLIENT_FUNC_SHADE);
954 if (self->delete_window) {
955 self->functions |= OB_CLIENT_FUNC_CLOSE;
956 self->decorations |= OB_FRAME_DECOR_CLOSE;
959 if (!(self->min_size.width < self->max_size.width ||
960 self->min_size.height < self->max_size.height))
961 self->functions &= ~OB_CLIENT_FUNC_RESIZE;
963 switch (self->type) {
964 case OB_CLIENT_TYPE_NORMAL:
965 /* normal windows retain all of the possible decorations and
966 functionality, and are the only windows that you can fullscreen */
967 self->functions |= OB_CLIENT_FUNC_FULLSCREEN;
970 case OB_CLIENT_TYPE_DIALOG:
971 case OB_CLIENT_TYPE_UTILITY:
972 /* these windows cannot be maximized */
973 self->functions &= ~OB_CLIENT_FUNC_MAXIMIZE;
976 case OB_CLIENT_TYPE_MENU:
977 case OB_CLIENT_TYPE_TOOLBAR:
978 /* these windows get less functionality */
979 self->functions &= ~(OB_CLIENT_FUNC_ICONIFY | OB_CLIENT_FUNC_RESIZE);
982 case OB_CLIENT_TYPE_DESKTOP:
983 case OB_CLIENT_TYPE_DOCK:
984 case OB_CLIENT_TYPE_SPLASH:
985 /* none of these windows are manipulated by the window manager */
986 self->decorations = 0;
991 /* Mwm Hints are applied subtractively to what has already been chosen for
992 decor and functionality */
993 if (self->mwmhints.flags & OB_MWM_FLAG_DECORATIONS) {
994 if (! (self->mwmhints.decorations & OB_MWM_DECOR_ALL)) {
995 if (! ((self->mwmhints.decorations & OB_MWM_DECOR_HANDLE) ||
996 (self->mwmhints.decorations & OB_MWM_DECOR_TITLE)))
997 /* if the mwm hints request no handle or title, then all
998 decorations are disabled */
999 self->decorations = 0;
1003 if (self->mwmhints.flags & OB_MWM_FLAG_FUNCTIONS) {
1004 if (! (self->mwmhints.functions & OB_MWM_FUNC_ALL)) {
1005 if (! (self->mwmhints.functions & OB_MWM_FUNC_RESIZE))
1006 self->functions &= ~OB_CLIENT_FUNC_RESIZE;
1007 if (! (self->mwmhints.functions & OB_MWM_FUNC_MOVE))
1008 self->functions &= ~OB_CLIENT_FUNC_MOVE;
1009 /* dont let mwm hints kill any buttons
1010 if (! (self->mwmhints.functions & OB_MWM_FUNC_ICONIFY))
1011 self->functions &= ~OB_CLIENT_FUNC_ICONIFY;
1012 if (! (self->mwmhints.functions & OB_MWM_FUNC_MAXIMIZE))
1013 self->functions &= ~OB_CLIENT_FUNC_MAXIMIZE;
1015 /* dont let mwm hints kill the close button
1016 if (! (self->mwmhints.functions & MwmFunc_Close))
1017 self->functions &= ~OB_CLIENT_FUNC_CLOSE; */
1021 if (!(self->functions & OB_CLIENT_FUNC_SHADE))
1022 self->decorations &= ~OB_FRAME_DECOR_SHADE;
1023 if (!(self->functions & OB_CLIENT_FUNC_ICONIFY))
1024 self->decorations &= ~OB_FRAME_DECOR_ICONIFY;
1025 if (!(self->functions & OB_CLIENT_FUNC_RESIZE))
1026 self->decorations &= ~OB_FRAME_DECOR_GRIPS;
1028 /* can't maximize without moving/resizing */
1029 if (!((self->functions & OB_CLIENT_FUNC_MAXIMIZE) &&
1030 (self->functions & OB_CLIENT_FUNC_MOVE) &&
1031 (self->functions & OB_CLIENT_FUNC_RESIZE))) {
1032 self->functions &= ~OB_CLIENT_FUNC_MAXIMIZE;
1033 self->decorations &= ~OB_FRAME_DECOR_MAXIMIZE;
1036 /* finally, the user can have requested no decorations, which overrides
1038 if (!self->decorate)
1039 self->decorations = 0;
1041 /* if we don't have a titlebar, then we cannot shade! */
1042 if (!(self->decorations & OB_FRAME_DECOR_TITLEBAR))
1043 self->functions &= ~OB_CLIENT_FUNC_SHADE;
1045 /* now we need to check against rules for the client's current state */
1046 if (self->fullscreen) {
1047 self->functions &= (OB_CLIENT_FUNC_CLOSE |
1048 OB_CLIENT_FUNC_FULLSCREEN |
1049 OB_CLIENT_FUNC_ICONIFY);
1050 self->decorations = 0;
1053 client_change_allowed_actions(self);
1056 /* this makes sure that these windows appear on all desktops */
1057 if (self->type == OB_CLIENT_TYPE_DESKTOP &&
1058 self->desktop != DESKTOP_ALL)
1059 client_set_desktop(self, DESKTOP_ALL, FALSE);
1061 /* adjust the client's decorations, etc. */
1062 client_reconfigure(self);
1064 /* this makes sure that these windows appear on all desktops */
1065 if (self->type == OB_CLIENT_TYPE_DESKTOP &&
1066 self->desktop != DESKTOP_ALL)
1068 self->desktop = DESKTOP_ALL;
1073 static void client_change_allowed_actions(ObClient *self)
1078 /* desktop windows are kept on all desktops */
1079 if (self->type != OB_CLIENT_TYPE_DESKTOP)
1080 actions[num++] = prop_atoms.net_wm_action_change_desktop;
1082 if (self->functions & OB_CLIENT_FUNC_SHADE)
1083 actions[num++] = prop_atoms.net_wm_action_shade;
1084 if (self->functions & OB_CLIENT_FUNC_CLOSE)
1085 actions[num++] = prop_atoms.net_wm_action_close;
1086 if (self->functions & OB_CLIENT_FUNC_MOVE)
1087 actions[num++] = prop_atoms.net_wm_action_move;
1088 if (self->functions & OB_CLIENT_FUNC_ICONIFY)
1089 actions[num++] = prop_atoms.net_wm_action_minimize;
1090 if (self->functions & OB_CLIENT_FUNC_RESIZE)
1091 actions[num++] = prop_atoms.net_wm_action_resize;
1092 if (self->functions & OB_CLIENT_FUNC_FULLSCREEN)
1093 actions[num++] = prop_atoms.net_wm_action_fullscreen;
1094 if (self->functions & OB_CLIENT_FUNC_MAXIMIZE) {
1095 actions[num++] = prop_atoms.net_wm_action_maximize_horz;
1096 actions[num++] = prop_atoms.net_wm_action_maximize_vert;
1099 PROP_SETA32(self->window, net_wm_allowed_actions, atom, actions, num);
1101 /* make sure the window isn't breaking any rules now */
1103 if (!(self->functions & OB_CLIENT_FUNC_SHADE) && self->shaded) {
1104 if (self->frame) client_shade(self, FALSE);
1105 else self->shaded = FALSE;
1107 if (!(self->functions & OB_CLIENT_FUNC_ICONIFY) && self->iconic) {
1108 g_message("UNSETTING ICONIC");
1109 if (self->frame) client_iconify(self, FALSE, TRUE);
1110 else self->iconic = FALSE;
1112 if (!(self->functions & OB_CLIENT_FUNC_FULLSCREEN) && self->fullscreen) {
1113 if (self->frame) client_fullscreen(self, FALSE, TRUE);
1114 else self->fullscreen = FALSE;
1116 if (!(self->functions & OB_CLIENT_FUNC_MAXIMIZE) && (self->max_horz ||
1118 if (self->frame) client_maximize(self, FALSE, 0, TRUE);
1119 else self->max_vert = self->max_horz = FALSE;
1123 void client_reconfigure(ObClient *self)
1125 /* by making this pass FALSE for user, we avoid the emacs event storm where
1126 every configurenotify causes an update in its normal hints, i think this
1127 is generally what we want anyways... */
1128 client_configure(self, OB_CORNER_TOPLEFT, self->area.x, self->area.y,
1129 self->area.width, self->area.height, FALSE, TRUE);
1132 void client_update_wmhints(ObClient *self)
1135 gboolean ur = FALSE;
1138 /* assume a window takes input if it doesnt specify */
1139 self->can_focus = TRUE;
1141 if ((hints = XGetWMHints(ob_display, self->window)) != NULL) {
1142 if (hints->flags & InputHint)
1143 self->can_focus = hints->input;
1145 /* only do this when first managing the window *AND* when we aren't
1147 if (ob_state() != OB_STATE_STARTING && self->frame == NULL)
1148 if (hints->flags & StateHint)
1149 self->iconic = hints->initial_state == IconicState;
1151 if (hints->flags & XUrgencyHint)
1154 if (!(hints->flags & WindowGroupHint))
1155 hints->window_group = None;
1157 /* did the group state change? */
1158 if (hints->window_group !=
1159 (self->group ? self->group->leader : None)) {
1160 /* remove from the old group if there was one */
1161 if (self->group != NULL) {
1162 /* remove transients of the group */
1163 for (it = self->group->members; it; it = it->next)
1164 self->transients = g_slist_remove(self->transients,
1166 group_remove(self->group, self);
1169 if (hints->window_group != None) {
1170 self->group = group_add(hints->window_group, self);
1172 /* i can only have transients from the group if i am not
1174 if (!self->transient_for) {
1175 /* add other transients of the group that are already
1177 for (it = self->group->members; it; it = it->next)
1178 if (it->data != self &&
1179 ((ObClient*)it->data)->transient_for == OB_TRAN_GROUP)
1180 self->transients = g_slist_append(self->transients,
1185 /* the WM_HINTS can contain an icon */
1186 client_update_icons(self);
1188 /* because the self->transient flag wont change from this call,
1189 we don't need to update the window's type and such, only its
1190 transient_for, and the transients lists of other windows in
1191 the group may be affected */
1192 client_update_transient_for(self);
1198 if (ur != self->urgent) {
1200 g_message("Urgent Hint for 0x%lx: %s", self->window,
1202 /* fire the urgent callback if we're mapped, otherwise, wait until
1203 after we're mapped */
1205 dispatch_client(Event_Client_Urgent, self, self->urgent, 0);
1209 void client_update_title(ObClient *self)
1215 gboolean read_title;
1217 g_free(self->title);
1220 if (!PROP_GETS(self->window, net_wm_name, utf8, &data))
1221 /* try old x stuff */
1222 if (!PROP_GETS(self->window, wm_name, locale, &data))
1223 data = g_strdup("Unnamed Window");
1225 /* look for duplicates and append a number */
1227 for (it = client_list; it; it = it->next)
1228 if (it->data != self) {
1229 ObClient *c = it->data;
1230 if (0 == strncmp(c->title, data, strlen(data)))
1231 nums |= 1 << c->title_count;
1233 /* find first free number */
1234 for (i = 1; i <= 32; ++i)
1235 if (!(nums & (1 << i))) {
1236 if (self->title_count == 1 || i == 1)
1237 self->title_count = i;
1240 /* dont display the number for the first window */
1241 if (self->title_count > 1) {
1242 char *vdata, *ndata;
1243 ndata = g_strdup_printf(" - [%u]", self->title_count);
1244 vdata = g_strconcat(data, ndata, NULL);
1250 PROP_SETS(self->window, net_wm_visible_name, data);
1255 frame_adjust_title(self->frame);
1257 /* update the icon title */
1259 g_free(self->icon_title);
1263 if (!PROP_GETS(self->window, net_wm_icon_name, utf8, &data))
1264 /* try old x stuff */
1265 if (!PROP_GETS(self->window, wm_icon_name, locale, &data)) {
1266 data = g_strdup(self->title);
1270 /* append the title count, dont display the number for the first window */
1271 if (read_title && self->title_count > 1) {
1272 char *vdata, *ndata;
1273 ndata = g_strdup_printf(" - [%u]", self->title_count);
1274 vdata = g_strconcat(data, ndata, NULL);
1280 PROP_SETS(self->window, net_wm_visible_icon_name, data);
1282 self->icon_title = data;
1285 void client_update_class(ObClient *self)
1290 if (self->name) g_free(self->name);
1291 if (self->class) g_free(self->class);
1292 if (self->role) g_free(self->role);
1294 self->name = self->class = self->role = NULL;
1296 if (PROP_GETSS(self->window, wm_class, locale, &data)) {
1298 self->name = g_strdup(data[0]);
1300 self->class = g_strdup(data[1]);
1305 if (PROP_GETS(self->window, wm_window_role, locale, &s))
1306 self->role = g_strdup(s);
1308 if (self->name == NULL) self->name = g_strdup("");
1309 if (self->class == NULL) self->class = g_strdup("");
1310 if (self->role == NULL) self->role = g_strdup("");
1313 void client_update_strut(ObClient *self)
1318 if (!PROP_GETA32(self->window, net_wm_strut, cardinal, &data, &num)) {
1319 STRUT_SET(self->strut, 0, 0, 0, 0);
1322 STRUT_SET(self->strut, data[0], data[2], data[1], data[3]);
1324 STRUT_SET(self->strut, 0, 0, 0, 0);
1328 /* updating here is pointless while we're being mapped cuz we're not in
1329 the client list yet */
1331 screen_update_areas();
1334 void client_update_icons(ObClient *self)
1340 for (i = 0; i < self->nicons; ++i)
1341 g_free(self->icons[i].data);
1342 if (self->nicons > 0)
1343 g_free(self->icons);
1346 if (PROP_GETA32(self->window, net_wm_icon, cardinal, &data, &num)) {
1347 /* figure out how many valid icons are in here */
1349 while (num - i > 2) {
1353 if (i > num || w*h == 0) break;
1357 self->icons = g_new(ObClientIcon, self->nicons);
1359 /* store the icons */
1361 for (j = 0; j < self->nicons; ++j) {
1364 w = self->icons[j].width = data[i++];
1365 h = self->icons[j].height = data[i++];
1367 if (w*h == 0) continue;
1369 self->icons[j].data = g_new(RrPixel32, w * h);
1370 for (x = 0, y = 0, t = 0; t < w * h; ++t, ++x, ++i) {
1375 self->icons[j].data[t] =
1376 (((data[i] >> 24) & 0xff) << RrDefaultAlphaOffset) +
1377 (((data[i] >> 16) & 0xff) << RrDefaultRedOffset) +
1378 (((data[i] >> 8) & 0xff) << RrDefaultGreenOffset) +
1379 (((data[i] >> 0) & 0xff) << RrDefaultBlueOffset);
1385 } else if (PROP_GETA32(self->window, kwm_win_icon,
1386 kwm_win_icon, &data, &num)) {
1389 self->icons = g_new(ObClientIcon, self->nicons);
1390 xerror_set_ignore(TRUE);
1391 if (!RrPixmapToRGBA(ob_rr_inst,
1393 &self->icons[self->nicons-1].width,
1394 &self->icons[self->nicons-1].height,
1395 &self->icons[self->nicons-1].data)) {
1396 g_free(&self->icons[self->nicons-1]);
1399 xerror_set_ignore(FALSE);
1405 if ((hints = XGetWMHints(ob_display, self->window))) {
1406 if (hints->flags & IconPixmapHint) {
1408 self->icons = g_new(ObClientIcon, self->nicons);
1409 xerror_set_ignore(TRUE);
1410 if (!RrPixmapToRGBA(ob_rr_inst,
1412 (hints->flags & IconMaskHint ?
1413 hints->icon_mask : None),
1414 &self->icons[self->nicons-1].width,
1415 &self->icons[self->nicons-1].height,
1416 &self->icons[self->nicons-1].data)){
1417 g_free(&self->icons[self->nicons-1]);
1420 xerror_set_ignore(FALSE);
1427 frame_adjust_icon(self->frame);
1430 static void client_change_state(ObClient *self)
1433 guint32 netstate[10];
1436 state[0] = self->wmstate;
1438 PROP_SETA32(self->window, wm_state, wm_state, state, 2);
1442 netstate[num++] = prop_atoms.net_wm_state_modal;
1444 netstate[num++] = prop_atoms.net_wm_state_shaded;
1446 netstate[num++] = prop_atoms.net_wm_state_hidden;
1447 if (self->skip_taskbar)
1448 netstate[num++] = prop_atoms.net_wm_state_skip_taskbar;
1449 if (self->skip_pager)
1450 netstate[num++] = prop_atoms.net_wm_state_skip_pager;
1451 if (self->fullscreen)
1452 netstate[num++] = prop_atoms.net_wm_state_fullscreen;
1454 netstate[num++] = prop_atoms.net_wm_state_maximized_vert;
1456 netstate[num++] = prop_atoms.net_wm_state_maximized_horz;
1458 netstate[num++] = prop_atoms.net_wm_state_above;
1460 netstate[num++] = prop_atoms.net_wm_state_below;
1461 PROP_SETA32(self->window, net_wm_state, atom, netstate, num);
1463 client_calc_layer(self);
1466 frame_adjust_state(self->frame);
1469 ObClient *client_search_focus_tree(ObClient *self)
1474 for (it = self->transients; it != NULL; it = it->next) {
1475 if (client_focused(it->data)) return it->data;
1476 if ((ret = client_search_focus_tree(it->data))) return ret;
1481 ObClient *client_search_focus_tree_full(ObClient *self)
1483 if (self->transient_for) {
1484 if (self->transient_for != OB_TRAN_GROUP) {
1485 return client_search_focus_tree_full(self->transient_for);
1488 gboolean recursed = FALSE;
1490 for (it = self->group->members; it; it = it->next)
1491 if (!((ObClient*)it->data)->transient_for) {
1493 if ((c = client_search_focus_tree_full(it->data)))
1502 /* this function checks the whole tree, the client_search_focus_tree~
1503 does not, so we need to check this window */
1504 if (client_focused(self))
1506 return client_search_focus_tree(self);
1509 static ObStackingLayer calc_layer(ObClient *self)
1513 if (self->fullscreen) l = OB_STACKING_LAYER_FULLSCREEN;
1514 else if (self->type == OB_CLIENT_TYPE_DESKTOP)
1515 l = OB_STACKING_LAYER_DESKTOP;
1516 else if (self->type == OB_CLIENT_TYPE_DOCK) {
1517 if (!self->below) l = OB_STACKING_LAYER_TOP;
1518 else l = OB_STACKING_LAYER_NORMAL;
1520 else if (self->above) l = OB_STACKING_LAYER_ABOVE;
1521 else if (self->below) l = OB_STACKING_LAYER_BELOW;
1522 else l = OB_STACKING_LAYER_NORMAL;
1527 static void client_calc_layer_recursive(ObClient *self, ObClient *orig,
1528 ObStackingLayer l, gboolean raised)
1530 ObStackingLayer old, own;
1534 own = calc_layer(self);
1535 self->layer = l > own ? l : own;
1537 for (it = self->transients; it; it = it->next)
1538 client_calc_layer_recursive(it->data, orig,
1539 l, raised ? raised : l != old);
1541 if (!raised && l != old)
1542 if (orig->frame) { /* only restack if the original window is managed */
1543 /* XXX add_non_intrusive ever? */
1544 stacking_remove(CLIENT_AS_WINDOW(self));
1545 stacking_add(CLIENT_AS_WINDOW(self));
1549 void client_calc_layer(ObClient *self)
1556 /* transients take on the layer of their parents */
1557 self = client_search_top_transient(self);
1559 l = calc_layer(self);
1561 client_calc_layer_recursive(self, orig, l, FALSE);
1564 gboolean client_should_show(ObClient *self)
1566 if (self->iconic) return FALSE;
1567 else if (!(self->desktop == screen_desktop ||
1568 self->desktop == DESKTOP_ALL)) return FALSE;
1569 else if (client_normal(self) && screen_showing_desktop) return FALSE;
1574 static void client_showhide(ObClient *self)
1577 if (client_should_show(self))
1578 frame_show(self->frame);
1580 frame_hide(self->frame);
1583 gboolean client_normal(ObClient *self) {
1584 return ! (self->type == OB_CLIENT_TYPE_DESKTOP ||
1585 self->type == OB_CLIENT_TYPE_DOCK ||
1586 self->type == OB_CLIENT_TYPE_SPLASH);
1589 static void client_apply_startup_state(ObClient *self)
1591 /* these are in a carefully crafted order.. */
1594 self->iconic = FALSE;
1595 client_iconify(self, TRUE, FALSE);
1597 if (self->fullscreen) {
1598 self->fullscreen = FALSE;
1599 client_fullscreen(self, TRUE, FALSE);
1602 self->shaded = FALSE;
1603 client_shade(self, TRUE);
1606 dispatch_client(Event_Client_Urgent, self, self->urgent, 0);
1608 if (self->max_vert && self->max_horz) {
1609 self->max_vert = self->max_horz = FALSE;
1610 client_maximize(self, TRUE, 0, FALSE);
1611 } else if (self->max_vert) {
1612 self->max_vert = FALSE;
1613 client_maximize(self, TRUE, 2, FALSE);
1614 } else if (self->max_horz) {
1615 self->max_horz = FALSE;
1616 client_maximize(self, TRUE, 1, FALSE);
1619 /* nothing to do for the other states:
1628 void client_configure(ObClient *self, ObCorner anchor,
1629 int x, int y, int w, int h,
1630 gboolean user, gboolean final)
1632 gboolean moved = FALSE, resized = FALSE;
1634 /* gets the frame's position */
1635 frame_client_gravity(self->frame, &x, &y);
1637 /* these positions are frame positions, not client positions */
1639 /* set the size and position if fullscreen */
1640 if (self->fullscreen) {
1643 XF86VidModeModeLine mode;
1648 i = client_monitor(self);
1649 a = screen_physical_area_monitor(i);
1652 if (i == 0 && /* primary head */
1653 extensions_vidmode &&
1654 XF86VidModeGetViewPort(ob_display, ob_screen, &x, &y) &&
1655 /* get the mode last so the mode.privsize isnt freed incorrectly */
1656 XF86VidModeGetModeLine(ob_display, ob_screen, &dot, &mode)) {
1661 if (mode.privsize) XFree(mode.private);
1671 user = FALSE; /* ignore that increment etc shit when in fullscreen */
1675 a = screen_area_monitor(self->desktop, client_monitor(self));
1677 /* set the size and position if maximized */
1678 if (self->max_horz) {
1679 x = a->x - self->frame->size.left;
1682 if (self->max_vert) {
1684 h = a->height - self->frame->size.top - self->frame->size.bottom;
1688 /* gets the client's position */
1689 frame_frame_gravity(self->frame, &x, &y);
1691 /* these override the above states! if you cant move you can't move! */
1693 if (!(self->functions & OB_CLIENT_FUNC_MOVE)) {
1697 if (!(self->functions & OB_CLIENT_FUNC_RESIZE)) {
1698 w = self->area.width;
1699 h = self->area.height;
1703 if (!(w == self->area.width && h == self->area.height)) {
1704 int basew, baseh, minw, minh;
1706 /* base size is substituted with min size if not specified */
1707 if (self->base_size.width || self->base_size.height) {
1708 basew = self->base_size.width;
1709 baseh = self->base_size.height;
1711 basew = self->min_size.width;
1712 baseh = self->min_size.height;
1714 /* min size is substituted with base size if not specified */
1715 if (self->min_size.width || self->min_size.height) {
1716 minw = self->min_size.width;
1717 minh = self->min_size.height;
1719 minw = self->base_size.width;
1720 minh = self->base_size.height;
1724 /* for interactive resizing. have to move half an increment in each
1727 /* how far we are towards the next size inc */
1728 int mw = (w - basew) % self->size_inc.width;
1729 int mh = (h - baseh) % self->size_inc.height;
1731 int aw = self->size_inc.width / 2;
1732 int ah = self->size_inc.height / 2;
1733 /* don't let us move into a new size increment */
1734 if (mw + aw >= self->size_inc.width)
1735 aw = self->size_inc.width - mw - 1;
1736 if (mh + ah >= self->size_inc.height)
1737 ah = self->size_inc.height - mh - 1;
1741 /* if this is a user-requested resize, then check against min/max
1744 /* smaller than min size or bigger than max size? */
1745 if (w > self->max_size.width) w = self->max_size.width;
1746 if (w < minw) w = minw;
1747 if (h > self->max_size.height) h = self->max_size.height;
1748 if (h < minh) h = minh;
1754 /* keep to the increments */
1755 w /= self->size_inc.width;
1756 h /= self->size_inc.height;
1758 /* you cannot resize to nothing */
1762 /* store the logical size */
1763 SIZE_SET(self->logical_size, w, h);
1765 w *= self->size_inc.width;
1766 h *= self->size_inc.height;
1772 /* adjust the height to match the width for the aspect ratios.
1773 for this, min size is not substituted for base size ever. */
1774 w -= self->base_size.width;
1775 h -= self->base_size.height;
1777 if (self->min_ratio)
1778 if (h * self->min_ratio > w) h = (int)(w / self->min_ratio);
1779 if (self->max_ratio)
1780 if (h * self->max_ratio < w) h = (int)(w / self->max_ratio);
1782 w += self->base_size.width;
1783 h += self->base_size.height;
1788 case OB_CORNER_TOPLEFT:
1790 case OB_CORNER_TOPRIGHT:
1791 x -= w - self->area.width;
1793 case OB_CORNER_BOTTOMLEFT:
1794 y -= h - self->area.height;
1796 case OB_CORNER_BOTTOMRIGHT:
1797 x -= w - self->area.width;
1798 y -= h - self->area.height;
1802 moved = x != self->area.x || y != self->area.y;
1803 resized = w != self->area.width || h != self->area.height;
1805 RECT_SET(self->area, x, y, w, h);
1807 /* for app-requested resizes, always resize if 'resized' is true.
1808 for user-requested ones, only resize if final is true, or when
1809 resizing in opaque mode */
1810 if ((!user && resized) ||
1811 (user && (final || (resized && config_opaque_resize))))
1812 XResizeWindow(ob_display, self->window, w, h);
1814 /* move/resize the frame to match the request */
1816 if (self->decorations != self->frame->decorations)
1817 moved = resized = TRUE;
1819 if (moved || resized)
1820 frame_adjust_area(self->frame, moved, resized);
1822 /* If you send this and the client hasn't changed you end up with buggy
1823 clients (emacs) freaking out, cuz they send back a configure every
1824 time they receive this event, which resends them this event... etc.
1826 if ((!user && moved) || (user && final)) {
1828 event.type = ConfigureNotify;
1829 event.xconfigure.display = ob_display;
1830 event.xconfigure.event = self->window;
1831 event.xconfigure.window = self->window;
1833 /* root window real coords */
1834 event.xconfigure.x = self->frame->area.x + self->frame->size.left;
1835 event.xconfigure.y = self->frame->area.y + self->frame->size.top;
1837 event.xconfigure.width = w;
1838 event.xconfigure.height = h;
1839 event.xconfigure.border_width = 0;
1840 event.xconfigure.above = self->frame->plate;
1841 event.xconfigure.override_redirect = FALSE;
1842 XSendEvent(event.xconfigure.display, event.xconfigure.window,
1843 FALSE, StructureNotifyMask, &event);
1848 void client_fullscreen(ObClient *self, gboolean fs, gboolean savearea)
1852 if (!(self->functions & OB_CLIENT_FUNC_FULLSCREEN) || /* can't */
1853 self->fullscreen == fs) return; /* already done */
1855 self->fullscreen = fs;
1856 client_change_state(self); /* change the state hints on the client,
1857 and adjust out layer/stacking */
1861 guint32 dimensions[4];
1862 dimensions[0] = self->area.x;
1863 dimensions[1] = self->area.y;
1864 dimensions[2] = self->area.width;
1865 dimensions[3] = self->area.height;
1867 PROP_SETA32(self->window, openbox_premax, cardinal,
1871 /* these are not actually used cuz client_configure will set them
1872 as appropriate when the window is fullscreened */
1879 /* pick some fallbacks... */
1880 a = screen_area_monitor(self->desktop, 0);
1881 x = a->x + a->width / 4;
1882 y = a->y + a->height / 4;
1886 if (PROP_GETA32(self->window, openbox_premax, cardinal,
1887 (guint32**)&dimensions, &num)) {
1898 client_setup_decor_and_functions(self);
1900 client_configure(self, OB_CORNER_TOPLEFT, x, y, w, h, TRUE, TRUE);
1902 /* try focus us when we go into fullscreen mode */
1906 static void client_iconify_recursive(ObClient *self,
1907 gboolean iconic, gboolean curdesk)
1910 gboolean changed = FALSE;
1913 if (self->iconic != iconic) {
1914 g_message("%sconifying window: 0x%lx", (iconic ? "I" : "Uni"),
1917 self->iconic = iconic;
1920 if (self->functions & OB_CLIENT_FUNC_ICONIFY) {
1921 self->wmstate = IconicState;
1922 self->ignore_unmaps++;
1923 /* we unmap the client itself so that we can get MapRequest
1924 events, and because the ICCCM tells us to! */
1925 XUnmapWindow(ob_display, self->window);
1927 /* update the focus lists.. iconic windows go to the bottom of
1928 the list, put the new iconic window at the 'top of the
1930 focus_order_to_top(self);
1936 client_set_desktop(self, screen_desktop, FALSE);
1937 self->wmstate = self->shaded ? IconicState : NormalState;
1938 XMapWindow(ob_display, self->window);
1940 /* this puts it after the current focused window */
1941 focus_order_remove(self);
1942 focus_order_add_new(self);
1944 /* this is here cuz with the VIDMODE extension, the viewport can
1945 change while a fullscreen window is iconic, and when it
1946 uniconifies, it would be nice if it did so to the new position
1948 client_reconfigure(self);
1955 client_change_state(self);
1956 client_showhide(self);
1957 screen_update_areas();
1959 dispatch_client(iconic ? Event_Client_Unmapped : Event_Client_Mapped,
1963 /* iconify all transients */
1964 for (it = self->transients; it != NULL; it = it->next)
1965 if (it->data != self) client_iconify_recursive(it->data,
1969 void client_iconify(ObClient *self, gboolean iconic, gboolean curdesk)
1971 /* move up the transient chain as far as possible first */
1972 self = client_search_top_transient(self);
1974 client_iconify_recursive(client_search_top_transient(self),
1978 void client_maximize(ObClient *self, gboolean max, int dir, gboolean savearea)
1982 g_assert(dir == 0 || dir == 1 || dir == 2);
1983 if (!(self->functions & OB_CLIENT_FUNC_MAXIMIZE)) return; /* can't */
1985 /* check if already done */
1987 if (dir == 0 && self->max_horz && self->max_vert) return;
1988 if (dir == 1 && self->max_horz) return;
1989 if (dir == 2 && self->max_vert) return;
1991 if (dir == 0 && !self->max_horz && !self->max_vert) return;
1992 if (dir == 1 && !self->max_horz) return;
1993 if (dir == 2 && !self->max_vert) return;
1996 /* work with the frame's coords */
1997 x = self->frame->area.x;
1998 y = self->frame->area.y;
1999 w = self->area.width;
2000 h = self->area.height;
2004 gint32 dimensions[4];
2013 /* get the property off the window and use it for the dimensions
2014 we are already maxed on */
2015 if (PROP_GETA32(self->window, openbox_premax, cardinal,
2016 (guint32**)&readdim, &num)) {
2018 if (self->max_horz) {
2019 dimensions[0] = readdim[0];
2020 dimensions[2] = readdim[2];
2022 if (self->max_vert) {
2023 dimensions[1] = readdim[1];
2024 dimensions[3] = readdim[3];
2030 PROP_SETA32(self->window, openbox_premax, cardinal,
2031 (guint32*)dimensions, 4);
2038 /* pick some fallbacks... */
2039 a = screen_area_monitor(self->desktop, 0);
2040 if (dir == 0 || dir == 1) { /* horz */
2041 x = a->x + a->width / 4;
2044 if (dir == 0 || dir == 2) { /* vert */
2045 y = a->y + a->height / 4;
2049 if (PROP_GETA32(self->window, openbox_premax, cardinal,
2050 (guint32**)&dimensions, &num)) {
2052 if (dir == 0 || dir == 1) { /* horz */
2056 if (dir == 0 || dir == 2) { /* vert */
2065 if (dir == 0 || dir == 1) /* horz */
2066 self->max_horz = max;
2067 if (dir == 0 || dir == 2) /* vert */
2068 self->max_vert = max;
2070 if (!self->max_horz && !self->max_vert)
2071 PROP_ERASE(self->window, openbox_premax);
2073 client_change_state(self); /* change the state hints on the client */
2075 /* figure out where the client should be going */
2076 frame_frame_gravity(self->frame, &x, &y);
2077 client_configure(self, OB_CORNER_TOPLEFT, x, y, w, h, TRUE, TRUE);
2080 void client_shade(ObClient *self, gboolean shade)
2082 if ((!(self->functions & OB_CLIENT_FUNC_SHADE) &&
2083 shade) || /* can't shade */
2084 self->shaded == shade) return; /* already done */
2086 /* when we're iconic, don't change the wmstate */
2088 self->wmstate = shade ? IconicState : NormalState;
2089 self->shaded = shade;
2090 client_change_state(self);
2091 /* resize the frame to just the titlebar */
2092 frame_adjust_area(self->frame, FALSE, FALSE);
2095 void client_close(ObClient *self)
2099 if (!(self->functions & OB_CLIENT_FUNC_CLOSE)) return;
2102 XXX: itd be cool to do timeouts and shit here for killing the client's
2104 like... if the window is around after 5 seconds, then the close button
2105 turns a nice red, and if this function is called again, the client is
2109 ce.xclient.type = ClientMessage;
2110 ce.xclient.message_type = prop_atoms.wm_protocols;
2111 ce.xclient.display = ob_display;
2112 ce.xclient.window = self->window;
2113 ce.xclient.format = 32;
2114 ce.xclient.data.l[0] = prop_atoms.wm_delete_window;
2115 ce.xclient.data.l[1] = event_lasttime;
2116 ce.xclient.data.l[2] = 0l;
2117 ce.xclient.data.l[3] = 0l;
2118 ce.xclient.data.l[4] = 0l;
2119 XSendEvent(ob_display, self->window, FALSE, NoEventMask, &ce);
2122 void client_kill(ObClient *self)
2124 XKillClient(ob_display, self->window);
2127 void client_set_desktop_recursive(ObClient *self,
2128 guint target, gboolean donthide)
2133 if (target != self->desktop) {
2135 g_message("Setting desktop %u", target+1);
2137 g_assert(target < screen_num_desktops || target == DESKTOP_ALL);
2139 /* remove from the old desktop(s) */
2140 focus_order_remove(self);
2142 old = self->desktop;
2143 self->desktop = target;
2144 PROP_SET32(self->window, net_wm_desktop, cardinal, target);
2145 /* the frame can display the current desktop state */
2146 frame_adjust_state(self->frame);
2147 /* 'move' the window to the new desktop */
2149 client_showhide(self);
2150 /* raise if it was not already on the desktop */
2151 if (old != DESKTOP_ALL)
2152 stacking_raise(CLIENT_AS_WINDOW(self));
2153 screen_update_areas();
2155 /* add to the new desktop(s) */
2156 if (config_focus_new)
2157 focus_order_to_top(self);
2159 focus_order_to_bottom(self);
2161 dispatch_client(Event_Client_Desktop, self, target, old);
2164 /* move all transients */
2165 for (it = self->transients; it != NULL; it = it->next)
2166 if (it->data != self) client_set_desktop_recursive(it->data,
2170 void client_set_desktop(ObClient *self, guint target, gboolean donthide)
2172 client_set_desktop_recursive(client_search_top_transient(self),
2176 ObClient *client_search_modal_child(ObClient *self)
2181 for (it = self->transients; it != NULL; it = it->next) {
2182 ObClient *c = it->data;
2183 if ((ret = client_search_modal_child(c))) return ret;
2184 if (c->modal) return c;
2189 gboolean client_validate(ObClient *self)
2193 XSync(ob_display, FALSE); /* get all events on the server */
2195 if (XCheckTypedWindowEvent(ob_display, self->window, DestroyNotify, &e) ||
2196 XCheckTypedWindowEvent(ob_display, self->window, UnmapNotify, &e)) {
2197 XPutBackEvent(ob_display, &e);
2204 void client_set_wm_state(ObClient *self, long state)
2206 if (state == self->wmstate) return; /* no change */
2210 client_iconify(self, TRUE, TRUE);
2213 client_iconify(self, FALSE, TRUE);
2218 void client_set_state(ObClient *self, Atom action, long data1, long data2)
2220 gboolean shaded = self->shaded;
2221 gboolean fullscreen = self->fullscreen;
2222 gboolean max_horz = self->max_horz;
2223 gboolean max_vert = self->max_vert;
2226 if (!(action == prop_atoms.net_wm_state_add ||
2227 action == prop_atoms.net_wm_state_remove ||
2228 action == prop_atoms.net_wm_state_toggle))
2229 /* an invalid action was passed to the client message, ignore it */
2232 for (i = 0; i < 2; ++i) {
2233 Atom state = i == 0 ? data1 : data2;
2235 if (!state) continue;
2237 /* if toggling, then pick whether we're adding or removing */
2238 if (action == prop_atoms.net_wm_state_toggle) {
2239 if (state == prop_atoms.net_wm_state_modal)
2240 action = self->modal ? prop_atoms.net_wm_state_remove :
2241 prop_atoms.net_wm_state_add;
2242 else if (state == prop_atoms.net_wm_state_maximized_vert)
2243 action = self->max_vert ? prop_atoms.net_wm_state_remove :
2244 prop_atoms.net_wm_state_add;
2245 else if (state == prop_atoms.net_wm_state_maximized_horz)
2246 action = self->max_horz ? prop_atoms.net_wm_state_remove :
2247 prop_atoms.net_wm_state_add;
2248 else if (state == prop_atoms.net_wm_state_shaded)
2249 action = self->shaded ? prop_atoms.net_wm_state_remove :
2250 prop_atoms.net_wm_state_add;
2251 else if (state == prop_atoms.net_wm_state_skip_taskbar)
2252 action = self->skip_taskbar ?
2253 prop_atoms.net_wm_state_remove :
2254 prop_atoms.net_wm_state_add;
2255 else if (state == prop_atoms.net_wm_state_skip_pager)
2256 action = self->skip_pager ?
2257 prop_atoms.net_wm_state_remove :
2258 prop_atoms.net_wm_state_add;
2259 else if (state == prop_atoms.net_wm_state_fullscreen)
2260 action = self->fullscreen ?
2261 prop_atoms.net_wm_state_remove :
2262 prop_atoms.net_wm_state_add;
2263 else if (state == prop_atoms.net_wm_state_above)
2264 action = self->above ? prop_atoms.net_wm_state_remove :
2265 prop_atoms.net_wm_state_add;
2266 else if (state == prop_atoms.net_wm_state_below)
2267 action = self->below ? prop_atoms.net_wm_state_remove :
2268 prop_atoms.net_wm_state_add;
2271 if (action == prop_atoms.net_wm_state_add) {
2272 if (state == prop_atoms.net_wm_state_modal) {
2273 /* XXX raise here or something? */
2275 } else if (state == prop_atoms.net_wm_state_maximized_vert) {
2277 } else if (state == prop_atoms.net_wm_state_maximized_horz) {
2279 } else if (state == prop_atoms.net_wm_state_shaded) {
2281 } else if (state == prop_atoms.net_wm_state_skip_taskbar) {
2282 self->skip_taskbar = TRUE;
2283 } else if (state == prop_atoms.net_wm_state_skip_pager) {
2284 self->skip_pager = TRUE;
2285 } else if (state == prop_atoms.net_wm_state_fullscreen) {
2287 } else if (state == prop_atoms.net_wm_state_above) {
2289 } else if (state == prop_atoms.net_wm_state_below) {
2293 } else { /* action == prop_atoms.net_wm_state_remove */
2294 if (state == prop_atoms.net_wm_state_modal) {
2295 self->modal = FALSE;
2296 } else if (state == prop_atoms.net_wm_state_maximized_vert) {
2298 } else if (state == prop_atoms.net_wm_state_maximized_horz) {
2300 } else if (state == prop_atoms.net_wm_state_shaded) {
2302 } else if (state == prop_atoms.net_wm_state_skip_taskbar) {
2303 self->skip_taskbar = FALSE;
2304 } else if (state == prop_atoms.net_wm_state_skip_pager) {
2305 self->skip_pager = FALSE;
2306 } else if (state == prop_atoms.net_wm_state_fullscreen) {
2308 } else if (state == prop_atoms.net_wm_state_above) {
2309 self->above = FALSE;
2310 } else if (state == prop_atoms.net_wm_state_below) {
2311 self->below = FALSE;
2315 if (max_horz != self->max_horz || max_vert != self->max_vert) {
2316 if (max_horz != self->max_horz && max_vert != self->max_vert) {
2318 if (max_horz == max_vert) { /* both going the same way */
2319 client_maximize(self, max_horz, 0, TRUE);
2321 client_maximize(self, max_horz, 1, TRUE);
2322 client_maximize(self, max_vert, 2, TRUE);
2326 if (max_horz != self->max_horz)
2327 client_maximize(self, max_horz, 1, TRUE);
2329 client_maximize(self, max_vert, 2, TRUE);
2332 /* change fullscreen state before shading, as it will affect if the window
2334 if (fullscreen != self->fullscreen)
2335 client_fullscreen(self, fullscreen, TRUE);
2336 if (shaded != self->shaded)
2337 client_shade(self, shaded);
2338 client_calc_layer(self);
2339 client_change_state(self); /* change the hint to reflect these changes */
2342 ObClient *client_focus_target(ObClient *self)
2346 /* if we have a modal child, then focus it, not us */
2347 child = client_search_modal_child(self);
2348 if (child) return child;
2352 gboolean client_can_focus(ObClient *self)
2356 /* choose the correct target */
2357 self = client_focus_target(self);
2359 if (!self->frame->visible)
2362 if (!((self->can_focus || self->focus_notify) &&
2363 (self->desktop == screen_desktop ||
2364 self->desktop == DESKTOP_ALL) &&
2368 /* do a check to see if the window has already been unmapped or destroyed
2369 do this intelligently while watching out for unmaps we've generated
2370 (ignore_unmaps > 0) */
2371 if (XCheckTypedWindowEvent(ob_display, self->window,
2372 DestroyNotify, &ev)) {
2373 XPutBackEvent(ob_display, &ev);
2376 while (XCheckTypedWindowEvent(ob_display, self->window,
2377 UnmapNotify, &ev)) {
2378 if (self->ignore_unmaps) {
2379 self->ignore_unmaps--;
2381 XPutBackEvent(ob_display, &ev);
2389 gboolean client_focus(ObClient *self)
2391 /* choose the correct target */
2392 self = client_focus_target(self);
2394 if (!client_can_focus(self)) {
2395 if (!self->frame->visible) {
2396 /* update the focus lists */
2397 focus_order_to_top(self);
2402 if (self->can_focus)
2403 /* RevertToPointerRoot causes much more headache than RevertToNone, so
2404 I choose to use it always, hopefully to find errors quicker, if any
2405 are left. (I hate X. I hate focus events.) */
2406 XSetInputFocus(ob_display, self->window, RevertToPointerRoot,
2409 if (self->focus_notify) {
2411 ce.xclient.type = ClientMessage;
2412 ce.xclient.message_type = prop_atoms.wm_protocols;
2413 ce.xclient.display = ob_display;
2414 ce.xclient.window = self->window;
2415 ce.xclient.format = 32;
2416 ce.xclient.data.l[0] = prop_atoms.wm_take_focus;
2417 ce.xclient.data.l[1] = event_lasttime;
2418 ce.xclient.data.l[2] = 0l;
2419 ce.xclient.data.l[3] = 0l;
2420 ce.xclient.data.l[4] = 0l;
2421 XSendEvent(ob_display, self->window, FALSE, NoEventMask, &ce);
2425 g_message("%sively focusing %lx at %d", (self->can_focus ? "act" : "pass"),
2430 /* Cause the FocusIn to come back to us. Important for desktop switches,
2431 since otherwise we'll have no FocusIn on the queue and send it off to
2432 the focus_backup. */
2433 XSync(ob_display, FALSE);
2437 void client_unfocus(ObClient *self)
2439 g_assert(focus_client == self);
2441 g_message("client_unfocus for %lx", self->window);
2443 focus_fallback(OB_FOCUS_FALLBACK_UNFOCUSING);
2446 void client_activate(ObClient *self)
2448 if (client_normal(self) && screen_showing_desktop)
2449 screen_show_desktop(FALSE);
2451 client_iconify(self, FALSE, FALSE);
2452 if (self->desktop != DESKTOP_ALL &&
2453 self->desktop != screen_desktop)
2454 screen_set_desktop(self->desktop);
2455 else if (!self->frame->visible)
2456 /* if its not visible for other reasons, then don't mess
2460 client_shade(self, FALSE);
2462 stacking_raise(CLIENT_AS_WINDOW(self));
2465 gboolean client_focused(ObClient *self)
2467 return self == focus_client;
2470 ObClientIcon *client_icon(ObClient *self, int w, int h)
2473 /* si is the smallest image >= req */
2474 /* li is the largest image < req */
2475 unsigned long size, smallest = 0xffffffff, largest = 0, si = 0, li = 0;
2477 if (!self->nicons) return NULL;
2479 for (i = 0; i < self->nicons; ++i) {
2480 size = self->icons[i].width * self->icons[i].height;
2481 if (size < smallest && size >= (unsigned)(w * h)) {
2485 if (size > largest && size <= (unsigned)(w * h)) {
2490 if (largest == 0) /* didnt find one smaller than the requested size */
2491 return &self->icons[si];
2492 return &self->icons[li];
2495 /* this be mostly ripped from fvwm */
2496 ObClient *client_find_directional(ObClient *c, ObDirection dir)
2498 int my_cx, my_cy, his_cx, his_cy;
2501 int score, best_score;
2502 ObClient *best_client, *cur;
2508 /* first, find the centre coords of the currently focused window */
2509 my_cx = c->frame->area.x + c->frame->area.width / 2;
2510 my_cy = c->frame->area.y + c->frame->area.height / 2;
2515 for(it = g_list_first(client_list); it; it = it->next) {
2518 /* the currently selected window isn't interesting */
2521 if (!client_normal(cur))
2523 if(c->desktop != cur->desktop && cur->desktop != DESKTOP_ALL)
2527 if(client_focus_target(cur) == cur &&
2528 !(cur->can_focus || cur->focus_notify))
2531 /* find the centre coords of this window, from the
2532 * currently focused window's point of view */
2533 his_cx = (cur->frame->area.x - my_cx)
2534 + cur->frame->area.width / 2;
2535 his_cy = (cur->frame->area.y - my_cy)
2536 + cur->frame->area.height / 2;
2540 /* Rotate the diagonals 45 degrees counterclockwise.
2541 * To do this, multiply the matrix /+h +h\ with the
2542 * vector (x y). \-h +h/
2543 * h = sqrt(0.5). We can set h := 1 since absolute
2544 * distance doesn't matter here. */
2545 tx = his_cx + his_cy;
2546 his_cy = -his_cx + his_cy;
2551 case OB_DIRECTION_NORTH:
2552 case OB_DIRECTION_SOUTH:
2553 case OB_DIRECTION_NORTHEAST:
2554 case OB_DIRECTION_SOUTHWEST:
2555 offset = (his_cx < 0) ? -his_cx : his_cx;
2556 distance = ((dir == OB_DIRECTION_NORTH ||
2557 dir == OB_DIRECTION_NORTHEAST) ?
2560 case OB_DIRECTION_EAST:
2561 case OB_DIRECTION_WEST:
2562 case OB_DIRECTION_SOUTHEAST:
2563 case OB_DIRECTION_NORTHWEST:
2564 offset = (his_cy < 0) ? -his_cy : his_cy;
2565 distance = ((dir == OB_DIRECTION_WEST ||
2566 dir == OB_DIRECTION_NORTHWEST) ?
2571 /* the target must be in the requested direction */
2575 /* Calculate score for this window. The smaller the better. */
2576 score = distance + offset;
2578 /* windows more than 45 degrees off the direction are
2579 * heavily penalized and will only be chosen if nothing
2580 * else within a million pixels */
2581 if(offset > distance)
2584 if(best_score == -1 || score < best_score)
2592 void client_set_layer(ObClient *self, int layer)
2596 self->above = FALSE;
2597 } else if (layer == 0) {
2598 self->below = self->above = FALSE;
2600 self->below = FALSE;
2603 client_calc_layer(self);
2604 client_change_state(self); /* reflect this in the state hints */
2607 guint client_monitor(ObClient *self)
2611 for (i = 0; i < screen_num_monitors; ++i) {
2612 Rect *area = screen_physical_area_monitor(i);
2613 if (RECT_INTERSECTS_RECT(*area, self->frame->area))
2616 if (i == screen_num_monitors) i = 0;
2617 g_assert(i < screen_num_monitors);
2621 ObClient *client_search_top_transient(ObClient *self)
2623 /* move up the transient chain as far as possible */
2624 if (self->transient_for) {
2625 if (self->transient_for != OB_TRAN_GROUP) {
2626 return client_search_top_transient(self->transient_for);
2630 for (it = self->group->members; it; it = it->next) {
2631 ObClient *c = it->data;
2633 /* checking transient_for prevents infinate loops! */
2634 if (c != self && !c->transient_for)