]>
Dogcows Code - chaz/openbox/blob - stacking.c
4702baa3e017dafe1f54064d77ef8a03b5299ca1
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_SETA32(ob_root
, net_client_list_stacking
, window
, windows
, size
);
39 static GList
*find_lowest_transient(Client
*c
)
44 for (it
= g_list_last(stacking_list
); it
; it
= it
->prev
)
45 for (sit
= c
->transients
; sit
; sit
= sit
->next
)
46 if (it
->data
== sit
->data
) /* found a transient */
51 static void raise_recursive(Client
*client
)
53 Window wins
[2]; /* only ever restack 2 windows. */
57 g_assert(stacking_list
!= NULL
); /* this would be bad */
59 /* remove the client before looking so we can't run into ourselves and our
60 transients can't either. */
61 stacking_list
= g_list_remove(stacking_list
, client
);
63 /* raise transients first */
64 for (sit
= client
->transients
; sit
; sit
= sit
->next
)
65 raise_recursive(sit
->data
);
67 /* find 'it' where it is the positiion in the stacking order where
68 'client' will be inserted *before* */
70 it
= find_lowest_transient(client
);
74 /* the stacking list is from highest to lowest */
75 for (it
= stacking_list
; it
; it
= it
->next
) {
76 if (client
->layer
>= ((Client
*)it
->data
)->layer
)
82 if our new position is the top, we want to stack under the focus_backup.
83 otherwise, we want to stack under the previous window in the stack.
85 if (it
== stacking_list
)
86 wins
[0] = focus_backup
;
88 wins
[0] = ((Client
*)it
->prev
->data
)->frame
->window
;
90 wins
[0] = ((Client
*)g_list_last(stacking_list
)->data
)->frame
->window
;
91 wins
[1] = client
->frame
->window
;
93 stacking_list
= g_list_insert_before(stacking_list
, it
, client
);
95 XRestackWindows(ob_display
, wins
, 2);
98 void stacking_raise(Client
*client
)
100 g_assert(stacking_list
!= NULL
); /* this would be bad */
102 /* move up the transient chain as far as possible first */
103 while (client
->transient_for
) {
104 if (client
->transient_for
!= TRAN_GROUP
) {
105 client
= client
->transient_for
;
109 /* the check for TRAN_GROUP is to prevent an infinate loop with
110 2 transients of the same group at the head of the group's
112 for (it
= client
->group
->members
; it
; it
= it
->next
) {
113 Client
*c
= it
->data
;
115 if (c
!= client
&& c
->transient_for
!= TRAN_GROUP
) {
120 if (it
== NULL
) break;
124 raise_recursive(client
);
129 static void lower_recursive(Client
*client
, Client
*above
)
131 Window wins
[2]; /* only ever restack 2 windows. */
135 /* find 'it' where 'it' is the position in the stacking_list where the
136 'client' will be placed *after* */
138 for (it
= g_list_last(stacking_list
); it
!= stacking_list
; it
= it
->prev
)
139 if (client
->layer
<= ((Client
*)it
->data
)->layer
&& it
->data
!= above
)
142 if (it
->data
!= client
) { /* not already the bottom */
143 wins
[0] = ((Client
*)it
->data
)->frame
->window
;
144 wins
[1] = client
->frame
->window
;
146 stacking_list
= g_list_remove(stacking_list
, client
);
147 stacking_list
= g_list_insert_before(stacking_list
, it
->next
, client
);
148 XRestackWindows(ob_display
, wins
, 2);
151 for (sit
= client
->transients
; sit
; sit
= sit
->next
)
152 lower_recursive(sit
->data
, client
);
155 void stacking_lower(Client
*client
)
157 g_assert(stacking_list
!= NULL
); /* this would be bad */
159 /* move up the transient chain as far as possible first */
160 while (client
->transient_for
) {
161 if (client
->transient_for
!= TRAN_GROUP
) {
162 client
= client
->transient_for
;
166 /* the check for TRAN_GROUP is to prevent an infinate loop with
167 2 transients of the same group at the head of the group's
169 for (it
= client
->group
->members
; it
; it
= it
->next
) {
170 Client
*c
= it
->data
;
172 if (c
!= client
&& c
->transient_for
!= TRAN_GROUP
) {
177 if (it
== NULL
) break;
181 lower_recursive(client
, NULL
);
This page took 0.040373 seconds and 3 git commands to generate.