summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2011-10-26 16:09:44 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2011-10-26 16:09:44 +1000
commitef37f8203949796cc0df346023f71f70e0b424f2 (patch)
tree2cf32aa80dc2eac969b975d20529646070faaba6
parent45eb289f0990db43e8beb1a349c76898486061a6 (diff)
Use poll(2) so we can actually interrupt as expected
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--multitouch.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/multitouch.c b/multitouch.c
index 62aa348..5274fe8 100644
--- a/multitouch.c
+++ b/multitouch.c
@@ -7,6 +7,7 @@
#include <stdlib.h>
#include <stdarg.h>
#include <signal.h>
+#include <poll.h>
#include <X11/Xlib.h>
#include <X11/extensions/XInput.h>
@@ -125,6 +126,10 @@ static void print_event(struct multitouch *mt, XIDeviceEvent* event)
static int main_loop(struct multitouch *mt)
{
int xi_opcode, xi_error, xi_event;
+ struct pollfd fd;
+
+ fd.fd = ConnectionNumber(mt->dpy);
+ fd.events = POLLIN;
XQueryExtension(mt->dpy, INAME, &xi_opcode, &xi_event, &xi_error);
@@ -132,6 +137,11 @@ static int main_loop(struct multitouch *mt)
{
XEvent ev;
XGenericEventCookie *cookie = &ev.xcookie;
+
+
+ if (poll(&fd, 1, 500) <= 0)
+ continue;
+
XNextEvent(mt->dpy, &ev);
if (XGetEventData(mt->dpy, cookie) &&
cookie->type == GenericEvent &&