[mutter/wip/wayland-kms: 677/697] MetaWayland: install an X io error handler



commit 913661c5f50fa5cd70bba7f4c8a16f9949309d2a
Author: Giovanni Campagna <gcampagn redhat com>
Date:   Mon Aug 12 15:31:18 2013 +0200

    MetaWayland: install an X io error handler
    
    This way can detect X disconnections correctly, crash with a core
    dump and reset the tty.

 src/core/display.c                  |    5 +++++
 src/wayland/meta-xwayland-private.h |    3 +++
 src/wayland/meta-xwayland.c         |   20 ++++++++++++++++++++
 3 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/src/core/display.c b/src/core/display.c
index e7cdefd..aaee6fe 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -74,6 +74,8 @@
 #include <string.h>
 #include <unistd.h>
 
+#include "meta-xwayland-private.h"
+
 #define GRAB_OP_IS_WINDOW_SWITCH(g)                     \
         (g == META_GRAB_OP_KEYBOARD_TABBING_NORMAL  ||  \
          g == META_GRAB_OP_KEYBOARD_TABBING_DOCK    ||  \
@@ -515,6 +517,9 @@ meta_display_open (void)
       return FALSE;
     }
 
+  if (meta_is_wayland_compositor ())
+    meta_xwayland_complete_init ();
+
   if (meta_is_syncing ())
     XSynchronize (xdisplay, True);
   
diff --git a/src/wayland/meta-xwayland-private.h b/src/wayland/meta-xwayland-private.h
index 0d6716b..d115510 100644
--- a/src/wayland/meta-xwayland-private.h
+++ b/src/wayland/meta-xwayland-private.h
@@ -28,6 +28,9 @@ gboolean
 meta_xwayland_start (MetaWaylandCompositor *compositor);
 
 void
+meta_xwayland_complete_init (void);
+
+void
 meta_xwayland_stop (MetaWaylandCompositor *compositor);
 
 #endif /* META_XWAYLAND_PRIVATE_H */
diff --git a/src/wayland/meta-xwayland.c b/src/wayland/meta-xwayland.c
index d78b199..3b3c699 100644
--- a/src/wayland/meta-xwayland.c
+++ b/src/wayland/meta-xwayland.c
@@ -301,6 +301,14 @@ xserver_died (GPid     pid,
     }
 }
 
+static int
+x_io_error (Display *display)
+{
+  g_error ("Connection to xwayland lost");
+
+  return 0;
+}
+
 gboolean
 meta_xwayland_start (MetaWaylandCompositor *compositor)
 {
@@ -425,6 +433,18 @@ meta_xwayland_start (MetaWaylandCompositor *compositor)
   return TRUE;
 }
 
+/* To be called right after connecting */
+void
+meta_xwayland_complete_init (void)
+{
+  /* We install an X IO error handler in addition to the child watch,
+     because after Xlib connects our child watch may not be called soon
+     enough, and therefore we won't crash when X exits (and most important
+     we won't reset the tty).
+  */
+  XSetIOErrorHandler (x_io_error);
+}
+
 void
 meta_xwayland_stop (MetaWaylandCompositor *compositor)
 {


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