summaryrefslogtreecommitdiff
path: root/Xi/exevents.c
diff options
context:
space:
mode:
authorPeter Hutterer <peter@cs.unisa.edu.au>2007-11-09 23:10:24 +1030
committerPeter Hutterer <peter@cs.unisa.edu.au>2007-11-09 23:10:24 +1030
commit7a81bafc9bc7048560b17483e6addf58469a05d0 (patch)
treec6babb6619ccd1cb977edfe0fbb73cc3b891b524 /Xi/exevents.c
parentc0a05805783ee3d38fbcc0fb45f4aa3c511785f0 (diff)
Xi, dix: Add ability to change MD classes + send event when doing so.
Each time a different slave device sends through a master, an DeviceClassesChangedEvent is enqueued. When this event is processed, all classes of the matching master device are changed, and the event is sent to the clients. Next time the master is queried, it thus shows the evclasses of the last slave device. The original classes are stored in the devPrivates. TODO: if all slave devices are removed, the master's original classes need to be restored.
Diffstat (limited to 'Xi/exevents.c')
-rw-r--r--Xi/exevents.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/Xi/exevents.c b/Xi/exevents.c
index 4c57fd017..617aef7b4 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -73,6 +73,7 @@ SOFTWARE.
#include "dixevents.h" /* DeliverFocusedEvent */
#include "dixgrabs.h" /* CreateGrab() */
#include "scrnintstr.h"
+#include "listdev.h" /* for CopySwapXXXClass */
#ifdef XKB
#include "xkbsrv.h"
@@ -127,6 +128,62 @@ ProcessOtherEvent(xEventPtr xE, DeviceIntPtr device, int count)
xEvent core;
int coretype = 0;
+ /* This event is always the first we get, before the actual events with
+ * the data. However, the way how the DDX is set up, "device" will
+ * actually be the slave device that caused the event.
+ */
+ if (GEIsType(xE, IReqCode, XI_DeviceClassesChangedNotify))
+ {
+ deviceClassesChangedEvent* dcce = (deviceClassesChangedEvent*)xE;
+ DeviceIntPtr master = device->u.master;
+ char* classbuff;
+
+ if (device->isMaster)
+ return;
+
+ if (!master) /* if device was set floating between SIGIO and now */
+ return;
+
+ dcce->deviceid = master->id;
+ dcce->num_classes = 0;
+
+ master->key = device->key;
+ master->valuator = device->valuator;
+ master->button = device->button;
+ master->focus = device->focus;
+ master->proximity = device->proximity;
+ master->absolute = device->absolute;
+ master->kbdfeed = device->kbdfeed;
+ master->ptrfeed = device->ptrfeed;
+ master->intfeed = device->intfeed;
+ master->stringfeed = device->stringfeed;
+ master->bell = device->bell;
+ master->leds = device->leds;
+
+ /* event is already correct size, see comment in GetPointerEvents */
+ classbuff = (char*)&xE[1];
+ if (master->key)
+ {
+ /* we don't actually swap here, swapping is done later */
+ CopySwapKeyClass(NullClient, master->key, &classbuff);
+ dcce->num_classes++;
+ }
+ if (master->button)
+ {
+ CopySwapButtonClass(NullClient, master->button, &classbuff);
+ dcce->num_classes++;
+ }
+ if (master->valuator)
+ {
+ CopySwapValuatorClass(NullClient, master->valuator, &classbuff);
+ dcce->num_classes++;
+ }
+
+ SendEventToAllWindows(master, XI_DeviceClassesChangedMask,
+ xE, 1);
+ return;
+ }
+
coretype = XItoCoreType(xE->u.u.type);
if (device->isMaster && device->coreEvents && coretype)
sendCore = TRUE;