xwayland: add wlr_xwayland_server_options.terminate_delay

This allows users to specify a delay after which the Xwayland process
terminates itself when there are no more X11 clients connected.
This commit is contained in:
Simon Ser 2021-06-25 12:00:26 +02:00 committed by Kenny Levinsen
parent 7ad67e0f1d
commit 352064d76d
3 changed files with 18 additions and 1 deletions

View File

@ -24,6 +24,7 @@ struct wlr_xwayland_server_options {
bool lazy;
bool enable_wm;
bool no_touch_pointer_emulation;
int terminate_delay; // in seconds, 0 to terminate immediately
};
struct wlr_xwayland_server {

View File

@ -1,11 +1,13 @@
have_listenfd = false
have_no_touch_pointer_emulation = false
have_terminate_delay = false
if xwayland.found()
xwayland_path = xwayland.get_variable('xwayland')
have_listenfd = xwayland.get_variable('have_listenfd',
default_value: 'false') == 'true'
have_no_touch_pointer_emulation = xwayland.get_variable(
'have_no_touch_pointer_emulation', default_value: 'false') == 'true'
have_terminate_delay = xwayland.get_variable(pkgconfig: 'have_terminate_delay') == 'true'
else
xwayland_path = xwayland_prog.full_path()
endif
@ -14,6 +16,7 @@ xwayland_config_data = configuration_data()
xwayland_config_data.set_quoted('XWAYLAND_PATH', xwayland_path)
xwayland_config_data.set10('HAVE_XWAYLAND_LISTENFD', have_listenfd)
xwayland_config_data.set10('HAVE_XWAYLAND_NO_TOUCH_POINTER_EMULATION', have_no_touch_pointer_emulation)
xwayland_config_data.set10('HAVE_XWAYLAND_TERMINATE_DELAY', have_terminate_delay)
configure_file(
output: 'config.h',
configuration: xwayland_config_data,

View File

@ -49,9 +49,18 @@ noreturn static void exec_xwayland(struct wlr_xwayland_server *server,
argv[i++] = "Xwayland";
argv[i++] = server->display_name;
argv[i++] = "-rootless";
argv[i++] = "-terminate";
argv[i++] = "-core";
argv[i++] = "-terminate";
#if HAVE_XWAYLAND_TERMINATE_DELAY
char terminate_delay[16];
if (server->options.terminate_delay > 0) {
snprintf(terminate_delay, sizeof(terminate_delay), "%d",
server->options.terminate_delay);
argv[i++] = terminate_delay;
}
#endif
#if HAVE_XWAYLAND_LISTENFD
argv[i++] = "-listenfd";
argv[i++] = listenfd0;
@ -436,6 +445,10 @@ struct wlr_xwayland_server *wlr_xwayland_server_create(
server->wl_display = wl_display;
server->options = *options;
#if !HAVE_XWAYLAND_TERMINATE_DELAY
server->options.terminate_delay = 0;
#endif
server->x_fd[0] = server->x_fd[1] = -1;
server->wl_fd[0] = server->wl_fd[1] = -1;
server->wm_fd[0] = server->wm_fd[1] = -1;