Skip to contentSkip to conversation

ui/gtk: Fix mouse wheel on 3.4.0 or later

PATCH Superseded OGAWA Hirofumi 2 participants 5 messages Dec 23, 2016 – Jan 10, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ui/gtk: Fix mouse wheel on 3.4.0 or later

On 3.4.0 or later, send GDK_SCROLL_SMOOTH event, instead of GDK_SCROLL_UP/DOWN.

This fixes it by converting any smooth scroll to up/down. (I.e. without smooth support)

---

 ui/gtk.c |   10 ++++++++++
 1 file changed, 10 insertions(+)
ui/gtk.c renamed from ui/gtk.c~mouse-wheel-fix +10 -0
diff -puN ui/gtk.c~mouse-wheel-fix ui/gtk.c
@@ -1015,6 +1015,16 @@ static gboolean gd_scroll_event(GtkWidge
         btn = INPUT_BUTTON_WHEEL_UP;
     } else if (scroll->direction == GDK_SCROLL_DOWN) {
         btn = INPUT_BUTTON_WHEEL_DOWN;
+#if GTK_CHECK_VERSION(3, 4, 0)
+    } else if (scroll->direction == GDK_SCROLL_SMOOTH) {
+        gdouble delta_x, delta_y;
+        if (!gdk_event_get_scroll_deltas((GdkEvent*)scroll, &delta_x, &delta_y))
+            return TRUE;
+        if (delta_y > 0)
+            btn = INPUT_BUTTON_WHEEL_DOWN;
+        else
+            btn = INPUT_BUTTON_WHEEL_UP;
+#endif
     } else {
         return TRUE;
     }

_

Signature · 1 line
OGAWA Hirofumi <[email protected]>
#1 lore raw

ui/gtk.c static gboolean gd_scroll_event(GtkWidge · line 1027

Quoted 10 lines
ui/gtk.c renamed from ui/gtk.c~mouse-wheel-fix +10 -0
+#if GTK_CHECK_VERSION(3, 4, 0)
+    } else if (scroll->direction == GDK_SCROLL_SMOOTH) {
+        gdouble delta_x, delta_y;
+        if (!gdk_event_get_scroll_deltas((GdkEvent*)scroll, &delta_x, &delta_y))
+            return TRUE;
+        if (delta_y > 0)
+            btn = INPUT_BUTTON_WHEEL_DOWN;
+        else
+            btn = INPUT_BUTTON_WHEEL_UP;
+#endif

Patch looks good, except for some codestyle issues:

=== checkpatch complains ===
ERROR: "(foo*)" should be "(foo *)"
#13: FILE: ui/gtk.c:1024:
+ if (!gdk_event_get_scroll_deltas((GdkEvent*)scroll, &delta_x,
&delta_y))

ERROR: braces {} are necessary for all arms of this statement #13: FILE: ui/gtk.c:1024:
+ if (!gdk_event_get_scroll_deltas((GdkEvent*)scroll, &delta_x,
&delta_y))
[...]

ERROR: braces {} are necessary for all arms of this statement #15: FILE: ui/gtk.c:1026:
+ if (delta_y > 0)
[...]
+ else
[...]

total: 3 errors, 0 warnings, 16 lines checked

cheers,
Gerd

#2 lore raw
Quoted 4 lines · Gerd Hoffmann
Quoted 4 lines
ui/gtk.c renamed from ui/gtk.c~mouse-wheel-fix +4 -0
+#if GTK_CHECK_VERSION(3, 4, 0)
+    } else if (scroll->direction == GDK_SCROLL_SMOOTH) {
+        gdouble delta_x, delta_y;
+        if (!gdk_event_get_scroll_deltas((GdkEvent*)scroll, &delta_x, &delta_y))
Quoted 8 lines

ui/gtk.c static gboolean gd_scroll_event(GtkWidge · line 1027

Quoted 6 lines
ui/gtk.c renamed from ui/gtk.c~mouse-wheel-fix +6 -0
+            return TRUE;
+        if (delta_y > 0)
+            btn = INPUT_BUTTON_WHEEL_DOWN;
+        else
+            btn = INPUT_BUTTON_WHEEL_UP;
+#endif

Patch looks good, except for some codestyle issues:

will fix

Quoted 20 lines

=== checkpatch complains ===
ERROR: "(foo*)" should be "(foo *)"
#13: FILE: ui/gtk.c:1024:
+ if (!gdk_event_get_scroll_deltas((GdkEvent*)scroll, &delta_x,
&delta_y))

ERROR: braces {} are necessary for all arms of this statement #13: FILE: ui/gtk.c:1024:
+ if (!gdk_event_get_scroll_deltas((GdkEvent*)scroll, &delta_x,
&delta_y))
[...]

ERROR: braces {} are necessary for all arms of this statement #15: FILE: ui/gtk.c:1026:

ui/gtk.c renamed from ui/gtk.c~mouse-wheel-fix +2 -0
+        if (delta_y > 0)
[...]
+        else
[...]

total: 3 errors, 0 warnings, 16 lines checked

Signature · 1 line
OGAWA Hirofumi <[email protected]>
#3 lore raw

PATCH v2 1/1 ui/gtk: Fix mouse wheel on 3.4.0 or later

On 3.4.0 or later, send GDK_SCROLL_SMOOTH event, instead of GDK_SCROLL_UP/DOWN.

This fixes it by converting any smooth scroll to up/down. (I.e. without smooth support)

---

 ui/gtk.c |   13 +++++++++++++
 1 file changed, 13 insertions(+)
ui/gtk.c renamed from ui/gtk.c~mouse-wheel-fix +13 -0
diff -puN ui/gtk.c~mouse-wheel-fix ui/gtk.c
@@ -1015,6 +1015,19 @@ static gboolean gd_scroll_event(GtkWidge
         btn = INPUT_BUTTON_WHEEL_UP;
     } else if (scroll->direction == GDK_SCROLL_DOWN) {
         btn = INPUT_BUTTON_WHEEL_DOWN;
+#if GTK_CHECK_VERSION(3, 4, 0)
+    } else if (scroll->direction == GDK_SCROLL_SMOOTH) {
+        gdouble delta_x, delta_y;
+        if (!gdk_event_get_scroll_deltas((GdkEvent *)scroll,
+                                         &delta_x, &delta_y)) {
+            return TRUE;
+        }
+        if (delta_y > 0) {
+            btn = INPUT_BUTTON_WHEEL_DOWN;
+        } else {
+            btn = INPUT_BUTTON_WHEEL_UP;
+        }
+#endif
     } else {
         return TRUE;
     }

_

Signature · 1 line
OGAWA Hirofumi <[email protected]>
#4 lore raw
Quoted 7 lines · OGAWA Hirofumi

On 3.4.0 or later, send GDK_SCROLL_SMOOTH event, instead of GDK_SCROLL_UP/DOWN.

This fixes it by converting any smooth scroll to up/down. (I.e. without smooth support)

Added to ui queue.

thanks,
Gerd