diff mbox

ui/gtk: Fix mouse wheel on 3.4.0 or later

Message ID 87bmw2vgvy.fsf@mail.parknet.co.jp
State New
Headers show

Commit Message

OGAWA Hirofumi Dec. 23, 2016, 2:50 p.m. UTC
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)

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
---

 ui/gtk.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Gerd Hoffmann Jan. 4, 2017, 8:48 a.m. UTC | #1
> +#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
OGAWA Hirofumi Jan. 4, 2017, 8:39 p.m. UTC | #2
Gerd Hoffmann <kraxel@redhat.com> writes:

>> +#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:

will fix

> === 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
diff mbox

Patch

diff -puN ui/gtk.c~mouse-wheel-fix ui/gtk.c
--- qemu/ui/gtk.c~mouse-wheel-fix	2016-12-23 23:39:24.419659012 +0900
+++ qemu-hirofumi/ui/gtk.c	2016-12-23 23:39:37.540735673 +0900
@@ -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;
     }