7 #include "moveresize.h"
9 #include "extensions.h"
20 #include "render/render.h"
23 #include <X11/Xutil.h>
25 /*! The event mask to grab on client windows */
26 #define CLIENT_EVENTMASK (PropertyChangeMask | FocusChangeMask | \
29 #define CLIENT_NOPROPAGATEMASK (ButtonPressMask | ButtonReleaseMask | \
32 GList *client_list = NULL;
34 static void client_get_all(ObClient *self);
35 static void client_toggle_border(ObClient *self, gboolean show);
36 static void client_get_area(ObClient *self);
37 static void client_get_desktop(ObClient *self);
38 static void client_get_state(ObClient *self);
39 static void client_get_shaped(ObClient *self);
40 static void client_get_mwm_hints(ObClient *self);
41 static void client_get_gravity(ObClient *self);
42 static void client_showhide(ObClient *self);
43 static void client_change_allowed_actions(ObClient *self);
44 static void client_change_state(ObClient *self);
45 static void client_apply_startup_state(ObClient *self);
52 void client_shutdown()
56 void client_set_list()
58 Window *windows, *win_it;
60 guint size = g_list_length(client_list);
62 /* create an array of the window ids */
64 windows = g_new(Window, size);
66 for (it = client_list; it != NULL; it = it->next, ++win_it)
67 *win_it = ((ObClient*)it->data)->window;
71 PROP_SETA32(RootWindow(ob_display, ob_screen),
72 net_client_list, window, (guint32*)windows, size);
81 void client_foreach_transient(ObClient *self, ObClientForeachFunc func, void *data)
85 for (it = self->transients; it; it = it->next) {
86 if (!func(it->data, data)) return;
87 client_foreach_transient(it->data, func, data);
91 void client_foreach_ancestor(ObClient *self, ObClientForeachFunc func, void *data)
93 if (self->transient_for) {
94 if (self->transient_for != OB_TRAN_GROUP) {
95 if (!func(self->transient_for, data)) return;
96 client_foreach_ancestor(self->transient_for, func, data);
100 for (it = self->group->members; it; it = it->next)
101 if (it->data != self &&
102 !((ObClient*)it->data)->transient_for) {
103 if (!func(it->data, data)) return;
104 client_foreach_ancestor(it->data, func, data);
111 void client_manage_all()
113 unsigned int i, j, nchild;
116 XWindowAttributes attrib;
118 XQueryTree(ob_display, RootWindow(ob_display, ob_screen),
119 &w, &w, &children, &nchild);
121 /* remove all icon windows from the list */
122 for (i = 0; i < nchild; i++) {
123 if (children[i] == None) continue;
124 wmhints = XGetWMHints(ob_display, children[i]);
126 if ((wmhints->flags & IconWindowHint) &&
127 (wmhints->icon_window != children[i]))
128 for (j = 0; j < nchild; j++)
129 if (children[j] == wmhints->icon_window) {
137 for (i = 0; i < nchild; ++i) {
138 if (children[i] == None)
140 if (XGetWindowAttributes(ob_display, children[i], &attrib)) {
141 if (attrib.override_redirect) continue;
143 if (attrib.map_state != IsUnmapped)
144 client_manage(children[i]);
149 /* stack them as they were on startup!
150 why with stacking_lower? Why, because then windows who aren't in the
151 stacking list are on the top where you can see them instead of buried
153 for (i = startup_stack_size; i > 0; --i) {
156 w = startup_stack_order[i-1];
157 obw = g_hash_table_lookup(window_map, &w);
159 g_assert(WINDOW_IS_CLIENT(obw));
160 stacking_lower(CLIENT_AS_WINDOW(obw));
163 g_free(startup_stack_order);
164 startup_stack_order = NULL;
165 startup_stack_size = 0;
167 if (config_focus_new) {
170 active = g_hash_table_lookup(window_map, &startup_active);
172 g_assert(WINDOW_IS_CLIENT(active));
173 if (!client_focus(WINDOW_AS_CLIENT(active)))
174 focus_fallback(OB_FOCUS_FALLBACK_NOFOCUS);
176 focus_fallback(OB_FOCUS_FALLBACK_NOFOCUS);
180 void client_manage(Window window)
184 XWindowAttributes attrib;
185 XSetWindowAttributes attrib_set;
187 gboolean activate = FALSE;
191 /* check if it has already been unmapped by the time we started mapping
192 the grab does a sync so we don't have to here */
193 if (XCheckTypedWindowEvent(ob_display, window, DestroyNotify, &e) ||
194 XCheckTypedWindowEvent(ob_display, window, UnmapNotify, &e)) {
195 XPutBackEvent(ob_display, &e);
198 return; /* don't manage it */
201 /* make sure it isn't an override-redirect window */
202 if (!XGetWindowAttributes(ob_display, window, &attrib) ||
203 attrib.override_redirect) {
205 return; /* don't manage it */
208 /* is the window a docking app */
209 if ((wmhint = XGetWMHints(ob_display, window))) {
210 if ((wmhint->flags & StateHint) &&
211 wmhint->initial_state == WithdrawnState) {
212 dock_add(window, wmhint);
220 ob_debug("Managing window: %lx\n", window);
222 /* choose the events we want to receive on the CLIENT window */
223 attrib_set.event_mask = CLIENT_EVENTMASK;
224 attrib_set.do_not_propagate_mask = CLIENT_NOPROPAGATEMASK;
225 XChangeWindowAttributes(ob_display, window,
226 CWEventMask|CWDontPropagate, &attrib_set);
229 /* create the ObClient struct, and populate it from the hints on the
231 self = g_new(ObClient, 1);
232 self->obwin.type = Window_Client;
233 self->window = window;
234 client_get_all(self);
236 /* remove the client's border (and adjust re gravity) */
237 client_toggle_border(self, FALSE);
239 /* specify that if we exit, the window should not be destroyed and should
240 be reparented back to root automatically */
241 XChangeSaveSet(ob_display, window, SetModeInsert);
243 /* create the decoration frame for the client window */
244 self->frame = frame_new();
246 frame_grab_client(self->frame, self);
248 client_apply_startup_state(self);
252 /* add to client list/map */
253 client_list = g_list_append(client_list, self);
254 g_hash_table_insert(window_map, &self->window, self);
256 /* update the focus lists */
257 focus_order_add_new(self);
259 stacking_add(CLIENT_AS_WINDOW(self));
261 /* focus the new window? */
262 if (ob_state() != OB_STATE_STARTING && config_focus_new &&
263 /* note the check against Type_Normal/Dialog, not client_normal(self),
264 which would also include other types. in this case we want more
265 strict rules for focus */
266 (self->type == OB_CLIENT_TYPE_NORMAL ||
267 self->type == OB_CLIENT_TYPE_DIALOG))
269 if (self->desktop != screen_desktop) {
270 /* activate the window */
273 gboolean group_foc = FALSE;
278 for (it = self->group->members; it; it = it->next)
280 if (client_focused(it->data))
288 (!self->transient_for && (!self->group ||
289 !self->group->members->next))) ||
290 client_search_focus_tree_full(self) ||
292 !client_normal(focus_client))
294 /* activate the window */
300 dispatch_client(Event_Client_New, self, 0, 0);
302 /* make sure the window is visible */
303 client_move_onscreen(self);
305 screen_update_areas();
307 client_showhide(self);
309 /* use client_focus instead of client_activate cuz client_activate does
310 stuff like switch desktops etc and I'm not interested in all that when
311 a window maps since its not based on an action from the user like
312 clicking a window to activate is. so keep the new window out of the way
314 if (activate) client_focus(self);
316 /* client_activate does this but we aret using it so we have to do it
318 if (screen_showing_desktop)
319 screen_show_desktop(FALSE);
321 /* update the list hints */
324 dispatch_client(Event_Client_Mapped, self, 0, 0);
326 ob_debug("Managed window 0x%lx (%s)\n", window, self->class);
329 void client_unmanage_all()
331 while (client_list != NULL)
332 client_unmanage(client_list->data);
335 /* called by client_unmanage() to close any menus referencing this client */
336 void client_close_menus(gpointer key, gpointer value, gpointer self)
338 if (((ObMenu *)value)->client == (ObClient *)self)
339 menu_hide((ObMenu *)value);
342 void client_unmanage(ObClient *self)
347 ob_debug("Unmanaging window: %lx (%s)\n", self->window, self->class);
349 dispatch_client(Event_Client_Destroy, self, 0, 0);
350 g_assert(self != NULL);
352 /* remove the window from our save set */
353 XChangeSaveSet(ob_display, self->window, SetModeDelete);
355 /* we dont want events no more */
356 XSelectInput(ob_display, self->window, NoEventMask);
358 frame_hide(self->frame);
360 client_list = g_list_remove(client_list, self);
361 stacking_remove(self);
362 g_hash_table_remove(window_map, &self->window);
364 /* update the focus lists */
365 focus_order_remove(self);
367 /* once the client is out of the list, update the struts to remove it's
369 screen_update_areas();
371 /* tell our parent(s) that we're gone */
372 if (self->transient_for == OB_TRAN_GROUP) { /* transient of group */
375 for (it = self->group->members; it; it = it->next)
376 if (it->data != self)
377 ((ObClient*)it->data)->transients =
378 g_slist_remove(((ObClient*)it->data)->transients, self);
379 } else if (self->transient_for) { /* transient of window */
380 self->transient_for->transients =
381 g_slist_remove(self->transient_for->transients, self);
384 /* tell our transients that we're gone */
385 for (it = self->transients; it != NULL; it = it->next) {
386 if (((ObClient*)it->data)->transient_for != OB_TRAN_GROUP) {
387 ((ObClient*)it->data)->transient_for = NULL;
388 client_calc_layer(it->data);
392 if (moveresize_client == self)
393 moveresize_end(TRUE);
395 /* close any windows that are attached to this window */
396 g_hash_table_foreach(menu_hash, client_close_menus, self);
399 if (focus_client == self) {
402 /* focus the last focused window on the desktop, and ignore enter
403 events from the unmap so it doesnt mess with the focus */
404 while (XCheckTypedEvent(ob_display, EnterNotify, &e));
405 client_unfocus(self);
408 /* remove from its group */
410 group_remove(self->group, self);
414 /* dispatch the unmapped event */
415 dispatch_client(Event_Client_Unmapped, self, 0, 0);
416 g_assert(self != NULL);
418 /* give the client its border back */
419 client_toggle_border(self, TRUE);
421 /* reparent the window out of the frame, and free the frame */
422 frame_release_client(self->frame, self);
425 if (ob_state() != OB_STATE_EXITING) {
426 /* these values should not be persisted across a window
428 prop_erase(self->window, prop_atoms.net_wm_desktop);
429 prop_erase(self->window, prop_atoms.net_wm_state);
431 /* if we're left in an iconic state, the client wont be mapped. this is
432 bad, since we will no longer be managing the window on restart */
434 XMapWindow(ob_display, self->window);
438 ob_debug("Unmanaged window 0x%lx\n", self->window);
440 /* free all data allocated in the client struct */
441 g_slist_free(self->transients);
442 for (j = 0; j < self->nicons; ++j)
443 g_free(self->icons[j].data);
444 if (self->nicons > 0)
447 g_free(self->icon_title);
453 /* update the list hints */
457 void client_move_onscreen(ObClient *self)
460 int x = self->frame->area.x, y = self->frame->area.y;
462 /* XXX watch for xinerama dead areas */
463 a = screen_area(self->desktop);
464 if (x >= a->x + a->width - 1)
465 x = a->x + a->width - self->frame->area.width;
466 if (y >= a->y + a->height - 1)
467 y = a->y + a->height - self->frame->area.height;
468 if (x + self->frame->area.width - 1 < a->x)
470 if (y + self->frame->area.height - 1< a->y)
473 frame_frame_gravity(self->frame, &x, &y); /* get where the client
475 client_configure(self, OB_CORNER_TOPLEFT, x, y,
476 self->area.width, self->area.height,
480 static void client_toggle_border(ObClient *self, gboolean show)
482 /* adjust our idea of where the client is, based on its border. When the
483 border is removed, the client should now be considered to be in a
485 when re-adding the border to the client, the same operation needs to be
487 int oldx = self->area.x, oldy = self->area.y;
488 int x = oldx, y = oldy;
489 switch(self->gravity) {
491 case NorthWestGravity:
493 case SouthWestGravity:
495 case NorthEastGravity:
497 case SouthEastGravity:
498 if (show) x -= self->border_width * 2;
499 else x += self->border_width * 2;
506 if (show) x -= self->border_width;
507 else x += self->border_width;
510 switch(self->gravity) {
512 case NorthWestGravity:
514 case NorthEastGravity:
516 case SouthWestGravity:
518 case SouthEastGravity:
519 if (show) y -= self->border_width * 2;
520 else y += self->border_width * 2;
527 if (show) y -= self->border_width;
528 else y += self->border_width;
535 XSetWindowBorderWidth(ob_display, self->window, self->border_width);
537 /* move the client so it is back it the right spot _with_ its
539 if (x != oldx || y != oldy)
540 XMoveWindow(ob_display, self->window, x, y);
542 XSetWindowBorderWidth(ob_display, self->window, 0);
546 static void client_get_all(ObClient *self)
548 /* update EVERYTHING!! */
550 self->ignore_unmaps = 0;
554 self->title = self->icon_title = NULL;
555 self->title_count = 1;
556 self->name = self->class = self->role = NULL;
557 self->wmstate = NormalState;
558 self->transient = FALSE;
559 self->transients = NULL;
560 self->transient_for = NULL;
562 self->urgent = FALSE;
563 self->positioned = FALSE;
564 self->decorate = TRUE;
568 client_get_area(self);
569 client_update_transient_for(self);
570 client_update_wmhints(self);
571 client_get_desktop(self);
572 client_get_state(self);
573 client_get_shaped(self);
575 client_get_mwm_hints(self);
576 client_get_type(self);/* this can change the mwmhints for special cases */
578 client_update_protocols(self);
580 client_get_gravity(self); /* get the attribute gravity */
581 client_update_normal_hints(self); /* this may override the attribute
584 /* got the type, the mwmhints, the protocols, and the normal hints
585 (min/max sizes), so we're ready to set up the decorations/functions */
586 client_setup_decor_and_functions(self);
588 client_update_title(self);
589 client_update_class(self);
590 client_update_strut(self);
591 client_update_icons(self);
593 client_change_state(self);
596 static void client_get_area(ObClient *self)
598 XWindowAttributes wattrib;
601 ret = XGetWindowAttributes(ob_display, self->window, &wattrib);
602 g_assert(ret != BadWindow);
604 RECT_SET(self->area, wattrib.x, wattrib.y, wattrib.width, wattrib.height);
605 self->border_width = wattrib.border_width;
608 static void client_get_desktop(ObClient *self)
610 guint32 d = screen_num_desktops; /* an always-invalid value */
612 if (PROP_GET32(self->window, net_wm_desktop, cardinal, &d)) {
613 if (d >= screen_num_desktops && d != DESKTOP_ALL)
614 self->desktop = screen_num_desktops - 1;
618 gboolean trdesk = FALSE;
620 if (self->transient_for) {
621 if (self->transient_for != OB_TRAN_GROUP) {
622 self->desktop = self->transient_for->desktop;
627 for (it = self->group->members; it; it = it->next)
628 if (it->data != self &&
629 !((ObClient*)it->data)->transient_for) {
630 self->desktop = ((ObClient*)it->data)->desktop;
637 /* defaults to the current desktop */
638 self->desktop = screen_desktop;
641 if (self->desktop != d) {
642 /* set the desktop hint, to make sure that it always exists */
643 PROP_SET32(self->window, net_wm_desktop, cardinal, self->desktop);
647 static void client_get_state(ObClient *self)
652 self->modal = self->shaded = self->max_horz = self->max_vert =
653 self->fullscreen = self->above = self->below = self->iconic =
654 self->skip_taskbar = self->skip_pager = FALSE;
656 if (PROP_GETA32(self->window, net_wm_state, atom, &state, &num)) {
658 for (i = 0; i < num; ++i) {
659 if (state[i] == prop_atoms.net_wm_state_modal)
661 else if (state[i] == prop_atoms.net_wm_state_shaded)
663 else if (state[i] == prop_atoms.net_wm_state_hidden)
665 else if (state[i] == prop_atoms.net_wm_state_skip_taskbar)
666 self->skip_taskbar = TRUE;
667 else if (state[i] == prop_atoms.net_wm_state_skip_pager)
668 self->skip_pager = TRUE;
669 else if (state[i] == prop_atoms.net_wm_state_fullscreen)
670 self->fullscreen = TRUE;
671 else if (state[i] == prop_atoms.net_wm_state_maximized_vert)
672 self->max_vert = TRUE;
673 else if (state[i] == prop_atoms.net_wm_state_maximized_horz)
674 self->max_horz = TRUE;
675 else if (state[i] == prop_atoms.net_wm_state_above)
677 else if (state[i] == prop_atoms.net_wm_state_below)
685 static void client_get_shaped(ObClient *self)
687 self->shaped = FALSE;
689 if (extensions_shape) {
694 XShapeSelectInput(ob_display, self->window, ShapeNotifyMask);
696 XShapeQueryExtents(ob_display, self->window, &s, &foo,
697 &foo, &ufoo, &ufoo, &foo, &foo, &foo, &ufoo,
699 self->shaped = (s != 0);
704 void client_update_transient_for(ObClient *self)
707 ObClient *target = NULL;
709 if (XGetTransientForHint(ob_display, self->window, &t)) {
710 self->transient = TRUE;
711 if (t != self->window) { /* cant be transient to itself! */
712 target = g_hash_table_lookup(window_map, &t);
713 /* if this happens then we need to check for it*/
714 g_assert(target != self);
715 g_assert(!target || WINDOW_IS_CLIENT(target));
717 if (!target && self->group) {
718 /* not transient to a client, see if it is transient for a
720 if (t == self->group->leader ||
722 t == RootWindow(ob_display, ob_screen)) {
723 /* window is a transient for its group! */
724 target = OB_TRAN_GROUP;
729 self->transient = FALSE;
731 /* if anything has changed... */
732 if (target != self->transient_for) {
733 if (self->transient_for == OB_TRAN_GROUP) { /* transient of group */
736 /* remove from old parents */
737 for (it = self->group->members; it; it = g_slist_next(it)) {
738 ObClient *c = it->data;
739 if (c != self && !c->transient_for)
740 c->transients = g_slist_remove(c->transients, self);
742 } else if (self->transient_for != NULL) { /* transient of window */
743 /* remove from old parent */
744 self->transient_for->transients =
745 g_slist_remove(self->transient_for->transients, self);
747 self->transient_for = target;
748 if (self->transient_for == OB_TRAN_GROUP) { /* transient of group */
751 /* add to new parents */
752 for (it = self->group->members; it; it = g_slist_next(it)) {
753 ObClient *c = it->data;
754 if (c != self && !c->transient_for)
755 c->transients = g_slist_append(c->transients, self);
758 /* remove all transients which are in the group, that causes
759 circlular pointer hell of doom */
760 for (it = self->group->members; it; it = g_slist_next(it)) {
762 for (sit = self->transients; sit; sit = next) {
763 next = g_slist_next(sit);
764 if (sit->data == it->data)
766 g_slist_delete_link(self->transients, sit);
769 } else if (self->transient_for != NULL) { /* transient of window */
770 /* add to new parent */
771 self->transient_for->transients =
772 g_slist_append(self->transient_for->transients, self);
777 static void client_get_mwm_hints(ObClient *self)
782 self->mwmhints.flags = 0; /* default to none */
784 if (PROP_GETA32(self->window, motif_wm_hints, motif_wm_hints,
786 if (num >= OB_MWM_ELEMENTS) {
787 self->mwmhints.flags = hints[0];
788 self->mwmhints.functions = hints[1];
789 self->mwmhints.decorations = hints[2];
795 void client_get_type(ObClient *self)
802 if (PROP_GETA32(self->window, net_wm_window_type, atom, &val, &num)) {
803 /* use the first value that we know about in the array */
804 for (i = 0; i < num; ++i) {
805 if (val[i] == prop_atoms.net_wm_window_type_desktop)
806 self->type = OB_CLIENT_TYPE_DESKTOP;
807 else if (val[i] == prop_atoms.net_wm_window_type_dock)
808 self->type = OB_CLIENT_TYPE_DOCK;
809 else if (val[i] == prop_atoms.net_wm_window_type_toolbar)
810 self->type = OB_CLIENT_TYPE_TOOLBAR;
811 else if (val[i] == prop_atoms.net_wm_window_type_menu)
812 self->type = OB_CLIENT_TYPE_MENU;
813 else if (val[i] == prop_atoms.net_wm_window_type_utility)
814 self->type = OB_CLIENT_TYPE_UTILITY;
815 else if (val[i] == prop_atoms.net_wm_window_type_splash)
816 self->type = OB_CLIENT_TYPE_SPLASH;
817 else if (val[i] == prop_atoms.net_wm_window_type_dialog)
818 self->type = OB_CLIENT_TYPE_DIALOG;
819 else if (val[i] == prop_atoms.net_wm_window_type_normal)
820 self->type = OB_CLIENT_TYPE_NORMAL;
821 else if (val[i] == prop_atoms.kde_net_wm_window_type_override) {
822 /* prevent this window from getting any decor or
824 self->mwmhints.flags &= (OB_MWM_FLAG_FUNCTIONS |
825 OB_MWM_FLAG_DECORATIONS);
826 self->mwmhints.decorations = 0;
827 self->mwmhints.functions = 0;
829 if (self->type != (ObClientType) -1)
830 break; /* grab the first legit type */
835 if (self->type == (ObClientType) -1) {
836 /*the window type hint was not set, which means we either classify
837 ourself as a normal window or a dialog, depending on if we are a
840 self->type = OB_CLIENT_TYPE_DIALOG;
842 self->type = OB_CLIENT_TYPE_NORMAL;
846 void client_update_protocols(ObClient *self)
851 self->focus_notify = FALSE;
852 self->delete_window = FALSE;
854 if (PROP_GETA32(self->window, wm_protocols, atom, &proto, &num_return)) {
855 for (i = 0; i < num_return; ++i) {
856 if (proto[i] == prop_atoms.wm_delete_window) {
857 /* this means we can request the window to close */
858 self->delete_window = TRUE;
859 } else if (proto[i] == prop_atoms.wm_take_focus)
860 /* if this protocol is requested, then the window will be
861 notified whenever we want it to receive focus */
862 self->focus_notify = TRUE;
868 static void client_get_gravity(ObClient *self)
870 XWindowAttributes wattrib;
873 ret = XGetWindowAttributes(ob_display, self->window, &wattrib);
874 g_assert(ret != BadWindow);
875 self->gravity = wattrib.win_gravity;
878 void client_update_normal_hints(ObClient *self)
882 int oldgravity = self->gravity;
885 self->min_ratio = 0.0f;
886 self->max_ratio = 0.0f;
887 SIZE_SET(self->size_inc, 1, 1);
888 SIZE_SET(self->base_size, 0, 0);
889 SIZE_SET(self->min_size, 0, 0);
890 SIZE_SET(self->max_size, G_MAXINT, G_MAXINT);
892 /* get the hints from the window */
893 if (XGetWMNormalHints(ob_display, self->window, &size, &ret)) {
894 self->positioned = !!(size.flags & (PPosition|USPosition));
896 if (size.flags & PWinGravity) {
897 self->gravity = size.win_gravity;
899 /* if the client has a frame, i.e. has already been mapped and
900 is changing its gravity */
901 if (self->frame && self->gravity != oldgravity) {
902 /* move our idea of the client's position based on its new
904 self->area.x = self->frame->area.x;
905 self->area.y = self->frame->area.y;
906 frame_frame_gravity(self->frame, &self->area.x, &self->area.y);
910 if (size.flags & PAspect) {
911 if (size.min_aspect.y)
912 self->min_ratio = (float)size.min_aspect.x / size.min_aspect.y;
913 if (size.max_aspect.y)
914 self->max_ratio = (float)size.max_aspect.x / size.max_aspect.y;
917 if (size.flags & PMinSize)
918 SIZE_SET(self->min_size, size.min_width, size.min_height);
920 if (size.flags & PMaxSize)
921 SIZE_SET(self->max_size, size.max_width, size.max_height);
923 if (size.flags & PBaseSize)
924 SIZE_SET(self->base_size, size.base_width, size.base_height);
926 if (size.flags & PResizeInc)
927 SIZE_SET(self->size_inc, size.width_inc, size.height_inc);
931 void client_setup_decor_and_functions(ObClient *self)
933 /* start with everything (cept fullscreen) */
934 self->decorations = (OB_FRAME_DECOR_TITLEBAR |
935 OB_FRAME_DECOR_HANDLE |
936 OB_FRAME_DECOR_GRIPS |
937 OB_FRAME_DECOR_BORDER |
938 OB_FRAME_DECOR_ICON |
939 OB_FRAME_DECOR_ALLDESKTOPS |
940 OB_FRAME_DECOR_ICONIFY |
941 OB_FRAME_DECOR_MAXIMIZE |
942 OB_FRAME_DECOR_SHADE);
943 self->functions = (OB_CLIENT_FUNC_RESIZE |
944 OB_CLIENT_FUNC_MOVE |
945 OB_CLIENT_FUNC_ICONIFY |
946 OB_CLIENT_FUNC_MAXIMIZE |
947 OB_CLIENT_FUNC_SHADE);
948 if (self->delete_window) {
949 self->functions |= OB_CLIENT_FUNC_CLOSE;
950 self->decorations |= OB_FRAME_DECOR_CLOSE;
953 if (!(self->min_size.width < self->max_size.width ||
954 self->min_size.height < self->max_size.height))
955 self->functions &= ~OB_CLIENT_FUNC_RESIZE;
957 switch (self->type) {
958 case OB_CLIENT_TYPE_NORMAL:
959 /* normal windows retain all of the possible decorations and
960 functionality, and are the only windows that you can fullscreen */
961 self->functions |= OB_CLIENT_FUNC_FULLSCREEN;
964 case OB_CLIENT_TYPE_DIALOG:
965 case OB_CLIENT_TYPE_UTILITY:
966 /* these windows cannot be maximized */
967 self->functions &= ~OB_CLIENT_FUNC_MAXIMIZE;
970 case OB_CLIENT_TYPE_MENU:
971 case OB_CLIENT_TYPE_TOOLBAR:
972 /* these windows get less functionality */
973 self->functions &= ~(OB_CLIENT_FUNC_ICONIFY | OB_CLIENT_FUNC_RESIZE);
976 case OB_CLIENT_TYPE_DESKTOP:
977 case OB_CLIENT_TYPE_DOCK:
978 case OB_CLIENT_TYPE_SPLASH:
979 /* none of these windows are manipulated by the window manager */
980 self->decorations = 0;
985 /* Mwm Hints are applied subtractively to what has already been chosen for
986 decor and functionality */
987 if (self->mwmhints.flags & OB_MWM_FLAG_DECORATIONS) {
988 if (! (self->mwmhints.decorations & OB_MWM_DECOR_ALL)) {
989 if (! ((self->mwmhints.decorations & OB_MWM_DECOR_HANDLE) ||
990 (self->mwmhints.decorations & OB_MWM_DECOR_TITLE)))
991 /* if the mwm hints request no handle or title, then all
992 decorations are disabled */
993 self->decorations = 0;
997 if (self->mwmhints.flags & OB_MWM_FLAG_FUNCTIONS) {
998 if (! (self->mwmhints.functions & OB_MWM_FUNC_ALL)) {
999 if (! (self->mwmhints.functions & OB_MWM_FUNC_RESIZE))
1000 self->functions &= ~OB_CLIENT_FUNC_RESIZE;
1001 if (! (self->mwmhints.functions & OB_MWM_FUNC_MOVE))
1002 self->functions &= ~OB_CLIENT_FUNC_MOVE;
1003 /* dont let mwm hints kill any buttons
1004 if (! (self->mwmhints.functions & OB_MWM_FUNC_ICONIFY))
1005 self->functions &= ~OB_CLIENT_FUNC_ICONIFY;
1006 if (! (self->mwmhints.functions & OB_MWM_FUNC_MAXIMIZE))
1007 self->functions &= ~OB_CLIENT_FUNC_MAXIMIZE;
1009 /* dont let mwm hints kill the close button
1010 if (! (self->mwmhints.functions & MwmFunc_Close))
1011 self->functions &= ~OB_CLIENT_FUNC_CLOSE; */
1015 if (!(self->functions & OB_CLIENT_FUNC_SHADE))
1016 self->decorations &= ~OB_FRAME_DECOR_SHADE;
1017 if (!(self->functions & OB_CLIENT_FUNC_ICONIFY))
1018 self->decorations &= ~OB_FRAME_DECOR_ICONIFY;
1019 if (!(self->functions & OB_CLIENT_FUNC_RESIZE))
1020 self->decorations &= ~OB_FRAME_DECOR_GRIPS;
1022 /* can't maximize without moving/resizing */
1023 if (!((self->functions & OB_CLIENT_FUNC_MAXIMIZE) &&
1024 (self->functions & OB_CLIENT_FUNC_MOVE) &&
1025 (self->functions & OB_CLIENT_FUNC_RESIZE))) {
1026 self->functions &= ~OB_CLIENT_FUNC_MAXIMIZE;
1027 self->decorations &= ~OB_FRAME_DECOR_MAXIMIZE;
1030 /* finally, the user can have requested no decorations, which overrides
1032 if (!self->decorate)
1033 self->decorations = 0;
1035 /* if we don't have a titlebar, then we cannot shade! */
1036 if (!(self->decorations & OB_FRAME_DECOR_TITLEBAR))
1037 self->functions &= ~OB_CLIENT_FUNC_SHADE;
1039 /* now we need to check against rules for the client's current state */
1040 if (self->fullscreen) {
1041 self->functions &= (OB_CLIENT_FUNC_CLOSE |
1042 OB_CLIENT_FUNC_FULLSCREEN |
1043 OB_CLIENT_FUNC_ICONIFY);
1044 self->decorations = 0;
1047 client_change_allowed_actions(self);
1050 /* this makes sure that these windows appear on all desktops */
1051 if (self->type == OB_CLIENT_TYPE_DESKTOP &&
1052 self->desktop != DESKTOP_ALL)
1053 client_set_desktop(self, DESKTOP_ALL, FALSE);
1055 /* adjust the client's decorations, etc. */
1056 client_reconfigure(self);
1058 /* this makes sure that these windows appear on all desktops */
1059 if (self->type == OB_CLIENT_TYPE_DESKTOP &&
1060 self->desktop != DESKTOP_ALL)
1062 self->desktop = DESKTOP_ALL;
1067 static void client_change_allowed_actions(ObClient *self)
1072 /* desktop windows are kept on all desktops */
1073 if (self->type != OB_CLIENT_TYPE_DESKTOP)
1074 actions[num++] = prop_atoms.net_wm_action_change_desktop;
1076 if (self->functions & OB_CLIENT_FUNC_SHADE)
1077 actions[num++] = prop_atoms.net_wm_action_shade;
1078 if (self->functions & OB_CLIENT_FUNC_CLOSE)
1079 actions[num++] = prop_atoms.net_wm_action_close;
1080 if (self->functions & OB_CLIENT_FUNC_MOVE)
1081 actions[num++] = prop_atoms.net_wm_action_move;
1082 if (self->functions & OB_CLIENT_FUNC_ICONIFY)
1083 actions[num++] = prop_atoms.net_wm_action_minimize;
1084 if (self->functions & OB_CLIENT_FUNC_RESIZE)
1085 actions[num++] = prop_atoms.net_wm_action_resize;
1086 if (self->functions & OB_CLIENT_FUNC_FULLSCREEN)
1087 actions[num++] = prop_atoms.net_wm_action_fullscreen;
1088 if (self->functions & OB_CLIENT_FUNC_MAXIMIZE) {
1089 actions[num++] = prop_atoms.net_wm_action_maximize_horz;
1090 actions[num++] = prop_atoms.net_wm_action_maximize_vert;
1093 PROP_SETA32(self->window, net_wm_allowed_actions, atom, actions, num);
1095 /* make sure the window isn't breaking any rules now */
1097 if (!(self->functions & OB_CLIENT_FUNC_SHADE) && self->shaded) {
1098 if (self->frame) client_shade(self, FALSE);
1099 else self->shaded = FALSE;
1101 if (!(self->functions & OB_CLIENT_FUNC_ICONIFY) && self->iconic) {
1102 if (self->frame) client_iconify(self, FALSE, TRUE);
1103 else self->iconic = FALSE;
1105 if (!(self->functions & OB_CLIENT_FUNC_FULLSCREEN) && self->fullscreen) {
1106 if (self->frame) client_fullscreen(self, FALSE, TRUE);
1107 else self->fullscreen = FALSE;
1109 if (!(self->functions & OB_CLIENT_FUNC_MAXIMIZE) && (self->max_horz ||
1111 if (self->frame) client_maximize(self, FALSE, 0, TRUE);
1112 else self->max_vert = self->max_horz = FALSE;
1116 void client_reconfigure(ObClient *self)
1118 /* by making this pass FALSE for user, we avoid the emacs event storm where
1119 every configurenotify causes an update in its normal hints, i think this
1120 is generally what we want anyways... */
1121 client_configure(self, OB_CORNER_TOPLEFT, self->area.x, self->area.y,
1122 self->area.width, self->area.height, FALSE, TRUE);
1125 void client_update_wmhints(ObClient *self)
1128 gboolean ur = FALSE;
1131 /* assume a window takes input if it doesnt specify */
1132 self->can_focus = TRUE;
1134 if ((hints = XGetWMHints(ob_display, self->window)) != NULL) {
1135 if (hints->flags & InputHint)
1136 self->can_focus = hints->input;
1138 /* only do this when first managing the window *AND* when we aren't
1140 if (ob_state() != OB_STATE_STARTING && self->frame == NULL)
1141 if (hints->flags & StateHint)
1142 self->iconic = hints->initial_state == IconicState;
1144 if (hints->flags & XUrgencyHint)
1147 if (!(hints->flags & WindowGroupHint))
1148 hints->window_group = None;
1150 /* did the group state change? */
1151 if (hints->window_group !=
1152 (self->group ? self->group->leader : None)) {
1153 /* remove from the old group if there was one */
1154 if (self->group != NULL) {
1155 /* remove transients of the group */
1156 for (it = self->group->members; it; it = it->next)
1157 self->transients = g_slist_remove(self->transients,
1159 group_remove(self->group, self);
1162 if (hints->window_group != None) {
1163 self->group = group_add(hints->window_group, self);
1165 /* i can only have transients from the group if i am not
1167 if (!self->transient_for) {
1168 /* add other transients of the group that are already
1170 for (it = self->group->members; it; it = it->next) {
1171 ObClient *c = it->data;
1172 if (c != self && c->transient_for == OB_TRAN_GROUP)
1174 g_slist_append(self->transients, c);
1179 /* the WM_HINTS can contain an icon */
1180 client_update_icons(self);
1182 /* because the self->transient flag wont change from this call,
1183 we don't need to update the window's type and such, only its
1184 transient_for, and the transients lists of other windows in
1185 the group may be affected */
1186 client_update_transient_for(self);
1192 if (ur != self->urgent) {
1194 ob_debug("Urgent Hint for 0x%lx: %s\n", self->window,
1196 /* fire the urgent callback if we're mapped, otherwise, wait until
1197 after we're mapped */
1199 dispatch_client(Event_Client_Urgent, self, self->urgent, 0);
1203 void client_update_title(ObClient *self)
1209 gboolean read_title;
1211 g_free(self->title);
1214 if (!PROP_GETS(self->window, net_wm_name, utf8, &data))
1215 /* try old x stuff */
1216 if (!PROP_GETS(self->window, wm_name, locale, &data))
1217 data = g_strdup("Unnamed Window");
1219 /* look for duplicates and append a number */
1221 for (it = client_list; it; it = it->next)
1222 if (it->data != self) {
1223 ObClient *c = it->data;
1224 if (0 == strncmp(c->title, data, strlen(data)))
1225 nums |= 1 << c->title_count;
1227 /* find first free number */
1228 for (i = 1; i <= 32; ++i)
1229 if (!(nums & (1 << i))) {
1230 if (self->title_count == 1 || i == 1)
1231 self->title_count = i;
1234 /* dont display the number for the first window */
1235 if (self->title_count > 1) {
1236 char *vdata, *ndata;
1237 ndata = g_strdup_printf(" - [%u]", self->title_count);
1238 vdata = g_strconcat(data, ndata, NULL);
1244 PROP_SETS(self->window, net_wm_visible_name, data);
1249 frame_adjust_title(self->frame);
1251 /* update the icon title */
1253 g_free(self->icon_title);
1257 if (!PROP_GETS(self->window, net_wm_icon_name, utf8, &data))
1258 /* try old x stuff */
1259 if (!PROP_GETS(self->window, wm_icon_name, locale, &data)) {
1260 data = g_strdup(self->title);
1264 /* append the title count, dont display the number for the first window */
1265 if (read_title && self->title_count > 1) {
1266 char *vdata, *ndata;
1267 ndata = g_strdup_printf(" - [%u]", self->title_count);
1268 vdata = g_strconcat(data, ndata, NULL);
1274 PROP_SETS(self->window, net_wm_visible_icon_name, data);
1276 self->icon_title = data;
1279 void client_update_class(ObClient *self)
1284 if (self->name) g_free(self->name);
1285 if (self->class) g_free(self->class);
1286 if (self->role) g_free(self->role);
1288 self->name = self->class = self->role = NULL;
1290 if (PROP_GETSS(self->window, wm_class, locale, &data)) {
1292 self->name = g_strdup(data[0]);
1294 self->class = g_strdup(data[1]);
1299 if (PROP_GETS(self->window, wm_window_role, locale, &s))
1300 self->role = g_strdup(s);
1302 if (self->name == NULL) self->name = g_strdup("");
1303 if (self->class == NULL) self->class = g_strdup("");
1304 if (self->role == NULL) self->role = g_strdup("");
1307 void client_update_strut(ObClient *self)
1312 if (!PROP_GETA32(self->window, net_wm_strut, cardinal, &data, &num)) {
1313 STRUT_SET(self->strut, 0, 0, 0, 0);
1316 STRUT_SET(self->strut, data[0], data[2], data[1], data[3]);
1318 STRUT_SET(self->strut, 0, 0, 0, 0);
1322 /* updating here is pointless while we're being mapped cuz we're not in
1323 the client list yet */
1325 screen_update_areas();
1328 void client_update_icons(ObClient *self)
1334 for (i = 0; i < self->nicons; ++i)
1335 g_free(self->icons[i].data);
1336 if (self->nicons > 0)
1337 g_free(self->icons);
1340 if (PROP_GETA32(self->window, net_wm_icon, cardinal, &data, &num)) {
1341 /* figure out how many valid icons are in here */
1343 while (num - i > 2) {
1347 if (i > num || w*h == 0) break;
1351 self->icons = g_new(ObClientIcon, self->nicons);
1353 /* store the icons */
1355 for (j = 0; j < self->nicons; ++j) {
1358 w = self->icons[j].width = data[i++];
1359 h = self->icons[j].height = data[i++];
1361 if (w*h == 0) continue;
1363 self->icons[j].data = g_new(RrPixel32, w * h);
1364 for (x = 0, y = 0, t = 0; t < w * h; ++t, ++x, ++i) {
1369 self->icons[j].data[t] =
1370 (((data[i] >> 24) & 0xff) << RrDefaultAlphaOffset) +
1371 (((data[i] >> 16) & 0xff) << RrDefaultRedOffset) +
1372 (((data[i] >> 8) & 0xff) << RrDefaultGreenOffset) +
1373 (((data[i] >> 0) & 0xff) << RrDefaultBlueOffset);
1379 } else if (PROP_GETA32(self->window, kwm_win_icon,
1380 kwm_win_icon, &data, &num)) {
1383 self->icons = g_new(ObClientIcon, self->nicons);
1384 xerror_set_ignore(TRUE);
1385 if (!RrPixmapToRGBA(ob_rr_inst,
1387 &self->icons[self->nicons-1].width,
1388 &self->icons[self->nicons-1].height,
1389 &self->icons[self->nicons-1].data)) {
1390 g_free(&self->icons[self->nicons-1]);
1393 xerror_set_ignore(FALSE);
1399 if ((hints = XGetWMHints(ob_display, self->window))) {
1400 if (hints->flags & IconPixmapHint) {
1402 self->icons = g_new(ObClientIcon, self->nicons);
1403 xerror_set_ignore(TRUE);
1404 if (!RrPixmapToRGBA(ob_rr_inst,
1406 (hints->flags & IconMaskHint ?
1407 hints->icon_mask : None),
1408 &self->icons[self->nicons-1].width,
1409 &self->icons[self->nicons-1].height,
1410 &self->icons[self->nicons-1].data)){
1411 g_free(&self->icons[self->nicons-1]);
1414 xerror_set_ignore(FALSE);
1421 frame_adjust_icon(self->frame);
1424 static void client_change_state(ObClient *self)
1427 guint32 netstate[10];
1430 state[0] = self->wmstate;
1432 PROP_SETA32(self->window, wm_state, wm_state, state, 2);
1436 netstate[num++] = prop_atoms.net_wm_state_modal;
1438 netstate[num++] = prop_atoms.net_wm_state_shaded;
1440 netstate[num++] = prop_atoms.net_wm_state_hidden;
1441 if (self->skip_taskbar)
1442 netstate[num++] = prop_atoms.net_wm_state_skip_taskbar;
1443 if (self->skip_pager)
1444 netstate[num++] = prop_atoms.net_wm_state_skip_pager;
1445 if (self->fullscreen)
1446 netstate[num++] = prop_atoms.net_wm_state_fullscreen;
1448 netstate[num++] = prop_atoms.net_wm_state_maximized_vert;
1450 netstate[num++] = prop_atoms.net_wm_state_maximized_horz;
1452 netstate[num++] = prop_atoms.net_wm_state_above;
1454 netstate[num++] = prop_atoms.net_wm_state_below;
1455 PROP_SETA32(self->window, net_wm_state, atom, netstate, num);
1457 client_calc_layer(self);
1460 frame_adjust_state(self->frame);
1463 ObClient *client_search_focus_tree(ObClient *self)
1468 for (it = self->transients; it != NULL; it = it->next) {
1469 if (client_focused(it->data)) return it->data;
1470 if ((ret = client_search_focus_tree(it->data))) return ret;
1475 ObClient *client_search_focus_tree_full(ObClient *self)
1477 if (self->transient_for) {
1478 if (self->transient_for != OB_TRAN_GROUP) {
1479 return client_search_focus_tree_full(self->transient_for);
1482 gboolean recursed = FALSE;
1484 for (it = self->group->members; it; it = it->next)
1485 if (!((ObClient*)it->data)->transient_for) {
1487 if ((c = client_search_focus_tree_full(it->data)))
1496 /* this function checks the whole tree, the client_search_focus_tree~
1497 does not, so we need to check this window */
1498 if (client_focused(self))
1500 return client_search_focus_tree(self);
1503 static ObStackingLayer calc_layer(ObClient *self)
1507 if (self->fullscreen) l = OB_STACKING_LAYER_FULLSCREEN;
1508 else if (self->type == OB_CLIENT_TYPE_DESKTOP)
1509 l = OB_STACKING_LAYER_DESKTOP;
1510 else if (self->type == OB_CLIENT_TYPE_DOCK) {
1511 if (!self->below) l = OB_STACKING_LAYER_TOP;
1512 else l = OB_STACKING_LAYER_NORMAL;
1514 else if (self->above) l = OB_STACKING_LAYER_ABOVE;
1515 else if (self->below) l = OB_STACKING_LAYER_BELOW;
1516 else l = OB_STACKING_LAYER_NORMAL;
1521 static void client_calc_layer_recursive(ObClient *self, ObClient *orig,
1522 ObStackingLayer l, gboolean raised)
1524 ObStackingLayer old, own;
1528 own = calc_layer(self);
1529 self->layer = l > own ? l : own;
1531 for (it = self->transients; it; it = it->next)
1532 client_calc_layer_recursive(it->data, orig,
1533 l, raised ? raised : l != old);
1535 if (!raised && l != old)
1536 if (orig->frame) { /* only restack if the original window is managed */
1537 /* XXX add_non_intrusive ever? */
1538 stacking_remove(CLIENT_AS_WINDOW(self));
1539 stacking_add(CLIENT_AS_WINDOW(self));
1543 void client_calc_layer(ObClient *self)
1550 /* transients take on the layer of their parents */
1551 self = client_search_top_transient(self);
1553 l = calc_layer(self);
1555 client_calc_layer_recursive(self, orig, l, FALSE);
1558 gboolean client_should_show(ObClient *self)
1560 if (self->iconic) return FALSE;
1561 else if (!(self->desktop == screen_desktop ||
1562 self->desktop == DESKTOP_ALL)) return FALSE;
1563 else if (client_normal(self) && screen_showing_desktop) return FALSE;
1568 static void client_showhide(ObClient *self)
1571 if (client_should_show(self))
1572 frame_show(self->frame);
1574 frame_hide(self->frame);
1577 gboolean client_normal(ObClient *self) {
1578 return ! (self->type == OB_CLIENT_TYPE_DESKTOP ||
1579 self->type == OB_CLIENT_TYPE_DOCK ||
1580 self->type == OB_CLIENT_TYPE_SPLASH);
1583 static void client_apply_startup_state(ObClient *self)
1585 /* these are in a carefully crafted order.. */
1588 self->iconic = FALSE;
1589 client_iconify(self, TRUE, FALSE);
1591 if (self->fullscreen) {
1592 self->fullscreen = FALSE;
1593 client_fullscreen(self, TRUE, FALSE);
1596 self->shaded = FALSE;
1597 client_shade(self, TRUE);
1600 dispatch_client(Event_Client_Urgent, self, self->urgent, 0);
1602 if (self->max_vert && self->max_horz) {
1603 self->max_vert = self->max_horz = FALSE;
1604 client_maximize(self, TRUE, 0, FALSE);
1605 } else if (self->max_vert) {
1606 self->max_vert = FALSE;
1607 client_maximize(self, TRUE, 2, FALSE);
1608 } else if (self->max_horz) {
1609 self->max_horz = FALSE;
1610 client_maximize(self, TRUE, 1, FALSE);
1613 /* nothing to do for the other states:
1622 void client_configure(ObClient *self, ObCorner anchor,
1623 int x, int y, int w, int h,
1624 gboolean user, gboolean final)
1626 gboolean moved = FALSE, resized = FALSE;
1628 /* gets the frame's position */
1629 frame_client_gravity(self->frame, &x, &y);
1631 /* these positions are frame positions, not client positions */
1633 /* set the size and position if fullscreen */
1634 if (self->fullscreen) {
1637 XF86VidModeModeLine mode;
1642 i = client_monitor(self);
1643 a = screen_physical_area_monitor(i);
1646 if (i == 0 && /* primary head */
1647 extensions_vidmode &&
1648 XF86VidModeGetViewPort(ob_display, ob_screen, &x, &y) &&
1649 /* get the mode last so the mode.privsize isnt freed incorrectly */
1650 XF86VidModeGetModeLine(ob_display, ob_screen, &dot, &mode)) {
1655 if (mode.privsize) XFree(mode.private);
1665 user = FALSE; /* ignore that increment etc shit when in fullscreen */
1669 a = screen_area_monitor(self->desktop, client_monitor(self));
1671 /* set the size and position if maximized */
1672 if (self->max_horz) {
1673 x = a->x - self->frame->size.left;
1676 if (self->max_vert) {
1678 h = a->height - self->frame->size.top - self->frame->size.bottom;
1682 /* gets the client's position */
1683 frame_frame_gravity(self->frame, &x, &y);
1685 /* these override the above states! if you cant move you can't move! */
1687 if (!(self->functions & OB_CLIENT_FUNC_MOVE)) {
1691 if (!(self->functions & OB_CLIENT_FUNC_RESIZE)) {
1692 w = self->area.width;
1693 h = self->area.height;
1697 if (!(w == self->area.width && h == self->area.height)) {
1698 int basew, baseh, minw, minh;
1700 /* base size is substituted with min size if not specified */
1701 if (self->base_size.width || self->base_size.height) {
1702 basew = self->base_size.width;
1703 baseh = self->base_size.height;
1705 basew = self->min_size.width;
1706 baseh = self->min_size.height;
1708 /* min size is substituted with base size if not specified */
1709 if (self->min_size.width || self->min_size.height) {
1710 minw = self->min_size.width;
1711 minh = self->min_size.height;
1713 minw = self->base_size.width;
1714 minh = self->base_size.height;
1718 /* for interactive resizing. have to move half an increment in each
1721 /* how far we are towards the next size inc */
1722 int mw = (w - basew) % self->size_inc.width;
1723 int mh = (h - baseh) % self->size_inc.height;
1725 int aw = self->size_inc.width / 2;
1726 int ah = self->size_inc.height / 2;
1727 /* don't let us move into a new size increment */
1728 if (mw + aw >= self->size_inc.width)
1729 aw = self->size_inc.width - mw - 1;
1730 if (mh + ah >= self->size_inc.height)
1731 ah = self->size_inc.height - mh - 1;
1735 /* if this is a user-requested resize, then check against min/max
1738 /* smaller than min size or bigger than max size? */
1739 if (w > self->max_size.width) w = self->max_size.width;
1740 if (w < minw) w = minw;
1741 if (h > self->max_size.height) h = self->max_size.height;
1742 if (h < minh) h = minh;
1748 /* keep to the increments */
1749 w /= self->size_inc.width;
1750 h /= self->size_inc.height;
1752 /* you cannot resize to nothing */
1756 /* store the logical size */
1757 SIZE_SET(self->logical_size, w, h);
1759 w *= self->size_inc.width;
1760 h *= self->size_inc.height;
1766 /* adjust the height to match the width for the aspect ratios.
1767 for this, min size is not substituted for base size ever. */
1768 w -= self->base_size.width;
1769 h -= self->base_size.height;
1771 if (self->min_ratio)
1772 if (h * self->min_ratio > w) h = (int)(w / self->min_ratio);
1773 if (self->max_ratio)
1774 if (h * self->max_ratio < w) h = (int)(w / self->max_ratio);
1776 w += self->base_size.width;
1777 h += self->base_size.height;
1782 case OB_CORNER_TOPLEFT:
1784 case OB_CORNER_TOPRIGHT:
1785 x -= w - self->area.width;
1787 case OB_CORNER_BOTTOMLEFT:
1788 y -= h - self->area.height;
1790 case OB_CORNER_BOTTOMRIGHT:
1791 x -= w - self->area.width;
1792 y -= h - self->area.height;
1796 moved = x != self->area.x || y != self->area.y;
1797 resized = w != self->area.width || h != self->area.height;
1799 RECT_SET(self->area, x, y, w, h);
1801 /* for app-requested resizes, always resize if 'resized' is true.
1802 for user-requested ones, only resize if final is true, or when
1803 resizing in opaque mode */
1804 if ((!user && resized) ||
1805 (user && (final || (resized && config_opaque_resize))))
1806 XResizeWindow(ob_display, self->window, w, h);
1808 /* move/resize the frame to match the request */
1810 if (self->decorations != self->frame->decorations)
1811 moved = resized = TRUE;
1813 if (moved || resized)
1814 frame_adjust_area(self->frame, moved, resized);
1816 /* If you send this and the client hasn't changed you end up with buggy
1817 clients (emacs) freaking out, cuz they send back a configure every
1818 time they receive this event, which resends them this event... etc.
1820 if ((!user && moved) || (user && final)) {
1822 event.type = ConfigureNotify;
1823 event.xconfigure.display = ob_display;
1824 event.xconfigure.event = self->window;
1825 event.xconfigure.window = self->window;
1827 /* root window real coords */
1828 event.xconfigure.x = self->frame->area.x + self->frame->size.left;
1829 event.xconfigure.y = self->frame->area.y + self->frame->size.top;
1831 event.xconfigure.width = w;
1832 event.xconfigure.height = h;
1833 event.xconfigure.border_width = 0;
1834 event.xconfigure.above = self->frame->plate;
1835 event.xconfigure.override_redirect = FALSE;
1836 XSendEvent(event.xconfigure.display, event.xconfigure.window,
1837 FALSE, StructureNotifyMask, &event);
1842 void client_fullscreen(ObClient *self, gboolean fs, gboolean savearea)
1846 if (!(self->functions & OB_CLIENT_FUNC_FULLSCREEN) || /* can't */
1847 self->fullscreen == fs) return; /* already done */
1849 self->fullscreen = fs;
1850 client_change_state(self); /* change the state hints on the client,
1851 and adjust out layer/stacking */
1855 guint32 dimensions[4];
1856 dimensions[0] = self->area.x;
1857 dimensions[1] = self->area.y;
1858 dimensions[2] = self->area.width;
1859 dimensions[3] = self->area.height;
1861 PROP_SETA32(self->window, openbox_premax, cardinal,
1865 /* these are not actually used cuz client_configure will set them
1866 as appropriate when the window is fullscreened */
1873 /* pick some fallbacks... */
1874 a = screen_area_monitor(self->desktop, 0);
1875 x = a->x + a->width / 4;
1876 y = a->y + a->height / 4;
1880 if (PROP_GETA32(self->window, openbox_premax, cardinal,
1881 (guint32**)&dimensions, &num)) {
1892 client_setup_decor_and_functions(self);
1894 client_configure(self, OB_CORNER_TOPLEFT, x, y, w, h, TRUE, TRUE);
1896 /* try focus us when we go into fullscreen mode */
1900 static void client_iconify_recursive(ObClient *self,
1901 gboolean iconic, gboolean curdesk)
1904 gboolean changed = FALSE;
1907 if (self->iconic != iconic) {
1908 ob_debug("%sconifying window: 0x%lx\n", (iconic ? "I" : "Uni"),
1911 self->iconic = iconic;
1914 if (self->functions & OB_CLIENT_FUNC_ICONIFY) {
1915 self->wmstate = IconicState;
1916 self->ignore_unmaps++;
1917 /* we unmap the client itself so that we can get MapRequest
1918 events, and because the ICCCM tells us to! */
1919 XUnmapWindow(ob_display, self->window);
1921 /* update the focus lists.. iconic windows go to the bottom of
1922 the list, put the new iconic window at the 'top of the
1924 focus_order_to_top(self);
1930 client_set_desktop(self, screen_desktop, FALSE);
1931 self->wmstate = self->shaded ? IconicState : NormalState;
1932 XMapWindow(ob_display, self->window);
1934 /* this puts it after the current focused window */
1935 focus_order_remove(self);
1936 focus_order_add_new(self);
1938 /* this is here cuz with the VIDMODE extension, the viewport can
1939 change while a fullscreen window is iconic, and when it
1940 uniconifies, it would be nice if it did so to the new position
1942 client_reconfigure(self);
1949 client_change_state(self);
1950 client_showhide(self);
1951 screen_update_areas();
1953 dispatch_client(iconic ? Event_Client_Unmapped : Event_Client_Mapped,
1957 /* iconify all transients */
1958 for (it = self->transients; it != NULL; it = it->next)
1959 if (it->data != self) client_iconify_recursive(it->data,
1963 void client_iconify(ObClient *self, gboolean iconic, gboolean curdesk)
1965 /* move up the transient chain as far as possible first */
1966 self = client_search_top_transient(self);
1968 client_iconify_recursive(client_search_top_transient(self),
1972 void client_maximize(ObClient *self, gboolean max, int dir, gboolean savearea)
1976 g_assert(dir == 0 || dir == 1 || dir == 2);
1977 if (!(self->functions & OB_CLIENT_FUNC_MAXIMIZE)) return; /* can't */
1979 /* check if already done */
1981 if (dir == 0 && self->max_horz && self->max_vert) return;
1982 if (dir == 1 && self->max_horz) return;
1983 if (dir == 2 && self->max_vert) return;
1985 if (dir == 0 && !self->max_horz && !self->max_vert) return;
1986 if (dir == 1 && !self->max_horz) return;
1987 if (dir == 2 && !self->max_vert) return;
1990 /* work with the frame's coords */
1991 x = self->frame->area.x;
1992 y = self->frame->area.y;
1993 w = self->area.width;
1994 h = self->area.height;
1998 gint32 dimensions[4];
2007 /* get the property off the window and use it for the dimensions
2008 we are already maxed on */
2009 if (PROP_GETA32(self->window, openbox_premax, cardinal,
2010 (guint32**)&readdim, &num)) {
2012 if (self->max_horz) {
2013 dimensions[0] = readdim[0];
2014 dimensions[2] = readdim[2];
2016 if (self->max_vert) {
2017 dimensions[1] = readdim[1];
2018 dimensions[3] = readdim[3];
2024 PROP_SETA32(self->window, openbox_premax, cardinal,
2025 (guint32*)dimensions, 4);
2032 /* pick some fallbacks... */
2033 a = screen_area_monitor(self->desktop, 0);
2034 if (dir == 0 || dir == 1) { /* horz */
2035 x = a->x + a->width / 4;
2038 if (dir == 0 || dir == 2) { /* vert */
2039 y = a->y + a->height / 4;
2043 if (PROP_GETA32(self->window, openbox_premax, cardinal,
2044 (guint32**)&dimensions, &num)) {
2046 if (dir == 0 || dir == 1) { /* horz */
2050 if (dir == 0 || dir == 2) { /* vert */
2059 if (dir == 0 || dir == 1) /* horz */
2060 self->max_horz = max;
2061 if (dir == 0 || dir == 2) /* vert */
2062 self->max_vert = max;
2064 if (!self->max_horz && !self->max_vert)
2065 PROP_ERASE(self->window, openbox_premax);
2067 client_change_state(self); /* change the state hints on the client */
2069 /* figure out where the client should be going */
2070 frame_frame_gravity(self->frame, &x, &y);
2071 client_configure(self, OB_CORNER_TOPLEFT, x, y, w, h, TRUE, TRUE);
2074 void client_shade(ObClient *self, gboolean shade)
2076 if ((!(self->functions & OB_CLIENT_FUNC_SHADE) &&
2077 shade) || /* can't shade */
2078 self->shaded == shade) return; /* already done */
2080 /* when we're iconic, don't change the wmstate */
2082 self->wmstate = shade ? IconicState : NormalState;
2083 self->shaded = shade;
2084 client_change_state(self);
2085 /* resize the frame to just the titlebar */
2086 frame_adjust_area(self->frame, FALSE, FALSE);
2089 void client_close(ObClient *self)
2093 if (!(self->functions & OB_CLIENT_FUNC_CLOSE)) return;
2096 XXX: itd be cool to do timeouts and shit here for killing the client's
2098 like... if the window is around after 5 seconds, then the close button
2099 turns a nice red, and if this function is called again, the client is
2103 ce.xclient.type = ClientMessage;
2104 ce.xclient.message_type = prop_atoms.wm_protocols;
2105 ce.xclient.display = ob_display;
2106 ce.xclient.window = self->window;
2107 ce.xclient.format = 32;
2108 ce.xclient.data.l[0] = prop_atoms.wm_delete_window;
2109 ce.xclient.data.l[1] = event_lasttime;
2110 ce.xclient.data.l[2] = 0l;
2111 ce.xclient.data.l[3] = 0l;
2112 ce.xclient.data.l[4] = 0l;
2113 XSendEvent(ob_display, self->window, FALSE, NoEventMask, &ce);
2116 void client_kill(ObClient *self)
2118 XKillClient(ob_display, self->window);
2121 void client_set_desktop_recursive(ObClient *self,
2122 guint target, gboolean donthide)
2127 if (target != self->desktop) {
2129 ob_debug("Setting desktop %u\n", target+1);
2131 g_assert(target < screen_num_desktops || target == DESKTOP_ALL);
2133 /* remove from the old desktop(s) */
2134 focus_order_remove(self);
2136 old = self->desktop;
2137 self->desktop = target;
2138 PROP_SET32(self->window, net_wm_desktop, cardinal, target);
2139 /* the frame can display the current desktop state */
2140 frame_adjust_state(self->frame);
2141 /* 'move' the window to the new desktop */
2143 client_showhide(self);
2144 /* raise if it was not already on the desktop */
2145 if (old != DESKTOP_ALL)
2146 stacking_raise(CLIENT_AS_WINDOW(self));
2147 screen_update_areas();
2149 /* add to the new desktop(s) */
2150 if (config_focus_new)
2151 focus_order_to_top(self);
2153 focus_order_to_bottom(self);
2155 dispatch_client(Event_Client_Desktop, self, target, old);
2158 /* move all transients */
2159 for (it = self->transients; it != NULL; it = it->next)
2160 if (it->data != self) client_set_desktop_recursive(it->data,
2164 void client_set_desktop(ObClient *self, guint target, gboolean donthide)
2166 client_set_desktop_recursive(client_search_top_transient(self),
2170 ObClient *client_search_modal_child(ObClient *self)
2175 for (it = self->transients; it != NULL; it = it->next) {
2176 ObClient *c = it->data;
2177 if ((ret = client_search_modal_child(c))) return ret;
2178 if (c->modal) return c;
2183 gboolean client_validate(ObClient *self)
2187 XSync(ob_display, FALSE); /* get all events on the server */
2189 if (XCheckTypedWindowEvent(ob_display, self->window, DestroyNotify, &e) ||
2190 XCheckTypedWindowEvent(ob_display, self->window, UnmapNotify, &e)) {
2191 XPutBackEvent(ob_display, &e);
2198 void client_set_wm_state(ObClient *self, long state)
2200 if (state == self->wmstate) return; /* no change */
2204 client_iconify(self, TRUE, TRUE);
2207 client_iconify(self, FALSE, TRUE);
2212 void client_set_state(ObClient *self, Atom action, long data1, long data2)
2214 gboolean shaded = self->shaded;
2215 gboolean fullscreen = self->fullscreen;
2216 gboolean max_horz = self->max_horz;
2217 gboolean max_vert = self->max_vert;
2220 if (!(action == prop_atoms.net_wm_state_add ||
2221 action == prop_atoms.net_wm_state_remove ||
2222 action == prop_atoms.net_wm_state_toggle))
2223 /* an invalid action was passed to the client message, ignore it */
2226 for (i = 0; i < 2; ++i) {
2227 Atom state = i == 0 ? data1 : data2;
2229 if (!state) continue;
2231 /* if toggling, then pick whether we're adding or removing */
2232 if (action == prop_atoms.net_wm_state_toggle) {
2233 if (state == prop_atoms.net_wm_state_modal)
2234 action = self->modal ? prop_atoms.net_wm_state_remove :
2235 prop_atoms.net_wm_state_add;
2236 else if (state == prop_atoms.net_wm_state_maximized_vert)
2237 action = self->max_vert ? prop_atoms.net_wm_state_remove :
2238 prop_atoms.net_wm_state_add;
2239 else if (state == prop_atoms.net_wm_state_maximized_horz)
2240 action = self->max_horz ? prop_atoms.net_wm_state_remove :
2241 prop_atoms.net_wm_state_add;
2242 else if (state == prop_atoms.net_wm_state_shaded)
2243 action = self->shaded ? prop_atoms.net_wm_state_remove :
2244 prop_atoms.net_wm_state_add;
2245 else if (state == prop_atoms.net_wm_state_skip_taskbar)
2246 action = self->skip_taskbar ?
2247 prop_atoms.net_wm_state_remove :
2248 prop_atoms.net_wm_state_add;
2249 else if (state == prop_atoms.net_wm_state_skip_pager)
2250 action = self->skip_pager ?
2251 prop_atoms.net_wm_state_remove :
2252 prop_atoms.net_wm_state_add;
2253 else if (state == prop_atoms.net_wm_state_fullscreen)
2254 action = self->fullscreen ?
2255 prop_atoms.net_wm_state_remove :
2256 prop_atoms.net_wm_state_add;
2257 else if (state == prop_atoms.net_wm_state_above)
2258 action = self->above ? prop_atoms.net_wm_state_remove :
2259 prop_atoms.net_wm_state_add;
2260 else if (state == prop_atoms.net_wm_state_below)
2261 action = self->below ? prop_atoms.net_wm_state_remove :
2262 prop_atoms.net_wm_state_add;
2265 if (action == prop_atoms.net_wm_state_add) {
2266 if (state == prop_atoms.net_wm_state_modal) {
2267 /* XXX raise here or something? */
2269 } else if (state == prop_atoms.net_wm_state_maximized_vert) {
2271 } else if (state == prop_atoms.net_wm_state_maximized_horz) {
2273 } else if (state == prop_atoms.net_wm_state_shaded) {
2275 } else if (state == prop_atoms.net_wm_state_skip_taskbar) {
2276 self->skip_taskbar = TRUE;
2277 } else if (state == prop_atoms.net_wm_state_skip_pager) {
2278 self->skip_pager = TRUE;
2279 } else if (state == prop_atoms.net_wm_state_fullscreen) {
2281 } else if (state == prop_atoms.net_wm_state_above) {
2283 } else if (state == prop_atoms.net_wm_state_below) {
2287 } else { /* action == prop_atoms.net_wm_state_remove */
2288 if (state == prop_atoms.net_wm_state_modal) {
2289 self->modal = FALSE;
2290 } else if (state == prop_atoms.net_wm_state_maximized_vert) {
2292 } else if (state == prop_atoms.net_wm_state_maximized_horz) {
2294 } else if (state == prop_atoms.net_wm_state_shaded) {
2296 } else if (state == prop_atoms.net_wm_state_skip_taskbar) {
2297 self->skip_taskbar = FALSE;
2298 } else if (state == prop_atoms.net_wm_state_skip_pager) {
2299 self->skip_pager = FALSE;
2300 } else if (state == prop_atoms.net_wm_state_fullscreen) {
2302 } else if (state == prop_atoms.net_wm_state_above) {
2303 self->above = FALSE;
2304 } else if (state == prop_atoms.net_wm_state_below) {
2305 self->below = FALSE;
2309 if (max_horz != self->max_horz || max_vert != self->max_vert) {
2310 if (max_horz != self->max_horz && max_vert != self->max_vert) {
2312 if (max_horz == max_vert) { /* both going the same way */
2313 client_maximize(self, max_horz, 0, TRUE);
2315 client_maximize(self, max_horz, 1, TRUE);
2316 client_maximize(self, max_vert, 2, TRUE);
2320 if (max_horz != self->max_horz)
2321 client_maximize(self, max_horz, 1, TRUE);
2323 client_maximize(self, max_vert, 2, TRUE);
2326 /* change fullscreen state before shading, as it will affect if the window
2328 if (fullscreen != self->fullscreen)
2329 client_fullscreen(self, fullscreen, TRUE);
2330 if (shaded != self->shaded)
2331 client_shade(self, shaded);
2332 client_calc_layer(self);
2333 client_change_state(self); /* change the hint to reflect these changes */
2336 ObClient *client_focus_target(ObClient *self)
2340 /* if we have a modal child, then focus it, not us */
2341 child = client_search_modal_child(self);
2342 if (child) return child;
2346 gboolean client_can_focus(ObClient *self)
2350 /* choose the correct target */
2351 self = client_focus_target(self);
2353 if (!self->frame->visible)
2356 if (!((self->can_focus || self->focus_notify) &&
2357 (self->desktop == screen_desktop ||
2358 self->desktop == DESKTOP_ALL) &&
2362 /* do a check to see if the window has already been unmapped or destroyed
2363 do this intelligently while watching out for unmaps we've generated
2364 (ignore_unmaps > 0) */
2365 if (XCheckTypedWindowEvent(ob_display, self->window,
2366 DestroyNotify, &ev)) {
2367 XPutBackEvent(ob_display, &ev);
2370 while (XCheckTypedWindowEvent(ob_display, self->window,
2371 UnmapNotify, &ev)) {
2372 if (self->ignore_unmaps) {
2373 self->ignore_unmaps--;
2375 XPutBackEvent(ob_display, &ev);
2383 gboolean client_focus(ObClient *self)
2385 /* choose the correct target */
2386 self = client_focus_target(self);
2388 if (!client_can_focus(self)) {
2389 if (!self->frame->visible) {
2390 /* update the focus lists */
2391 focus_order_to_top(self);
2396 if (self->can_focus)
2397 /* RevertToPointerRoot causes much more headache than RevertToNone, so
2398 I choose to use it always, hopefully to find errors quicker, if any
2399 are left. (I hate X. I hate focus events.) */
2400 XSetInputFocus(ob_display, self->window, RevertToPointerRoot,
2403 if (self->focus_notify) {
2405 ce.xclient.type = ClientMessage;
2406 ce.xclient.message_type = prop_atoms.wm_protocols;
2407 ce.xclient.display = ob_display;
2408 ce.xclient.window = self->window;
2409 ce.xclient.format = 32;
2410 ce.xclient.data.l[0] = prop_atoms.wm_take_focus;
2411 ce.xclient.data.l[1] = event_lasttime;
2412 ce.xclient.data.l[2] = 0l;
2413 ce.xclient.data.l[3] = 0l;
2414 ce.xclient.data.l[4] = 0l;
2415 XSendEvent(ob_display, self->window, FALSE, NoEventMask, &ce);
2419 ob_debug("%sively focusing %lx at %d\n",
2420 (self->can_focus ? "act" : "pass"),
2421 self->window, (int) event_lasttime);
2424 /* Cause the FocusIn to come back to us. Important for desktop switches,
2425 since otherwise we'll have no FocusIn on the queue and send it off to
2426 the focus_backup. */
2427 XSync(ob_display, FALSE);
2431 void client_unfocus(ObClient *self)
2433 g_assert(focus_client == self);
2435 ob_debug("client_unfocus for %lx\n", self->window);
2437 focus_fallback(OB_FOCUS_FALLBACK_UNFOCUSING);
2440 void client_activate(ObClient *self)
2442 if (client_normal(self) && screen_showing_desktop)
2443 screen_show_desktop(FALSE);
2445 client_iconify(self, FALSE, FALSE);
2446 if (self->desktop != DESKTOP_ALL &&
2447 self->desktop != screen_desktop)
2448 screen_set_desktop(self->desktop);
2449 else if (!self->frame->visible)
2450 /* if its not visible for other reasons, then don't mess
2454 client_shade(self, FALSE);
2456 stacking_raise(CLIENT_AS_WINDOW(self));
2459 gboolean client_focused(ObClient *self)
2461 return self == focus_client;
2464 ObClientIcon *client_icon(ObClient *self, int w, int h)
2467 /* si is the smallest image >= req */
2468 /* li is the largest image < req */
2469 unsigned long size, smallest = 0xffffffff, largest = 0, si = 0, li = 0;
2471 if (!self->nicons) return NULL;
2473 for (i = 0; i < self->nicons; ++i) {
2474 size = self->icons[i].width * self->icons[i].height;
2475 if (size < smallest && size >= (unsigned)(w * h)) {
2479 if (size > largest && size <= (unsigned)(w * h)) {
2484 if (largest == 0) /* didnt find one smaller than the requested size */
2485 return &self->icons[si];
2486 return &self->icons[li];
2489 /* this be mostly ripped from fvwm */
2490 ObClient *client_find_directional(ObClient *c, ObDirection dir)
2492 int my_cx, my_cy, his_cx, his_cy;
2495 int score, best_score;
2496 ObClient *best_client, *cur;
2502 /* first, find the centre coords of the currently focused window */
2503 my_cx = c->frame->area.x + c->frame->area.width / 2;
2504 my_cy = c->frame->area.y + c->frame->area.height / 2;
2509 for(it = g_list_first(client_list); it; it = it->next) {
2512 /* the currently selected window isn't interesting */
2515 if (!client_normal(cur))
2517 if(c->desktop != cur->desktop && cur->desktop != DESKTOP_ALL)
2521 if(client_focus_target(cur) == cur &&
2522 !(cur->can_focus || cur->focus_notify))
2525 /* find the centre coords of this window, from the
2526 * currently focused window's point of view */
2527 his_cx = (cur->frame->area.x - my_cx)
2528 + cur->frame->area.width / 2;
2529 his_cy = (cur->frame->area.y - my_cy)
2530 + cur->frame->area.height / 2;
2534 /* Rotate the diagonals 45 degrees counterclockwise.
2535 * To do this, multiply the matrix /+h +h\ with the
2536 * vector (x y). \-h +h/
2537 * h = sqrt(0.5). We can set h := 1 since absolute
2538 * distance doesn't matter here. */
2539 tx = his_cx + his_cy;
2540 his_cy = -his_cx + his_cy;
2545 case OB_DIRECTION_NORTH:
2546 case OB_DIRECTION_SOUTH:
2547 case OB_DIRECTION_NORTHEAST:
2548 case OB_DIRECTION_SOUTHWEST:
2549 offset = (his_cx < 0) ? -his_cx : his_cx;
2550 distance = ((dir == OB_DIRECTION_NORTH ||
2551 dir == OB_DIRECTION_NORTHEAST) ?
2554 case OB_DIRECTION_EAST:
2555 case OB_DIRECTION_WEST:
2556 case OB_DIRECTION_SOUTHEAST:
2557 case OB_DIRECTION_NORTHWEST:
2558 offset = (his_cy < 0) ? -his_cy : his_cy;
2559 distance = ((dir == OB_DIRECTION_WEST ||
2560 dir == OB_DIRECTION_NORTHWEST) ?
2565 /* the target must be in the requested direction */
2569 /* Calculate score for this window. The smaller the better. */
2570 score = distance + offset;
2572 /* windows more than 45 degrees off the direction are
2573 * heavily penalized and will only be chosen if nothing
2574 * else within a million pixels */
2575 if(offset > distance)
2578 if(best_score == -1 || score < best_score)
2586 void client_set_layer(ObClient *self, int layer)
2590 self->above = FALSE;
2591 } else if (layer == 0) {
2592 self->below = self->above = FALSE;
2594 self->below = FALSE;
2597 client_calc_layer(self);
2598 client_change_state(self); /* reflect this in the state hints */
2601 guint client_monitor(ObClient *self)
2605 for (i = 0; i < screen_num_monitors; ++i) {
2606 Rect *area = screen_physical_area_monitor(i);
2607 if (RECT_INTERSECTS_RECT(*area, self->frame->area))
2610 if (i == screen_num_monitors) i = 0;
2611 g_assert(i < screen_num_monitors);
2615 ObClient *client_search_top_transient(ObClient *self)
2617 /* move up the transient chain as far as possible */
2618 if (self->transient_for) {
2619 if (self->transient_for != OB_TRAN_GROUP) {
2620 return client_search_top_transient(self->transient_for);
2624 for (it = self->group->members; it; it = it->next) {
2625 ObClient *c = it->data;
2627 /* checking transient_for prevents infinate loops! */
2628 if (c != self && !c->transient_for)