From e3be2237b88871d122b0c668ebdda4db105edf11 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Wed, 19 Jun 2013 13:49:31 +0100 Subject: [PATCH] wayland: Create a dummy stage window when running as a display server When Mutter is running as a display server then Clutter won't be using the X11 backend so there won't be a window for the stage. The shell global keeps track of this stage window to be used in various places. This patch adds a dummy window that is never mapped to use instead of the stage window so that the various places that are using it might be able to continue working without generating X errors. --- src/shell-global.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/shell-global.c b/src/shell-global.c index 4a82b9533..1e0ea9c8c 100644 --- a/src/shell-global.c +++ b/src/shell-global.c @@ -930,9 +930,34 @@ _shell_global_set_plugin (ShellGlobal *global, meta_screen_get_screen_number (global->meta_screen)); global->stage = CLUTTER_STAGE (meta_get_stage_for_screen (global->meta_screen)); - global->stage_xwindow = clutter_x11_get_stage_window (global->stage); - global->stage_gdk_window = gdk_x11_window_foreign_new_for_display (global->gdk_display, - global->stage_xwindow); + if (meta_is_display_server ()) + { + /* When Mutter is acting as its own display server then the + stage does not have a window. Instead we'll just create a + dummy window that might make some things blunder along but + will probably just leave most things broken. It might be + possible to fix this to make the fake window be the same size + as the stage window would be and make it more useful. */ + + GdkWindowAttr attributes; + + attributes.wclass = GDK_INPUT_OUTPUT; + attributes.width = 100; + attributes.height = 100; + attributes.window_type = GDK_WINDOW_TOPLEVEL; + + global->stage_gdk_window = gdk_window_new (NULL, + &attributes, + 0 /* attributes_mask */); + global->stage_xwindow = gdk_x11_window_get_xid (global->stage_gdk_window); + } + else + { + global->stage_xwindow = clutter_x11_get_stage_window (global->stage); + global->stage_gdk_window = + gdk_x11_window_foreign_new_for_display (global->gdk_display, + global->stage_xwindow); + } g_signal_connect (global->stage, "notify::width", G_CALLBACK (global_stage_notify_width), global);