From 8a63c589a6e81f574a0984895ded2e2a6db9a6c1 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sat, 9 Apr 2016 16:06:21 +0200 Subject: [PATCH] Update root window size on RandR notify The code that claims to do what XRRUpdateConfiguration() would do was actually wrong. That function does not send any requests to the X11 server, but it just updates the local, in-memory state. This commit makes us do the same: We update the size of the root window if it changed. The code is directly inspired from the code in libXrandr. Signed-off-by: Uli Schlachter --- event.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/event.c b/event.c index 2809916f..83d388d2 100644 --- a/event.c +++ b/event.c @@ -771,22 +771,18 @@ event_handle_unmapnotify(xcb_unmap_notify_event_t *ev) static void event_handle_randr_screen_change_notify(xcb_randr_screen_change_notify_event_t *ev) { - /* Code of XRRUpdateConfiguration Xlib function ported to XCB - * (only the code relevant to RRScreenChangeNotify) as the latter - * doesn't provide this kind of function */ - if(ev->rotation & (XCB_RANDR_ROTATION_ROTATE_90 | XCB_RANDR_ROTATION_ROTATE_270)) - xcb_randr_set_screen_size(globalconf.connection, ev->root, ev->height, ev->width, - ev->mheight, ev->mwidth); - else - xcb_randr_set_screen_size(globalconf.connection, ev->root, ev->width, ev->height, - ev->mwidth, ev->mheight); + /* Ignore events for other roots (do we get them at all?) */ + if (ev->root != globalconf.screen->root) + return; - /* XRRUpdateConfiguration also executes the following instruction - * but it's not useful because SubpixelOrder is not used at all at - * the moment - * - * XRenderSetSubpixelOrder(dpy, snum, scevent->subpixel_order); - */ + /* Do (part of) what XRRUpdateConfiguration() would do (update our state) */ + if (ev->rotation & (XCB_RANDR_ROTATION_ROTATE_90 | XCB_RANDR_ROTATION_ROTATE_270)) { + globalconf.screen->width_in_pixels = ev->height; + globalconf.screen->height_in_pixels = ev->width; + } else { + globalconf.screen->width_in_pixels = ev->width; + globalconf.screen->height_in_pixels = ev->height; + } awesome_restart(); }