Fix resize with multiple monitors and portrait mode
authorBob Uhl <buhl@zvelo.com>
Mon, 7 Nov 2016 17:15:20 +0000 (10:15 -0700)
committerMarkus Teich <teichm@fs.tum.de>
Tue, 22 Nov 2016 23:26:51 +0000 (00:26 +0100)
When connecting/disconnecting a portrait monitor, the
XRRScreenChangeNotifyEvent height & width are reversed due to the XRandR
rotation; detect this and DTRT.

slock.c

diff --git a/slock.c b/slock.c
index d2f0886..61fe9ee 100644 (file)
--- a/slock.c
+++ b/slock.c
@@ -201,8 +201,13 @@ readpw(Display *dpy, struct xrandr *rr, struct lock **locks, int nscreens,
                        rre = (XRRScreenChangeNotifyEvent*)&ev;
                        for (screen = 0; screen < nscreens; screen++) {
                                if (locks[screen]->win == rre->window) {
-                                       XResizeWindow(dpy, locks[screen]->win,
-                                                     rre->width, rre->height);
+                                       if (rre->rotation == RR_Rotate_90 ||
+                                           rre->rotation == RR_Rotate_270)
+                                               XResizeWindow(dpy, locks[screen]->win,
+                                                             rre->height, rre->width);
+                                       else
+                                               XResizeWindow(dpy, locks[screen]->win,
+                                                             rre->width, rre->height);
                                        XClearWindow(dpy, locks[screen]->win);
                                }
                        }