[hackers] [slock][PATCH] Fix resize with multiple monitors and portrait mode

From: Bob Uhl <buhl_AT_zvelo.com>
Date: Mon, 07 Nov 2016 10:15:20 -0700

When connecting/disconnecting a portrait monitor, the
XRRScreenChangeNotifyEvent height & width are reversed due to the XRandR
rotation; detect this and DTRT.
---
 slock.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/slock.c b/slock.c
index ad539dc..ab20036 100644
--- a/slock.c
+++ b/slock.c
_AT_@ -201,8 +201,11 @@ 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);
 				}
 			}
-- 
2.1.4
Received on Mon Nov 07 2016 - 18:15:20 CET

This archive was generated by hypermail 2.3.0 : Mon Nov 07 2016 - 18:24:18 CET