2 * Copyright (c) 2011-2017 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #define LOG_TAG "TIZEN_N_EFL_UTIL"
24 #include <sys/types.h>
28 #include <tbm_bufmgr.h>
29 #include <tbm_surface.h>
30 #include <tbm_surface_internal.h>
31 #include <Elementary.h>
32 #include <Ecore_Evas.h>
35 #include <Ecore_Wl2.h>
36 #include <wayland-client.h>
37 #include <wayland-tbm-client.h>
38 #include <tizen-extension-client-protocol.h>
39 #include <screenshooter-client-protocol.h>
41 #include <efl_util_screenshot_extension.h>
48 /* Determine Tizen profile at runtime */
49 #include <system_info.h>
51 TIZEN_PROFILE_UNKNOWN = 0,
52 TIZEN_PROFILE_MOBILE = 0x1,
53 TIZEN_PROFILE_WEARABLE = 0x2,
54 TIZEN_PROFILE_TV = 0x4,
55 TIZEN_PROFILE_IVI = 0x8,
56 TIZEN_PROFILE_COMMON = 0x10,
58 static tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN;
59 static tizen_profile_t _get_tizen_profile()
62 system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
63 switch (*profileName) {
66 profile = TIZEN_PROFILE_MOBILE;
70 profile = TIZEN_PROFILE_WEARABLE;
74 profile = TIZEN_PROFILE_TV;
78 profile = TIZEN_PROFILE_IVI;
80 default: // common or unknown ==> ALL ARE COMMON.
81 profile = TIZEN_PROFILE_COMMON;
87 static inline tizen_profile_t get_tizen_profile()
89 if (__builtin_expect(profile != TIZEN_PROFILE_UNKNOWN, 1))
91 return _get_tizen_profile();
95 #define LOG_TAG "TIZEN_N_EFL_UTIL"
97 typedef struct _Efl_Util_Wl_Surface_Lv_Info
99 void *surface; /* wl_surface */
101 Eina_Bool wait_for_done;
103 } Efl_Util_Wl_Surface_Lv_Info;
105 typedef struct _Efl_Util_Wl_Surface_Scr_Mode_Info
107 void *surface; /* wl_surface */
109 Eina_Bool wait_for_done;
111 } Efl_Util_Wl_Surface_Scr_Mode_Info;
113 typedef struct _Efl_Util_Wl_Surface_Brightness_Info
115 void *surface; /* wl_surface */
117 Eina_Bool wait_for_done;
119 } Efl_Util_Wl_Surface_Brightness_Info;
121 typedef struct _Efl_Util_Wl_Output_Info
123 struct wl_output *output;
124 int offset_x, offset_y, width, height;
125 } Efl_Util_Wl_Output_Info;
127 typedef struct _Efl_Util_Gesture_Common_Grab_Data
130 } Efl_Util_Gesture_Common_Grab_Data;
132 typedef struct _Efl_Util_Gesture_Edge_Swipe_Grab_Data
134 Efl_Util_Gesture_Common_Grab_Data base;
136 unsigned int fingers;
137 efl_util_gesture_edge_e edge;
138 efl_util_gesture_edge_size_e edge_size;
139 unsigned int start_point;
140 unsigned int end_point;
141 } Efl_Util_Gesture_Edge_Swipe_Grab_Data;
143 typedef struct _Efl_Util_Gesture_Edge_Drag_Grab_Data
145 Efl_Util_Gesture_Common_Grab_Data base;
147 unsigned int fingers;
148 efl_util_gesture_edge_e edge;
149 efl_util_gesture_edge_size_e edge_size;
150 unsigned int start_point;
151 unsigned int end_point;
152 } Efl_Util_Gesture_Edge_Drag_Grab_Data;
154 typedef struct _Efl_Util_Gesture_Tap_Grab_Data
156 Efl_Util_Gesture_Common_Grab_Data base;
158 unsigned int fingers;
159 unsigned int repeats;
160 } Efl_Util_Gesture_Tap_Grab_Data;
162 typedef struct _Efl_Util_Gesture_Palm_Cover_Grab_Data
164 Efl_Util_Gesture_Common_Grab_Data base;
165 } Efl_Util_Gesture_Palm_Cover_Grab_Data;
167 typedef struct _Efl_Util_Data
169 /* wayland related stuffs */
173 Ecore_Wl2_Display *wl2_display;
174 struct wl_display *dpy;
175 struct wl_event_queue *queue;
177 Ecore_Fd_Handler *fd_hdl;
182 struct tizen_policy *proto;
183 Eina_Hash *hash_noti_lv;
184 Eina_Hash *hash_scr_mode;
188 struct wl_event_queue *queue;
189 struct screenshooter *screenshooter;
190 struct tizen_screenshooter *tz_screenshooter;
191 struct wayland_tbm_client *tbm_client;
192 Eina_List *output_list;
197 struct tizen_input_device_manager *devicemgr;
198 int request_notified;
203 struct tizen_display_policy *proto;
204 Eina_Hash *hash_brightness;
208 struct tizen_gesture *proto;
209 int request_notified;
215 static Efl_Util_Data _eflutil =
221 { 0, NULL, NULL, NULL }, /* tizen_policy protocol */
222 { NULL, NULL, NULL, NULL, NULL, 0 }, /* screenshooter protocol */
223 { NULL, -1 }, /* tizen_input_device_manager protocol */
224 { 0, NULL, NULL }, /* display_policy protocol */
225 { NULL, -1, EINA_FALSE } /* tizen_gesture protocol */
229 static Eina_Bool _wl_init(void);
230 static void _cb_wl_reg_global(void *data, struct wl_registry *reg, unsigned int name, const char *interface, unsigned int version);
231 static void _cb_wl_reg_global_remove(void *data, struct wl_registry *reg, unsigned int name);
232 static void _cb_wl_reg_screenshooter_global(void *data, struct wl_registry *reg, unsigned int name, const char *interface, unsigned int version);
233 static void _cb_wl_reg_screenshooter_global_remove(void *data, struct wl_registry *reg, unsigned int name);
234 static void _cb_wl_tz_policy_conformant(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface, uint32_t is_conformant);
235 static void _cb_wl_tz_policy_conformant_area(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface, uint32_t conformant_part, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h);
236 static void _cb_wl_tz_policy_notification_done(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface, int32_t level, uint32_t state);
237 static void _cb_wl_tz_policy_transient_for_done(void *data, struct tizen_policy *tizen_policy, uint32_t child_id);
238 static void _cb_wl_tz_policy_scr_mode_done(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface, uint32_t mode, uint32_t state);
239 static void _cb_wl_tz_policy_iconify_state_changed(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface_resource, uint32_t iconified, uint32_t force);
240 static void _cb_wl_tz_policy_supported_aux_hints(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface_resource, struct wl_array *hints, uint32_t num_hints);
241 static void _cb_wl_tz_policy_allowed_aux_hint(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface_resource, int id);
242 static void _cb_wl_tz_policy_aux_message(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface_resource, const char *key, const char *val, struct wl_array *options);
243 static void _cb_wl_conformant_region(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface, uint32_t conformant_part, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t serial);
245 static void _cb_wl_tz_display_policy_brightness_done(void *data, struct tizen_display_policy *tizen_display_policy, struct wl_surface *surface_resource, int32_t brightness, uint32_t state);
247 static void _cb_device_add(void *data EINA_UNUSED, struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED, uint32_t serial EINA_UNUSED, const char *identifier EINA_UNUSED, struct tizen_input_device *device EINA_UNUSED, struct wl_seat *seat EINA_UNUSED);
248 static void _cb_device_remove(void *data EINA_UNUSED, struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED, uint32_t serial EINA_UNUSED, const char *identifier EINA_UNUSED, struct tizen_input_device *device EINA_UNUSED, struct wl_seat *seat EINA_UNUSED);
249 static void _cb_error(void *data EINA_UNUSED, struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED, uint32_t errorcode);
250 static void _cb_block_expired(void *data EINA_UNUSED, struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED);
252 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);
253 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);
254 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);
255 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);
256 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);
257 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);
258 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);
259 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);
260 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);
263 static const struct wl_registry_listener _wl_reg_listener =
266 _cb_wl_reg_global_remove
269 static const struct wl_registry_listener _wl_reg_screenshooter_listener =
271 _cb_wl_reg_screenshooter_global,
272 _cb_wl_reg_screenshooter_global_remove
275 struct tizen_policy_listener _wl_tz_policy_listener =
277 _cb_wl_tz_policy_conformant,
278 _cb_wl_tz_policy_conformant_area,
279 _cb_wl_tz_policy_notification_done,
280 _cb_wl_tz_policy_transient_for_done,
281 _cb_wl_tz_policy_scr_mode_done,
282 _cb_wl_tz_policy_iconify_state_changed,
283 _cb_wl_tz_policy_supported_aux_hints,
284 _cb_wl_tz_policy_allowed_aux_hint,
285 _cb_wl_tz_policy_aux_message,
286 _cb_wl_conformant_region,
289 struct tizen_input_device_manager_listener _wl_tz_devmgr_listener =
297 struct tizen_display_policy_listener _wl_tz_display_policy_listener =
299 _cb_wl_tz_display_policy_brightness_done,
302 struct tizen_gesture_listener _wl_tz_gesture_listener =
304 _cb_gesture_edge_swipe_notify,
305 _cb_gesture_edge_swipe,
306 _cb_gesture_edge_drag_notify,
307 _cb_gesture_edge_drag,
308 _cb_gesture_tap_notify,
310 _cb_gesture_palm_cover_notify,
311 _cb_gesture_palm_cover,
312 _cb_gesture_activate_notify
318 struct wl_display *display_wrapper = NULL;
319 struct wl_registry *reg = NULL;
321 if (_eflutil.wl.init) return EINA_TRUE;
325 _eflutil.wl.wl2_display = ecore_wl2_display_connect(NULL);
326 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.wl2_display, fail);
327 _eflutil.wl.dpy = ecore_wl2_display_get(_eflutil.wl.wl2_display);
328 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.dpy, fail);
330 display_wrapper = wl_proxy_create_wrapper(_eflutil.wl.dpy);
331 EINA_SAFETY_ON_NULL_GOTO(display_wrapper, fail);
333 _eflutil.wl.queue = wl_display_create_queue(_eflutil.wl.dpy);
334 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.queue, fail);
336 wl_proxy_set_queue((struct wl_proxy *)display_wrapper, _eflutil.wl.queue);
338 reg = wl_display_get_registry(display_wrapper);
339 wl_proxy_wrapper_destroy(display_wrapper);
340 display_wrapper = NULL;
341 EINA_SAFETY_ON_NULL_GOTO(reg, fail);
343 wl_registry_add_listener(reg, &_wl_reg_listener, NULL);
345 _eflutil.wl.init = EINA_TRUE;
350 wl_proxy_wrapper_destroy(display_wrapper);
352 if (_eflutil.wl.queue)
354 wl_event_queue_destroy(_eflutil.wl.queue);
355 _eflutil.wl.queue = NULL;
358 ecore_wl2_shutdown();
363 _cb_wl_output_geometry(void *data, struct wl_output *wl_output, int x, int y,
364 int physical_width, int physical_height, int subpixel,
365 const char *make, const char *model, int transform)
367 Efl_Util_Wl_Output_Info *output = wl_output_get_user_data(wl_output);
368 if (wl_output == output->output)
370 output->offset_x = x;
371 output->offset_y = y;
376 _cb_wl_output_mode(void *data, struct wl_output *wl_output, uint32_t flags,
377 int width, int height, int refresh)
379 Efl_Util_Wl_Output_Info *output = wl_output_get_user_data(wl_output);
380 if (wl_output == output->output && (flags & WL_OUTPUT_MODE_CURRENT))
382 output->width = width;
383 output->height = height;
388 _cb_wl_output_done(void *data, struct wl_output *wl_output)
393 _cb_wl_output_scale(void *data, struct wl_output *wl_output, int32_t factor)
397 static const struct wl_output_listener output_listener =
399 _cb_wl_output_geometry,
406 _cb_wl_screenshot_done(void *data, struct screenshooter *screenshooter)
408 Eina_Bool *shot_done = (Eina_Bool*)data;
410 *shot_done = EINA_TRUE;
413 static const struct screenshooter_listener screenshooter_listener =
415 _cb_wl_screenshot_done
419 _cb_tz_screenshot_format(void *data, struct tizen_screenshooter *tz_screenshooter, uint32_t format)
424 _cb_tz_screenshot_noti(void *data, struct tizen_screenshooter *tz_screenshooter, uint32_t noti)
426 _eflutil.wl.shot.noti = noti;
429 static const struct tizen_screenshooter_listener tz_screenshooter_listener =
431 _cb_tz_screenshot_format,
432 _cb_tz_screenshot_noti
436 _cb_wl_reg_global(void *data,
437 struct wl_registry *reg,
439 const char *interface,
440 unsigned int version)
442 if (!strcmp(interface, "tizen_policy"))
444 struct tizen_policy *proto;
445 proto = wl_registry_bind(reg,
447 &tizen_policy_interface,
451 tizen_policy_add_listener(proto,
452 &_wl_tz_policy_listener,
455 _eflutil.wl.policy.hash_noti_lv = eina_hash_pointer_new(free);
456 _eflutil.wl.policy.hash_scr_mode = eina_hash_pointer_new(free);
457 _eflutil.wl.policy.proto = proto;
458 _eflutil.wl.policy.id = id;
460 else if (strcmp(interface, "wl_output") == 0)
462 Efl_Util_Wl_Output_Info *output = calloc(1, sizeof(Efl_Util_Wl_Output_Info));
463 EINA_SAFETY_ON_NULL_RETURN(output);
465 _eflutil.wl.shot.output_list = eina_list_append(_eflutil.wl.shot.output_list, output);
467 output->output = wl_registry_bind(reg, id, &wl_output_interface, version);
468 wl_output_add_listener(output->output, &output_listener, output);
470 else if (strcmp(interface, "tizen_input_device_manager") == 0)
472 _eflutil.wl.devmgr.devicemgr = wl_registry_bind(reg, id, &tizen_input_device_manager_interface, version);
473 tizen_input_device_manager_add_listener(_eflutil.wl.devmgr.devicemgr, &_wl_tz_devmgr_listener, NULL);
475 else if (!strcmp(interface, "tizen_display_policy"))
477 _eflutil.wl.display_policy.proto = wl_registry_bind(reg, id, &tizen_display_policy_interface, version);
478 if (!_eflutil.wl.display_policy.proto) return;
480 tizen_display_policy_add_listener(_eflutil.wl.display_policy.proto,
481 &_wl_tz_display_policy_listener,
484 _eflutil.wl.display_policy.hash_brightness = eina_hash_pointer_new(free);
485 _eflutil.wl.display_policy.id = id;
487 else if (strcmp(interface, "tizen_gesture") == 0)
489 _eflutil.wl.gesture.proto = wl_registry_bind(reg, id, &tizen_gesture_interface, version);
490 tizen_gesture_add_listener(_eflutil.wl.gesture.proto, &_wl_tz_gesture_listener, NULL);
493 /* LCOV_EXCL_START */
495 _cb_wl_reg_global_remove(void *data,
496 struct wl_registry *reg,
499 /* unset each global id number to 0 since global id is started
500 * from number 1 on server side display structure
502 if (id == _eflutil.wl.policy.id)
504 _eflutil.wl.policy.id = 0;
505 _eflutil.wl.policy.proto = NULL;
506 eina_hash_free(_eflutil.wl.policy.hash_noti_lv);
507 eina_hash_free(_eflutil.wl.policy.hash_scr_mode);
509 else if (id == _eflutil.wl.display_policy.id)
511 _eflutil.wl.display_policy.id = 0;
512 _eflutil.wl.display_policy.proto = NULL;
513 eina_hash_free(_eflutil.wl.display_policy.hash_brightness);
519 _cb_wl_reg_screenshooter_global(void *data,
520 struct wl_registry *reg,
522 const char *interface,
523 unsigned int version)
525 if (strcmp(interface, "screenshooter") == 0)
527 _eflutil.wl.shot.screenshooter = wl_registry_bind(reg, name, &screenshooter_interface, version);
528 screenshooter_add_listener(_eflutil.wl.shot.screenshooter, &screenshooter_listener, NULL);
530 else if (strcmp(interface, "tizen_screenshooter") == 0)
532 _eflutil.wl.shot.tz_screenshooter = wl_registry_bind(reg, name, &tizen_screenshooter_interface, version);
533 tizen_screenshooter_add_listener(_eflutil.wl.shot.tz_screenshooter, &tz_screenshooter_listener, NULL);
535 wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
539 /* LCOV_EXCL_START */
541 _cb_wl_reg_screenshooter_global_remove(void *data,
542 struct wl_registry *reg,
548 _cb_wl_tz_policy_conformant(void *data, struct tizen_policy *tizen_policy,
549 struct wl_surface *surface, uint32_t is_conformant)
554 _cb_wl_tz_policy_conformant_area(void *data, struct tizen_policy *tizen_policy,
555 struct wl_surface *surface, uint32_t conformant_part,
556 uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h)
562 _cb_wl_tz_policy_notification_done(void *data,
563 struct tizen_policy *tizen_policy,
564 struct wl_surface *surface,
568 Efl_Util_Wl_Surface_Lv_Info *lv_info;
570 lv_info = eina_hash_find(_eflutil.wl.policy.hash_noti_lv, &surface);
573 lv_info->level = level;
574 lv_info->wait_for_done = EINA_FALSE;
575 lv_info->state = state;
579 /* LCOV_EXCL_START */
581 _cb_wl_tz_policy_transient_for_done(void *data, struct tizen_policy *tizen_policy, uint32_t child_id)
587 _cb_wl_tz_policy_scr_mode_done(void *data,
588 struct tizen_policy *tizen_policy,
589 struct wl_surface *surface,
593 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
595 scr_mode_info = eina_hash_find(_eflutil.wl.policy.hash_scr_mode, &surface);
598 scr_mode_info->mode = mode;
599 scr_mode_info->wait_for_done = EINA_FALSE;
600 scr_mode_info->state = state;
604 /* LCOV_EXCL_START */
605 static void _cb_wl_tz_policy_iconify_state_changed(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface_resource, uint32_t iconified, uint32_t force)
609 static void _cb_wl_tz_policy_supported_aux_hints(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface_resource, struct wl_array *hints, uint32_t num_hints)
613 static void _cb_wl_tz_policy_allowed_aux_hint(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface_resource, int id)
617 static void _cb_wl_tz_policy_aux_message(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface_resource, const char *key, const char *val, struct wl_array *options)
620 static void _cb_wl_conformant_region(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface, uint32_t conformant_part, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h, uint32_t serial)
626 _cb_wl_tz_display_policy_brightness_done(void *data,
627 struct tizen_display_policy *tizen_display_policy,
628 struct wl_surface *surface,
632 Efl_Util_Wl_Surface_Brightness_Info *brightness_info;
634 brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
637 brightness_info->brightness = brightness;
638 brightness_info->wait_for_done = EINA_FALSE;
639 brightness_info->state = state;
644 _cb_window_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
646 Efl_Util_Wl_Surface_Lv_Info *lv_info;
649 if (EINA_UNLIKELY(!lv_info))
652 eina_hash_del(_eflutil.wl.policy.hash_noti_lv, &lv_info->surface, lv_info);
656 efl_util_set_notification_window_level(Evas_Object *window,
657 efl_util_notification_level_e level)
661 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
662 EINA_SAFETY_ON_FALSE_RETURN_VAL((level >= EFL_UTIL_NOTIFICATION_LEVEL_NONE) &&
663 (level <= EFL_UTIL_NOTIFICATION_LEVEL_TOP),
664 EFL_UTIL_ERROR_INVALID_PARAMETER);
667 Ecore_Wl2_Window *wlwin;
668 struct wl_surface *surface;
669 Efl_Util_Wl_Surface_Lv_Info *lv_info;
670 Ecore_Wl2_Window_Type wl_type;
673 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
675 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
676 EINA_SAFETY_ON_NULL_RETURN_VAL(wlwin, EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
678 type = elm_win_type_get(window);
679 if (type != ELM_WIN_NOTIFICATION)
681 wl_type = ecore_wl2_window_type_get(wlwin);
682 EINA_SAFETY_ON_FALSE_RETURN_VAL((wl_type == ECORE_WL2_WINDOW_TYPE_NOTIFICATION),
683 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
686 while (!_eflutil.wl.policy.proto)
687 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
689 surface = ecore_wl2_window_surface_get(wlwin);
690 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
691 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
693 lv_info = eina_hash_find(_eflutil.wl.policy.hash_noti_lv, &surface);
696 lv_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Lv_Info));
697 EINA_SAFETY_ON_NULL_RETURN_VAL(lv_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
699 lv_info->surface = surface;
700 lv_info->level = (int)level;
701 lv_info->wait_for_done = EINA_TRUE;
702 lv_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
703 eina_hash_add(_eflutil.wl.policy.hash_noti_lv,
707 evas_object_event_callback_add(window, EVAS_CALLBACK_DEL,
708 _cb_window_del, lv_info);
712 lv_info->level = (int)level;
713 lv_info->wait_for_done = EINA_TRUE;
714 lv_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
718 tizen_policy_set_notification_level(_eflutil.wl.policy.proto,
719 surface, (int)level);
721 if (lv_info->wait_for_done)
724 while (lv_info->wait_for_done && (count < 3))
726 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
727 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
731 if (lv_info->wait_for_done)
733 return EFL_UTIL_ERROR_INVALID_PARAMETER;
737 if (lv_info->state == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
739 return EFL_UTIL_ERROR_PERMISSION_DENIED;
744 return EFL_UTIL_ERROR_NONE;
748 efl_util_get_notification_window_level(Evas_Object *window,
749 efl_util_notification_level_e *level)
753 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
754 EINA_SAFETY_ON_NULL_RETURN_VAL(level, EFL_UTIL_ERROR_INVALID_PARAMETER);
757 Ecore_Wl2_Window *wlwin;
758 struct wl_surface *surface;
759 Efl_Util_Wl_Surface_Lv_Info *lv_info;
760 Ecore_Wl2_Window_Type wl_type;
763 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
765 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
766 EINA_SAFETY_ON_NULL_RETURN_VAL(wlwin, EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
768 type = elm_win_type_get(window);
769 if (type != ELM_WIN_NOTIFICATION)
771 wl_type = ecore_wl2_window_type_get(wlwin);
772 EINA_SAFETY_ON_FALSE_RETURN_VAL((wl_type == ECORE_WL2_WINDOW_TYPE_NOTIFICATION),
773 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
776 while (!_eflutil.wl.policy.proto)
777 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
779 surface = ecore_wl2_window_surface_get(wlwin);
780 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
781 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
783 lv_info = eina_hash_find(_eflutil.wl.policy.hash_noti_lv, &surface);
786 if (lv_info->wait_for_done)
789 while ((lv_info->wait_for_done) && (count < 3))
791 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
792 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
796 if (lv_info->wait_for_done)
798 *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
799 return EFL_UTIL_ERROR_INVALID_PARAMETER;
803 switch (lv_info->level)
805 case TIZEN_POLICY_LEVEL_NONE: *level = EFL_UTIL_NOTIFICATION_LEVEL_NONE; break;
806 case TIZEN_POLICY_LEVEL_DEFAULT: *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT; break;
807 case TIZEN_POLICY_LEVEL_MEDIUM: *level = EFL_UTIL_NOTIFICATION_LEVEL_MEDIUM; break;
808 case TIZEN_POLICY_LEVEL_HIGH: *level = EFL_UTIL_NOTIFICATION_LEVEL_HIGH; break;
809 case TIZEN_POLICY_LEVEL_TOP: *level = EFL_UTIL_NOTIFICATION_LEVEL_TOP; break;
810 default: *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
811 return EFL_UTIL_ERROR_INVALID_PARAMETER;
813 return EFL_UTIL_ERROR_NONE;
816 *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
818 return EFL_UTIL_ERROR_NONE;
822 efl_util_set_window_opaque_state(Evas_Object *window,
827 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
828 EINA_SAFETY_ON_FALSE_RETURN_VAL(((opaque >= 0) && (opaque <= 1)),
829 EFL_UTIL_ERROR_INVALID_PARAMETER);
831 Ecore_Wl2_Window *wlwin;
832 struct wl_surface *surface;
834 if (!_eflutil.wl.policy.proto)
839 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
841 while (!_eflutil.wl.policy.proto && ret != -1)
842 ret = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
844 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.policy.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
847 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
849 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
851 surface = ecore_wl2_window_surface_get(wlwin);
853 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
855 tizen_policy_set_opaque_state(_eflutil.wl.policy.proto, surface, opaque);
857 return EFL_UTIL_ERROR_NONE;
861 efl_util_set_window_screen_mode(Evas_Object *window,
862 efl_util_screen_mode_e mode)
864 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
865 EINA_SAFETY_ON_FALSE_RETURN_VAL(((mode >= EFL_UTIL_SCREEN_MODE_DEFAULT) &&
866 (mode <= EFL_UTIL_SCREEN_MODE_ALWAYS_ON)),
867 EFL_UTIL_ERROR_INVALID_PARAMETER);
869 Ecore_Wl2_Window *wlwin;
870 struct wl_surface *surface;
871 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
875 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
877 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
880 while (!_eflutil.wl.policy.proto)
881 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
883 surface = ecore_wl2_window_surface_get(wlwin);
884 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
885 EFL_UTIL_ERROR_INVALID_PARAMETER);
887 scr_mode_info = eina_hash_find(_eflutil.wl.policy.hash_scr_mode, &surface);
890 scr_mode_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Scr_Mode_Info));
891 EINA_SAFETY_ON_NULL_RETURN_VAL(scr_mode_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
893 scr_mode_info->surface = surface;
894 scr_mode_info->mode = (unsigned int)mode;
895 scr_mode_info->wait_for_done = EINA_TRUE;
896 scr_mode_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
898 eina_hash_add(_eflutil.wl.policy.hash_scr_mode,
904 scr_mode_info->mode = (unsigned int)mode;
905 scr_mode_info->wait_for_done = EINA_TRUE;
906 scr_mode_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
909 tizen_policy_set_window_screen_mode(_eflutil.wl.policy.proto,
910 surface, (unsigned int)mode);
911 if (scr_mode_info->wait_for_done)
914 while (scr_mode_info->wait_for_done && (count < 3))
916 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
917 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
921 if (scr_mode_info->wait_for_done)
923 return EFL_UTIL_ERROR_INVALID_PARAMETER;
927 if (scr_mode_info->state == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
929 return EFL_UTIL_ERROR_PERMISSION_DENIED;
934 return EFL_UTIL_ERROR_NONE;
937 return EFL_UTIL_ERROR_INVALID_PARAMETER;
941 efl_util_get_window_screen_mode(Evas_Object *window,
942 efl_util_screen_mode_e *mode)
944 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
945 EINA_SAFETY_ON_NULL_RETURN_VAL(mode, EFL_UTIL_ERROR_INVALID_PARAMETER);
947 Ecore_Wl2_Window *wlwin;
948 struct wl_surface *surface;
949 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
953 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
955 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
958 while (!_eflutil.wl.policy.proto)
959 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
961 surface = ecore_wl2_window_surface_get(wlwin);
962 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
963 EFL_UTIL_ERROR_INVALID_PARAMETER);
965 scr_mode_info = eina_hash_find(_eflutil.wl.policy.hash_scr_mode, &surface);
968 if (scr_mode_info->wait_for_done)
970 while (scr_mode_info->wait_for_done)
972 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
973 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
977 switch (scr_mode_info->mode)
979 case TIZEN_POLICY_MODE_DEFAULT: *mode = EFL_UTIL_SCREEN_MODE_DEFAULT; break;
980 case TIZEN_POLICY_MODE_ALWAYS_ON: *mode = EFL_UTIL_SCREEN_MODE_ALWAYS_ON; break;
981 default: *mode = EFL_UTIL_SCREEN_MODE_DEFAULT;
982 return EFL_UTIL_ERROR_INVALID_PARAMETER;
984 return EFL_UTIL_ERROR_NONE;
988 *mode = EFL_UTIL_SCREEN_MODE_DEFAULT;
989 return EFL_UTIL_ERROR_INVALID_PARAMETER;
993 return EFL_UTIL_ERROR_INVALID_PARAMETER;
997 efl_util_set_window_brightness(Evas_Object *window, int brightness)
999 Ecore_Wl2_Window *wlwin;
1000 struct wl_surface *surface;
1001 Efl_Util_Wl_Surface_Brightness_Info *brightness_info;
1004 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1005 EINA_SAFETY_ON_FALSE_RETURN_VAL(brightness <= 100, EFL_UTIL_ERROR_INVALID_PARAMETER);
1008 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1010 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
1013 while (!_eflutil.wl.display_policy.proto)
1014 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1016 surface = ecore_wl2_window_surface_get(wlwin);
1017 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1018 EFL_UTIL_ERROR_INVALID_PARAMETER);
1020 brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
1021 if (!brightness_info)
1023 brightness_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Brightness_Info));
1024 EINA_SAFETY_ON_NULL_RETURN_VAL(brightness_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
1026 brightness_info->surface = surface;
1027 brightness_info->brightness = brightness;
1028 brightness_info->wait_for_done = EINA_TRUE;
1029 brightness_info->state = TIZEN_DISPLAY_POLICY_ERROR_STATE_NONE;
1031 eina_hash_add(_eflutil.wl.display_policy.hash_brightness,
1037 brightness_info->brightness = brightness;
1038 brightness_info->wait_for_done = EINA_TRUE;
1039 brightness_info->state = TIZEN_DISPLAY_POLICY_ERROR_STATE_NONE;
1042 tizen_display_policy_set_window_brightness(_eflutil.wl.display_policy.proto,
1043 surface, brightness);
1044 if (brightness_info->wait_for_done)
1047 while (brightness_info->wait_for_done && (count < 3))
1049 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
1050 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1054 if (brightness_info->wait_for_done)
1056 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1060 if (brightness_info->state == TIZEN_DISPLAY_POLICY_ERROR_STATE_PERMISSION_DENIED)
1062 return EFL_UTIL_ERROR_PERMISSION_DENIED;
1066 return EFL_UTIL_ERROR_NONE;
1069 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1073 efl_util_get_window_brightness(Evas_Object *window, int *brightness)
1075 Ecore_Wl2_Window *wlwin;
1076 struct wl_surface *surface;
1077 Efl_Util_Wl_Surface_Brightness_Info *brightness_info;
1080 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1081 EINA_SAFETY_ON_NULL_RETURN_VAL(brightness, EFL_UTIL_ERROR_INVALID_PARAMETER);
1084 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1086 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
1087 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
1089 while (!_eflutil.wl.display_policy.proto)
1090 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1092 surface = ecore_wl2_window_surface_get(wlwin);
1093 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1094 EFL_UTIL_ERROR_INVALID_PARAMETER);
1096 brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
1097 if (brightness_info)
1099 if (brightness_info->wait_for_done)
1101 while (brightness_info->wait_for_done)
1103 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
1104 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1107 *brightness = brightness_info->brightness;
1112 return EFL_UTIL_ERROR_NONE;
1116 struct _efl_util_inputgen_h
1118 unsigned int init_type;
1123 _cb_device_add(void *data EINA_UNUSED,
1124 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1125 uint32_t serial EINA_UNUSED,
1126 const char *identifier EINA_UNUSED,
1127 struct tizen_input_device *device EINA_UNUSED,
1128 struct wl_seat *seat EINA_UNUSED)
1133 /* LCOV_EXCL_START */
1135 _cb_device_remove(void *data EINA_UNUSED,
1136 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1137 uint32_t serial EINA_UNUSED,
1138 const char *identifier EINA_UNUSED,
1139 struct tizen_input_device *device EINA_UNUSED,
1140 struct wl_seat *seat EINA_UNUSED)
1144 /* LCOV_EXCL_STOP */
1147 _cb_error(void *data EINA_UNUSED,
1148 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1151 _eflutil.wl.devmgr.request_notified = errorcode;
1154 /* LCOV_EXCL_START */
1156 _cb_block_expired(void *data EINA_UNUSED,
1157 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED)
1161 /* LCOV_EXCL_STOP */
1163 static efl_util_error_e
1164 _efl_util_input_convert_input_generator_error(int ret)
1168 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE:
1169 return EFL_UTIL_ERROR_NONE;
1170 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NO_PERMISSION:
1171 return EFL_UTIL_ERROR_PERMISSION_DENIED;
1172 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NO_SYSTEM_RESOURCES:
1173 return EFL_UTIL_ERROR_OUT_OF_MEMORY;
1174 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_INVALID_PARAMETER:
1175 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1177 return EFL_UTIL_ERROR_NONE;
1181 API efl_util_inputgen_h
1182 efl_util_input_initialize_generator(unsigned int dev_type)
1184 int ret = EFL_UTIL_ERROR_NONE;
1185 efl_util_inputgen_h inputgen_h = NULL;
1186 unsigned int clas = 0x0;
1189 dev_type & ~(EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN
1190 | EFL_UTIL_INPUT_DEVTYPE_KEYBOARD
1191 | EFL_UTIL_INPUT_DEVTYPE_POINTER))
1193 set_last_result(EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1197 inputgen_h = (efl_util_inputgen_h)calloc(1, sizeof(struct _efl_util_inputgen_h));
1200 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
1204 inputgen_h->init_type |= dev_type;
1207 if (ret == (int)EINA_FALSE)
1209 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1213 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN)
1214 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
1215 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD)
1216 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD;
1217 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_POINTER)
1218 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE;
1220 while (!_eflutil.wl.devmgr.devicemgr)
1221 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1223 tizen_input_device_manager_init_generator(_eflutil.wl.devmgr.devicemgr, clas);
1225 while (_eflutil.wl.devmgr.request_notified == -1)
1226 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1228 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1229 _eflutil.wl.devmgr.request_notified = -1;
1231 set_last_result(ret);
1232 if (ret != TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE)
1246 API efl_util_inputgen_h
1247 efl_util_input_initialize_generator_with_name(unsigned int dev_type, const char *name)
1249 int ret = EFL_UTIL_ERROR_NONE;
1250 efl_util_inputgen_h inputgen_h = NULL;
1251 unsigned int clas = 0x0;
1254 dev_type & ~(EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN
1255 | EFL_UTIL_INPUT_DEVTYPE_KEYBOARD
1256 | EFL_UTIL_INPUT_DEVTYPE_POINTER))
1258 set_last_result(EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1262 inputgen_h = (efl_util_inputgen_h)calloc(1, sizeof(struct _efl_util_inputgen_h));
1265 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
1269 inputgen_h->init_type |= dev_type;
1270 strncpy(inputgen_h->name, name, 31);
1273 if (ret == (int)EINA_FALSE)
1275 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1279 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN)
1280 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
1281 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD)
1282 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD;
1283 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_POINTER)
1284 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE;
1286 while (!_eflutil.wl.devmgr.devicemgr)
1287 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1289 tizen_input_device_manager_init_generator_with_name(_eflutil.wl.devmgr.devicemgr, clas, inputgen_h->name);
1291 while (_eflutil.wl.devmgr.request_notified == -1)
1292 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1294 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1295 _eflutil.wl.devmgr.request_notified = -1;
1297 set_last_result(ret);
1298 if (ret != TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE)
1314 efl_util_input_deinitialize_generator(efl_util_inputgen_h inputgen_h)
1316 int ret = EFL_UTIL_ERROR_NONE;
1317 unsigned int clas = 0x0;
1318 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1320 if (inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN)
1321 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
1322 if (inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD)
1323 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD;
1324 if (inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_POINTER)
1325 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE;
1330 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1332 tizen_input_device_manager_deinit_generator(_eflutil.wl.devmgr.devicemgr, clas);
1334 while (_eflutil.wl.devmgr.request_notified == -1)
1335 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1337 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1338 _eflutil.wl.devmgr.request_notified = -1;
1344 efl_util_input_generate_key(efl_util_inputgen_h inputgen_h, const char *key_name, int pressed)
1346 int ret = EFL_UTIL_ERROR_NONE;
1348 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1349 EINA_SAFETY_ON_NULL_RETURN_VAL(key_name, EFL_UTIL_ERROR_INVALID_PARAMETER);
1350 EINA_SAFETY_ON_FALSE_RETURN_VAL(pressed == 0 || pressed == 1, EFL_UTIL_ERROR_INVALID_PARAMETER);
1351 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1353 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1355 tizen_input_device_manager_generate_key(_eflutil.wl.devmgr.devicemgr, key_name, pressed);
1357 while (_eflutil.wl.devmgr.request_notified == -1)
1358 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1360 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1361 _eflutil.wl.devmgr.request_notified = -1;
1367 efl_util_input_generate_touch(efl_util_inputgen_h inputgen_h, int idx,
1368 efl_util_input_touch_type_e touch_type, int x, int y)
1371 enum tizen_input_device_manager_pointer_event_type type;
1373 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1374 EINA_SAFETY_ON_FALSE_RETURN_VAL(idx >= 0, EFL_UTIL_ERROR_INVALID_PARAMETER);
1375 EINA_SAFETY_ON_FALSE_RETURN_VAL((x > 0 && y > 0), EFL_UTIL_ERROR_INVALID_PARAMETER);
1376 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1378 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1382 case EFL_UTIL_INPUT_TOUCH_BEGIN:
1383 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_BEGIN;
1385 case EFL_UTIL_INPUT_TOUCH_UPDATE:
1386 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_UPDATE;
1388 case EFL_UTIL_INPUT_TOUCH_END:
1389 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_END;
1392 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1395 tizen_input_device_manager_generate_touch(_eflutil.wl.devmgr.devicemgr, type, x, y, idx);
1397 while (_eflutil.wl.devmgr.request_notified == -1)
1398 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1400 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1401 _eflutil.wl.devmgr.request_notified = -1;
1407 efl_util_input_generate_pointer(efl_util_inputgen_h inputgen_h, int buttons, efl_util_input_pointer_type_e pointer_type, int x, int y)
1410 enum tizen_input_device_manager_pointer_event_type type;
1412 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1413 EINA_SAFETY_ON_FALSE_RETURN_VAL(buttons > 0, EFL_UTIL_ERROR_INVALID_PARAMETER);
1414 EINA_SAFETY_ON_FALSE_RETURN_VAL((x >= 0 && y >= 0), EFL_UTIL_ERROR_INVALID_PARAMETER);
1415 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_POINTER, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1417 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1419 switch(pointer_type)
1421 case EFL_UTIL_INPUT_POINTER_BUTTON_DOWN:
1422 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_BEGIN;
1424 case EFL_UTIL_INPUT_POINTER_MOVE:
1425 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_UPDATE;
1427 case EFL_UTIL_INPUT_POINTER_BUTTON_UP:
1428 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_END;
1431 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1434 tizen_input_device_manager_generate_pointer(_eflutil.wl.devmgr.devicemgr, type, x, y, buttons);
1436 while (_eflutil.wl.devmgr.request_notified == -1)
1437 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1439 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1440 _eflutil.wl.devmgr.request_notified = -1;
1446 struct _efl_util_screenshot_h
1451 Eina_Bool shot_done;
1456 Eina_Bool auto_rotation;
1459 /* scrrenshot handle */
1460 static efl_util_screenshot_h g_screenshot;
1461 static Eina_Bool shot_mutex_init;
1462 static pthread_mutex_t shot_lock;
1465 _screenshot_mutex_init(void)
1467 if (shot_mutex_init)
1470 if (pthread_mutex_init(&shot_lock, NULL))
1472 fprintf(stderr, "[screenshot] fail: mutex init"); /*LCOV_EXCL_LINE*/
1473 return EINA_FALSE; /*LCOV_EXCL_LINE*/
1476 shot_mutex_init = EINA_TRUE;
1482 _screenshot_mutex_destory(void)
1484 if (!shot_mutex_init)
1487 if (pthread_mutex_destroy(&shot_lock))
1489 fprintf(stderr, "[screenshot] fail: mutex destory"); /*LCOV_EXCL_LINE*/
1490 return EINA_FALSE; /*LCOV_EXCL_LINE*/
1493 shot_mutex_init = EINA_FALSE;
1499 _screenshot_mutex_lock(void)
1501 if (!_screenshot_mutex_init())
1504 pthread_mutex_lock(&shot_lock);
1508 _screenshot_mutex_unlock(void)
1510 pthread_mutex_unlock(&shot_lock);
1513 API efl_util_screenshot_h
1514 efl_util_screenshot_initialize(int width, int height)
1516 efl_util_screenshot_h screenshot = NULL;
1517 struct wl_display *display_wrapper = NULL;
1518 struct wl_registry *reg = NULL;
1521 EINA_SAFETY_ON_FALSE_GOTO(width > 0, fail_param);
1522 EINA_SAFETY_ON_FALSE_GOTO(height > 0, fail_param);
1524 _screenshot_mutex_lock();
1526 if (!_eflutil.wl.shot.screenshooter)
1529 if (ret == (int)EINA_FALSE)
1531 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1532 _screenshot_mutex_unlock();
1535 wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1537 display_wrapper = wl_proxy_create_wrapper(_eflutil.wl.dpy);
1538 EINA_SAFETY_ON_NULL_GOTO(display_wrapper, fail_memory);
1540 _eflutil.wl.shot.queue = wl_display_create_queue(_eflutil.wl.dpy);
1541 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.queue, fail_memory);
1543 wl_proxy_set_queue((struct wl_proxy *)display_wrapper, _eflutil.wl.shot.queue);
1545 reg = wl_display_get_registry(display_wrapper);
1546 wl_proxy_wrapper_destroy(display_wrapper);
1547 display_wrapper = NULL;
1548 EINA_SAFETY_ON_NULL_GOTO(reg, fail_init);
1550 wl_registry_add_listener(reg, &_wl_reg_screenshooter_listener, NULL);
1552 ret = wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
1553 EINA_SAFETY_ON_TRUE_GOTO(ret == -1, fail_init);
1554 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.screenshooter, fail_init);
1555 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.tz_screenshooter, fail_init);
1557 _eflutil.wl.shot.tbm_client = wayland_tbm_client_init(_eflutil.wl.dpy);
1558 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.tbm_client, fail_init);
1560 wl_registry_destroy(reg);
1564 if (_eflutil.wl.shot.noti == 0)
1566 fprintf(stderr, "[screenshot] fail: privilege error\n"); /* LCOV_EXCL_LINE */
1572 if (g_screenshot->width != width || g_screenshot->height != height)
1574 g_screenshot->width = width;
1575 g_screenshot->height = height;
1578 _screenshot_mutex_unlock();
1580 return g_screenshot;
1583 screenshot = calloc(1, sizeof(struct _efl_util_screenshot_h));
1584 EINA_SAFETY_ON_NULL_GOTO(screenshot, fail_memory);
1586 screenshot->width = width;
1587 screenshot->height = height;
1588 screenshot->auto_rotation = EINA_TRUE;
1590 screenshot->bufmgr = wayland_tbm_client_get_bufmgr(_eflutil.wl.shot.tbm_client);
1591 EINA_SAFETY_ON_NULL_GOTO(screenshot->bufmgr, fail_init);
1593 g_screenshot = screenshot;
1594 set_last_result(EFL_UTIL_ERROR_NONE);
1596 screenshooter_set_user_data(_eflutil.wl.shot.screenshooter, &screenshot->shot_done);
1598 _screenshot_mutex_unlock();
1600 return g_screenshot;
1603 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1606 /* LCOV_EXCL_START */
1607 if (display_wrapper)
1608 wl_proxy_wrapper_destroy(display_wrapper);
1609 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
1613 wl_registry_destroy(reg);
1615 efl_util_screenshot_deinitialize(screenshot);
1616 _screenshot_mutex_unlock();
1617 set_last_result(EFL_UTIL_ERROR_SCREENSHOT_INIT_FAIL);
1619 /* LCOV_EXCL_STOP */
1623 efl_util_screenshot_deinitialize(efl_util_screenshot_h screenshot)
1625 _screenshot_mutex_lock();
1629 _screenshot_mutex_unlock();
1630 _screenshot_mutex_destory();
1631 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1635 g_screenshot = NULL;
1637 if (_eflutil.wl.shot.screenshooter)
1639 screenshooter_destroy(_eflutil.wl.shot.screenshooter);
1640 _eflutil.wl.shot.screenshooter = NULL;
1642 if (_eflutil.wl.shot.tz_screenshooter)
1644 tizen_screenshooter_destroy(_eflutil.wl.shot.tz_screenshooter);
1645 _eflutil.wl.shot.tz_screenshooter = NULL;
1648 if (_eflutil.wl.shot.queue)
1650 wl_event_queue_destroy(_eflutil.wl.shot.queue);
1651 _eflutil.wl.shot.queue = NULL;
1654 _screenshot_mutex_unlock();
1655 _screenshot_mutex_destory();
1657 return EFL_UTIL_ERROR_NONE;
1662 efl_util_screenshot_take_tbm_surface(efl_util_screenshot_h screenshot)
1664 tbm_surface_h t_surface = NULL;
1665 struct wl_buffer *buffer = NULL;
1666 Efl_Util_Wl_Output_Info *output;
1669 _screenshot_mutex_lock();
1671 if (!screenshot || (screenshot != g_screenshot))
1673 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1674 _screenshot_mutex_unlock();
1678 output = eina_list_nth(_eflutil.wl.shot.output_list, 0);
1681 fprintf(stderr, "[screenshot] fail: no output for screenshot\n"); /* LCOV_EXCL_LINE */
1685 t_surface = tbm_surface_create(screenshot->width, screenshot->height, TBM_FORMAT_XRGB8888);
1688 fprintf(stderr, "[screenshot] fail: tbm_surface_create\n"); /* LCOV_EXCL_LINE */
1692 buffer = wayland_tbm_client_create_buffer(_eflutil.wl.shot.tbm_client, t_surface);
1695 fprintf(stderr, "[screenshot] fail: create wl_buffer for screenshot\n"); /* LCOV_EXCL_LINE */
1699 screenshooter_shoot(_eflutil.wl.shot.screenshooter, output->output, buffer);
1701 screenshot->shot_done = EINA_FALSE;
1702 while (!screenshot->shot_done && ret != -1)
1703 ret = wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
1707 fprintf(stderr, "[screenshot] fail: screenshooter_shoot\n"); /* LCOV_EXCL_LINE */
1711 wl_buffer_destroy(buffer);
1713 /* reset shot_done for next screenshot */
1714 screenshot->shot_done = EINA_FALSE;
1716 set_last_result(EFL_UTIL_ERROR_NONE);
1718 _screenshot_mutex_unlock();
1724 tbm_surface_destroy(t_surface);
1726 wl_buffer_destroy(buffer);
1728 set_last_result(EFL_UTIL_ERROR_SCREENSHOT_EXECUTION_FAIL);
1730 _screenshot_mutex_unlock();
1735 /* LCOV_EXCL_START */
1737 efl_util_screenshot_set_auto_rotation(efl_util_screenshot_h screenshot, int set)
1739 if (!screenshot || (screenshot != g_screenshot))
1740 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1742 if (!(set == 0 || set == 1))
1743 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1746 g_screenshot->auto_rotation = EINA_TRUE;
1748 g_screenshot->auto_rotation = EINA_FALSE;
1750 tizen_screenshooter_set_oneshot_auto_rotation(_eflutil.wl.shot.tz_screenshooter, g_screenshot->auto_rotation);
1752 return EFL_UTIL_ERROR_NONE;
1756 efl_util_screenshot_get_auto_rotation(efl_util_screenshot_h screenshot, int *set)
1758 if (!screenshot || (screenshot != g_screenshot) || !set)
1759 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1761 *set = g_screenshot->auto_rotation;
1763 return EFL_UTIL_ERROR_NONE;
1765 /* LCOV_EXCL_STOP */
1767 struct _efl_util_gesture_h
1772 API int EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = 0;
1773 API int EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = 0;
1774 API int EFL_UTIL_EVENT_GESTURE_TAP = 0;
1775 API int EFL_UTIL_EVENT_GESTURE_PALM_COVER = 0;
1777 /* LCOV_EXCL_START */
1779 _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)
1781 _eflutil.wl.gesture.request_notified = error;
1785 _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)
1787 efl_util_event_gesture_edge_swipe_s *ev = NULL;
1789 ev = (efl_util_event_gesture_edge_swipe_s *)calloc(1, sizeof(*ev));
1794 ev->fingers = fingers;
1799 ecore_event_add(EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE, ev, NULL, NULL);
1803 _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)
1805 _eflutil.wl.gesture.request_notified = error;
1809 _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)
1811 efl_util_event_gesture_edge_drag_s *ev = NULL;
1813 ev = (efl_util_event_gesture_edge_drag_s *)calloc(1, sizeof(*ev));
1818 ev->fingers = fingers;
1823 ecore_event_add(EFL_UTIL_EVENT_GESTURE_EDGE_DRAG, ev, NULL, NULL);
1827 _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)
1829 _eflutil.wl.gesture.request_notified = error;
1833 _cb_gesture_tap(void *data EINA_UNUSED, struct tizen_gesture *tizen_gesture EINA_UNUSED, uint32_t mode, uint32_t fingers, uint32_t repeats)
1835 efl_util_event_gesture_tap_s *ev = NULL;
1837 ev = (efl_util_event_gesture_tap_s *)calloc(1, sizeof(*ev));
1842 ev->fingers = fingers;
1843 ev->repeats = repeats;
1845 ecore_event_add(EFL_UTIL_EVENT_GESTURE_TAP, ev, NULL, NULL);
1847 /* LCOV_EXCL_STOP */
1850 _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)
1852 _eflutil.wl.gesture.request_notified = error;
1855 /* LCOV_EXCL_START */
1857 _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)
1859 efl_util_event_gesture_palm_cover_s *ev = NULL;
1861 ev = (efl_util_event_gesture_palm_cover_s *)calloc(1, sizeof(*ev));
1866 ev->duration = duration;
1870 ev->pressure = wl_fixed_to_int(pressure);
1872 ecore_event_add(EFL_UTIL_EVENT_GESTURE_PALM_COVER, ev, NULL, NULL);
1874 /* LCOV_EXCL_STOP */
1877 _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)
1879 _eflutil.wl.gesture.request_notified = error;
1882 static efl_util_error_e
1883 _efl_util_gesture_convert_error(int ret)
1887 case TIZEN_GESTURE_ERROR_NONE:
1888 return EFL_UTIL_ERROR_NONE;
1889 case TIZEN_GESTURE_ERROR_INVALID_DATA:
1890 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1891 case TIZEN_GESTURE_ERROR_NO_PERMISSION:
1892 return EFL_UTIL_ERROR_PERMISSION_DENIED;
1893 case TIZEN_GESTURE_ERROR_NO_SYSTEM_RESOURCES:
1894 return EFL_UTIL_ERROR_OUT_OF_MEMORY;
1895 case TIZEN_GESTURE_ERROR_GRABBED_ALREADY:
1896 return EFL_UTIL_ERROR_NO_RESOURCE_AVAILABLE;
1897 case TIZEN_GESTURE_ERROR_NOT_SUPPORTED:
1898 return EFL_UTIL_ERROR_NOT_SUPPORTED;
1900 return EFL_UTIL_ERROR_NONE;
1904 /* LCOV_EXCL_START */
1906 _efl_util_gesture_grab_edge_swipe(efl_util_gesture_data data)
1908 int ret = EFL_UTIL_ERROR_NONE;
1909 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
1910 Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = NULL;
1911 unsigned int fingers = 0;
1912 unsigned int edge = 0;
1913 unsigned int edge_size = 0;
1914 unsigned int start_point = 0;
1915 unsigned int end_point = 0;
1917 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
1919 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
1920 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
1921 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_SWIPE,
1922 EFL_UTIL_ERROR_INVALID_PARAMETER);
1924 edge_swipe_data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)data;
1926 fingers = edge_swipe_data->fingers;
1927 edge = edge_swipe_data->edge;
1928 edge_size = edge_swipe_data->edge_size;
1929 start_point = edge_swipe_data->start_point;
1930 end_point = edge_swipe_data->end_point;
1932 tizen_gesture_grab_edge_swipe(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
1934 while (_eflutil.wl.gesture.request_notified == -1)
1935 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1937 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
1938 _eflutil.wl.gesture.request_notified = -1;
1944 _efl_util_gesture_ungrab_edge_swipe(efl_util_gesture_data data)
1946 int ret = EFL_UTIL_ERROR_NONE;
1947 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
1948 Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = NULL;
1949 unsigned int fingers = 0;
1950 unsigned int edge = 0;
1951 unsigned int edge_size = 0;
1952 unsigned int start_point = 0;
1953 unsigned int end_point = 0;
1955 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
1957 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
1958 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
1959 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_SWIPE,
1960 EFL_UTIL_ERROR_INVALID_PARAMETER);
1962 edge_swipe_data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)data;
1964 fingers = edge_swipe_data->fingers;
1965 edge = edge_swipe_data->edge;
1966 edge_size = edge_swipe_data->edge_size;
1967 start_point = edge_swipe_data->start_point;
1968 end_point = edge_swipe_data->end_point;
1970 tizen_gesture_ungrab_edge_swipe(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
1972 while (_eflutil.wl.gesture.request_notified == -1)
1973 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1975 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
1976 _eflutil.wl.gesture.request_notified = -1;
1982 _efl_util_gesture_grab_edge_drag(efl_util_gesture_data data)
1984 int ret = EFL_UTIL_ERROR_NONE;
1985 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
1986 Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = NULL;
1987 unsigned int fingers = 0;
1988 unsigned int edge = 0;
1989 unsigned int edge_size = 0;
1990 unsigned int start_point = 0;
1991 unsigned int end_point = 0;
1993 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
1995 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
1996 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
1997 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_DRAG,
1998 EFL_UTIL_ERROR_INVALID_PARAMETER);
2000 edge_drag_data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)data;
2002 fingers = edge_drag_data->fingers;
2003 edge = edge_drag_data->edge;
2004 edge_size = edge_drag_data->edge_size;
2005 start_point = edge_drag_data->start_point;
2006 end_point = edge_drag_data->end_point;
2008 tizen_gesture_grab_edge_drag(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2010 while (_eflutil.wl.gesture.request_notified == -1)
2011 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2013 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2014 _eflutil.wl.gesture.request_notified = -1;
2020 _efl_util_gesture_ungrab_edge_drag(efl_util_gesture_data data)
2022 int ret = EFL_UTIL_ERROR_NONE;
2023 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2024 Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = NULL;
2025 unsigned int fingers = 0;
2026 unsigned int edge = 0;
2027 unsigned int edge_size = 0;
2028 unsigned int start_point = 0;
2029 unsigned int end_point = 0;
2031 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2033 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2034 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2035 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_DRAG,
2036 EFL_UTIL_ERROR_INVALID_PARAMETER);
2038 edge_drag_data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)data;
2040 fingers = edge_drag_data->fingers;
2041 edge = edge_drag_data->edge;
2042 edge_size = edge_drag_data->edge_size;
2043 start_point = edge_drag_data->start_point;
2044 end_point = edge_drag_data->end_point;
2046 tizen_gesture_ungrab_edge_drag(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2048 while (_eflutil.wl.gesture.request_notified == -1)
2049 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2051 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2052 _eflutil.wl.gesture.request_notified = -1;
2059 _efl_util_gesture_grab_tap(efl_util_gesture_data data)
2061 int ret = EFL_UTIL_ERROR_NONE;
2062 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2063 Efl_Util_Gesture_Tap_Grab_Data *tap_data = NULL;
2064 unsigned int fingers = 0;
2065 unsigned int repeats = 0;
2067 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2069 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2070 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2071 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_TAP,
2072 EFL_UTIL_ERROR_INVALID_PARAMETER);
2074 tap_data = (Efl_Util_Gesture_Tap_Grab_Data *)data;
2076 fingers = tap_data->fingers;
2077 repeats = tap_data->repeats;
2079 tizen_gesture_grab_tap(_eflutil.wl.gesture.proto, fingers, repeats);
2081 while (_eflutil.wl.gesture.request_notified == -1)
2082 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2084 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2085 _eflutil.wl.gesture.request_notified = -1;
2091 _efl_util_gesture_ungrab_tap(efl_util_gesture_data data)
2093 int ret = EFL_UTIL_ERROR_NONE;
2094 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2095 Efl_Util_Gesture_Tap_Grab_Data *tap_data = NULL;
2096 unsigned int fingers = 0;
2097 unsigned int repeats = 0;
2099 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2101 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2102 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2103 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_TAP,
2104 EFL_UTIL_ERROR_INVALID_PARAMETER);
2106 tap_data = (Efl_Util_Gesture_Tap_Grab_Data *)data;
2108 fingers = tap_data->fingers;
2109 repeats = tap_data->repeats;
2111 tizen_gesture_ungrab_tap(_eflutil.wl.gesture.proto, fingers, repeats);
2113 while (_eflutil.wl.gesture.request_notified == -1)
2114 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2116 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2117 _eflutil.wl.gesture.request_notified = -1;
2123 _efl_util_gesture_grab_palm_cover(efl_util_gesture_data data)
2125 int ret = EFL_UTIL_ERROR_NONE;
2126 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2128 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2130 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2131 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2132 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_PALM_COVER,
2133 EFL_UTIL_ERROR_INVALID_PARAMETER);
2135 tizen_gesture_grab_palm_cover(_eflutil.wl.gesture.proto);
2137 while (_eflutil.wl.gesture.request_notified == -1)
2138 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2140 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2141 _eflutil.wl.gesture.request_notified = -1;
2147 _efl_util_gesture_ungrab_palm_cover(efl_util_gesture_data data)
2149 int ret = EFL_UTIL_ERROR_NONE;
2150 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2152 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2154 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2155 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2156 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_PALM_COVER,
2157 EFL_UTIL_ERROR_INVALID_PARAMETER);
2159 tizen_gesture_ungrab_palm_cover(_eflutil.wl.gesture.proto);
2161 while (_eflutil.wl.gesture.request_notified == -1)
2162 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2164 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2165 _eflutil.wl.gesture.request_notified = -1;
2171 _efl_util_fd_cb(void *data, Ecore_Fd_Handler *hdl)
2173 if (_eflutil.wl.dpy && _eflutil.wl.queue)
2175 wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2176 return ECORE_CALLBACK_RENEW;
2180 return ECORE_CALLBACK_CANCEL;
2183 /* LCOV_EXCL_STOP */
2185 API efl_util_gesture_h
2186 efl_util_gesture_initialize(void)
2188 efl_util_gesture_h gesture_h = NULL;
2191 gesture_h = (efl_util_gesture_h)calloc(1, sizeof(struct _efl_util_gesture_h));
2194 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2195 goto out; /* LCOV_EXCL_LINE */
2198 if (_wl_init() == (int)EINA_FALSE)
2200 set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED); /* LCOV_EXCL_LINE */
2201 goto out; /* LCOV_EXCL_LINE */
2204 while (!_eflutil.wl.gesture.proto)
2205 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue); /* LCOV_EXCL_LINE */
2207 if (_eflutil.wl.gesture.event_init <= 0)
2209 if (ecore_event_init() <= 0)
2211 set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED); /* LCOV_EXCL_LINE */
2212 goto out; /* LCOV_EXCL_LINE */
2214 EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = ecore_event_type_new();
2215 EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = ecore_event_type_new();
2216 EFL_UTIL_EVENT_GESTURE_TAP = ecore_event_type_new();
2217 EFL_UTIL_EVENT_GESTURE_PALM_COVER = ecore_event_type_new();
2219 dpy_fd = wl_display_get_fd(_eflutil.wl.dpy);
2220 _eflutil.wl.dpy_fd = fcntl(dpy_fd, F_DUPFD_CLOEXEC, 0);
2221 if (_eflutil.wl.dpy_fd >= 0)
2222 _eflutil.wl.fd_hdl = ecore_main_fd_handler_add(_eflutil.wl.dpy_fd,
2223 ECORE_FD_READ | ECORE_FD_WRITE | ECORE_FD_ERROR,
2224 _efl_util_fd_cb, NULL,
2227 _eflutil.wl.gesture.event_init++;
2228 gesture_h->init = EINA_TRUE;
2230 set_last_result(EFL_UTIL_ERROR_NONE);
2234 /* LCOV_EXCL_START */
2241 /* LCOV_EXCL_STOP */
2245 efl_util_gesture_deinitialize(efl_util_gesture_h gesture_h)
2247 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2248 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2253 _eflutil.wl.gesture.event_init--;
2255 if (_eflutil.wl.gesture.event_init <= 0)
2257 _eflutil.wl.gesture.event_init = 0;
2258 ecore_event_shutdown();
2259 EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = 0;
2260 EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = 0;
2261 EFL_UTIL_EVENT_GESTURE_TAP = 0;
2262 EFL_UTIL_EVENT_GESTURE_PALM_COVER = 0;
2263 if (_eflutil.wl.dpy_fd >= 0)
2265 ecore_main_fd_handler_del(_eflutil.wl.fd_hdl);
2266 _eflutil.wl.fd_hdl = NULL;
2267 close(_eflutil.wl.dpy_fd);
2268 _eflutil.wl.dpy_fd = -1;
2272 return EFL_UTIL_ERROR_NONE;
2275 API efl_util_gesture_data
2276 efl_util_gesture_edge_swipe_new(efl_util_gesture_h gesture_h, unsigned int fingers, efl_util_gesture_edge_e edge)
2278 Efl_Util_Gesture_Edge_Swipe_Grab_Data *data;
2280 if (!gesture_h || gesture_h->init == EINA_FALSE)
2282 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2286 if (edge <= EFL_UTIL_GESTURE_EDGE_NONE || edge > EFL_UTIL_GESTURE_EDGE_LEFT)
2288 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2292 data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Edge_Swipe_Grab_Data));
2295 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2296 return NULL; /* LCOV_EXCL_LINE */
2299 data->base.type = TIZEN_GESTURE_TYPE_EDGE_SWIPE;
2300 data->fingers = fingers;
2302 data->edge_size = EFL_UTIL_GESTURE_EDGE_SIZE_FULL;
2304 set_last_result(EFL_UTIL_ERROR_NONE);
2306 return (void *)data;
2310 efl_util_gesture_edge_swipe_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2312 if (!gesture_h || gesture_h->init == EINA_FALSE)
2314 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2319 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2325 return EFL_UTIL_ERROR_NONE;
2329 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)
2331 Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = data;
2333 EINA_SAFETY_ON_NULL_RETURN_VAL(edge_swipe_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2334 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_swipe_data->base.type == TIZEN_GESTURE_TYPE_EDGE_SWIPE,
2335 EFL_UTIL_ERROR_INVALID_PARAMETER);
2336 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_size == EFL_UTIL_GESTURE_EDGE_SIZE_PARTIAL,
2337 EFL_UTIL_ERROR_INVALID_PARAMETER);
2338 EINA_SAFETY_ON_FALSE_RETURN_VAL(end_point > start_point, EFL_UTIL_ERROR_INVALID_PARAMETER);
2340 edge_swipe_data->edge_size = edge_size;
2341 edge_swipe_data->start_point = start_point;
2342 edge_swipe_data->end_point = end_point;
2344 return EFL_UTIL_ERROR_NONE;
2347 API efl_util_gesture_data
2348 efl_util_gesture_edge_drag_new(efl_util_gesture_h gesture_h, unsigned int fingers, efl_util_gesture_edge_e edge)
2350 Efl_Util_Gesture_Edge_Drag_Grab_Data *data;
2352 if (!gesture_h || gesture_h->init == EINA_FALSE)
2354 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2358 if (edge <= EFL_UTIL_GESTURE_EDGE_NONE || edge > EFL_UTIL_GESTURE_EDGE_LEFT)
2360 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2364 data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Edge_Drag_Grab_Data));
2367 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2368 return NULL; /* LCOV_EXCL_LINE */
2371 data->base.type = TIZEN_GESTURE_TYPE_EDGE_DRAG;
2372 data->fingers = fingers;
2374 data->edge_size = EFL_UTIL_GESTURE_EDGE_SIZE_FULL;
2376 set_last_result(EFL_UTIL_ERROR_NONE);
2378 return (void *)data;
2382 efl_util_gesture_edge_drag_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2384 if (!gesture_h || gesture_h->init == EINA_FALSE)
2386 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2391 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2397 return EFL_UTIL_ERROR_NONE;
2401 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)
2403 Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = data;
2405 EINA_SAFETY_ON_NULL_RETURN_VAL(edge_drag_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2406 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_drag_data->base.type == TIZEN_GESTURE_TYPE_EDGE_DRAG,
2407 EFL_UTIL_ERROR_INVALID_PARAMETER);
2408 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_size == EFL_UTIL_GESTURE_EDGE_SIZE_PARTIAL,
2409 EFL_UTIL_ERROR_INVALID_PARAMETER);
2410 EINA_SAFETY_ON_FALSE_RETURN_VAL(end_point > start_point, EFL_UTIL_ERROR_INVALID_PARAMETER);
2412 edge_drag_data->edge_size = edge_size;
2413 edge_drag_data->start_point = start_point;
2414 edge_drag_data->end_point = end_point;
2416 return EFL_UTIL_ERROR_NONE;
2419 API efl_util_gesture_data
2420 efl_util_gesture_tap_new(efl_util_gesture_h gesture_h, unsigned int fingers, unsigned int repeats)
2422 Efl_Util_Gesture_Tap_Grab_Data *data;
2424 if (!gesture_h || gesture_h->init == EINA_FALSE)
2426 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2430 if (fingers <= 1 || repeats <= 1)
2432 set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED);
2436 data = (Efl_Util_Gesture_Tap_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Tap_Grab_Data));
2439 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2440 return NULL; /* LCOV_EXCL_LINE */
2443 data->base.type = TIZEN_GESTURE_TYPE_TAP;
2444 data->fingers = fingers;
2445 data->repeats = repeats;
2447 set_last_result(EFL_UTIL_ERROR_NONE);
2449 return (void *)data;
2453 efl_util_gesture_tap_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2455 if (!gesture_h || gesture_h->init == EINA_FALSE)
2457 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2462 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2468 return EFL_UTIL_ERROR_NONE;
2471 API efl_util_gesture_data
2472 efl_util_gesture_palm_cover_new(efl_util_gesture_h gesture_h)
2474 Efl_Util_Gesture_Palm_Cover_Grab_Data *data;
2476 if (!gesture_h || gesture_h->init == EINA_FALSE)
2478 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2482 data = (Efl_Util_Gesture_Palm_Cover_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Palm_Cover_Grab_Data));
2485 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2486 return NULL; /* LCOV_EXCL_LINE */
2489 data->base.type = TIZEN_GESTURE_TYPE_PALM_COVER;
2491 set_last_result(EFL_UTIL_ERROR_NONE);
2493 return (void *)data;
2497 efl_util_gesture_palm_cover_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2499 if (!gesture_h || gesture_h->init == EINA_FALSE)
2501 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2506 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2512 return EFL_UTIL_ERROR_NONE;
2515 /* LCOV_EXCL_START */
2517 efl_util_gesture_grab(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2519 int ret = EFL_UTIL_ERROR_NONE;
2520 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2522 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2524 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2525 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2526 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2528 switch (base_data->type)
2530 case TIZEN_GESTURE_TYPE_EDGE_SWIPE:
2531 ret = _efl_util_gesture_grab_edge_swipe(data);
2533 case TIZEN_GESTURE_TYPE_EDGE_DRAG:
2534 ret = _efl_util_gesture_grab_edge_drag(data);
2536 case TIZEN_GESTURE_TYPE_TAP:
2537 ret = _efl_util_gesture_grab_tap(data);
2539 case TIZEN_GESTURE_TYPE_PALM_COVER:
2540 ret = _efl_util_gesture_grab_palm_cover(data);
2543 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2550 efl_util_gesture_ungrab(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2552 int ret = EFL_UTIL_ERROR_NONE;
2553 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2555 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2557 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2558 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2559 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2561 switch (base_data->type)
2563 case TIZEN_GESTURE_TYPE_EDGE_SWIPE:
2564 ret = _efl_util_gesture_ungrab_edge_swipe(data);
2566 case TIZEN_GESTURE_TYPE_EDGE_DRAG:
2567 ret = _efl_util_gesture_ungrab_edge_drag(data);
2569 case TIZEN_GESTURE_TYPE_TAP:
2570 ret = _efl_util_gesture_ungrab_tap(data);
2572 case TIZEN_GESTURE_TYPE_PALM_COVER:
2573 ret = _efl_util_gesture_ungrab_palm_cover(data);
2576 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2581 /* LCOV_EXCL_STOP */
2584 efl_util_gesture_select(efl_util_gesture_h gesture_h, Evas_Object *window, efl_util_gesture_data data)
2586 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2587 Ecore_Wl2_Window *wlwin;
2588 struct wl_surface *surface;
2591 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2593 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2594 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2595 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
2596 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2598 if (base_data->type != TIZEN_GESTURE_TYPE_PALM_COVER)
2599 return EFL_UTIL_ERROR_NOT_SUPPORTED;
2601 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
2602 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
2604 surface = ecore_wl2_window_surface_get(wlwin);
2605 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
2606 EFL_UTIL_ERROR_INVALID_PARAMETER);
2608 tizen_gesture_select_palm_cover(_eflutil.wl.gesture.proto, surface);
2610 while (_eflutil.wl.gesture.request_notified == -1)
2611 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2613 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2614 _eflutil.wl.gesture.request_notified = -1;
2620 efl_util_gesture_deselect(efl_util_gesture_h gesture_h, Evas_Object *window, efl_util_gesture_data data)
2622 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2623 Ecore_Wl2_Window *wlwin;
2624 struct wl_surface *surface;
2627 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2629 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2630 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2631 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
2632 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2634 if (base_data->type != TIZEN_GESTURE_TYPE_PALM_COVER)
2635 return EFL_UTIL_ERROR_NOT_SUPPORTED;
2637 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
2638 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
2640 surface = ecore_wl2_window_surface_get(wlwin);
2641 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
2642 EFL_UTIL_ERROR_INVALID_PARAMETER);
2644 tizen_gesture_deselect_palm_cover(_eflutil.wl.gesture.proto, surface);
2646 while (_eflutil.wl.gesture.request_notified == -1)
2647 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2649 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2650 _eflutil.wl.gesture.request_notified = -1;
2655 /* LCOV_EXCL_START */
2657 efl_util_gesture_activate_set(efl_util_gesture_h gesture_h, unsigned int type, Eina_Bool active)
2661 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2662 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2663 EINA_SAFETY_ON_TRUE_RETURN_VAL(type == EFL_UTIL_GESTURE_TYPE_NONE, EFL_UTIL_ERROR_INVALID_PARAMETER);
2665 tizen_gesture_activate_set(_eflutil.wl.gesture.proto, NULL, type, active);
2667 while (_eflutil.wl.gesture.request_notified == -1)
2668 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2670 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2671 _eflutil.wl.gesture.request_notified = -1;
2675 /* LCOV_EXCL_STOP */
2678 efl_util_gesture_activate_set_on_window(efl_util_gesture_h gesture_h, Evas_Object *window, unsigned int type, Eina_Bool active)
2680 Ecore_Wl2_Window *wlwin;
2681 struct wl_surface *surface;
2684 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2685 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2686 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
2687 EINA_SAFETY_ON_TRUE_RETURN_VAL(type == EFL_UTIL_GESTURE_TYPE_NONE, EFL_UTIL_ERROR_INVALID_PARAMETER);
2689 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
2690 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
2692 surface = ecore_wl2_window_surface_get(wlwin);
2693 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
2694 EFL_UTIL_ERROR_INVALID_PARAMETER);
2696 tizen_gesture_activate_set(_eflutil.wl.gesture.proto, surface, type, active);
2698 while (_eflutil.wl.gesture.request_notified == -1)
2699 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2701 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2702 _eflutil.wl.gesture.request_notified = -1;