From 502d58395f8937a0e9db30d53da3e5d5c6123499 Mon Sep 17 00:00:00 2001 From: monsta Date: Tue, 16 Feb 2016 14:21:25 +0300 Subject: [GTK+3] handle smooth scroll events for zooming (with Ctrl held) fixes https://github.com/mate-desktop/caja/issues/516 adapted from: https://git.gnome.org/browse/nautilus/commit/?id=1a76e044a2c9b834d00c4ea30f1e3af3321d8cdd https://git.gnome.org/browse/nautilus/commit/?id=878e2a4f7ada26bb7c106e5bbdbd8434acf86c77 https://git.gnome.org/browse/nautilus/commit/?id=f7b54cdba55a0856b201e62818059ac5007fac35 https://git.gnome.org/browse/nautilus/commit/?id=3d275a971132a41809a3b1e5b8ac683d264d6c35 --- src/file-manager/fm-directory-view.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/file-manager') diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c index df7a2988..e5180dad 100644 --- a/src/file-manager/fm-directory-view.c +++ b/src/file-manager/fm-directory-view.c @@ -10890,6 +10890,11 @@ gboolean fm_directory_view_handle_scroll_event (FMDirectoryView *directory_view, GdkEventScroll *event) { +#if GTK_CHECK_VERSION (3, 0, 0) + static gdouble total_delta_y = 0; + gdouble delta_x, delta_y; +#endif + if (event->state & GDK_CONTROL_MASK) { switch (event->direction) { case GDK_SCROLL_UP: @@ -10902,6 +10907,29 @@ fm_directory_view_handle_scroll_event (FMDirectoryView *directory_view, fm_directory_view_bump_zoom_level (directory_view, -1); return TRUE; +#if GTK_CHECK_VERSION (3, 0, 0) + case GDK_SCROLL_SMOOTH: + gdk_event_get_scroll_deltas ((const GdkEvent *) event, + &delta_x, &delta_y); + + /* try to emulate a normal scrolling event by summing deltas */ + total_delta_y += delta_y; + + if (total_delta_y >= 1) { + total_delta_y = 0; + /* emulate scroll down */ + fm_directory_view_bump_zoom_level (directory_view, -1); + return TRUE; + } else if (total_delta_y <= - 1) { + total_delta_y = 0; + /* emulate scroll up */ + fm_directory_view_bump_zoom_level (directory_view, 1); + return TRUE; + } else { + /* eat event */ + return TRUE; + } +#endif case GDK_SCROLL_LEFT: case GDK_SCROLL_RIGHT: break; -- cgit v1.2.1