self->desktop = screen_num_desktops - 1;
else
self->desktop = d;
- } else {
+ } else {
gboolean trdesk = FALSE;
if (self->transient_for) {
return l;
}
-static void calc_recursive(Client *self, Client *orig, StackLayer l,
- gboolean raised)
+static void client_calc_layer_recursive(Client *self, Client *orig,
+ StackLayer l, gboolean raised)
{
StackLayer old, own;
GSList *it;
self->layer = l > own ? l : own;
for (it = self->transients; it; it = it->next)
- calc_recursive(it->data, orig, l, raised ? raised : l != old);
+ client_calc_layer_recursive(it->data, orig,
+ l, raised ? raised : l != old);
if (!raised && l != old)
if (orig->frame) { /* only restack if the original window is managed */
orig = self;
/* transients take on the layer of their parents */
- if (self->transient_for) {
- if (self->transient_for != TRAN_GROUP) {
- self = self->transient_for;
- } else {
- GSList *it;
-
- for (it = self->group->members; it; it = it->next)
- if (it->data != self &&
- !((Client*)it->data)->transient_for) {
- self = it->data;
- break;
- }
- }
- }
+ self = client_search_top_transient(self);
l = calc_layer(self);
- calc_recursive(self, orig, l, FALSE);
+ client_calc_layer_recursive(self, orig, l, FALSE);
}
gboolean client_should_show(Client *self)
client_focus(self);
}
-void client_iconify(Client *self, gboolean iconic, gboolean curdesk)
+static void client_iconify_recursive(Client *self,
+ gboolean iconic, gboolean curdesk)
{
GSList *it;
+ gboolean changed = FALSE;
- /* move up the transient chain as far as possible first */
- if (self->transient_for) {
- if (self->transient_for != TRAN_GROUP) {
- if (self->transient_for->iconic != iconic) {
- client_iconify(self->transient_for, iconic, curdesk);
- return;
- }
- } else {
- GSList *it;
-
- for (it = self->group->members; it; it = it->next) {
- Client *c = it->data;
- if (c != self && c->iconic != iconic &&
- !c->transient_for) {
- client_iconify(it->data, iconic, curdesk);
- break;
- }
- }
- if (it != NULL) return;
- }
- }
- if (self->iconic == iconic) return; /* nothing to do */
+ if (self->iconic != iconic) {
+ g_message("%sconifying window: 0x%lx", (iconic ? "I" : "Uni"),
+ self->window);
- g_message("%sconifying window: 0x%lx", (iconic ? "I" : "Uni"),
- self->window);
+ self->iconic = iconic;
- self->iconic = iconic;
+ if (iconic) {
+ if (self->functions & Func_Iconify) {
+ self->wmstate = IconicState;
+ self->ignore_unmaps++;
+ /* we unmap the client itself so that we can get MapRequest
+ events, and because the ICCCM tells us to! */
+ XUnmapWindow(ob_display, self->window);
- if (iconic) {
- self->wmstate = IconicState;
- self->ignore_unmaps++;
- /* we unmap the client itself so that we can get MapRequest events,
- and because the ICCCM tells us to! */
- XUnmapWindow(ob_display, self->window);
+ /* update the focus lists.. iconic windows go to the bottom of
+ the list, put the new iconic window at the 'top of the
+ bottom'. */
+ focus_order_to_top(self);
- /* update the focus lists.. iconic windows go to the bottom of the
- list, put the new iconic window at the 'top of the bottom'. */
- focus_order_to_top(self);
- } else {
- if (curdesk)
- client_set_desktop(self, screen_desktop, FALSE);
- self->wmstate = self->shaded ? IconicState : NormalState;
- XMapWindow(ob_display, self->window);
+ changed = TRUE;
+ }
+ } else {
+ if (curdesk)
+ client_set_desktop(self, screen_desktop, FALSE);
+ self->wmstate = self->shaded ? IconicState : NormalState;
+ XMapWindow(ob_display, self->window);
+
+ /* this puts it after the current focused window */
+ focus_order_remove(self);
+ focus_order_add_new(self);
+
+ /* this is here cuz with the VIDMODE extension, the viewport can
+ change while a fullscreen window is iconic, and when it
+ uniconifies, it would be nice if it did so to the new position
+ of the viewport */
+ client_reconfigure(self);
+
+ changed = TRUE;
+ }
+ }
- /* this puts it after the current focused window */
- focus_order_remove(self);
- focus_order_add_new(self);
+ if (changed) {
+ client_change_state(self);
+ client_showhide(self);
+ screen_update_areas();
- /* this is here cuz with the VIDMODE extension, the viewport can change
- while a fullscreen window is iconic, and when it uniconifies, it
- would be nice if it did so to the new position of the viewport */
- client_reconfigure(self);
+ dispatch_client(iconic ? Event_Client_Unmapped : Event_Client_Mapped,
+ self, 0, 0);
}
- client_change_state(self);
- client_showhide(self);
- screen_update_areas();
-
- dispatch_client(iconic ? Event_Client_Unmapped : Event_Client_Mapped,
- self, 0, 0);
/* iconify all transients */
for (it = self->transients; it != NULL; it = it->next)
- if (it->data != self) client_iconify(it->data, iconic, curdesk);
+ if (it->data != self) client_iconify_recursive(it->data,
+ iconic, curdesk);
+}
+
+void client_iconify(Client *self, gboolean iconic, gboolean curdesk)
+{
+ /* move up the transient chain as far as possible first */
+ self = client_search_top_transient(self);
+
+ client_iconify_recursive(client_search_top_transient(self),
+ iconic, curdesk);
}
void client_maximize(Client *self, gboolean max, int dir, gboolean savearea)
XKillClient(ob_display, self->window);
}
-void client_set_desktop(Client *self, guint target, gboolean donthide)
+void client_set_desktop_recursive(Client *self,
+ guint target, gboolean donthide)
{
guint old;
+ GSList *it;
- if (target == self->desktop) return;
-
- g_message("Setting desktop %u", target+1);
+ if (target != self->desktop) {
- g_assert(target < screen_num_desktops || target == DESKTOP_ALL);
+ g_message("Setting desktop %u", target+1);
- /* remove from the old desktop(s) */
- focus_order_remove(self);
+ g_assert(target < screen_num_desktops || target == DESKTOP_ALL);
- old = self->desktop;
- self->desktop = target;
- PROP_SET32(self->window, net_wm_desktop, cardinal, target);
- /* the frame can display the current desktop state */
- frame_adjust_state(self->frame);
- /* 'move' the window to the new desktop */
- if (!donthide)
- client_showhide(self);
- /* raise if it was not already on the desktop */
- if (old != DESKTOP_ALL)
- stacking_raise(CLIENT_AS_WINDOW(self));
- screen_update_areas();
+ /* remove from the old desktop(s) */
+ focus_order_remove(self);
- /* add to the new desktop(s) */
- if (config_focus_new)
- focus_order_to_top(self);
- else
- focus_order_to_bottom(self);
+ old = self->desktop;
+ self->desktop = target;
+ PROP_SET32(self->window, net_wm_desktop, cardinal, target);
+ /* the frame can display the current desktop state */
+ frame_adjust_state(self->frame);
+ /* 'move' the window to the new desktop */
+ if (!donthide)
+ client_showhide(self);
+ /* raise if it was not already on the desktop */
+ if (old != DESKTOP_ALL)
+ stacking_raise(CLIENT_AS_WINDOW(self));
+ screen_update_areas();
+
+ /* add to the new desktop(s) */
+ if (config_focus_new)
+ focus_order_to_top(self);
+ else
+ focus_order_to_bottom(self);
- dispatch_client(Event_Client_Desktop, self, target, old);
+ dispatch_client(Event_Client_Desktop, self, target, old);
+ }
+
+ /* move all transients */
+ for (it = self->transients; it != NULL; it = it->next)
+ if (it->data != self) client_set_desktop_recursive(it->data,
+ target, donthide);
+}
+
+void client_set_desktop(Client *self, guint target, gboolean donthide)
+{
+ client_set_desktop_recursive(client_search_top_transient(self),
+ target, donthide);
}
Client *client_search_modal_child(Client *self)
g_assert(i < screen_num_xin_areas);
return i;
}
+
+Client *client_search_top_transient(Client *self)
+{
+ /* move up the transient chain as far as possible */
+ if (self->transient_for) {
+ if (self->transient_for != TRAN_GROUP) {
+ return client_search_top_transient(self->transient_for);
+ } else {
+ GSList *it;
+
+ for (it = self->group->members; it; it = it->next) {
+ Client *c = it->data;
+
+ /* checking transient_for prevents infinate loops! */
+ if (c != self && !c->transient_for)
+ break;
+ }
+ if (it)
+ return it->data;
+ }
+ }
+
+ return self;
+}