From 8fe50a7001c67bb7d519ccae8b061307ba8eeee6 Mon Sep 17 00:00:00 2001 From: Window Maker Date: Sun, 24 May 2026 13:30:35 +0200 Subject: [PATCH] WPrefs.app: WPrefs.c X11-free (reconfigure via SIGUSR1 on Wayland) - XSendEvent/_WINDOWMAKER_COMMAND path guarded with USE_X11_BACKEND - Wayland path: send SIGUSR1 to wmaker via PID file - XFlush calls replaced with eventBackend->flush() - Added X11 includes inside #ifdef guard only Also: double.c/Paths.c already committed; HotCornerShortcuts.c done. Remaining panels with X11 calls (all architectural violations): editmenu.c (30), Menu.c (14), TexturePanel.c (13), KeyboardShortcuts.c (11), MouseSettings.c (5) --- WPrefs.app/WPrefs.c | 54 +++++++++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 14 deletions(-) diff --git a/WPrefs.app/WPrefs.c b/WPrefs.app/WPrefs.c index 9b0637d..75eca95 100644 --- a/WPrefs.app/WPrefs.c +++ b/WPrefs.app/WPrefs.c @@ -24,6 +24,11 @@ #include "WPrefs.h" #include +#ifdef USE_X11_BACKEND +#include +#include +#endif + #ifdef HAVE_STDNORETURN #include #endif @@ -91,7 +96,6 @@ static void save(WMWidget * w, void *data) WMPropList *p1, *p2; WMPropList *keyList; WMPropList *key; - XEvent ev; /* Parameter not used, but tell the compiler that it is ok */ (void) data; @@ -128,17 +132,39 @@ static void save(WMWidget * w, void *data) WMWritePropListToFile(WindowMakerDB, WindowMakerDBPath); - memset(&ev, 0, sizeof(XEvent)); - - ev.xclient.type = ClientMessage; - ev.xclient.message_type = XInternAtom(WMScreenDisplay(WMWidgetScreen(w)), "_WINDOWMAKER_COMMAND", False); - ev.xclient.window = DefaultRootWindow(WMScreenDisplay(WMWidgetScreen(w))); - ev.xclient.format = 8; - strncpy(ev.xclient.data.b, "Reconfigure", sizeof(ev.xclient.data.b)); - - XSendEvent(WMScreenDisplay(WMWidgetScreen(w)), - DefaultRootWindow(WMScreenDisplay(WMWidgetScreen(w))), False, WM_EVMASK_SUBSTRUCTURE_REDIRECT, &ev); - XFlush(WMScreenDisplay(WMWidgetScreen(w))); + /* Tell the running wmaker to reconfigure. On X11 this sends a + * _WINDOWMAKER_COMMAND ClientMessage; on Wayland we use the + * WINGs screen flush (which triggers a wl_display_flush) and + * rely on wmaker's file-watch or SIGUSR1 mechanism. */ +#ifdef USE_X11_BACKEND + { + Display *dpy = WMScreenDisplay(WMWidgetScreen(w)); + XEvent ev; + memset(&ev, 0, sizeof(XEvent)); + ev.xclient.type = ClientMessage; + ev.xclient.message_type = XInternAtom(dpy, "_WINDOWMAKER_COMMAND", False); + ev.xclient.window = DefaultRootWindow(dpy); + ev.xclient.format = 8; + strncpy(ev.xclient.data.b, "Reconfigure", sizeof(ev.xclient.data.b)); + XSendEvent(dpy, DefaultRootWindow(dpy), False, + SubstructureRedirectMask, &ev); + XFlush(dpy); + } +#else + /* Wayland: signal wmaker to re-read config. */ + { + /* Find wmaker's PID from the lock file and send SIGUSR1. */ + char pidfile[256]; + snprintf(pidfile, sizeof(pidfile), "/tmp/wmaker-%d.pid", getuid()); + FILE *f = fopen(pidfile, "r"); + if (f) { + pid_t pid; + if (fscanf(f, "%d", &pid) == 1 && pid > 0) + kill(pid, SIGUSR1); + fclose(f); + } + } +#endif } static void undo(WMWidget * w, void *data) @@ -550,9 +576,9 @@ void Initialize(WMScreen * scr) WMSetWindowMiniwindowImage(WPrefs.win, WMGetApplicationIconImage(scr)); WMMapWidget(WPrefs.win); - XFlush(WMScreenDisplay(scr)); + scr->eventBackend->flush(scr->eventBackendCtx, False); WMSetLabelText(WPrefs.statusL, _("Loading Window Maker configuration files...")); - XFlush(WMScreenDisplay(scr)); + scr->eventBackend->flush(scr->eventBackendCtx, False); loadConfigurations(scr, WPrefs.win); WMSetLabelText(WPrefs.statusL, _("Initializing configuration panels..."));