diff options
Diffstat (limited to 'src/core/stack.c')
-rw-r--r-- | src/core/stack.c | 226 |
1 files changed, 113 insertions, 113 deletions
diff --git a/src/core/stack.c b/src/core/stack.c index a619f960..cb6200f7 100644 --- a/src/core/stack.c +++ b/src/core/stack.c @@ -4,12 +4,12 @@ * \file stack.c Which windows cover which other windows */ -/* +/* * Copyright (C) 2001 Havoc Pennington * Copyright (C) 2002, 2003 Red Hat, Inc. * Copyright (C) 2004 Rob Adams * Copyright (C) 2004, 2005 Elijah Newren - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the @@ -19,7 +19,7 @@ * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, see <http://www.gnu.org/licenses/>. */ @@ -64,7 +64,7 @@ MetaStack* meta_stack_new (MetaScreen *screen) { MetaStack *stack; - + stack = g_new (MetaStack, 1); stack->screen = screen; @@ -82,7 +82,7 @@ meta_stack_new (MetaScreen *screen) stack->need_resort = FALSE; stack->need_relayer = FALSE; stack->need_constrain = FALSE; - + return stack; } @@ -97,7 +97,7 @@ meta_stack_free (MetaStack *stack) if (stack->last_root_children_stacked) g_array_free (stack->last_root_children_stacked, TRUE); - + g_free (stack); } @@ -109,7 +109,7 @@ meta_stack_add (MetaStack *stack, if (window->stack_position >= 0) meta_bug ("Window %s had stack position already\n", window->desc); - + stack->added = g_list_prepend (stack->added, window); window->stack_position = stack->n_positions; @@ -117,7 +117,7 @@ meta_stack_add (MetaStack *stack, meta_topic (META_DEBUG_STACK, "Window %s has stack_position initialized to %d\n", window->desc, window->stack_position); - + stack_sync_to_server (stack); } @@ -137,7 +137,7 @@ meta_stack_remove (MetaStack *stack, meta_window_set_stack_position_no_sync (window, stack->n_positions - 1); window->stack_position = -1; - stack->n_positions -= 1; + stack->n_positions -= 1; /* We don't know if it's been moved from "added" to "stack" yet */ stack->added = g_list_remove (stack->added, window); @@ -152,7 +152,7 @@ meta_stack_remove (MetaStack *stack, if (window->frame) stack->removed = g_list_prepend (stack->removed, GUINT_TO_POINTER (window->frame->xwindow)); - + stack_sync_to_server (stack); } @@ -161,7 +161,7 @@ meta_stack_update_layer (MetaStack *stack, MetaWindow *window) { stack->need_relayer = TRUE; - + stack_sync_to_server (stack); } @@ -170,7 +170,7 @@ meta_stack_update_transient (MetaStack *stack, MetaWindow *window) { stack->need_constrain = TRUE; - + stack_sync_to_server (stack); } @@ -178,10 +178,10 @@ meta_stack_update_transient (MetaStack *stack, void meta_stack_raise (MetaStack *stack, MetaWindow *window) -{ +{ meta_window_set_stack_position_no_sync (window, stack->n_positions - 1); - + stack_sync_to_server (stack); } @@ -190,7 +190,7 @@ meta_stack_lower (MetaStack *stack, MetaWindow *window) { meta_window_set_stack_position_no_sync (window, 0); - + stack_sync_to_server (stack); } @@ -204,7 +204,7 @@ void meta_stack_thaw (MetaStack *stack) { g_return_if_fail (stack->freeze_count > 0); - + stack->freeze_count -= 1; stack_sync_to_server (stack); } @@ -238,7 +238,7 @@ get_standalone_layer (MetaWindow *window) { MetaStackLayer layer; gboolean focused_transient = FALSE; - + switch (window->type) { case META_WINDOW_DESKTOP: @@ -253,7 +253,7 @@ get_standalone_layer (MetaWindow *window) layer = META_LAYER_DOCK; break; - default: + default: meta_window_foreach_transient (window, is_focused_foreach, &focused_transient); @@ -289,16 +289,16 @@ get_maximum_layer_in_group (MetaWindow *window) GSList *tmp; MetaStackLayer max; MetaStackLayer layer; - + max = META_LAYER_DESKTOP; - + group = meta_window_get_group (window); if (group != NULL) members = meta_group_list_windows (group); else members = NULL; - + tmp = members; while (tmp != NULL) { @@ -307,12 +307,12 @@ get_maximum_layer_in_group (MetaWindow *window) layer = get_standalone_layer (w); if (layer > max) max = layer; - + tmp = tmp->next; } g_slist_free (members); - + return max; } @@ -320,7 +320,7 @@ static void compute_layer (MetaWindow *window) { window->layer = get_standalone_layer (window); - + /* We can only do promotion-due-to-group for dialogs and other * transients, or weird stuff happens like the desktop window and * nautilus windows getting in the same layer, or all gnome-terminal @@ -336,11 +336,11 @@ compute_layer (MetaWindow *window) * and a dialog transient for the normal window; you don't want the dialog * above the dock if it wouldn't normally be. */ - + MetaStackLayer group_max; - + group_max = get_maximum_layer_in_group (window); - + if (group_max > window->layer) { meta_topic (META_DEBUG_STACK, @@ -377,10 +377,10 @@ compare_window_position (void *a, else return 0; /* not reached */ } - + /* * Stacking constraints - * + * * Assume constraints of the form "AB" meaning "window A must be * below window B" * @@ -397,14 +397,14 @@ compare_window_position (void *a, * apply BC: ABC * * but apply constraints in the wrong order and it breaks: - * + * * start: BCA * apply BC: BCA * apply AB: CAB * * We make a directed graph of the constraints by linking * from "above windows" to "below windows as follows: - * + * * AB -> BC -> CD * \ * CE @@ -429,7 +429,7 @@ struct Constraint /* used to create the graph. */ GSList *next_nodes; - + /* constraint has been applied, used * to detect cycles. */ @@ -457,7 +457,7 @@ add_constraint (Constraint **constraints, Constraint *c; g_assert (above->screen == below->screen); - + /* check if constraint is a duplicate */ c = constraints[below->stack_position]; while (c != NULL) @@ -484,7 +484,7 @@ create_constraints (Constraint **constraints, GList *windows) { GList *tmp; - + tmp = windows; while (tmp != NULL) { @@ -497,7 +497,7 @@ create_constraints (Constraint **constraints, tmp = tmp->next; continue; } - + if (WINDOW_TRANSIENT_FOR_WHOLE_GROUP (w)) { GSList *group_windows; @@ -510,9 +510,9 @@ create_constraints (Constraint **constraints, group_windows = meta_group_list_windows (group); else group_windows = NULL; - + tmp2 = group_windows; - + while (tmp2 != NULL) { MetaWindow *group_window = tmp2->data; @@ -523,7 +523,7 @@ create_constraints (Constraint **constraints, tmp2 = tmp2->next; continue; } - + #if 0 /* old way of doing it */ if (!(meta_window_is_ancestor_of_transient (w, group_window)) && @@ -539,7 +539,7 @@ create_constraints (Constraint **constraints, w->desc, group_window->desc); add_constraint (constraints, w, group_window); } - + tmp2 = tmp2->next; } @@ -549,7 +549,7 @@ create_constraints (Constraint **constraints, !w->transient_parent_is_root_window) { MetaWindow *parent; - + parent = meta_display_lookup_x_window (w->display, w->xtransient_for); @@ -561,7 +561,7 @@ create_constraints (Constraint **constraints, add_constraint (constraints, w, parent); } } - + tmp = tmp->next; } } @@ -580,12 +580,12 @@ graph_constraints (Constraint **constraints, /* If we have "A below B" and "B below C" then AB -> BC so we * add BC to next_nodes in AB. */ - + c = constraints[i]; while (c != NULL) { Constraint *n; - + g_assert (c->below->stack_position == i); /* Constraints where ->above is below are our @@ -598,10 +598,10 @@ graph_constraints (Constraint **constraints, n); /* c is a previous node of n */ n->has_prev = TRUE; - + n = n->next; } - + c = c->next; } @@ -619,16 +619,16 @@ free_constraints (Constraint **constraints, while (i < n_constraints) { Constraint *c; - + c = constraints[i]; while (c != NULL) { Constraint *next = c->next; - + g_slist_free (c->next_nodes); g_free (c); - + c = next; } @@ -639,7 +639,7 @@ free_constraints (Constraint **constraints, static void ensure_above (MetaWindow *above, MetaWindow *below) -{ +{ if (WINDOW_HAS_TRANSIENT_TYPE(above) && above->layer < below->layer) { @@ -667,10 +667,10 @@ traverse_constraint (Constraint *c) if (c->applied) return; - + ensure_above (c->above, c->below); c->applied = TRUE; - + tmp = c->next_nodes; while (tmp != NULL) { @@ -694,13 +694,13 @@ apply_constraints (Constraint **constraints, while (i < n_constraints) { Constraint *c; - + c = constraints[i]; while (c != NULL) { if (!c->has_prev) heads = g_slist_prepend (heads, c); - + c = c->next; } @@ -714,7 +714,7 @@ apply_constraints (Constraint **constraints, Constraint *c = tmp->data; traverse_constraint (c); - + tmp = tmp->next; } @@ -733,7 +733,7 @@ stack_do_window_deletions (MetaStack *stack) */ GList *tmp; int i; - + tmp = stack->removed; while (tmp != NULL) { @@ -747,7 +747,7 @@ stack_do_window_deletions (MetaStack *stack) while (i > 0) { --i; - + /* there's no guarantee we'll actually find windows to * remove, e.g. the same xwindow could have been * added/removed before we ever synced, and we put @@ -784,34 +784,34 @@ stack_do_window_additions (MetaStack *stack) meta_topic (META_DEBUG_STACK, "Adding %d windows to sorted list\n", n_added); - + old_size = stack->windows->len; g_array_set_size (stack->windows, old_size + n_added); - + end = &g_array_index (stack->windows, Window, old_size); /* stack->added has the most recent additions at the * front of the list, so we need to reverse it */ stack->added = g_list_reverse (stack->added); - + i = 0; tmp = stack->added; while (tmp != NULL) { MetaWindow *w; - + w = tmp->data; - + end[i] = w->xwindow; /* add to the main list */ stack->sorted = g_list_prepend (stack->sorted, w); - + ++i; tmp = tmp->next; } - + stack->need_resort = TRUE; /* may not be needed as we add to top */ stack->need_constrain = TRUE; stack->need_relayer = TRUE; @@ -828,13 +828,13 @@ static void stack_do_relayer (MetaStack *stack) { GList *tmp; - + if (!stack->need_relayer) return; - + meta_topic (META_DEBUG_STACK, "Recomputing layers\n"); - + tmp = stack->sorted; while (tmp != NULL) @@ -852,7 +852,7 @@ stack_do_relayer (MetaStack *stack) meta_topic (META_DEBUG_STACK, "Window %s moved from layer %u to %u\n", w->desc, old_layer, w->layer); - + stack->need_resort = TRUE; stack->need_constrain = TRUE; /* don't need to constrain as constraining @@ -860,7 +860,7 @@ stack_do_relayer (MetaStack *stack) * not layer */ } - + tmp = tmp->next; } @@ -877,7 +877,7 @@ stack_do_constrain (MetaStack *stack) Constraint **constraints; /* It'd be nice if this were all faster, probably */ - + if (!stack->need_constrain) return; @@ -892,10 +892,10 @@ stack_do_constrain (MetaStack *stack) graph_constraints (constraints, stack->n_positions); apply_constraints (constraints, stack->n_positions); - + free_constraints (constraints, stack->n_positions); g_free (constraints); - + stack->need_constrain = FALSE; } @@ -907,10 +907,10 @@ stack_do_resort (MetaStack *stack) { if (!stack->need_resort) return; - + meta_topic (META_DEBUG_STACK, "Sorting stack list\n"); - + stack->sorted = g_list_sort (stack->sorted, (GCompareFunc) compare_window_position); @@ -961,9 +961,9 @@ raise_window_relative_to_managed_windows (MetaScreen *screen, * we don't, since we know we won't manage any new windows * or restack any windows before using the XQueryTree results. */ - + meta_error_trap_push_with_return (screen->display); - + XQueryTree (screen->display->xdisplay, screen->xroot, &ignored1, &ignored2, &children, &n_children); @@ -999,7 +999,7 @@ raise_window_relative_to_managed_windows (MetaScreen *screen, children[i]) != NULL) { XWindowChanges changes; - + /* children[i] is the topmost managed child */ meta_topic (META_DEBUG_STACK, "Moving 0x%lx above topmost managed child window 0x%lx\n", @@ -1031,7 +1031,7 @@ raise_window_relative_to_managed_windows (MetaScreen *screen, xwindow); meta_error_trap_pop (screen->display, FALSE); } - + if (children) XFree (children); } @@ -1049,15 +1049,15 @@ stack_sync_to_server (MetaStack *stack) GArray *stacked; GArray *root_children_stacked; GList *tmp; - + /* Bail out if frozen */ if (stack->freeze_count > 0) return; - - meta_topic (META_DEBUG_STACK, "Syncing window stack to server\n"); + + meta_topic (META_DEBUG_STACK, "Syncing window stack to server\n"); stack_ensure_sorted (stack); - + /* Create stacked xwindow arrays. * Painfully, "stacked" is in bottom-to-top order for the * _NET hints, and "root_children_stacked" is in top-to-bottom @@ -1068,25 +1068,25 @@ stack_sync_to_server (MetaStack *stack) meta_topic (META_DEBUG_STACK, "Top to bottom: "); meta_push_no_msg_prefix (); - + tmp = stack->sorted; while (tmp != NULL) { MetaWindow *w; - + w = tmp->data; - + /* remember, stacked is in reverse order (bottom to top) */ g_array_prepend_val (stacked, w->xwindow); - + /* build XRestackWindows() array from top to bottom */ if (w->frame) g_array_append_val (root_children_stacked, w->frame->xwindow); else g_array_append_val (root_children_stacked, w->xwindow); - + meta_topic (META_DEBUG_STACK, "%u:%d - %s ", w->layer, w->stack_position, w->desc); - + tmp = tmp->next; } @@ -1097,12 +1097,12 @@ stack_sync_to_server (MetaStack *stack) if (stacked->len != stack->windows->len) meta_bug ("%u windows stacked, %u windows exist in stack\n", stacked->len, stack->windows->len); - + /* Sync to server */ meta_topic (META_DEBUG_STACK, "Restacking %u windows\n", root_children_stacked->len); - + meta_error_trap_push (stack->screen->display); if (stack->last_root_children_stacked == NULL) @@ -1134,7 +1134,7 @@ stack_sync_to_server (MetaStack *stack) const Window *old_end = old_stack + old_len; const Window *new_end = new_stack + new_len; Window last_window = None; - + while (oldp != old_end && newp != new_end) { @@ -1169,7 +1169,7 @@ stack_sync_to_server (MetaStack *stack) * *newp, then we fail to restack *newp; but on * unmanaging last_window, we'll fix it up. */ - + XWindowChanges changes; changes.sibling = last_window; @@ -1177,7 +1177,7 @@ stack_sync_to_server (MetaStack *stack) meta_topic (META_DEBUG_STACK, "Placing window 0x%lx below 0x%lx\n", *newp, last_window); - + XConfigureWindow (stack->screen->display->xdisplay, *newp, CWSibling | CWStackMode, @@ -1210,7 +1210,7 @@ stack_sync_to_server (MetaStack *stack) * get removed from the stacking list when we unmanage it * and we'll fix stacking at that time. */ - + /* Sync _NET_CLIENT_LIST and _NET_CLIENT_LIST_STACKING */ XChangeProperty (stack->screen->display->xdisplay, @@ -1233,7 +1233,7 @@ stack_sync_to_server (MetaStack *stack) if (stack->last_root_children_stacked) g_array_free (stack->last_root_children_stacked, TRUE); stack->last_root_children_stacked = root_children_stacked; - + /* That was scary... */ } @@ -1269,9 +1269,9 @@ meta_stack_get_above (MetaStack *stack, { GList *link; MetaWindow *above; - + stack_ensure_sorted (stack); - + link = g_list_find (stack->sorted, window); if (link == NULL) return NULL; @@ -1294,7 +1294,7 @@ meta_stack_get_below (MetaStack *stack, { GList *link; MetaWindow *below; - + stack_ensure_sorted (stack); link = g_list_find (stack->sorted, window); @@ -1303,7 +1303,7 @@ meta_stack_get_below (MetaStack *stack, return NULL; if (link->next == NULL) return NULL; - + below = link->next->data; if (only_within_layer && @@ -1345,7 +1345,7 @@ get_default_focus_window (MetaStack *stack, MetaWindow *topmost_overall; MetaGroup *not_this_one_group; GList *link; - + topmost_dock = NULL; transient_parent = NULL; topmost_in_group = NULL; @@ -1359,7 +1359,7 @@ get_default_focus_window (MetaStack *stack, /* top of this layer is at the front of the list */ link = stack->sorted; - + while (link) { MetaWindow *window = link->data; @@ -1447,22 +1447,22 @@ meta_stack_list_windows (MetaStack *stack, { GList *workspace_windows = NULL; GList *link; - + stack_ensure_sorted (stack); /* do adds/removes */ - + link = stack->sorted; - + while (link) { MetaWindow *window = link->data; - + if (window && (workspace == NULL || meta_window_located_on_workspace (window, workspace))) { workspace_windows = g_list_prepend (workspace_windows, window); } - + link = link->next; } @@ -1479,7 +1479,7 @@ meta_stack_windows_cmp (MetaStack *stack, /* -1 means a below b */ stack_ensure_sorted (stack); /* update constraints, layers */ - + if (window_a->layer < window_b->layer) return -1; else if (window_a->layer > window_b->layer) @@ -1529,7 +1529,7 @@ compare_pointers (gconstpointer a, return 1; else if (a < b) return -1; - else + else return 0; } @@ -1567,7 +1567,7 @@ meta_stack_set_positions (MetaStack *stack, /* Make sure any adds or removes aren't in limbo -- is this needed? */ stack_ensure_sorted (stack); - + if (!lists_contain_same_windows (windows, stack->sorted)) { meta_warning ("This list of windows has somehow changed; not resetting " @@ -1580,7 +1580,7 @@ meta_stack_set_positions (MetaStack *stack, stack->need_resort = TRUE; stack->need_constrain = TRUE; - + i = 0; tmp = windows; while (tmp != NULL) @@ -1589,7 +1589,7 @@ meta_stack_set_positions (MetaStack *stack, w->stack_position = i++; tmp = tmp->next; } - + meta_topic (META_DEBUG_STACK, "Reset the stack positions of (nearly) all windows\n"); @@ -1602,7 +1602,7 @@ meta_window_set_stack_position_no_sync (MetaWindow *window, { int low, high, delta; GList *tmp; - + g_return_if_fail (window->screen->stack != NULL); g_return_if_fail (window->stack_position >= 0); g_return_if_fail (position >= 0); @@ -1617,7 +1617,7 @@ meta_window_set_stack_position_no_sync (MetaWindow *window, window->screen->stack->need_resort = TRUE; window->screen->stack->need_constrain = TRUE; - + if (position < window->stack_position) { low = position; @@ -1642,7 +1642,7 @@ meta_window_set_stack_position_no_sync (MetaWindow *window, tmp = tmp->next; } - + window->stack_position = position; meta_topic (META_DEBUG_STACK, |