diff options
author | Corey Berla <corey@berla.me> | 2022-10-29 10:45:21 -0700 |
---|---|---|
committer | António Fernandes <antoniof@gnome.org> | 2022-12-23 19:46:54 +0000 |
commit | 04630f90ab85de7bffb752441221fd8a73a419ca (patch) | |
tree | b4bdc2c8e55e35e8b9142ebe74b101de5876320d /src | |
parent | 6dad8f3d1516a5ba5111338880a09be0c69fe269 (diff) | |
download | nautilus-04630f90ab85de7bffb752441221fd8a73a419ca.tar.gz |
files-view: Only set discrete scrolling when ctrl is held
The scroll controller on the scrolled window in files view
is set to discrete in order to accomodate for when CTRL+scroll
(zoom) is performed. This however, causes problems with
the scrolls that are propogated and have delta's <1
(especially when they are much much less 1). So instead
let's set the discrete flag in scroll-begin only when CTRL
is held and remove it in scroll-end.
Fixes: https://gitlab.gnome.org/GNOME/nautilus/-/issues/2511
Diffstat (limited to 'src')
-rw-r--r-- | src/nautilus-files-view.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c index c47d03391..14913978f 100644 --- a/src/nautilus-files-view.c +++ b/src/nautilus-files-view.c @@ -9256,6 +9256,28 @@ on_scroll (GtkEventControllerScroll *scroll, } static void +on_scroll_begin (GtkEventControllerScroll *scroll, + gpointer user_data) +{ + GdkModifierType state; + + state = gtk_event_controller_get_current_event_state (GTK_EVENT_CONTROLLER (scroll)); + if (state & GDK_CONTROL_MASK) + { + gtk_event_controller_scroll_set_flags (scroll, + GTK_EVENT_CONTROLLER_SCROLL_VERTICAL | + GTK_EVENT_CONTROLLER_SCROLL_DISCRETE); + } +} + +static void +on_scroll_end (GtkEventControllerScroll *scroll, + gpointer user_data) +{ + gtk_event_controller_scroll_set_flags (scroll, GTK_EVENT_CONTROLLER_SCROLL_VERTICAL); +} + +static void on_parent_changed (GObject *object, GParamSpec *pspec, gpointer user_data) @@ -9680,11 +9702,12 @@ nautilus_files_view_init (NautilusFilesView *view) g_type_ensure (NAUTILUS_TYPE_FLOATING_BAR); gtk_widget_init_template (GTK_WIDGET (view)); - controller = gtk_event_controller_scroll_new (GTK_EVENT_CONTROLLER_SCROLL_VERTICAL | - GTK_EVENT_CONTROLLER_SCROLL_DISCRETE); + controller = gtk_event_controller_scroll_new (GTK_EVENT_CONTROLLER_SCROLL_VERTICAL); gtk_widget_add_controller (priv->scrolled_window, controller); gtk_event_controller_set_propagation_phase (controller, GTK_PHASE_CAPTURE); g_signal_connect (controller, "scroll", G_CALLBACK (on_scroll), view); + g_signal_connect (controller, "scroll-begin", G_CALLBACK (on_scroll_begin), view); + g_signal_connect (controller, "scroll-end", G_CALLBACK (on_scroll_end), view); g_signal_connect (priv->floating_bar, "stop", |