summaryrefslogtreecommitdiff
path: root/src/core/stack.c
diff options
context:
space:
mode:
authorJoaquín Ignacio Aramendía <[email protected]>2014-06-25 19:06:17 -0300
committerJoaquín Ignacio Aramendía <[email protected]>2014-06-26 20:03:32 -0300
commita65a66d49bd0d6ec6c94b8e3ecd551cb570cec95 (patch)
treeb451afa6025e587f0ee287601427e572712e3428 /src/core/stack.c
parent32050fd47713d9254e05344a6afd87202fa45d11 (diff)
downloadmarco-a65a66d49bd0d6ec6c94b8e3ecd551cb570cec95.tar.bz2
marco-a65a66d49bd0d6ec6c94b8e3ecd551cb570cec95.tar.xz
Remove all trailing whitespaces in the code tree
Just run: $ find -name '*.c' -print0 | xargs -r0 sed -e 's/[[:blank:]]\+$//' -i $ find -name '*.h' -print0 | xargs -r0 sed -e 's/[[:blank:]]\+$//' -i
Diffstat (limited to 'src/core/stack.c')
-rw-r--r--src/core/stack.c226
1 files changed, 113 insertions, 113 deletions
diff --git a/src/core/stack.c b/src/core/stack.c
index 2a1dd8e5..9ab4d60e 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, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
@@ -66,7 +66,7 @@ MetaStack*
meta_stack_new (MetaScreen *screen)
{
MetaStack *stack;
-
+
stack = g_new (MetaStack, 1);
stack->screen = screen;
@@ -84,7 +84,7 @@ meta_stack_new (MetaScreen *screen)
stack->need_resort = FALSE;
stack->need_relayer = FALSE;
stack->need_constrain = FALSE;
-
+
return stack;
}
@@ -99,7 +99,7 @@ meta_stack_free (MetaStack *stack)
if (stack->last_root_children_stacked)
g_array_free (stack->last_root_children_stacked, TRUE);
-
+
g_free (stack);
}
@@ -111,7 +111,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;
@@ -119,7 +119,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);
}
@@ -139,7 +139,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);
@@ -154,7 +154,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);
}
@@ -163,7 +163,7 @@ meta_stack_update_layer (MetaStack *stack,
MetaWindow *window)
{
stack->need_relayer = TRUE;
-
+
stack_sync_to_server (stack);
}
@@ -172,7 +172,7 @@ meta_stack_update_transient (MetaStack *stack,
MetaWindow *window)
{
stack->need_constrain = TRUE;
-
+
stack_sync_to_server (stack);
}
@@ -180,10 +180,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);
}
@@ -192,7 +192,7 @@ meta_stack_lower (MetaStack *stack,
MetaWindow *window)
{
meta_window_set_stack_position_no_sync (window, 0);
-
+
stack_sync_to_server (stack);
}
@@ -206,7 +206,7 @@ void
meta_stack_thaw (MetaStack *stack)
{
g_return_if_fail (stack->freeze_count > 0);
-
+
stack->freeze_count -= 1;
stack_sync_to_server (stack);
}
@@ -240,7 +240,7 @@ get_standalone_layer (MetaWindow *window)
{
MetaStackLayer layer;
gboolean focused_transient = FALSE;
-
+
switch (window->type)
{
case META_WINDOW_DESKTOP:
@@ -255,7 +255,7 @@ get_standalone_layer (MetaWindow *window)
layer = META_LAYER_DOCK;
break;
- default:
+ default:
meta_window_foreach_transient (window,
is_focused_foreach,
&focused_transient);
@@ -291,16 +291,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)
{
@@ -309,12 +309,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;
}
@@ -322,7 +322,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
* caja windows getting in the same layer, or all mate-terminal
@@ -338,11 +338,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,
@@ -379,10 +379,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"
*
@@ -399,14 +399,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
@@ -431,7 +431,7 @@ struct Constraint
/* used to create the graph. */
GSList *next_nodes;
-
+
/* constraint has been applied, used
* to detect cycles.
*/
@@ -459,7 +459,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)
@@ -486,7 +486,7 @@ create_constraints (Constraint **constraints,
GList *windows)
{
GList *tmp;
-
+
tmp = windows;
while (tmp != NULL)
{
@@ -499,7 +499,7 @@ create_constraints (Constraint **constraints,
tmp = tmp->next;
continue;
}
-
+
if (WINDOW_TRANSIENT_FOR_WHOLE_GROUP (w))
{
GSList *group_windows;
@@ -512,9 +512,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;
@@ -525,7 +525,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)) &&
@@ -541,7 +541,7 @@ create_constraints (Constraint **constraints,
w->desc, group_window->desc);
add_constraint (constraints, w, group_window);
}
-
+
tmp2 = tmp2->next;
}
@@ -551,7 +551,7 @@ create_constraints (Constraint **constraints,
!w->transient_parent_is_root_window)
{
MetaWindow *parent;
-
+
parent =
meta_display_lookup_x_window (w->display, w->xtransient_for);
@@ -563,7 +563,7 @@ create_constraints (Constraint **constraints,
add_constraint (constraints, w, parent);
}
}
-
+
tmp = tmp->next;
}
}
@@ -582,12 +582,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
@@ -600,10 +600,10 @@ graph_constraints (Constraint **constraints,
n);
/* c is a previous node of n */
n->has_prev = TRUE;
-
+
n = n->next;
}
-
+
c = c->next;
}
@@ -621,16 +621,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;
}
@@ -641,7 +641,7 @@ free_constraints (Constraint **constraints,
static void
ensure_above (MetaWindow *above,
MetaWindow *below)
-{
+{
if (WINDOW_HAS_TRANSIENT_TYPE(above) &&
above->layer < below->layer)
{
@@ -669,10 +669,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)
{
@@ -696,13 +696,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;
}
@@ -716,7 +716,7 @@ apply_constraints (Constraint **constraints,
Constraint *c = tmp->data;
traverse_constraint (c);
-
+
tmp = tmp->next;
}
@@ -735,7 +735,7 @@ stack_do_window_deletions (MetaStack *stack)
*/
GList *tmp;
int i;
-
+
tmp = stack->removed;
while (tmp != NULL)
{
@@ -749,7 +749,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
@@ -786,34 +786,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;
@@ -830,13 +830,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)
@@ -854,7 +854,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
@@ -862,7 +862,7 @@ stack_do_relayer (MetaStack *stack)
* not layer
*/
}
-
+
tmp = tmp->next;
}
@@ -879,7 +879,7 @@ stack_do_constrain (MetaStack *stack)
Constraint **constraints;
/* It'd be nice if this were all faster, probably */
-
+
if (!stack->need_constrain)
return;
@@ -894,10 +894,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;
}
@@ -909,10 +909,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);
@@ -963,9 +963,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);
@@ -1001,7 +1001,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",
@@ -1033,7 +1033,7 @@ raise_window_relative_to_managed_windows (MetaScreen *screen,
xwindow);
meta_error_trap_pop (screen->display, FALSE);
}
-
+
if (children)
XFree (children);
}
@@ -1051,15 +1051,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
@@ -1070,25 +1070,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;
}
@@ -1099,12 +1099,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)
@@ -1136,7 +1136,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)
{
@@ -1171,7 +1171,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;
@@ -1179,7 +1179,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,
@@ -1212,7 +1212,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,
@@ -1235,7 +1235,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... */
}
@@ -1271,9 +1271,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;
@@ -1296,7 +1296,7 @@ meta_stack_get_below (MetaStack *stack,
{
GList *link;
MetaWindow *below;
-
+
stack_ensure_sorted (stack);
link = g_list_find (stack->sorted, window);
@@ -1305,7 +1305,7 @@ meta_stack_get_below (MetaStack *stack,
return NULL;
if (link->next == NULL)
return NULL;
-
+
below = link->next->data;
if (only_within_layer &&
@@ -1347,7 +1347,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;
@@ -1361,7 +1361,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;
@@ -1449,22 +1449,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;
}
@@ -1481,7 +1481,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)
@@ -1531,7 +1531,7 @@ compare_pointers (gconstpointer a,
return 1;
else if (a < b)
return -1;
- else
+ else
return 0;
}
@@ -1569,7 +1569,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 "
@@ -1582,7 +1582,7 @@ meta_stack_set_positions (MetaStack *stack,
stack->need_resort = TRUE;
stack->need_constrain = TRUE;
-
+
i = 0;
tmp = windows;
while (tmp != NULL)
@@ -1591,7 +1591,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");
@@ -1604,7 +1604,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);
@@ -1619,7 +1619,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;
@@ -1644,7 +1644,7 @@ meta_window_set_stack_position_no_sync (MetaWindow *window,
tmp = tmp->next;
}
-
+
window->stack_position = position;
meta_topic (META_DEBUG_STACK,