[PATCH v2 2/4 libinput] evdev: split scroll button state check out

Peter Hutterer peter.hutterer at who-t.net
Tue Apr 12 18:50:55 UTC 2016


Rather than checking the physical key's state, set a flag for the button to be
down. This enables us to use non-physical buttons (middle button emulation).

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
changes to v1:
- replaces previous 2/4 patch

 src/evdev.c | 4 +++-
 src/evdev.h | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/evdev.c b/src/evdev.c
index 7ffc464..2afec6e 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -273,7 +273,7 @@ evdev_post_trackpoint_scroll(struct evdev_device *device,
 			     uint64_t time)
 {
 	if (device->scroll.method != LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN ||
-	    !hw_is_key_down(device, device->scroll.button))
+	    !device->scroll.button_scroll_btn_pressed)
 		return false;
 
 	if (device->scroll.button_scroll_active)
@@ -494,6 +494,8 @@ static void
 evdev_button_scroll_button(struct evdev_device *device,
 			   uint64_t time, int is_press)
 {
+	device->scroll.button_scroll_btn_pressed = is_press;
+
 	if (is_press) {
 		libinput_timer_set(&device->scroll.timer,
 				   time + DEFAULT_MIDDLE_BUTTON_SCROLL_TIMEOUT);
diff --git a/src/evdev.h b/src/evdev.h
index 3a7693e..520446d 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -173,6 +173,7 @@ struct evdev_device {
 		/* Checks if buttons are down and commits the setting */
 		void (*change_scroll_method)(struct evdev_device *device);
 		bool button_scroll_active;
+		bool button_scroll_btn_pressed;
 		double threshold;
 		double direction_lock_threshold;
 		uint32_t direction;
-- 
2.5.5



More information about the wayland-devel mailing list