Replace deprecated usleep() with nanosleep()
This commit is contained in:
parent
c15a95a061
commit
c42c378027
5
dmenu.c
5
dmenu.c
|
@ -6,7 +6,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include <unistd.h>
|
#include <time.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
|
@ -203,6 +203,7 @@ drawmenu(void)
|
||||||
static void
|
static void
|
||||||
grabkeyboard(void)
|
grabkeyboard(void)
|
||||||
{
|
{
|
||||||
|
struct timespec ts = { .tv_sec = 1, .tv_nsec = 0 };
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* try to grab keyboard, we may have to wait for another process to ungrab */
|
/* try to grab keyboard, we may have to wait for another process to ungrab */
|
||||||
|
@ -210,7 +211,7 @@ grabkeyboard(void)
|
||||||
if (XGrabKeyboard(dpy, DefaultRootWindow(dpy), True,
|
if (XGrabKeyboard(dpy, DefaultRootWindow(dpy), True,
|
||||||
GrabModeAsync, GrabModeAsync, CurrentTime) == GrabSuccess)
|
GrabModeAsync, GrabModeAsync, CurrentTime) == GrabSuccess)
|
||||||
return;
|
return;
|
||||||
usleep(1000);
|
nanosleep(&ts, NULL);
|
||||||
}
|
}
|
||||||
die("cannot grab keyboard\n");
|
die("cannot grab keyboard\n");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user