[gtk/gtk-3-24: 1/2] gtkscrolledwindow: Consider shift key presses when decelerating



commit 5c6596ad99cf23a7e621b4752c7066571dce3bc2
Author: Sebastian Keller <sebastian-keller gmx de>
Date:   Sat Aug 4 16:36:47 2018 +0200

    gtkscrolledwindow: Consider shift key presses when decelerating
    
    Otherwise horizontal scrolling using the shift key would decelerate
    vertically.
    
    Fixes https://gitlab.gnome.org/GNOME/gtk/issues/770

 gtk/gtkscrolledwindow.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index 0d6b220952..cc7c439938 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -1321,7 +1321,8 @@ get_scroll_unit (GtkScrolledWindow *sw,
 
 static void
 scroll_history_push (GtkScrolledWindow *sw,
-                     GdkEventScroll    *event)
+                     GdkEventScroll    *event,
+                     gboolean           shifted)
 {
   GtkScrolledWindowPrivate *priv = sw->priv;
   ScrollHistoryElem new_item;
@@ -1343,8 +1344,16 @@ scroll_history_push (GtkScrolledWindow *sw,
   if (i > 0)
     g_array_remove_range (priv->scroll_history, 0, i);
 
-  new_item.dx = event->delta_x;
-  new_item.dy = event->delta_y;
+  if (shifted)
+    {
+      new_item.dx = event->delta_y;
+      new_item.dy = event->delta_x;
+    }
+  else
+    {
+      new_item.dx = event->delta_x;
+      new_item.dy = event->delta_y;
+    }
   new_item.evtime = event->time;
   g_array_append_val (priv->scroll_history, new_item);
 }
@@ -3481,7 +3490,7 @@ gtk_scrolled_window_scroll_event (GtkWidget      *widget,
           scroll_history_reset (scrolled_window);
         }
 
-      scroll_history_push (scrolled_window, event);
+      scroll_history_push (scrolled_window, event, shifted);
 
       if (input_source == GDK_SOURCE_TRACKPOINT ||
           input_source == GDK_SOURCE_TOUCHPAD)


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