From 3f7d729978be9032d31c3e25c7c4cef4dffe610f Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Mon, 16 Apr 2007 04:57:32 +0000 Subject: [PATCH] Preserve stacking order across restarts. 2007-04-15 Elijah Newren Preserve stacking order across restarts. * src/display.c (meta_display_unmanage_windows_for_screen): unmap windows in stacking order so that stacking is preserved upon shutdown * src/display.[ch] (meta_display_stack_cmp): * src/session.c (stack_cmp, save_state): rename stack_cmp() -> meta_display_stack_cmp() and move it to a different function so that it can be used in both session.c:save_state() and meta_display_unmanage_windows_for_screen() svn path=/trunk/; revision=3197 --- ChangeLog | 15 +++++++++++++++ src/display.c | 19 +++++++++++++++++++ src/display.h | 4 ++++ src/session.c | 20 +------------------- 4 files changed, 39 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index a9a0987d0..af46ec159 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2007-04-15 Elijah Newren + + Preserve stacking order across restarts. + + * src/display.c (meta_display_unmanage_windows_for_screen): + unmap windows in stacking order so that stacking is preserved upon + shutdown + + * src/display.[ch] (meta_display_stack_cmp): + * src/session.c (stack_cmp, save_state): + rename stack_cmp() -> meta_display_stack_cmp() and move it to a + different function so that it can be used in both + session.c:save_state() and + meta_display_unmanage_windows_for_screen() + 2007-04-15 Elijah Newren Remove incorrect usage of window.h from menu.c. See #426791 & diff --git a/src/display.c b/src/display.c index 637e60b9e..15f42395f 100644 --- a/src/display.c +++ b/src/display.c @@ -4702,6 +4702,7 @@ meta_display_unmanage_windows_for_screen (MetaDisplay *display, GSList *winlist; winlist = meta_display_list_windows (display); + winlist = g_slist_sort (winlist, meta_display_stack_cmp); /* Unmanage all windows */ tmp = winlist; @@ -4714,6 +4715,24 @@ meta_display_unmanage_windows_for_screen (MetaDisplay *display, g_slist_free (winlist); } +int +meta_display_stack_cmp (const void *a, + const void *b) +{ + MetaWindow *aw = (void*) a; + MetaWindow *bw = (void*) b; + + if (aw->screen == bw->screen) + return meta_stack_windows_cmp (aw->screen->stack, aw, bw); + /* Then assume screens are stacked by number */ + else if (aw->screen->number < bw->screen->number) + return -1; + else if (aw->screen->number > bw->screen->number) + return 1; + else + return 0; /* not reached in theory, if windows on same display */ +} + void meta_display_devirtualize_modifiers (MetaDisplay *display, MetaVirtualModifier modifiers, diff --git a/src/display.h b/src/display.h index b934d7180..14bd4eee8 100644 --- a/src/display.h +++ b/src/display.h @@ -416,6 +416,10 @@ void meta_display_unmanage_windows_for_screen (MetaDisplay *display, MetaScreen *screen, guint32 timestamp); +/* Utility function to compare the stacking of two windows */ +int meta_display_stack_cmp (const void *a, + const void *b); + /* A given MetaWindow may have various X windows that "belong" * to it, such as the frame window. */ diff --git a/src/session.c b/src/session.c index dc2d6fd5c..4c247509a 100644 --- a/src/session.c +++ b/src/session.c @@ -801,24 +801,6 @@ decode_text_from_utf8 (const char *text) return g_string_free (str, FALSE); } -static int -stack_cmp (const void *a, - const void *b) -{ - MetaWindow *aw = (void*) a; - MetaWindow *bw = (void*) b; - - if (aw->screen == bw->screen) - return meta_stack_windows_cmp (aw->screen->stack, aw, bw); - /* Then assume screens are stacked by number */ - else if (aw->screen->number < bw->screen->number) - return -1; - else if (aw->screen->number > bw->screen->number) - return 1; - else - return 0; /* not reached in theory, if windows on same display */ -} - static void save_state (void) { @@ -891,7 +873,7 @@ save_state (void) int stack_position; windows = meta_display_list_windows (display_iter->data); - windows = g_slist_sort (windows, stack_cmp); + windows = g_slist_sort (windows, meta_display_stack_cmp); stack_position = 0; tmp = windows;