9 GList *stacking_list = NULL;
11 void stacking_set_list()
13 Window *windows, *win_it;
15 guint size = g_list_length(stacking_list);
17 /* on shutdown, don't update the properties, so that we can read it back
18 in on startup and re-stack the windows as they were before we shut down
20 if (ob_state == State_Exiting) return;
22 /* create an array of the window ids (from bottom to top,
25 windows = g_new(Window, size);
27 for (it = g_list_last(stacking_list); it != NULL;
28 it = it->prev, ++win_it)
29 *win_it = ((Client*)it->data)->window;
33 PROP_SET32A(ob_root, net_client_list_stacking, window, windows, size);
39 void stacking_raise(Client *client)
41 Window wins[2]; /* only ever restack 2 windows. */
45 g_assert(stacking_list != NULL); /* this would be bad */
47 m = client_find_modal_child(client);
48 /* if we have a modal child, raise it instead, we'll go along tho later */
49 if (m) stacking_raise(m);
51 /* remove the client before looking so we can't run into ourselves */
52 stacking_list = g_list_remove(stacking_list, client);
54 /* the stacking list is from highest to lowest */
58 if (client->layer >= c->layer && m != c)
64 if our new position is the top, we want to stack under the focus_backup.
65 otherwise, we want to stack under the previous window in the stack.
67 if (it == stacking_list)
68 wins[0] = focus_backup;
70 wins[0] = ((Client*)it->prev->data)->frame->window;
72 wins[0] = ((Client*)g_list_last(stacking_list)->data)->frame->window;
73 wins[1] = client->frame->window;
75 stacking_list = g_list_insert_before(stacking_list, it, client);
77 XRestackWindows(ob_display, wins, 2);
82 void stacking_lower(Client *client)
84 Window wins[2]; /* only ever restack 2 windows. */
87 g_assert(stacking_list != NULL); /* this would be bad */
89 if (client->modal && client->transient_for) {
90 if (client->transient_for == TRAN_GROUP) {
91 /* don't let a modal of the group lower below any other windows
93 for (it = stacking_list; it; it = it->next) {
97 for (sit = c->group->members; sit; sit = sit->next)
98 if (sit->data == it->data) break;
99 if (sit) break; /* got it */
102 goto lower_no_parent;
104 /* don't let a modal window lower below its transient_for */
105 it = g_list_find(stacking_list, client->transient_for);
107 g_assert(it != NULL);
109 wins[0] = (it == stacking_list ? focus_backup :
110 ((Client*)it->prev->data)->frame->window);
111 wins[1] = client->frame->window;
112 if (wins[0] == wins[1]) return; /* already right above the window */
114 stacking_list = g_list_remove(stacking_list, client);
115 stacking_list = g_list_insert_before(stacking_list, it, client);
119 it = g_list_last(stacking_list);
121 while (it != stacking_list) {
122 Client *c = it->data;
123 if (client->layer <= c->layer)
127 if (it->data == client) return; /* already the bottom, return */
129 wins[0] = ((Client*)it->data)->frame->window;
130 wins[1] = client->frame->window;
132 stacking_list = g_list_remove(stacking_list, client);
133 stacking_list = g_list_insert_before(stacking_list,
137 XRestackWindows(ob_display, wins, 2);