From 5417d3cbbda866335b941a168d91be3d331ebfc6 Mon Sep 17 00:00:00 2001 From: Window Maker Date: Sun, 24 May 2026 11:38:55 +0200 Subject: [PATCH] wprefs: route through WMOpenScreen for Wayland-client autodetect WPrefs.app/main.c was opening the display directly via XOpenDisplay / WMCreateScreen. Replaced with WMOpenScreen, which autodetects Wayland mode from WAYLAND_DISPLAY / DISPLAY env and dispatches to W_WLClientInit in WINGs (Wayland) or W_X11OpenDisplay (widgets_x11.c) accordingly. The XSupportsLocale / XSetLocaleModifiers calls are now skipped in Wayland mode (they're X11-only). This is just startup plumbing; WPrefs's many tab modules still have direct Xlib calls that won't work as a pure Wayland client until each is ported through WINGs vtables. This commit gets us a minimal Wayland-aware launch path; further work required to actually run native. --- WPrefs.app/main.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/WPrefs.app/main.c b/WPrefs.app/main.c index 414fa00..a6bb396 100644 --- a/WPrefs.app/main.c +++ b/WPrefs.app/main.c @@ -81,7 +81,6 @@ void AddDeadChildHandler(pid_t pid, void (*handler) (void *), void *data) int main(int argc, char **argv) { - Display *dpy; WMScreen *scr; char *path; int i; @@ -136,20 +135,22 @@ int main(int argc, char **argv) bind_textdomain_codeset("WPrefs", "UTF-8"); textdomain("WPrefs"); - if (!XSupportsLocale()) { - wwarning(_("X server does not support locale")); - } - if (XSetLocaleModifiers("") == NULL) { - wwarning(_("cannot set locale modifiers")); + /* X11 locale checks only meaningful in X11 mode. In Wayland mode + * locale handling is delegated to xkbcommon / glib. */ + if (!getenv("WAYLAND_DISPLAY") || getenv("DISPLAY")) { + if (!XSupportsLocale()) { + wwarning(_("X server does not support locale")); + } + if (XSetLocaleModifiers("") == NULL) { + wwarning(_("cannot set locale modifiers")); + } } #endif - dpy = XOpenDisplay(display_name); - if (!dpy) { - wfatal(_("could not open display %s"), XDisplayName(display_name)); - exit(0); - } - scr = WMCreateScreen(dpy, DefaultScreen(dpy)); + /* WMOpenScreen autodetects Wayland-client mode (WAYLAND_DISPLAY set + * and DISPLAY unset, or display string starts with "wayland"). + * In X11 mode it transparently does XOpenDisplay + WMCreateScreen. */ + scr = WMOpenScreen(display_name); if (!scr) { wfatal(_("could not initialize application")); exit(0);