diff options
| -rw-r--r-- | config.mk | 2 | ||||
| -rw-r--r-- | slock.c | 18 | 
2 files changed, 17 insertions, 3 deletions
| @@ -11,7 +11,7 @@ X11LIB = /usr/X11R6/lib | |||
| 11 | 11 | ||
| 12 | # includes and libs | 12 | # includes and libs | 
| 13 | INCS = -I. -I/usr/include -I${X11INC} | 13 | INCS = -I. -I/usr/include -I${X11INC} | 
| 14 | LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -lX11 -lXext | 14 | LIBS = -L/usr/lib -lc -lcrypt -L${X11LIB} -lX11 -lXext -lXrandr | 
| 15 | 15 | ||
| 16 | # flags | 16 | # flags | 
| 17 | CPPFLAGS = -DVERSION=\"${VERSION}\" -DHAVE_SHADOW_H | 17 | CPPFLAGS = -DVERSION=\"${VERSION}\" -DHAVE_SHADOW_H | 
| @@ -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 { | |||
| 41 | static Lock **locks; | 42 | static Lock **locks; | 
| 42 | static int nscreens; | 43 | static int nscreens; | 
| 43 | static Bool running = True; | 44 | static Bool running = True; | 
| 45 | static Bool rr; | ||
| 46 | static int rrevbase; | ||
| 47 | static int rrerrbase; | ||
| 44 | 48 | ||
| 45 | static void | 49 | static void | 
| 46 | die(const char *errstr, ...) | 50 | die(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); | 
