wmpager: use select(2) instead of usleep(3), increase sleep time to 0.5 sec
This commit is contained in:
parent
2f27664839
commit
79857511c5
|
@ -11,6 +11,7 @@
|
||||||
#include <X11/extensions/shape.h>
|
#include <X11/extensions/shape.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <sys/select.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -278,6 +279,7 @@ void initApplicationName (char* szApplicationName) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static Display* _display;
|
static Display* _display;
|
||||||
|
static int _xfd;
|
||||||
|
|
||||||
Display* getDisplay () {
|
Display* getDisplay () {
|
||||||
return _display;
|
return _display;
|
||||||
|
@ -308,6 +310,7 @@ void initDisplay (char* szDisplay) {
|
||||||
);
|
);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
_xfd= XConnectionNumber(_display);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -697,6 +700,8 @@ void loop () {
|
||||||
Display* display= getDisplay();
|
Display* display= getDisplay();
|
||||||
XEvent event;
|
XEvent event;
|
||||||
char* atom_name;
|
char* atom_name;
|
||||||
|
struct timeval tv;
|
||||||
|
fd_set fds;
|
||||||
|
|
||||||
if (isVerbose()) {
|
if (isVerbose()) {
|
||||||
fprintf(stdout, "[%8ld] starting event loop\n", currentTimeMillis());
|
fprintf(stdout, "[%8ld] starting event loop\n", currentTimeMillis());
|
||||||
|
@ -749,7 +754,12 @@ void loop () {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
usleep(50000);
|
|
||||||
|
tv.tv_sec = 0;
|
||||||
|
tv.tv_usec = 500000UL;
|
||||||
|
FD_ZERO(&fds);
|
||||||
|
FD_SET(_xfd, &fds);
|
||||||
|
select(_xfd + 1, &fds, NULL, NULL, &tv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue