dix: rework DeviceChangedEvents a bit.
DCEs are now processed when sent throught the master device, not when sent through the slave device. This includes a removal of some un-used (or partly used) fields in the DCE itself to something more self-explanatory. TODO: if a device has events queued and its attachment is changed, the DCE is silently dropped now. Instead, it should be generated as soon as the first event after the attachment is sent. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
c1d901d723
commit
2851f04cb2
|
@ -699,23 +699,31 @@ XISendDeviceChangedEvent(DeviceIntPtr device, DeviceIntPtr master, DeviceChanged
|
|||
static void
|
||||
ChangeMasterDeviceClasses(DeviceIntPtr device, DeviceChangedEvent *dce)
|
||||
{
|
||||
DeviceIntPtr master = device->u.master;
|
||||
DeviceIntPtr slave;
|
||||
int rc;
|
||||
|
||||
if (IsMaster(device))
|
||||
/* For now, we don't have devices that change physically. */
|
||||
if (!IsMaster(device))
|
||||
return;
|
||||
|
||||
if (!master) /* if device was set floating between SIGIO and now */
|
||||
return;
|
||||
rc = dixLookupDevice(&slave, dce->sourceid, serverClient, DixReadAccess);
|
||||
|
||||
if (rc != Success)
|
||||
return; /* Device has disappeared */
|
||||
|
||||
master = GetMaster(device,
|
||||
(dce->flags & DEVCHANGE_POINTER_EVENT) ? MASTER_POINTER : MASTER_KEYBOARD);
|
||||
if (!slave->u.master)
|
||||
return; /* set floating since the event */
|
||||
|
||||
master->public.devicePrivate = device->public.devicePrivate;
|
||||
if (slave->u.master->id != dce->masterid)
|
||||
return; /* not our slave anymore, don't care */
|
||||
|
||||
/* FIXME: we probably need to send a DCE for the new slave now */
|
||||
|
||||
device->public.devicePrivate = slave->public.devicePrivate;
|
||||
|
||||
/* FIXME: the classes may have changed since we generated the event. */
|
||||
DeepCopyDeviceClasses(device, master, dce);
|
||||
XISendDeviceChangedEvent(device, master, dce);
|
||||
DeepCopyDeviceClasses(slave, device, dce);
|
||||
XISendDeviceChangedEvent(slave, device, dce);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -350,7 +350,7 @@ appendKeyInfo(DeviceChangedEvent *dce, xXIKeyInfo* info)
|
|||
info->type = XIKeyClass;
|
||||
info->num_keycodes = dce->keys.max_keycode - dce->keys.min_keycode + 1;
|
||||
info->length = sizeof(xXIKeyInfo)/4 + info->num_keycodes;
|
||||
info->sourceid = dce->deviceid;
|
||||
info->sourceid = dce->sourceid;
|
||||
|
||||
kc = (uint32_t*)&info[1];
|
||||
for (i = 0; i < info->num_keycodes; i++)
|
||||
|
@ -371,7 +371,7 @@ appendButtonInfo(DeviceChangedEvent *dce, xXIButtonInfo *info)
|
|||
info->num_buttons = dce->buttons.num_buttons;
|
||||
info->length = bytes_to_int32(sizeof(xXIButtonInfo)) +
|
||||
info->num_buttons + mask_len;
|
||||
info->sourceid = dce->deviceid;
|
||||
info->sourceid = dce->sourceid;
|
||||
|
||||
bits = (unsigned char*)&info[1];
|
||||
memset(bits, 0, mask_len * 4);
|
||||
|
@ -399,7 +399,7 @@ appendValuatorInfo(DeviceChangedEvent *dce, xXIValuatorInfo *info, int axisnumbe
|
|||
info->resolution = dce->valuators[axisnumber].resolution;
|
||||
info->number = axisnumber;
|
||||
info->mode = dce->valuators[axisnumber].mode; /* Server doesn't have per-axis mode yet */
|
||||
info->sourceid = dce->deviceid;
|
||||
info->sourceid = dce->sourceid;
|
||||
|
||||
return info->length * 4;
|
||||
}
|
||||
|
@ -441,7 +441,7 @@ eventToDeviceChanged(DeviceChangedEvent *dce, xEvent **xi)
|
|||
dcce->evtype = XI_DeviceChanged;
|
||||
dcce->time = dce->time;
|
||||
dcce->deviceid = dce->deviceid;
|
||||
dcce->sourceid = dce->deviceid;
|
||||
dcce->sourceid = dce->sourceid;
|
||||
dcce->reason = (dce->flags & DEVCHANGE_DEVICE_CHANGE) ? XIDeviceChange : XISlaveSwitch;
|
||||
dcce->num_classes = 0;
|
||||
dcce->length = bytes_to_int32(len - sizeof(xEvent));
|
||||
|
|
|
@ -193,19 +193,15 @@ CreateClassesChangedEvent(EventList* event,
|
|||
|
||||
dce = (DeviceChangedEvent*)event->event;
|
||||
memset(dce, 0, sizeof(DeviceChangedEvent));
|
||||
dce->deviceid = master->id;
|
||||
dce->deviceid = slave->id;
|
||||
dce->masterid = master->id;
|
||||
dce->header = ET_Internal;
|
||||
dce->length = sizeof(DeviceChangedEvent);
|
||||
dce->type = ET_DeviceChanged;
|
||||
dce->time = ms;
|
||||
dce->flags = type;
|
||||
if (master->last.slave)
|
||||
{
|
||||
dce->flags |= DEVCHANGE_HAS_OLD_SLAVE;
|
||||
dce->old_slaveid = master->last.slave->id;
|
||||
}
|
||||
dce->flags |= DEVCHANGE_HAS_NEW_SLAVE;
|
||||
dce->new_slaveid = slave->id;
|
||||
dce->flags |= DEVCHANGE_SLAVE_SWITCH;
|
||||
dce->sourceid = slave->id;
|
||||
|
||||
if (slave->button)
|
||||
{
|
||||
|
|
|
@ -120,9 +120,8 @@ struct _DeviceEvent
|
|||
};
|
||||
|
||||
|
||||
/* Flags used in DeviceChangedEvent to signal if new/old slave is present. */
|
||||
#define DEVCHANGE_HAS_OLD_SLAVE 0x1
|
||||
#define DEVCHANGE_HAS_NEW_SLAVE 0x2
|
||||
/* Flags used in DeviceChangedEvent to signal if the slave has changed */
|
||||
#define DEVCHANGE_SLAVE_SWITCH 0x2
|
||||
/* Flags used in DeviceChangedEvent to signal whether the event was a
|
||||
* pointer event or a keyboard event */
|
||||
#define DEVCHANGE_POINTER_EVENT 0x4
|
||||
|
@ -140,14 +139,10 @@ struct _DeviceChangedEvent
|
|||
int length; /**< Length in bytes */
|
||||
Time time; /**< Time in ms */
|
||||
int deviceid; /**< Device whose capabilities have changed */
|
||||
int flags; /**< Mask of ::HAS_OLD_SLAVE, ::HAS_NEW_SLAVE,
|
||||
int flags; /**< Mask of ::HAS_NEW_SLAVE,
|
||||
::POINTER_EVENT, ::KEYBOARD_EVENT */
|
||||
/** If flags & HAS_OLD_SLAVE is set, old_slaveid specifies SD previously
|
||||
* attached to this device. */
|
||||
int old_slaveid;
|
||||
/** If flags & HAS_NEW_SLAVE is set, new_slaveid specifies device now
|
||||
* attached to this device. */
|
||||
int new_slaveid;
|
||||
int masterid; /**< MD when event was generated */
|
||||
int sourceid; /**< The device that caused the change */
|
||||
|
||||
struct {
|
||||
int num_buttons; /**< Number of buttons */
|
||||
|
|
Loading…
Reference in New Issue