Prevent windows from having the same stack index
authorAlberto Garcia <agarcia@igalia.com>
Thu, 18 Jun 2009 16:29:05 +0000 (18:29 +0200)
committerAlberto Garcia <agarcia@igalia.com>
Thu, 18 Jun 2009 16:37:52 +0000 (18:37 +0200)
* hildon/hildon-window-stack.c
(hildon_window_stack_pop_and_push_list):
Prevent windows from having the same stack index

ChangeLog
hildon/hildon-window-stack.c

index 926e85c..a3846b4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2009-06-18  Alberto Garcia  <agarcia@igalia.com>
 
+       * hildon/hildon-window-stack.c
+       (hildon_window_stack_pop_and_push_list):
+       Prevent windows from having the same stack index
+
+2009-06-18  Alberto Garcia  <agarcia@igalia.com>
+
        * hildon/hildon-window-stack.c (_hildon_window_stack_do_push):
        Use the index of the previous window rather than the stack length
        to calculate the new index.
index a7a6182..681265d 100644 (file)
@@ -511,15 +511,20 @@ hildon_window_stack_pop_and_push_list           (HildonWindowStack  *stack,
                                                  GList             **popped_windows,
                                                  GList              *list)
 {
-    gint i;
+    gint i, topmost_index;
     GList *l;
     GList *popped = NULL;
     GList *pushed = NULL;
+    HildonStackableWindowPrivate *priv;
 
     g_return_if_fail (HILDON_IS_WINDOW_STACK (stack));
     g_return_if_fail (nwindows > 0);
     g_return_if_fail (g_list_length (stack->priv->list) >= nwindows);
 
+    /* Store the index of the topmost window */
+    priv = HILDON_STACKABLE_WINDOW_GET_PRIVATE (hildon_window_stack_peek (stack));
+    topmost_index = priv->stack_position;
+
     /* Pop windows */
     for (i = 0; i < nwindows; i++) {
         GtkWidget *win = _hildon_window_stack_do_pop (stack);
@@ -537,6 +542,15 @@ hildon_window_stack_pop_and_push_list           (HildonWindowStack  *stack,
         }
     }
 
+    if (pushed != NULL) {
+        /* The WM will be confused if the old topmost window and the new
+         * one have the same index, so make sure that they're different */
+        priv = HILDON_STACKABLE_WINDOW_GET_PRIVATE (hildon_window_stack_peek (stack));
+        if (priv->stack_position == topmost_index) {
+            priv->stack_position++;
+        }
+    }
+
     /* Show windows in reverse order (topmost first) */
     g_list_foreach (pushed, (GFunc) gtk_widget_show, NULL);