summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2014-11-10 08:39:58 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2014-11-11 10:00:56 +1000
commitffad279751446a74b2f1298c46442796464e961a (patch)
tree187d80d909e826f188c6f9fa9060bc506fa60d9d /src
parentd7a1addcdde245dbb506528287fda5df7d3de5b7 (diff)
downloadlibinput-ffad279751446a74b2f1298c46442796464e961a.tar.gz
evdev: move scroll flag setting/check into a helper function
Much more readable, especially with the upcoming patches. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/evdev.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/evdev.c b/src/evdev.c
index 84c42b69..222d6b1c 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1491,6 +1491,26 @@ evdev_device_get_size(struct evdev_device *device,
return 0;
}
+static inline bool
+evdev_is_scrolling(const struct evdev_device *device,
+ enum libinput_pointer_axis axis)
+{
+ assert(axis == LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL ||
+ axis == LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL);
+
+ return (device->scroll.direction & (1 << axis)) != 0;
+}
+
+static inline void
+evdev_start_scrolling(struct evdev_device *device,
+ enum libinput_pointer_axis axis)
+{
+ assert(axis == LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL ||
+ axis == LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL);
+
+ device->scroll.direction |= (1 << axis);
+}
+
void
evdev_post_scroll(struct evdev_device *device,
uint64_t time,
@@ -1498,13 +1518,16 @@ evdev_post_scroll(struct evdev_device *device,
double dy)
{
if (dy <= -device->scroll.threshold || dy >= device->scroll.threshold)
- device->scroll.direction |= (1 << LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL);
+ evdev_start_scrolling(device,
+ LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL);
if (dx <= -device->scroll.threshold || dx >= device->scroll.threshold)
- device->scroll.direction |= (1 << LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL);
+ evdev_start_scrolling(device,
+ LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL);
if (dy != 0.0 &&
- (device->scroll.direction & (1 << LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL))) {
+ evdev_is_scrolling(device,
+ LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL)) {
pointer_notify_axis(&device->base,
time,
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL,
@@ -1512,7 +1535,8 @@ evdev_post_scroll(struct evdev_device *device,
}
if (dx != 0.0 &&
- (device->scroll.direction & (1 << LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL))) {
+ evdev_is_scrolling(device,
+ LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL)) {
pointer_notify_axis(&device->base,
time,
LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL,