]>
Dogcows Code - chaz/openbox/blob - openbox/stacking.c
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 if (it
->data
== client
) continue;
99 for (sit
= c
->group
->members
; sit
; sit
= sit
->next
)
100 if (sit
->data
== it
->data
) break;
101 if (sit
) break; /* got it */
104 goto lower_no_parent
;
106 /* don't let a modal window lower below its transient_for */
107 it
= g_list_find(stacking_list
, client
->transient_for
);
109 g_assert(it
!= NULL
);
111 wins
[0] = (it
== stacking_list
? focus_backup
:
112 ((Client
*)it
->prev
->data
)->frame
->window
);
113 wins
[1] = client
->frame
->window
;
114 if (wins
[0] == wins
[1]) return; /* already right above the window */
116 stacking_list
= g_list_remove(stacking_list
, client
);
117 stacking_list
= g_list_insert_before(stacking_list
, it
, client
);
121 it
= g_list_last(stacking_list
);
123 while (it
!= stacking_list
) {
124 Client
*c
= it
->data
;
125 if (client
->layer
<= c
->layer
)
129 if (it
->data
== client
) return; /* already the bottom, return */
131 wins
[0] = ((Client
*)it
->data
)->frame
->window
;
132 wins
[1] = client
->frame
->window
;
134 stacking_list
= g_list_remove(stacking_list
, client
);
135 stacking_list
= g_list_insert_before(stacking_list
,
139 XRestackWindows(ob_display
, wins
, 2);
This page took 0.040918 seconds and 4 git commands to generate.