[gtk+/multitouch: 121/124] gtk, gestures: Only match 0-length strokes with homologous stock ones



commit 07a41762b04646f246e956974304a395f8ca0df8
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Jan 12 03:38:25 2012 +0100

    gtk,gestures: Only match 0-length strokes with homologous stock ones
    
    Avoids spurious stroke matching with fleeting touches.

 gtk/gtkgesturesinterpreter.c |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkgesturesinterpreter.c b/gtk/gtkgesturesinterpreter.c
index b961a42..6d278e3 100644
--- a/gtk/gtkgesturesinterpreter.c
+++ b/gtk/gtkgesturesinterpreter.c
@@ -568,7 +568,12 @@ gtk_gesture_stroke_get_vector (const GtkGestureStroke *stroke,
     *length = vector->length;
 
   if (relative_length)
-    *relative_length = (gdouble) vector->length / stroke->total_length;
+    {
+      if (vector->length != 0)
+        *relative_length = (gdouble) vector->length / stroke->total_length;
+      else
+        *relative_length = 0;
+    }
 
   return TRUE;
 }
@@ -1050,6 +1055,18 @@ compare_strokes (const GtkGestureStroke *stroke_gesture,
                                       &stock_length, &stock_relative_length))
     return FALSE;
 
+  if (gesture_length == 0 && n_vectors_gesture == 1)
+    {
+      /* If both gestures have 0-length, they're good */
+      if (stock_length == 0 && n_vectors_stock == 1)
+        {
+          *confidence = 1;
+          return TRUE;
+        }
+
+      return FALSE;
+    }
+
   while (cur_stock < n_vectors_stock &&
          cur_gesture < n_vectors_gesture)
     {



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