[mutter/wip/wayland: 554/555] make sure gtk_init_check doesn't shutdown xwayland



commit a235381da1fb3672d45fc1fddb7d988a5dbaeb9b
Author: Robert Bragg <robert linux intel com>
Date:   Tue Apr 23 15:34:01 2013 +0100

    make sure gtk_init_check doesn't shutdown xwayland
    
    This ensures we don't inadvertently cause xwayland to shutdown when
    trying to first connect to it via gtk_init_check. The problem is that
    the xserver shuts down when the last client disconnects and
    gtk_init_check may create a transient X connection during
    _gtk_accessibility_init before connecting to X for gtk itself.
    
    This patch is a kludge that simply opens a transient X connection before
    calling gtk_init_check and closes it afterwards to ensure there is
    always at least one X client during gtk_init_check.

 src/ui/ui.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/src/ui/ui.c b/src/ui/ui.c
index c0c819e..c1736b4 100644
--- a/src/ui/ui.c
+++ b/src/ui/ui.c
@@ -60,9 +60,23 @@ struct _MetaUI
 void
 meta_ui_init (void)
 {
+  Display *xdpy;
+
+  /* XXX: This is a hack because gtk_init_check may result in a transient X
+   * connection being opened during _gtk_accessibility_init and because
+   * xwayland's behaviour is to shutdown after the last client disconnects that
+   * means the later attempt to connect will fail. By opening our own transient
+   * X connection then we make sure that the X server wont be shutdown.
+   */
+  xdpy = XOpenDisplay (NULL);
+  if (!xdpy)
+    meta_fatal ("Unable to open X display %s\n", XDisplayName (NULL));
+
   if (!gtk_init_check (NULL, NULL))
     meta_fatal ("Unable to open X display %s\n", XDisplayName (NULL));
 
+  XCloseDisplay (xdpy);
+
   meta_stock_icons_init ();
 }
 


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