1
0
mirror of https://github.com/gryf/wmaker.git synced 2026-03-19 17:23:33 +01:00

Prevent unnecessary RandR wmaker restart

As reported in bug https://github.com/window-maker/wmaker/issues/34
when RandR is enabled, everytime a monitor is turned on or off wmaker is restarting
(that happens either manually or automatically with DPMS).
This behavior causes issues with xscreensaver.

How to reproduce the issue:
-install xscreensaver and lock the screen
-turn off then on the monitor manually
-you can see that wmaker was restarted and behind the xscreensaver lock window,
the desktop appears, potentially leaking information

Instead of using the RandR event RRScreenChangeNotifyMask which is too generic,
the patch is using RRCrtcChangeNotifyMask defined since RandR 1.2 (released in 2007).
In the recent RandR version, events for output (hardware) changes are propagated via
RROutputChangeNotifyMask while layout changes (like position, size, rotation)
are propagated via RRCrtcChangeNotifyMask.

The patch is purposedly not listening for RROutputChangeNotifyMask,
thus wmaker is not restarting on DPMS events anymore.

Currently, in case a new monitor is added (or removed) wmaker is not discovering it anyway
even after an automatic restart.
Either, wmaker has to be exited and restarted fully or an external tool like arandr
has to be used to configure the new monitor. So after the patch functionality remains unchanged.
This commit is contained in:
David Maciejak
2025-12-24 06:47:33 -05:00
committed by Carlos R. Mafra
parent 896bbce2e5
commit 3579c85af1
2 changed files with 21 additions and 10 deletions

View File

@@ -575,14 +575,18 @@ static void handleExtensions(XEvent * event)
}
#endif /*KEEP_XKB_LOCK_STATUS */
#ifdef USE_RANDR
if (w_global.xext.randr.supported && event->type == (w_global.xext.randr.event_base + RRScreenChangeNotify)) {
/* From xrandr man page: "Clients must call back into Xlib using
* XRRUpdateConfiguration when screen configuration change notify
* events are generated */
XRRUpdateConfiguration(event);
WCHANGE_STATE(WSTATE_RESTARTING);
Shutdown(WSRestartPreparationMode);
Restart(NULL,True);
if (w_global.xext.randr.supported) {
int base = w_global.xext.randr.event_base;
if (event->type == base + RRScreenChangeNotify ||
(event->type == base + RRNotify && ((XRRNotifyEvent*)event)->subtype == RRNotify_CrtcChange)) {
/* From xrandr man page: "Clients must call back into Xlib using
* XRRUpdateConfiguration when screen configuration change notify
* events are generated */
XRRUpdateConfiguration(event);
WCHANGE_STATE(WSTATE_RESTARTING);
Shutdown(WSRestartPreparationMode);
Restart(NULL,True);
}
}
#endif
}

View File

@@ -669,8 +669,15 @@ WScreen *wScreenInit(int screen_number)
#endif /* KEEP_XKB_LOCK_STATUS */
#ifdef USE_RANDR
if (w_global.xext.randr.supported)
XRRSelectInput(dpy, scr->root_win, RRScreenChangeNotifyMask);
if (w_global.xext.randr.supported) {
int major, minor;
if (XRRQueryVersion(dpy, &major, &minor)) {
if (major >= 1 && minor >= 2)
XRRSelectInput(dpy, scr->root_win, RRCrtcChangeNotifyMask);
else
XRRSelectInput(dpy, scr->root_win, RRScreenChangeNotifyMask);
}
}
#endif
XSync(dpy, False);