]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0570: GTK4: mouse wheel scrolling does not work correctly v9.2.0570
authorFoxe Chen <chen.foxe@gmail.com>
Sun, 31 May 2026 18:24:21 +0000 (18:24 +0000)
committerChristian Brabandt <cb@256bit.org>
Sun, 31 May 2026 18:24:21 +0000 (18:24 +0000)
Problem:  GTK4: mouse wheel scrolling does not work correctly
Solution: Use gui_mch_getmouse() to obtain the pointer position, and
          add GTK_EVENT_CONTROLLER_SCROLL_DISCRETE to the scroll
          controller flags (Foxe Chen).

closes: #20389

Signed-off-by: Foxe Chen <chen.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/gui_gtk4.c
src/version.c

index b5e134b8a459c40c56ed1a7846d9f49446fc513c..1596f19e5c2052a5bc7b464a7632f16a249e8e95 100644 (file)
@@ -573,7 +573,8 @@ gui_mch_init(void)
 
     {
        GtkEventController *scroll = gtk_event_controller_scroll_new(
-               GTK_EVENT_CONTROLLER_SCROLL_BOTH_AXES);
+               GTK_EVENT_CONTROLLER_SCROLL_BOTH_AXES
+               | GTK_EVENT_CONTROLLER_SCROLL_DISCRETE);
        g_signal_connect(scroll, "scroll",
                         G_CALLBACK(scroll_event), NULL);
        gtk_widget_add_controller(gui.drawarea, scroll);
@@ -1860,6 +1861,7 @@ scroll_event(GtkEventControllerScroll *controller UNUSED,
 {
     int button;
     int_u vim_modifiers;
+    int x, y;
     GdkModifierType state;
     GdkEvent *event;
 
@@ -1882,11 +1884,8 @@ scroll_event(GtkEventControllerScroll *controller UNUSED,
 
     vim_modifiers = modifiers_gdk2mouse(state);
 
-    {
-       double mx, my;
-       gdk_event_get_position(event, &mx, &my);
-       gui_send_mouse_event(button, (int)mx, (int)my, FALSE, vim_modifiers);
-    }
+    gui_mch_getmouse(&x, &y);
+    gui_send_mouse_event(button, x, y, FALSE, vim_modifiers);
 
     return TRUE;
 }
index cc7fdadc15ff0864a02e5e96586c64ed5b83b9b8..15a4d34e9cd3e9b36a48c34f40328262434865f6 100644 (file)
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    570,
 /**/
     569,
 /**/