[mutter] screen: Split workspace initialization from meta_screen_new()



commit 8100cefd4c34a366af404f9ec022917f7b2fbc45
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Jun 5 22:28:56 2014 +0200

    screen: Split workspace initialization from meta_screen_new()
    
    Since commit 8b2b65246a86, we assume that the compositor always
    exists. Alas, the assumption is wrong - the compositor is currently
    initialized after the screen, but meta_screen_new() itself may
    call a compositor function if initialization involves a workspace
    switch (which will happen when meta_workspace_activate() is called
    more than once and for different workspaces - or in other words,
    when _NET_CURRENT_DESKTOP is set and not 0).
    So carefully split out the offending bits and only call them after
    the compositor has been initialized.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=731332

 src/core/display.c        |    1 +
 src/core/screen-private.h |    1 +
 src/core/screen.c         |   62 +++++++++++++++++++++++++-------------------
 3 files changed, 37 insertions(+), 27 deletions(-)
---
diff --git a/src/core/display.c b/src/core/display.c
index c185762..017d541 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -805,6 +805,7 @@ meta_display_open (void)
 
   enable_compositor (the_display);
 
+  meta_screen_init_workspaces (screen);
   meta_screen_create_guard_window (screen);
 
   /* We know that if mutter is running as a Wayland compositor,
diff --git a/src/core/screen-private.h b/src/core/screen-private.h
index c312599..766af4b 100644
--- a/src/core/screen-private.h
+++ b/src/core/screen-private.h
@@ -135,6 +135,7 @@ MetaScreen*   meta_screen_new                 (MetaDisplay                *displ
                                                guint32                     timestamp);
 void          meta_screen_free                (MetaScreen                 *screen,
                                                guint32                     timestamp);
+void          meta_screen_init_workspaces     (MetaScreen                 *screen);
 void          meta_screen_manage_all_windows  (MetaScreen                 *screen);
 void          meta_screen_foreach_window      (MetaScreen                 *screen,
                                                MetaScreenWindowFunc        func,
diff --git a/src/core/screen.c b/src/core/screen.c
index afc3ca9..e47115c 100644
--- a/src/core/screen.c
+++ b/src/core/screen.c
@@ -506,7 +506,6 @@ meta_screen_new (MetaDisplay *display,
   Atom wm_sn_atom;
   char buf[128];
   guint32 manager_timestamp;
-  gulong current_workspace;
   MetaMonitorManager *manager;
 
   replace_current_wm = meta_get_replace_current_wm ();
@@ -721,24 +720,10 @@ meta_screen_new (MetaDisplay *display,
 
   meta_screen_update_workspace_layout (screen);
 
-  /* Get current workspace */
-  current_workspace = 0;
-  if (meta_prop_get_cardinal (screen->display,
-                              screen->xroot,
-                              screen->display->atom__NET_CURRENT_DESKTOP,
-                              &current_workspace))
-    meta_verbose ("Read existing _NET_CURRENT_DESKTOP = %d\n",
-                  (int) current_workspace);
-  else
-    meta_verbose ("No _NET_CURRENT_DESKTOP present\n");
-
   /* Screens must have at least one workspace at all times,
    * so create that required workspace.
    */
-  meta_workspace_activate (meta_workspace_new (screen), timestamp);
-  update_num_workspaces (screen, timestamp);
-
-  set_workspace_names (screen);
+  meta_workspace_new (screen);
 
   screen->keys_grabbed = FALSE;
   meta_screen_grab_keys (screen);
@@ -764,17 +749,6 @@ meta_screen_new (MetaDisplay *display,
   screen->startup_sequence_timeout = 0;
 #endif
 
-  /* Switch to the _NET_CURRENT_DESKTOP workspace */
-  {
-    MetaWorkspace *space;
-
-    space = meta_screen_get_workspace_by_index (screen,
-                                                current_workspace);
-
-    if (space != NULL)
-      meta_workspace_activate (space, timestamp);
-  }
-
   meta_verbose ("Added screen %d ('%s') root 0x%lx\n",
                 screen->number, screen->screen_name, screen->xroot);
 
@@ -782,6 +756,40 @@ meta_screen_new (MetaDisplay *display,
 }
 
 void
+meta_screen_init_workspaces (MetaScreen *screen)
+{
+  MetaWorkspace *current_workspace;
+  gulong current_workspace_index = 0;
+  guint32 timestamp;
+
+  g_return_if_fail (META_IS_SCREEN (screen));
+
+  timestamp = screen->wm_sn_timestamp;
+
+  /* Get current workspace */
+  if (meta_prop_get_cardinal (screen->display,
+                              screen->xroot,
+                              screen->display->atom__NET_CURRENT_DESKTOP,
+                              &current_workspace_index))
+    meta_verbose ("Read existing _NET_CURRENT_DESKTOP = %d\n",
+                  (int) current_workspace_index);
+  else
+    meta_verbose ("No _NET_CURRENT_DESKTOP present\n");
+
+  meta_workspace_activate (screen->workspaces->data, timestamp);
+  update_num_workspaces (screen, timestamp);
+
+  set_workspace_names (screen);
+
+  /* Switch to the _NET_CURRENT_DESKTOP workspace */
+  current_workspace = meta_screen_get_workspace_by_index (screen,
+                                                          current_workspace_index);
+
+  if (current_workspace != NULL)
+    meta_workspace_activate (current_workspace, timestamp);
+}
+
+void
 meta_screen_free (MetaScreen *screen,
                   guint32     timestamp)
 {


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