diff options
author | duna.oh <duna.oh@samsung.com> | 2024-05-30 22:10:48 +0900 |
---|---|---|
committer | Duna Oh <duna.oh@samsung.com> | 2024-06-20 11:16:38 +0000 |
commit | d21a1a7203f6ada97c31c3f1fccbf2125734796b (patch) | |
tree | c730b15da2046aca9d3c930510d5d7dff0e07a4d | |
parent | 7bd6ad8389496a295e4db7e383fd510546f5c009 (diff) | |
download | efl-util-d21a1a7203f6ada97c31c3f1fccbf2125734796b.tar.gz efl-util-d21a1a7203f6ada97c31c3f1fccbf2125734796b.tar.bz2 efl-util-d21a1a7203f6ada97c31c3f1fccbf2125734796b.zip |
gesture: add APIs to register callback functions whan gesture events are triggeredaccepted/tizen/unified/x/20240625.014046accepted/tizen/unified/dev/20240701.072755accepted/tizen/unified/20240624.155449
introduce new APIs that allow application to set up a callback function which gets
executed when gesture events are detected.
Change-Id: Ic740dd1031120e379bda19386bb08bf6fdbaf646
-rw-r--r-- | include/efl_util.h | 9 | ||||
-rw-r--r-- | src/efl_util.c | 139 |
2 files changed, 148 insertions, 0 deletions
diff --git a/include/efl_util.h b/include/efl_util.h index 5e15849..87daeef 100644 --- a/include/efl_util.h +++ b/include/efl_util.h @@ -972,6 +972,15 @@ API int efl_util_gesture_activate_set(efl_util_gesture_h gesture_h, unsigned int */ API int efl_util_gesture_activate_set_on_window(efl_util_gesture_h gesture_h, Evas_Object *window, unsigned int type, Eina_Bool active); +typedef void (*efl_util_gesture_edge_swipe_cb)(void *data, int mode, int fingers, int sx, int sy, int edge); +typedef void (*efl_util_gesture_edge_drag_cb)(void *data, int mode, int fingers, int cx, int cy, int edge); +typedef void (*efl_util_gesture_tap_cb)(void *data, int mode, int fingers, int repeats); +typedef void (*efl_util_gesture_palm_cover_cb)(void *data, int mode, int duration, int cx, int cy, int size, double pressure); + +API int efl_util_gesture_edge_swipe_cb_set(efl_util_gesture_h gesture_h, efl_util_gesture_data data, efl_util_gesture_edge_swipe_cb cb_func, void *cb_data); +API int efl_util_gesture_edge_drag_cb_set(efl_util_gesture_h gesture_h, efl_util_gesture_data data, efl_util_gesture_edge_drag_cb cb_func, void *cb_data); +API int efl_util_gesture_tap_cb_set(efl_util_gesture_h gesture_h, efl_util_gesture_data data, efl_util_gesture_tap_cb cb_func, void *cb_data); +API int efl_util_gesture_palm_cover_cb_set(efl_util_gesture_h gesture_h, efl_util_gesture_data data, efl_util_gesture_palm_cover_cb cb_func, void *cb_data); /** * @} */ diff --git a/src/efl_util.c b/src/efl_util.c index 14a4b7e..307ac3b 100644 --- a/src/efl_util.c +++ b/src/efl_util.c @@ -189,6 +189,11 @@ typedef struct _Efl_Util_Data_Default_Queue struct tizen_gesture *proto; int request_notified; int event_init; + efl_util_gesture_edge_swipe_cb edge_swipe_cb; + efl_util_gesture_edge_drag_cb edge_drag_cb; + efl_util_gesture_tap_cb tap_cb; + efl_util_gesture_palm_cover_cb palm_cover_cb; + void *data; } gesture; } wl; } Efl_Util_Data_Default_Queue; @@ -2496,12 +2501,14 @@ API int EFL_UTIL_EVENT_GESTURE_PALM_COVER = 0; static void _cb_gesture_edge_swipe_notify(void *data EINA_UNUSED, struct tizen_gesture *tizen_gesture EINA_UNUSED, uint32_t fingers EINA_UNUSED, uint32_t edge EINA_UNUSED, uint32_t edge_size EINA_UNUSED, uint32_t start_point EINA_UNUSED, uint32_t end_point EINA_UNUSED, uint32_t error) { + LOGD(""); _eflutil_defaultqueue.wl.gesture.request_notified = error; } static void _cb_gesture_edge_swipe(void *data EINA_UNUSED, struct tizen_gesture *tizen_gesture EINA_UNUSED, uint32_t mode, uint32_t fingers, int sx, int sy, uint32_t edge) { + LOGD(""); efl_util_event_gesture_edge_swipe_s *ev = NULL; ev = (efl_util_event_gesture_edge_swipe_s *)calloc(1, sizeof(*ev)); @@ -2515,17 +2522,25 @@ _cb_gesture_edge_swipe(void *data EINA_UNUSED, struct tizen_gesture *tizen_gestu ev->edge = edge; ecore_event_add(EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE, ev, NULL, NULL); + + if (_eflutil_defaultqueue.wl.gesture.edge_swipe_cb) + { + LOGD("edge_swipe_cb"); + _eflutil_defaultqueue.wl.gesture.edge_swipe_cb(_eflutil_defaultqueue.wl.gesture.data, mode, fingers, sx, sy, edge); + } } static void _cb_gesture_edge_drag_notify(void *data EINA_UNUSED, struct tizen_gesture *tizen_gesture EINA_UNUSED, uint32_t fingers EINA_UNUSED, uint32_t edge EINA_UNUSED, uint32_t edge_size EINA_UNUSED, uint32_t start_point EINA_UNUSED, uint32_t end_point EINA_UNUSED, uint32_t error) { + LOGD(""); _eflutil_defaultqueue.wl.gesture.request_notified = error; } static void _cb_gesture_edge_drag(void *data EINA_UNUSED, struct tizen_gesture *tizen_gesture EINA_UNUSED, uint32_t mode, uint32_t fingers, int cx, int cy, uint32_t edge) { + LOGD(""); efl_util_event_gesture_edge_drag_s *ev = NULL; ev = (efl_util_event_gesture_edge_drag_s *)calloc(1, sizeof(*ev)); @@ -2539,17 +2554,25 @@ _cb_gesture_edge_drag(void *data EINA_UNUSED, struct tizen_gesture *tizen_gestur ev->edge = edge; ecore_event_add(EFL_UTIL_EVENT_GESTURE_EDGE_DRAG, ev, NULL, NULL); + + if (_eflutil_defaultqueue.wl.gesture.edge_drag_cb) + { + LOGD("edge_drag_cb"); + _eflutil_defaultqueue.wl.gesture.edge_drag_cb(_eflutil_defaultqueue.wl.gesture.data, mode, fingers, cx, cy, edge); + } } static void _cb_gesture_tap_notify(void *data EINA_UNUSED, struct tizen_gesture *tizen_gesture EINA_UNUSED, uint32_t fingers EINA_UNUSED, uint32_t repeat EINA_UNUSED, uint32_t error) { + LOGD(""); _eflutil_defaultqueue.wl.gesture.request_notified = error; } static void _cb_gesture_tap(void *data EINA_UNUSED, struct tizen_gesture *tizen_gesture EINA_UNUSED, uint32_t mode, uint32_t fingers, uint32_t repeats) { + LOGD(""); efl_util_event_gesture_tap_s *ev = NULL; ev = (efl_util_event_gesture_tap_s *)calloc(1, sizeof(*ev)); @@ -2561,12 +2584,19 @@ _cb_gesture_tap(void *data EINA_UNUSED, struct tizen_gesture *tizen_gesture EINA ev->repeats = repeats; ecore_event_add(EFL_UTIL_EVENT_GESTURE_TAP, ev, NULL, NULL); + + if (_eflutil_defaultqueue.wl.gesture.tap_cb) + { + LOGD("tap_cb"); + _eflutil_defaultqueue.wl.gesture.tap_cb(_eflutil_defaultqueue.wl.gesture.data, mode, fingers, repeats); + } } /* LCOV_EXCL_STOP */ static void _cb_gesture_palm_cover_notify(void *data EINA_UNUSED, struct tizen_gesture *tizen_gesture EINA_UNUSED, struct wl_surface *surface EINA_UNUSED, uint32_t error) { + LOGD(""); _eflutil_defaultqueue.wl.gesture.request_notified = error; } @@ -2574,6 +2604,7 @@ _cb_gesture_palm_cover_notify(void *data EINA_UNUSED, struct tizen_gesture *tize static void _cb_gesture_palm_cover(void *data EINA_UNUSED, struct tizen_gesture *tizen_gesture EINA_UNUSED, struct wl_surface *surface, uint32_t mode, uint32_t duration, int cx, int cy, uint32_t size, wl_fixed_t pressure) { + LOGD(""); efl_util_event_gesture_palm_cover_s *ev = NULL; ev = (efl_util_event_gesture_palm_cover_s *)calloc(1, sizeof(*ev)); @@ -2588,12 +2619,19 @@ _cb_gesture_palm_cover(void *data EINA_UNUSED, struct tizen_gesture *tizen_gestu ev->pressure = wl_fixed_to_int(pressure); ecore_event_add(EFL_UTIL_EVENT_GESTURE_PALM_COVER, ev, NULL, NULL); + + if (_eflutil_defaultqueue.wl.gesture.palm_cover_cb) + { + LOGD("palm_cover_cb"); + _eflutil_defaultqueue.wl.gesture.palm_cover_cb(_eflutil_defaultqueue.wl.gesture.data, mode, duration, cx, cy, size, pressure); + } } /* LCOV_EXCL_STOP */ static void _cb_gesture_activate_notify(void *data EINA_UNUSED, struct tizen_gesture *tizen_gesture EINA_UNUSED, struct wl_surface *surface EINA_UNUSED, uint32_t type EINA_UNUSED, uint32_t active EINA_UNUSED, uint32_t error) { + LOGD(""); _eflutil_defaultqueue.wl.gesture.request_notified = error; } @@ -2637,6 +2675,7 @@ _efl_util_gesture_verify_request_notified() static int _efl_util_gesture_grab_edge_swipe(efl_util_gesture_data data, Eina_Bool grabbed) { + LOGD(""); int ret = EFL_UTIL_ERROR_NONE; Efl_Util_Gesture_Common_Grab_Data *base_data = NULL; Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = NULL; @@ -2674,6 +2713,7 @@ _efl_util_gesture_grab_edge_swipe(efl_util_gesture_data data, Eina_Bool grabbed) static int _efl_util_gesture_grab_edge_drag(efl_util_gesture_data data, Eina_Bool grabbed) { + LOGD(""); int ret = EFL_UTIL_ERROR_NONE; Efl_Util_Gesture_Common_Grab_Data *base_data = NULL; Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = NULL; @@ -2711,6 +2751,7 @@ _efl_util_gesture_grab_edge_drag(efl_util_gesture_data data, Eina_Bool grabbed) static int _efl_util_gesture_grab_tap(efl_util_gesture_data data, Eina_Bool grabbed) { + LOGD(""); int ret = EFL_UTIL_ERROR_NONE; Efl_Util_Gesture_Common_Grab_Data *base_data = NULL; Efl_Util_Gesture_Tap_Grab_Data *tap_data = NULL; @@ -2742,6 +2783,7 @@ _efl_util_gesture_grab_tap(efl_util_gesture_data data, Eina_Bool grabbed) static int _efl_util_gesture_grab_palm_cover(efl_util_gesture_data data, Eina_Bool grabbed) { + LOGD(""); int ret = EFL_UTIL_ERROR_NONE; Efl_Util_Gesture_Common_Grab_Data *base_data = NULL; @@ -2766,6 +2808,7 @@ _efl_util_gesture_grab_palm_cover(efl_util_gesture_data data, Eina_Bool grabbed) API efl_util_gesture_h efl_util_gesture_initialize(void) { + LOGD(""); efl_util_gesture_h gesture_h = NULL; gesture_h = (efl_util_gesture_h)calloc(1, sizeof(struct _efl_util_gesture_h)); @@ -2816,6 +2859,7 @@ out: API int efl_util_gesture_deinitialize(efl_util_gesture_h gesture_h) { + LOGD(""); EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER); EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER); @@ -2840,6 +2884,7 @@ efl_util_gesture_deinitialize(efl_util_gesture_h gesture_h) API efl_util_gesture_data efl_util_gesture_edge_swipe_new(efl_util_gesture_h gesture_h, unsigned int fingers, efl_util_gesture_edge_e edge) { + LOGD(""); Efl_Util_Gesture_Edge_Swipe_Grab_Data *data; if (!gesture_h || gesture_h->init == EINA_FALSE) @@ -2874,6 +2919,7 @@ efl_util_gesture_edge_swipe_new(efl_util_gesture_h gesture_h, unsigned int finge API int efl_util_gesture_edge_swipe_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data) { + LOGD(""); if (!gesture_h || gesture_h->init == EINA_FALSE) { return EFL_UTIL_ERROR_INVALID_PARAMETER; @@ -2893,6 +2939,7 @@ efl_util_gesture_edge_swipe_free(efl_util_gesture_h gesture_h, efl_util_gesture_ API int efl_util_gesture_edge_swipe_size_set(efl_util_gesture_data data, efl_util_gesture_edge_size_e edge_size, unsigned int start_point, unsigned int end_point) { + LOGD(""); Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = data; EINA_SAFETY_ON_NULL_RETURN_VAL(edge_swipe_data, EFL_UTIL_ERROR_INVALID_PARAMETER); @@ -2912,6 +2959,7 @@ efl_util_gesture_edge_swipe_size_set(efl_util_gesture_data data, efl_util_gestur API efl_util_gesture_data efl_util_gesture_edge_drag_new(efl_util_gesture_h gesture_h, unsigned int fingers, efl_util_gesture_edge_e edge) { + LOGD(""); Efl_Util_Gesture_Edge_Drag_Grab_Data *data; if (!gesture_h || gesture_h->init == EINA_FALSE) @@ -2946,6 +2994,7 @@ efl_util_gesture_edge_drag_new(efl_util_gesture_h gesture_h, unsigned int finger API int efl_util_gesture_edge_drag_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data) { + LOGD(""); if (!gesture_h || gesture_h->init == EINA_FALSE) { return EFL_UTIL_ERROR_INVALID_PARAMETER; @@ -2965,6 +3014,7 @@ efl_util_gesture_edge_drag_free(efl_util_gesture_h gesture_h, efl_util_gesture_d API int efl_util_gesture_edge_drag_size_set(efl_util_gesture_data data, efl_util_gesture_edge_size_e edge_size, unsigned int start_point, unsigned int end_point) { + LOGD(""); Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = data; EINA_SAFETY_ON_NULL_RETURN_VAL(edge_drag_data, EFL_UTIL_ERROR_INVALID_PARAMETER); @@ -2984,6 +3034,7 @@ efl_util_gesture_edge_drag_size_set(efl_util_gesture_data data, efl_util_gesture API efl_util_gesture_data efl_util_gesture_tap_new(efl_util_gesture_h gesture_h, unsigned int fingers, unsigned int repeats) { + LOGD(""); Efl_Util_Gesture_Tap_Grab_Data *data; if (!gesture_h || gesture_h->init == EINA_FALSE) @@ -3017,6 +3068,7 @@ efl_util_gesture_tap_new(efl_util_gesture_h gesture_h, unsigned int fingers, uns API int efl_util_gesture_tap_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data) { + LOGD(""); if (!gesture_h || gesture_h->init == EINA_FALSE) { return EFL_UTIL_ERROR_INVALID_PARAMETER; @@ -3036,6 +3088,7 @@ efl_util_gesture_tap_free(efl_util_gesture_h gesture_h, efl_util_gesture_data da API efl_util_gesture_data efl_util_gesture_palm_cover_new(efl_util_gesture_h gesture_h) { + LOGD(""); Efl_Util_Gesture_Palm_Cover_Grab_Data *data; if (!gesture_h || gesture_h->init == EINA_FALSE) @@ -3061,6 +3114,7 @@ efl_util_gesture_palm_cover_new(efl_util_gesture_h gesture_h) API int efl_util_gesture_palm_cover_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data) { + LOGD(""); if (!gesture_h || gesture_h->init == EINA_FALSE) { return EFL_UTIL_ERROR_INVALID_PARAMETER; @@ -3081,6 +3135,7 @@ efl_util_gesture_palm_cover_free(efl_util_gesture_h gesture_h, efl_util_gesture_ API int efl_util_gesture_grab(efl_util_gesture_h gesture_h, efl_util_gesture_data data) { + LOGD(""); int ret = EFL_UTIL_ERROR_NONE; Efl_Util_Gesture_Common_Grab_Data *base_data = NULL; @@ -3114,6 +3169,7 @@ efl_util_gesture_grab(efl_util_gesture_h gesture_h, efl_util_gesture_data data) API int efl_util_gesture_ungrab(efl_util_gesture_h gesture_h, efl_util_gesture_data data) { + LOGD(""); int ret = EFL_UTIL_ERROR_NONE; Efl_Util_Gesture_Common_Grab_Data *base_data = NULL; @@ -3148,6 +3204,7 @@ efl_util_gesture_ungrab(efl_util_gesture_h gesture_h, efl_util_gesture_data data API int efl_util_gesture_select(efl_util_gesture_h gesture_h, Evas_Object *window, efl_util_gesture_data data) { + LOGD(""); Efl_Util_Gesture_Common_Grab_Data *base_data = NULL; Ecore_Wl2_Window *wlwin; struct wl_surface *surface; @@ -3180,6 +3237,7 @@ efl_util_gesture_select(efl_util_gesture_h gesture_h, Evas_Object *window, efl_u API int efl_util_gesture_deselect(efl_util_gesture_h gesture_h, Evas_Object *window, efl_util_gesture_data data) { + LOGD(""); Efl_Util_Gesture_Common_Grab_Data *base_data = NULL; Ecore_Wl2_Window *wlwin; struct wl_surface *surface; @@ -3213,6 +3271,7 @@ efl_util_gesture_deselect(efl_util_gesture_h gesture_h, Evas_Object *window, efl API int efl_util_gesture_activate_set(efl_util_gesture_h gesture_h, unsigned int type, Eina_Bool active) { + LOGD(""); int ret; EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER); @@ -3230,6 +3289,7 @@ efl_util_gesture_activate_set(efl_util_gesture_h gesture_h, unsigned int type, E API int efl_util_gesture_activate_set_on_window(efl_util_gesture_h gesture_h, Evas_Object *window, unsigned int type, Eina_Bool active) { + LOGD(""); Ecore_Wl2_Window *wlwin; struct wl_surface *surface; int ret; @@ -3252,3 +3312,82 @@ efl_util_gesture_activate_set_on_window(efl_util_gesture_h gesture_h, Evas_Objec return ret; } + +API int efl_util_gesture_edge_swipe_cb_set(efl_util_gesture_h gesture_h, efl_util_gesture_data data, efl_util_gesture_edge_swipe_cb cb_func, void *cb_data) +{ + LOGD(""); + int ret = EFL_UTIL_ERROR_NONE; + Efl_Util_Gesture_Common_Grab_Data *base_data = NULL; + + base_data = (Efl_Util_Gesture_Common_Grab_Data *)data; + + EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER); + EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER); + EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER); + EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_SWIPE, + EFL_UTIL_ERROR_INVALID_PARAMETER); + + _eflutil_defaultqueue.wl.gesture.edge_swipe_cb = cb_func; + _eflutil_defaultqueue.wl.gesture.data = cb_data; + + return ret; +} +API int efl_util_gesture_edge_drag_cb_set(efl_util_gesture_h gesture_h, efl_util_gesture_data data, efl_util_gesture_edge_drag_cb cb_func, void *cb_data) +{ + LOGD(""); + int ret = EFL_UTIL_ERROR_NONE; + Efl_Util_Gesture_Common_Grab_Data *base_data = NULL; + + base_data = (Efl_Util_Gesture_Common_Grab_Data *)data; + + EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER); + EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER); + EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER); + EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_DRAG, + EFL_UTIL_ERROR_INVALID_PARAMETER); + + _eflutil_defaultqueue.wl.gesture.edge_drag_cb = cb_func; + _eflutil_defaultqueue.wl.gesture.data = cb_data; + + return ret; +} +API int efl_util_gesture_tap_cb_set(efl_util_gesture_h gesture_h, efl_util_gesture_data data, efl_util_gesture_tap_cb cb_func, void *cb_data) +{ + LOGD(""); + int ret = EFL_UTIL_ERROR_NONE; + Efl_Util_Gesture_Common_Grab_Data *base_data = NULL; + + base_data = (Efl_Util_Gesture_Common_Grab_Data *)data; + + EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER); + EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER); + EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER); + EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_TAP, + EFL_UTIL_ERROR_INVALID_PARAMETER); + + _eflutil_defaultqueue.wl.gesture.tap_cb = cb_func; + _eflutil_defaultqueue.wl.gesture.data = cb_data; + + return ret; +} + + +API int efl_util_gesture_palm_cover_cb_set(efl_util_gesture_h gesture_h, efl_util_gesture_data data, efl_util_gesture_palm_cover_cb cb_func, void *cb_data) +{ + LOGD(""); + int ret = EFL_UTIL_ERROR_NONE; + Efl_Util_Gesture_Common_Grab_Data *base_data = NULL; + + base_data = (Efl_Util_Gesture_Common_Grab_Data *)data; + + EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER); + EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER); + EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER); + EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_PALM_COVER, + EFL_UTIL_ERROR_INVALID_PARAMETER); + + _eflutil_defaultqueue.wl.gesture.palm_cover_cb = cb_func; + _eflutil_defaultqueue.wl.gesture.data = cb_data; + + return ret; +}
\ No newline at end of file |