[nautilus] view: improve scroll-zooming for smooth scrolling devices
- From: Stefano Facchini <sfacchini src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] view: improve scroll-zooming for smooth scrolling devices
- Date: Tue, 13 Mar 2012 15:31:07 +0000 (UTC)
commit 3d275a971132a41809a3b1e5b8ac683d264d6c35
Author: Stefano Facchini <stefano facchini gmail com>
Date: Tue Mar 13 16:20:00 2012 +0100
view: improve scroll-zooming for smooth scrolling devices
Try to emulate a normal scroll event by adding deltas until the total
delta reaches +1 or -1.
src/nautilus-view.c | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/src/nautilus-view.c b/src/nautilus-view.c
index f58f97b..87cd9f1 100644
--- a/src/nautilus-view.c
+++ b/src/nautilus-view.c
@@ -9465,6 +9465,7 @@ gboolean
nautilus_view_handle_scroll_event (NautilusView *directory_view,
GdkEventScroll *event)
{
+ static gdouble total_delta_y = 0;
gdouble delta_x, delta_y;
if (event->state & GDK_CONTROL_MASK) {
@@ -9483,15 +9484,16 @@ nautilus_view_handle_scroll_event (NautilusView *directory_view,
gdk_event_get_scroll_deltas ((const GdkEvent *) event,
&delta_x, &delta_y);
- /* 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) {
+ /* 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 */
nautilus_view_bump_zoom_level (directory_view, -1);
return TRUE;
- } else if (delta_y < - 0.25) {
+ } else if (total_delta_y <= - 1) {
+ total_delta_y = 0;
/* emulate scroll up */
nautilus_view_bump_zoom_level (directory_view, 1);
return TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]