summaryrefslogtreecommitdiff
path: root/Xi/exevents.c
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2011-12-06 12:04:11 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2011-12-13 13:24:00 +1000
commit86c3137c81e924bacd919e9d65809e07afeabbff (patch)
treeba78cbe3fa22550e560bf7d2775dd26e16266405 /Xi/exevents.c
parente0f37250ffff5dcb3bc0e8cad63439995ce01a20 (diff)
Xi: split updating button count and state into helper functions
Functional change: for a button mapped to 0, the motionHintWindow is not updated to the NullWindow anymore. Before it got updated unconditionally to the button mapping. I have no idea what the practical effect of this is, but I guess it's closer to the correct behaviour: pressing a button that's logically disabled now does not disrupt the motion hint delivery. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
Diffstat (limited to 'Xi/exevents.c')
-rw-r--r--Xi/exevents.c41
1 files changed, 29 insertions, 12 deletions
diff --git a/Xi/exevents.c b/Xi/exevents.c
index 211095743..798377670 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -726,6 +726,32 @@ UpdateDeviceMotionMask(DeviceIntPtr device, unsigned short state,
SetMaskForEvent(device->id, mask, MotionNotify);
}
+static void
+IncreaseButtonCount(DeviceIntPtr dev, int key, CARD8 *buttons_down,
+ Mask *motion_mask, unsigned short *state)
+{
+ if (dev->valuator)
+ dev->valuator->motionHintWindow = NullWindow;
+
+ (*buttons_down)++;
+ *motion_mask = DeviceButtonMotionMask;
+ if (dev->button->map[key] <= 5)
+ *state |= (Button1Mask >> 1) << dev->button->map[key];
+}
+
+static void
+DecreaseButtonCount(DeviceIntPtr dev, int key, CARD8 *buttons_down,
+ Mask *motion_mask, unsigned short *state)
+{
+ if (dev->valuator)
+ dev->valuator->motionHintWindow = NullWindow;
+
+ if (*buttons_down >= 1 && !--(*buttons_down))
+ *motion_mask = 0;
+ if (dev->button->map[key] <= 5)
+ *state &= ~((Button1Mask >> 1) << dev->button->map[key]);
+}
+
/**
* Update the device state according to the data in the event.
*
@@ -831,15 +857,11 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event)
return DONT_PROCESS;
set_button_down(device, key, BUTTON_PROCESSED);
- if (device->valuator)
- device->valuator->motionHintWindow = NullWindow;
+
if (!b->map[key])
return DONT_PROCESS;
- b->buttonsDown++;
- b->motionMask = DeviceButtonMotionMask;
- if (b->map[key] <= 5)
- b->state |= (Button1Mask >> 1) << b->map[key];
+ IncreaseButtonCount(device, key, &b->buttonsDown, &b->motionMask, &b->state);
UpdateDeviceMotionMask(device, b->state, b->motionMask);
} else if (event->type == ET_ButtonRelease) {
if (!b)
@@ -867,15 +889,10 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event)
}
}
set_button_up(device, key, BUTTON_PROCESSED);
- if (device->valuator)
- device->valuator->motionHintWindow = NullWindow;
if (!b->map[key])
return DONT_PROCESS;
- if (b->buttonsDown >= 1 && !--b->buttonsDown)
- b->motionMask = 0;
- if (b->map[key] <= 5)
- b->state &= ~((Button1Mask >> 1) << b->map[key]);
+ DecreaseButtonCount(device, key, &b->buttonsDown, &b->motionMask, &b->state);
UpdateDeviceMotionMask(device, b->state, b->motionMask);
} else if (event->type == ET_ProximityIn)
device->proximity->in_proximity = TRUE;