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, net_wm_desktop);
429 PROP_ERASE(self->window, 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 if (size.flags & (PPosition|USPosition)) {
897 /* this is my MOZILLA BITCHSLAP. oh ya it fucking feels good.
898 Java can suck it too. */
900 /* dont let windows map above/left into the strut unless they
901 are bigger than the available area */
902 a = screen_area(self->desktop);
903 if (self->area.width <= a->width && self->area.x < a->x)
905 if (self->area.height <= a->height && self->area.y < a->y)
908 self->positioned = TRUE;
911 if (size.flags & PWinGravity) {
912 self->gravity = size.win_gravity;
914 /* if the client has a frame, i.e. has already been mapped and
915 is changing its gravity */
916 if (self->frame && self->gravity != oldgravity) {
917 /* move our idea of the client's position based on its new
919 self->area.x = self->frame->area.x;
920 self->area.y = self->frame->area.y;
921 frame_frame_gravity(self->frame, &self->area.x, &self->area.y);
925 if (size.flags & PAspect) {
926 if (size.min_aspect.y)
927 self->min_ratio = (float)size.min_aspect.x / size.min_aspect.y;
928 if (size.max_aspect.y)
929 self->max_ratio = (float)size.max_aspect.x / size.max_aspect.y;
932 if (size.flags & PMinSize)
933 SIZE_SET(self->min_size, size.min_width, size.min_height);
935 if (size.flags & PMaxSize)
936 SIZE_SET(self->max_size, size.max_width, size.max_height);
938 if (size.flags & PBaseSize)
939 SIZE_SET(self->base_size, size.base_width, size.base_height);
941 if (size.flags & PResizeInc)
942 SIZE_SET(self->size_inc, size.width_inc, size.height_inc);
946 void client_setup_decor_and_functions(ObClient *self)
948 /* start with everything (cept fullscreen) */
949 self->decorations = (OB_FRAME_DECOR_TITLEBAR |
950 OB_FRAME_DECOR_HANDLE |
951 OB_FRAME_DECOR_GRIPS |
952 OB_FRAME_DECOR_BORDER |
953 OB_FRAME_DECOR_ICON |
954 OB_FRAME_DECOR_ALLDESKTOPS |
955 OB_FRAME_DECOR_ICONIFY |
956 OB_FRAME_DECOR_MAXIMIZE |
957 OB_FRAME_DECOR_SHADE);
958 self->functions = (OB_CLIENT_FUNC_RESIZE |
959 OB_CLIENT_FUNC_MOVE |
960 OB_CLIENT_FUNC_ICONIFY |
961 OB_CLIENT_FUNC_MAXIMIZE |
962 OB_CLIENT_FUNC_SHADE);
963 if (self->delete_window) {
964 self->functions |= OB_CLIENT_FUNC_CLOSE;
965 self->decorations |= OB_FRAME_DECOR_CLOSE;
968 if (!(self->min_size.width < self->max_size.width ||
969 self->min_size.height < self->max_size.height))
970 self->functions &= ~OB_CLIENT_FUNC_RESIZE;
972 switch (self->type) {
973 case OB_CLIENT_TYPE_NORMAL:
974 /* normal windows retain all of the possible decorations and
975 functionality, and are the only windows that you can fullscreen */
976 self->functions |= OB_CLIENT_FUNC_FULLSCREEN;
979 case OB_CLIENT_TYPE_DIALOG:
980 case OB_CLIENT_TYPE_UTILITY:
981 /* these windows cannot be maximized */
982 self->functions &= ~OB_CLIENT_FUNC_MAXIMIZE;
985 case OB_CLIENT_TYPE_MENU:
986 case OB_CLIENT_TYPE_TOOLBAR:
987 /* these windows get less functionality */
988 self->functions &= ~(OB_CLIENT_FUNC_ICONIFY | OB_CLIENT_FUNC_RESIZE);
991 case OB_CLIENT_TYPE_DESKTOP:
992 case OB_CLIENT_TYPE_DOCK:
993 case OB_CLIENT_TYPE_SPLASH:
994 /* none of these windows are manipulated by the window manager */
995 self->decorations = 0;
1000 /* Mwm Hints are applied subtractively to what has already been chosen for
1001 decor and functionality */
1002 if (self->mwmhints.flags & OB_MWM_FLAG_DECORATIONS) {
1003 if (! (self->mwmhints.decorations & OB_MWM_DECOR_ALL)) {
1004 if (! ((self->mwmhints.decorations & OB_MWM_DECOR_HANDLE) ||
1005 (self->mwmhints.decorations & OB_MWM_DECOR_TITLE)))
1006 /* if the mwm hints request no handle or title, then all
1007 decorations are disabled */
1008 self->decorations = 0;
1012 if (self->mwmhints.flags & OB_MWM_FLAG_FUNCTIONS) {
1013 if (! (self->mwmhints.functions & OB_MWM_FUNC_ALL)) {
1014 if (! (self->mwmhints.functions & OB_MWM_FUNC_RESIZE))
1015 self->functions &= ~OB_CLIENT_FUNC_RESIZE;
1016 if (! (self->mwmhints.functions & OB_MWM_FUNC_MOVE))
1017 self->functions &= ~OB_CLIENT_FUNC_MOVE;
1018 /* dont let mwm hints kill any buttons
1019 if (! (self->mwmhints.functions & OB_MWM_FUNC_ICONIFY))
1020 self->functions &= ~OB_CLIENT_FUNC_ICONIFY;
1021 if (! (self->mwmhints.functions & OB_MWM_FUNC_MAXIMIZE))
1022 self->functions &= ~OB_CLIENT_FUNC_MAXIMIZE;
1024 /* dont let mwm hints kill the close button
1025 if (! (self->mwmhints.functions & MwmFunc_Close))
1026 self->functions &= ~OB_CLIENT_FUNC_CLOSE; */
1030 if (!(self->functions & OB_CLIENT_FUNC_SHADE))
1031 self->decorations &= ~OB_FRAME_DECOR_SHADE;
1032 if (!(self->functions & OB_CLIENT_FUNC_ICONIFY))
1033 self->decorations &= ~OB_FRAME_DECOR_ICONIFY;
1034 if (!(self->functions & OB_CLIENT_FUNC_RESIZE))
1035 self->decorations &= ~OB_FRAME_DECOR_GRIPS;
1037 /* can't maximize without moving/resizing */
1038 if (!((self->functions & OB_CLIENT_FUNC_MAXIMIZE) &&
1039 (self->functions & OB_CLIENT_FUNC_MOVE) &&
1040 (self->functions & OB_CLIENT_FUNC_RESIZE))) {
1041 self->functions &= ~OB_CLIENT_FUNC_MAXIMIZE;
1042 self->decorations &= ~OB_FRAME_DECOR_MAXIMIZE;
1045 /* finally, the user can have requested no decorations, which overrides
1047 if (!self->decorate)
1048 self->decorations = 0;
1050 /* if we don't have a titlebar, then we cannot shade! */
1051 if (!(self->decorations & OB_FRAME_DECOR_TITLEBAR))
1052 self->functions &= ~OB_CLIENT_FUNC_SHADE;
1054 /* now we need to check against rules for the client's current state */
1055 if (self->fullscreen) {
1056 self->functions &= (OB_CLIENT_FUNC_CLOSE |
1057 OB_CLIENT_FUNC_FULLSCREEN |
1058 OB_CLIENT_FUNC_ICONIFY);
1059 self->decorations = 0;
1062 client_change_allowed_actions(self);
1065 /* this makes sure that these windows appear on all desktops */
1066 if (self->type == OB_CLIENT_TYPE_DESKTOP &&
1067 self->desktop != DESKTOP_ALL)
1068 client_set_desktop(self, DESKTOP_ALL, FALSE);
1070 /* adjust the client's decorations, etc. */
1071 client_reconfigure(self);
1073 /* this makes sure that these windows appear on all desktops */
1074 if (self->type == OB_CLIENT_TYPE_DESKTOP &&
1075 self->desktop != DESKTOP_ALL)
1077 self->desktop = DESKTOP_ALL;
1082 static void client_change_allowed_actions(ObClient *self)
1087 /* desktop windows are kept on all desktops */
1088 if (self->type != OB_CLIENT_TYPE_DESKTOP)
1089 actions[num++] = prop_atoms.net_wm_action_change_desktop;
1091 if (self->functions & OB_CLIENT_FUNC_SHADE)
1092 actions[num++] = prop_atoms.net_wm_action_shade;
1093 if (self->functions & OB_CLIENT_FUNC_CLOSE)
1094 actions[num++] = prop_atoms.net_wm_action_close;
1095 if (self->functions & OB_CLIENT_FUNC_MOVE)
1096 actions[num++] = prop_atoms.net_wm_action_move;
1097 if (self->functions & OB_CLIENT_FUNC_ICONIFY)
1098 actions[num++] = prop_atoms.net_wm_action_minimize;
1099 if (self->functions & OB_CLIENT_FUNC_RESIZE)
1100 actions[num++] = prop_atoms.net_wm_action_resize;
1101 if (self->functions & OB_CLIENT_FUNC_FULLSCREEN)
1102 actions[num++] = prop_atoms.net_wm_action_fullscreen;
1103 if (self->functions & OB_CLIENT_FUNC_MAXIMIZE) {
1104 actions[num++] = prop_atoms.net_wm_action_maximize_horz;
1105 actions[num++] = prop_atoms.net_wm_action_maximize_vert;
1108 PROP_SETA32(self->window, net_wm_allowed_actions, atom, actions, num);
1110 /* make sure the window isn't breaking any rules now */
1112 if (!(self->functions & OB_CLIENT_FUNC_SHADE) && self->shaded) {
1113 if (self->frame) client_shade(self, FALSE);
1114 else self->shaded = FALSE;
1116 if (!(self->functions & OB_CLIENT_FUNC_ICONIFY) && self->iconic) {
1117 if (self->frame) client_iconify(self, FALSE, TRUE);
1118 else self->iconic = FALSE;
1120 if (!(self->functions & OB_CLIENT_FUNC_FULLSCREEN) && self->fullscreen) {
1121 if (self->frame) client_fullscreen(self, FALSE, TRUE);
1122 else self->fullscreen = FALSE;
1124 if (!(self->functions & OB_CLIENT_FUNC_MAXIMIZE) && (self->max_horz ||
1126 if (self->frame) client_maximize(self, FALSE, 0, TRUE);
1127 else self->max_vert = self->max_horz = FALSE;
1131 void client_reconfigure(ObClient *self)
1133 /* by making this pass FALSE for user, we avoid the emacs event storm where
1134 every configurenotify causes an update in its normal hints, i think this
1135 is generally what we want anyways... */
1136 client_configure(self, OB_CORNER_TOPLEFT, self->area.x, self->area.y,
1137 self->area.width, self->area.height, FALSE, TRUE);
1140 void client_update_wmhints(ObClient *self)
1143 gboolean ur = FALSE;
1146 /* assume a window takes input if it doesnt specify */
1147 self->can_focus = TRUE;
1149 if ((hints = XGetWMHints(ob_display, self->window)) != NULL) {
1150 if (hints->flags & InputHint)
1151 self->can_focus = hints->input;
1153 /* only do this when first managing the window *AND* when we aren't
1155 if (ob_state() != OB_STATE_STARTING && self->frame == NULL)
1156 if (hints->flags & StateHint)
1157 self->iconic = hints->initial_state == IconicState;
1159 if (hints->flags & XUrgencyHint)
1162 if (!(hints->flags & WindowGroupHint))
1163 hints->window_group = None;
1165 /* did the group state change? */
1166 if (hints->window_group !=
1167 (self->group ? self->group->leader : None)) {
1168 /* remove from the old group if there was one */
1169 if (self->group != NULL) {
1170 /* remove transients of the group */
1171 for (it = self->group->members; it; it = it->next)
1172 self->transients = g_slist_remove(self->transients,
1174 group_remove(self->group, self);
1177 if (hints->window_group != None) {
1178 self->group = group_add(hints->window_group, self);
1180 /* i can only have transients from the group if i am not
1182 if (!self->transient_for) {
1183 /* add other transients of the group that are already
1185 for (it = self->group->members; it; it = it->next) {
1186 ObClient *c = it->data;
1187 if (c != self && c->transient_for == OB_TRAN_GROUP)
1189 g_slist_append(self->transients, c);
1194 /* the WM_HINTS can contain an icon */
1195 client_update_icons(self);
1197 /* because the self->transient flag wont change from this call,
1198 we don't need to update the window's type and such, only its
1199 transient_for, and the transients lists of other windows in
1200 the group may be affected */
1201 client_update_transient_for(self);
1207 if (ur != self->urgent) {
1209 ob_debug("Urgent Hint for 0x%lx: %s\n", self->window,
1211 /* fire the urgent callback if we're mapped, otherwise, wait until
1212 after we're mapped */
1214 dispatch_client(Event_Client_Urgent, self, self->urgent, 0);
1218 void client_update_title(ObClient *self)
1224 gboolean read_title;
1226 g_free(self->title);
1229 if (!PROP_GETS(self->window, net_wm_name, utf8, &data))
1230 /* try old x stuff */
1231 if (!PROP_GETS(self->window, wm_name, locale, &data))
1232 data = g_strdup("Unnamed Window");
1234 /* look for duplicates and append a number */
1236 for (it = client_list; it; it = it->next)
1237 if (it->data != self) {
1238 ObClient *c = it->data;
1239 if (0 == strncmp(c->title, data, strlen(data)))
1240 nums |= 1 << c->title_count;
1242 /* find first free number */
1243 for (i = 1; i <= 32; ++i)
1244 if (!(nums & (1 << i))) {
1245 if (self->title_count == 1 || i == 1)
1246 self->title_count = i;
1249 /* dont display the number for the first window */
1250 if (self->title_count > 1) {
1251 char *vdata, *ndata;
1252 ndata = g_strdup_printf(" - [%u]", self->title_count);
1253 vdata = g_strconcat(data, ndata, NULL);
1259 PROP_SETS(self->window, net_wm_visible_name, data);
1264 frame_adjust_title(self->frame);
1266 /* update the icon title */
1268 g_free(self->icon_title);
1272 if (!PROP_GETS(self->window, net_wm_icon_name, utf8, &data))
1273 /* try old x stuff */
1274 if (!PROP_GETS(self->window, wm_icon_name, locale, &data)) {
1275 data = g_strdup(self->title);
1279 /* append the title count, dont display the number for the first window */
1280 if (read_title && self->title_count > 1) {
1281 char *vdata, *ndata;
1282 ndata = g_strdup_printf(" - [%u]", self->title_count);
1283 vdata = g_strconcat(data, ndata, NULL);
1289 PROP_SETS(self->window, net_wm_visible_icon_name, data);
1291 self->icon_title = data;
1294 void client_update_class(ObClient *self)
1299 if (self->name) g_free(self->name);
1300 if (self->class) g_free(self->class);
1301 if (self->role) g_free(self->role);
1303 self->name = self->class = self->role = NULL;
1305 if (PROP_GETSS(self->window, wm_class, locale, &data)) {
1307 self->name = g_strdup(data[0]);
1309 self->class = g_strdup(data[1]);
1314 if (PROP_GETS(self->window, wm_window_role, locale, &s))
1315 self->role = g_strdup(s);
1317 if (self->name == NULL) self->name = g_strdup("");
1318 if (self->class == NULL) self->class = g_strdup("");
1319 if (self->role == NULL) self->role = g_strdup("");
1322 void client_update_strut(ObClient *self)
1327 if (!PROP_GETA32(self->window, net_wm_strut, cardinal, &data, &num)) {
1328 STRUT_SET(self->strut, 0, 0, 0, 0);
1331 STRUT_SET(self->strut, data[0], data[2], data[1], data[3]);
1333 STRUT_SET(self->strut, 0, 0, 0, 0);
1337 /* updating here is pointless while we're being mapped cuz we're not in
1338 the client list yet */
1340 screen_update_areas();
1343 void client_update_icons(ObClient *self)
1349 for (i = 0; i < self->nicons; ++i)
1350 g_free(self->icons[i].data);
1351 if (self->nicons > 0)
1352 g_free(self->icons);
1355 if (PROP_GETA32(self->window, net_wm_icon, cardinal, &data, &num)) {
1356 /* figure out how many valid icons are in here */
1358 while (num - i > 2) {
1362 if (i > num || w*h == 0) break;
1366 self->icons = g_new(ObClientIcon, self->nicons);
1368 /* store the icons */
1370 for (j = 0; j < self->nicons; ++j) {
1373 w = self->icons[j].width = data[i++];
1374 h = self->icons[j].height = data[i++];
1376 if (w*h == 0) continue;
1378 self->icons[j].data = g_new(RrPixel32, w * h);
1379 for (x = 0, y = 0, t = 0; t < w * h; ++t, ++x, ++i) {
1384 self->icons[j].data[t] =
1385 (((data[i] >> 24) & 0xff) << RrDefaultAlphaOffset) +
1386 (((data[i] >> 16) & 0xff) << RrDefaultRedOffset) +
1387 (((data[i] >> 8) & 0xff) << RrDefaultGreenOffset) +
1388 (((data[i] >> 0) & 0xff) << RrDefaultBlueOffset);
1394 } else if (PROP_GETA32(self->window, kwm_win_icon,
1395 kwm_win_icon, &data, &num)) {
1398 self->icons = g_new(ObClientIcon, self->nicons);
1399 xerror_set_ignore(TRUE);
1400 if (!RrPixmapToRGBA(ob_rr_inst,
1402 &self->icons[self->nicons-1].width,
1403 &self->icons[self->nicons-1].height,
1404 &self->icons[self->nicons-1].data)) {
1405 g_free(&self->icons[self->nicons-1]);
1408 xerror_set_ignore(FALSE);
1414 if ((hints = XGetWMHints(ob_display, self->window))) {
1415 if (hints->flags & IconPixmapHint) {
1417 self->icons = g_new(ObClientIcon, self->nicons);
1418 xerror_set_ignore(TRUE);
1419 if (!RrPixmapToRGBA(ob_rr_inst,
1421 (hints->flags & IconMaskHint ?
1422 hints->icon_mask : None),
1423 &self->icons[self->nicons-1].width,
1424 &self->icons[self->nicons-1].height,
1425 &self->icons[self->nicons-1].data)){
1426 g_free(&self->icons[self->nicons-1]);
1429 xerror_set_ignore(FALSE);
1436 frame_adjust_icon(self->frame);
1439 static void client_change_state(ObClient *self)
1442 guint32 netstate[10];
1445 state[0] = self->wmstate;
1447 PROP_SETA32(self->window, wm_state, wm_state, state, 2);
1451 netstate[num++] = prop_atoms.net_wm_state_modal;
1453 netstate[num++] = prop_atoms.net_wm_state_shaded;
1455 netstate[num++] = prop_atoms.net_wm_state_hidden;
1456 if (self->skip_taskbar)
1457 netstate[num++] = prop_atoms.net_wm_state_skip_taskbar;
1458 if (self->skip_pager)
1459 netstate[num++] = prop_atoms.net_wm_state_skip_pager;
1460 if (self->fullscreen)
1461 netstate[num++] = prop_atoms.net_wm_state_fullscreen;
1463 netstate[num++] = prop_atoms.net_wm_state_maximized_vert;
1465 netstate[num++] = prop_atoms.net_wm_state_maximized_horz;
1467 netstate[num++] = prop_atoms.net_wm_state_above;
1469 netstate[num++] = prop_atoms.net_wm_state_below;
1470 PROP_SETA32(self->window, net_wm_state, atom, netstate, num);
1472 client_calc_layer(self);
1475 frame_adjust_state(self->frame);
1478 ObClient *client_search_focus_tree(ObClient *self)
1483 for (it = self->transients; it != NULL; it = it->next) {
1484 if (client_focused(it->data)) return it->data;
1485 if ((ret = client_search_focus_tree(it->data))) return ret;
1490 ObClient *client_search_focus_tree_full(ObClient *self)
1492 if (self->transient_for) {
1493 if (self->transient_for != OB_TRAN_GROUP) {
1494 return client_search_focus_tree_full(self->transient_for);
1497 gboolean recursed = FALSE;
1499 for (it = self->group->members; it; it = it->next)
1500 if (!((ObClient*)it->data)->transient_for) {
1502 if ((c = client_search_focus_tree_full(it->data)))
1511 /* this function checks the whole tree, the client_search_focus_tree~
1512 does not, so we need to check this window */
1513 if (client_focused(self))
1515 return client_search_focus_tree(self);
1518 static ObStackingLayer calc_layer(ObClient *self)
1522 if (self->fullscreen) l = OB_STACKING_LAYER_FULLSCREEN;
1523 else if (self->type == OB_CLIENT_TYPE_DESKTOP)
1524 l = OB_STACKING_LAYER_DESKTOP;
1525 else if (self->type == OB_CLIENT_TYPE_DOCK) {
1526 if (!self->below) l = OB_STACKING_LAYER_TOP;
1527 else l = OB_STACKING_LAYER_NORMAL;
1529 else if (self->above) l = OB_STACKING_LAYER_ABOVE;
1530 else if (self->below) l = OB_STACKING_LAYER_BELOW;
1531 else l = OB_STACKING_LAYER_NORMAL;
1536 static void client_calc_layer_recursive(ObClient *self, ObClient *orig,
1537 ObStackingLayer l, gboolean raised)
1539 ObStackingLayer old, own;
1543 own = calc_layer(self);
1544 self->layer = l > own ? l : own;
1546 for (it = self->transients; it; it = it->next)
1547 client_calc_layer_recursive(it->data, orig,
1548 l, raised ? raised : l != old);
1550 if (!raised && l != old)
1551 if (orig->frame) { /* only restack if the original window is managed */
1552 /* XXX add_non_intrusive ever? */
1553 stacking_remove(CLIENT_AS_WINDOW(self));
1554 stacking_add(CLIENT_AS_WINDOW(self));
1558 void client_calc_layer(ObClient *self)
1565 /* transients take on the layer of their parents */
1566 self = client_search_top_transient(self);
1568 l = calc_layer(self);
1570 client_calc_layer_recursive(self, orig, l, FALSE);
1573 gboolean client_should_show(ObClient *self)
1575 if (self->iconic) return FALSE;
1576 else if (!(self->desktop == screen_desktop ||
1577 self->desktop == DESKTOP_ALL)) return FALSE;
1578 else if (client_normal(self) && screen_showing_desktop) return FALSE;
1583 static void client_showhide(ObClient *self)
1586 if (client_should_show(self))
1587 frame_show(self->frame);
1589 frame_hide(self->frame);
1592 gboolean client_normal(ObClient *self) {
1593 return ! (self->type == OB_CLIENT_TYPE_DESKTOP ||
1594 self->type == OB_CLIENT_TYPE_DOCK ||
1595 self->type == OB_CLIENT_TYPE_SPLASH);
1598 static void client_apply_startup_state(ObClient *self)
1600 /* these are in a carefully crafted order.. */
1603 self->iconic = FALSE;
1604 client_iconify(self, TRUE, FALSE);
1606 if (self->fullscreen) {
1607 self->fullscreen = FALSE;
1608 client_fullscreen(self, TRUE, FALSE);
1611 self->shaded = FALSE;
1612 client_shade(self, TRUE);
1615 dispatch_client(Event_Client_Urgent, self, self->urgent, 0);
1617 if (self->max_vert && self->max_horz) {
1618 self->max_vert = self->max_horz = FALSE;
1619 client_maximize(self, TRUE, 0, FALSE);
1620 } else if (self->max_vert) {
1621 self->max_vert = FALSE;
1622 client_maximize(self, TRUE, 2, FALSE);
1623 } else if (self->max_horz) {
1624 self->max_horz = FALSE;
1625 client_maximize(self, TRUE, 1, FALSE);
1628 /* nothing to do for the other states:
1637 void client_configure(ObClient *self, ObCorner anchor,
1638 int x, int y, int w, int h,
1639 gboolean user, gboolean final)
1641 gboolean moved = FALSE, resized = FALSE;
1643 /* gets the frame's position */
1644 frame_client_gravity(self->frame, &x, &y);
1646 /* these positions are frame positions, not client positions */
1648 /* set the size and position if fullscreen */
1649 if (self->fullscreen) {
1652 XF86VidModeModeLine mode;
1657 i = client_monitor(self);
1658 a = screen_physical_area_monitor(i);
1661 if (i == 0 && /* primary head */
1662 extensions_vidmode &&
1663 XF86VidModeGetViewPort(ob_display, ob_screen, &x, &y) &&
1664 /* get the mode last so the mode.privsize isnt freed incorrectly */
1665 XF86VidModeGetModeLine(ob_display, ob_screen, &dot, &mode)) {
1670 if (mode.privsize) XFree(mode.private);
1680 user = FALSE; /* ignore that increment etc shit when in fullscreen */
1684 a = screen_area_monitor(self->desktop, client_monitor(self));
1686 /* set the size and position if maximized */
1687 if (self->max_horz) {
1688 x = a->x - self->frame->size.left;
1691 if (self->max_vert) {
1693 h = a->height - self->frame->size.top - self->frame->size.bottom;
1697 /* gets the client's position */
1698 frame_frame_gravity(self->frame, &x, &y);
1700 /* these override the above states! if you cant move you can't move! */
1702 if (!(self->functions & OB_CLIENT_FUNC_MOVE)) {
1706 if (!(self->functions & OB_CLIENT_FUNC_RESIZE)) {
1707 w = self->area.width;
1708 h = self->area.height;
1712 if (!(w == self->area.width && h == self->area.height)) {
1713 int basew, baseh, minw, minh;
1715 /* base size is substituted with min size if not specified */
1716 if (self->base_size.width || self->base_size.height) {
1717 basew = self->base_size.width;
1718 baseh = self->base_size.height;
1720 basew = self->min_size.width;
1721 baseh = self->min_size.height;
1723 /* min size is substituted with base size if not specified */
1724 if (self->min_size.width || self->min_size.height) {
1725 minw = self->min_size.width;
1726 minh = self->min_size.height;
1728 minw = self->base_size.width;
1729 minh = self->base_size.height;
1733 /* for interactive resizing. have to move half an increment in each
1736 /* how far we are towards the next size inc */
1737 int mw = (w - basew) % self->size_inc.width;
1738 int mh = (h - baseh) % self->size_inc.height;
1740 int aw = self->size_inc.width / 2;
1741 int ah = self->size_inc.height / 2;
1742 /* don't let us move into a new size increment */
1743 if (mw + aw >= self->size_inc.width)
1744 aw = self->size_inc.width - mw - 1;
1745 if (mh + ah >= self->size_inc.height)
1746 ah = self->size_inc.height - mh - 1;
1750 /* if this is a user-requested resize, then check against min/max
1753 /* smaller than min size or bigger than max size? */
1754 if (w > self->max_size.width) w = self->max_size.width;
1755 if (w < minw) w = minw;
1756 if (h > self->max_size.height) h = self->max_size.height;
1757 if (h < minh) h = minh;
1763 /* keep to the increments */
1764 w /= self->size_inc.width;
1765 h /= self->size_inc.height;
1767 /* you cannot resize to nothing */
1771 /* store the logical size */
1772 SIZE_SET(self->logical_size, w, h);
1774 w *= self->size_inc.width;
1775 h *= self->size_inc.height;
1781 /* adjust the height to match the width for the aspect ratios.
1782 for this, min size is not substituted for base size ever. */
1783 w -= self->base_size.width;
1784 h -= self->base_size.height;
1786 if (self->min_ratio)
1787 if (h * self->min_ratio > w) h = (int)(w / self->min_ratio);
1788 if (self->max_ratio)
1789 if (h * self->max_ratio < w) h = (int)(w / self->max_ratio);
1791 w += self->base_size.width;
1792 h += self->base_size.height;
1797 case OB_CORNER_TOPLEFT:
1799 case OB_CORNER_TOPRIGHT:
1800 x -= w - self->area.width;
1802 case OB_CORNER_BOTTOMLEFT:
1803 y -= h - self->area.height;
1805 case OB_CORNER_BOTTOMRIGHT:
1806 x -= w - self->area.width;
1807 y -= h - self->area.height;
1811 moved = x != self->area.x || y != self->area.y;
1812 resized = w != self->area.width || h != self->area.height;
1814 RECT_SET(self->area, x, y, w, h);
1816 /* for app-requested resizes, always resize if 'resized' is true.
1817 for user-requested ones, only resize if final is true, or when
1818 resizing in opaque mode */
1819 if ((!user && resized) ||
1820 (user && (final || (resized && config_opaque_resize))))
1821 XResizeWindow(ob_display, self->window, w, h);
1823 /* move/resize the frame to match the request */
1825 if (self->decorations != self->frame->decorations)
1826 moved = resized = TRUE;
1828 if (moved || resized)
1829 frame_adjust_area(self->frame, moved, resized);
1831 /* If you send this and the client hasn't changed you end up with buggy
1832 clients (emacs) freaking out, cuz they send back a configure every
1833 time they receive this event, which resends them this event... etc.
1835 if ((!user && moved) || (user && final)) {
1837 event.type = ConfigureNotify;
1838 event.xconfigure.display = ob_display;
1839 event.xconfigure.event = self->window;
1840 event.xconfigure.window = self->window;
1842 /* root window real coords */
1843 event.xconfigure.x = self->frame->area.x + self->frame->size.left;
1844 event.xconfigure.y = self->frame->area.y + self->frame->size.top;
1846 event.xconfigure.width = w;
1847 event.xconfigure.height = h;
1848 event.xconfigure.border_width = 0;
1849 event.xconfigure.above = self->frame->plate;
1850 event.xconfigure.override_redirect = FALSE;
1851 XSendEvent(event.xconfigure.display, event.xconfigure.window,
1852 FALSE, StructureNotifyMask, &event);
1857 void client_fullscreen(ObClient *self, gboolean fs, gboolean savearea)
1861 if (!(self->functions & OB_CLIENT_FUNC_FULLSCREEN) || /* can't */
1862 self->fullscreen == fs) return; /* already done */
1864 self->fullscreen = fs;
1865 client_change_state(self); /* change the state hints on the client,
1866 and adjust out layer/stacking */
1870 guint32 dimensions[4];
1871 dimensions[0] = self->area.x;
1872 dimensions[1] = self->area.y;
1873 dimensions[2] = self->area.width;
1874 dimensions[3] = self->area.height;
1876 PROP_SETA32(self->window, openbox_premax, cardinal,
1880 /* these are not actually used cuz client_configure will set them
1881 as appropriate when the window is fullscreened */
1888 /* pick some fallbacks... */
1889 a = screen_area_monitor(self->desktop, 0);
1890 x = a->x + a->width / 4;
1891 y = a->y + a->height / 4;
1895 if (PROP_GETA32(self->window, openbox_premax, cardinal,
1896 (guint32**)&dimensions, &num)) {
1907 client_setup_decor_and_functions(self);
1909 client_configure(self, OB_CORNER_TOPLEFT, x, y, w, h, TRUE, TRUE);
1911 /* try focus us when we go into fullscreen mode */
1915 static void client_iconify_recursive(ObClient *self,
1916 gboolean iconic, gboolean curdesk)
1919 gboolean changed = FALSE;
1922 if (self->iconic != iconic) {
1923 ob_debug("%sconifying window: 0x%lx\n", (iconic ? "I" : "Uni"),
1926 self->iconic = iconic;
1929 if (self->functions & OB_CLIENT_FUNC_ICONIFY) {
1930 self->wmstate = IconicState;
1931 self->ignore_unmaps++;
1932 /* we unmap the client itself so that we can get MapRequest
1933 events, and because the ICCCM tells us to! */
1934 XUnmapWindow(ob_display, self->window);
1936 /* update the focus lists.. iconic windows go to the bottom of
1937 the list, put the new iconic window at the 'top of the
1939 focus_order_to_top(self);
1945 client_set_desktop(self, screen_desktop, FALSE);
1946 self->wmstate = self->shaded ? IconicState : NormalState;
1947 XMapWindow(ob_display, self->window);
1949 /* this puts it after the current focused window */
1950 focus_order_remove(self);
1951 focus_order_add_new(self);
1953 /* this is here cuz with the VIDMODE extension, the viewport can
1954 change while a fullscreen window is iconic, and when it
1955 uniconifies, it would be nice if it did so to the new position
1957 client_reconfigure(self);
1964 client_change_state(self);
1965 client_showhide(self);
1966 screen_update_areas();
1968 dispatch_client(iconic ? Event_Client_Unmapped : Event_Client_Mapped,
1972 /* iconify all transients */
1973 for (it = self->transients; it != NULL; it = it->next)
1974 if (it->data != self) client_iconify_recursive(it->data,
1978 void client_iconify(ObClient *self, gboolean iconic, gboolean curdesk)
1980 /* move up the transient chain as far as possible first */
1981 self = client_search_top_transient(self);
1983 client_iconify_recursive(client_search_top_transient(self),
1987 void client_maximize(ObClient *self, gboolean max, int dir, gboolean savearea)
1991 g_assert(dir == 0 || dir == 1 || dir == 2);
1992 if (!(self->functions & OB_CLIENT_FUNC_MAXIMIZE)) return; /* can't */
1994 /* check if already done */
1996 if (dir == 0 && self->max_horz && self->max_vert) return;
1997 if (dir == 1 && self->max_horz) return;
1998 if (dir == 2 && self->max_vert) return;
2000 if (dir == 0 && !self->max_horz && !self->max_vert) return;
2001 if (dir == 1 && !self->max_horz) return;
2002 if (dir == 2 && !self->max_vert) return;
2005 /* work with the frame's coords */
2006 x = self->frame->area.x;
2007 y = self->frame->area.y;
2008 w = self->area.width;
2009 h = self->area.height;
2013 gint32 dimensions[4];
2022 /* get the property off the window and use it for the dimensions
2023 we are already maxed on */
2024 if (PROP_GETA32(self->window, openbox_premax, cardinal,
2025 (guint32**)&readdim, &num)) {
2027 if (self->max_horz) {
2028 dimensions[0] = readdim[0];
2029 dimensions[2] = readdim[2];
2031 if (self->max_vert) {
2032 dimensions[1] = readdim[1];
2033 dimensions[3] = readdim[3];
2039 PROP_SETA32(self->window, openbox_premax, cardinal,
2040 (guint32*)dimensions, 4);
2047 /* pick some fallbacks... */
2048 a = screen_area_monitor(self->desktop, 0);
2049 if (dir == 0 || dir == 1) { /* horz */
2050 x = a->x + a->width / 4;
2053 if (dir == 0 || dir == 2) { /* vert */
2054 y = a->y + a->height / 4;
2058 if (PROP_GETA32(self->window, openbox_premax, cardinal,
2059 (guint32**)&dimensions, &num)) {
2061 if (dir == 0 || dir == 1) { /* horz */
2065 if (dir == 0 || dir == 2) { /* vert */
2074 if (dir == 0 || dir == 1) /* horz */
2075 self->max_horz = max;
2076 if (dir == 0 || dir == 2) /* vert */
2077 self->max_vert = max;
2079 if (!self->max_horz && !self->max_vert)
2080 PROP_ERASE(self->window, openbox_premax);
2082 client_change_state(self); /* change the state hints on the client */
2084 /* figure out where the client should be going */
2085 frame_frame_gravity(self->frame, &x, &y);
2086 client_configure(self, OB_CORNER_TOPLEFT, x, y, w, h, TRUE, TRUE);
2089 void client_shade(ObClient *self, gboolean shade)
2091 if ((!(self->functions & OB_CLIENT_FUNC_SHADE) &&
2092 shade) || /* can't shade */
2093 self->shaded == shade) return; /* already done */
2095 /* when we're iconic, don't change the wmstate */
2097 self->wmstate = shade ? IconicState : NormalState;
2098 self->shaded = shade;
2099 client_change_state(self);
2100 /* resize the frame to just the titlebar */
2101 frame_adjust_area(self->frame, FALSE, FALSE);
2104 void client_close(ObClient *self)
2108 if (!(self->functions & OB_CLIENT_FUNC_CLOSE)) return;
2111 XXX: itd be cool to do timeouts and shit here for killing the client's
2113 like... if the window is around after 5 seconds, then the close button
2114 turns a nice red, and if this function is called again, the client is
2118 ce.xclient.type = ClientMessage;
2119 ce.xclient.message_type = prop_atoms.wm_protocols;
2120 ce.xclient.display = ob_display;
2121 ce.xclient.window = self->window;
2122 ce.xclient.format = 32;
2123 ce.xclient.data.l[0] = prop_atoms.wm_delete_window;
2124 ce.xclient.data.l[1] = event_lasttime;
2125 ce.xclient.data.l[2] = 0l;
2126 ce.xclient.data.l[3] = 0l;
2127 ce.xclient.data.l[4] = 0l;
2128 XSendEvent(ob_display, self->window, FALSE, NoEventMask, &ce);
2131 void client_kill(ObClient *self)
2133 XKillClient(ob_display, self->window);
2136 void client_set_desktop_recursive(ObClient *self,
2137 guint target, gboolean donthide)
2142 if (target != self->desktop) {
2144 ob_debug("Setting desktop %u\n", target+1);
2146 g_assert(target < screen_num_desktops || target == DESKTOP_ALL);
2148 /* remove from the old desktop(s) */
2149 focus_order_remove(self);
2151 old = self->desktop;
2152 self->desktop = target;
2153 PROP_SET32(self->window, net_wm_desktop, cardinal, target);
2154 /* the frame can display the current desktop state */
2155 frame_adjust_state(self->frame);
2156 /* 'move' the window to the new desktop */
2158 client_showhide(self);
2159 /* raise if it was not already on the desktop */
2160 if (old != DESKTOP_ALL)
2161 stacking_raise(CLIENT_AS_WINDOW(self));
2162 screen_update_areas();
2164 /* add to the new desktop(s) */
2165 if (config_focus_new)
2166 focus_order_to_top(self);
2168 focus_order_to_bottom(self);
2170 dispatch_client(Event_Client_Desktop, self, target, old);
2173 /* move all transients */
2174 for (it = self->transients; it != NULL; it = it->next)
2175 if (it->data != self) client_set_desktop_recursive(it->data,
2179 void client_set_desktop(ObClient *self, guint target, gboolean donthide)
2181 client_set_desktop_recursive(client_search_top_transient(self),
2185 ObClient *client_search_modal_child(ObClient *self)
2190 for (it = self->transients; it != NULL; it = it->next) {
2191 ObClient *c = it->data;
2192 if ((ret = client_search_modal_child(c))) return ret;
2193 if (c->modal) return c;
2198 gboolean client_validate(ObClient *self)
2202 XSync(ob_display, FALSE); /* get all events on the server */
2204 if (XCheckTypedWindowEvent(ob_display, self->window, DestroyNotify, &e) ||
2205 XCheckTypedWindowEvent(ob_display, self->window, UnmapNotify, &e)) {
2206 XPutBackEvent(ob_display, &e);
2213 void client_set_wm_state(ObClient *self, long state)
2215 if (state == self->wmstate) return; /* no change */
2219 client_iconify(self, TRUE, TRUE);
2222 client_iconify(self, FALSE, TRUE);
2227 void client_set_state(ObClient *self, Atom action, long data1, long data2)
2229 gboolean shaded = self->shaded;
2230 gboolean fullscreen = self->fullscreen;
2231 gboolean max_horz = self->max_horz;
2232 gboolean max_vert = self->max_vert;
2235 if (!(action == prop_atoms.net_wm_state_add ||
2236 action == prop_atoms.net_wm_state_remove ||
2237 action == prop_atoms.net_wm_state_toggle))
2238 /* an invalid action was passed to the client message, ignore it */
2241 for (i = 0; i < 2; ++i) {
2242 Atom state = i == 0 ? data1 : data2;
2244 if (!state) continue;
2246 /* if toggling, then pick whether we're adding or removing */
2247 if (action == prop_atoms.net_wm_state_toggle) {
2248 if (state == prop_atoms.net_wm_state_modal)
2249 action = self->modal ? prop_atoms.net_wm_state_remove :
2250 prop_atoms.net_wm_state_add;
2251 else if (state == prop_atoms.net_wm_state_maximized_vert)
2252 action = self->max_vert ? prop_atoms.net_wm_state_remove :
2253 prop_atoms.net_wm_state_add;
2254 else if (state == prop_atoms.net_wm_state_maximized_horz)
2255 action = self->max_horz ? prop_atoms.net_wm_state_remove :
2256 prop_atoms.net_wm_state_add;
2257 else if (state == prop_atoms.net_wm_state_shaded)
2258 action = self->shaded ? prop_atoms.net_wm_state_remove :
2259 prop_atoms.net_wm_state_add;
2260 else if (state == prop_atoms.net_wm_state_skip_taskbar)
2261 action = self->skip_taskbar ?
2262 prop_atoms.net_wm_state_remove :
2263 prop_atoms.net_wm_state_add;
2264 else if (state == prop_atoms.net_wm_state_skip_pager)
2265 action = self->skip_pager ?
2266 prop_atoms.net_wm_state_remove :
2267 prop_atoms.net_wm_state_add;
2268 else if (state == prop_atoms.net_wm_state_fullscreen)
2269 action = self->fullscreen ?
2270 prop_atoms.net_wm_state_remove :
2271 prop_atoms.net_wm_state_add;
2272 else if (state == prop_atoms.net_wm_state_above)
2273 action = self->above ? prop_atoms.net_wm_state_remove :
2274 prop_atoms.net_wm_state_add;
2275 else if (state == prop_atoms.net_wm_state_below)
2276 action = self->below ? prop_atoms.net_wm_state_remove :
2277 prop_atoms.net_wm_state_add;
2280 if (action == prop_atoms.net_wm_state_add) {
2281 if (state == prop_atoms.net_wm_state_modal) {
2282 /* XXX raise here or something? */
2284 } else if (state == prop_atoms.net_wm_state_maximized_vert) {
2286 } else if (state == prop_atoms.net_wm_state_maximized_horz) {
2288 } else if (state == prop_atoms.net_wm_state_shaded) {
2290 } else if (state == prop_atoms.net_wm_state_skip_taskbar) {
2291 self->skip_taskbar = TRUE;
2292 } else if (state == prop_atoms.net_wm_state_skip_pager) {
2293 self->skip_pager = TRUE;
2294 } else if (state == prop_atoms.net_wm_state_fullscreen) {
2296 } else if (state == prop_atoms.net_wm_state_above) {
2298 } else if (state == prop_atoms.net_wm_state_below) {
2302 } else { /* action == prop_atoms.net_wm_state_remove */
2303 if (state == prop_atoms.net_wm_state_modal) {
2304 self->modal = FALSE;
2305 } else if (state == prop_atoms.net_wm_state_maximized_vert) {
2307 } else if (state == prop_atoms.net_wm_state_maximized_horz) {
2309 } else if (state == prop_atoms.net_wm_state_shaded) {
2311 } else if (state == prop_atoms.net_wm_state_skip_taskbar) {
2312 self->skip_taskbar = FALSE;
2313 } else if (state == prop_atoms.net_wm_state_skip_pager) {
2314 self->skip_pager = FALSE;
2315 } else if (state == prop_atoms.net_wm_state_fullscreen) {
2317 } else if (state == prop_atoms.net_wm_state_above) {
2318 self->above = FALSE;
2319 } else if (state == prop_atoms.net_wm_state_below) {
2320 self->below = FALSE;
2324 if (max_horz != self->max_horz || max_vert != self->max_vert) {
2325 if (max_horz != self->max_horz && max_vert != self->max_vert) {
2327 if (max_horz == max_vert) { /* both going the same way */
2328 client_maximize(self, max_horz, 0, TRUE);
2330 client_maximize(self, max_horz, 1, TRUE);
2331 client_maximize(self, max_vert, 2, TRUE);
2335 if (max_horz != self->max_horz)
2336 client_maximize(self, max_horz, 1, TRUE);
2338 client_maximize(self, max_vert, 2, TRUE);
2341 /* change fullscreen state before shading, as it will affect if the window
2343 if (fullscreen != self->fullscreen)
2344 client_fullscreen(self, fullscreen, TRUE);
2345 if (shaded != self->shaded)
2346 client_shade(self, shaded);
2347 client_calc_layer(self);
2348 client_change_state(self); /* change the hint to reflect these changes */
2351 ObClient *client_focus_target(ObClient *self)
2355 /* if we have a modal child, then focus it, not us */
2356 child = client_search_modal_child(self);
2357 if (child) return child;
2361 gboolean client_can_focus(ObClient *self)
2365 /* choose the correct target */
2366 self = client_focus_target(self);
2368 if (!self->frame->visible)
2371 if (!((self->can_focus || self->focus_notify) &&
2372 (self->desktop == screen_desktop ||
2373 self->desktop == DESKTOP_ALL) &&
2377 /* do a check to see if the window has already been unmapped or destroyed
2378 do this intelligently while watching out for unmaps we've generated
2379 (ignore_unmaps > 0) */
2380 if (XCheckTypedWindowEvent(ob_display, self->window,
2381 DestroyNotify, &ev)) {
2382 XPutBackEvent(ob_display, &ev);
2385 while (XCheckTypedWindowEvent(ob_display, self->window,
2386 UnmapNotify, &ev)) {
2387 if (self->ignore_unmaps) {
2388 self->ignore_unmaps--;
2390 XPutBackEvent(ob_display, &ev);
2398 gboolean client_focus(ObClient *self)
2400 /* choose the correct target */
2401 self = client_focus_target(self);
2403 if (!client_can_focus(self)) {
2404 if (!self->frame->visible) {
2405 /* update the focus lists */
2406 focus_order_to_top(self);
2411 if (self->can_focus)
2412 /* RevertToPointerRoot causes much more headache than RevertToNone, so
2413 I choose to use it always, hopefully to find errors quicker, if any
2414 are left. (I hate X. I hate focus events.) */
2415 XSetInputFocus(ob_display, self->window, RevertToPointerRoot,
2418 if (self->focus_notify) {
2420 ce.xclient.type = ClientMessage;
2421 ce.xclient.message_type = prop_atoms.wm_protocols;
2422 ce.xclient.display = ob_display;
2423 ce.xclient.window = self->window;
2424 ce.xclient.format = 32;
2425 ce.xclient.data.l[0] = prop_atoms.wm_take_focus;
2426 ce.xclient.data.l[1] = event_lasttime;
2427 ce.xclient.data.l[2] = 0l;
2428 ce.xclient.data.l[3] = 0l;
2429 ce.xclient.data.l[4] = 0l;
2430 XSendEvent(ob_display, self->window, FALSE, NoEventMask, &ce);
2434 ob_debug("%sively focusing %lx at %d\n",
2435 (self->can_focus ? "act" : "pass"),
2436 self->window, (int) event_lasttime);
2439 /* Cause the FocusIn to come back to us. Important for desktop switches,
2440 since otherwise we'll have no FocusIn on the queue and send it off to
2441 the focus_backup. */
2442 XSync(ob_display, FALSE);
2446 void client_unfocus(ObClient *self)
2448 g_assert(focus_client == self);
2450 ob_debug("client_unfocus for %lx\n", self->window);
2452 focus_fallback(OB_FOCUS_FALLBACK_UNFOCUSING);
2455 void client_activate(ObClient *self)
2457 if (client_normal(self) && screen_showing_desktop)
2458 screen_show_desktop(FALSE);
2460 client_iconify(self, FALSE, FALSE);
2461 if (self->desktop != DESKTOP_ALL &&
2462 self->desktop != screen_desktop)
2463 screen_set_desktop(self->desktop);
2464 else if (!self->frame->visible)
2465 /* if its not visible for other reasons, then don't mess
2469 client_shade(self, FALSE);
2471 stacking_raise(CLIENT_AS_WINDOW(self));
2474 gboolean client_focused(ObClient *self)
2476 return self == focus_client;
2479 ObClientIcon *client_icon(ObClient *self, int w, int h)
2482 /* si is the smallest image >= req */
2483 /* li is the largest image < req */
2484 unsigned long size, smallest = 0xffffffff, largest = 0, si = 0, li = 0;
2486 if (!self->nicons) return NULL;
2488 for (i = 0; i < self->nicons; ++i) {
2489 size = self->icons[i].width * self->icons[i].height;
2490 if (size < smallest && size >= (unsigned)(w * h)) {
2494 if (size > largest && size <= (unsigned)(w * h)) {
2499 if (largest == 0) /* didnt find one smaller than the requested size */
2500 return &self->icons[si];
2501 return &self->icons[li];
2504 /* this be mostly ripped from fvwm */
2505 ObClient *client_find_directional(ObClient *c, ObDirection dir)
2507 int my_cx, my_cy, his_cx, his_cy;
2510 int score, best_score;
2511 ObClient *best_client, *cur;
2517 /* first, find the centre coords of the currently focused window */
2518 my_cx = c->frame->area.x + c->frame->area.width / 2;
2519 my_cy = c->frame->area.y + c->frame->area.height / 2;
2524 for(it = g_list_first(client_list); it; it = it->next) {
2527 /* the currently selected window isn't interesting */
2530 if (!client_normal(cur))
2532 if(c->desktop != cur->desktop && cur->desktop != DESKTOP_ALL)
2536 if(client_focus_target(cur) == cur &&
2537 !(cur->can_focus || cur->focus_notify))
2540 /* find the centre coords of this window, from the
2541 * currently focused window's point of view */
2542 his_cx = (cur->frame->area.x - my_cx)
2543 + cur->frame->area.width / 2;
2544 his_cy = (cur->frame->area.y - my_cy)
2545 + cur->frame->area.height / 2;
2549 /* Rotate the diagonals 45 degrees counterclockwise.
2550 * To do this, multiply the matrix /+h +h\ with the
2551 * vector (x y). \-h +h/
2552 * h = sqrt(0.5). We can set h := 1 since absolute
2553 * distance doesn't matter here. */
2554 tx = his_cx + his_cy;
2555 his_cy = -his_cx + his_cy;
2560 case OB_DIRECTION_NORTH:
2561 case OB_DIRECTION_SOUTH:
2562 case OB_DIRECTION_NORTHEAST:
2563 case OB_DIRECTION_SOUTHWEST:
2564 offset = (his_cx < 0) ? -his_cx : his_cx;
2565 distance = ((dir == OB_DIRECTION_NORTH ||
2566 dir == OB_DIRECTION_NORTHEAST) ?
2569 case OB_DIRECTION_EAST:
2570 case OB_DIRECTION_WEST:
2571 case OB_DIRECTION_SOUTHEAST:
2572 case OB_DIRECTION_NORTHWEST:
2573 offset = (his_cy < 0) ? -his_cy : his_cy;
2574 distance = ((dir == OB_DIRECTION_WEST ||
2575 dir == OB_DIRECTION_NORTHWEST) ?
2580 /* the target must be in the requested direction */
2584 /* Calculate score for this window. The smaller the better. */
2585 score = distance + offset;
2587 /* windows more than 45 degrees off the direction are
2588 * heavily penalized and will only be chosen if nothing
2589 * else within a million pixels */
2590 if(offset > distance)
2593 if(best_score == -1 || score < best_score)
2601 void client_set_layer(ObClient *self, int layer)
2605 self->above = FALSE;
2606 } else if (layer == 0) {
2607 self->below = self->above = FALSE;
2609 self->below = FALSE;
2612 client_calc_layer(self);
2613 client_change_state(self); /* reflect this in the state hints */
2616 guint client_monitor(ObClient *self)
2620 for (i = 0; i < screen_num_monitors; ++i) {
2621 Rect *area = screen_physical_area_monitor(i);
2622 if (RECT_INTERSECTS_RECT(*area, self->frame->area))
2625 if (i == screen_num_monitors) i = 0;
2626 g_assert(i < screen_num_monitors);
2630 ObClient *client_search_top_transient(ObClient *self)
2632 /* move up the transient chain as far as possible */
2633 if (self->transient_for) {
2634 if (self->transient_for != OB_TRAN_GROUP) {
2635 return client_search_top_transient(self->transient_for);
2639 for (it = self->group->members; it; it = it->next) {
2640 ObClient *c = it->data;
2642 /* checking transient_for prevents infinate loops! */
2643 if (c != self && !c->transient_for)
2654 ObClient *client_search_transient(ObClient *self, ObClient *search)
2658 for (sit = self->transients; sit; sit = g_slist_next(sit)) {
2659 if (sit->data == search)
2661 if (client_search_transient(sit->data, search))