Skip to content

Commit

Permalink
client/x11: Add support for XFixes ClientDisconnectMode
Browse files Browse the repository at this point in the history
The Xserver itself is capable of terminating itself once all X11 clients
are gone, yet in a typical full session, there are a number of X11
clients such as ibus-x11 running continuously.

Those always-running clients will prevent the Xserver from terminating,
because the actual number of X11 clients will never drop to 0.

Use XFixes ClientDisconnectMode to inform the X11 server that it can
terminate even if ibus-x11 is still running.

That will allow Xwayland from terminating automatically when regular
clients have quit.

On plain Xorg servers, the lifetime of the session is usually tied to
the session manager or window manager, and this change will have no
effect.

BUG=#2314
  • Loading branch information
ofourdan authored and fujiwarat committed Aug 18, 2021
1 parent a823161 commit 71ca4a9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions client/x11/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ ibus_x11_LDADD = \
$(libibus) \
@X11_LIBS@ \
$(GTK_LIBS) \
$(XFIXES_LIBS) \
$(NULL)

ibus_x11_CFLAGS = \
@X11_CFLAGS@ \
$(GTK_CFLAGS) \
$(XFIXES_CFLAGS) \
@DBUS_CFLAGS@ \
-I$(top_srcdir)/util/IMdkit \
-I$(top_srcdir)/src \
Expand Down
10 changes: 10 additions & 0 deletions client/x11/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,15 @@
*/
#define _GNU_SOURCE

#include "config.h"

#include <X11/Xproto.h>
#include <X11/Xlib.h>
#include <X11/keysym.h>
#include <X11/Xutil.h>
#ifdef HAVE_XFIXES
#include <X11/extensions/Xfixes.h>
#endif
#include <XimProto.h>
#include <IMdkit.h>
#include <Xi18n.h>
Expand Down Expand Up @@ -1174,6 +1179,11 @@ main (int argc, char **argv)
XSetErrorHandler (_xerror_handler);
XSetIOErrorHandler (_xerror_io_handler);

#ifdef HAVE_XFIXES
XFixesSetClientDisconnectMode(GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
XFixesClientDisconnectFlagTerminate);
#endif

while (1) {
static struct option long_options [] = {
{ "debug", 1, 0, 0},
Expand Down
8 changes: 8 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,13 @@ PKG_CHECK_MODULES(XTEST,
)
AM_CONDITIONAL([ENABLE_XTEST], [test x"$enable_xtest" = x"yes"])

PKG_CHECK_MODULES(XFIXES,
[x11 xfixes >= 6],
[AC_DEFINE([HAVE_XFIXES], [1], [Define to enable XFixes])
have_xfixes=yes],
[have_xfixes="no (libXfixes version is lower than 6)"]
)

# --enable-install-tests
AC_ARG_ENABLE(install-tests,
AS_HELP_STRING([--enable-install-tests],
Expand Down Expand Up @@ -843,6 +850,7 @@ Build options:
Enable Unicode dict $enable_unicode_dict
UCD directory $UCD_DIR
Socket directory "$IBUS_SOCKET_DIR"
XFixes client disconnect $have_xfixes
Run test cases $enable_tests
Install tests $enable_install_tests
])
Expand Down

0 comments on commit 71ca4a9

Please sign in to comment.