diff options
| author | Sunderland93 <[email protected]> | 2026-08-06 13:15:20 +0400 |
|---|---|---|
| committer | Luke from DC <[email protected]> | 2026-08-19 19:15:44 +0000 |
| commit | 78d84fce70f7d6a24a37eb1dfdaa2575d2c9643b (patch) | |
| tree | 994691ffae33c00105291b012715b1517f809c68 | |
| parent | 46a71781ddf3cc6cc6d03f400363cdd0231b56f6 (diff) | |
| download | mate-settings-daemon-78d84fce70f7d6a24a37eb1dfdaa2575d2c9643b.tar.bz2 mate-settings-daemon-78d84fce70f7d6a24a37eb1dfdaa2575d2c9643b.tar.xz | |
xsettings: flush Xlib output so settings reach X11/XWayland clients
| -rw-r--r-- | plugins/xsettings/msd-xsettings-manager.c | 26 | ||||
| -rw-r--r-- | plugins/xsettings/xsettings-manager.c | 10 |
2 files changed, 36 insertions, 0 deletions
diff --git a/plugins/xsettings/msd-xsettings-manager.c b/plugins/xsettings/msd-xsettings-manager.c index 6656ccb..879aa81 100644 --- a/plugins/xsettings/msd-xsettings-manager.c +++ b/plugins/xsettings/msd-xsettings-manager.c @@ -39,6 +39,9 @@ #ifdef GDK_WINDOWING_X11 #include <gdk/gdkx.h> #endif /* GDK_WINDOWING_X11 */ +#ifdef GDK_WINDOWING_WAYLAND +#include <gdk/gdkwayland.h> +#endif /* GDK_WINDOWING_WAYLAND */ #include <gtk/gtk.h> #include <gio/gio.h> @@ -879,6 +882,19 @@ terminate_cb (void *data) gtk_main_quit (); } +#ifdef GDK_WINDOWING_WAYLAND +/* No-op Xlib IO error handler used when running on Wayland: the X connection + * only serves XSettings on XWayland, so the daemon should survive an + * XWayland restart instead of exiting. */ +static int +wayland_x_io_error_handler (Display *display) +{ + g_warning ("Connection to the XWayland display lost; XSettings for " + "X11 applications disabled"); + return 0; +} +#endif /* GDK_WINDOWING_WAYLAND */ + static gboolean setup_xsettings_managers (MateXSettingsManager *manager) { @@ -892,6 +908,16 @@ setup_xsettings_managers (MateXSettingsManager *manager) return FALSE; } +#ifdef GDK_WINDOWING_WAYLAND + /* When running on Wayland the XSETTINGS manager uses its own Xlib + * connection to XWayland, which nothing else watches. Now that we + * explicitly flush it, a disappearing XWayland would otherwise kill + * the whole daemon through the default Xlib IO error handler. */ + if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ())) { + XSetIOErrorHandler (wayland_x_io_error_handler); + } +#endif /* GDK_WINDOWING_WAYLAND */ + res = xsettings_manager_check_running (xdisplay, DefaultScreen (xdisplay)); if (res) { g_warning ("You can only run one xsettings manager at a time; exiting"); diff --git a/plugins/xsettings/xsettings-manager.c b/plugins/xsettings/xsettings-manager.c index d8f5dd5..3aeffa6 100644 --- a/plugins/xsettings/xsettings-manager.c +++ b/plugins/xsettings/xsettings-manager.c @@ -188,6 +188,11 @@ xsettings_manager_new (Display *display, manager->terminate (manager->cb_data); } + /* The display may not be watched by the main loop (e.g. when running on + * Wayland the XSettings manager uses its own connection to XWayland), so + * make sure the MANAGER message actually reaches the server. */ + XFlush (manager->display); + return manager; } @@ -428,6 +433,11 @@ xsettings_manager_notify (XSettingsManager *manager) free (buffer.data); + /* See the note in xsettings_manager_new(): on Wayland nothing else + * flushes this connection, so without this clients never see the + * property and none of the settings are applied. */ + XFlush (manager->display); + return XSETTINGS_SUCCESS; } |
