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

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