[gtk/wip/carlosg/scroll-speed-4-6] gtkscrolledwindow: Backport scroll speed from 4.7/main




commit 9d01189f2fc678d92213b965a069be205400e7c1
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Aug 11 23:52:44 2022 +0200

    gtkscrolledwindow: Backport scroll speed from 4.7/main
    
    Only the scroll velocity factor is backported here, the scroll unit
    event API is notably missing, so this implicitly applies to all smooth
    scroll events.
    
    The number also accounts for the 1/10th factor applied in GDK, compared
    to the code in main.

 gtk/gtkscrolledwindow.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
---
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index 77c5832e02..80144a721d 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -54,6 +54,10 @@
 #include "gtkviewport.h"
 #include "gtkwidgetprivate.h"
 
+#ifdef GDK_WINDOWING_WAYLAND
+#include <gdk/wayland/gdkwayland.h>
+#endif
+
 #include <math.h>
 
 /**
@@ -1233,6 +1237,7 @@ get_scroll_unit (GtkScrolledWindow        *sw,
                  GtkEventControllerScroll *scroll)
 {
   GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (sw);
+  GdkDisplay *display = gtk_widget_get_display (GTK_WIDGET (sw));
   GtkScrollbar *scrollbar;
   GtkAdjustment *adj;
   double page_size;
@@ -1261,6 +1266,18 @@ get_scroll_unit (GtkScrolledWindow        *sw,
   }
 #endif
 
+#ifdef GDK_WINDOWING_WAYLAND
+  if (GDK_IS_WAYLAND_DISPLAY (display))
+  {
+    GdkEvent *event = gtk_event_controller_get_current_event (GTK_EVENT_CONTROLLER (scroll));
+
+    if (event != NULL &&
+        gdk_event_get_event_type (event) == GDK_SCROLL &&
+        gdk_scroll_event_get_direction (event) == GDK_SCROLL_SMOOTH)
+      scroll_unit = 25;
+  }
+#endif
+
   return scroll_unit;
 }
 


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