diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2009-02-20 16:07:33 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2009-03-20 15:17:55 +1000 |
commit | 38bba0c1b75b84e8bbdfa7975cf701a9414a3afd (patch) | |
tree | 8d9f6b47c58b93f123e9b2966b6997061e1c4089 /dix/eventconvert.c | |
parent | 181e41511d5772962b8bc998a1940d2a9ba62d5e (diff) |
Xi: Change ChangeMasterDeviceClasses to new XI2 events.
Split ChangeMasterDeviceClasses into an extra XISendDeviceChangedEvent that
assembles the XI2 wire event for the DeviceChanged event. Re-use this when
detaching the last SD.
Not quite perfect yet, we still copy the device classes from the slave now
rather than from the data we had when the event occured. But it's a start.
(We can now unexport SizeDeviceInfo and CopySwapDevices, not needed anymore)
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'dix/eventconvert.c')
-rw-r--r-- | dix/eventconvert.c | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/dix/eventconvert.c b/dix/eventconvert.c index c3328d63f..553d95330 100644 --- a/dix/eventconvert.c +++ b/dix/eventconvert.c @@ -45,13 +45,12 @@ #include "events.h" #include "exglobals.h" #include "eventconvert.h" -#include "listdev.h" +#include "querydev.h" static int countValuators(DeviceEvent *ev, int *first); static int getValuatorEvents(DeviceEvent *ev, deviceValuator *xv); static int eventToKeyButtonPointer(DeviceEvent *ev, xEvent **xi, int *count); -static int eventToClassesChanged(DeviceChangedEvent *ev, xEvent **dcce, - int *count); +static int eventToClassesChanged(DeviceChangedEvent *ev, xEvent **dcce); static int eventToDeviceEvent(DeviceEvent *ev, xEvent **xi); /** * Convert the given event to the respective core event. @@ -127,8 +126,9 @@ EventToXI(InternalEvent *ev, xEvent **xi, int *count) case ET_ProximityOut: return eventToKeyButtonPointer((DeviceEvent*)ev, xi, count); case ET_DeviceChanged: - return eventToClassesChanged((DeviceChangedEvent*)ev, xi, count); - break; + *count = 0; + *xi = NULL; + return Success; } ErrorF("[dix] EventToXI: Not implemented for %d \n", ev->u.any.type); @@ -162,6 +162,9 @@ EventToXI2(InternalEvent *ev, xEvent **xi) case ET_ProximityOut: *xi = NULL; return Success; + case ET_DeviceChanged: + return eventToClassesChanged((DeviceChangedEvent*)ev, xi); + } ErrorF("[dix] EventToXI2: Not implemented for %d \n", ev->u.any.type); @@ -290,14 +293,12 @@ getValuatorEvents(DeviceEvent *ev, deviceValuator *xv) } static int -eventToClassesChanged(DeviceChangedEvent *ev, xEvent **xi, int *count) +eventToClassesChanged(DeviceChangedEvent *ev, xEvent **xi) { int len = sizeof(xEvent); - int namelen = 0; /* dummy */ DeviceIntPtr slave; int rc; - deviceClassesChangedEvent *dcce; - + xXIDeviceChangedEvent *dce; rc = dixLookupDevice(&slave, ev->new_slaveid, serverClient, DixReadAccess); @@ -305,21 +306,25 @@ eventToClassesChanged(DeviceChangedEvent *ev, xEvent **xi, int *count) if (rc != Success) return rc; - SizeDeviceInfo(slave, &namelen, &len); + len += SizeDeviceClasses(slave); *xi = xcalloc(1, len); if (!(*xi)) return BadAlloc; - dcce = (deviceClassesChangedEvent*)(*xi); - dcce->type = GenericEvent; - dcce->extension = IReqCode; - dcce->evtype = XI_DeviceClassesChangedNotify; - dcce->time = GetTimeInMillis(); - dcce->new_slave = slave->id; - dcce->length = (len - sizeof(xEvent))/4; + dce = (xXIDeviceChangedEvent*)(*xi); + dce->type = GenericEvent; + dce->extension = IReqCode; + dce->evtype = XI_DeviceChanged; + dce->time = GetTimeInMillis(); + dce->sourceid = slave->id; + dce->reason = SlaveSwitch; + dce->length = (len - sizeof(xEvent))/4; + + /* FIXME: this should come from the event, not from the device. See + * CreateClassesChangedEvent */ + ListDeviceClasses(slave, (char*)&dce[1], &dce->num_classes); - *count = 1; return Success; } @@ -350,7 +355,6 @@ eventToDeviceEvent(DeviceEvent *ev, xEvent **xi) char *ptr; int32_t *axisval; - /* FIXME: this should just send the buttons we have, not MAX_BUTTONs. Same * with MAX_VALUATORS below */ /* btlen is in 4 byte units */ |