diff --git a/src/event.c b/src/event.c index 67d30098..3b93ffee 100644 --- a/src/event.c +++ b/src/event.c @@ -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 } diff --git a/src/screen.c b/src/screen.c index 3a2fd3b7..59fc8aa9 100644 --- a/src/screen.c +++ b/src/screen.c @@ -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);