aboutsummarylogtreecommitdiffstats
path: root/0002-Fix-duplicate-pointer-scroll-events.patch
blob: 70b2dba84384c872bb107e042dd840cd9a6b1135 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
From fb39b826d4b087ee8653767bb4ac189adc46c249 Mon Sep 17 00:00:00 2001
From: BoyOrigin <ahmadyasinfikri@gmail.com>
Date: Tue, 19 Sep 2023 03:31:57 +0700
Subject: [PATCH] Fix duplicate pointer scroll events


diff --git a/src/wl_platform.h b/src/wl_platform.h
index 149cd241..b17fa722 100644
--- a/src/wl_platform.h
+++ b/src/wl_platform.h
@@ -413,6 +413,8 @@ typedef struct _GLFWwindowWayland
         _GLFWfallbackEdgeWayland    top, left, right, bottom;
         struct wl_surface*          focus;
     } fallback;
+
+    uint32_t                    pointerAxisTime;
 } _GLFWwindowWayland;
 
 // Wayland-specific global data
diff --git a/src/wl_window.c b/src/wl_window.c
index 31fe9c14..aab79d01 100644
--- a/src/wl_window.c
+++ b/src/wl_window.c
@@ -1617,6 +1617,11 @@ static void pointerHandleAxis(void* userData,
     if (!window)
         return;
 
+    // On newer GNOME, there is a bug where scroll events are invoked twice. This code will fix that issue.
+    if (window->wl.pointerAxisTime == time)
+        return;
+    window->wl.pointerAxisTime = time;
+
     // NOTE: 10 units of motion per mouse wheel step seems to be a common ratio
     if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL)
         _glfwInputScroll(window, -wl_fixed_to_double(value) / 10.0, 0.0);
-- 
2.43.0