summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Close <Benjamin.Close@clearchain.com>2009-06-24 11:55:00 +0930
committerPeter Hutterer <peter.hutterer@who-t.net>2009-06-24 12:35:56 +1000
commit248faefc957a9b0877384842540b2d935e1b5c07 (patch)
treefb5aeb5f8adb32e16f17bcd6f47d0cb434fa63e4
parent1c28ba44958389892470688ce394c034dc8efa21 (diff)
Obtain the XInput opcode and check that GenericEvents are actually XI events
Signed-off-by: Benjamin Close <Benjamin.Close@clearchain.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-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);