#include <string.h>
#include <unistd.h>
#include <sys/types.h>
+#include <X11/extensions/Xrandr.h>
#include <X11/keysym.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
static Lock **locks;
static int nscreens;
static Bool running = True;
+static Bool rr;
+static int rrevbase;
+static int rrerrbase;
static void
die(const char *errstr, ...)
}
}
llen = len;
- }
- else for (screen = 0; screen < nscreens; screen++)
+ } else if (rr && ev.type == rrevbase + RRScreenChangeNotify) {
+ XRRScreenChangeNotifyEvent *rre = (XRRScreenChangeNotifyEvent*)&ev;
+ for (screen = 0; screen < nscreens; screen++) {
+ if (locks[screen]->win == rre->window) {
+ XResizeWindow(dpy, locks[screen]->win, rre->width, rre->height);
+ XClearWindow(dpy, locks[screen]->win);
+ }
+ }
+ } else for (screen = 0; screen < nscreens; screen++)
XRaiseWindow(dpy, locks[screen]->win);
}
}
invisible = XCreatePixmapCursor(dpy, lock->pmap, lock->pmap, &color, &color, 0, 0);
XDefineCursor(dpy, lock->win, invisible);
XMapRaised(dpy, lock->win);
+ if (rr)
+ XRRSelectInput(dpy, lock->win, RRScreenChangeNotifyMask);
for (len = 1000; len; len--) {
if (XGrabPointer(dpy, lock->root, False, ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
GrabModeAsync, GrabModeAsync, None, invisible, CurrentTime) == GrabSuccess)
if (!(dpy = XOpenDisplay(0)))
die("slock: cannot open display\n");
+ rr = XRRQueryExtension(dpy, &rrevbase, &rrerrbase);
/* Get the number of screens in display "dpy" and blank them all. */
nscreens = ScreenCount(dpy);
locks = malloc(sizeof(Lock *) * nscreens);