summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2009-01-08 11:53:30 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2009-01-15 09:28:01 +1000
commitd645721170b1196e5064b397cfbffd1da8c79bb1 (patch)
tree10771fb7ebc4a14a3fae98fb40bcbce55771e360
parent639f289dcdbe00a516820f573c01a8339e120ed4 (diff)
mi: ensure chained button mappings from SD -> MD (#19282)
After copying the master event, flip the detail field to the mapped button of the SD, not the physical button. This way if the SD has a mapping 1:3 and the MD has a mapping of 3:4, a press on button 1 on the SD results in a core event on button 4. X.Org Bug 19282 <http://bugs.freedesktop.org/show_bug.cgi?id=19282> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--mi/mieq.c26
-rw-r--r--xkb/ddxDevBtn.c2
2 files changed, 25 insertions, 3 deletions
diff --git a/mi/mieq.c b/mi/mieq.c
index 963f27c01..3ce3c49d3 100644
--- a/mi/mieq.c
+++ b/mi/mieq.c
@@ -323,15 +323,32 @@ ChangeDeviceID(DeviceIntPtr dev, xEvent* event)
DebugF("[mi] Unknown event type (%d), cannot change id.\n", type);
}
+static void
+FixUpEventForMaster(DeviceIntPtr mdev, DeviceIntPtr sdev, xEvent* original,
+ EventListPtr master, int count)
+{
+ /* Ensure chained button mappings, i.e. that the detail field is the
+ * value of the mapped button on the SD, not the physical button */
+ if (original->u.u.type == DeviceButtonPress || original->u.u.type == DeviceButtonRelease)
+ {
+ int btn = original->u.u.detail;
+ if (!sdev->button)
+ return; /* Should never happen */
+
+ master->event->u.u.detail = sdev->button->map[btn];
+ }
+}
+
/**
* Copy the given event into master.
* @param mdev The master device
+ * @param sdev The slave device the original event comes from
* @param original The event as it came from the EQ
* @param master The event after being copied
* @param count Number of events in original.
*/
void
-CopyGetMasterEvent(DeviceIntPtr mdev, xEvent* original,
+CopyGetMasterEvent(DeviceIntPtr mdev, DeviceIntPtr sdev, xEvent* original,
EventListPtr master, int count)
{
int len = count * sizeof(xEvent);
@@ -346,9 +363,14 @@ CopyGetMasterEvent(DeviceIntPtr mdev, xEvent* original,
memcpy(master->event, original, len);
while (count--)
+ {
ChangeDeviceID(mdev, &master->event[count]);
+ FixUpEventForMaster(mdev, sdev, original, master, count);
+ }
}
+
+
/* Call this from ProcessInputEvents(). */
void
mieqProcessInputEvents(void)
@@ -419,7 +441,7 @@ mieqProcessInputEvents(void)
}
else {
if (master)
- CopyGetMasterEvent(master, event, masterEvents, nevents);
+ CopyGetMasterEvent(master, dev, event, masterEvents, nevents);
/* If someone's registered a custom event handler, let them
* steal it. */
diff --git a/xkb/ddxDevBtn.c b/xkb/ddxDevBtn.c
index 709efc13a..03fb440fe 100644
--- a/xkb/ddxDevBtn.c
+++ b/xkb/ddxDevBtn.c
@@ -116,7 +116,7 @@ DeviceIntPtr master = NULL;
if (!IsPointerDevice(master))
master = GetPairedDevice(dev->u.master);
- CopyGetMasterEvent(master, &events, masterEvents, count);
+ CopyGetMasterEvent(master, dev, &events, masterEvents, count);
}
(*dev->public.processInputProc)((xEventPtr)btn, dev, count);