summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCosimo Cecchi <cosimoc@gnome.org>2012-03-13 10:25:34 -0400
committerCosimo Cecchi <cosimoc@gnome.org>2012-03-13 10:26:51 -0400
commitf7b54cdba55a0856b201e62818059ac5007fac35 (patch)
tree7bdf9498806851f94f27c7a01fd406f48f92e7dd
parent45cb82857c9cef34952da4c0488780fd8b19a61b (diff)
downloadnautilus-f7b54cdba55a0856b201e62818059ac5007fac35.tar.gz
view: threshold the delta information when scroll-zooming
We don't want to zoom for every single event, since in case the device supports smooth scrolling, we will get a lot of small events. Pointed out by Stefano Facchini.
-rw-r--r--src/nautilus-view.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/nautilus-view.c b/src/nautilus-view.c
index f99a0f1bd..f58f97b13 100644
--- a/src/nautilus-view.c
+++ b/src/nautilus-view.c
@@ -9483,16 +9483,21 @@ nautilus_view_handle_scroll_event (NautilusView *directory_view,
gdk_event_get_scroll_deltas ((const GdkEvent *) event,
&delta_x, &delta_y);
- if (delta_y > 0) {
+ /* threshold the delta, so that when events come from a device supporting
+ * smooth scrolling (e.g. a touchpad), we only change zoom level if the event
+ * is relevant enough.
+ */
+ if (delta_y > 0.25) {
/* emulate scroll down */
nautilus_view_bump_zoom_level (directory_view, -1);
return TRUE;
- } else if (delta_y < 0) {
+ } else if (delta_y < - 0.25) {
/* emulate scroll up */
nautilus_view_bump_zoom_level (directory_view, 1);
return TRUE;
} else {
- break;
+ /* eat event */
+ return TRUE;
}
case GDK_SCROLL_LEFT: