Blame SOURCES/0012-xwayland-Implement-tablet_tool_wheel-for-scrolling.patch

c40fb2
From d03bf0d1759d7d113216a0311e794b5adb0845de Mon Sep 17 00:00:00 2001
c40fb2
From: Jason Gerecke <killertofu@gmail.com>
c40fb2
Date: Fri, 9 Jun 2017 16:02:07 -0700
c40fb2
Subject: [PATCH xserver 12/12] xwayland: Implement tablet_tool_wheel for
c40fb2
 scrolling
c40fb2
c40fb2
The 'tablet_tool_wheel' function for tablet scrolling was added back in
c40fb2
8a1defcc634 but left unimplemented. This commit fills in the necessary
c40fb2
details, using the "clicks" count as the number of discrete scroll up/down
c40fb2
events to send.
c40fb2
c40fb2
Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
c40fb2
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
c40fb2
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
c40fb2
(cherry picked from commit 7c7a540f1e1d6b5466e1c9aa28476a2d7273d5ed)
c40fb2
---
c40fb2
 hw/xwayland/xwayland-input.c | 24 ++++++++++++++++++++++++
c40fb2
 hw/xwayland/xwayland.h       |  2 ++
c40fb2
 2 files changed, 26 insertions(+)
c40fb2
c40fb2
diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
c40fb2
index a6d7d9356..0cf318623 100644
c40fb2
--- a/hw/xwayland/xwayland-input.c
c40fb2
+++ b/hw/xwayland/xwayland-input.c
c40fb2
@@ -1566,6 +1566,13 @@ static void
c40fb2
 tablet_tool_wheel(void *data, struct zwp_tablet_tool_v2 *tool,
c40fb2
                   wl_fixed_t degrees, int32_t clicks)
c40fb2
 {
c40fb2
+    struct xwl_tablet_tool *xwl_tablet_tool = data;
c40fb2
+    struct xwl_seat *xwl_seat = xwl_tablet_tool->seat;
c40fb2
+
c40fb2
+    if (!xwl_seat->focus_window)
c40fb2
+        return;
c40fb2
+
c40fb2
+    xwl_tablet_tool->wheel_clicks = clicks;
c40fb2
 }
c40fb2
 
c40fb2
 static void
c40fb2
@@ -1677,6 +1684,23 @@ tablet_tool_frame(void *data, struct zwp_tablet_tool_v2 *tool, uint32_t time)
c40fb2
     }
c40fb2
 
c40fb2
     xwl_tablet_tool->buttons_prev = xwl_tablet_tool->buttons_now;
c40fb2
+
c40fb2
+    while (xwl_tablet_tool->wheel_clicks) {
c40fb2
+            if (xwl_tablet_tool->wheel_clicks < 0) {
c40fb2
+                button = 4;
c40fb2
+                xwl_tablet_tool->wheel_clicks++;
c40fb2
+            }
c40fb2
+            else {
c40fb2
+                button = 5;
c40fb2
+                xwl_tablet_tool->wheel_clicks--;
c40fb2
+            }
c40fb2
+
c40fb2
+            QueuePointerEvents(xwl_tablet_tool->xdevice,
c40fb2
+                               ButtonPress, button, 0, &mask);
c40fb2
+            QueuePointerEvents(xwl_tablet_tool->xdevice,
c40fb2
+                               ButtonRelease, button, 0, &mask);
c40fb2
+
c40fb2
+    }
c40fb2
 }
c40fb2
 
c40fb2
 static const struct zwp_tablet_tool_v2_listener tablet_tool_listener = {
c40fb2
diff --git a/hw/xwayland/xwayland.h b/hw/xwayland/xwayland.h
c40fb2
index 250564f73..135aa8761 100644
c40fb2
--- a/hw/xwayland/xwayland.h
c40fb2
+++ b/hw/xwayland/xwayland.h
c40fb2
@@ -213,6 +213,8 @@ struct xwl_tablet_tool {
c40fb2
     uint32_t buttons_now,
c40fb2
              buttons_prev;
c40fb2
 
c40fb2
+    int32_t wheel_clicks;
c40fb2
+
c40fb2
     struct xwl_cursor cursor;
c40fb2
 };
c40fb2
 
c40fb2
-- 
c40fb2
2.13.5
c40fb2