[gtk+/multitouch: 121/121] gtk, gestures: Only match 0-length strokes with homologous stock ones
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/multitouch: 121/121] gtk, gestures: Only match 0-length strokes with homologous stock ones
- Date: Thu, 12 Jan 2012 03:15:45 +0000 (UTC)
commit 892d9ce7cfab8778eb795415228a38e214fcdcbc
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 0505f4d..d82a2a7 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]