From fc9488211f689e7f8802345d753d70e5f5cd4025 Mon Sep 17 00:00:00 2001 From: Tomas Frydrych Date: Thu, 11 Feb 2010 10:06:38 +0000 Subject: [PATCH] [MetaScreen] Keep num_workspaces key in sync with the actual workspace number Changing the number of workspaces via an external pager relies on the gconf key; if a plugin adds or removes workspaces on the fly, we can get into a situation when the stale number stored by the preferences matches the new number requested by the pager, in which case the pager request becomes a nop. This commit ensures that when the meta_screen_append_new_workspace() or meta_screen_remove_workspace() functions are called, the stored value is updated accordingly. https://bugzilla.gnome.org/show_bug.cgi?id=613127 --- src/core/screen.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/core/screen.c b/src/core/screen.c index 7ac65d0fa..7f1a152c1 100644 --- a/src/core/screen.c +++ b/src/core/screen.c @@ -1266,7 +1266,8 @@ meta_screen_remove_workspace (MetaScreen *screen, MetaWorkspace *workspace, GList *l; MetaWorkspace *neighbour = NULL; GList *next = NULL; - int index; + int index; + int new_num; l = screen->workspaces; while (l) @@ -1308,7 +1309,10 @@ meta_screen_remove_workspace (MetaScreen *screen, MetaWorkspace *workspace, /* This also removes the workspace from the screens list */ meta_workspace_remove (workspace); - set_number_of_spaces_hint (screen, g_list_length (screen->workspaces)); + new_num = g_list_length (screen->workspaces); + + set_number_of_spaces_hint (screen, new_num); + meta_prefs_set_num_workspaces (new_num); l = next; while (l) @@ -1344,6 +1348,7 @@ meta_screen_append_new_workspace (MetaScreen *screen, gboolean activate, guint32 timestamp) { MetaWorkspace *w; + int new_num; /* This also adds the workspace to the screen list */ w = meta_workspace_new (screen); @@ -1354,7 +1359,10 @@ meta_screen_append_new_workspace (MetaScreen *screen, gboolean activate, if (activate) meta_workspace_activate (w, timestamp); - set_number_of_spaces_hint (screen, g_list_length (screen->workspaces)); + new_num = g_list_length (screen->workspaces); + + set_number_of_spaces_hint (screen, new_num); + meta_prefs_set_num_workspaces (new_num); meta_screen_queue_workarea_recalc (screen); @@ -1381,6 +1389,9 @@ update_num_workspaces (MetaScreen *screen, g_assert (new_num > 0); + if (g_list_length (screen->workspaces) == (guint) new_num) + return; + last_remaining = NULL; extras = NULL; i = 0;