[gtk/wip/carlosg/for-master: 5/8] gtk/eventscrollerscroll: Handle smooth events in discrete controllers




commit 8402665c5528e2d475143a5ea4c09d1d9c2d40d8
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Dec 12 00:37:12 2020 +0100

    gtk/eventscrollerscroll: Handle smooth events in discrete controllers
    
    We let smooth scroll events that don't trigger a ::scroll signal through.
    This is unintended, these are handled, even if just accumulated.
    
    This fixes cases like GtkSpinButton inside GtkScrolledWindow, where both
    would handle events, until the GtkSpinButton eventually shifts away from
    underneath the pointer.
    
    Brought up at https://gitlab.gnome.org/GNOME/gtk/-/issues/593

 gtk/gtkeventcontrollerscroll.c | 4 ++++
 1 file changed, 4 insertions(+)
---
diff --git a/gtk/gtkeventcontrollerscroll.c b/gtk/gtkeventcontrollerscroll.c
index 261d8bd21e..44278b0ebb 100644
--- a/gtk/gtkeventcontrollerscroll.c
+++ b/gtk/gtkeventcontrollerscroll.c
@@ -325,6 +325,9 @@ gtk_event_controller_scroll_handle_event (GtkEventController *controller,
 
   if (dx != 0 || dy != 0)
     g_signal_emit (controller, signals[SCROLL], 0, dx, dy, &handled);
+  else if (direction == GDK_SCROLL_SMOOTH &&
+           (scroll->flags & GTK_EVENT_CONTROLLER_SCROLL_DISCRETE) != 0)
+    handled = scroll->active;
 
   if (direction == GDK_SCROLL_SMOOTH &&
       scroll->flags & GTK_EVENT_CONTROLLER_SCROLL_KINETIC)
@@ -334,6 +337,7 @@ gtk_event_controller_scroll_handle_event (GtkEventController *controller,
     {
       g_signal_emit (controller, signals[SCROLL_END], 0);
       scroll->active = FALSE;
+      handled = FALSE;
 
       if (scroll->flags & GTK_EVENT_CONTROLLER_SCROLL_KINETIC)
         {


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