[libchamplain] ChamplainView: Handle CLUTTER_SCROLL_SMOOTH



commit 1a34b284750d966cd5fce59be3d03bb263dd184a
Author: Jonas Danielsson <jonas threetimestwo org>
Date:   Mon Mar 16 17:42:44 2015 +0100

    ChamplainView: Handle CLUTTER_SCROLL_SMOOTH
    
    In latest Clutter more devices reports scroll using
    the CLUTTER_SCROLL_SMOOTH direction. This means that the
    scroll to zoom functionality stopped working for Maps.
    
    Not handling the CLUTTER_SCROLL_SMOOTH in Champlain has
    always been a buglet. It gets more serious now that we
    get CLUTTER_SCROLL_SMOOTH more often.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=746127

 champlain/champlain-view.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/champlain/champlain-view.c b/champlain/champlain-view.c
index cca78a6..d72b4dd 100644
--- a/champlain/champlain-view.c
+++ b/champlain/champlain-view.c
@@ -386,7 +386,22 @@ scroll_event (G_GNUC_UNUSED ClutterActor *actor,
     zoom_level = priv->zoom_level + 1;
   else if (event->direction == CLUTTER_SCROLL_DOWN)
     zoom_level = priv->zoom_level - 1;
-    
+  else if (event->direction == CLUTTER_SCROLL_SMOOTH)
+    {
+      gdouble dx, dy;
+
+      clutter_event_get_scroll_delta (event, &dx, &dy);
+
+      /* Use a threshhold value to avoid jitter */
+      if (fabs(dy) < 0.75)
+        return FALSE;
+
+      if (dy > 0)
+        zoom_level = priv->zoom_level - 1;
+      else
+        zoom_level = priv->zoom_level + 1;
+  }
+
   return view_set_zoom_level_at (view, zoom_level, TRUE, event->x, event->y);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]