summaryrefslogtreecommitdiff
path: root/src/lib/evas
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2020-01-28 13:33:11 -0500
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2020-02-05 10:10:46 +0100
commit2c8d7aa7c0131727f82e2e4ac15690a98c700de1 (patch)
treef88d9cad964e0159840f0edf50a502f20fbf7c0c /src/lib/evas
parentf9dacb581176cf594d1fd838650b33dee4664be6 (diff)
efl/gesture: break out gesture processing code into separate function
this will get reused shortly Reviewed-by: woochan lee <wc0917.lee@samsung.com> Differential Revision: https://phab.enlightenment.org/D11222
Diffstat (limited to 'src/lib/evas')
-rw-r--r--src/lib/evas/gesture/efl_canvas_gesture_manager.c130
1 files changed, 67 insertions, 63 deletions
diff --git a/src/lib/evas/gesture/efl_canvas_gesture_manager.c b/src/lib/evas/gesture/efl_canvas_gesture_manager.c
index 9bed20e62f..c78682c7c3 100644
--- a/src/lib/evas/gesture/efl_canvas_gesture_manager.c
+++ b/src/lib/evas/gesture/efl_canvas_gesture_manager.c
@@ -215,6 +215,72 @@ _efl_canvas_gesture_manager_callback_del_hook(void *data, Eo *target, const Efl_
215 } 215 }
216} 216}
217 217
218static void
219_gesture_recognizer_process_internal(Efl_Canvas_Gesture_Manager_Data *pd, Efl_Canvas_Gesture_Recognizer *recognizer,
220 Eo *target, const Efl_Event_Description *gesture_type, Efl_Canvas_Gesture_Touch *touch_event)
221{
222 Efl_Canvas_Gesture_Recognizer_Result recog_result;
223 Efl_Canvas_Gesture_Recognizer_Result recog_state;
224 //If the gesture canceled or already finished by recognizer.
225 Efl_Canvas_Gesture *gesture = _get_state(pd, target, recognizer, gesture_type);
226 if (!gesture) return;
227
228 /* this is the "default" value for the event, recognizers may modify it if necessary */
229 efl_gesture_touch_count_set(gesture, efl_gesture_touch_points_count_get(touch_event));
230
231 //Gesture detecting.
232 recog_result = efl_gesture_recognizer_recognize(recognizer, gesture, target, touch_event);
233 recog_state = recog_result & EFL_GESTURE_RECOGNIZER_RESULT_RESULT_MASK;
234
235 Efl_Canvas_Gesture_Recognizer_Data *rd =
236 efl_data_scope_get(recognizer, EFL_CANVAS_GESTURE_RECOGNIZER_CLASS);
237
238 if (recog_state == EFL_GESTURE_RECOGNIZER_RESULT_TRIGGER)
239 {
240 if (efl_gesture_state_get(gesture) == EFL_GESTURE_STATE_NONE)
241 efl_gesture_state_set(gesture, EFL_GESTURE_STATE_STARTED);
242 else
243 efl_gesture_state_set(gesture, EFL_GESTURE_STATE_UPDATED);
244 }
245 else if (recog_state == EFL_GESTURE_RECOGNIZER_RESULT_FINISH)
246 {
247 efl_gesture_state_set(gesture, EFL_GESTURE_STATE_FINISHED);
248 }
249 else if (recog_state == EFL_GESTURE_RECOGNIZER_RESULT_MAYBE)
250 {
251 return;
252 }
253 else if (recog_state == EFL_GESTURE_RECOGNIZER_RESULT_CANCEL)
254 {
255 if (efl_gesture_state_get(gesture) != EFL_GESTURE_STATE_NONE)
256 efl_gesture_state_set(gesture, EFL_GESTURE_STATE_CANCELED);
257 else
258 {
259 if (rd->continues)
260 return;
261 goto post_event;
262 }
263 }
264 else if (recog_state == EFL_GESTURE_RECOGNIZER_RESULT_IGNORE)
265 {
266 return;
267 }
268
269 efl_gesture_timestamp_set(gesture, efl_gesture_touch_cur_timestamp_get(touch_event));
270 efl_event_callback_call(target, gesture_type, gesture);
271post_event:
272 //If the current event recognizes the gesture continuously, dont delete gesture.
273 if (((recog_state == EFL_GESTURE_RECOGNIZER_RESULT_FINISH) || (recog_state == EFL_GESTURE_RECOGNIZER_RESULT_CANCEL)) &&
274 !rd->continues)
275 {
276 _cleanup_cached_gestures(pd, target, gesture_type);
277 eina_hash_del(pd->m_object_events, &gesture_type, NULL);
278 //FIXME: delete it by object not list.
279 _cleanup_object(pd->m_gestures_to_delete);
280 pd->m_gestures_to_delete = NULL;
281 }
282}
283
218void 284void
219_efl_canvas_gesture_manager_filter_event(void *data, Eo *target, void *event) 285_efl_canvas_gesture_manager_filter_event(void *data, Eo *target, void *event)
220{ 286{
@@ -223,9 +289,6 @@ _efl_canvas_gesture_manager_filter_event(void *data, Eo *target, void *event)
223 Eina_Iterator *it; 289 Eina_Iterator *it;
224 Eina_Hash_Tuple *tup; 290 Eina_Hash_Tuple *tup;
225 Efl_Canvas_Gesture_Recognizer *recognizer; 291 Efl_Canvas_Gesture_Recognizer *recognizer;
226 Efl_Canvas_Gesture *gesture;
227 Efl_Canvas_Gesture_Recognizer_Result recog_result;
228 Efl_Canvas_Gesture_Recognizer_Result recog_state;
229 Efl_Canvas_Gesture_Touch *touch_event; 292 Efl_Canvas_Gesture_Touch *touch_event;
230 293
231 thisisreallystupid = eina_hash_find(pd->m_gesture_contex, &target); 294 thisisreallystupid = eina_hash_find(pd->m_gesture_contex, &target);
@@ -251,66 +314,7 @@ _efl_canvas_gesture_manager_filter_event(void *data, Eo *target, void *event)
251 continue; 314 continue;
252 315
253 recognizer = eina_hash_find(pd->m_recognizers, &gesture_type); 316 recognizer = eina_hash_find(pd->m_recognizers, &gesture_type);
254 317 _gesture_recognizer_process_internal(pd, recognizer, target, gesture_type, touch_event);
255 //If the gesture canceled or already finished by recognizer.
256 gesture = _get_state(pd, target, recognizer, gesture_type);
257 if (!gesture)
258 continue;
259
260 /* this is the "default" value for the event, recognizers may modify it if necessary */
261 efl_gesture_touch_count_set(gesture, efl_gesture_touch_points_count_get(touch_event));
262
263 //Gesture detecting.
264 recog_result = efl_gesture_recognizer_recognize(recognizer, gesture, target, touch_event);
265 recog_state = recog_result & EFL_GESTURE_RECOGNIZER_RESULT_RESULT_MASK;
266
267 Efl_Canvas_Gesture_Recognizer_Data *rd =
268 efl_data_scope_get(recognizer, EFL_CANVAS_GESTURE_RECOGNIZER_CLASS);
269
270 if (recog_state == EFL_GESTURE_RECOGNIZER_RESULT_TRIGGER)
271 {
272 if (efl_gesture_state_get(gesture) == EFL_GESTURE_STATE_NONE)
273 efl_gesture_state_set(gesture, EFL_GESTURE_STATE_STARTED);
274 else
275 efl_gesture_state_set(gesture, EFL_GESTURE_STATE_UPDATED);
276 }
277 else if (recog_state == EFL_GESTURE_RECOGNIZER_RESULT_FINISH)
278 {
279 efl_gesture_state_set(gesture, EFL_GESTURE_STATE_FINISHED);
280 }
281 else if (recog_state == EFL_GESTURE_RECOGNIZER_RESULT_MAYBE)
282 {
283 continue;
284 }
285 else if (recog_state == EFL_GESTURE_RECOGNIZER_RESULT_CANCEL)
286 {
287 if (efl_gesture_state_get(gesture) != EFL_GESTURE_STATE_NONE)
288 efl_gesture_state_set(gesture, EFL_GESTURE_STATE_CANCELED);
289 else
290 {
291 if (rd->continues)
292 continue;
293 goto post_event;
294 }
295 }
296 else if (recog_state == EFL_GESTURE_RECOGNIZER_RESULT_IGNORE)
297 {
298 continue;
299 }
300
301 efl_gesture_timestamp_set(gesture, efl_gesture_touch_cur_timestamp_get(touch_event));
302 efl_event_callback_call(target, gesture_type, gesture);
303post_event:
304 //If the current event recognizes the gesture continuously, dont delete gesture.
305 if (((recog_state == EFL_GESTURE_RECOGNIZER_RESULT_FINISH) || (recog_state == EFL_GESTURE_RECOGNIZER_RESULT_CANCEL)) &&
306 !rd->continues)
307 {
308 _cleanup_cached_gestures(pd, target, gesture_type);
309 eina_hash_del(pd->m_object_events, &gesture_type, NULL);
310 //FIXME: delete it by object not list.
311 _cleanup_object(pd->m_gestures_to_delete);
312 pd->m_gestures_to_delete = NULL;
313 }
314 } 318 }
315 eina_iterator_free(it); 319 eina_iterator_free(it);
316} 320}