diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2009-03-08 21:16:33 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2009-03-11 14:49:07 +1000 |
commit | 30c2e3f9398f3d9cbae70150e4bb5cec6dfcc0a1 (patch) | |
tree | 2f8a1235e50e4cb3123517d4b60b505eacaedcf8 | |
parent | 0cac1faccebdd317e889d2ae1a1570dc9430725f (diff) |
Add support for XIDeviceChangedEvent
-rw-r--r-- | include/X11/extensions/XInput2.h | 10 | ||||
-rw-r--r-- | src/XExtInt.c | 35 | ||||
-rw-r--r-- | src/XIFreeEvent.c | 3 | ||||
-rw-r--r-- | src/XIQueryDevice.c | 2 |
4 files changed, 44 insertions, 6 deletions
diff --git a/include/X11/extensions/XInput2.h b/include/X11/extensions/XInput2.h index 60138b1..4ef622c 100644 --- a/include/X11/extensions/XInput2.h +++ b/include/X11/extensions/XInput2.h @@ -157,12 +157,12 @@ typedef struct { int extension; /* XI extension offset */ int evtype; /* XI_DeviceHierarchyChangedNotify */ Time time; - XID deviceid; /* id of the device that changed */ - XID slaveid; /* id of the slave device that caused the - change */ + int deviceid; /* id of the device that changed */ + int sourceid; /* Source for the new classes. */ + int reason; /* Reason for the change */ int num_classes; - XIAnyClassInfo *inputclassinfo; /* same as in XDeviceInfo */ -} XDeviceClassesChangedEvent; + XIAnyClassInfo **classes; /* same as in XIDeviceInfo */ +} XIDeviceChangedEvent; typedef struct { diff --git a/src/XExtInt.c b/src/XExtInt.c index b9f10fe..77575b3 100644 --- a/src/XExtInt.c +++ b/src/XExtInt.c @@ -99,6 +99,9 @@ extern int _XiGetDevicePresenceNotifyEvent( Display * /* dpy */ ); +extern int copy_classes(XIDeviceInfo *to, xXIAnyInfo* from, int nclasses); + + static XExtensionInfo *xinput_info; static /* const */ char *xinput_extension_name = INAME; @@ -123,6 +126,8 @@ static Bool XInputWireToEvent( static int wireToDeviceEvent(xXIDeviceEvent *in, XIDeviceEvent* out); +static int +wireToDeviceChangedEvent(xXIDeviceChangedEvent *in, XIDeviceChangedEvent* out); static /* const */ XEvent emptyevent; @@ -792,6 +797,15 @@ XInputWireToEvent( break; } return ENQUEUE_EVENT; + case XI_DeviceChanged: + *re = *save; + if (!wireToDeviceChangedEvent(event, re)) + { + printf("XInputWireToEvent: CONVERSION FAILURE! evtype=%d\n", + ge->evtype); + break; + } + return ENQUEUE_EVENT; #if 0 case XI_HierarchyChangedNotify: @@ -929,3 +943,24 @@ wireToDeviceEvent(xXIDeviceEvent *in, XIDeviceEvent* out) return 1; } + + +static int +wireToDeviceChangedEvent(xXIDeviceChangedEvent *in, XIDeviceChangedEvent* out) +{ + XIDeviceInfo info; + out->type = in->type; + out->extension = in->extension; + out->evtype = in->evtype; + out->time = in->time; + out->deviceid = in->deviceid; + out->sourceid = in->sourceid; + out->reason = in->reason; + out->num_classes = in->num_classes; + + copy_classes(&info, (xXIAnyInfo*)&in[1], out->num_classes); + out->classes= info.classes; + + return 1; +} + diff --git a/src/XIFreeEvent.c b/src/XIFreeEvent.c index 2dd0100..053cd2e 100644 --- a/src/XIFreeEvent.c +++ b/src/XIFreeEvent.c @@ -49,5 +49,8 @@ XIFreeEventData(XIEvent *event) free(ev->group); } break; + case XI_DeviceChanged: + free(((XIDeviceChangedEvent*)event)->classes); + break; } } diff --git a/src/XIQueryDevice.c b/src/XIQueryDevice.c index 83d10be..1e17ad0 100644 --- a/src/XIQueryDevice.c +++ b/src/XIQueryDevice.c @@ -35,7 +35,7 @@ * |________|___________^ * |______________________^ */ -static int +int copy_classes(XIDeviceInfo* to, xXIAnyInfo* from, int nclasses) { XIAnyClassInfo *any_lib; |