Skip to content

xwayland: Add support for XFixes ClientDisconnectMode

Olivier Fourdan requested to merge ofourdan/mutter:xfixes-ignore-client into main

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.

If we rely on the Xserver to terminate itself when all relevant, meaningful X11 clients are gone, we can safely remove the experimental xwayland-autoclose feature.

Alone with it, goes the all mechanism that was added to check the X11 clients connected and their executable.

So all in all, it's a nice clean-up and a a much more reliable way for Xwayland to terminate cleanly.


See also:

Edited by Olivier Fourdan

Merge request reports