summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/test_xi2.c4
-rw-r--r--src/xinput.c8
-rw-r--r--src/xinput.h1
3 files changed, 11 insertions, 2 deletions
diff --git a/src/test_xi2.c b/src/test_xi2.c
index 2201692..b08a395 100644
--- a/src/test_xi2.c
+++ b/src/test_xi2.c
@@ -240,7 +240,7 @@ test_sync_grab(Display *display, Window win)
XIEvent ev;
XNextEvent(display, (XEvent*)&ev);
- if (ev.type == GenericEvent)
+ if (ev.type == GenericEvent && ev.extension == xi_opcode )
{
XIDeviceEvent *event = (XIDeviceEvent*)&ev;
print_deviceevent(event);
@@ -325,7 +325,7 @@ test_xi2(Display *display,
{
XIEvent ev;
XNextEvent(display, (XEvent*)&ev);
- if (ev.type == GenericEvent)
+ if (ev.type == GenericEvent && ev.extension == xi_opcode)
{
XIDeviceEvent *event = (XIDeviceEvent*)&ev;
diff --git a/src/xinput.c b/src/xinput.c
index 275fa1b..8340211 100644
--- a/src/xinput.c
+++ b/src/xinput.c
@@ -25,6 +25,8 @@
#include <ctype.h>
#include <string.h>
+int xi_opcode;
+
typedef int (*prog)(Display* display, int argc, char *argv[],
char *prog_name, char *prog_desc);
@@ -257,6 +259,7 @@ main(int argc, char * argv[])
Display *display;
entry *driver = drivers;
char *func;
+ int event, error;
if (argc < 2) {
usage();
@@ -270,6 +273,11 @@ main(int argc, char * argv[])
return EXIT_FAILURE;
}
+ if (!XQueryExtension(display, "XInputExtension", &xi_opcode, &event, &error)) {
+ printf("X Input extension not available.\n");
+ return EXIT_FAILURE;
+ }
+
func = argv[1];
while((*func) == '-') func++;
diff --git a/src/xinput.h b/src/xinput.h
index fd468b0..d44ce09 100644
--- a/src/xinput.h
+++ b/src/xinput.h
@@ -41,6 +41,7 @@
#define EXIT_FAILURE 0
#endif
+extern int xi_opcode; /* xinput extension op code */
XDeviceInfo* find_device_info( Display *display, char *name, Bool only_extended);
#if HAVE_XI2
XIDeviceInfo* xi2_find_device_info(Display *display, char *name);