summaryrefslogtreecommitdiff
path: root/Xi/exevents.c
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2011-12-06 11:40:33 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2011-12-13 13:24:00 +1000
commite0f37250ffff5dcb3bc0e8cad63439995ce01a20 (patch)
treea42833142f840bbc828c1f93f5794199edd8d1bd /Xi/exevents.c
parent6eff14a789341d366b3013c5aa020e959c954651 (diff)
Xi: deduplicate button motion mask setting
No functional changes 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.c37
1 files changed, 25 insertions, 12 deletions
diff --git a/Xi/exevents.c b/Xi/exevents.c
index b2e82ec06..211095743 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -704,6 +704,29 @@ ChangeMasterDeviceClasses(DeviceIntPtr device, DeviceChangedEvent *dce)
}
/**
+ * Add state and motionMask to the filter for this event. The protocol
+ * supports some extra masks for motion when a button is down:
+ * ButtonXMotionMask and the DeviceButtonMotionMask to trigger only when at
+ * least one button (or that specific button is down). These masks need to
+ * be added to the filters for core/XI motion events.
+ *
+ * @param device The device to update the mask for
+ * @param state The current button state mask
+ * @param motion_mask The motion mask (DeviceButtonMotionMask or 0)
+ */
+static void
+UpdateDeviceMotionMask(DeviceIntPtr device, unsigned short state,
+ Mask motion_mask)
+{
+ Mask mask;
+
+ mask = DevicePointerMotionMask | state | motion_mask;
+ SetMaskForEvent(device->id, mask, DeviceMotionNotify);
+ mask = PointerMotionMask | state | motion_mask;
+ SetMaskForEvent(device->id, mask, MotionNotify);
+}
+
+/**
* Update the device state according to the data in the event.
*
* return values are
@@ -801,7 +824,6 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event)
device->valuator->motionHintWindow = NullWindow;
set_key_up(device, key, KEY_PROCESSED);
} else if (event->type == ET_ButtonPress) {
- Mask mask;
if (!b)
return DONT_PROCESS;
@@ -818,13 +840,8 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event)
if (b->map[key] <= 5)
b->state |= (Button1Mask >> 1) << b->map[key];
- /* Add state and motionMask to the filter for this event */
- mask = DevicePointerMotionMask | b->state | b->motionMask;
- SetMaskForEvent(device->id, mask, DeviceMotionNotify);
- mask = PointerMotionMask | b->state | b->motionMask;
- SetMaskForEvent(device->id, mask, MotionNotify);
+ UpdateDeviceMotionMask(device, b->state, b->motionMask);
} else if (event->type == ET_ButtonRelease) {
- Mask mask;
if (!b)
return DONT_PROCESS;
@@ -859,11 +876,7 @@ UpdateDeviceState(DeviceIntPtr device, DeviceEvent* event)
if (b->map[key] <= 5)
b->state &= ~((Button1Mask >> 1) << b->map[key]);
- /* Add state and motionMask to the filter for this event */
- mask = DevicePointerMotionMask | b->state | b->motionMask;
- SetMaskForEvent(device->id, mask, DeviceMotionNotify);
- mask = PointerMotionMask | b->state | b->motionMask;
- SetMaskForEvent(device->id, mask, MotionNotify);
+ UpdateDeviceMotionMask(device, b->state, b->motionMask);
} else if (event->type == ET_ProximityIn)
device->proximity->in_proximity = TRUE;
else if (event->type == ET_ProximityOut)