screen: Split workspace initialization from meta_screen_new()

Since commit 8b2b65246a, 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
This commit is contained in:
Florian Müllner 2014-06-05 22:28:56 +02:00
parent d7e99a3f86
commit 8100cefd4c
3 changed files with 37 additions and 27 deletions

View File

@ -805,6 +805,7 @@ meta_display_open (void)
enable_compositor (the_display); enable_compositor (the_display);
meta_screen_init_workspaces (screen);
meta_screen_create_guard_window (screen); meta_screen_create_guard_window (screen);
/* We know that if mutter is running as a Wayland compositor, /* We know that if mutter is running as a Wayland compositor,

View File

@ -135,6 +135,7 @@ MetaScreen* meta_screen_new (MetaDisplay *displ
guint32 timestamp); guint32 timestamp);
void meta_screen_free (MetaScreen *screen, void meta_screen_free (MetaScreen *screen,
guint32 timestamp); guint32 timestamp);
void meta_screen_init_workspaces (MetaScreen *screen);
void meta_screen_manage_all_windows (MetaScreen *screen); void meta_screen_manage_all_windows (MetaScreen *screen);
void meta_screen_foreach_window (MetaScreen *screen, void meta_screen_foreach_window (MetaScreen *screen,
MetaScreenWindowFunc func, MetaScreenWindowFunc func,

View File

@ -506,7 +506,6 @@ meta_screen_new (MetaDisplay *display,
Atom wm_sn_atom; Atom wm_sn_atom;
char buf[128]; char buf[128];
guint32 manager_timestamp; guint32 manager_timestamp;
gulong current_workspace;
MetaMonitorManager *manager; MetaMonitorManager *manager;
replace_current_wm = meta_get_replace_current_wm (); replace_current_wm = meta_get_replace_current_wm ();
@ -721,24 +720,10 @@ meta_screen_new (MetaDisplay *display,
meta_screen_update_workspace_layout (screen); 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, /* Screens must have at least one workspace at all times,
* so create that required workspace. * so create that required workspace.
*/ */
meta_workspace_activate (meta_workspace_new (screen), timestamp); meta_workspace_new (screen);
update_num_workspaces (screen, timestamp);
set_workspace_names (screen);
screen->keys_grabbed = FALSE; screen->keys_grabbed = FALSE;
meta_screen_grab_keys (screen); meta_screen_grab_keys (screen);
@ -764,23 +749,46 @@ meta_screen_new (MetaDisplay *display,
screen->startup_sequence_timeout = 0; screen->startup_sequence_timeout = 0;
#endif #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", meta_verbose ("Added screen %d ('%s') root 0x%lx\n",
screen->number, screen->screen_name, screen->xroot); screen->number, screen->screen_name, screen->xroot);
return screen; return screen;
} }
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 void
meta_screen_free (MetaScreen *screen, meta_screen_free (MetaScreen *screen,
guint32 timestamp) guint32 timestamp)