summaryrefslogtreecommitdiff
path: root/src/wayland/meta-xwayland.c
diff options
context:
space:
mode:
authorOlivier Fourdan <ofourdan@redhat.com>2021-03-17 15:44:45 +0100
committerOlivier Fourdan <ofourdan@redhat.com>2022-01-26 14:42:22 +0100
commit42855b69e7b37e229e6a8a6c4fb129c94141e899 (patch)
treef50e5a5e2c5c955a2bf15db4460d94ac8b012fbb /src/wayland/meta-xwayland.c
parentffa5fd776d16b7b64fe62f54c1c62e6e56d284e8 (diff)
downloadmutter-42855b69e7b37e229e6a8a6c4fb129c94141e899.tar.gz
xwayland: Mark our X11 connection terminatable
The connection to the Xserver for the X11 window manager part of mutter even on Wayland may prevent the Xserver from shutting down. Currently, what mutter does is to check the X11 clients still connected to Xwayland using the XRes extension, with a list of X11 clients that can be safely ignored (typically the GNOME XSettings daemon, the IBus daemon, pulseaudio and even mutter window manager itself). When there is just those known clients remaining, mutter would kill Xwayland automatically. But that's racy, because between the time mutter checks with Xwayland the remaining clients and the time it actually kills the process, a new X11 client might have come along and won't be able to connect to Xwayland that mutter is just about to kill. Because of that, the feature “autoclose-xwayland” is marked as an experimental feature in mutter and not enabled by default. Thankfully, the Xserver has all it takes to manage that already, and is even capable of terminating itself once all X11 clients are gone (the -terminate option on the command line). With XFixes version 6, the X11 clients can declare themselves "terminatable", so that the Xserver could simply ignore those X11 clients when checking the remaining clients and terminate itself automatically. Use that mechanism to declare mutter's own connection to the Xserver as "terminatable" when Xwayland is started on demand so that it won't hold Xwayland alive for the sole purpose of mutter itself. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1794>
Diffstat (limited to 'src/wayland/meta-xwayland.c')
-rw-r--r--src/wayland/meta-xwayland.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/wayland/meta-xwayland.c b/src/wayland/meta-xwayland.c
index 77fb366ea..5613f386d 100644
--- a/src/wayland/meta-xwayland.c
+++ b/src/wayland/meta-xwayland.c
@@ -40,6 +40,7 @@
#endif
#include <unistd.h>
#include <X11/extensions/Xrandr.h>
+#include <X11/extensions/Xfixes.h>
#include <X11/Xauth.h>
#include <X11/Xlib-xcb.h>
@@ -1305,6 +1306,8 @@ meta_xwayland_setup_xdisplay (MetaXWaylandManager *manager,
XSetIOErrorExitHandler (xdisplay, x_io_error_exit, manager);
#endif
+ XFixesSetClientDisconnectMode (xdisplay, XFixesClientDisconnectFlagTerminate);
+
add_local_user_to_xhost (xdisplay);
}