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