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)
This commit is contained in:
Window Maker 2026-05-24 13:30:35 +02:00
parent fabf6c01b2
commit 8fe50a7001
1 changed files with 40 additions and 14 deletions

View File

@ -24,6 +24,11 @@
#include "WPrefs.h"
#include <assert.h>
#ifdef USE_X11_BACKEND
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#endif
#ifdef HAVE_STDNORETURN
#include <stdnoreturn.h>
#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..."));