aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.mk2
-rw-r--r--slock.c18
2 files changed, 17 insertions, 3 deletions
diff --git a/config.mk b/config.mk
index 067cfc7..44e41c6 100644
--- a/config.mk
+++ b/config.mk
@@ -11,7 +11,7 @@ X11LIB = /usr/X11R6/lib
11 11
12# includes and libs 12# includes and libs
13INCS = -I. -I/usr/include -I${X11INC} 13INCS = -I. -I/usr/include -I${X11INC}
14LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -lX11 -lXext 14LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -lX11 -lXext -lXrandr
15 15
16# flags 16# flags
17CPPFLAGS = -DVERSION=\"${VERSION}\" -DHAVE_SHADOW_H 17CPPFLAGS = -DVERSION=\"${VERSION}\" -DHAVE_SHADOW_H
diff --git a/slock.c b/slock.c
index df5c3fe..6502c86 100644
--- a/slock.c
+++ b/slock.c
@@ -13,6 +13,7 @@
13#include <string.h> 13#include <string.h>
14#include <unistd.h> 14#include <unistd.h>
15#include <sys/types.h> 15#include <sys/types.h>
16#include <X11/extensions/Xrandr.h>
16#include <X11/keysym.h> 17#include <X11/keysym.h>
17#include <X11/Xlib.h> 18#include <X11/Xlib.h>
18#include <X11/Xutil.h> 19#include <X11/Xutil.h>
@@ -41,6 +42,9 @@ typedef struct {
41static Lock **locks; 42static Lock **locks;
42static int nscreens; 43static int nscreens;
43static Bool running = True; 44static Bool running = True;
45static Bool rr;
46static int rrevbase;
47static int rrerrbase;
44 48
45static void 49static void
46die(const char *errstr, ...) 50die(const char *errstr, ...)
@@ -179,8 +183,15 @@ readpw(Display *dpy, const char *pws)
179 } 183 }
180 } 184 }
181 llen = len; 185 llen = len;
182 } 186 } else if (rr && ev.type == rrevbase + RRScreenChangeNotify) {
183 else for (screen = 0; screen < nscreens; screen++) 187 XRRScreenChangeNotifyEvent *rre = (XRRScreenChangeNotifyEvent*)&ev;
188 for (screen = 0; screen < nscreens; screen++) {
189 if (locks[screen]->win == rre->window) {
190 XResizeWindow(dpy, locks[screen]->win, rre->width, rre->height);
191 XClearWindow(dpy, locks[screen]->win);
192 }
193 }
194 } else for (screen = 0; screen < nscreens; screen++)
184 XRaiseWindow(dpy, locks[screen]->win); 195 XRaiseWindow(dpy, locks[screen]->win);
185 } 196 }
186} 197}
@@ -236,6 +247,8 @@ lockscreen(Display *dpy, int screen)
236 invisible = XCreatePixmapCursor(dpy, lock->pmap, lock->pmap, &color, &color, 0, 0); 247 invisible = XCreatePixmapCursor(dpy, lock->pmap, lock->pmap, &color, &color, 0, 0);
237 XDefineCursor(dpy, lock->win, invisible); 248 XDefineCursor(dpy, lock->win, invisible);
238 XMapRaised(dpy, lock->win); 249 XMapRaised(dpy, lock->win);
250 if (rr)
251 XRRSelectInput(dpy, lock->win, RRScreenChangeNotifyMask);
239 for (len = 1000; len; len--) { 252 for (len = 1000; len; len--) {
240 if (XGrabPointer(dpy, lock->root, False, ButtonPressMask | ButtonReleaseMask | PointerMotionMask, 253 if (XGrabPointer(dpy, lock->root, False, ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
241 GrabModeAsync, GrabModeAsync, None, invisible, CurrentTime) == GrabSuccess) 254 GrabModeAsync, GrabModeAsync, None, invisible, CurrentTime) == GrabSuccess)
@@ -295,6 +308,7 @@ main(int argc, char **argv) {
295 308
296 if (!(dpy = XOpenDisplay(0))) 309 if (!(dpy = XOpenDisplay(0)))
297 die("slock: cannot open display\n"); 310 die("slock: cannot open display\n");
311 rr = XRRQueryExtension(dpy, &rrevbase, &rrerrbase);
298 /* Get the number of screens in display "dpy" and blank them all. */ 312 /* Get the number of screens in display "dpy" and blank them all. */
299 nscreens = ScreenCount(dpy); 313 nscreens = ScreenCount(dpy);
300 locks = malloc(sizeof(Lock *) * nscreens); 314 locks = malloc(sizeof(Lock *) * nscreens);