diff options
author | monsta <[email protected]> | 2016-02-16 14:21:25 +0300 |
---|---|---|
committer | monsta <[email protected]> | 2016-02-16 14:21:25 +0300 |
commit | 502d58395f8937a0e9db30d53da3e5d5c6123499 (patch) | |
tree | 05d565b977692f684152f9843251074b593616dc /src | |
parent | e5c29655e5301b6d4ba19a3d4970745804039c0e (diff) | |
download | caja-502d58395f8937a0e9db30d53da3e5d5c6123499.tar.bz2 caja-502d58395f8937a0e9db30d53da3e5d5c6123499.tar.xz |
[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
Diffstat (limited to 'src')
-rw-r--r-- | src/file-manager/fm-directory-view.c | 28 |
1 files changed, 28 insertions, 0 deletions
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; |