- if (!len) {
- fprintf(stderr, "unable to grab mouse pointer for screen %d\n", screen);
- } else {
- for (len = 1000; len; len--) {
- if (XGrabKeyboard(dpy, lock->root, True, GrabModeAsync, GrabModeAsync, CurrentTime) == GrabSuccess) {
- /* everything fine, we grabbed both inputs */
- XSelectInput(dpy, lock->root, SubstructureNotifyMask);
- return lock;
- }
- usleep(1000);
- }
- fprintf(stderr, "unable to grab keyboard for screen %d\n", screen);
+
+ if (XGrabKeyboard(dpy, lock->root, True, GrabModeAsync, GrabModeAsync,
+ CurrentTime) != GrabSuccess) {
+ fprintf(stderr, "slock: unable to grab keyboard for screen %d\n", screen);
+ running = 0;
+ unlockscreen(dpy, lock);
+ return NULL;