[gtk: 1/2] GdkWin32: Support high resolution scroll wheel events




commit 6ceacee0f90c6e5a7a09380ef4be810b76db10cb
Author: Ricardo Maia Louro <r maialouro hotmail com>
Date:   Sun Aug 14 18:27:03 2022 +0100

    GdkWin32: Support high resolution scroll wheel events

 gdk/win32/gdkevents-win32.c | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)
---
diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c
index 23f99c1ab7..ee5bc47b39 100644
--- a/gdk/win32/gdkevents-win32.c
+++ b/gdk/win32/gdkevents-win32.c
@@ -2669,6 +2669,7 @@ gdk_event_translate (MSG *msg,
     {
       int16_t scroll_x = 0;
       int16_t scroll_y = 0;
+      GdkScrollDirection direction;
 
       char classname[64];
 
@@ -2720,15 +2721,24 @@ gdk_event_translate (MSG *msg,
       _gdk_device_virtual_set_active (_gdk_device_manager->core_pointer,
                                       _gdk_device_manager->system_pointer);
 
-      event = gdk_scroll_event_new (window,
-                                    device_manager_win32->core_pointer,
-                                    NULL,
-                                    _gdk_win32_get_next_tick (msg->time),
-                                    build_pointer_event_state (msg),
-                                    (double) scroll_x / (double) WHEEL_DELTA,
-                                    (double) -scroll_y / (double) WHEEL_DELTA,
-                                    FALSE,
-                                    GDK_SCROLL_UNIT_WHEEL);
+      direction = 0;
+      if (msg->message == WM_MOUSEWHEEL)
+        direction = (((short) HIWORD (msg->wParam)) > 0)
+                      ? GDK_SCROLL_UP
+                      : GDK_SCROLL_DOWN;
+      else if (msg->message == WM_MOUSEHWHEEL)
+        direction = (((short) HIWORD (msg->wParam)) > 0)
+                      ? GDK_SCROLL_RIGHT
+                      : GDK_SCROLL_LEFT;
+
+      event = gdk_scroll_event_new_value120 (window,
+                                             device_manager_win32->core_pointer,
+                                             NULL,
+                                             _gdk_win32_get_next_tick (msg->time),
+                                             build_pointer_event_state (msg),
+                                             direction,
+                                             (double) scroll_x,
+                                             (double) -scroll_y);
 
       _gdk_win32_append_event (event);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]