MetaWayland: install an X io error handler

This way can detect X disconnections correctly, crash with a core
dump and reset the tty.

https://bugzilla.gnome.org/show_bug.cgi?id=706962
This commit is contained in:
Giovanni Campagna 2013-08-12 15:31:18 +02:00
parent c9830c13b4
commit 0cceddab75
3 changed files with 28 additions and 0 deletions

View File

@ -75,6 +75,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 || \
@ -516,6 +518,9 @@ meta_display_open (void)
return FALSE;
}
if (meta_is_wayland_compositor ())
meta_xwayland_complete_init ();
if (meta_is_syncing ())
XSynchronize (xdisplay, True);

View File

@ -27,6 +27,9 @@
gboolean
meta_xwayland_start (MetaWaylandCompositor *compositor);
void
meta_xwayland_complete_init (void);
void
meta_xwayland_stop (MetaWaylandCompositor *compositor);

View File

@ -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)
{