Mercurial > vim
comparison src/gui_gtk_x11.c @ 34303:7c95f913fdd6 v9.1.0086
patch 9.1.0086: Problem when scrolling using slow touchpads scroll event
Commit: https://github.com/vim/vim/commit/725c7c31a4c7603e688511d769b0addaab442d07
Author: lilydjwg <lilydjwg@gmail.com>
Date: Fri Feb 9 19:24:23 2024 +0100
patch 9.1.0086: Problem when scrolling using slow touchpads scroll event
Problem: Problem when scrolling using slow touchpads scroll event
Solution: better ways to determine if a smooth scroll has ended (when
available) (lilydjwg)
related: #13997
Signed-off-by: lilydjwg <lilydjwg@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 09 Feb 2024 19:30:04 +0100 |
parents | 0b85121f25e0 |
children | bce11c34ef41 |
comparison
equal
deleted
inserted
replaced
34302:82cbfa8e2109 | 34303:7c95f913fdd6 |
---|---|
2047 | 2047 |
2048 return TRUE; | 2048 return TRUE; |
2049 } | 2049 } |
2050 | 2050 |
2051 /* | 2051 /* |
2052 * GTK+ 2 abstracts scrolling via the GdkEventScroll. | 2052 * GTK+ abstracts scrolling via the GdkEventScroll. |
2053 */ | 2053 */ |
2054 static gboolean | 2054 static gboolean |
2055 scroll_event(GtkWidget *widget, | 2055 scroll_event(GtkWidget *widget, |
2056 GdkEventScroll *event, | 2056 GdkEventScroll *event, |
2057 gpointer data UNUSED) | 2057 gpointer data UNUSED) |
2058 { | 2058 { |
2059 int button = 0; // silence gcc | 2059 int button = 0; // silence gcc |
2060 int_u vim_modifiers; | 2060 int_u vim_modifiers; |
2061 #if GTK_CHECK_VERSION(3,4,0) | 2061 #if GTK_CHECK_VERSION(3,4,0) |
2062 static double acc_x, acc_y; | 2062 static double acc_x, acc_y; |
2063 #if !GTK_CHECK_VERSION(3,22,0) | |
2063 static guint32 last_smooth_event_time; | 2064 static guint32 last_smooth_event_time; |
2065 #endif | |
2064 #define DT_X11 1 | 2066 #define DT_X11 1 |
2065 #define DT_WAYLAND 2 | 2067 #define DT_WAYLAND 2 |
2066 static display_type; | 2068 static display_type; |
2067 if (!display_type) | 2069 if (!display_type) |
2068 display_type = gui_mch_get_display() ? DT_X11 : DT_WAYLAND; | 2070 display_type = gui_mch_get_display() ? DT_X11 : DT_WAYLAND; |
2085 case GDK_SCROLL_RIGHT: | 2087 case GDK_SCROLL_RIGHT: |
2086 button = MOUSE_6; | 2088 button = MOUSE_6; |
2087 break; | 2089 break; |
2088 #if GTK_CHECK_VERSION(3,4,0) | 2090 #if GTK_CHECK_VERSION(3,4,0) |
2089 case GDK_SCROLL_SMOOTH: | 2091 case GDK_SCROLL_SMOOTH: |
2092 if (event->is_stop) | |
2093 { | |
2094 acc_x = acc_y = 0; | |
2095 // this event tells us to stop, without an actual moving | |
2096 return FALSE; | |
2097 } | |
2098 #if GTK_CHECK_VERSION(3,22,0) | |
2099 if (gdk_device_get_axes(event->device) & GDK_AXIS_FLAG_WHEEL) | |
2100 // this is from a wheel (as oppose to a touchpad / trackpoint) | |
2101 #else | |
2090 if (event->time - last_smooth_event_time > 50) | 2102 if (event->time - last_smooth_event_time > 50) |
2091 // reset our accumulations after 50ms of silence | 2103 // reset our accumulations after 50ms of silence |
2104 #endif | |
2092 acc_x = acc_y = 0; | 2105 acc_x = acc_y = 0; |
2093 acc_x += event->delta_x; | 2106 acc_x += event->delta_x; |
2094 acc_y += event->delta_y; | 2107 acc_y += event->delta_y; |
2108 #if !GTK_CHECK_VERSION(3,22,0) | |
2095 last_smooth_event_time = event->time; | 2109 last_smooth_event_time = event->time; |
2110 #endif | |
2096 break; | 2111 break; |
2097 #endif | 2112 #endif |
2098 default: // This shouldn't happen | 2113 default: // This shouldn't happen |
2099 return FALSE; | 2114 return FALSE; |
2100 } | 2115 } |