- g_assert(stacking_list != NULL); /* this would be bad */
-
- /* move up the transient chain as far as possible first */
- while (client->transient_for) {
- if (client->transient_for != TRAN_GROUP) {
- client = client->transient_for;
- } else {
- GSList *it;
-
- /* the check for TRAN_GROUP is to prevent an infinate loop with
- 2 transients of the same group at the head of the group's
- members list */
- for (it = client->group->members; it; it = it->next) {
- Client *c = it->data;
-
- if (c != client && c->transient_for != TRAN_GROUP) {
- client = it->data;
- break;
+ if (WINDOW_IS_CLIENT(window)) {
+ ObClient *selected;
+ selected = WINDOW_AS_CLIENT(window);
+ restack_windows(selected, TRUE);
+ } else {
+ GList *wins;
+ wins = g_list_append(NULL, window);
+ stacking_list = g_list_remove(stacking_list, window);
+ do_raise(wins);
+ g_list_free(wins);
+ }
+}
+
+void stacking_lower(ObWindow *window)
+{
+ if (WINDOW_IS_CLIENT(window)) {
+ ObClient *selected;
+ selected = WINDOW_AS_CLIENT(window);
+ restack_windows(selected, FALSE);
+ } else {
+ GList *wins;
+ wins = g_list_append(NULL, window);
+ stacking_list = g_list_remove(stacking_list, window);
+ do_lower(wins);
+ g_list_free(wins);
+ }
+}
+
+void stacking_below(ObWindow *window, ObWindow *below)
+{
+ GList *wins, *before;
+
+ if (window_layer(window) != window_layer(below))
+ return;
+
+ wins = g_list_append(NULL, window);
+ stacking_list = g_list_remove(stacking_list, window);
+ before = g_list_next(g_list_find(stacking_list, below));
+ do_restack(wins, before);
+ g_list_free(wins);
+}
+
+void stacking_add(ObWindow *win)
+{
+ g_assert(screen_support_win != None); /* make sure I dont break this in the
+ future */
+
+ stacking_list = g_list_append(stacking_list, win);
+ stacking_raise(win);
+}
+
+static GList *find_highest_relative(ObClient *client)
+{
+ GList *ret = NULL;
+
+ if (client->transient_for) {
+ GList *it;
+ GSList *top;
+
+ /* get all top level relatives of this client */
+ top = client_search_all_top_parents_layer(client);
+
+ /* go from the top of the stacking order down */
+ for (it = stacking_list; !ret && it; it = g_list_next(it)) {
+ if (WINDOW_IS_CLIENT(it->data)) {
+ ObClient *c = it->data;
+ /* only look at windows in the same layer */
+ if (c->layer == client->layer) {
+ GSList *sit;
+
+ /* go through each top level parent and see it this window
+ is related to them */
+ for (sit = top; !ret && sit; sit = g_slist_next(sit)) {
+ ObClient *topc = sit->data;
+
+ /* are they related ? */
+ if (topc == c || client_search_transient(topc, c))
+ ret = it;
+ }