summaryrefslogtreecommitdiff
path: root/Xi
diff options
context:
space:
mode:
authorPeter Hutterer <peter@cs.unisa.edu.au>2008-01-09 17:36:39 +1030
committerPeter Hutterer <peter@cs.unisa.edu.au>2008-01-09 17:36:39 +1030
commit4e85c7c322faf14c14e4229fa294b8e3d3a4d304 (patch)
tree26f2d53a3233908c147c9ce880c3ae45c23fe39d /Xi
parent20ace6321ac464d821c67a82c7023f74ae038176 (diff)
Xi: keep a counter of buttons down to avoid duplicate press/release events.
If two devices are attached to the same master device, pressing button 1 on each of them leads to two button presses from the same device. Some apps really don't like that. So we just put a counter in place and only send the first press and the last release.
Diffstat (limited to 'Xi')
-rw-r--r--Xi/exevents.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/Xi/exevents.c b/Xi/exevents.c
index e577e3b25..fa3956597 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -348,13 +348,28 @@ DeepCopyDeviceClasses(DeviceIntPtr from, DeviceIntPtr to)
}
ALLOC_COPY_CLASS_IF(button, ButtonClassRec);
-#ifdef XKB
if (to->button)
{
+ int i;
+ DeviceIntPtr sd;
+
+ memset(to->button, 0, MAP_LENGTH);
+ /* merge button states from all attached devices */
+ for (sd = inputInfo.devices; sd; sd = sd->next)
+ {
+ if (sd->isMaster || sd->u.master != to)
+ continue;
+
+ for (i = 0; i < MAP_LENGTH; i++)
+ {
+ to->button->down[i] += sd->button->down[i];
+ }
+ }
+#ifdef XKB
to->button->xkb_acts = NULL;
/* XXX: XkbAction needs to be copied */
- }
#endif
+ }
ALLOC_COPY_CLASS_IF(focus, FocusClassRec);
ALLOC_COPY_CLASS_IF(proximity, ProximityClassRec);
ALLOC_COPY_CLASS_IF(absolute, AbsoluteClassRec);
@@ -541,8 +556,8 @@ UpdateDeviceState(DeviceIntPtr device, xEvent* xE, int count)
if (!b)
return DONT_PROCESS;
- kptr = &b->down[key >> 3];
- *kptr |= bit;
+ if (b->down[key]++ > 0)
+ return DONT_PROCESS;
if (device->valuator)
device->valuator->motionHintWindow = NullWindow;
b->buttonsDown++;
@@ -556,10 +571,10 @@ UpdateDeviceState(DeviceIntPtr device, xEvent* xE, int count)
if (!b)
return DONT_PROCESS;
- kptr = &b->down[key >> 3];
- if (!(*kptr & bit))
+ if (b->down[key] == 0)
+ return DONT_PROCESS;
+ if (--b->down[key] > 0)
return DONT_PROCESS;
- *kptr &= ~bit;
if (device->valuator)
device->valuator->motionHintWindow = NullWindow;
if (b->buttonsDown >= 1 && !--b->buttonsDown)