[mutter/meego-1.0: 14/30] [MetaScreen] Keep num_workspaces key in sync with the actual workspace number



commit 07802510fb2a7bc059f9ba4650959a680d457dae
Author: Tomas Frydrych <tf linux intel com>
Date:   Thu Feb 11 10:06:38 2010 +0000

    [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.

 src/core/screen.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)
---
diff --git a/src/core/screen.c b/src/core/screen.c
index b010be7..5876a24 100644
--- a/src/core/screen.c
+++ b/src/core/screen.c
@@ -1267,6 +1267,7 @@ meta_screen_remove_workspace (MetaScreen *screen, MetaWorkspace *workspace,
   MetaWorkspace *neighbour = NULL;
   GList         *next = NULL;
   int index;
+  gint           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;
+  gint 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;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]