summaryrefslogtreecommitdiff
path: root/src/stack.c
diff options
context:
space:
mode:
authorrhp <rhp>2001-06-24 03:18:10 +0000
committerrhp <rhp>2001-06-24 03:18:10 +0000
commitbeaac99991700466a367a70c13fade581c175f7d (patch)
tree466c3574a30b43f6d4760af100cb479e8c945fa1 /src/stack.c
parent41a817f11a0b7516a49376ccb0915f457f82882b (diff)
downloadmetacity-beaac99991700466a367a70c13fade581c175f7d.tar.gz
metacity-beaac99991700466a367a70c13fade581c175f7d.tar.bz2
...
Diffstat (limited to 'src/stack.c')
-rw-r--r--src/stack.c99
1 files changed, 99 insertions, 0 deletions
diff --git a/src/stack.c b/src/stack.c
index 89f881b..be6784d 100644
--- a/src/stack.c
+++ b/src/stack.c
@@ -661,3 +661,102 @@ meta_stack_sync_to_server (MetaStack *stack)
/* That was scary... */
}
+static MetaWindow*
+find_next_above_layer (MetaStack *stack,
+ int layer)
+{
+ ++layer;
+ while (layer < META_LAYER_LAST)
+ {
+ GList *link;
+
+ g_assert (layer >= 0 && layer < META_LAYER_LAST);
+
+ /* bottom of this layer is at the end of the list */
+ link = g_list_last (stack->layers[layer]);
+
+ if (link)
+ return link->data;
+
+ ++layer;
+ }
+
+ return NULL;
+}
+
+static MetaWindow*
+find_prev_below_layer (MetaStack *stack,
+ int layer)
+{
+ --layer;
+ while (layer >= 0)
+ {
+ GList *link;
+
+ g_assert (layer >= 0 && layer < META_LAYER_LAST);
+
+ /* top of this layer is at the front of the list */
+ link = stack->layers[layer];
+
+ if (link)
+ return link->data;
+
+ --layer;
+ }
+
+ return NULL;
+}
+
+MetaWindow*
+meta_stack_get_top (MetaStack *stack)
+{
+ /* FIXME if stack is frozen this is kind of broken. */
+
+ return find_prev_below_layer (stack, META_LAYER_LAST);
+}
+
+MetaWindow*
+meta_stack_get_bottom (MetaStack *stack)
+{
+ /* FIXME if stack is frozen this is kind of broken. */
+
+ return find_next_above_layer (stack, -1);
+}
+
+MetaWindow*
+meta_stack_get_above (MetaStack *stack,
+ MetaWindow *window)
+{
+ GList *link;
+
+ /* FIXME if stack is frozen this is kind of broken. */
+
+ g_assert (window->layer >= 0 && window->layer < META_LAYER_LAST);
+ link = g_list_find (stack->layers[window->layer], window);
+ if (link == NULL)
+ return NULL;
+
+ if (link->prev)
+ return link->prev->data;
+ else
+ return find_next_above_layer (stack, window->layer);
+}
+
+MetaWindow*
+meta_stack_get_below (MetaStack *stack,
+ MetaWindow *window)
+{
+ GList *link;
+
+ /* FIXME if stack is frozen this is kind of broken. */
+
+ g_assert (window->layer >= 0 && window->layer < META_LAYER_LAST);
+ link = g_list_find (stack->layers[window->layer], window);
+ if (link == NULL)
+ return NULL;
+
+ if (link->next)
+ return link->next->data;
+ else
+ return find_prev_below_layer (stack, window->layer);
+}