[gtk+/gtk-3-14] GtkRange: Fix scroll wheel direction for horizontal ranges



commit f34ecab28f94bd36dc8201b4f81c6b290806195e
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Mar 17 22:02:35 2015 -0400

    GtkRange: Fix scroll wheel direction for horizontal ranges
    
    The expected behavior here is that scrolling up goes towards
    larger values, ie to the right. This matches e.g. volume
    sliders in gnome-shell.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=737175

 gtk/gtkrange.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index 4c36b75..036802e 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -2819,10 +2819,11 @@ _gtk_range_get_wheel_delta (GtkRange       *range,
   GtkRangePrivate *priv = range->priv;
   GtkAdjustment *adjustment = priv->adjustment;
   gdouble dx, dy;
-  gdouble delta;
+  gdouble delta = 0;
   gdouble page_size;
   gdouble page_increment;
   gdouble scroll_unit;
+  GdkScrollDirection direction;
 
   page_size = gtk_adjustment_get_page_size (adjustment);
   page_increment = gtk_adjustment_get_page_increment (adjustment);
@@ -2838,16 +2839,15 @@ _gtk_range_get_wheel_delta (GtkRange       *range,
       scroll_unit = 1;
 #endif
 
-      if (dx != 0 &&
-          gtk_orientable_get_orientation (GTK_ORIENTABLE (range)) == GTK_ORIENTATION_HORIZONTAL)
-        delta = dx * scroll_unit;
+      if (gtk_orientable_get_orientation (GTK_ORIENTABLE (range)) == GTK_ORIENTATION_HORIZONTAL)
+        delta = - (dx ? dx : dy) * scroll_unit;
       else
         delta = dy * scroll_unit;
     }
-  else
+  else if (gdk_event_get_scroll_direction ((GdkEvent *) event, &direction))
     {
-      if (event->direction == GDK_SCROLL_UP ||
-          event->direction == GDK_SCROLL_LEFT)
+      if (direction == GDK_SCROLL_UP ||
+          direction == GDK_SCROLL_RIGHT)
         delta = - scroll_unit;
       else
         delta = scroll_unit;


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