[gtk+/gtk-3-16] scrolledwindow: Ignore 0/0 scroll events when possibly cancelling animation



commit d563b943ed3b448935e5a73a3b94503873807c2d
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Mar 31 20:24:07 2015 +0200

    scrolledwindow: Ignore 0/0 scroll events when possibly cancelling animation
    
    These should be used eventually to start kinetic scrolling, so should definitely
    be ignored on cancellation.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=747133

 gtk/gtkscrolledwindow.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index 73aa5b0..2845629 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -1074,7 +1074,18 @@ captured_event_cb (GtkWidget *widget,
 
   if (event->type == GDK_SCROLL)
     {
-      gtk_scrolled_window_cancel_deceleration (sw);
+      gdouble dx, dy;
+
+      /* The libinput driver may generate a final event with dx=dy=0
+       * after scrolling finished, this is usually an indication that
+       * the deceleration animation just started, so we definitely
+       * shouldn't cancel it.
+       */
+      if (event->scroll.direction != GDK_SCROLL_SMOOTH ||
+          (gdk_event_get_scroll_deltas (event, &dx, &dy) &&
+           ((int) dx != 0 || (int) dy != 0)))
+        gtk_scrolled_window_cancel_deceleration (sw);
+
       return GDK_EVENT_PROPAGATE;
     }
 


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