From d1f7ffb69c47821ca0e99c42e796da86ffc85ca0 Mon Sep 17 00:00:00 2001 From: JengHyun Kang Date: Mon, 11 Sep 2017 14:32:06 +0900 Subject: [PATCH] e_gesture: add a e_gesture feature for global gesture server grab Change-Id: I08e613855ec2ea7d76198cc73332d45eda86eb8a --- src/bin/Makefile.mk | 6 +- src/bin/e_gesture.c | 186 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/bin/e_gesture.h | 169 ++++++++++++++++++++++++++++++++++++++++++++++ src/bin/e_includes.h | 1 + src/bin/e_main.c | 4 ++ 5 files changed, 364 insertions(+), 2 deletions(-) create mode 100644 src/bin/e_gesture.c create mode 100644 src/bin/e_gesture.h diff --git a/src/bin/Makefile.mk b/src/bin/Makefile.mk index a6efc2c..9cd63fa 100644 --- a/src/bin/Makefile.mk +++ b/src/bin/Makefile.mk @@ -118,7 +118,8 @@ src/bin/e_policy_wl_display.h \ src/bin/e_process.h \ src/bin/e_privilege.h \ src/bin/e_security.h \ -src/bin/e_keyrouter.h +src/bin/e_keyrouter.h \ +src/bin/e_gesture.h enlightenment_src = \ src/bin/e_actions.c \ @@ -215,7 +216,8 @@ src/bin/e_policy_wl_display.c \ src/bin/e_process.c \ src/bin/e_privilege.c \ src/bin/e_security.c \ -src/bin/e_keyrouter.c +src/bin/e_keyrouter.c \ +src/bin/e_gesture.c src_bin_enlightenment_CPPFLAGS = $(E_CPPFLAGS) -DEFL_BETA_API_SUPPORT -DEFL_EO_API_SUPPORT -DE_LOGGING=1 @WAYLAND_CFLAGS@ $(TTRACE_CFLAGS) $(DLOG_CFLAGS) $(PIXMAN_CFLAGS) $(POLICY_CFLAGS) @TIZEN_REMOTE_SURFACE_CFLAGS@ if HAVE_LIBGOMP diff --git a/src/bin/e_gesture.c b/src/bin/e_gesture.c new file mode 100644 index 0000000..a59e0cf --- /dev/null +++ b/src/bin/e_gesture.c @@ -0,0 +1,186 @@ +#include "e.h" +#include "e_gesture.h" + +E_API E_Gesture_Info *e_gesture = NULL; + +E_API int E_EVENT_GESTURE_EDGE_SWIPE; +E_API int E_EVENT_GESTURE_EDGE_DRAG; +E_API int E_EVENT_GESTURE_TAP; +E_API int E_EVENT_GESTURE_PALM_COVER; +E_API int E_EVENT_GESTURE_PAN; +E_API int E_EVENT_GESTURE_PINCH; + +EINTERN void +e_gesture_init(void) +{ + e_gesture = E_NEW(E_Gesture_Info, 1); + if (!e_gesture) return; + + E_EVENT_GESTURE_EDGE_SWIPE = ecore_event_type_new(); + E_EVENT_GESTURE_EDGE_DRAG = ecore_event_type_new(); + E_EVENT_GESTURE_TAP = ecore_event_type_new(); + E_EVENT_GESTURE_PALM_COVER = ecore_event_type_new(); + E_EVENT_GESTURE_PAN = ecore_event_type_new(); + E_EVENT_GESTURE_PINCH = ecore_event_type_new(); +} + +EINTERN int +e_gesture_shutdown(void) +{ + if (e_gesture) + { + E_FREE(e_gesture); + E_EVENT_GESTURE_EDGE_SWIPE = 0; + E_EVENT_GESTURE_EDGE_DRAG = 0; + E_EVENT_GESTURE_TAP = 0; + E_EVENT_GESTURE_PALM_COVER = 0; + E_EVENT_GESTURE_PAN = 0; + E_EVENT_GESTURE_PINCH = 0; + } + + return 1; +} + +E_API int +e_gesture_edge_swipe_grab(unsigned int fingers, unsigned int edge, unsigned int edge_size, unsigned int start_point, unsigned int end_point) +{ + int ret; + + if (!e_gesture || !e_gesture->edge_swipe.grab) + return E_GESTURE_ERROR_NOT_SUPPORTED; + + ret = e_gesture->edge_swipe.grab(fingers, edge, edge_size, start_point, end_point); + return ret; +} + +E_API int +e_gesture_edge_swipe_ungrab(unsigned int fingers, unsigned int edge, unsigned int edge_size, unsigned int start_point, unsigned int end_point) +{ + int ret; + + if (!e_gesture || !e_gesture->edge_swipe.ungrab) + return E_GESTURE_ERROR_NOT_SUPPORTED; + + ret = e_gesture->edge_swipe.ungrab(fingers, edge, edge_size, start_point, end_point); + return ret; +} + +E_API int +e_gesture_edge_drag_grab(unsigned int fingers, unsigned int edge, unsigned int edge_size, unsigned int start_point, unsigned int end_point) +{ + int ret; + + if (!e_gesture || !e_gesture->edge_drag.grab) + return E_GESTURE_ERROR_NOT_SUPPORTED; + + ret = e_gesture->edge_drag.grab(fingers, edge, edge_size, start_point, end_point); + return ret; +} + +E_API int +e_gesture_edge_drag_ungrab(unsigned int fingers, unsigned int edge, unsigned int edge_size, unsigned int start_point, unsigned int end_point) +{ + int ret; + + if (!e_gesture || !e_gesture->edge_drag.ungrab) + return E_GESTURE_ERROR_NOT_SUPPORTED; + + ret = e_gesture->edge_drag.ungrab(fingers, edge, edge_size, start_point, end_point); + return ret; +} + +E_API int +e_gesture_tap_grab(unsigned int fingers, unsigned int repeats) +{ + int ret; + + if (!e_gesture || !e_gesture->tap.grab) + return E_GESTURE_ERROR_NOT_SUPPORTED; + + ret = e_gesture->tap.grab(fingers, repeats); + return ret; +} + +E_API int +e_gesture_tap_ungrab(unsigned int fingers, unsigned int repeats) +{ + int ret; + + if (!e_gesture || !e_gesture->tap.ungrab) + return E_GESTURE_ERROR_NOT_SUPPORTED; + + ret = e_gesture->tap.ungrab(fingers, repeats); + return ret; +} + +E_API int +e_gesture_palm_cover_grab(void) +{ + int ret; + + if (!e_gesture || !e_gesture->palm_cover.grab) + return E_GESTURE_ERROR_NOT_SUPPORTED; + + ret = e_gesture->palm_cover.grab(); + return ret; +} + +E_API int +e_gesture_palm_cover_ungrab(void) +{ + int ret; + + if (!e_gesture || !e_gesture->palm_cover.ungrab) + return E_GESTURE_ERROR_NOT_SUPPORTED; + + ret = e_gesture->palm_cover.ungrab(); + return ret; +} + +E_API int +e_gesture_pan_grab(unsigned int fingers) +{ + int ret; + + if (!e_gesture || !e_gesture->pan.grab) + return E_GESTURE_ERROR_NOT_SUPPORTED; + + ret = e_gesture->pan.grab(fingers); + return ret; +} + +E_API int +e_gesture_pan_ungrab(unsigned int fingers) +{ + int ret; + + if (!e_gesture || !e_gesture->pan.ungrab) + return E_GESTURE_ERROR_NOT_SUPPORTED; + + ret = e_gesture->pan.ungrab(fingers); + return ret; +} + +E_API int +e_gesture_pinch_grab(unsigned int fingers) +{ + int ret; + + if (!e_gesture || !e_gesture->pinch.grab) + return E_GESTURE_ERROR_NOT_SUPPORTED; + + ret = e_gesture->pinch.grab(fingers); + return ret; +} + +E_API int +e_gesture_pinch_ungrab(unsigned int fingers) +{ + int ret; + + if (!e_gesture || !e_gesture->pinch.ungrab) + return E_GESTURE_ERROR_NOT_SUPPORTED; + + ret = e_gesture->pinch.ungrab(fingers); + return ret; +} \ No newline at end of file diff --git a/src/bin/e_gesture.h b/src/bin/e_gesture.h new file mode 100644 index 0000000..123b75a --- /dev/null +++ b/src/bin/e_gesture.h @@ -0,0 +1,169 @@ +#ifdef E_TYPEDEFS + +typedef enum _E_Gesture_Error E_Gesture_Error; +typedef enum _E_Gesture_Mode E_Gesture_Mode; +typedef enum _E_Gesture_Edge E_Gesture_Edge; +typedef enum _E_Gesture_Edge_Size E_Gesture_Edge_Size; + +typedef struct _E_Gesture_Info E_Gesture_Info; + +typedef struct _E_Event_Gesture_Edge_Swipe E_Event_Gesture_Edge_Swipe; +typedef struct _E_Event_Gesture_Edge_Drag E_Event_Gesture_Edge_Drag; +typedef struct _E_Event_Gesture_Tap E_Event_Gesture_Tap; +typedef struct _E_Event_Gesture_Palm_Cover E_Event_Gesture_Palm_Cover; +typedef struct _E_Event_Gesture_Pan E_Event_Gesture_Pan; +typedef struct _E_Event_Gesture_Pinch E_Event_Gesture_Pinch; + +#else +#ifndef E_GESTURE_H +#define E_GESTURE_H + +extern E_API E_Gesture_Info *e_gesture; + +extern E_API int E_EVENT_GESTURE_EDGE_SWIPE; +extern E_API int E_EVENT_GESTURE_EDGE_DRAG; +extern E_API int E_EVENT_GESTURE_TAP; +extern E_API int E_EVENT_GESTURE_PALM_COVER; +extern E_API int E_EVENT_GESTURE_PAN; +extern E_API int E_EVENT_GESTURE_PINCH; + +enum _E_Gesture_Error +{ + E_GESTURE_ERROR_NONE = 0, + E_GESTURE_ERROR_INVAILD_DATA, + E_GESTURE_ERROR_NO_PERMISSION, + E_GESTURE_ERROR_NO_SYSTEM_RESOURCE, + E_GESTURE_ERROR_GRABBED_ALREADY, + E_GESTURE_ERROR_NOT_SUPPORTED +}; + +enum _E_Gesture_Mode +{ + E_GESTURE_MODE_NONE = 0, + E_GESTURE_MODE_BEGIN, + E_GESTURE_MODE_UPDATE, + E_GESTURE_MODE_END, + E_GESTURE_MODE_DONE +}; + +enum _E_Gesture_Edge +{ + E_GESTURE_EDGE_NONE = 0, + E_GESTURE_EDGE_TOP, + E_GESTURE_EDGE_RIGHT, + E_GESTURE_EDGE_BOTTOM, + E_GESTURE_EDGE_LEFT +}; + +enum _E_Gesture_Edge_Size +{ + E_GESTURE_EDGE_SIZE_NONE, + E_GESTURE_EDGE_SIZE_FULL, + E_GESTURE_EDGE_SIZE_PARTIAL +}; + +struct _E_Event_Gesture_Edge_Swipe +{ + E_Gesture_Mode mode; + unsigned int fingers; + int sx; + int sy; + unsigned int edge; +}; + +struct _E_Event_Gesture_Edge_Drag +{ + E_Gesture_Mode mode; + unsigned int fingers; + int cx; + int cy; + unsigned int edge; +}; + +struct _E_Event_Gesture_Tap +{ + E_Gesture_Mode mode; + unsigned int fingers; + unsigned int repeats; +}; + +struct _E_Event_Gesture_Palm_Cover +{ + E_Gesture_Mode mode; + unsigned int duration; + int cx; + int cy; + unsigned int size; + double pressure; +}; + +struct _E_Event_Gesture_Pan +{ + E_Gesture_Mode mode; + unsigned int fingers; + int cx; + int cy; +}; + +struct _E_Event_Gesture_Pinch +{ + E_Gesture_Mode mode; + unsigned int fingers; + double distance; + double angle; + int cx; + int cy; +}; + +struct _E_Gesture_Info +{ + struct + { + int (*grab)(uint32_t fingers, uint32_t edge, uint32_t edge_size, uint32_t start_point, uint32_t end_point); + int (*ungrab)(uint32_t fingers, uint32_t edge, uint32_t edge_size, uint32_t start_point, uint32_t end_point); + } edge_swipe; + struct + { + int (*grab)(uint32_t fingers, uint32_t edge, uint32_t edge_size, uint32_t start_point, uint32_t end_point); + int (*ungrab)(uint32_t fingers, uint32_t edge, uint32_t edge_size, uint32_t start_point, uint32_t end_point); + } edge_drag; + struct + { + int (*grab)(uint32_t fingers, uint32_t repeats); + int (*ungrab)(uint32_t fingers, uint32_t repeats); + } tap; + struct + { + int (*grab)(void); + int (*ungrab)(void); + } palm_cover; + struct + { + int (*grab)(uint32_t fingers); + int (*ungrab)(uint32_t fingers); + } pan; + struct + { + int (*grab)(uint32_t fingers); + int (*ungrab)(uint32_t fingers); + } pinch; +}; + +EINTERN void e_gesture_init(void); +EINTERN int e_gesture_shutdown(void); + +E_API int e_gesture_edge_swipe_grab(unsigned int fingers, unsigned int edge, unsigned int edge_size, unsigned int start_point, unsigned int end_point); +E_API int e_gesture_edge_swipe_ungrab(unsigned int fingers, unsigned int edge, unsigned int edge_size, unsigned int start_point, unsigned int end_point); +E_API int e_gesture_edge_drag_grab(unsigned int fingers, unsigned int edge, unsigned int edge_size, unsigned int start_point, unsigned int end_point); +E_API int e_gesture_edge_drag_ungrab(unsigned int fingers, unsigned int edge, unsigned int edge_size, unsigned int start_point, unsigned int end_point); +E_API int e_gesture_tap_grab(unsigned int fingers, unsigned int repeats); +E_API int e_gesture_tap_ungrab(unsigned int fingers, unsigned int repeats); +E_API int e_gesture_palm_cover_grab(void); +E_API int e_gesture_palm_cover_ungrab(void); +E_API int e_gesture_pan_grab(unsigned int fingers); +E_API int e_gesture_pan_ungrab(unsigned int fingers); +E_API int e_gesture_pinch_grab(unsigned int fingers); +E_API int e_gesture_pinch_ungrab(unsigned int fingers); + +#endif +#endif diff --git a/src/bin/e_includes.h b/src/bin/e_includes.h index 67892aa..cb78128 100644 --- a/src/bin/e_includes.h +++ b/src/bin/e_includes.h @@ -73,3 +73,4 @@ #include "e_security.h" #include "e_main.h" #include "e_keyrouter.h" +#include "e_gesture.h" diff --git a/src/bin/e_main.c b/src/bin/e_main.c index 4046a7e..de70f39 100644 --- a/src/bin/e_main.c +++ b/src/bin/e_main.c @@ -663,6 +663,10 @@ main(int argc, char **argv) TS("E_Grabinput Init Done"); _e_main_shutdown_push(e_grabinput_shutdown); + TS("E_Gesture Init"); + e_gesture_init(); + _e_main_shutdown_push(e_gesture_shutdown); + ecore_event_handler_add(E_EVENT_MODULE_INIT_END, _e_main_deferred_job_schedule, NULL); TS("E_Module Init"); -- 2.7.4