diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2011-10-28 10:19:36 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2011-10-28 10:19:36 +1000 |
commit | 798d322da99f90a14484b9fcbf57e60903687f97 (patch) | |
tree | 8b7b1647c7b526014c79a825d733de689f4e8992 | |
parent | ef37f8203949796cc0df346023f71f70e0b424f2 (diff) |
Move XQueryExtension call into init_x11
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | multitouch.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/multitouch.c b/multitouch.c index 5274fe8..7546c3f 100644 --- a/multitouch.c +++ b/multitouch.c @@ -18,6 +18,7 @@ struct multitouch { int screen; Window root; Window win; + int xi_opcode; }; static int error(const char *fmt, ...) @@ -82,19 +83,23 @@ static int init_x11(struct multitouch *mt) { Display *dpy; int major = 2, minor = 2; + int xi_opcode, xi_error, xi_event; dpy = XOpenDisplay(NULL); if (!dpy) return error("Invalid DISPLAY.\n"); + if (!XQueryExtension(dpy, INAME, &xi_opcode, &xi_event, &xi_error)) + return error("No X Input extension\n"); + if (XIQueryVersion(dpy, &major, &minor) != Success || major * 10 + minor < 22) return error("Need XI 2.2\n"); - - mt->dpy = dpy; - mt->screen = DefaultScreen(dpy); - mt->root = DefaultRootWindow(dpy); + mt->dpy = dpy; + mt->screen = DefaultScreen(dpy); + mt->root = DefaultRootWindow(dpy); + mt->xi_opcode = xi_opcode; mt->win = init_window(mt); if (!mt->win) @@ -125,14 +130,11 @@ 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); - while (running) { XEvent ev; @@ -145,7 +147,7 @@ static int main_loop(struct multitouch *mt) XNextEvent(mt->dpy, &ev); if (XGetEventData(mt->dpy, cookie) && cookie->type == GenericEvent && - cookie->extension == xi_opcode) + cookie->extension == mt->xi_opcode) { print_event(mt, cookie->data); } |