x11-display: Split out restoring of active workspace
Splitting out the X11 display initialization from display_open() broke restoring the previously active workspace in two ways: - when dynamic workspaces are used, the old workspaces haven't been restored yet, so we stay on the first workspace - when static workspaces are used, the code tries to access the compositor that hasn't been initialized yet, resulting in a segfault Fix both those issues by splitting out restoring of the active workspace. https://gitlab.gnome.org/GNOME/mutter/issues/479
This commit is contained in:
parent
3e472faf5c
commit
7abceb434d
@ -751,7 +751,10 @@ meta_display_open (void)
|
|||||||
enable_compositor (display);
|
enable_compositor (display);
|
||||||
|
|
||||||
if (display->x11_display)
|
if (display->x11_display)
|
||||||
meta_x11_display_create_guard_window (display->x11_display);
|
{
|
||||||
|
meta_x11_display_restore_active_workspace (display->x11_display);
|
||||||
|
meta_x11_display_create_guard_window (display->x11_display);
|
||||||
|
}
|
||||||
|
|
||||||
/* Set up touch support */
|
/* Set up touch support */
|
||||||
display->gesture_tracker = meta_gesture_tracker_new ();
|
display->gesture_tracker = meta_gesture_tracker_new ();
|
||||||
|
@ -156,6 +156,8 @@ struct _MetaX11Display
|
|||||||
|
|
||||||
MetaX11Display *meta_x11_display_new (MetaDisplay *display, GError **error);
|
MetaX11Display *meta_x11_display_new (MetaDisplay *display, GError **error);
|
||||||
|
|
||||||
|
void meta_x11_display_restore_active_workspace (MetaX11Display *x11_display);
|
||||||
|
|
||||||
Window meta_x11_display_create_offscreen_window (MetaX11Display *x11_display,
|
Window meta_x11_display_create_offscreen_window (MetaX11Display *x11_display,
|
||||||
Window parent,
|
Window parent,
|
||||||
long valuemask);
|
long valuemask);
|
||||||
|
@ -1068,8 +1068,6 @@ meta_x11_display_new (MetaDisplay *display, GError **error)
|
|||||||
Atom wm_sn_atom;
|
Atom wm_sn_atom;
|
||||||
char buf[128];
|
char buf[128];
|
||||||
guint32 timestamp;
|
guint32 timestamp;
|
||||||
MetaWorkspace *current_workspace;
|
|
||||||
uint32_t current_workspace_index = 0;
|
|
||||||
Atom atom_restart_helper;
|
Atom atom_restart_helper;
|
||||||
Window restart_helper_window = None;
|
Window restart_helper_window = None;
|
||||||
GdkDisplay *gdk_display;
|
GdkDisplay *gdk_display;
|
||||||
@ -1275,27 +1273,6 @@ meta_x11_display_new (MetaDisplay *display, GError **error)
|
|||||||
|
|
||||||
meta_x11_display_update_workspace_layout (x11_display);
|
meta_x11_display_update_workspace_layout (x11_display);
|
||||||
|
|
||||||
/* Get current workspace */
|
|
||||||
if (meta_prop_get_cardinal (x11_display,
|
|
||||||
x11_display->xroot,
|
|
||||||
x11_display->atom__NET_CURRENT_DESKTOP,
|
|
||||||
¤t_workspace_index))
|
|
||||||
{
|
|
||||||
meta_verbose ("Read existing _NET_CURRENT_DESKTOP = %d\n",
|
|
||||||
(int) current_workspace_index);
|
|
||||||
|
|
||||||
/* Switch to the _NET_CURRENT_DESKTOP workspace */
|
|
||||||
current_workspace = meta_workspace_manager_get_workspace_by_index (display->workspace_manager,
|
|
||||||
current_workspace_index);
|
|
||||||
|
|
||||||
if (current_workspace != NULL)
|
|
||||||
meta_workspace_activate (current_workspace, timestamp);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
meta_verbose ("No _NET_CURRENT_DESKTOP present\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (meta_prefs_get_dynamic_workspaces ())
|
if (meta_prefs_get_dynamic_workspaces ())
|
||||||
{
|
{
|
||||||
int num = 0;
|
int num = 0;
|
||||||
@ -1315,8 +1292,6 @@ meta_x11_display_new (MetaDisplay *display, GError **error)
|
|||||||
meta_workspace_manager_update_num_workspaces (display->workspace_manager, timestamp, num);
|
meta_workspace_manager_update_num_workspaces (display->workspace_manager, timestamp, num);
|
||||||
}
|
}
|
||||||
|
|
||||||
set_active_workspace_hint (display->workspace_manager, x11_display);
|
|
||||||
|
|
||||||
g_signal_connect_object (display->workspace_manager, "active-workspace-changed",
|
g_signal_connect_object (display->workspace_manager, "active-workspace-changed",
|
||||||
G_CALLBACK (set_active_workspace_hint),
|
G_CALLBACK (set_active_workspace_hint),
|
||||||
x11_display, 0);
|
x11_display, 0);
|
||||||
@ -1356,6 +1331,43 @@ meta_x11_display_new (MetaDisplay *display, GError **error)
|
|||||||
return x11_display;
|
return x11_display;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
meta_x11_display_restore_active_workspace (MetaX11Display *x11_display)
|
||||||
|
{
|
||||||
|
MetaDisplay *display;
|
||||||
|
MetaWorkspace *current_workspace;
|
||||||
|
uint32_t current_workspace_index = 0;
|
||||||
|
guint32 timestamp;
|
||||||
|
|
||||||
|
g_return_if_fail (META_IS_X11_DISPLAY (x11_display));
|
||||||
|
|
||||||
|
display = x11_display->display;
|
||||||
|
timestamp = x11_display->timestamp;
|
||||||
|
|
||||||
|
/* Get current workspace */
|
||||||
|
if (meta_prop_get_cardinal (x11_display,
|
||||||
|
x11_display->xroot,
|
||||||
|
x11_display->atom__NET_CURRENT_DESKTOP,
|
||||||
|
¤t_workspace_index))
|
||||||
|
{
|
||||||
|
meta_verbose ("Read existing _NET_CURRENT_DESKTOP = %d\n",
|
||||||
|
(int) current_workspace_index);
|
||||||
|
|
||||||
|
/* Switch to the _NET_CURRENT_DESKTOP workspace */
|
||||||
|
current_workspace = meta_workspace_manager_get_workspace_by_index (display->workspace_manager,
|
||||||
|
current_workspace_index);
|
||||||
|
|
||||||
|
if (current_workspace != NULL)
|
||||||
|
meta_workspace_activate (current_workspace, timestamp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
meta_verbose ("No _NET_CURRENT_DESKTOP present\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
set_active_workspace_hint (display->workspace_manager, x11_display);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
meta_x11_display_get_screen_number (MetaX11Display *x11_display)
|
meta_x11_display_get_screen_number (MetaX11Display *x11_display)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user