8 GList *stacking_list = NULL;
10 void stacking_set_list()
12 Window *windows, *win_it;
14 guint size = g_list_length(stacking_list);
16 /* on shutdown, don't update the properties, so that we can read it back
17 in on startup and re-stack the windows as they were before we shut down
19 if (ob_state == State_Exiting) return;
21 /* create an array of the window ids (from bottom to top,
24 windows = g_new(Window, size);
26 for (it = g_list_last(stacking_list); it != NULL;
27 it = it->prev, ++win_it)
28 *win_it = ((Client*)it->data)->window;
32 PROP_SET32A(ob_root, net_client_list_stacking, window, windows, size);
38 void stacking_raise(Client *client)
40 Window wins[2]; /* only ever restack 2 windows. */
44 g_assert(stacking_list != NULL); /* this would be bad */
46 m = client_find_modal_child(client);
47 /* if we have a modal child, raise it instead, we'll go along tho later */
48 if (m) stacking_raise(m);
50 /* remove the client before looking so we can't run into ourselves */
51 stacking_list = g_list_remove(stacking_list, client);
53 /* the stacking list is from highest to lowest */
57 if (client->layer >= c->layer && m != c)
63 if our new position is the top, we want to stack under the focus_backup.
64 otherwise, we want to stack under the previous window in the stack.
66 if (it == stacking_list)
67 wins[0] = focus_backup;
69 wins[0] = ((Client*)it->prev->data)->frame->window;
71 wins[0] = ((Client*)g_list_last(stacking_list)->data)->frame->window;
72 wins[1] = client->frame->window;
74 stacking_list = g_list_insert_before(stacking_list, it, client);
76 if (client->frame.visible)
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 it = g_list_last(stacking_list);
91 if (client->modal && client->transient_for) {
92 /* don't let a modal window lower below its transient_for */
93 it = g_list_find(stacking_list, client->transient_for);
96 wins[0] = (it == stacking_list ? focus_backup :
97 ((Client*)it->prev->data)->frame->window);
98 wins[1] = client->frame->window;
99 if (wins[0] == wins[1]) return; /* already right above the window */
101 stacking_list = g_list_remove(stacking_list, client);
102 stacking_list = g_list_insert_before(stacking_list, it, client);
104 while (it != stacking_list) {
105 Client *c = it->data;
106 if (client->layer <= c->layer)
110 if (it->data == client) return; /* already the bottom, return */
112 wins[0] = ((Client*)it->data)->frame->window;
113 wins[1] = client->frame->window;
115 stacking_list = g_list_remove(stacking_list, client);
116 stacking_list = g_list_insert_before(stacking_list,
120 if (client->frame.visible)
121 XRestackWindows(ob_display, wins, 2);