summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormonsta <[email protected]>2016-02-16 14:21:25 +0300
committermonsta <[email protected]>2016-03-01 11:14:25 +0300
commit15e4db0b1d29e8663ea9938e709078c70050dc4c (patch)
tree86a86477c906b529ffb6b1cb13c6cf75d3f3791b
parente95dfefac05c5c5d2965ef4e6617e000139bc7b1 (diff)
downloadcaja-15e4db0b1d29e8663ea9938e709078c70050dc4c.tar.bz2
caja-15e4db0b1d29e8663ea9938e709078c70050dc4c.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
-rw-r--r--src/file-manager/fm-directory-view.c28
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 80815dcd..135f4818 100644
--- a/src/file-manager/fm-directory-view.c
+++ b/src/file-manager/fm-directory-view.c
@@ -10827,6 +10827,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:
@@ -10839,6 +10844,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;