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)
713 ObClient *target = NULL;
715 if (XGetTransientForHint(ob_display, self->window, &t)) {
716 self->transient = TRUE;
717 if (t != self->window) { /* cant be transient to itself! */
718 target = g_hash_table_lookup(window_map, &t);
719 /* if this happens then we need to check for it*/
720 g_assert(target != self);
721 g_assert(!target || WINDOW_IS_CLIENT(target));
723 if (!target && 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! */
730 target = OB_TRAN_GROUP;
735 self->transient = FALSE;
737 /* if anything has changed... */
738 if (target != 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 = g_slist_next(it)) {
744 ObClient *c = it->data;
745 if (c != self && !c->transient_for)
746 c->transients = g_slist_remove(c->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 = target;
754 if (self->transient_for == OB_TRAN_GROUP) { /* transient of group */
757 /* add to new parents */
758 for (it = self->group->members; it; it = g_slist_next(it)) {
759 ObClient *c = it->data;
760 if (c != self && !c->transient_for)
761 c->transients = g_slist_append(c->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 = g_slist_next(it)) {
768 for (sit = self->transients; sit; sit = next) {
769 next = g_slist_next(sit);
770 if (sit->data == it->data)
772 g_slist_delete_link(self->transients, sit);
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 ObClient *c = it->data;
1179 if (c != self && c->transient_for == OB_TRAN_GROUP)
1181 g_slist_append(self->transients, c);
1186 /* the WM_HINTS can contain an icon */
1187 client_update_icons(self);
1189 /* because the self->transient flag wont change from this call,
1190 we don't need to update the window's type and such, only its
1191 transient_for, and the transients lists of other windows in
1192 the group may be affected */
1193 client_update_transient_for(self);
1199 if (ur != self->urgent) {
1201 g_message("Urgent Hint for 0x%lx: %s", self->window,
1203 /* fire the urgent callback if we're mapped, otherwise, wait until
1204 after we're mapped */
1206 dispatch_client(Event_Client_Urgent, self, self->urgent, 0);
1210 void client_update_title(ObClient *self)
1216 gboolean read_title;
1218 g_free(self->title);
1221 if (!PROP_GETS(self->window, net_wm_name, utf8, &data))
1222 /* try old x stuff */
1223 if (!PROP_GETS(self->window, wm_name, locale, &data))
1224 data = g_strdup("Unnamed Window");
1226 /* look for duplicates and append a number */
1228 for (it = client_list; it; it = it->next)
1229 if (it->data != self) {
1230 ObClient *c = it->data;
1231 if (0 == strncmp(c->title, data, strlen(data)))
1232 nums |= 1 << c->title_count;
1234 /* find first free number */
1235 for (i = 1; i <= 32; ++i)
1236 if (!(nums & (1 << i))) {
1237 if (self->title_count == 1 || i == 1)
1238 self->title_count = i;
1241 /* dont display the number for the first window */
1242 if (self->title_count > 1) {
1243 char *vdata, *ndata;
1244 ndata = g_strdup_printf(" - [%u]", self->title_count);
1245 vdata = g_strconcat(data, ndata, NULL);
1251 PROP_SETS(self->window, net_wm_visible_name, data);
1256 frame_adjust_title(self->frame);
1258 /* update the icon title */
1260 g_free(self->icon_title);
1264 if (!PROP_GETS(self->window, net_wm_icon_name, utf8, &data))
1265 /* try old x stuff */
1266 if (!PROP_GETS(self->window, wm_icon_name, locale, &data)) {
1267 data = g_strdup(self->title);
1271 /* append the title count, dont display the number for the first window */
1272 if (read_title && self->title_count > 1) {
1273 char *vdata, *ndata;
1274 ndata = g_strdup_printf(" - [%u]", self->title_count);
1275 vdata = g_strconcat(data, ndata, NULL);
1281 PROP_SETS(self->window, net_wm_visible_icon_name, data);
1283 self->icon_title = data;
1286 void client_update_class(ObClient *self)
1291 if (self->name) g_free(self->name);
1292 if (self->class) g_free(self->class);
1293 if (self->role) g_free(self->role);
1295 self->name = self->class = self->role = NULL;
1297 if (PROP_GETSS(self->window, wm_class, locale, &data)) {
1299 self->name = g_strdup(data[0]);
1301 self->class = g_strdup(data[1]);
1306 if (PROP_GETS(self->window, wm_window_role, locale, &s))
1307 self->role = g_strdup(s);
1309 if (self->name == NULL) self->name = g_strdup("");
1310 if (self->class == NULL) self->class = g_strdup("");
1311 if (self->role == NULL) self->role = g_strdup("");
1314 void client_update_strut(ObClient *self)
1319 if (!PROP_GETA32(self->window, net_wm_strut, cardinal, &data, &num)) {
1320 STRUT_SET(self->strut, 0, 0, 0, 0);
1323 STRUT_SET(self->strut, data[0], data[2], data[1], data[3]);
1325 STRUT_SET(self->strut, 0, 0, 0, 0);
1329 /* updating here is pointless while we're being mapped cuz we're not in
1330 the client list yet */
1332 screen_update_areas();
1335 void client_update_icons(ObClient *self)
1341 for (i = 0; i < self->nicons; ++i)
1342 g_free(self->icons[i].data);
1343 if (self->nicons > 0)
1344 g_free(self->icons);
1347 if (PROP_GETA32(self->window, net_wm_icon, cardinal, &data, &num)) {
1348 /* figure out how many valid icons are in here */
1350 while (num - i > 2) {
1354 if (i > num || w*h == 0) break;
1358 self->icons = g_new(ObClientIcon, self->nicons);
1360 /* store the icons */
1362 for (j = 0; j < self->nicons; ++j) {
1365 w = self->icons[j].width = data[i++];
1366 h = self->icons[j].height = data[i++];
1368 if (w*h == 0) continue;
1370 self->icons[j].data = g_new(RrPixel32, w * h);
1371 for (x = 0, y = 0, t = 0; t < w * h; ++t, ++x, ++i) {
1376 self->icons[j].data[t] =
1377 (((data[i] >> 24) & 0xff) << RrDefaultAlphaOffset) +
1378 (((data[i] >> 16) & 0xff) << RrDefaultRedOffset) +
1379 (((data[i] >> 8) & 0xff) << RrDefaultGreenOffset) +
1380 (((data[i] >> 0) & 0xff) << RrDefaultBlueOffset);
1386 } else if (PROP_GETA32(self->window, kwm_win_icon,
1387 kwm_win_icon, &data, &num)) {
1390 self->icons = g_new(ObClientIcon, self->nicons);
1391 xerror_set_ignore(TRUE);
1392 if (!RrPixmapToRGBA(ob_rr_inst,
1394 &self->icons[self->nicons-1].width,
1395 &self->icons[self->nicons-1].height,
1396 &self->icons[self->nicons-1].data)) {
1397 g_free(&self->icons[self->nicons-1]);
1400 xerror_set_ignore(FALSE);
1406 if ((hints = XGetWMHints(ob_display, self->window))) {
1407 if (hints->flags & IconPixmapHint) {
1409 self->icons = g_new(ObClientIcon, self->nicons);
1410 xerror_set_ignore(TRUE);
1411 if (!RrPixmapToRGBA(ob_rr_inst,
1413 (hints->flags & IconMaskHint ?
1414 hints->icon_mask : None),
1415 &self->icons[self->nicons-1].width,
1416 &self->icons[self->nicons-1].height,
1417 &self->icons[self->nicons-1].data)){
1418 g_free(&self->icons[self->nicons-1]);
1421 xerror_set_ignore(FALSE);
1428 frame_adjust_icon(self->frame);
1431 static void client_change_state(ObClient *self)
1434 guint32 netstate[10];
1437 state[0] = self->wmstate;
1439 PROP_SETA32(self->window, wm_state, wm_state, state, 2);
1443 netstate[num++] = prop_atoms.net_wm_state_modal;
1445 netstate[num++] = prop_atoms.net_wm_state_shaded;
1447 netstate[num++] = prop_atoms.net_wm_state_hidden;
1448 if (self->skip_taskbar)
1449 netstate[num++] = prop_atoms.net_wm_state_skip_taskbar;
1450 if (self->skip_pager)
1451 netstate[num++] = prop_atoms.net_wm_state_skip_pager;
1452 if (self->fullscreen)
1453 netstate[num++] = prop_atoms.net_wm_state_fullscreen;
1455 netstate[num++] = prop_atoms.net_wm_state_maximized_vert;
1457 netstate[num++] = prop_atoms.net_wm_state_maximized_horz;
1459 netstate[num++] = prop_atoms.net_wm_state_above;
1461 netstate[num++] = prop_atoms.net_wm_state_below;
1462 PROP_SETA32(self->window, net_wm_state, atom, netstate, num);
1464 client_calc_layer(self);
1467 frame_adjust_state(self->frame);
1470 ObClient *client_search_focus_tree(ObClient *self)
1475 for (it = self->transients; it != NULL; it = it->next) {
1476 if (client_focused(it->data)) return it->data;
1477 if ((ret = client_search_focus_tree(it->data))) return ret;
1482 ObClient *client_search_focus_tree_full(ObClient *self)
1484 if (self->transient_for) {
1485 if (self->transient_for != OB_TRAN_GROUP) {
1486 return client_search_focus_tree_full(self->transient_for);
1489 gboolean recursed = FALSE;
1491 for (it = self->group->members; it; it = it->next)
1492 if (!((ObClient*)it->data)->transient_for) {
1494 if ((c = client_search_focus_tree_full(it->data)))
1503 /* this function checks the whole tree, the client_search_focus_tree~
1504 does not, so we need to check this window */
1505 if (client_focused(self))
1507 return client_search_focus_tree(self);
1510 static ObStackingLayer calc_layer(ObClient *self)
1514 if (self->fullscreen) l = OB_STACKING_LAYER_FULLSCREEN;
1515 else if (self->type == OB_CLIENT_TYPE_DESKTOP)
1516 l = OB_STACKING_LAYER_DESKTOP;
1517 else if (self->type == OB_CLIENT_TYPE_DOCK) {
1518 if (!self->below) l = OB_STACKING_LAYER_TOP;
1519 else l = OB_STACKING_LAYER_NORMAL;
1521 else if (self->above) l = OB_STACKING_LAYER_ABOVE;
1522 else if (self->below) l = OB_STACKING_LAYER_BELOW;
1523 else l = OB_STACKING_LAYER_NORMAL;
1528 static void client_calc_layer_recursive(ObClient *self, ObClient *orig,
1529 ObStackingLayer l, gboolean raised)
1531 ObStackingLayer old, own;
1535 own = calc_layer(self);
1536 self->layer = l > own ? l : own;
1538 for (it = self->transients; it; it = it->next)
1539 client_calc_layer_recursive(it->data, orig,
1540 l, raised ? raised : l != old);
1542 if (!raised && l != old)
1543 if (orig->frame) { /* only restack if the original window is managed */
1544 /* XXX add_non_intrusive ever? */
1545 stacking_remove(CLIENT_AS_WINDOW(self));
1546 stacking_add(CLIENT_AS_WINDOW(self));
1550 void client_calc_layer(ObClient *self)
1557 /* transients take on the layer of their parents */
1558 self = client_search_top_transient(self);
1560 l = calc_layer(self);
1562 client_calc_layer_recursive(self, orig, l, FALSE);
1565 gboolean client_should_show(ObClient *self)
1567 if (self->iconic) return FALSE;
1568 else if (!(self->desktop == screen_desktop ||
1569 self->desktop == DESKTOP_ALL)) return FALSE;
1570 else if (client_normal(self) && screen_showing_desktop) return FALSE;
1575 static void client_showhide(ObClient *self)
1578 if (client_should_show(self))
1579 frame_show(self->frame);
1581 frame_hide(self->frame);
1584 gboolean client_normal(ObClient *self) {
1585 return ! (self->type == OB_CLIENT_TYPE_DESKTOP ||
1586 self->type == OB_CLIENT_TYPE_DOCK ||
1587 self->type == OB_CLIENT_TYPE_SPLASH);
1590 static void client_apply_startup_state(ObClient *self)
1592 /* these are in a carefully crafted order.. */
1595 self->iconic = FALSE;
1596 client_iconify(self, TRUE, FALSE);
1598 if (self->fullscreen) {
1599 self->fullscreen = FALSE;
1600 client_fullscreen(self, TRUE, FALSE);
1603 self->shaded = FALSE;
1604 client_shade(self, TRUE);
1607 dispatch_client(Event_Client_Urgent, self, self->urgent, 0);
1609 if (self->max_vert && self->max_horz) {
1610 self->max_vert = self->max_horz = FALSE;
1611 client_maximize(self, TRUE, 0, FALSE);
1612 } else if (self->max_vert) {
1613 self->max_vert = FALSE;
1614 client_maximize(self, TRUE, 2, FALSE);
1615 } else if (self->max_horz) {
1616 self->max_horz = FALSE;
1617 client_maximize(self, TRUE, 1, FALSE);
1620 /* nothing to do for the other states:
1629 void client_configure(ObClient *self, ObCorner anchor,
1630 int x, int y, int w, int h,
1631 gboolean user, gboolean final)
1633 gboolean moved = FALSE, resized = FALSE;
1635 /* gets the frame's position */
1636 frame_client_gravity(self->frame, &x, &y);
1638 /* these positions are frame positions, not client positions */
1640 /* set the size and position if fullscreen */
1641 if (self->fullscreen) {
1644 XF86VidModeModeLine mode;
1649 i = client_monitor(self);
1650 a = screen_physical_area_monitor(i);
1653 if (i == 0 && /* primary head */
1654 extensions_vidmode &&
1655 XF86VidModeGetViewPort(ob_display, ob_screen, &x, &y) &&
1656 /* get the mode last so the mode.privsize isnt freed incorrectly */
1657 XF86VidModeGetModeLine(ob_display, ob_screen, &dot, &mode)) {
1662 if (mode.privsize) XFree(mode.private);
1672 user = FALSE; /* ignore that increment etc shit when in fullscreen */
1676 a = screen_area_monitor(self->desktop, client_monitor(self));
1678 /* set the size and position if maximized */
1679 if (self->max_horz) {
1680 x = a->x - self->frame->size.left;
1683 if (self->max_vert) {
1685 h = a->height - self->frame->size.top - self->frame->size.bottom;
1689 /* gets the client's position */
1690 frame_frame_gravity(self->frame, &x, &y);
1692 /* these override the above states! if you cant move you can't move! */
1694 if (!(self->functions & OB_CLIENT_FUNC_MOVE)) {
1698 if (!(self->functions & OB_CLIENT_FUNC_RESIZE)) {
1699 w = self->area.width;
1700 h = self->area.height;
1704 if (!(w == self->area.width && h == self->area.height)) {
1705 int basew, baseh, minw, minh;
1707 /* base size is substituted with min size if not specified */
1708 if (self->base_size.width || self->base_size.height) {
1709 basew = self->base_size.width;
1710 baseh = self->base_size.height;
1712 basew = self->min_size.width;
1713 baseh = self->min_size.height;
1715 /* min size is substituted with base size if not specified */
1716 if (self->min_size.width || self->min_size.height) {
1717 minw = self->min_size.width;
1718 minh = self->min_size.height;
1720 minw = self->base_size.width;
1721 minh = self->base_size.height;
1725 /* for interactive resizing. have to move half an increment in each
1728 /* how far we are towards the next size inc */
1729 int mw = (w - basew) % self->size_inc.width;
1730 int mh = (h - baseh) % self->size_inc.height;
1732 int aw = self->size_inc.width / 2;
1733 int ah = self->size_inc.height / 2;
1734 /* don't let us move into a new size increment */
1735 if (mw + aw >= self->size_inc.width)
1736 aw = self->size_inc.width - mw - 1;
1737 if (mh + ah >= self->size_inc.height)
1738 ah = self->size_inc.height - mh - 1;
1742 /* if this is a user-requested resize, then check against min/max
1745 /* smaller than min size or bigger than max size? */
1746 if (w > self->max_size.width) w = self->max_size.width;
1747 if (w < minw) w = minw;
1748 if (h > self->max_size.height) h = self->max_size.height;
1749 if (h < minh) h = minh;
1755 /* keep to the increments */
1756 w /= self->size_inc.width;
1757 h /= self->size_inc.height;
1759 /* you cannot resize to nothing */
1763 /* store the logical size */
1764 SIZE_SET(self->logical_size, w, h);
1766 w *= self->size_inc.width;
1767 h *= self->size_inc.height;
1773 /* adjust the height to match the width for the aspect ratios.
1774 for this, min size is not substituted for base size ever. */
1775 w -= self->base_size.width;
1776 h -= self->base_size.height;
1778 if (self->min_ratio)
1779 if (h * self->min_ratio > w) h = (int)(w / self->min_ratio);
1780 if (self->max_ratio)
1781 if (h * self->max_ratio < w) h = (int)(w / self->max_ratio);
1783 w += self->base_size.width;
1784 h += self->base_size.height;
1789 case OB_CORNER_TOPLEFT:
1791 case OB_CORNER_TOPRIGHT:
1792 x -= w - self->area.width;
1794 case OB_CORNER_BOTTOMLEFT:
1795 y -= h - self->area.height;
1797 case OB_CORNER_BOTTOMRIGHT:
1798 x -= w - self->area.width;
1799 y -= h - self->area.height;
1803 moved = x != self->area.x || y != self->area.y;
1804 resized = w != self->area.width || h != self->area.height;
1806 RECT_SET(self->area, x, y, w, h);
1808 /* for app-requested resizes, always resize if 'resized' is true.
1809 for user-requested ones, only resize if final is true, or when
1810 resizing in opaque mode */
1811 if ((!user && resized) ||
1812 (user && (final || (resized && config_opaque_resize))))
1813 XResizeWindow(ob_display, self->window, w, h);
1815 /* move/resize the frame to match the request */
1817 if (self->decorations != self->frame->decorations)
1818 moved = resized = TRUE;
1820 if (moved || resized)
1821 frame_adjust_area(self->frame, moved, resized);
1823 /* If you send this and the client hasn't changed you end up with buggy
1824 clients (emacs) freaking out, cuz they send back a configure every
1825 time they receive this event, which resends them this event... etc.
1827 if ((!user && moved) || (user && final)) {
1829 event.type = ConfigureNotify;
1830 event.xconfigure.display = ob_display;
1831 event.xconfigure.event = self->window;
1832 event.xconfigure.window = self->window;
1834 /* root window real coords */
1835 event.xconfigure.x = self->frame->area.x + self->frame->size.left;
1836 event.xconfigure.y = self->frame->area.y + self->frame->size.top;
1838 event.xconfigure.width = w;
1839 event.xconfigure.height = h;
1840 event.xconfigure.border_width = 0;
1841 event.xconfigure.above = self->frame->plate;
1842 event.xconfigure.override_redirect = FALSE;
1843 XSendEvent(event.xconfigure.display, event.xconfigure.window,
1844 FALSE, StructureNotifyMask, &event);
1849 void client_fullscreen(ObClient *self, gboolean fs, gboolean savearea)
1853 if (!(self->functions & OB_CLIENT_FUNC_FULLSCREEN) || /* can't */
1854 self->fullscreen == fs) return; /* already done */
1856 self->fullscreen = fs;
1857 client_change_state(self); /* change the state hints on the client,
1858 and adjust out layer/stacking */
1862 guint32 dimensions[4];
1863 dimensions[0] = self->area.x;
1864 dimensions[1] = self->area.y;
1865 dimensions[2] = self->area.width;
1866 dimensions[3] = self->area.height;
1868 PROP_SETA32(self->window, openbox_premax, cardinal,
1872 /* these are not actually used cuz client_configure will set them
1873 as appropriate when the window is fullscreened */
1880 /* pick some fallbacks... */
1881 a = screen_area_monitor(self->desktop, 0);
1882 x = a->x + a->width / 4;
1883 y = a->y + a->height / 4;
1887 if (PROP_GETA32(self->window, openbox_premax, cardinal,
1888 (guint32**)&dimensions, &num)) {
1899 client_setup_decor_and_functions(self);
1901 client_configure(self, OB_CORNER_TOPLEFT, x, y, w, h, TRUE, TRUE);
1903 /* try focus us when we go into fullscreen mode */
1907 static void client_iconify_recursive(ObClient *self,
1908 gboolean iconic, gboolean curdesk)
1911 gboolean changed = FALSE;
1914 if (self->iconic != iconic) {
1915 g_message("%sconifying window: 0x%lx", (iconic ? "I" : "Uni"),
1918 self->iconic = iconic;
1921 if (self->functions & OB_CLIENT_FUNC_ICONIFY) {
1922 self->wmstate = IconicState;
1923 self->ignore_unmaps++;
1924 /* we unmap the client itself so that we can get MapRequest
1925 events, and because the ICCCM tells us to! */
1926 XUnmapWindow(ob_display, self->window);
1928 /* update the focus lists.. iconic windows go to the bottom of
1929 the list, put the new iconic window at the 'top of the
1931 focus_order_to_top(self);
1937 client_set_desktop(self, screen_desktop, FALSE);
1938 self->wmstate = self->shaded ? IconicState : NormalState;
1939 XMapWindow(ob_display, self->window);
1941 /* this puts it after the current focused window */
1942 focus_order_remove(self);
1943 focus_order_add_new(self);
1945 /* this is here cuz with the VIDMODE extension, the viewport can
1946 change while a fullscreen window is iconic, and when it
1947 uniconifies, it would be nice if it did so to the new position
1949 client_reconfigure(self);
1956 client_change_state(self);
1957 client_showhide(self);
1958 screen_update_areas();
1960 dispatch_client(iconic ? Event_Client_Unmapped : Event_Client_Mapped,
1964 /* iconify all transients */
1965 for (it = self->transients; it != NULL; it = it->next)
1966 if (it->data != self) client_iconify_recursive(it->data,
1970 void client_iconify(ObClient *self, gboolean iconic, gboolean curdesk)
1972 /* move up the transient chain as far as possible first */
1973 self = client_search_top_transient(self);
1975 client_iconify_recursive(client_search_top_transient(self),
1979 void client_maximize(ObClient *self, gboolean max, int dir, gboolean savearea)
1983 g_assert(dir == 0 || dir == 1 || dir == 2);
1984 if (!(self->functions & OB_CLIENT_FUNC_MAXIMIZE)) return; /* can't */
1986 /* check if already done */
1988 if (dir == 0 && self->max_horz && self->max_vert) return;
1989 if (dir == 1 && self->max_horz) return;
1990 if (dir == 2 && self->max_vert) return;
1992 if (dir == 0 && !self->max_horz && !self->max_vert) return;
1993 if (dir == 1 && !self->max_horz) return;
1994 if (dir == 2 && !self->max_vert) return;
1997 /* work with the frame's coords */
1998 x = self->frame->area.x;
1999 y = self->frame->area.y;
2000 w = self->area.width;
2001 h = self->area.height;
2005 gint32 dimensions[4];
2014 /* get the property off the window and use it for the dimensions
2015 we are already maxed on */
2016 if (PROP_GETA32(self->window, openbox_premax, cardinal,
2017 (guint32**)&readdim, &num)) {
2019 if (self->max_horz) {
2020 dimensions[0] = readdim[0];
2021 dimensions[2] = readdim[2];
2023 if (self->max_vert) {
2024 dimensions[1] = readdim[1];
2025 dimensions[3] = readdim[3];
2031 PROP_SETA32(self->window, openbox_premax, cardinal,
2032 (guint32*)dimensions, 4);
2039 /* pick some fallbacks... */
2040 a = screen_area_monitor(self->desktop, 0);
2041 if (dir == 0 || dir == 1) { /* horz */
2042 x = a->x + a->width / 4;
2045 if (dir == 0 || dir == 2) { /* vert */
2046 y = a->y + a->height / 4;
2050 if (PROP_GETA32(self->window, openbox_premax, cardinal,
2051 (guint32**)&dimensions, &num)) {
2053 if (dir == 0 || dir == 1) { /* horz */
2057 if (dir == 0 || dir == 2) { /* vert */
2066 if (dir == 0 || dir == 1) /* horz */
2067 self->max_horz = max;
2068 if (dir == 0 || dir == 2) /* vert */
2069 self->max_vert = max;
2071 if (!self->max_horz && !self->max_vert)
2072 PROP_ERASE(self->window, openbox_premax);
2074 client_change_state(self); /* change the state hints on the client */
2076 /* figure out where the client should be going */
2077 frame_frame_gravity(self->frame, &x, &y);
2078 client_configure(self, OB_CORNER_TOPLEFT, x, y, w, h, TRUE, TRUE);
2081 void client_shade(ObClient *self, gboolean shade)
2083 if ((!(self->functions & OB_CLIENT_FUNC_SHADE) &&
2084 shade) || /* can't shade */
2085 self->shaded == shade) return; /* already done */
2087 /* when we're iconic, don't change the wmstate */
2089 self->wmstate = shade ? IconicState : NormalState;
2090 self->shaded = shade;
2091 client_change_state(self);
2092 /* resize the frame to just the titlebar */
2093 frame_adjust_area(self->frame, FALSE, FALSE);
2096 void client_close(ObClient *self)
2100 if (!(self->functions & OB_CLIENT_FUNC_CLOSE)) return;
2103 XXX: itd be cool to do timeouts and shit here for killing the client's
2105 like... if the window is around after 5 seconds, then the close button
2106 turns a nice red, and if this function is called again, the client is
2110 ce.xclient.type = ClientMessage;
2111 ce.xclient.message_type = prop_atoms.wm_protocols;
2112 ce.xclient.display = ob_display;
2113 ce.xclient.window = self->window;
2114 ce.xclient.format = 32;
2115 ce.xclient.data.l[0] = prop_atoms.wm_delete_window;
2116 ce.xclient.data.l[1] = event_lasttime;
2117 ce.xclient.data.l[2] = 0l;
2118 ce.xclient.data.l[3] = 0l;
2119 ce.xclient.data.l[4] = 0l;
2120 XSendEvent(ob_display, self->window, FALSE, NoEventMask, &ce);
2123 void client_kill(ObClient *self)
2125 XKillClient(ob_display, self->window);
2128 void client_set_desktop_recursive(ObClient *self,
2129 guint target, gboolean donthide)
2134 if (target != self->desktop) {
2136 g_message("Setting desktop %u", target+1);
2138 g_assert(target < screen_num_desktops || target == DESKTOP_ALL);
2140 /* remove from the old desktop(s) */
2141 focus_order_remove(self);
2143 old = self->desktop;
2144 self->desktop = target;
2145 PROP_SET32(self->window, net_wm_desktop, cardinal, target);
2146 /* the frame can display the current desktop state */
2147 frame_adjust_state(self->frame);
2148 /* 'move' the window to the new desktop */
2150 client_showhide(self);
2151 /* raise if it was not already on the desktop */
2152 if (old != DESKTOP_ALL)
2153 stacking_raise(CLIENT_AS_WINDOW(self));
2154 screen_update_areas();
2156 /* add to the new desktop(s) */
2157 if (config_focus_new)
2158 focus_order_to_top(self);
2160 focus_order_to_bottom(self);
2162 dispatch_client(Event_Client_Desktop, self, target, old);
2165 /* move all transients */
2166 for (it = self->transients; it != NULL; it = it->next)
2167 if (it->data != self) client_set_desktop_recursive(it->data,
2171 void client_set_desktop(ObClient *self, guint target, gboolean donthide)
2173 client_set_desktop_recursive(client_search_top_transient(self),
2177 ObClient *client_search_modal_child(ObClient *self)
2182 for (it = self->transients; it != NULL; it = it->next) {
2183 ObClient *c = it->data;
2184 if ((ret = client_search_modal_child(c))) return ret;
2185 if (c->modal) return c;
2190 gboolean client_validate(ObClient *self)
2194 XSync(ob_display, FALSE); /* get all events on the server */
2196 if (XCheckTypedWindowEvent(ob_display, self->window, DestroyNotify, &e) ||
2197 XCheckTypedWindowEvent(ob_display, self->window, UnmapNotify, &e)) {
2198 XPutBackEvent(ob_display, &e);
2205 void client_set_wm_state(ObClient *self, long state)
2207 if (state == self->wmstate) return; /* no change */
2211 client_iconify(self, TRUE, TRUE);
2214 client_iconify(self, FALSE, TRUE);
2219 void client_set_state(ObClient *self, Atom action, long data1, long data2)
2221 gboolean shaded = self->shaded;
2222 gboolean fullscreen = self->fullscreen;
2223 gboolean max_horz = self->max_horz;
2224 gboolean max_vert = self->max_vert;
2227 if (!(action == prop_atoms.net_wm_state_add ||
2228 action == prop_atoms.net_wm_state_remove ||
2229 action == prop_atoms.net_wm_state_toggle))
2230 /* an invalid action was passed to the client message, ignore it */
2233 for (i = 0; i < 2; ++i) {
2234 Atom state = i == 0 ? data1 : data2;
2236 if (!state) continue;
2238 /* if toggling, then pick whether we're adding or removing */
2239 if (action == prop_atoms.net_wm_state_toggle) {
2240 if (state == prop_atoms.net_wm_state_modal)
2241 action = self->modal ? prop_atoms.net_wm_state_remove :
2242 prop_atoms.net_wm_state_add;
2243 else if (state == prop_atoms.net_wm_state_maximized_vert)
2244 action = self->max_vert ? prop_atoms.net_wm_state_remove :
2245 prop_atoms.net_wm_state_add;
2246 else if (state == prop_atoms.net_wm_state_maximized_horz)
2247 action = self->max_horz ? prop_atoms.net_wm_state_remove :
2248 prop_atoms.net_wm_state_add;
2249 else if (state == prop_atoms.net_wm_state_shaded)
2250 action = self->shaded ? prop_atoms.net_wm_state_remove :
2251 prop_atoms.net_wm_state_add;
2252 else if (state == prop_atoms.net_wm_state_skip_taskbar)
2253 action = self->skip_taskbar ?
2254 prop_atoms.net_wm_state_remove :
2255 prop_atoms.net_wm_state_add;
2256 else if (state == prop_atoms.net_wm_state_skip_pager)
2257 action = self->skip_pager ?
2258 prop_atoms.net_wm_state_remove :
2259 prop_atoms.net_wm_state_add;
2260 else if (state == prop_atoms.net_wm_state_fullscreen)
2261 action = self->fullscreen ?
2262 prop_atoms.net_wm_state_remove :
2263 prop_atoms.net_wm_state_add;
2264 else if (state == prop_atoms.net_wm_state_above)
2265 action = self->above ? prop_atoms.net_wm_state_remove :
2266 prop_atoms.net_wm_state_add;
2267 else if (state == prop_atoms.net_wm_state_below)
2268 action = self->below ? prop_atoms.net_wm_state_remove :
2269 prop_atoms.net_wm_state_add;
2272 if (action == prop_atoms.net_wm_state_add) {
2273 if (state == prop_atoms.net_wm_state_modal) {
2274 /* XXX raise here or something? */
2276 } else if (state == prop_atoms.net_wm_state_maximized_vert) {
2278 } else if (state == prop_atoms.net_wm_state_maximized_horz) {
2280 } else if (state == prop_atoms.net_wm_state_shaded) {
2282 } else if (state == prop_atoms.net_wm_state_skip_taskbar) {
2283 self->skip_taskbar = TRUE;
2284 } else if (state == prop_atoms.net_wm_state_skip_pager) {
2285 self->skip_pager = TRUE;
2286 } else if (state == prop_atoms.net_wm_state_fullscreen) {
2288 } else if (state == prop_atoms.net_wm_state_above) {
2290 } else if (state == prop_atoms.net_wm_state_below) {
2294 } else { /* action == prop_atoms.net_wm_state_remove */
2295 if (state == prop_atoms.net_wm_state_modal) {
2296 self->modal = FALSE;
2297 } else if (state == prop_atoms.net_wm_state_maximized_vert) {
2299 } else if (state == prop_atoms.net_wm_state_maximized_horz) {
2301 } else if (state == prop_atoms.net_wm_state_shaded) {
2303 } else if (state == prop_atoms.net_wm_state_skip_taskbar) {
2304 self->skip_taskbar = FALSE;
2305 } else if (state == prop_atoms.net_wm_state_skip_pager) {
2306 self->skip_pager = FALSE;
2307 } else if (state == prop_atoms.net_wm_state_fullscreen) {
2309 } else if (state == prop_atoms.net_wm_state_above) {
2310 self->above = FALSE;
2311 } else if (state == prop_atoms.net_wm_state_below) {
2312 self->below = FALSE;
2316 if (max_horz != self->max_horz || max_vert != self->max_vert) {
2317 if (max_horz != self->max_horz && max_vert != self->max_vert) {
2319 if (max_horz == max_vert) { /* both going the same way */
2320 client_maximize(self, max_horz, 0, TRUE);
2322 client_maximize(self, max_horz, 1, TRUE);
2323 client_maximize(self, max_vert, 2, TRUE);
2327 if (max_horz != self->max_horz)
2328 client_maximize(self, max_horz, 1, TRUE);
2330 client_maximize(self, max_vert, 2, TRUE);
2333 /* change fullscreen state before shading, as it will affect if the window
2335 if (fullscreen != self->fullscreen)
2336 client_fullscreen(self, fullscreen, TRUE);
2337 if (shaded != self->shaded)
2338 client_shade(self, shaded);
2339 client_calc_layer(self);
2340 client_change_state(self); /* change the hint to reflect these changes */
2343 ObClient *client_focus_target(ObClient *self)
2347 /* if we have a modal child, then focus it, not us */
2348 child = client_search_modal_child(self);
2349 if (child) return child;
2353 gboolean client_can_focus(ObClient *self)
2357 /* choose the correct target */
2358 self = client_focus_target(self);
2360 if (!self->frame->visible)
2363 if (!((self->can_focus || self->focus_notify) &&
2364 (self->desktop == screen_desktop ||
2365 self->desktop == DESKTOP_ALL) &&
2369 /* do a check to see if the window has already been unmapped or destroyed
2370 do this intelligently while watching out for unmaps we've generated
2371 (ignore_unmaps > 0) */
2372 if (XCheckTypedWindowEvent(ob_display, self->window,
2373 DestroyNotify, &ev)) {
2374 XPutBackEvent(ob_display, &ev);
2377 while (XCheckTypedWindowEvent(ob_display, self->window,
2378 UnmapNotify, &ev)) {
2379 if (self->ignore_unmaps) {
2380 self->ignore_unmaps--;
2382 XPutBackEvent(ob_display, &ev);
2390 gboolean client_focus(ObClient *self)
2392 /* choose the correct target */
2393 self = client_focus_target(self);
2395 if (!client_can_focus(self)) {
2396 if (!self->frame->visible) {
2397 /* update the focus lists */
2398 focus_order_to_top(self);
2403 if (self->can_focus)
2404 /* RevertToPointerRoot causes much more headache than RevertToNone, so
2405 I choose to use it always, hopefully to find errors quicker, if any
2406 are left. (I hate X. I hate focus events.) */
2407 XSetInputFocus(ob_display, self->window, RevertToPointerRoot,
2410 if (self->focus_notify) {
2412 ce.xclient.type = ClientMessage;
2413 ce.xclient.message_type = prop_atoms.wm_protocols;
2414 ce.xclient.display = ob_display;
2415 ce.xclient.window = self->window;
2416 ce.xclient.format = 32;
2417 ce.xclient.data.l[0] = prop_atoms.wm_take_focus;
2418 ce.xclient.data.l[1] = event_lasttime;
2419 ce.xclient.data.l[2] = 0l;
2420 ce.xclient.data.l[3] = 0l;
2421 ce.xclient.data.l[4] = 0l;
2422 XSendEvent(ob_display, self->window, FALSE, NoEventMask, &ce);
2426 g_message("%sively focusing %lx at %d", (self->can_focus ? "act" : "pass"),
2431 /* Cause the FocusIn to come back to us. Important for desktop switches,
2432 since otherwise we'll have no FocusIn on the queue and send it off to
2433 the focus_backup. */
2434 XSync(ob_display, FALSE);
2438 void client_unfocus(ObClient *self)
2440 g_assert(focus_client == self);
2442 g_message("client_unfocus for %lx", self->window);
2444 focus_fallback(OB_FOCUS_FALLBACK_UNFOCUSING);
2447 void client_activate(ObClient *self)
2449 if (client_normal(self) && screen_showing_desktop)
2450 screen_show_desktop(FALSE);
2452 client_iconify(self, FALSE, FALSE);
2453 if (self->desktop != DESKTOP_ALL &&
2454 self->desktop != screen_desktop)
2455 screen_set_desktop(self->desktop);
2456 else if (!self->frame->visible)
2457 /* if its not visible for other reasons, then don't mess
2461 client_shade(self, FALSE);
2463 stacking_raise(CLIENT_AS_WINDOW(self));
2466 gboolean client_focused(ObClient *self)
2468 return self == focus_client;
2471 ObClientIcon *client_icon(ObClient *self, int w, int h)
2474 /* si is the smallest image >= req */
2475 /* li is the largest image < req */
2476 unsigned long size, smallest = 0xffffffff, largest = 0, si = 0, li = 0;
2478 if (!self->nicons) return NULL;
2480 for (i = 0; i < self->nicons; ++i) {
2481 size = self->icons[i].width * self->icons[i].height;
2482 if (size < smallest && size >= (unsigned)(w * h)) {
2486 if (size > largest && size <= (unsigned)(w * h)) {
2491 if (largest == 0) /* didnt find one smaller than the requested size */
2492 return &self->icons[si];
2493 return &self->icons[li];
2496 /* this be mostly ripped from fvwm */
2497 ObClient *client_find_directional(ObClient *c, ObDirection dir)
2499 int my_cx, my_cy, his_cx, his_cy;
2502 int score, best_score;
2503 ObClient *best_client, *cur;
2509 /* first, find the centre coords of the currently focused window */
2510 my_cx = c->frame->area.x + c->frame->area.width / 2;
2511 my_cy = c->frame->area.y + c->frame->area.height / 2;
2516 for(it = g_list_first(client_list); it; it = it->next) {
2519 /* the currently selected window isn't interesting */
2522 if (!client_normal(cur))
2524 if(c->desktop != cur->desktop && cur->desktop != DESKTOP_ALL)
2528 if(client_focus_target(cur) == cur &&
2529 !(cur->can_focus || cur->focus_notify))
2532 /* find the centre coords of this window, from the
2533 * currently focused window's point of view */
2534 his_cx = (cur->frame->area.x - my_cx)
2535 + cur->frame->area.width / 2;
2536 his_cy = (cur->frame->area.y - my_cy)
2537 + cur->frame->area.height / 2;
2541 /* Rotate the diagonals 45 degrees counterclockwise.
2542 * To do this, multiply the matrix /+h +h\ with the
2543 * vector (x y). \-h +h/
2544 * h = sqrt(0.5). We can set h := 1 since absolute
2545 * distance doesn't matter here. */
2546 tx = his_cx + his_cy;
2547 his_cy = -his_cx + his_cy;
2552 case OB_DIRECTION_NORTH:
2553 case OB_DIRECTION_SOUTH:
2554 case OB_DIRECTION_NORTHEAST:
2555 case OB_DIRECTION_SOUTHWEST:
2556 offset = (his_cx < 0) ? -his_cx : his_cx;
2557 distance = ((dir == OB_DIRECTION_NORTH ||
2558 dir == OB_DIRECTION_NORTHEAST) ?
2561 case OB_DIRECTION_EAST:
2562 case OB_DIRECTION_WEST:
2563 case OB_DIRECTION_SOUTHEAST:
2564 case OB_DIRECTION_NORTHWEST:
2565 offset = (his_cy < 0) ? -his_cy : his_cy;
2566 distance = ((dir == OB_DIRECTION_WEST ||
2567 dir == OB_DIRECTION_NORTHWEST) ?
2572 /* the target must be in the requested direction */
2576 /* Calculate score for this window. The smaller the better. */
2577 score = distance + offset;
2579 /* windows more than 45 degrees off the direction are
2580 * heavily penalized and will only be chosen if nothing
2581 * else within a million pixels */
2582 if(offset > distance)
2585 if(best_score == -1 || score < best_score)
2593 void client_set_layer(ObClient *self, int layer)
2597 self->above = FALSE;
2598 } else if (layer == 0) {
2599 self->below = self->above = FALSE;
2601 self->below = FALSE;
2604 client_calc_layer(self);
2605 client_change_state(self); /* reflect this in the state hints */
2608 guint client_monitor(ObClient *self)
2612 for (i = 0; i < screen_num_monitors; ++i) {
2613 Rect *area = screen_physical_area_monitor(i);
2614 if (RECT_INTERSECTS_RECT(*area, self->frame->area))
2617 if (i == screen_num_monitors) i = 0;
2618 g_assert(i < screen_num_monitors);
2622 ObClient *client_search_top_transient(ObClient *self)
2624 /* move up the transient chain as far as possible */
2625 if (self->transient_for) {
2626 if (self->transient_for != OB_TRAN_GROUP) {
2627 return client_search_top_transient(self->transient_for);
2631 for (it = self->group->members; it; it = it->next) {
2632 ObClient *c = it->data;
2634 /* checking transient_for prevents infinate loops! */
2635 if (c != self && !c->transient_for)