aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dmenu.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/dmenu.c b/dmenu.c
index 49a6583..aa6e5d8 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -6,7 +6,7 @@
6#include <stdlib.h> 6#include <stdlib.h>
7#include <string.h> 7#include <string.h>
8#include <strings.h> 8#include <strings.h>
9#include <unistd.h> 9#include <time.h>
10#include <X11/Xlib.h> 10#include <X11/Xlib.h>
11#include <X11/Xatom.h> 11#include <X11/Xatom.h>
12#include <X11/Xutil.h> 12#include <X11/Xutil.h>
@@ -203,6 +203,7 @@ drawmenu(void)
203static void 203static void
204grabkeyboard(void) 204grabkeyboard(void)
205{ 205{
206 struct timespec ts = { .tv_sec = 1, .tv_nsec = 0 };
206 int i; 207 int i;
207 208
208 /* try to grab keyboard, we may have to wait for another process to ungrab */ 209 /* try to grab keyboard, we may have to wait for another process to ungrab */
@@ -210,7 +211,7 @@ grabkeyboard(void)
210 if (XGrabKeyboard(dpy, DefaultRootWindow(dpy), True, 211 if (XGrabKeyboard(dpy, DefaultRootWindow(dpy), True,
211 GrabModeAsync, GrabModeAsync, CurrentTime) == GrabSuccess) 212 GrabModeAsync, GrabModeAsync, CurrentTime) == GrabSuccess)
212 return; 213 return;
213 usleep(1000); 214 nanosleep(&ts, NULL);
214 } 215 }
215 die("cannot grab keyboard\n"); 216 die("cannot grab keyboard\n");
216} 217}