Introduction
Introduction Statistics Contact Development Disclaimer Help
Exit as soon as possible on input grabbing error - slock - simple X display loc…
git clone git://git.suckless.org/slock
Log
Files
Refs
README
LICENSE
---
commit c2f975773d720e734dbdab9a1e9ae51b0972ae0c
parent 3bb868e40873c568acdec74f7783c77f063aa396
Author: Quentin Rameau <[email protected]>
Date: Tue, 30 Aug 2016 17:33:09 +0200
Exit as soon as possible on input grabbing error
We want to know at once if slock failed or not to lock the screen, not
seing a black screen for a whole second (or two) and then die.
Thanks to ^7heo for reporting this.
Diffstat:
M slock.c | 44 ++++++++++++++---------------…
1 file changed, 20 insertions(+), 24 deletions(-)
---
diff --git a/slock.c b/slock.c
@@ -222,7 +222,6 @@ static Lock *
lockscreen(Display *dpy, int screen)
{
char curs[] = {0, 0, 0, 0, 0, 0, 0, 0};
- unsigned int len;
int i;
Lock *lock;
XColor color, dummy;
@@ -249,34 +248,31 @@ lockscreen(Display *dpy, int screen)
lock->pmap = XCreateBitmapFromData(dpy, lock->win, curs, 8, 8);
invisible = XCreatePixmapCursor(dpy, lock->pmap, lock->pmap, &color, &…
XDefineCursor(dpy, lock->win, invisible);
- XMapRaised(dpy, lock->win);
- if (rr)
- XRRSelectInput(dpy, lock->win, RRScreenChangeNotifyMask);
/* Try to grab mouse pointer *and* keyboard, else fail the lock */
- for (len = 1000; len; len--) {
- if (XGrabPointer(dpy, lock->root, False, ButtonPressMask | But…
- GrabModeAsync, GrabModeAsync, None, invisible, CurrentTime…
- break;
- usleep(1000);
- }
- if (!len) {
+ if (XGrabPointer(dpy, lock->root, False, ButtonPressMask |
+ ButtonReleaseMask | PointerMotionMask, GrabModeAsync, GrabModeAsyn…
+ None, invisible, CurrentTime) != GrabSuccess) {
fprintf(stderr, "slock: unable to grab mouse pointer for scree…
- } else {
- for (len = 1000; len; len--) {
- if (XGrabKeyboard(dpy, lock->root, True, GrabModeAsync…
- /* everything fine, we grabbed both inputs */
- XSelectInput(dpy, lock->root, SubstructureNoti…
- return lock;
- }
- usleep(1000);
- }
+ running = 0;
+ unlockscreen(dpy, lock);
+ return NULL;
+ }
+
+ if (XGrabKeyboard(dpy, lock->root, True, GrabModeAsync, GrabModeAsync,
+ CurrentTime) != GrabSuccess) {
fprintf(stderr, "slock: unable to grab keyboard for screen %d\…
+ running = 0;
+ unlockscreen(dpy, lock);
+ return NULL;
}
- /* grabbing one of the inputs failed */
- running = 0;
- unlockscreen(dpy, lock);
- return NULL;
+
+ XMapRaised(dpy, lock->win);
+ if (rr)
+ XRRSelectInput(dpy, lock->win, RRScreenChangeNotifyMask);
+
+ XSelectInput(dpy, lock->root, SubstructureNotifyMask);
+ return lock;
}
static void
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.