forked from enlightenment/efl
efl/gesture: move manager's recognizer cleanup function to eo
this is needed by recognizers which use timers in order to do timeouts on gestures Reviewed-by: Xavi Artigas <xavierartigas@yahoo.es> Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de> Differential Revision: https://phab.enlightenment.org/D11245
This commit is contained in:
parent
6307fc056a
commit
0f2a61b5f2
|
@ -32,7 +32,7 @@ typedef struct _Efl_Canvas_Gesture_Manager_Data
|
||||||
} Efl_Canvas_Gesture_Manager_Data;
|
} Efl_Canvas_Gesture_Manager_Data;
|
||||||
|
|
||||||
static void _cleanup_cached_gestures(Efl_Canvas_Gesture_Manager_Data *pd,
|
static void _cleanup_cached_gestures(Efl_Canvas_Gesture_Manager_Data *pd,
|
||||||
Eo *target, const Efl_Event_Description *type, Efl_Canvas_Gesture_Recognizer *recognizer);
|
const Eo *target, const Efl_Event_Description *type, const Efl_Canvas_Gesture_Recognizer *recognizer);
|
||||||
static Efl_Canvas_Gesture *
|
static Efl_Canvas_Gesture *
|
||||||
_get_state(Efl_Canvas_Gesture_Manager_Data *pd, Eo *target,
|
_get_state(Efl_Canvas_Gesture_Manager_Data *pd, Eo *target,
|
||||||
Efl_Canvas_Gesture_Recognizer *recognizer, const Efl_Event_Description *type);
|
Efl_Canvas_Gesture_Recognizer *recognizer, const Efl_Event_Description *type);
|
||||||
|
@ -486,7 +486,7 @@ _get_state(Efl_Canvas_Gesture_Manager_Data *pd,
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_cleanup_cached_gestures(Efl_Canvas_Gesture_Manager_Data *pd,
|
_cleanup_cached_gestures(Efl_Canvas_Gesture_Manager_Data *pd,
|
||||||
Eo *target, const Efl_Event_Description *type, Efl_Canvas_Gesture_Recognizer *recognizer)
|
const Eo *target, const Efl_Event_Description *type, const Efl_Canvas_Gesture_Recognizer *recognizer)
|
||||||
{
|
{
|
||||||
Eina_List *l, *l_next;
|
Eina_List *l, *l_next;
|
||||||
Object_Gesture *object_gesture;
|
Object_Gesture *object_gesture;
|
||||||
|
@ -503,12 +503,20 @@ _cleanup_cached_gestures(Efl_Canvas_Gesture_Manager_Data *pd,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
EOLIAN static void
|
||||||
efl_gesture_manager_gesture_clean_up(Eo *obj, Eo *target, const Efl_Event_Description *type, Efl_Canvas_Gesture_Recognizer *recognizer)
|
_efl_canvas_gesture_manager_recognizer_cleanup(Eo *obj EINA_UNUSED, Efl_Canvas_Gesture_Manager_Data *pd, const Efl_Canvas_Gesture_Recognizer *recognizer, const Eo *target)
|
||||||
{
|
{
|
||||||
Efl_Canvas_Gesture_Manager_Data *pd = efl_data_scope_get(obj, MY_CLASS);
|
const Efl_Event_Description *type;
|
||||||
|
Efl_Canvas_Gesture *dummy;
|
||||||
|
|
||||||
EINA_SAFETY_ON_NULL_RETURN(recognizer);
|
EINA_SAFETY_ON_NULL_RETURN(recognizer);
|
||||||
|
|
||||||
|
//Find the type of the recognizer
|
||||||
|
dummy = efl_gesture_recognizer_add((void*)recognizer, 0);
|
||||||
|
EINA_SAFETY_ON_NULL_RETURN(dummy);
|
||||||
|
|
||||||
|
type = _efl_gesture_type_get(dummy);
|
||||||
|
efl_del(dummy);
|
||||||
_cleanup_cached_gestures(pd, target, type, recognizer);
|
_cleanup_cached_gestures(pd, target, type, recognizer);
|
||||||
eina_hash_del(pd->m_object_events, &recognizer, NULL);
|
eina_hash_del(pd->m_object_events, &recognizer, NULL);
|
||||||
_cleanup_object(pd->m_gestures_to_delete);
|
_cleanup_object(pd->m_gestures_to_delete);
|
||||||
|
|
|
@ -35,6 +35,13 @@ class @beta Efl.Canvas.Gesture_Manager extends Efl.Object
|
||||||
value: any_value_ref; [[Value of the property.]]
|
value: any_value_ref; [[Value of the property.]]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
recognizer_cleanup {
|
||||||
|
[[Perform cleanup for a gesture which ends after a delay.]]
|
||||||
|
params {
|
||||||
|
@in recognizer: const(Efl.Canvas.Gesture_Recognizer); [[The gesture recognizer object.]]
|
||||||
|
@in target: const(Efl.Canvas.Object); [[The target object being processed by the recognizer.]]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
events {
|
events {
|
||||||
config,changed: string; [[Called when a config value has been changed for the manager object. Passed string is the name of the value.]]
|
config,changed: string; [[Called when a config value has been changed for the manager object. Passed string is the name of the value.]]
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
#define TAP_TOUCH_TIME_THRESHOLD (0.1 * 1000)
|
#define TAP_TOUCH_TIME_THRESHOLD (0.1 * 1000)
|
||||||
|
|
||||||
const Efl_Event_Description * _efl_gesture_type_get(const Eo *obj);
|
const Efl_Event_Description * _efl_gesture_type_get(const Eo *obj);
|
||||||
void efl_gesture_manager_gesture_clean_up(Eo *obj, Eo *target, const Efl_Event_Description *type, Efl_Canvas_Gesture_Recognizer *recognizer);
|
|
||||||
int _direction_get(Evas_Coord xx1, Evas_Coord xx2);
|
int _direction_get(Evas_Coord xx1, Evas_Coord xx2);
|
||||||
Eina_Value *_recognizer_config_get(const Eo *obj, const char *name);
|
Eina_Value *_recognizer_config_get(const Eo *obj, const char *name);
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,8 @@ _tap_timeout_cb(void *data)
|
||||||
efl_gesture_state_set(pd->gesture, EFL_GESTURE_STATE_CANCELED);
|
efl_gesture_state_set(pd->gesture, EFL_GESTURE_STATE_CANCELED);
|
||||||
efl_event_callback_call(pd->target, EFL_EVENT_GESTURE_DOUBLE_TAP, pd->gesture);
|
efl_event_callback_call(pd->target, EFL_EVENT_GESTURE_DOUBLE_TAP, pd->gesture);
|
||||||
|
|
||||||
efl_gesture_manager_gesture_clean_up(efl_provider_find(data, EFL_CANVAS_GESTURE_MANAGER_CLASS),
|
efl_gesture_manager_recognizer_cleanup(efl_provider_find(data, EFL_CANVAS_GESTURE_MANAGER_CLASS), data,
|
||||||
pd->target, EFL_EVENT_GESTURE_DOUBLE_TAP, data);
|
pd->target);
|
||||||
|
|
||||||
pd->timeout = NULL;
|
pd->timeout = NULL;
|
||||||
pd->tap_count = 0;
|
pd->tap_count = 0;
|
||||||
|
|
|
@ -212,7 +212,7 @@ _efl_canvas_gesture_recognizer_flick_efl_canvas_gesture_recognizer_recognize(Eo
|
||||||
//This is to handle a case with a mouse click on the target object.
|
//This is to handle a case with a mouse click on the target object.
|
||||||
if (efl_gesture_touch_state_get(event) == EFL_GESTURE_TOUCH_STATE_END && !pd->touched)
|
if (efl_gesture_touch_state_get(event) == EFL_GESTURE_TOUCH_STATE_END && !pd->touched)
|
||||||
{
|
{
|
||||||
efl_gesture_manager_gesture_clean_up(efl_provider_find(obj, EFL_CANVAS_GESTURE_MANAGER_CLASS), watched, EFL_EVENT_GESTURE_FLICK, obj);
|
efl_gesture_manager_recognizer_cleanup(efl_provider_find(obj, EFL_CANVAS_GESTURE_MANAGER_CLASS), obj, watched);
|
||||||
dead = EINA_TRUE;
|
dead = EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ _tap_timeout_cb(void *data)
|
||||||
efl_gesture_state_set(pd->gesture, EFL_GESTURE_STATE_CANCELED);
|
efl_gesture_state_set(pd->gesture, EFL_GESTURE_STATE_CANCELED);
|
||||||
efl_event_callback_call(pd->target, EFL_EVENT_GESTURE_TRIPLE_TAP, pd->gesture);
|
efl_event_callback_call(pd->target, EFL_EVENT_GESTURE_TRIPLE_TAP, pd->gesture);
|
||||||
|
|
||||||
efl_gesture_manager_gesture_clean_up(efl_provider_find(data, EFL_CANVAS_GESTURE_MANAGER_CLASS), pd->target, EFL_EVENT_GESTURE_TRIPLE_TAP, data);
|
efl_gesture_manager_recognizer_cleanup(efl_provider_find(data, EFL_CANVAS_GESTURE_MANAGER_CLASS), data, pd->target);
|
||||||
|
|
||||||
pd->timeout = NULL;
|
pd->timeout = NULL;
|
||||||
pd->tap_count = 0;
|
pd->tap_count = 0;
|
||||||
|
|
|
@ -267,7 +267,7 @@ _efl_canvas_gesture_recognizer_zoom_efl_canvas_gesture_recognizer_recognize(Eo *
|
||||||
rd->continues = EINA_FALSE;
|
rd->continues = EINA_FALSE;
|
||||||
|
|
||||||
_reset_recognizer(pd);
|
_reset_recognizer(pd);
|
||||||
efl_gesture_manager_gesture_clean_up(efl_provider_find(obj, EFL_CANVAS_GESTURE_MANAGER_CLASS), watched, EFL_EVENT_GESTURE_ZOOM, obj);
|
efl_gesture_manager_recognizer_cleanup(efl_provider_find(obj, EFL_CANVAS_GESTURE_MANAGER_CLASS), obj, watched);
|
||||||
|
|
||||||
return EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
|
return EFL_GESTURE_RECOGNIZER_RESULT_IGNORE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue