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..."));