[gtk/wip/exalm/kinetic_scrolling_gtk3] eventcontrollerscroll: Fix the history push condition



commit 97f540622abca60b54d5a8141d6f05bf791ffdb8
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Fri May 15 01:20:38 2020 +0500

    eventcontrollerscroll: Fix the history push condition
    
    Once upon a time, there was a function called gdk_event_get_scroll_deltas().
    It returned %TRUE when an event had scroll deltas and that was used as the
    condition to decide whether to push scroll deltas to the scroll history,
    even when the both deltas are 0 for the stop event at the end of scrolling.
    
    When GtkScrolledWindow kinetic scrolling code was adapted for
    GtkEventControllerScroll, it was replaced with a (dx != 0 && dy != 0)
    check. This prevented the stop event from getting into the history, and
    instead allowed non-smooth scrolling to affect the history as they have
    synthetic deltas with one of the values being -1 or 1 and the other on 0.
    
    Instead, check the direction as we already have it as a local variable.

 gtk/gtkeventcontrollerscroll.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkeventcontrollerscroll.c b/gtk/gtkeventcontrollerscroll.c
index 9e90b54dd7..ef3cf3ce51 100644
--- a/gtk/gtkeventcontrollerscroll.c
+++ b/gtk/gtkeventcontrollerscroll.c
@@ -326,12 +326,11 @@ gtk_event_controller_scroll_handle_event (GtkEventController *controller,
     }
 
   if (dx != 0 || dy != 0)
-    {
-      g_signal_emit (controller, signals[SCROLL], 0, dx, dy);
+    g_signal_emit (controller, signals[SCROLL], 0, dx, dy);
 
-      if (scroll->flags & GTK_EVENT_CONTROLLER_SCROLL_KINETIC)
-        scroll_history_push (scroll, dx, dy, gdk_event_get_time (event));
-    }
+  if (direction == GDK_SCROLL_SMOOTH &&
+      scroll->flags & GTK_EVENT_CONTROLLER_SCROLL_KINETIC)
+    scroll_history_push (scroll, dx, dy, gdk_event_get_time (event));
 
   if (scroll->active && gdk_event_is_scroll_stop_event (event))
     {


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