From: JengHyun Kang Date: Mon, 26 Jun 2017 08:57:36 +0000 (+0900) Subject: gesture: add gesture APIs X-Git-Tag: accepted/tizen/unified/20170727.191239^0 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fapi%2Fefl-util.git;a=commitdiff_plain;h=6d1e77999b8e6626ee3beced27f78aeab8da5386 gesture: add gesture APIs Change-Id: Id4ea4220f5fec52a09bcdca2f90f6bc0f6d7704a --- diff --git a/doc/ui_efl_util_gesture_doc.h b/doc/ui_efl_util_gesture_doc.h new file mode 100644 index 0000000..6eeff36 --- /dev/null +++ b/doc/ui_efl_util_gesture_doc.h @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2011-2017 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __TIZEN_UI_EFL_UTIL_GESTURE_DOC_H__ +#define __TIZEN_UI_EFL_UTIL_GESTURE_DOC_H__ + +/** + * @ingroup CAPI_EFL_UTIL_MODULE + * @defgroup CAPI_EFL_UTIL_GESTURE_MODULE EFL UTIL GESTURE + * @brief Handling global gesture events + * + * @section CAPI_EFL_UTIL_GESTURE_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_EFL_UTIL_GESTURE_MODULE_OVERVIEW Overview + * The EFL UTIL API provides functions to grab / select / activate global gestures + * and propagate these events to Ecore_Event. + * + */ + +#endif /* __TIZEN_UI_EFL_UTIL_GESTURE_DOC_H__ */ diff --git a/include/efl_util.h.in b/include/efl_util.h.in index 258648f..8055226 100644 --- a/include/efl_util.h.in +++ b/include/efl_util.h.in @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2011-2017 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. @@ -57,7 +57,8 @@ typedef enum EFL_UTIL_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< @platform Not supported (@b Since: $TZ_CFG_VER_24_OR_30$) */ EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE = TIZEN_ERROR_EFL_UTIL | 0x01, /**< Window type not supported */ EFL_UTIL_ERROR_SCREENSHOT_INIT_FAIL = TIZEN_ERROR_EFL_UTIL | 0x02, /**< @platform Screenshot initialization fail (@b Since: $TZ_CFG_VER_24_OR_30$) */ - EFL_UTIL_ERROR_SCREENSHOT_EXECUTION_FAIL = TIZEN_ERROR_EFL_UTIL | 0x03 /**< @platform Screenshot execution fail (@b Since: $TZ_CFG_VER_24_OR_30$) */ + EFL_UTIL_ERROR_SCREENSHOT_EXECUTION_FAIL = TIZEN_ERROR_EFL_UTIL | 0x03, /**< @platform Screenshot execution fail (@b Since: $TZ_CFG_VER_24_OR_30$) */ + EFL_UTIL_ERROR_NO_RESOURCE_AVAILABLE = TIZEN_ERROR_EFL_UTIL | 0x04 /**< Resource is not available (@b Since: 4.0) */ } efl_util_error_e; /** @@ -532,6 +533,417 @@ API int efl_util_screenshot_deinitialize(efl_util_screenshot_h screenshot); * @} */ +/** + * @addtogroup CAPI_EFL_UTIL_GESTURE_MODULE + * @{ + */ + +/** + * @brief Definition for the gesture handle. + * @since_tizen 4.0 + */ +typedef struct _efl_util_gesture_h * efl_util_gesture_h; + +/** + * @brief Definition for the edge swipe gesture event. + * @since_tizen 4.0 + */ +API extern int EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE; + +/** + * @brief Definition for the edge swipe gesture event. + * @since_tizen 4.0 + */ +API extern int EFL_UTIL_EVENT_GESTURE_EDGE_DRAG; + +/** + * @brief Definition for the tap gesture event. + * @since_tizen 4.0 + */ +API extern int EFL_UTIL_EVENT_GESTURE_TAP; + +/** + * @brief Definition for the palm cover gesture event. + * @since_tizen 4.0 + */ +API extern int EFL_UTIL_EVENT_GESTURE_PALM_COVER; + +/** + * @brief Enumeration of gesture type + * @since_tizen 4.0 + */ +typedef enum _efl_util_gesture_type_e +{ + EFL_UTIL_GESTURE_TYPE_NONE = 0, /**< None gesture type */ + EFL_UTIL_GESTURE_TYPE_EDGE_SWIPE = (1 << 0), /**< Edge swipe gesture type */ + EFL_UTIL_GESTURE_TYPE_EDGE_DRAG = (1 << 1), /**< Edge drag gesture type */ + EFL_UTIL_GESTURE_TYPE_TAP = (1 << 2), /**< Tap gesture type */ + EFL_UTIL_GESTURE_TYPE_PALM_COVER = (1 << 3), /**< Palm cover gesture type */ + EFL_UTIL_GESTURE_TYPE_PAN = (1 << 4), /**< Pan gesture type */ + EFL_UTIL_GESTURE_TYPE_PINCH = (1 << 5), /**< Pinch gesture type */ + EFL_UTIL_GESTURE_TYPE_PALM_SWIPE = (1 << 6) /**< Palm swipe gesture type */ +} efl_util_gesture_type_e; + +/** + * @brief Enumeration of gesture mode + * @since_tizen 4.0 + */ +typedef enum _efl_util_gesture_mode_e +{ + EFL_UTIL_GESTURE_MODE_NONE = 0, /**< None gesture mode */ + EFL_UTIL_GESTURE_MODE_BEGIN, /**< Begin a gesture event */ + EFL_UTIL_GESTURE_MODE_UPDATE, /**< continually update a gesture event */ + EFL_UTIL_GESTURE_MODE_END, /**< End a gesture event */ + EFL_UTIL_GESTURE_MODE_DONE /**< Occur a gesture event */ +} efl_util_gesture_mode_e; + +/** + * @brief Enumeration of gesture edge + * @since_tizen 4.0 + */ +typedef enum _efl_util_gesture_edge_e +{ + EFL_UTIL_GESTURE_EDGE_NONE = 0, /**< None edge point */ + EFL_UTIL_GESTURE_EDGE_TOP, /**< Top edge position of screen */ + EFL_UTIL_GESTURE_EDGE_RIGHT, /**< Right edge position of screen */ + EFL_UTIL_GESTURE_EDGE_BOTTOM, /**< Bottom edge position of screen */ + EFL_UTIL_GESTURE_EDGE_LEFT /**< Left edge position of screen */ +} efl_util_gesture_edge_e; + +/** + * @brief Enumeration of gesture edge size + * @since_tizen 4.0 + */ +typedef enum _efl_util_gesture_edge_size_e +{ + EFL_UTIL_GESTURE_EDGE_SIZE_NONE, /**< None size of edge */ + EFL_UTIL_GESTURE_EDGE_SIZE_FULL, /**< Full size in the edge */ + EFL_UTIL_GESTURE_EDGE_SIZE_PARTIAL /**< Part of edge */ +} efl_util_gesture_edge_size_e; + +/** + * @brief Definition for the gesture data handle + * @since_tizen 4.0 + */ +typedef void *efl_util_gesture_data; + +/** + * @brief Definition for the edge swipe gesture's event data structure + * @since_tizen 4.0 + */ +typedef struct _efl_util_event_gesture_edge_swipe_s +{ + efl_util_gesture_mode_e mode; /**< Mode of a gesture event */ + unsigned int fingers; /**< Number of fingers */ + int sx; /**< Start x point of edge area */ + int sy; /**< Start y point of edge area */ + unsigned int edge; /**< Start edge location */ +} efl_util_event_gesture_edge_swipe_s; + +/** + * @brief Definition for the edge drag gesture's event data structure + * @since_tizen 4.0 + */ +typedef struct efl_util_event_gesture_edge_drag_s +{ + efl_util_gesture_mode_e mode; /**< Mode of a gesture event */ + unsigned int fingers; /**< Number of fingers */ + int cx; /**< Center x point of edge area */ + int cy; /**< Center y point of edge area */ + unsigned int edge; /**< Start edge location */ +} efl_util_event_gesture_edge_drag_s; + +/** + * @brief Definition for the tap gesture's event data structure + * @since_tizen 4.0 + */ +typedef struct _efl_util_event_gesture_tap_s +{ + efl_util_gesture_mode_e mode; /**< Mode of a gesture event */ + unsigned int fingers; /**< Number of fingers */ + unsigned int repeats; /**< Number of tap repeats */ +} efl_util_event_gesture_tap_s; + +/** + * @brief Definition for the palm cover gesture's event data structure + * @since_tizen 4.0 + */ +typedef struct _efl_util_event_gesture_palm_cover_s +{ + efl_util_gesture_mode_e mode; /**< Mode of a gesture event */ + unsigned int duration; /**< Duration time of gesture behavior */ + int cx; /**< Center x point of edge area */ + int cy; /**< Center y point of edge area */ + unsigned int size; /**< Size of touched area */ + double pressure; /**< Pressure of touched finger */ +} efl_util_event_gesture_palm_cover_s; + +/** + * @brief Initializes system and check if global gestures are supported. + * @since_tizen 4.0 + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exception section. + * @return #efl_util_gesture_h on success, otherwise @c NULL + * @retval #efl_util_gesture_h The global gesture handle + * @exception #EFL_UTIL_ERROR_NONE Successful + * @exception #EFL_UTIL_ERROR_OUT_OF_MEMORY Memory allocation failure + * @exception #EFL_UTIL_ERROR_NOT_SUPPORTED Not supported + * @exception #EFL_UTIL_ERROR_NO_RESOURCE_AVAILABLE Resource is not available + * @see efl_util_gesture_deinitialize() + */ +API efl_util_gesture_h efl_util_gesture_initialize(void); + +/** + * @brief Deinitializes system. + * @since_tizen 4.0 + * @param[in] gesture_h The #efl_util_gesture_h handle + * @return @c 0 on success, otherwise a negative error value + * @retval #EFL_UTIL_ERROR_NONE Successful + * @retval #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter + * @see efl_util_gesture_initialize() + */ +API int efl_util_gesture_deinitialize(efl_util_gesture_h gesture_h); + +/** + * @brief Generates a edge swipe gesture's grab info handle. + * @since_tizen 4.0 + * @param[in] gesture_h The #efl_util_gesture_h handle + * @param[in] fingers The number of fingers + * @param[in] edge The position of edge + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exception section. + * @return #efl_util_gesture_data on success, otherwise @c NULL + * @retval #efl_util_gesture_data The specific gesture data handle + * @exception #EFL_UTIL_ERROR_NONE Successful + * @exception #EFL_UTIL_ERROR_OUT_OF_MEMORY Memory allocation failure + * @exception #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter + * @exception #EFL_UTIL_ERROR_NO_RESOURCE_AVAILABLE Resource is not available + */ +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); + +/** + * @brief Frees a memory of edge swipe gesture's grab info handle. + * @since_tizen 4.0 + * @param[in] gesture_h The #efl_util_gesture_h handle + * @param[in] data The #efl_util_gesture_data handle + * @return @c 0 on success, otherwise a negative error value + * @retval #EFL_UTIL_ERROR_NONE Successful + * @retval #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter + */ +API int efl_util_gesture_edge_swipe_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data); + + +/** + * @brief Sets a specific size of edge for edge swipe gesture. + * @since_tizen 4.0 + * @param[in] data The #efl_util_gesture_data handle + * @param[in] edge_size The #efl_util_gesture_edge_size_e enum + * @param[in] start_point The start point of edge area + * @param[in] end_point The end point of edge area + * @return @c 0 on success, otherwise a negative error value + * @retval #EFL_UTIL_ERROR_NONE Successful + * @retval #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #EFL_UTIL_ERROR_NO_RESOURCE_AVAILABLE Resource is not available + */ +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); + +/** + * @brief Generates a edge drag gesture's grab info handle. + * @since_tizen 4.0 + * @param[in] gesture_h The #efl_util_gesture_h handle + * @param[in] fingers The number of fingers + * @param[in] edge The position of edge + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exception section. + * @return #efl_util_gesture_data on success, otherwise @c NULL + * @retval #efl_util_gesture_data The specific gesture data handle + * @exception #EFL_UTIL_ERROR_NONE Successful + * @exception #EFL_UTIL_ERROR_OUT_OF_MEMORY Memory allocation failure + * @exception #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter + * @exception #EFL_UTIL_ERROR_NO_RESOURCE_AVAILABLE Resource is not available + */ +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); + +/** + * @brief Frees a memory of edge drag gesture's grab info handle. + * @since_tizen 4.0 + * @param[in] gesture_h The #efl_util_gesture_h handle + * @param[in] data The #efl_util_gesture_data handle + * @return @c 0 on success, otherwise a negative error value + * @retval #EFL_UTIL_ERROR_NONE Successful + * @retval #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter + */ +API int efl_util_gesture_edge_drag_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data); + +/** + * @brief Sets a specific size of edge for edge drag gesture. + * @since_tizen 4.0 + * @param[in] data The #efl_util_gesture_data handle + * @param[in] edge_size The #efl_util_gesture_edge_size_e enum + * @param[in] start_point The start point of edge area + * @param[in] end_point The end point of edge area + * @return @c 0 on success, otherwise a negative error value + * @retval #EFL_UTIL_ERROR_NONE Successful + * @retval #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #EFL_UTIL_ERROR_NO_RESOURCE_AVAILABLE Resource is not available + */ +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); + +/** + * @brief Generates a tap gesture's grab info handle. + * @since_tizen 4.0 + * @param[in] gesture_h The #efl_util_gesture_h handle + * @param[in] fingers The number of fingers + * @param[in] repeats The number of repeats + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exception section. + * @return #efl_util_gesture_data on success, otherwise @c NULL + * @retval #efl_util_gesture_data The specific gesture data handle + * @exception #EFL_UTIL_ERROR_NONE Successful + * @exception #EFL_UTIL_ERROR_OUT_OF_MEMORY Memory allocation failure + * @exception #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter + * @exception #EFL_UTIL_ERROR_NO_RESOURCE_AVAILABLE Resource is not available + */ +API efl_util_gesture_data efl_util_gesture_tap_new(efl_util_gesture_h gesture_h, unsigned int fingers, unsigned int repeats); + +/** + * @brief Frees a memory of tap gesture's grab info handle. + * @since_tizen 4.0 + * @param[in] gesture_h The #efl_util_gesture_h handle + * @param[in] data The #efl_util_gesture_data handle + * @return @c 0 on success, otherwise a negative error value + * @retval #EFL_UTIL_ERROR_NONE Successful + * @retval #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter + */ +API int efl_util_gesture_tap_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data); + +/** + * @brief Generates a palm cover gesture's grab info handle. + * @since_tizen 4.0 + * @param[in] gesture_h The #efl_util_gesture_h handle + * @remarks The specific error code can be obtained using the get_last_result() method. + * Error codes are described in Exception section. + * @return #efl_util_gesture_data on success, otherwise @c NULL + * @retval #efl_util_gesture_data The specific gesture data handle + * @exception #EFL_UTIL_ERROR_NONE Successful + * @exception #EFL_UTIL_ERROR_OUT_OF_MEMORY Memory allocation failure + * @exception #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter + * @exception #EFL_UTIL_ERROR_NO_RESOURCE_AVAILABLE Resource is not available + */ +API efl_util_gesture_data efl_util_gesture_palm_cover_new(efl_util_gesture_h gesture_h); + +/** + * @brief Frees a memory of palm cover gesture's grab info handle. + * @since_tizen 4.0 + * @param[in] gesture_h The #efl_util_gesture_h handle + * @param[in] data The #efl_util_gesture_data handle + * @return @c 0 on success, otherwise a negative error value + * @retval #EFL_UTIL_ERROR_NONE Successful + * @retval #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter + */ +API int efl_util_gesture_palm_cover_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data); + +/** + * @platform + * @brief Grabs a global gesture. + * @since_tizen 4.0 + * @privlevel platform + * @privilege %http://tizen.org/privilege/gesturegrab + * @param[in] gesture_h The #efl_util_gesture_h handle + * @param[in] data The #efl_util_gesture_data handle. + * @return @c 0 on success, otherwise a negative error value + * @retval #EFL_UTIL_ERROR_NONE Successful + * @retval #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #EFL_UTIL_ERROR_PERMISSION_DENIED Permission denied + * @retval #EFL_UTIL_ERROR_OUT_OF_MEMORY Memory allocation failure + * @retval #EFL_UTIL_ERROR_NOT_SUPPORTED Not supported + * @retval #EFL_UTIL_ERROR_NO_RESOURCE_AVAILABLE Resource is not available + */ +API int efl_util_gesture_grab(efl_util_gesture_h gesture_h, efl_util_gesture_data data); + +/** + * @platform + * @brief Ungrabs a global gesture. + * @since_tizen 4.0 + * @privlevel platform + * @privilege %http://tizen.org/privilege/gesturegrab + * @param[in] gesture_h The #efl_util_gesture_h handle + * @param[in] data The #efl_util_gesture_data handle. + * @return @c 0 on success, otherwise a negative error value + * @retval #EFL_UTIL_ERROR_NONE Successful + * @retval #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #EFL_UTIL_ERROR_PERMISSION_DENIED Permission denied + * @retval #EFL_UTIL_ERROR_OUT_OF_MEMORY Memory allocation failure + * @retval #EFL_UTIL_ERROR_NOT_SUPPORTED Not supported + * @retval #EFL_UTIL_ERROR_NO_RESOURCE_AVAILABLE Resource is not available + */ +API int efl_util_gesture_ungrab(efl_util_gesture_h gesture_h, efl_util_gesture_data data); + +/** + * @brief Selects a global gesture on given window. + * @since_tizen 4.0 + * @param[in] gesture_h The #efl_util_gesture_h handle + * @param[in] window The efl window + * @param[in] data The #efl_util_gesture_data handle. + * @return @c 0 on success, otherwise a negative error value + * @retval #EFL_UTIL_ERROR_NONE Successful + * @retval #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #EFL_UTIL_ERROR_OUT_OF_MEMORY Memory allocation failure + * @retval #EFL_UTIL_ERROR_NO_RESOURCE_AVAILABLE Resource is not available + */ +API int efl_util_gesture_select(efl_util_gesture_h gesture_h, Evas_Object *window, efl_util_gesture_data data); + +/** + * @brief Deselects a global gesture on given window. + * @since_tizen 4.0 + * @param[in] gesture_h The #efl_util_gesture_h handle + * @param[in] window The efl window + * @param[in] data The #efl_util_gesture_data handle + * @return @c 0 on success, otherwise a negative error value + * @retval #EFL_UTIL_ERROR_NONE Successful + * @retval #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #EFL_UTIL_ERROR_OUT_OF_MEMORY Memory allocation failure + * @retval #EFL_UTIL_ERROR_NO_RESOURCE_AVAILABLE Resource is not available + */ +API int efl_util_gesture_deselect(efl_util_gesture_h gesture_h, Evas_Object *window, efl_util_gesture_data data); + +/** + * @platform + * @brief Activates or deactivates a global gesture. + * @since_tizen 4.0 + * @privlevel platform + * @privilege %http://tizen.org/privilege/gestureactivation + * @param[in] gesture_h The #efl_util_gesture_h handle + * @param[in] type The gesture type to activate /deactivate combined by #efl_util_gesture_type_e to bitwise operation + * @param[in] active The activated boolean value + * @return @c 0 on success, otherwise a negative error value + * @retval #EFL_UTIL_ERROR_NONE Successful + * @retval #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #EFL_UTIL_ERROR_PERMISSION_DENIED Permission denied + * @retval #EFL_UTIL_ERROR_OUT_OF_MEMORY Memory allocation failure + * @retval #EFL_UTIL_ERROR_NO_RESOURCE_AVAILABLE Resource is not available + */ +API int efl_util_gesture_activate_set(efl_util_gesture_h gesture_h, unsigned int type, Eina_Bool active); + +/** + * @brief Activates or deactivates a global gesture on given window. + * @since_tizen 4.0 + * @param[in] gesture_h The #efl_util_gesture_h handle + * @param[in] window The efl window + * @param[in] type The gesture type to activate /deactivate combined by #efl_util_gesture_type_e to bitwise operation + * @param[in] active The activated boolean value + * @return @c 0 on success, otherwise a negative error value + * @retval #EFL_UTIL_ERROR_NONE Successful + * @retval #EFL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #EFL_UTIL_ERROR_OUT_OF_MEMORY Memory allocation failure + * @retval #EFL_UTIL_ERROR_NO_RESOURCE_AVAILABLE Resource is not available + */ +API int efl_util_gesture_activate_set_on_window(efl_util_gesture_h gesture_h, Evas_Object *window, unsigned int type, Eina_Bool active); + +/** + * @} + */ + #ifdef __cplusplus } #endif diff --git a/src/efl_util.c b/src/efl_util.c index 0e0ca0c..248578b 100644 --- a/src/efl_util.c +++ b/src/efl_util.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2011-2017 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. @@ -139,6 +139,46 @@ typedef struct _Efl_Util_Wl_Output_Info int offset_x, offset_y, width, height; } Efl_Util_Wl_Output_Info; +typedef struct _Efl_Util_Gesture_Common_Grab_Data +{ + int type; +} Efl_Util_Gesture_Common_Grab_Data; + +typedef struct _Efl_Util_Gesture_Edge_Swipe_Grab_Data +{ + Efl_Util_Gesture_Common_Grab_Data base; + + unsigned int fingers; + efl_util_gesture_edge_e edge; + efl_util_gesture_edge_size_e edge_size; + unsigned int start_point; + unsigned int end_point; +} Efl_Util_Gesture_Edge_Swipe_Grab_Data; + +typedef struct _Efl_Util_Gesture_Edge_Drag_Grab_Data +{ + Efl_Util_Gesture_Common_Grab_Data base; + + unsigned int fingers; + efl_util_gesture_edge_e edge; + efl_util_gesture_edge_size_e edge_size; + unsigned int start_point; + unsigned int end_point; +} Efl_Util_Gesture_Edge_Drag_Grab_Data; + +typedef struct _Efl_Util_Gesture_Tap_Grab_Data +{ + Efl_Util_Gesture_Common_Grab_Data base; + + unsigned int fingers; + unsigned int repeats; +} Efl_Util_Gesture_Tap_Grab_Data; + +typedef struct _Efl_Util_Gesture_Palm_Cover_Grab_Data +{ + Efl_Util_Gesture_Common_Grab_Data base; +} Efl_Util_Gesture_Palm_Cover_Grab_Data; + typedef struct _Efl_Util_Data { /* wayland related stuffs */ @@ -173,6 +213,12 @@ typedef struct _Efl_Util_Data struct tizen_display_policy *proto; Eina_Hash *hash_brightness; } display_policy; + struct + { + struct tizen_gesture *proto; + int request_notified; + int event_init; + } gesture; } wl; struct @@ -190,7 +236,8 @@ static Efl_Util_Data _eflutil = { NULL, NULL, NULL }, /* tizen_policy protocol */ { NULL, NULL, NULL, NULL, NULL, 0 }, /* screenshooter protocol */ { NULL, -1 }, /* tizen_input_device_manager protocol */ - { NULL, NULL } /* display_policy protocol */ + { NULL, NULL }, /* display_policy protocol */ + { NULL, -1, EINA_FALSE } /* tizen_gesture protocol */ }, { { NULL, 0 }, /* handler for notification level */ @@ -225,6 +272,17 @@ static void _cb_device_remove(void *data EINA_UNUSED, struct static void _cb_error(void *data EINA_UNUSED, struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED, uint32_t errorcode); static void _cb_block_expired(void *data EINA_UNUSED, struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED); +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); +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); +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); +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); +static void _cb_gesture_tap_notify(void *data EINA_UNUSED, struct tizen_gesture *tizen_gesture EINA_UNUSED, uint32_t fingers EINA_UNUSED, uint32_t repeats EINA_UNUSED, uint32_t 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); +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); +static void _cb_gesture_palm_cover(void *data EINA_UNUSED, struct tizen_gesture *tizen_gesture EINA_UNUSED, struct wl_surface *surface EINA_UNUSED, uint32_t mode, uint32_t duration, int cx, int cy, uint32_t size, wl_fixed_t pressure); +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); + + static const struct wl_registry_listener _wl_reg_listener = { _cb_wl_reg_global, @@ -263,6 +321,19 @@ struct tizen_display_policy_listener _wl_tz_display_policy_listener = _cb_wl_tz_display_policy_brightness_done, }; +struct tizen_gesture_listener _wl_tz_gesture_listener = +{ + _cb_gesture_edge_swipe_notify, + _cb_gesture_edge_swipe, + _cb_gesture_edge_drag_notify, + _cb_gesture_edge_drag, + _cb_gesture_tap_notify, + _cb_gesture_tap, + _cb_gesture_palm_cover_notify, + _cb_gesture_palm_cover, + _cb_gesture_activate_notify +}; + static Eina_Bool _cb_info_add(Evas_Object *win, Efl_Util_Cb cb, @@ -501,7 +572,11 @@ _cb_wl_reg_global(void *data, _eflutil.wl.display_policy.hash_brightness = eina_hash_pointer_new(free); } - + else if (strcmp(interface, "tizen_gesture") == 0) + { + _eflutil.wl.gesture.proto = wl_registry_bind(reg, name, &tizen_gesture_interface, version); + tizen_gesture_add_listener(_eflutil.wl.gesture.proto, &_wl_tz_gesture_listener, NULL); + } } /* LCOV_EXCL_START */ static void @@ -1902,3 +1977,900 @@ efl_util_screenshot_get_auto_rotation(efl_util_screenshot_h screenshot, int *set return EFL_UTIL_ERROR_NONE; } + +struct _efl_util_gesture_h +{ + Eina_Bool init; +}; + +API int EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = 0; +API int EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = 0; +API int EFL_UTIL_EVENT_GESTURE_TAP = 0; +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) +{ + _eflutil.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) +{ + efl_util_event_gesture_edge_swipe_s *ev = NULL; + + ev = (efl_util_event_gesture_edge_swipe_s *)calloc(1, sizeof(*ev)); + if (!ev) return; + + ev->mode = mode; + + ev->fingers = fingers; + ev->sx = sx; + ev->sy = sy; + ev->edge = edge; + + ecore_event_add(EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE, ev, NULL, NULL); +} + +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) +{ + _eflutil.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) +{ + efl_util_event_gesture_edge_drag_s *ev = NULL; + + ev = (efl_util_event_gesture_edge_drag_s *)calloc(1, sizeof(*ev)); + if (!ev) return; + + ev->mode = mode; + + ev->fingers = fingers; + ev->cx = cx; + ev->cy = cy; + ev->edge = edge; + + ecore_event_add(EFL_UTIL_EVENT_GESTURE_EDGE_DRAG, ev, NULL, NULL); +} + +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) +{ + _eflutil.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) +{ + efl_util_event_gesture_tap_s *ev = NULL; + + ev = (efl_util_event_gesture_tap_s *)calloc(1, sizeof(*ev)); + if (!ev) return; + + ev->mode = mode; + + ev->fingers = fingers; + ev->repeats = repeats; + + ecore_event_add(EFL_UTIL_EVENT_GESTURE_TAP, ev, NULL, NULL); +} + +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) +{ + _eflutil.wl.gesture.request_notified = error; +} + +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) +{ + efl_util_event_gesture_palm_cover_s *ev = NULL; + + ev = (efl_util_event_gesture_palm_cover_s *)calloc(1, sizeof(*ev)); + if (!ev) return; + + ev->mode = mode; + + ev->duration = duration; + ev->cx = cx; + ev->cy = cy; + ev->size = size; + ev->pressure = wl_fixed_to_int(pressure); + + ecore_event_add(EFL_UTIL_EVENT_GESTURE_PALM_COVER, ev, NULL, NULL); +} + +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) +{ + _eflutil.wl.gesture.request_notified = error; +} + +static efl_util_error_e +_efl_util_gesture_convert_error(int ret) +{ + switch (ret) + { + case TIZEN_GESTURE_ERROR_NONE: + return EFL_UTIL_ERROR_NONE; + case TIZEN_GESTURE_ERROR_INVALID_DATA: + return EFL_UTIL_ERROR_INVALID_PARAMETER; + case TIZEN_GESTURE_ERROR_NO_PERMISSION: + return EFL_UTIL_ERROR_PERMISSION_DENIED; + case TIZEN_GESTURE_ERROR_NO_SYSTEM_RESOURCES: + return EFL_UTIL_ERROR_OUT_OF_MEMORY; + case TIZEN_GESTURE_ERROR_GRABBED_ALREADY: + return EFL_UTIL_ERROR_NO_RESOURCE_AVAILABLE; + case TIZEN_GESTURE_ERROR_NOT_SUPPORTED: + return EFL_UTIL_ERROR_NOT_SUPPORTED; + default : + return EFL_UTIL_ERROR_NONE; + } +} + +static int +_efl_util_gesture_grab_edge_swipe(efl_util_gesture_data data) +{ + 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; + unsigned int fingers = 0; + unsigned int edge = 0; + unsigned int edge_size = 0; + unsigned int start_point = 0; + unsigned int end_point = 0; + + base_data = (Efl_Util_Gesture_Common_Grab_Data *)data; + + EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, 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); + + edge_swipe_data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)data; + + fingers = edge_swipe_data->fingers; + edge = edge_swipe_data->edge; + edge_size = edge_swipe_data->edge_size; + start_point = edge_swipe_data->start_point; + end_point = edge_swipe_data->end_point; + + tizen_gesture_grab_edge_swipe(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point); + + while (_eflutil.wl.gesture.request_notified == -1) + wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue); + + ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified); + _eflutil.wl.gesture.request_notified = -1; + + return ret; +} + +static int +_efl_util_gesture_ungrab_edge_swipe(efl_util_gesture_data data) +{ + 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; + unsigned int fingers = 0; + unsigned int edge = 0; + unsigned int edge_size = 0; + unsigned int start_point = 0; + unsigned int end_point = 0; + + base_data = (Efl_Util_Gesture_Common_Grab_Data *)data; + + EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, 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); + + edge_swipe_data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)data; + + fingers = edge_swipe_data->fingers; + edge = edge_swipe_data->edge; + edge_size = edge_swipe_data->edge_size; + start_point = edge_swipe_data->start_point; + end_point = edge_swipe_data->end_point; + + tizen_gesture_ungrab_edge_swipe(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point); + + while (_eflutil.wl.gesture.request_notified == -1) + wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue); + + ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified); + _eflutil.wl.gesture.request_notified = -1; + + return ret; +} + +static int +_efl_util_gesture_grab_edge_drag(efl_util_gesture_data data) +{ + 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; + unsigned int fingers = 0; + unsigned int edge = 0; + unsigned int edge_size = 0; + unsigned int start_point = 0; + unsigned int end_point = 0; + + base_data = (Efl_Util_Gesture_Common_Grab_Data *)data; + + EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, 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); + + edge_drag_data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)data; + + fingers = edge_drag_data->fingers; + edge = edge_drag_data->edge; + edge_size = edge_drag_data->edge_size; + start_point = edge_drag_data->start_point; + end_point = edge_drag_data->end_point; + + tizen_gesture_grab_edge_drag(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point); + + while (_eflutil.wl.gesture.request_notified == -1) + wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue); + + ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified); + _eflutil.wl.gesture.request_notified = -1; + + return ret; +} + +static int +_efl_util_gesture_ungrab_edge_drag(efl_util_gesture_data data) +{ + 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; + unsigned int fingers = 0; + unsigned int edge = 0; + unsigned int edge_size = 0; + unsigned int start_point = 0; + unsigned int end_point = 0; + + base_data = (Efl_Util_Gesture_Common_Grab_Data *)data; + + EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, 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); + + edge_drag_data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)data; + + fingers = edge_drag_data->fingers; + edge = edge_drag_data->edge; + edge_size = edge_drag_data->edge_size; + start_point = edge_drag_data->start_point; + end_point = edge_drag_data->end_point; + + tizen_gesture_ungrab_edge_drag(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point); + + while (_eflutil.wl.gesture.request_notified == -1) + wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue); + + ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified); + _eflutil.wl.gesture.request_notified = -1; + + return ret; +} + + +static int +_efl_util_gesture_grab_tap(efl_util_gesture_data data) +{ + int ret = EFL_UTIL_ERROR_NONE; + Efl_Util_Gesture_Common_Grab_Data *base_data = NULL; + Efl_Util_Gesture_Tap_Grab_Data *tap_data = NULL; + unsigned int fingers = 0; + unsigned int repeats = 0; + + base_data = (Efl_Util_Gesture_Common_Grab_Data *)data; + + EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, 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); + + tap_data = (Efl_Util_Gesture_Tap_Grab_Data *)data; + + fingers = tap_data->fingers; + repeats = tap_data->repeats; + + tizen_gesture_grab_tap(_eflutil.wl.gesture.proto, fingers, repeats); + + while (_eflutil.wl.gesture.request_notified == -1) + wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue); + + ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified); + _eflutil.wl.gesture.request_notified = -1; + + return ret; +} + +static int +_efl_util_gesture_ungrab_tap(efl_util_gesture_data data) +{ + int ret = EFL_UTIL_ERROR_NONE; + Efl_Util_Gesture_Common_Grab_Data *base_data = NULL; + Efl_Util_Gesture_Tap_Grab_Data *tap_data = NULL; + unsigned int fingers = 0; + unsigned int repeats = 0; + + base_data = (Efl_Util_Gesture_Common_Grab_Data *)data; + + EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, 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); + + tap_data = (Efl_Util_Gesture_Tap_Grab_Data *)data; + + fingers = tap_data->fingers; + repeats = tap_data->repeats; + + tizen_gesture_ungrab_tap(_eflutil.wl.gesture.proto, fingers, repeats); + + while (_eflutil.wl.gesture.request_notified == -1) + wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue); + + ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified); + _eflutil.wl.gesture.request_notified = -1; + + return ret; +} + +static int +_efl_util_gesture_grab_palm_cover(efl_util_gesture_data data) +{ + 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(_eflutil.wl.gesture.proto, 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); + + tizen_gesture_grab_palm_cover(_eflutil.wl.gesture.proto); + + while (_eflutil.wl.gesture.request_notified == -1) + wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue); + + ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified); + _eflutil.wl.gesture.request_notified = -1; + + return ret; +} + +static int +_efl_util_gesture_ungrab_palm_cover(efl_util_gesture_data data) +{ + 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(_eflutil.wl.gesture.proto, 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); + + tizen_gesture_ungrab_palm_cover(_eflutil.wl.gesture.proto); + + while (_eflutil.wl.gesture.request_notified == -1) + wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue); + + ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified); + _eflutil.wl.gesture.request_notified = -1; + + return ret; +} + +API efl_util_gesture_h +efl_util_gesture_initialize(void) +{ + efl_util_gesture_h gesture_h = NULL; + + gesture_h = (efl_util_gesture_h)calloc(1, sizeof(struct _efl_util_gesture_h)); + if (!gesture_h) + { + set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); + goto out; + } + + if (_wl_init() == (int)EINA_FALSE) + { + set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED); + goto out; + } + + while (!_eflutil.wl.gesture.proto) + wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue); + + if (_eflutil.wl.gesture.event_init <= 0) + { + if (ecore_event_init() <= 0) + { + set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED); + goto out; + } + EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = ecore_event_type_new(); + EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = ecore_event_type_new(); + EFL_UTIL_EVENT_GESTURE_TAP = ecore_event_type_new(); + EFL_UTIL_EVENT_GESTURE_PALM_COVER = ecore_event_type_new(); + } + _eflutil.wl.gesture.event_init++; + + set_last_result(EFL_UTIL_ERROR_NONE); + return gesture_h; + +out: + if (gesture_h) + { + free(gesture_h); + gesture_h = NULL; + } + return gesture_h; +} + +API int +efl_util_gesture_deinitialize(efl_util_gesture_h gesture_h) +{ + 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); + + free(gesture_h); + gesture_h = NULL; + + _eflutil.wl.gesture.event_init--; + + if (_eflutil.wl.gesture.event_init <= 0) + { + _eflutil.wl.gesture.event_init = 0; + ecore_event_shutdown(); + EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = 0; + EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = 0; + EFL_UTIL_EVENT_GESTURE_TAP = 0; + EFL_UTIL_EVENT_GESTURE_PALM_COVER = 0; + } + + return EFL_UTIL_ERROR_NONE; +} + +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) +{ + Efl_Util_Gesture_Edge_Swipe_Grab_Data *data; + + if (!gesture_h || gesture_h->init == EINA_FALSE) + { + set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER); + return NULL; + } + + if (edge <= EFL_UTIL_GESTURE_EDGE_NONE || edge > EFL_UTIL_GESTURE_EDGE_LEFT) + { + set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER); + return NULL; + } + + data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Edge_Swipe_Grab_Data)); + if (!data) + { + set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); + return NULL; + } + + data->base.type = TIZEN_GESTURE_TYPE_EDGE_SWIPE; + data->fingers = fingers; + data->edge = edge; + data->edge_size = EFL_UTIL_GESTURE_EDGE_SIZE_FULL; + + set_last_result(EFL_UTIL_ERROR_NONE); + + return (void *)data; +} + +API int +efl_util_gesture_edge_swipe_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data) +{ + if (!gesture_h || gesture_h->init == EINA_FALSE) + { + return EFL_UTIL_ERROR_INVALID_PARAMETER; + } + + if (!data) + { + return EFL_UTIL_ERROR_INVALID_PARAMETER; + } + + free(data); + data = NULL; + + return EFL_UTIL_ERROR_NONE; +} + +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) +{ + 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); + EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_swipe_data->base.type == TIZEN_GESTURE_TYPE_EDGE_SWIPE, + EFL_UTIL_ERROR_INVALID_PARAMETER); + EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_size == EFL_UTIL_GESTURE_EDGE_SIZE_PARTIAL, + EFL_UTIL_ERROR_INVALID_PARAMETER); + EINA_SAFETY_ON_FALSE_RETURN_VAL(end_point > start_point, EFL_UTIL_ERROR_INVALID_PARAMETER); + + edge_swipe_data->edge_size = edge_size; + edge_swipe_data->start_point = start_point; + edge_swipe_data->end_point = end_point; + + return EFL_UTIL_ERROR_NONE; +} + +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) +{ + Efl_Util_Gesture_Edge_Drag_Grab_Data *data; + + if (!gesture_h || gesture_h->init == EINA_FALSE) + { + set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER); + return NULL; + } + + if (edge <= EFL_UTIL_GESTURE_EDGE_NONE || edge > EFL_UTIL_GESTURE_EDGE_LEFT) + { + set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER); + return NULL; + } + + data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Edge_Drag_Grab_Data)); + if (!data) + { + set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); + return NULL; + } + + data->base.type = TIZEN_GESTURE_TYPE_EDGE_DRAG; + data->fingers = fingers; + data->edge = edge; + data->edge_size = EFL_UTIL_GESTURE_EDGE_SIZE_FULL; + + set_last_result(EFL_UTIL_ERROR_NONE); + + return (void *)data; +} + +API int +efl_util_gesture_edge_drag_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data) +{ + if (!gesture_h || gesture_h->init == EINA_FALSE) + { + return EFL_UTIL_ERROR_INVALID_PARAMETER; + } + + if (!data) + { + return EFL_UTIL_ERROR_INVALID_PARAMETER; + } + + free(data); + data = NULL; + + return EFL_UTIL_ERROR_NONE; +} + +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) +{ + 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); + EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_drag_data->base.type == TIZEN_GESTURE_TYPE_EDGE_DRAG, + EFL_UTIL_ERROR_INVALID_PARAMETER); + EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_size == EFL_UTIL_GESTURE_EDGE_SIZE_PARTIAL, + EFL_UTIL_ERROR_INVALID_PARAMETER); + EINA_SAFETY_ON_FALSE_RETURN_VAL(end_point > start_point, EFL_UTIL_ERROR_INVALID_PARAMETER); + + edge_drag_data->edge_size = edge_size; + edge_drag_data->start_point = start_point; + edge_drag_data->end_point = end_point; + + return EFL_UTIL_ERROR_NONE; +} + +API efl_util_gesture_data +efl_util_gesture_tap_new(efl_util_gesture_h gesture_h, unsigned int fingers, unsigned int repeats) +{ + Efl_Util_Gesture_Tap_Grab_Data *data; + + if (!gesture_h || gesture_h->init == EINA_FALSE) + { + set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER); + return NULL; + } + + if (fingers <= 1 || repeats <= 1) + { + set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED); + return NULL; + } + + data = (Efl_Util_Gesture_Tap_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Tap_Grab_Data)); + if (!data) + { + set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); + return NULL; + } + + data->base.type = TIZEN_GESTURE_TYPE_TAP; + data->fingers = fingers; + data->repeats = repeats; + + set_last_result(EFL_UTIL_ERROR_NONE); + + return (void *)data; +} + +API int +efl_util_gesture_tap_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data) +{ + if (!gesture_h || gesture_h->init == EINA_FALSE) + { + return EFL_UTIL_ERROR_INVALID_PARAMETER; + } + + if (!data) + { + return EFL_UTIL_ERROR_INVALID_PARAMETER; + } + + free(data); + data = NULL; + + return EFL_UTIL_ERROR_NONE; +} + +API efl_util_gesture_data +efl_util_gesture_palm_cover_new(efl_util_gesture_h gesture_h) +{ + Efl_Util_Gesture_Palm_Cover_Grab_Data *data; + + if (!gesture_h || gesture_h->init == EINA_FALSE) + { + set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER); + return NULL; + } + + data = (Efl_Util_Gesture_Palm_Cover_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Palm_Cover_Grab_Data)); + if (!data) + { + set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); + return NULL; + } + + data->base.type = TIZEN_GESTURE_TYPE_PALM_COVER; + + set_last_result(EFL_UTIL_ERROR_NONE); + + return (void *)data; +} + +API int +efl_util_gesture_palm_cover_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data) +{ + if (!gesture_h || gesture_h->init == EINA_FALSE) + { + return EFL_UTIL_ERROR_INVALID_PARAMETER; + } + + if (!data) + { + return EFL_UTIL_ERROR_INVALID_PARAMETER; + } + + free(data); + data = NULL; + + return EFL_UTIL_ERROR_NONE; +} + +API int +efl_util_gesture_grab(efl_util_gesture_h gesture_h, efl_util_gesture_data data) +{ + 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); + + switch (base_data->type) + { + case TIZEN_GESTURE_TYPE_EDGE_SWIPE: + ret = _efl_util_gesture_grab_edge_swipe(data); + break; + case TIZEN_GESTURE_TYPE_EDGE_DRAG: + ret = _efl_util_gesture_grab_edge_drag(data); + break; + case TIZEN_GESTURE_TYPE_TAP: + ret = _efl_util_gesture_grab_tap(data); + break; + case TIZEN_GESTURE_TYPE_PALM_COVER: + ret = _efl_util_gesture_grab_palm_cover(data); + break; + default: + return EFL_UTIL_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +API int +efl_util_gesture_ungrab(efl_util_gesture_h gesture_h, efl_util_gesture_data data) +{ + 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); + + switch (base_data->type) + { + case TIZEN_GESTURE_TYPE_EDGE_SWIPE: + ret = _efl_util_gesture_ungrab_edge_swipe(data); + break; + case TIZEN_GESTURE_TYPE_EDGE_DRAG: + ret = _efl_util_gesture_ungrab_edge_drag(data); + break; + case TIZEN_GESTURE_TYPE_TAP: + ret = _efl_util_gesture_ungrab_tap(data); + break; + case TIZEN_GESTURE_TYPE_PALM_COVER: + ret = _efl_util_gesture_ungrab_palm_cover(data); + break; + default: + return EFL_UTIL_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +API int +efl_util_gesture_select(efl_util_gesture_h gesture_h, Evas_Object *window, efl_util_gesture_data data) +{ + Efl_Util_Gesture_Common_Grab_Data *base_data = NULL; + Ecore_Wl_Window *wlwin; + struct wl_surface *surface; + int ret; + + 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(window, EFL_UTIL_ERROR_INVALID_PARAMETER); + EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER); + + if (base_data->type != TIZEN_GESTURE_TYPE_PALM_COVER) + return EFL_UTIL_ERROR_NOT_SUPPORTED; + + wlwin = elm_win_wl_window_get(window); + if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER; + + surface = ecore_wl_window_surface_get(wlwin); + EINA_SAFETY_ON_NULL_RETURN_VAL(surface, + EFL_UTIL_ERROR_INVALID_PARAMETER); + + tizen_gesture_select_palm_cover(_eflutil.wl.gesture.proto, surface); + + while (_eflutil.wl.gesture.request_notified == -1) + wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue); + + ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified); + _eflutil.wl.gesture.request_notified = -1; + + return ret; +} + +API int +efl_util_gesture_deselect(efl_util_gesture_h gesture_h, Evas_Object *window, efl_util_gesture_data data) +{ + Efl_Util_Gesture_Common_Grab_Data *base_data = NULL; + Ecore_Wl_Window *wlwin; + struct wl_surface *surface; + int ret; + + 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(window, EFL_UTIL_ERROR_INVALID_PARAMETER); + EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER); + + if (base_data->type != TIZEN_GESTURE_TYPE_PALM_COVER) + return EFL_UTIL_ERROR_NOT_SUPPORTED; + + wlwin = elm_win_wl_window_get(window); + if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER; + + surface = ecore_wl_window_surface_get(wlwin); + EINA_SAFETY_ON_NULL_RETURN_VAL(surface, + EFL_UTIL_ERROR_INVALID_PARAMETER); + + tizen_gesture_deselect_palm_cover(_eflutil.wl.gesture.proto, surface); + + while (_eflutil.wl.gesture.request_notified == -1) + wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue); + + ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified); + _eflutil.wl.gesture.request_notified = -1; + + return ret; +} + +API int +efl_util_gesture_activate_set(efl_util_gesture_h gesture_h, unsigned int type, Eina_Bool active) +{ + int ret; + + 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_TRUE_RETURN_VAL(type == EFL_UTIL_GESTURE_TYPE_NONE, EFL_UTIL_ERROR_INVALID_PARAMETER); + + tizen_gesture_activate_set(_eflutil.wl.gesture.proto, NULL, type, active); + + while (_eflutil.wl.gesture.request_notified == -1) + wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue); + + ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified); + _eflutil.wl.gesture.request_notified = -1; + + return ret; +} + +API int +efl_util_gesture_activate_set_on_window(efl_util_gesture_h gesture_h, Evas_Object *window, unsigned int type, Eina_Bool active) +{ + Ecore_Wl_Window *wlwin; + struct wl_surface *surface; + int ret; + + 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(window, EFL_UTIL_ERROR_INVALID_PARAMETER); + EINA_SAFETY_ON_TRUE_RETURN_VAL(type == EFL_UTIL_GESTURE_TYPE_NONE, EFL_UTIL_ERROR_INVALID_PARAMETER); + + wlwin = elm_win_wl_window_get(window); + if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER; + + surface = ecore_wl_window_surface_get(wlwin); + EINA_SAFETY_ON_NULL_RETURN_VAL(surface, + EFL_UTIL_ERROR_INVALID_PARAMETER); + + tizen_gesture_activate_set(_eflutil.wl.gesture.proto, surface, type, active); + + while (_eflutil.wl.gesture.request_notified == -1) + wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue); + + ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified); + _eflutil.wl.gesture.request_notified = -1; + + return ret; +}