diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2009-06-18 14:40:20 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2009-06-18 15:50:47 +1000 |
commit | e92dcb6ce07aa3cfb53e8bad5701481c106c4094 (patch) | |
tree | 4008c4a7c54a0f193830412ff04c52efac2d78f9 /Xi | |
parent | 280b7f92d729ec910ffa3d18dce7bbc215be7a3c (diff) |
input: unify button numbers on master devices.
Master devices provide the union of all attached slave devices' buttons,
i.e. the number of buttons on the master device is always the number of
buttons of the slave device with the highest number of buttons. When slaves
are attached or detached, the master device adjusts the button number to
reflect the new buttons.
On a slave switch, this slave's button labels are copied into the master (up
to slave->num_buttons). The remaining button labels (if any) stay as they
are. Thus, if any of the higher buttons is still pressed, it reflects the
label of the last pressed device that provided this button.
If two devices press the same button and it is differently labelled the last
pressed one will be reflected in the master device.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'Xi')
-rw-r--r-- | Xi/exevents.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/Xi/exevents.c b/Xi/exevents.c index 8b69a3ad3..e54af094e 100644 --- a/Xi/exevents.c +++ b/Xi/exevents.c @@ -588,6 +588,8 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to) } else xfree(to->button->xkb_acts); + memcpy(to->button->labels, from->button->labels, + from->button->numButtons * sizeof(Atom)); to->button->sourceid = from->id; } else if (to->button && !from->button) { @@ -670,10 +672,7 @@ DeepCopyDeviceClasses(DeviceIntPtr from, DeviceIntPtr to, DeviceChangedEvent *dc /** - * Change MD to look like SD by copying all classes over. An event is sent to - * all interested clients. - * @param device The slave device - * @param dcce Pointer to the event struct. + * Send an XI2 DeviceChangedEvent to all interested clients. */ void XISendDeviceChangedEvent(DeviceIntPtr device, DeviceIntPtr master, DeviceChangedEvent *dce) @@ -700,7 +699,7 @@ XISendDeviceChangedEvent(DeviceIntPtr device, DeviceIntPtr master, DeviceChanged len += sizeof(CARD32) * nkeys; /* keycodes */ } - dcce = xalloc(len); + dcce = xcalloc(1, len); if (!dcce) { ErrorF("[Xi] BadAlloc in SendDeviceChangedEvent.\n"); @@ -713,7 +712,7 @@ XISendDeviceChangedEvent(DeviceIntPtr device, DeviceIntPtr master, DeviceChanged dcce->time = GetTimeInMillis(); dcce->deviceid = master->id; dcce->sourceid = device->id; - dcce->reason = XISlaveSwitch; + dcce->reason = (dce->flags & DEVCHANGE_DEVICE_CHANGE) ? XIDeviceChange : XISlaveSwitch; dcce->num_classes = 0; dcce->length = (len - sizeof(xEvent))/4; |