summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2020-02-20 13:22:47 -0500
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2020-03-03 10:54:32 +0100
commit322fdba5f093b14d6057171039567fc6cc35bf07 (patch)
tree59df82ff18df6c7e81895f87a88d75a593d0d6e2
parente1b70206331dae6dea027e578459a8779e20ba4c (diff)
efl/gesture: fix momentum gesture recognizer to properly continue its gestures
it's not enough to just check the value for this in the recognizer; we need to always modify the recognizer property here to correctly manage object lifetimes and generate the correct events (e.g., not emitting momentum gestures while multiple fingers are moving simultaneously) also update a couple existing unit test checks which were wrong Differential Revision: https://phab.enlightenment.org/D11386
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_recognizer_momentum.c30
-rw-r--r--src/tests/elementary/efl_ui_test_gesture.c4
2 files changed, 22 insertions, 12 deletions
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_momentum.c b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_momentum.c
index 0489147721..64afe22a2d 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_recognizer_momentum.c
+++ b/src/lib/evas/gesture/efl_canvas_gesture_recognizer_momentum.c
@@ -67,6 +67,7 @@ _efl_canvas_gesture_recognizer_momentum_efl_canvas_gesture_recognizer_recognize(
67 Eina_Value *val; 67 Eina_Value *val;
68 unsigned char glayer_continues_enable; 68 unsigned char glayer_continues_enable;
69 Efl_Canvas_Gesture_Recognizer_Result result = EFL_GESTURE_RECOGNIZER_RESULT_CANCEL; 69 Efl_Canvas_Gesture_Recognizer_Result result = EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
70 Efl_Canvas_Gesture_Recognizer_Data *rd = efl_data_scope_get(obj, EFL_CANVAS_GESTURE_RECOGNIZER_CLASS);
70 Efl_Canvas_Gesture_Momentum_Data *md = efl_data_scope_get(gesture, EFL_CANVAS_GESTURE_MOMENTUM_CLASS); 71 Efl_Canvas_Gesture_Momentum_Data *md = efl_data_scope_get(gesture, EFL_CANVAS_GESTURE_MOMENTUM_CLASS);
71 72
72 val = _recognizer_config_get(obj, "glayer_continues_enable"); 73 val = _recognizer_config_get(obj, "glayer_continues_enable");
@@ -83,6 +84,7 @@ _efl_canvas_gesture_recognizer_momentum_efl_canvas_gesture_recognizer_recognize(
83 if (efl_gesture_touch_points_count_get(event) == 1) 84 if (efl_gesture_touch_points_count_get(event) == 1)
84 { 85 {
85 pd->touched = EINA_TRUE; 86 pd->touched = EINA_TRUE;
87 rd->continues = EINA_TRUE;
86 md->id = -1; 88 md->id = -1;
87 } 89 }
88 } 90 }
@@ -109,6 +111,7 @@ _efl_canvas_gesture_recognizer_momentum_efl_canvas_gesture_recognizer_recognize(
109 if ((xdir != pd->xdir) || (ydir != pd->ydir)) 111 if ((xdir != pd->xdir) || (ydir != pd->ydir))
110 { 112 {
111 memset(pd, 0, sizeof(Efl_Canvas_Gesture_Recognizer_Momentum_Data)); 113 memset(pd, 0, sizeof(Efl_Canvas_Gesture_Recognizer_Momentum_Data));
114 rd->continues = EINA_FALSE;
112 return EFL_GESTURE_RECOGNIZER_RESULT_CANCEL; 115 return EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
113 } 116 }
114 return EFL_GESTURE_RECOGNIZER_RESULT_IGNORE; 117 return EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
@@ -124,20 +127,20 @@ _efl_canvas_gesture_recognizer_momentum_efl_canvas_gesture_recognizer_recognize(
124 if (efl_gesture_touch_state_get(event) == EFL_GESTURE_TOUCH_STATE_BEGIN || 127 if (efl_gesture_touch_state_get(event) == EFL_GESTURE_TOUCH_STATE_BEGIN ||
125 glayer_continues_enable) 128 glayer_continues_enable)
126 { 129 {
127 if (efl_gesture_touch_previous_data_get(event)) 130
128 {
129 if (efl_gesture_touch_previous_data_get(event)->action == efl_gesture_touch_current_data_get(event)->action)
130 return EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
131 }
132 pd->t_st = pd->t_end = efl_gesture_touch_current_timestamp_get(event); 131 pd->t_st = pd->t_end = efl_gesture_touch_current_timestamp_get(event);
133 132
134 pd->st_line = pd->end_line = 133 pd->st_line = pd->end_line =
135 efl_gesture_touch_start_point_get(event); 134 efl_gesture_touch_start_point_get(event);
136 135
137 efl_gesture_hotspot_set(gesture, pd->st_line); 136 efl_gesture_hotspot_set(gesture, pd->st_line);
138 if (!glayer_continues_enable) 137 md->id = efl_gesture_touch_current_data_get(event)->id;
139 md->id = efl_gesture_touch_current_data_get(event)->id; 138 if (efl_gesture_touch_previous_data_get(event))
140 139 {
140 /* if multiple fingers are pressed simultaneously, start tracking the latest finger for gesture */
141 if (efl_gesture_touch_previous_data_get(event)->action == efl_gesture_touch_current_data_get(event)->action)
142 return EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
143 }
141 return EFL_GESTURE_RECOGNIZER_RESULT_TRIGGER; 144 return EFL_GESTURE_RECOGNIZER_RESULT_TRIGGER;
142 } 145 }
143 } 146 }
@@ -186,11 +189,16 @@ _efl_canvas_gesture_recognizer_momentum_efl_canvas_gesture_recognizer_recognize(
186 189
187 case EFL_GESTURE_TOUCH_STATE_END: 190 case EFL_GESTURE_TOUCH_STATE_END:
188 { 191 {
192 Eina_Bool touched = !!efl_gesture_touch_points_count_get(event);
189 if (!pd->t_st) 193 if (!pd->t_st)
190 { 194 {
191 pd->touched = EINA_FALSE; 195 Eina_Bool prev_touched = pd->touched;
196
197 rd->continues = pd->touched = touched;
192 198
193 return EFL_GESTURE_RECOGNIZER_RESULT_CANCEL; 199 if (prev_touched)
200 return EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
201 return EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
194 } 202 }
195 203
196 if ((efl_gesture_touch_current_timestamp_get(event) - MOMENTUM_TIMEOUT) > pd->t_end) 204 if ((efl_gesture_touch_current_timestamp_get(event) - MOMENTUM_TIMEOUT) > pd->t_end)
@@ -202,6 +210,7 @@ _efl_canvas_gesture_recognizer_momentum_efl_canvas_gesture_recognizer_recognize(
202 210
203 pd->end_line = efl_gesture_touch_current_point_get(event); 211 pd->end_line = efl_gesture_touch_current_point_get(event);
204 pd->t_end = efl_gesture_touch_current_timestamp_get(event); 212 pd->t_end = efl_gesture_touch_current_timestamp_get(event);
213 rd->continues = touched;
205 efl_gesture_hotspot_set(gesture, pd->end_line); 214 efl_gesture_hotspot_set(gesture, pd->end_line);
206 215
207 if ((fabs(md->momentum.x) > EFL_GESTURE_MINIMUM_MOMENTUM) || 216 if ((fabs(md->momentum.x) > EFL_GESTURE_MINIMUM_MOMENTUM) ||
@@ -211,6 +220,7 @@ _efl_canvas_gesture_recognizer_momentum_efl_canvas_gesture_recognizer_recognize(
211 result = EFL_GESTURE_RECOGNIZER_RESULT_CANCEL; 220 result = EFL_GESTURE_RECOGNIZER_RESULT_CANCEL;
212 221
213 memset(pd, 0, sizeof(Efl_Canvas_Gesture_Recognizer_Momentum_Data)); 222 memset(pd, 0, sizeof(Efl_Canvas_Gesture_Recognizer_Momentum_Data));
223 pd->touched = touched;
214 224
215 break; 225 break;
216 } 226 }
diff --git a/src/tests/elementary/efl_ui_test_gesture.c b/src/tests/elementary/efl_ui_test_gesture.c
index c176818331..0efd168f68 100644
--- a/src/tests/elementary/efl_ui_test_gesture.c
+++ b/src/tests/elementary/efl_ui_test_gesture.c
@@ -481,7 +481,7 @@ EFL_START_TEST(test_efl_ui_gesture_zoom)
481 CHECK_ALL(TRIPLE_TAP, 1, 0, 0, 1); 481 CHECK_ALL(TRIPLE_TAP, 1, 0, 0, 1);
482 482
483 CHECK_START(MOMENTUM, 1); 483 CHECK_START(MOMENTUM, 1);
484 CHECK_UPDATE(MOMENTUM, moves * 2 + 1); 484 CHECK_UPDATE(MOMENTUM, 0);
485 CHECK_FINISH(MOMENTUM, 0); 485 CHECK_FINISH(MOMENTUM, 0);
486 CHECK_CANCEL(MOMENTUM, 1); 486 CHECK_CANCEL(MOMENTUM, 1);
487 487
@@ -509,7 +509,7 @@ EFL_START_TEST(test_efl_ui_gesture_zoom)
509 CHECK_ALL(TRIPLE_TAP, 1, 0, 0, 1); 509 CHECK_ALL(TRIPLE_TAP, 1, 0, 0, 1);
510 510
511 CHECK_START(MOMENTUM, 1); 511 CHECK_START(MOMENTUM, 1);
512 CHECK_UPDATE(MOMENTUM, moves * 2 + 1); 512 CHECK_UPDATE(MOMENTUM, 0);
513 CHECK_FINISH(MOMENTUM, 0); 513 CHECK_FINISH(MOMENTUM, 0);
514 CHECK_CANCEL(MOMENTUM, 1); 514 CHECK_CANCEL(MOMENTUM, 1);
515 515