From 5c6596ad99cf23a7e621b4752c7066571dce3bc2 Mon Sep 17 00:00:00 2001 From: Sebastian Keller Date: Sat, 4 Aug 2018 16:36:47 +0200 Subject: [PATCH] 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)