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.
19 #define LOG_TAG "TIZEN_N_EFL_UTIL"
26 #include <sys/types.h>
30 #include <tbm_bufmgr.h>
31 #include <tbm_surface.h>
32 #include <tbm_surface_internal.h>
33 #include <Elementary.h>
34 #include <Ecore_Evas.h>
37 #include <Ecore_Wl2.h>
38 #include <wayland-client.h>
39 #include <wayland-tbm-client.h>
40 #include <tizen-extension-client-protocol.h>
42 #include <efl_util_screenshot_extension.h>
49 #define LOG_TAG "TIZEN_N_EFL_UTIL"
50 #define EFL_UTIL_INPUT_GENERATOR_TOUCH_MAX_FINGER 10
52 #define NUM_EVENT_WAIT_DONE_COUNT 10
54 typedef struct _Efl_Util_Wl_Surface_Lv_Info
56 void *surface; /* wl_surface */
58 Eina_Bool wait_for_done;
60 } Efl_Util_Wl_Surface_Lv_Info;
62 typedef struct _Efl_Util_Wl_Surface_Scr_Mode_Info
64 void *surface; /* wl_surface */
66 Eina_Bool wait_for_done;
68 } Efl_Util_Wl_Surface_Scr_Mode_Info;
70 typedef struct _Efl_Util_Wl_Surface_Brightness_Info
72 void *surface; /* wl_surface */
74 Eina_Bool wait_for_done;
76 } Efl_Util_Wl_Surface_Brightness_Info;
78 typedef struct _Efl_Util_Wl_Output_Info
80 struct wl_output *output;
81 int offset_x, offset_y, width, height;
82 } Efl_Util_Wl_Output_Info;
84 typedef struct _Efl_Util_Gesture_Common_Grab_Data
87 } Efl_Util_Gesture_Common_Grab_Data;
89 typedef struct _Efl_Util_Gesture_Edge_Swipe_Grab_Data
91 Efl_Util_Gesture_Common_Grab_Data base;
94 efl_util_gesture_edge_e edge;
95 efl_util_gesture_edge_size_e edge_size;
96 unsigned int start_point;
97 unsigned int end_point;
98 } Efl_Util_Gesture_Edge_Swipe_Grab_Data;
100 typedef struct _Efl_Util_Gesture_Edge_Drag_Grab_Data
102 Efl_Util_Gesture_Common_Grab_Data base;
104 unsigned int fingers;
105 efl_util_gesture_edge_e edge;
106 efl_util_gesture_edge_size_e edge_size;
107 unsigned int start_point;
108 unsigned int end_point;
109 } Efl_Util_Gesture_Edge_Drag_Grab_Data;
111 typedef struct _Efl_Util_Gesture_Tap_Grab_Data
113 Efl_Util_Gesture_Common_Grab_Data base;
115 unsigned int fingers;
116 unsigned int repeats;
117 } Efl_Util_Gesture_Tap_Grab_Data;
119 typedef struct _Efl_Util_Gesture_Palm_Cover_Grab_Data
121 Efl_Util_Gesture_Common_Grab_Data base;
122 } Efl_Util_Gesture_Palm_Cover_Grab_Data;
124 typedef struct _E_Devicemgr_Inputgen_Touch_Axis
131 } E_Devicemgr_Inputgen_Touch_Axis;
133 typedef struct _Efl_Util_Data
135 /* wayland related stuffs */
139 Ecore_Wl2_Display *wl2_display;
140 struct wl_display *dpy;
141 struct wl_event_queue *queue;
146 struct tizen_policy *proto;
147 Eina_Hash *hash_noti_lv;
148 Eina_Hash *hash_scr_mode;
152 struct wl_event_queue *queue;
153 struct tizen_screenshooter *tz_screenshooter;
154 struct wayland_tbm_client *tbm_client;
155 Eina_List *output_list;
160 struct tizen_input_device_manager *devicemgr;
161 int request_notified;
163 Eina_List *wait_devices;
164 struct wl_event_source *wait_timer;
166 int request_touch_count;
171 struct tizen_display_policy *proto;
172 Eina_Hash *hash_brightness;
177 typedef struct _Efl_Util_Data_Default_Queue
179 /* wayland related stuffs */
183 Ecore_Wl2_Display *wl2_display;
184 struct wl_display *dpy;
189 struct tizen_gesture *proto;
190 int request_notified;
194 } Efl_Util_Data_Default_Queue;
197 static Efl_Util_Data _eflutil =
202 { 0, NULL, NULL, NULL }, /* tizen_policy protocol */
203 { NULL, NULL, NULL, NULL, 0 }, /* screenshooter protocol */
204 { NULL, -1, NULL, NULL, NULL, 0, 0 }, /* tizen_input_device_manager protocol */
205 { 0, NULL, NULL } /* display_policy protocol */
209 static Efl_Util_Data_Default_Queue _eflutil_defaultqueue =
214 { 0, NULL, -1, 0 } /* gesture protocol */
219 static Eina_Bool _wl_init(void);
220 static Eina_Bool _wl_init_default_queue(void);
221 static void _cb_wl_reg_global(void *data, struct wl_registry *reg, unsigned int name, const char *interface, unsigned int version);
222 static void _cb_wl_reg_global_remove(void *data, struct wl_registry *reg, unsigned int name);
223 static void _cb_wl_default_queue_reg_global(void *data, struct wl_registry *reg, unsigned int name, const char *interface, unsigned int version);
224 static void _cb_wl_default_queue_reg_global_remove(void *data, struct wl_registry *reg, unsigned int name);
225 static void _cb_wl_reg_screenshooter_global(void *data, struct wl_registry *reg, unsigned int name, const char *interface, unsigned int version);
226 static void _cb_wl_reg_screenshooter_global_remove(void *data, struct wl_registry *reg, unsigned int name);
227 static void _cb_wl_tz_policy_conformant(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface, uint32_t is_conformant);
228 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);
229 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);
230 static void _cb_wl_tz_policy_transient_for_done(void *data, struct tizen_policy *tizen_policy, uint32_t child_id);
231 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);
232 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);
233 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);
234 static void _cb_wl_tz_policy_allowed_aux_hint(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface_resource, int id);
235 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);
236 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);
238 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);
240 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);
241 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);
242 static void _cb_error(void *data EINA_UNUSED, struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED, uint32_t errorcode);
243 static void _cb_block_expired(void *data EINA_UNUSED, struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED);
244 static void _cb_max_touch_count(void *data EINA_UNUSED, struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED, uint32_t serial EINA_UNUSED, int32_t max_count EINA_UNUSED, struct wl_seat *seat EINA_UNUSED);
246 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);
247 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);
248 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);
249 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);
250 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);
251 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);
252 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);
253 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);
254 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);
257 static const struct wl_registry_listener _wl_reg_listener =
260 _cb_wl_reg_global_remove
263 static const struct wl_registry_listener _wl_reg_screenshooter_listener =
265 _cb_wl_reg_screenshooter_global,
266 _cb_wl_reg_screenshooter_global_remove
269 struct tizen_policy_listener _wl_tz_policy_listener =
271 _cb_wl_tz_policy_conformant,
272 _cb_wl_tz_policy_conformant_area,
273 _cb_wl_tz_policy_notification_done,
274 _cb_wl_tz_policy_transient_for_done,
275 _cb_wl_tz_policy_scr_mode_done,
276 _cb_wl_tz_policy_iconify_state_changed,
277 _cb_wl_tz_policy_supported_aux_hints,
278 _cb_wl_tz_policy_allowed_aux_hint,
279 _cb_wl_tz_policy_aux_message,
280 _cb_wl_conformant_region,
283 struct tizen_input_device_manager_listener _wl_tz_devmgr_listener =
292 struct tizen_display_policy_listener _wl_tz_display_policy_listener =
294 _cb_wl_tz_display_policy_brightness_done,
297 static const struct wl_registry_listener _wl_default_queue_reg_listener =
299 _cb_wl_default_queue_reg_global,
300 _cb_wl_default_queue_reg_global_remove
303 struct tizen_gesture_listener _wl_tz_gesture_listener =
305 _cb_gesture_edge_swipe_notify,
306 _cb_gesture_edge_swipe,
307 _cb_gesture_edge_drag_notify,
308 _cb_gesture_edge_drag,
309 _cb_gesture_tap_notify,
311 _cb_gesture_palm_cover_notify,
312 _cb_gesture_palm_cover,
313 _cb_gesture_activate_notify
319 struct wl_display *display_wrapper = NULL;
320 struct wl_registry *reg = NULL;
322 if (_eflutil.wl.init) return EINA_TRUE;
326 _eflutil.wl.wl2_display = ecore_wl2_display_connect(NULL);
327 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.wl2_display, fail);
328 _eflutil.wl.dpy = ecore_wl2_display_get(_eflutil.wl.wl2_display);
329 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.dpy, fail);
331 display_wrapper = wl_proxy_create_wrapper(_eflutil.wl.dpy);
332 EINA_SAFETY_ON_NULL_GOTO(display_wrapper, fail);
334 _eflutil.wl.queue = wl_display_create_queue(_eflutil.wl.dpy);
335 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.queue, fail);
337 wl_proxy_set_queue((struct wl_proxy *)display_wrapper, _eflutil.wl.queue);
339 reg = wl_display_get_registry(display_wrapper);
340 wl_proxy_wrapper_destroy(display_wrapper);
341 display_wrapper = NULL;
342 EINA_SAFETY_ON_NULL_GOTO(reg, fail);
344 wl_registry_add_listener(reg, &_wl_reg_listener, NULL);
346 _eflutil.wl.init = EINA_TRUE;
351 wl_proxy_wrapper_destroy(display_wrapper);
353 if (_eflutil.wl.queue)
355 wl_event_queue_destroy(_eflutil.wl.queue);
356 _eflutil.wl.queue = NULL;
359 ecore_wl2_shutdown();
364 _wl_init_default_queue(void)
366 struct wl_display *display_wrapper = NULL;
367 struct wl_registry *reg = NULL;
369 if (_eflutil_defaultqueue.wl.init) return EINA_TRUE;
371 if (ecore_wl2_init() <= 0) return EINA_FALSE;
373 _eflutil_defaultqueue.wl.wl2_display = ecore_wl2_connected_display_get(NULL);
374 EINA_SAFETY_ON_NULL_GOTO(_eflutil_defaultqueue.wl.wl2_display, fail);
375 _eflutil_defaultqueue.wl.dpy = ecore_wl2_display_get(_eflutil_defaultqueue.wl.wl2_display);
376 EINA_SAFETY_ON_NULL_GOTO(_eflutil_defaultqueue.wl.dpy, fail);
378 display_wrapper = wl_proxy_create_wrapper(_eflutil_defaultqueue.wl.dpy);
379 EINA_SAFETY_ON_NULL_GOTO(display_wrapper, fail);
381 reg = wl_display_get_registry(display_wrapper);
382 wl_proxy_wrapper_destroy(display_wrapper);
383 display_wrapper = NULL;
384 EINA_SAFETY_ON_NULL_GOTO(reg, fail);
386 wl_registry_add_listener(reg, &_wl_default_queue_reg_listener, NULL);
388 _eflutil_defaultqueue.wl.init = EINA_TRUE;
393 ecore_wl2_shutdown();
398 _cb_wl_output_geometry(void *data, struct wl_output *wl_output, int x, int y,
399 int physical_width, int physical_height, int subpixel,
400 const char *make, const char *model, int transform)
402 Efl_Util_Wl_Output_Info *output = wl_output_get_user_data(wl_output);
403 if (wl_output == output->output)
405 output->offset_x = x;
406 output->offset_y = y;
411 _cb_wl_output_mode(void *data, struct wl_output *wl_output, uint32_t flags,
412 int width, int height, int refresh)
414 Efl_Util_Wl_Output_Info *output = wl_output_get_user_data(wl_output);
415 if (wl_output == output->output && (flags & WL_OUTPUT_MODE_CURRENT))
417 output->width = width;
418 output->height = height;
423 _cb_wl_output_done(void *data, struct wl_output *wl_output)
428 _cb_wl_output_scale(void *data, struct wl_output *wl_output, int32_t factor)
432 static const struct wl_output_listener output_listener =
434 _cb_wl_output_geometry,
441 _cb_tz_screenshot_format(void *data, struct tizen_screenshooter *tz_screenshooter, uint32_t format)
446 _cb_tz_screenshot_noti(void *data, struct tizen_screenshooter *tz_screenshooter, uint32_t noti)
448 _eflutil.wl.shot.noti = noti;
452 _cb_tz_screenshot_done(void *data, struct tizen_screenshooter *tz_screenshooter)
454 Eina_Bool *shot_done = (Eina_Bool*)data;
456 *shot_done = EINA_TRUE;
459 static const struct tizen_screenshooter_listener tz_screenshooter_listener =
461 _cb_tz_screenshot_format,
462 _cb_tz_screenshot_noti,
463 _cb_tz_screenshot_done,
467 _cb_wl_reg_global(void *data,
468 struct wl_registry *reg,
470 const char *interface,
471 unsigned int version)
473 if (!strcmp(interface, "tizen_policy"))
475 struct tizen_policy *proto;
476 proto = wl_registry_bind(reg,
478 &tizen_policy_interface,
482 tizen_policy_add_listener(proto,
483 &_wl_tz_policy_listener,
486 _eflutil.wl.policy.hash_noti_lv = eina_hash_pointer_new(free);
487 _eflutil.wl.policy.hash_scr_mode = eina_hash_pointer_new(free);
488 _eflutil.wl.policy.proto = proto;
489 _eflutil.wl.policy.id = id;
491 else if (strcmp(interface, "wl_output") == 0)
493 Efl_Util_Wl_Output_Info *output = calloc(1, sizeof(Efl_Util_Wl_Output_Info));
494 EINA_SAFETY_ON_NULL_RETURN(output);
496 _eflutil.wl.shot.output_list = eina_list_append(_eflutil.wl.shot.output_list, output);
498 output->output = wl_registry_bind(reg, id, &wl_output_interface, version);
499 wl_output_add_listener(output->output, &output_listener, output);
501 else if (strcmp(interface, "tizen_input_device_manager") == 0)
503 _eflutil.wl.devmgr.devicemgr = wl_registry_bind(reg, id, &tizen_input_device_manager_interface, version);
504 tizen_input_device_manager_add_listener(_eflutil.wl.devmgr.devicemgr, &_wl_tz_devmgr_listener, NULL);
506 else if (!strcmp(interface, "tizen_display_policy"))
508 _eflutil.wl.display_policy.proto = wl_registry_bind(reg, id, &tizen_display_policy_interface, version);
509 if (!_eflutil.wl.display_policy.proto) return;
511 tizen_display_policy_add_listener(_eflutil.wl.display_policy.proto,
512 &_wl_tz_display_policy_listener,
515 _eflutil.wl.display_policy.hash_brightness = eina_hash_pointer_new(free);
516 _eflutil.wl.display_policy.id = id;
519 /* LCOV_EXCL_START */
521 _cb_wl_reg_global_remove(void *data,
522 struct wl_registry *reg,
525 /* unset each global id number to 0 since global id is started
526 * from number 1 on server side display structure
528 if (id == _eflutil.wl.policy.id)
530 _eflutil.wl.policy.id = 0;
531 _eflutil.wl.policy.proto = NULL;
532 eina_hash_free(_eflutil.wl.policy.hash_noti_lv);
533 eina_hash_free(_eflutil.wl.policy.hash_scr_mode);
535 else if (id == _eflutil.wl.display_policy.id)
537 _eflutil.wl.display_policy.id = 0;
538 _eflutil.wl.display_policy.proto = NULL;
539 eina_hash_free(_eflutil.wl.display_policy.hash_brightness);
545 _cb_wl_default_queue_reg_global(void *data,
546 struct wl_registry *reg,
548 const char *interface,
549 unsigned int version)
551 if (strcmp(interface, "tizen_gesture") == 0)
553 _eflutil_defaultqueue.wl.gesture.id = id;
554 _eflutil_defaultqueue.wl.gesture.proto = wl_registry_bind(reg, id, &tizen_gesture_interface, version);
555 tizen_gesture_add_listener(_eflutil_defaultqueue.wl.gesture.proto, &_wl_tz_gesture_listener, NULL);
558 /* LCOV_EXCL_START */
560 _cb_wl_default_queue_reg_global_remove(void *data,
561 struct wl_registry *reg,
564 if (id == _eflutil_defaultqueue.wl.gesture.id)
566 _eflutil_defaultqueue.wl.gesture.id = 0;
567 _eflutil_defaultqueue.wl.gesture.proto = NULL;
574 _cb_wl_reg_screenshooter_global(void *data,
575 struct wl_registry *reg,
577 const char *interface,
578 unsigned int version)
580 if (strcmp(interface, "tizen_screenshooter") == 0)
582 _eflutil.wl.shot.tz_screenshooter = wl_registry_bind(reg, name, &tizen_screenshooter_interface, version);
583 tizen_screenshooter_add_listener(_eflutil.wl.shot.tz_screenshooter, &tz_screenshooter_listener, NULL);
585 wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
589 /* LCOV_EXCL_START */
591 _cb_wl_reg_screenshooter_global_remove(void *data,
592 struct wl_registry *reg,
598 _cb_wl_tz_policy_conformant(void *data, struct tizen_policy *tizen_policy,
599 struct wl_surface *surface, uint32_t is_conformant)
604 _cb_wl_tz_policy_conformant_area(void *data, struct tizen_policy *tizen_policy,
605 struct wl_surface *surface, uint32_t conformant_part,
606 uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h)
612 _cb_wl_tz_policy_notification_done(void *data,
613 struct tizen_policy *tizen_policy,
614 struct wl_surface *surface,
618 Efl_Util_Wl_Surface_Lv_Info *lv_info;
620 lv_info = eina_hash_find(_eflutil.wl.policy.hash_noti_lv, &surface);
623 lv_info->level = level;
624 lv_info->wait_for_done = EINA_FALSE;
625 lv_info->state = state;
629 /* LCOV_EXCL_START */
631 _cb_wl_tz_policy_transient_for_done(void *data, struct tizen_policy *tizen_policy, uint32_t child_id)
637 _cb_wl_tz_policy_scr_mode_done(void *data,
638 struct tizen_policy *tizen_policy,
639 struct wl_surface *surface,
643 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
645 scr_mode_info = eina_hash_find(_eflutil.wl.policy.hash_scr_mode, &surface);
648 scr_mode_info->mode = mode;
649 scr_mode_info->wait_for_done = EINA_FALSE;
650 scr_mode_info->state = state;
654 /* LCOV_EXCL_START */
655 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)
659 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)
663 static void _cb_wl_tz_policy_allowed_aux_hint(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface_resource, int id)
667 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)
670 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)
676 _cb_wl_tz_display_policy_brightness_done(void *data,
677 struct tizen_display_policy *tizen_display_policy,
678 struct wl_surface *surface,
682 Efl_Util_Wl_Surface_Brightness_Info *brightness_info;
684 brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
687 brightness_info->brightness = brightness;
688 brightness_info->wait_for_done = EINA_FALSE;
689 brightness_info->state = state;
694 _cb_window_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
696 Efl_Util_Wl_Surface_Lv_Info *lv_info;
699 if (EINA_UNLIKELY(!lv_info))
702 eina_hash_del(_eflutil.wl.policy.hash_noti_lv, &lv_info->surface, lv_info);
706 efl_util_set_notification_window_level(Evas_Object *window,
707 efl_util_notification_level_e level)
711 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
712 EINA_SAFETY_ON_FALSE_RETURN_VAL((level >= EFL_UTIL_NOTIFICATION_LEVEL_NONE) &&
713 (level <= EFL_UTIL_NOTIFICATION_LEVEL_TOP),
714 EFL_UTIL_ERROR_INVALID_PARAMETER);
717 Ecore_Wl2_Window *wlwin;
718 struct wl_surface *surface;
719 Efl_Util_Wl_Surface_Lv_Info *lv_info;
720 Ecore_Wl2_Window_Type wl_type;
723 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
725 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
726 EINA_SAFETY_ON_NULL_RETURN_VAL(wlwin, EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
728 type = elm_win_type_get(window);
729 if (type != ELM_WIN_NOTIFICATION)
731 wl_type = ecore_wl2_window_type_get(wlwin);
732 EINA_SAFETY_ON_FALSE_RETURN_VAL((wl_type == ECORE_WL2_WINDOW_TYPE_NOTIFICATION),
733 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
736 while (!_eflutil.wl.policy.proto)
737 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
739 surface = ecore_wl2_window_surface_get(wlwin);
740 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
741 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
743 lv_info = eina_hash_find(_eflutil.wl.policy.hash_noti_lv, &surface);
746 lv_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Lv_Info));
747 EINA_SAFETY_ON_NULL_RETURN_VAL(lv_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
749 lv_info->surface = surface;
750 lv_info->level = (int)level;
751 lv_info->wait_for_done = EINA_TRUE;
752 lv_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
753 eina_hash_add(_eflutil.wl.policy.hash_noti_lv,
757 evas_object_event_callback_add(window, EVAS_CALLBACK_DEL,
758 _cb_window_del, lv_info);
762 lv_info->level = (int)level;
763 lv_info->wait_for_done = EINA_TRUE;
764 lv_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
768 tizen_policy_set_notification_level(_eflutil.wl.policy.proto,
769 surface, (int)level);
771 if (lv_info->wait_for_done)
774 while (lv_info->wait_for_done && (count < NUM_EVENT_WAIT_DONE_COUNT))
776 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
777 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
781 if (lv_info->wait_for_done)
783 return EFL_UTIL_ERROR_INVALID_PARAMETER;
787 if (lv_info->state == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
789 return EFL_UTIL_ERROR_PERMISSION_DENIED;
794 return EFL_UTIL_ERROR_NONE;
798 efl_util_get_notification_window_level(Evas_Object *window,
799 efl_util_notification_level_e *level)
803 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
804 EINA_SAFETY_ON_NULL_RETURN_VAL(level, EFL_UTIL_ERROR_INVALID_PARAMETER);
807 Ecore_Wl2_Window *wlwin;
808 struct wl_surface *surface;
809 Efl_Util_Wl_Surface_Lv_Info *lv_info;
810 Ecore_Wl2_Window_Type wl_type;
813 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
815 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
816 EINA_SAFETY_ON_NULL_RETURN_VAL(wlwin, EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
818 type = elm_win_type_get(window);
819 if (type != ELM_WIN_NOTIFICATION)
821 wl_type = ecore_wl2_window_type_get(wlwin);
822 EINA_SAFETY_ON_FALSE_RETURN_VAL((wl_type == ECORE_WL2_WINDOW_TYPE_NOTIFICATION),
823 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
826 while (!_eflutil.wl.policy.proto)
827 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
829 surface = ecore_wl2_window_surface_get(wlwin);
830 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
831 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
833 lv_info = eina_hash_find(_eflutil.wl.policy.hash_noti_lv, &surface);
836 if (lv_info->wait_for_done)
839 while ((lv_info->wait_for_done) && (count < NUM_EVENT_WAIT_DONE_COUNT))
841 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
842 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
846 if (lv_info->wait_for_done)
848 *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
849 return EFL_UTIL_ERROR_INVALID_PARAMETER;
853 switch (lv_info->level)
855 case TIZEN_POLICY_LEVEL_NONE: *level = EFL_UTIL_NOTIFICATION_LEVEL_NONE; break;
856 case TIZEN_POLICY_LEVEL_DEFAULT: *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT; break;
857 case TIZEN_POLICY_LEVEL_MEDIUM: *level = EFL_UTIL_NOTIFICATION_LEVEL_MEDIUM; break;
858 case TIZEN_POLICY_LEVEL_HIGH: *level = EFL_UTIL_NOTIFICATION_LEVEL_HIGH; break;
859 case TIZEN_POLICY_LEVEL_TOP: *level = EFL_UTIL_NOTIFICATION_LEVEL_TOP; break;
860 default: *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
861 return EFL_UTIL_ERROR_INVALID_PARAMETER;
863 return EFL_UTIL_ERROR_NONE;
866 *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
868 return EFL_UTIL_ERROR_NONE;
872 efl_util_set_window_opaque_state(Evas_Object *window,
877 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
878 EINA_SAFETY_ON_FALSE_RETURN_VAL(((opaque >= 0) && (opaque <= 1)),
879 EFL_UTIL_ERROR_INVALID_PARAMETER);
881 Ecore_Wl2_Window *wlwin;
882 struct wl_surface *surface;
884 if (!_eflutil.wl.policy.proto)
889 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
891 while (!_eflutil.wl.policy.proto && ret != -1)
892 ret = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
894 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.policy.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
897 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
899 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
901 surface = ecore_wl2_window_surface_get(wlwin);
903 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
905 tizen_policy_set_opaque_state(_eflutil.wl.policy.proto, surface, opaque);
907 return EFL_UTIL_ERROR_NONE;
911 efl_util_set_window_screen_mode(Evas_Object *window,
912 efl_util_screen_mode_e mode)
914 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
915 EINA_SAFETY_ON_FALSE_RETURN_VAL(((mode >= EFL_UTIL_SCREEN_MODE_DEFAULT) &&
916 (mode <= EFL_UTIL_SCREEN_MODE_ALWAYS_ON)),
917 EFL_UTIL_ERROR_INVALID_PARAMETER);
919 Ecore_Wl2_Window *wlwin;
920 struct wl_surface *surface;
921 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
925 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
927 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
930 while (!_eflutil.wl.policy.proto)
931 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
933 surface = ecore_wl2_window_surface_get(wlwin);
934 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
935 EFL_UTIL_ERROR_INVALID_PARAMETER);
937 scr_mode_info = eina_hash_find(_eflutil.wl.policy.hash_scr_mode, &surface);
940 scr_mode_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Scr_Mode_Info));
941 EINA_SAFETY_ON_NULL_RETURN_VAL(scr_mode_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
943 scr_mode_info->surface = surface;
944 scr_mode_info->mode = (unsigned int)mode;
945 scr_mode_info->wait_for_done = EINA_TRUE;
946 scr_mode_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
948 eina_hash_add(_eflutil.wl.policy.hash_scr_mode,
954 scr_mode_info->mode = (unsigned int)mode;
955 scr_mode_info->wait_for_done = EINA_TRUE;
956 scr_mode_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
959 tizen_policy_set_window_screen_mode(_eflutil.wl.policy.proto,
960 surface, (unsigned int)mode);
961 if (scr_mode_info->wait_for_done)
964 while (scr_mode_info->wait_for_done && (count < NUM_EVENT_WAIT_DONE_COUNT))
966 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
967 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
971 if (scr_mode_info->wait_for_done)
973 return EFL_UTIL_ERROR_INVALID_PARAMETER;
977 if (scr_mode_info->state == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
979 return EFL_UTIL_ERROR_PERMISSION_DENIED;
984 return EFL_UTIL_ERROR_NONE;
987 return EFL_UTIL_ERROR_INVALID_PARAMETER;
991 efl_util_get_window_screen_mode(Evas_Object *window,
992 efl_util_screen_mode_e *mode)
994 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
995 EINA_SAFETY_ON_NULL_RETURN_VAL(mode, EFL_UTIL_ERROR_INVALID_PARAMETER);
997 Ecore_Wl2_Window *wlwin;
998 struct wl_surface *surface;
999 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
1003 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1005 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
1008 while (!_eflutil.wl.policy.proto)
1009 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1011 surface = ecore_wl2_window_surface_get(wlwin);
1012 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1013 EFL_UTIL_ERROR_INVALID_PARAMETER);
1015 scr_mode_info = eina_hash_find(_eflutil.wl.policy.hash_scr_mode, &surface);
1018 if (scr_mode_info->wait_for_done)
1020 while (scr_mode_info->wait_for_done)
1022 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
1023 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1027 switch (scr_mode_info->mode)
1029 case TIZEN_POLICY_MODE_DEFAULT: *mode = EFL_UTIL_SCREEN_MODE_DEFAULT; break;
1030 case TIZEN_POLICY_MODE_ALWAYS_ON: *mode = EFL_UTIL_SCREEN_MODE_ALWAYS_ON; break;
1031 default: *mode = EFL_UTIL_SCREEN_MODE_DEFAULT;
1032 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1034 return EFL_UTIL_ERROR_NONE;
1038 *mode = EFL_UTIL_SCREEN_MODE_DEFAULT;
1039 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1043 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1047 efl_util_set_window_brightness(Evas_Object *window, int brightness)
1049 Ecore_Wl2_Window *wlwin;
1050 struct wl_surface *surface;
1051 Efl_Util_Wl_Surface_Brightness_Info *brightness_info;
1054 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1055 EINA_SAFETY_ON_FALSE_RETURN_VAL(brightness <= 100, EFL_UTIL_ERROR_INVALID_PARAMETER);
1058 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1060 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
1063 while (!_eflutil.wl.display_policy.proto)
1064 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1066 surface = ecore_wl2_window_surface_get(wlwin);
1067 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1068 EFL_UTIL_ERROR_INVALID_PARAMETER);
1070 brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
1071 if (!brightness_info)
1073 brightness_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Brightness_Info));
1074 EINA_SAFETY_ON_NULL_RETURN_VAL(brightness_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
1076 brightness_info->surface = surface;
1077 brightness_info->brightness = brightness;
1078 brightness_info->wait_for_done = EINA_TRUE;
1079 brightness_info->state = TIZEN_DISPLAY_POLICY_ERROR_STATE_NONE;
1081 eina_hash_add(_eflutil.wl.display_policy.hash_brightness,
1087 brightness_info->brightness = brightness;
1088 brightness_info->wait_for_done = EINA_TRUE;
1089 brightness_info->state = TIZEN_DISPLAY_POLICY_ERROR_STATE_NONE;
1092 tizen_display_policy_set_window_brightness(_eflutil.wl.display_policy.proto,
1093 surface, brightness);
1094 if (brightness_info->wait_for_done)
1097 while (brightness_info->wait_for_done && (count < NUM_EVENT_WAIT_DONE_COUNT))
1099 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
1100 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1104 if (brightness_info->wait_for_done)
1106 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1110 if (brightness_info->state == TIZEN_DISPLAY_POLICY_ERROR_STATE_PERMISSION_DENIED)
1112 return EFL_UTIL_ERROR_PERMISSION_DENIED;
1116 return EFL_UTIL_ERROR_NONE;
1119 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1123 efl_util_get_window_brightness(Evas_Object *window, int *brightness)
1125 Ecore_Wl2_Window *wlwin;
1126 struct wl_surface *surface;
1127 Efl_Util_Wl_Surface_Brightness_Info *brightness_info;
1130 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1131 EINA_SAFETY_ON_NULL_RETURN_VAL(brightness, EFL_UTIL_ERROR_INVALID_PARAMETER);
1134 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1136 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
1137 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
1139 while (!_eflutil.wl.display_policy.proto)
1140 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1142 surface = ecore_wl2_window_surface_get(wlwin);
1143 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1144 EFL_UTIL_ERROR_INVALID_PARAMETER);
1146 brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
1147 if (brightness_info)
1149 if (brightness_info->wait_for_done)
1151 while (brightness_info->wait_for_done)
1153 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
1154 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1157 *brightness = brightness_info->brightness;
1162 return EFL_UTIL_ERROR_NONE;
1166 struct _efl_util_inputgen_h
1168 unsigned int init_type;
1170 E_Devicemgr_Inputgen_Touch_Axis *axis_info;
1173 /* LCOV_EXCL_STOP */
1176 _cb_device_add(void *data EINA_UNUSED,
1177 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1178 uint32_t serial EINA_UNUSED,
1179 const char *identifier EINA_UNUSED,
1180 struct tizen_input_device *device,
1181 struct wl_seat *seat EINA_UNUSED)
1187 _cb_device_remove(void *data EINA_UNUSED,
1188 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1189 uint32_t serial EINA_UNUSED,
1190 const char *identifier EINA_UNUSED,
1191 struct tizen_input_device *device,
1192 struct wl_seat *seat EINA_UNUSED)
1198 _cb_error(void *data EINA_UNUSED,
1199 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1202 _eflutil.wl.devmgr.request_notified = errorcode;
1205 /* LCOV_EXCL_START */
1207 _cb_block_expired(void *data EINA_UNUSED,
1208 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED)
1212 /* LCOV_EXCL_STOP */
1215 _cb_max_touch_count(void *data EINA_UNUSED,
1216 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1217 uint32_t serial EINA_UNUSED,
1219 struct wl_seat *seat EINA_UNUSED)
1221 _eflutil.wl.devmgr.max_touch_count = max_count;
1224 static efl_util_error_e
1225 _efl_util_input_convert_input_generator_error(int ret)
1229 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE:
1230 return EFL_UTIL_ERROR_NONE;
1231 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NO_PERMISSION:
1232 return EFL_UTIL_ERROR_PERMISSION_DENIED;
1233 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NO_SYSTEM_RESOURCES:
1234 return EFL_UTIL_ERROR_OUT_OF_MEMORY;
1235 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_INVALID_PARAMETER:
1236 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1237 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NOT_ALLOWED:
1238 return EFL_UTIL_ERROR_NO_RESOURCE_AVAILABLE;
1240 return EFL_UTIL_ERROR_NONE;
1244 static efl_util_inputgen_h
1245 _efl_util_input_create_inputgen(unsigned int dev_type, const char *name, int *ret, int with_name)
1247 efl_util_inputgen_h inputgen_h = NULL;
1248 unsigned int clas = 0x0;
1251 dev_type & ~(EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN
1252 | EFL_UTIL_INPUT_DEVTYPE_KEYBOARD
1253 | EFL_UTIL_INPUT_DEVTYPE_POINTER))
1255 set_last_result(EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1259 inputgen_h = (efl_util_inputgen_h)calloc(1, sizeof(struct _efl_util_inputgen_h));
1262 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
1266 inputgen_h->init_type |= dev_type;
1269 if (name) strncpy(inputgen_h->name, name, 31);
1270 else strncpy(inputgen_h->name, "Input Generator", 31);
1274 if (*ret == (int)EINA_FALSE)
1276 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1280 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN)
1281 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
1282 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD)
1283 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD;
1284 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_POINTER)
1285 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE;
1287 while (!_eflutil.wl.devmgr.devicemgr)
1288 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1291 tizen_input_device_manager_init_generator_with_sync(_eflutil.wl.devmgr.devicemgr, clas, inputgen_h->name);
1292 else if (with_name == 1)
1293 tizen_input_device_manager_init_generator_with_name(_eflutil.wl.devmgr.devicemgr, clas, inputgen_h->name);
1295 tizen_input_device_manager_init_generator(_eflutil.wl.devmgr.devicemgr, clas);
1298 while (_eflutil.wl.devmgr.request_notified == -1)
1299 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1301 *ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1302 _eflutil.wl.devmgr.request_notified = -1;
1304 set_last_result(*ret);
1305 if (*ret != TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE)
1319 API efl_util_inputgen_h
1320 efl_util_input_initialize_generator(unsigned int dev_type)
1322 int ret = EFL_UTIL_ERROR_NONE;
1323 efl_util_inputgen_h inputgen_h = NULL;
1325 inputgen_h = _efl_util_input_create_inputgen(dev_type, NULL, &ret, 0);
1332 API efl_util_inputgen_h
1333 efl_util_input_initialize_generator_with_name(unsigned int dev_type, const char *name)
1335 int ret = EFL_UTIL_ERROR_NONE;
1336 efl_util_inputgen_h inputgen_h = NULL;
1338 inputgen_h = _efl_util_input_create_inputgen(dev_type, name, &ret, 1);
1345 API efl_util_inputgen_h
1346 efl_util_input_initialize_generator_with_sync(unsigned int dev_type, const char *name)
1348 int ret = EFL_UTIL_ERROR_NONE;
1349 efl_util_inputgen_h inputgen_h = NULL;
1351 inputgen_h = _efl_util_input_create_inputgen(dev_type, name, &ret, 2);
1359 efl_util_input_set_touch_count(int max_count)
1361 int ret = EFL_UTIL_ERROR_NONE;
1364 if (ret == (int)EINA_FALSE)
1366 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1369 while (!_eflutil.wl.devmgr.devicemgr)
1370 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1372 if (_eflutil.wl.devmgr.max_touch_count >= max_count)
1373 return EFL_UTIL_ERROR_NONE;
1375 tizen_input_device_manager_set_touch_count(_eflutil.wl.devmgr.devicemgr, max_count);
1377 while (_eflutil.wl.devmgr.request_notified == -1)
1378 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1380 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1381 _eflutil.wl.devmgr.request_notified = -1;
1383 if (ret == EFL_UTIL_ERROR_NONE)
1385 _eflutil.wl.devmgr.request_touch_count = max_count;
1392 efl_util_input_deinitialize_generator(efl_util_inputgen_h inputgen_h)
1394 int ret = EFL_UTIL_ERROR_NONE;
1395 unsigned int clas = 0x0;
1396 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1398 if (inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN)
1399 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
1400 if (inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD)
1401 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD;
1402 if (inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_POINTER)
1403 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE;
1405 if (inputgen_h->axis_info)
1406 free(inputgen_h->axis_info);
1411 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1413 tizen_input_device_manager_deinit_generator(_eflutil.wl.devmgr.devicemgr, clas);
1415 while (_eflutil.wl.devmgr.request_notified == -1)
1416 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1418 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1419 _eflutil.wl.devmgr.request_notified = -1;
1425 efl_util_input_generate_key(efl_util_inputgen_h inputgen_h, const char *key_name, int pressed)
1427 int ret = EFL_UTIL_ERROR_NONE;
1429 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1430 EINA_SAFETY_ON_NULL_RETURN_VAL(key_name, EFL_UTIL_ERROR_INVALID_PARAMETER);
1431 EINA_SAFETY_ON_FALSE_RETURN_VAL(pressed == 0 || pressed == 1, EFL_UTIL_ERROR_INVALID_PARAMETER);
1432 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1434 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1436 tizen_input_device_manager_generate_key(_eflutil.wl.devmgr.devicemgr, key_name, pressed);
1438 while (_eflutil.wl.devmgr.request_notified == -1)
1439 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1441 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1442 _eflutil.wl.devmgr.request_notified = -1;
1448 efl_util_input_generate_touch(efl_util_inputgen_h inputgen_h, int idx,
1449 efl_util_input_touch_type_e touch_type, int x, int y)
1452 enum tizen_input_device_manager_pointer_event_type type;
1454 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1455 EINA_SAFETY_ON_FALSE_RETURN_VAL(idx >= 0, EFL_UTIL_ERROR_INVALID_PARAMETER);
1456 EINA_SAFETY_ON_FALSE_RETURN_VAL((x > 0 && y > 0), EFL_UTIL_ERROR_INVALID_PARAMETER);
1457 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1459 if (_eflutil.wl.devmgr.request_touch_count != 0 &&
1460 _eflutil.wl.devmgr.max_touch_count != _eflutil.wl.devmgr.request_touch_count)
1461 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1463 if (idx >= _eflutil.wl.devmgr.max_touch_count)
1464 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1466 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1470 case EFL_UTIL_INPUT_TOUCH_BEGIN:
1471 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_BEGIN;
1473 case EFL_UTIL_INPUT_TOUCH_UPDATE:
1474 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_UPDATE;
1476 case EFL_UTIL_INPUT_TOUCH_END:
1477 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_END;
1480 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1483 tizen_input_device_manager_generate_touch(_eflutil.wl.devmgr.devicemgr, type, x, y, idx);
1485 while (_eflutil.wl.devmgr.request_notified == -1)
1486 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1488 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1489 _eflutil.wl.devmgr.request_notified = -1;
1495 _efl_util_input_generate_touch_axis_send(unsigned int type, double value)
1499 tizen_input_device_manager_generate_axis(_eflutil.wl.devmgr.devicemgr, type, wl_fixed_from_double(value));
1501 while (_eflutil.wl.devmgr.request_notified == -1)
1502 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1504 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1505 _eflutil.wl.devmgr.request_notified = -1;
1511 _efl_util_input_generate_touch_axis_cleanup(efl_util_inputgen_h inputgen_h, int idx)
1516 inputgen_h->axis_info[idx].radius_x = 1.0;
1517 inputgen_h->axis_info[idx].radius_y = 1.0;
1518 inputgen_h->axis_info[idx].pressure = 1.0;
1519 inputgen_h->axis_info[idx].angle = 0.0;
1520 inputgen_h->axis_info[idx].palm = 0.0;
1524 for (i = 0; i < EFL_UTIL_INPUT_GENERATOR_TOUCH_MAX_FINGER; i++)
1526 inputgen_h->axis_info[i].radius_x = 1.0;
1527 inputgen_h->axis_info[i].radius_y = 1.0;
1528 inputgen_h->axis_info[i].pressure = 1.0;
1529 inputgen_h->axis_info[i].angle = 0.0;
1530 inputgen_h->axis_info[i].palm = 0.0;
1536 _efl_util_input_generate_touch_axis_process(efl_util_inputgen_h inputgen_h, int idx, double radius_x,
1537 double radius_y, double pressure, double angle, double palm)
1539 int ret = EFL_UTIL_ERROR_NONE;
1541 if (!inputgen_h->axis_info)
1543 inputgen_h->axis_info = calloc(EFL_UTIL_INPUT_GENERATOR_TOUCH_MAX_FINGER,
1544 sizeof(E_Devicemgr_Inputgen_Touch_Axis));
1545 _efl_util_input_generate_touch_axis_cleanup(inputgen_h, -1);
1548 if (inputgen_h->axis_info[idx].radius_x != radius_x)
1550 ret = _efl_util_input_generate_touch_axis_send(TIZEN_INPUT_DEVICE_MANAGER_AXIS_TYPE_RADIUS_X, radius_x);
1551 if (ret != EFL_UTIL_ERROR_NONE) return ret;
1552 inputgen_h->axis_info[idx].radius_x = radius_x;
1554 if (inputgen_h->axis_info[idx].radius_y != radius_y)
1556 ret = _efl_util_input_generate_touch_axis_send(TIZEN_INPUT_DEVICE_MANAGER_AXIS_TYPE_RADIUS_Y, radius_y);
1557 if (ret != EFL_UTIL_ERROR_NONE) return ret;
1558 inputgen_h->axis_info[idx].radius_y = radius_y;
1560 if (inputgen_h->axis_info[idx].pressure != pressure)
1562 ret = _efl_util_input_generate_touch_axis_send(TIZEN_INPUT_DEVICE_MANAGER_AXIS_TYPE_PRESSURE, pressure);
1563 if (ret != EFL_UTIL_ERROR_NONE) return ret;
1564 inputgen_h->axis_info[idx].pressure = pressure;
1566 if (inputgen_h->axis_info[idx].angle != angle)
1568 ret = _efl_util_input_generate_touch_axis_send(TIZEN_INPUT_DEVICE_MANAGER_AXIS_TYPE_ANGLE, angle);
1569 if (ret != EFL_UTIL_ERROR_NONE) return ret;
1570 inputgen_h->axis_info[idx].angle = angle;
1572 if (inputgen_h->axis_info[idx].palm != palm)
1574 ret = _efl_util_input_generate_touch_axis_send(TIZEN_INPUT_DEVICE_MANAGER_AXIS_TYPE_PALM, palm);
1575 if (ret != EFL_UTIL_ERROR_NONE) return ret;
1576 inputgen_h->axis_info[idx].palm = palm;
1583 efl_util_input_generate_touch_axis(efl_util_inputgen_h inputgen_h, int idx,
1584 efl_util_input_touch_type_e touch_type, int x, int y,
1585 double radius_x, double radius_y,
1586 double pressure, double angle, double palm)
1589 enum tizen_input_device_manager_pointer_event_type type;
1591 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1592 EINA_SAFETY_ON_FALSE_RETURN_VAL(idx >= 0, EFL_UTIL_ERROR_INVALID_PARAMETER);
1593 EINA_SAFETY_ON_FALSE_RETURN_VAL((x >= 0 && y >= 0), EFL_UTIL_ERROR_INVALID_PARAMETER);
1594 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1595 EINA_SAFETY_ON_FALSE_RETURN_VAL((radius_x >= 0.0 && radius_y >= 0.0), EFL_UTIL_ERROR_INVALID_PARAMETER);
1596 EINA_SAFETY_ON_FALSE_RETURN_VAL((pressure >= 0.0 && palm >= 0.0), EFL_UTIL_ERROR_INVALID_PARAMETER);
1598 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1599 version = tizen_input_device_manager_get_version(_eflutil.wl.devmgr.devicemgr);
1600 EINA_SAFETY_ON_FALSE_RETURN_VAL((version >= 3), EFL_UTIL_ERROR_NOT_SUPPORTED);
1604 case EFL_UTIL_INPUT_TOUCH_BEGIN:
1605 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_BEGIN;
1607 case EFL_UTIL_INPUT_TOUCH_UPDATE:
1608 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_UPDATE;
1610 case EFL_UTIL_INPUT_TOUCH_END:
1611 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_END;
1614 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1617 if (touch_type != EFL_UTIL_INPUT_TOUCH_END)
1618 _efl_util_input_generate_touch_axis_process(inputgen_h, idx, radius_x, radius_y, pressure, angle, palm);
1620 _efl_util_input_generate_touch_axis_cleanup(inputgen_h, idx);
1622 tizen_input_device_manager_generate_touch(_eflutil.wl.devmgr.devicemgr, type, x, y, idx);
1624 while (_eflutil.wl.devmgr.request_notified == -1)
1625 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1627 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1628 _eflutil.wl.devmgr.request_notified = -1;
1635 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)
1638 enum tizen_input_device_manager_pointer_event_type type;
1640 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1641 EINA_SAFETY_ON_FALSE_RETURN_VAL(buttons > 0, EFL_UTIL_ERROR_INVALID_PARAMETER);
1642 EINA_SAFETY_ON_FALSE_RETURN_VAL((x >= 0 && y >= 0), EFL_UTIL_ERROR_INVALID_PARAMETER);
1643 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_POINTER, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1645 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1647 switch(pointer_type)
1649 case EFL_UTIL_INPUT_POINTER_BUTTON_DOWN:
1650 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_BEGIN;
1652 case EFL_UTIL_INPUT_POINTER_MOVE:
1653 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_UPDATE;
1655 case EFL_UTIL_INPUT_POINTER_BUTTON_UP:
1656 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_END;
1659 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1662 tizen_input_device_manager_generate_pointer(_eflutil.wl.devmgr.devicemgr, type, x, y, buttons);
1664 while (_eflutil.wl.devmgr.request_notified == -1)
1665 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1667 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1668 _eflutil.wl.devmgr.request_notified = -1;
1674 efl_util_input_generate_wheel(efl_util_inputgen_h inputgen_h, efl_util_input_pointer_wheel_type_e wheel_type, int value)
1677 enum tizen_input_device_manager_pointer_event_type type;
1679 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1680 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_POINTER, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1682 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1683 version = tizen_input_device_manager_get_version(_eflutil.wl.devmgr.devicemgr);
1684 EINA_SAFETY_ON_FALSE_RETURN_VAL((version >= 3), EFL_UTIL_ERROR_NOT_SUPPORTED);
1688 case EFL_UTIL_INPUT_POINTER_WHEEL_VERT:
1689 type = TIZEN_INPUT_DEVICE_MANAGER_AXIS_TYPE_WHEEL;
1691 case EFL_UTIL_INPUT_POINTER_WHEEL_HORZ:
1692 type = TIZEN_INPUT_DEVICE_MANAGER_AXIS_TYPE_HWHEEL;
1695 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1698 tizen_input_device_manager_generate_axis(_eflutil.wl.devmgr.devicemgr, type, wl_fixed_from_int(value));
1700 while (_eflutil.wl.devmgr.request_notified == -1)
1701 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1703 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1704 _eflutil.wl.devmgr.request_notified = -1;
1711 struct _efl_util_screenshot_h
1716 Eina_Bool shot_done;
1721 Eina_Bool auto_rotation;
1724 /* scrrenshot handle */
1725 static efl_util_screenshot_h g_screenshot;
1726 static Eina_Bool shot_mutex_init;
1727 static pthread_mutex_t shot_lock;
1730 _screenshot_mutex_init(void)
1732 if (shot_mutex_init)
1735 if (pthread_mutex_init(&shot_lock, NULL))
1737 fprintf(stderr, "[screenshot] fail: mutex init"); /*LCOV_EXCL_LINE*/
1738 return EINA_FALSE; /*LCOV_EXCL_LINE*/
1741 shot_mutex_init = EINA_TRUE;
1747 _screenshot_mutex_destory(void)
1749 if (!shot_mutex_init)
1752 if (pthread_mutex_destroy(&shot_lock))
1754 fprintf(stderr, "[screenshot] fail: mutex destory"); /*LCOV_EXCL_LINE*/
1755 return EINA_FALSE; /*LCOV_EXCL_LINE*/
1758 shot_mutex_init = EINA_FALSE;
1764 _screenshot_mutex_lock(void)
1766 if (!_screenshot_mutex_init())
1769 pthread_mutex_lock(&shot_lock);
1773 _screenshot_mutex_unlock(void)
1775 pthread_mutex_unlock(&shot_lock);
1779 _efl_util_wl_screenshooter_init()
1781 struct wl_display *display_wrapper = NULL;
1782 struct wl_registry *registry = NULL;
1785 if (_wl_init() == EINA_FALSE)
1788 wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1790 display_wrapper = wl_proxy_create_wrapper(_eflutil.wl.dpy);
1791 EINA_SAFETY_ON_NULL_RETURN_VAL(display_wrapper, EINA_FALSE);
1793 _eflutil.wl.shot.queue = wl_display_create_queue(_eflutil.wl.dpy);
1794 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.queue, fail_create_queue);
1796 wl_proxy_set_queue((struct wl_proxy *)display_wrapper, _eflutil.wl.shot.queue);
1798 registry = wl_display_get_registry(display_wrapper);
1799 EINA_SAFETY_ON_NULL_GOTO(registry, fail_get_registry);
1801 wl_registry_add_listener(registry, &_wl_reg_screenshooter_listener, NULL);
1803 ret = wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
1804 EINA_SAFETY_ON_TRUE_GOTO(ret == -1, fail_roundtrip);
1805 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.tz_screenshooter, fail_roundtrip);
1807 _eflutil.wl.shot.tbm_client = wayland_tbm_client_init(_eflutil.wl.dpy);
1808 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.tbm_client, fail_tbm_client_init);
1810 wl_registry_destroy(registry);
1811 wl_proxy_wrapper_destroy(display_wrapper);
1813 if (_eflutil.wl.shot.noti == 0)
1815 fprintf(stderr, "[screenshot] fail: privilege error\n"); /* LCOV_EXCL_LINE */
1821 fail_tbm_client_init:
1822 tizen_screenshooter_destroy(_eflutil.wl.shot.tz_screenshooter);
1823 _eflutil.wl.shot.tz_screenshooter = NULL;
1825 wl_registry_destroy(registry);
1827 wl_event_queue_destroy(_eflutil.wl.shot.queue);
1828 _eflutil.wl.shot.queue = NULL;
1830 wl_proxy_wrapper_destroy(display_wrapper);
1836 _efl_util_wl_screenshooter_deinit()
1838 if (_eflutil.wl.shot.tbm_client)
1840 wayland_tbm_client_deinit(_eflutil.wl.shot.tbm_client);
1841 _eflutil.wl.shot.tbm_client = NULL;
1844 if (_eflutil.wl.shot.tz_screenshooter)
1846 tizen_screenshooter_destroy(_eflutil.wl.shot.tz_screenshooter);
1847 _eflutil.wl.shot.tz_screenshooter = NULL;
1850 if (_eflutil.wl.shot.queue)
1852 wl_event_queue_destroy(_eflutil.wl.shot.queue);
1853 _eflutil.wl.shot.queue = NULL;
1857 API efl_util_screenshot_h
1858 efl_util_screenshot_initialize(int width, int height)
1860 efl_util_screenshot_h screenshot = NULL;
1862 if (width <= 0 || height <= 0)
1864 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1868 _screenshot_mutex_lock();
1872 if (g_screenshot->width != width || g_screenshot->height != height)
1874 g_screenshot->width = width;
1875 g_screenshot->height = height;
1877 set_last_result(EFL_UTIL_ERROR_NONE);
1879 _screenshot_mutex_unlock();
1881 return g_screenshot;
1884 screenshot = calloc(1, sizeof(struct _efl_util_screenshot_h));
1885 if (screenshot == NULL)
1887 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
1889 _screenshot_mutex_unlock();
1894 if (!_eflutil.wl.shot.tz_screenshooter)
1896 if (_efl_util_wl_screenshooter_init() == EINA_FALSE)
1898 if (_eflutil.wl.shot.noti == 0)
1899 set_last_result(EFL_UTIL_ERROR_PERMISSION_DENIED);
1901 set_last_result(EFL_UTIL_ERROR_SCREENSHOT_INIT_FAIL);
1905 _screenshot_mutex_unlock();
1911 screenshot->width = width;
1912 screenshot->height = height;
1913 screenshot->auto_rotation = EINA_TRUE;
1915 screenshot->bufmgr = wayland_tbm_client_get_bufmgr(_eflutil.wl.shot.tbm_client);
1916 EINA_SAFETY_ON_NULL_GOTO(screenshot->bufmgr, fail_get_bufmgr);
1918 g_screenshot = screenshot;
1919 set_last_result(EFL_UTIL_ERROR_NONE);
1921 tizen_screenshooter_set_user_data(_eflutil.wl.shot.tz_screenshooter, &screenshot->shot_done);
1923 _screenshot_mutex_unlock();
1925 return g_screenshot;
1927 /* LCOV_EXCL_START */
1929 set_last_result(EFL_UTIL_ERROR_SCREENSHOT_INIT_FAIL);
1930 _screenshot_mutex_unlock();
1931 efl_util_screenshot_deinitialize(screenshot);
1934 /* LCOV_EXCL_STOP */
1938 efl_util_screenshot_deinitialize(efl_util_screenshot_h screenshot)
1940 _screenshot_mutex_lock();
1944 _screenshot_mutex_unlock();
1945 _screenshot_mutex_destory();
1946 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1950 g_screenshot = NULL;
1952 _efl_util_wl_screenshooter_deinit();
1954 _screenshot_mutex_unlock();
1955 _screenshot_mutex_destory();
1957 return EFL_UTIL_ERROR_NONE;
1962 efl_util_screenshot_take_tbm_surface(efl_util_screenshot_h screenshot)
1964 tbm_surface_h t_surface = NULL;
1965 struct wl_buffer *buffer = NULL;
1966 Efl_Util_Wl_Output_Info *output;
1969 _screenshot_mutex_lock();
1971 if (!screenshot || (screenshot != g_screenshot))
1973 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1974 _screenshot_mutex_unlock();
1978 output = eina_list_nth(_eflutil.wl.shot.output_list, 0);
1981 fprintf(stderr, "[screenshot] fail: no output for screenshot\n"); /* LCOV_EXCL_LINE */
1985 t_surface = tbm_surface_create(screenshot->width, screenshot->height, TBM_FORMAT_XRGB8888);
1988 fprintf(stderr, "[screenshot] fail: tbm_surface_create\n"); /* LCOV_EXCL_LINE */
1992 buffer = wayland_tbm_client_create_buffer(_eflutil.wl.shot.tbm_client, t_surface);
1995 fprintf(stderr, "[screenshot] fail: create wl_buffer for screenshot\n"); /* LCOV_EXCL_LINE */
1999 tizen_screenshooter_shoot(_eflutil.wl.shot.tz_screenshooter, output->output, buffer);
2001 screenshot->shot_done = EINA_FALSE;
2003 while (!screenshot->shot_done && ret != -1)
2004 ret = wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
2008 fprintf(stderr, "[screenshot] fail: tizen_screenshooter_shoot\n"); /* LCOV_EXCL_LINE */
2012 wayland_tbm_client_destroy_buffer(_eflutil.wl.shot.tbm_client, buffer);
2014 /* reset shot_done for next screenshot */
2015 screenshot->shot_done = EINA_FALSE;
2017 set_last_result(EFL_UTIL_ERROR_NONE);
2019 _screenshot_mutex_unlock();
2025 tbm_surface_destroy(t_surface);
2027 wayland_tbm_client_destroy_buffer(_eflutil.wl.shot.tbm_client, buffer);
2029 set_last_result(EFL_UTIL_ERROR_SCREENSHOT_EXECUTION_FAIL);
2031 _screenshot_mutex_unlock();
2037 efl_util_screenshot_set_auto_rotation(efl_util_screenshot_h screenshot, int set)
2039 if (!screenshot || (screenshot != g_screenshot))
2040 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2042 if (!(set == 0 || set == 1))
2043 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2046 g_screenshot->auto_rotation = EINA_TRUE;
2048 g_screenshot->auto_rotation = EINA_FALSE;
2050 tizen_screenshooter_set_oneshot_auto_rotation(_eflutil.wl.shot.tz_screenshooter, g_screenshot->auto_rotation);
2052 return EFL_UTIL_ERROR_NONE;
2056 efl_util_screenshot_get_auto_rotation(efl_util_screenshot_h screenshot, int *set)
2058 if (!screenshot || (screenshot != g_screenshot) || !set)
2059 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2061 *set = g_screenshot->auto_rotation;
2063 return EFL_UTIL_ERROR_NONE;
2066 /* LCOV_EXCL_START */
2067 struct _efl_util_screenmirror_h
2069 struct tizen_screenmirror *tz_screenmirror;
2075 Eina_List *buffer_list;
2077 Eina_Bool mirror_working;
2080 Eina_Bool cb_content;
2081 efl_util_screenmirror_handler user_func;
2085 typedef struct _efl_util_mirror_buffer efl_util_mirror_buffer;
2086 struct _efl_util_mirror_buffer
2088 struct wl_buffer *buffer;
2090 tbm_surface_h t_surface;
2093 static efl_util_screenmirror_h g_screenmirror;
2096 _efl_util_screenmirror_loop(void *data)
2098 efl_util_screenmirror_h screenmirror;
2101 screenmirror = (efl_util_screenmirror_h)data;
2105 if (!screenmirror->mirror_working)
2108 ret = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
2111 fprintf(stderr, "[screenmirror] fail: dispatch_queue\n");
2119 static efl_util_mirror_buffer *
2120 _efl_util_create_mirror_buffer(efl_util_screenmirror_h screenmirror)
2122 efl_util_mirror_buffer *mbuffer;
2124 mbuffer = calloc(1, sizeof(struct _efl_util_mirror_buffer));
2125 EINA_SAFETY_ON_NULL_RETURN_VAL(mbuffer, NULL);
2127 mbuffer->w = screenmirror->width;
2128 mbuffer->h = screenmirror->height;
2130 mbuffer->t_surface = tbm_surface_internal_create_with_flags(mbuffer->w,
2131 mbuffer->h, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT);
2132 EINA_SAFETY_ON_NULL_GOTO(mbuffer->t_surface, fail_create_surface);
2134 mbuffer->buffer = wayland_tbm_client_create_buffer(_eflutil.wl.shot.tbm_client, mbuffer->t_surface);
2135 EINA_SAFETY_ON_NULL_GOTO(mbuffer->buffer, fail_create_buffer);
2140 tbm_surface_destroy(mbuffer->t_surface);
2141 fail_create_surface:
2148 _efl_util_destroy_mirror_buffer(efl_util_mirror_buffer *mbuffer)
2150 EINA_SAFETY_ON_NULL_RETURN(mbuffer);
2152 if (mbuffer->buffer)
2153 wl_buffer_destroy(mbuffer->buffer);
2159 _efl_util_screenmirror_handle_dequeued(void *data,
2160 struct tizen_screenmirror *tz_screenmirror, struct wl_buffer *buffer)
2162 efl_util_screenmirror_h screenmirror;
2163 efl_util_mirror_buffer *mbuffer;
2166 screenmirror = (efl_util_screenmirror_h)data;
2167 screenmirror->cb_start = EINA_TRUE;
2169 EINA_LIST_FOREACH_SAFE(screenmirror->buffer_list, l, ll, mbuffer)
2171 if (mbuffer->buffer == buffer)
2173 if (mbuffer->w != screenmirror->width || mbuffer->h != screenmirror->height ||
2174 !screenmirror->mirror_working)
2175 tbm_surface_destroy(mbuffer->t_surface);
2177 screenmirror->user_func(screenmirror, mbuffer->t_surface, screenmirror->user_data);
2179 screenmirror->buffer_list = eina_list_remove_list(screenmirror->buffer_list, l);
2180 _efl_util_destroy_mirror_buffer(mbuffer);
2186 mbuffer = _efl_util_create_mirror_buffer(screenmirror);
2187 if (mbuffer == NULL)
2189 fprintf(stderr, "[screenmirror] fail: buffer create\n");
2192 screenmirror->buffer_list = eina_list_append(screenmirror->buffer_list, mbuffer);
2193 tizen_screenmirror_queue(screenmirror->tz_screenmirror, mbuffer->buffer);
2197 _efl_util_screenmirror_handle_content(void *data,
2198 struct tizen_screenmirror *tz_screenmirror, uint32_t content)
2200 efl_util_screenmirror_h screenmirror = NULL;
2202 screenmirror = (efl_util_screenmirror_h)data;
2203 screenmirror->cb_content = EINA_TRUE;
2207 _efl_util_screenmirror_handle_stop(void *data, struct tizen_screenmirror *tz_screenmirror)
2209 efl_util_screenmirror_h screenmirror = NULL;
2211 screenmirror = (efl_util_screenmirror_h)data;
2212 screenmirror->cb_stop = EINA_TRUE;
2215 static const struct tizen_screenmirror_listener efl_util_screenmirror_listener = {
2216 _efl_util_screenmirror_handle_dequeued,
2217 _efl_util_screenmirror_handle_content,
2218 _efl_util_screenmirror_handle_stop
2221 API efl_util_screenmirror_h
2222 efl_util_screenmirror_initialize(int width, int height)
2224 efl_util_screenmirror_h screenmirror = NULL;
2225 efl_util_mirror_buffer *mbuffer;
2226 Efl_Util_Wl_Output_Info *output;
2229 if (width <= 0 || height <= 0)
2231 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2235 _screenshot_mutex_lock();
2239 if (g_screenmirror->mirror_working)
2241 set_last_result(EFL_UTIL_ERROR_INVALID_OPERATION);
2242 _screenshot_mutex_unlock();
2247 g_screenmirror->width = width;
2248 g_screenmirror->height = height;
2249 set_last_result(EFL_UTIL_ERROR_NONE);
2250 _screenshot_mutex_unlock();
2251 return g_screenmirror;
2255 screenmirror = calloc(1, sizeof(struct _efl_util_screenmirror_h));
2256 if (screenmirror == NULL)
2258 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
2259 _screenshot_mutex_unlock();
2263 if (!_eflutil.wl.shot.tz_screenshooter)
2265 if (_efl_util_wl_screenshooter_init() == EINA_FALSE)
2267 if (_eflutil.wl.shot.noti == 0)
2268 set_last_result(EFL_UTIL_ERROR_PERMISSION_DENIED);
2270 set_last_result(EFL_UTIL_ERROR_SCREENSHOT_INIT_FAIL);
2276 output = eina_list_nth(_eflutil.wl.shot.output_list, 0);
2279 set_last_result(EFL_UTIL_ERROR_NO_RESOURCE_AVAILABLE);
2280 fprintf(stderr, "[screenmirror] fail: no output for screenmirror\n");
2281 goto fail_get_output;
2284 screenmirror->tz_screenmirror = tizen_screenshooter_get_screenmirror(_eflutil.wl.shot.tz_screenshooter, output->output);
2285 wl_proxy_set_queue((struct wl_proxy *)screenmirror->tz_screenmirror, _eflutil.wl.shot.queue);
2286 tizen_screenmirror_add_listener(screenmirror->tz_screenmirror, &efl_util_screenmirror_listener, screenmirror);
2287 tizen_screenmirror_set_stretch(screenmirror->tz_screenmirror, TIZEN_SCREENMIRROR_STRETCH_KEEP_RATIO);
2288 screenmirror->width = width;
2289 screenmirror->height = height;
2291 g_screenmirror = screenmirror;
2293 for (i = 0; i < 1; i++)
2295 mbuffer = _efl_util_create_mirror_buffer(screenmirror);
2298 screenmirror->buffer_list = eina_list_append(screenmirror->buffer_list, mbuffer);
2299 tizen_screenmirror_queue(screenmirror->tz_screenmirror, mbuffer->buffer);
2302 fprintf(stderr, "[screenmirror] fail: buffer create %d\n", i);
2304 while (!screenmirror->cb_content && ret != -1)
2305 ret = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
2307 _screenshot_mutex_unlock();
2309 return screenmirror;
2314 _screenshot_mutex_unlock();
2319 efl_util_screenmirror_deinitialize(efl_util_screenmirror_h screenmirror)
2321 efl_util_mirror_buffer *mbuffer;
2324 _screenshot_mutex_lock();
2326 if (!screenmirror || (screenmirror != g_screenmirror))
2328 _screenshot_mutex_unlock();
2329 _screenshot_mutex_destory();
2330 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2333 if (screenmirror->mirror_working)
2335 fprintf(stderr, "[screenmirror] fail: execute stop before deinit\n");
2336 _screenshot_mutex_unlock();
2337 _screenshot_mutex_destory();
2338 return EFL_UTIL_ERROR_INVALID_OPERATION;
2341 EINA_LIST_FOREACH(screenmirror->buffer_list, l, mbuffer)
2343 tbm_surface_destroy(mbuffer->t_surface);
2344 _efl_util_destroy_mirror_buffer(mbuffer);
2346 eina_list_free(screenmirror->buffer_list);
2348 tizen_screenmirror_destroy(screenmirror->tz_screenmirror);
2350 g_screenmirror = NULL;
2352 _efl_util_wl_screenshooter_deinit();
2354 _screenshot_mutex_unlock();
2355 _screenshot_mutex_destory();
2357 return EFL_UTIL_ERROR_NONE;
2361 efl_util_screenmirror_set_handler(efl_util_screenmirror_h screenmirror,
2362 efl_util_screenmirror_handler func, void *data)
2364 _screenshot_mutex_lock();
2366 if (!screenmirror || (screenmirror != g_screenmirror) || !func)
2368 _screenshot_mutex_unlock();
2369 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2371 screenmirror->user_func = func;
2372 screenmirror->user_data = data;
2374 _screenshot_mutex_unlock();
2376 return EFL_UTIL_ERROR_NONE;
2380 efl_util_screenmirror_start(efl_util_screenmirror_h screenmirror)
2384 _screenshot_mutex_lock();
2386 if (!screenmirror || (screenmirror != g_screenmirror))
2388 _screenshot_mutex_unlock();
2389 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2391 else if (!screenmirror->user_func)
2393 _screenshot_mutex_unlock();
2394 return EFL_UTIL_ERROR_SCREENSHOT_EXECUTION_FAIL;
2396 else if (screenmirror->mirror_working)
2398 _screenshot_mutex_unlock();
2399 return EFL_UTIL_ERROR_NONE;
2402 screenmirror->cb_start = EINA_FALSE;
2403 screenmirror->mirror_working = EINA_TRUE;
2404 tizen_screenmirror_start(screenmirror->tz_screenmirror);
2405 while (!screenmirror->cb_start && ret != -1)
2406 ret = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
2409 fprintf(stderr, "[screenmirror] fail: tizen_screenmirror_start\n");
2410 _screenshot_mutex_unlock();
2411 return EFL_UTIL_ERROR_SCREENSHOT_EXECUTION_FAIL;
2414 ret = pthread_create(&screenmirror->thread, NULL, _efl_util_screenmirror_loop, screenmirror);
2417 fprintf(stderr, "[screenmirror] fail: thread create fail\n");
2418 _screenshot_mutex_unlock();
2419 return EFL_UTIL_ERROR_SCREENSHOT_EXECUTION_FAIL;
2422 pthread_setname_np(screenmirror->thread, "e_util_mirror");
2424 _screenshot_mutex_unlock();
2426 return EFL_UTIL_ERROR_NONE;
2430 efl_util_screenmirror_stop(efl_util_screenmirror_h screenmirror)
2434 _screenshot_mutex_lock();
2436 if (!screenmirror || (screenmirror != g_screenmirror))
2438 _screenshot_mutex_unlock();
2439 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2441 else if (!screenmirror->mirror_working)
2443 _screenshot_mutex_unlock();
2444 return EFL_UTIL_ERROR_NONE;
2446 screenmirror->mirror_working = EINA_FALSE;
2447 pthread_join(screenmirror->thread, NULL);
2448 tizen_screenmirror_stop(screenmirror->tz_screenmirror);
2449 screenmirror->cb_stop = EINA_FALSE;
2451 while (!screenmirror->cb_stop && ret != -1)
2452 ret = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
2455 fprintf(stderr, "[screenmirror] fail: tizen_screenmirror_stop\n");
2456 _screenshot_mutex_unlock();
2457 return EFL_UTIL_ERROR_SCREENSHOT_EXECUTION_FAIL;
2460 _screenshot_mutex_unlock();
2462 return EFL_UTIL_ERROR_NONE;
2464 /* LCOV_EXCL_STOP */
2466 struct _efl_util_gesture_h
2471 API int EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = 0;
2472 API int EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = 0;
2473 API int EFL_UTIL_EVENT_GESTURE_TAP = 0;
2474 API int EFL_UTIL_EVENT_GESTURE_PALM_COVER = 0;
2476 /* LCOV_EXCL_START */
2478 _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)
2480 _eflutil_defaultqueue.wl.gesture.request_notified = error;
2484 _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)
2486 efl_util_event_gesture_edge_swipe_s *ev = NULL;
2488 ev = (efl_util_event_gesture_edge_swipe_s *)calloc(1, sizeof(*ev));
2493 ev->fingers = fingers;
2498 ecore_event_add(EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE, ev, NULL, NULL);
2502 _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)
2504 _eflutil_defaultqueue.wl.gesture.request_notified = error;
2508 _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)
2510 efl_util_event_gesture_edge_drag_s *ev = NULL;
2512 ev = (efl_util_event_gesture_edge_drag_s *)calloc(1, sizeof(*ev));
2517 ev->fingers = fingers;
2522 ecore_event_add(EFL_UTIL_EVENT_GESTURE_EDGE_DRAG, ev, NULL, NULL);
2526 _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)
2528 _eflutil_defaultqueue.wl.gesture.request_notified = error;
2532 _cb_gesture_tap(void *data EINA_UNUSED, struct tizen_gesture *tizen_gesture EINA_UNUSED, uint32_t mode, uint32_t fingers, uint32_t repeats)
2534 efl_util_event_gesture_tap_s *ev = NULL;
2536 ev = (efl_util_event_gesture_tap_s *)calloc(1, sizeof(*ev));
2541 ev->fingers = fingers;
2542 ev->repeats = repeats;
2544 ecore_event_add(EFL_UTIL_EVENT_GESTURE_TAP, ev, NULL, NULL);
2546 /* LCOV_EXCL_STOP */
2549 _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)
2551 _eflutil_defaultqueue.wl.gesture.request_notified = error;
2554 /* LCOV_EXCL_START */
2556 _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)
2558 efl_util_event_gesture_palm_cover_s *ev = NULL;
2560 ev = (efl_util_event_gesture_palm_cover_s *)calloc(1, sizeof(*ev));
2565 ev->duration = duration;
2569 ev->pressure = wl_fixed_to_int(pressure);
2571 ecore_event_add(EFL_UTIL_EVENT_GESTURE_PALM_COVER, ev, NULL, NULL);
2573 /* LCOV_EXCL_STOP */
2576 _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)
2578 _eflutil_defaultqueue.wl.gesture.request_notified = error;
2581 static efl_util_error_e
2582 _efl_util_gesture_convert_error(int ret)
2586 case TIZEN_GESTURE_ERROR_NONE:
2587 return EFL_UTIL_ERROR_NONE;
2588 case TIZEN_GESTURE_ERROR_INVALID_DATA:
2589 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2590 case TIZEN_GESTURE_ERROR_NO_PERMISSION:
2591 return EFL_UTIL_ERROR_PERMISSION_DENIED;
2592 case TIZEN_GESTURE_ERROR_NO_SYSTEM_RESOURCES:
2593 return EFL_UTIL_ERROR_OUT_OF_MEMORY;
2594 case TIZEN_GESTURE_ERROR_GRABBED_ALREADY:
2595 return EFL_UTIL_ERROR_NO_RESOURCE_AVAILABLE;
2596 case TIZEN_GESTURE_ERROR_NOT_SUPPORTED:
2597 return EFL_UTIL_ERROR_NOT_SUPPORTED;
2599 return EFL_UTIL_ERROR_NONE;
2603 /* LCOV_EXCL_START */
2604 static efl_util_error_e
2605 _efl_util_gesture_verify_request_notified()
2607 int ret = EFL_UTIL_ERROR_NONE;
2609 while (_eflutil_defaultqueue.wl.gesture.request_notified == -1)
2610 wl_display_dispatch(_eflutil_defaultqueue.wl.dpy);
2612 ret = _efl_util_gesture_convert_error(_eflutil_defaultqueue.wl.gesture.request_notified);
2613 _eflutil_defaultqueue.wl.gesture.request_notified = -1;
2619 _efl_util_gesture_grab_edge_swipe(efl_util_gesture_data data, Eina_Bool grabbed)
2621 int ret = EFL_UTIL_ERROR_NONE;
2622 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2623 Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = NULL;
2624 unsigned int fingers = 0;
2625 unsigned int edge = 0;
2626 unsigned int edge_size = 0;
2627 unsigned int start_point = 0;
2628 unsigned int end_point = 0;
2630 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2632 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil_defaultqueue.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2633 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2634 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_SWIPE,
2635 EFL_UTIL_ERROR_INVALID_PARAMETER);
2637 edge_swipe_data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)data;
2639 fingers = edge_swipe_data->fingers;
2640 edge = edge_swipe_data->edge;
2641 edge_size = edge_swipe_data->edge_size;
2642 start_point = edge_swipe_data->start_point;
2643 end_point = edge_swipe_data->end_point;
2646 tizen_gesture_grab_edge_swipe(_eflutil_defaultqueue.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2648 tizen_gesture_ungrab_edge_swipe(_eflutil_defaultqueue.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2650 ret = _efl_util_gesture_verify_request_notified();
2656 _efl_util_gesture_grab_edge_drag(efl_util_gesture_data data, Eina_Bool grabbed)
2658 int ret = EFL_UTIL_ERROR_NONE;
2659 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2660 Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = NULL;
2661 unsigned int fingers = 0;
2662 unsigned int edge = 0;
2663 unsigned int edge_size = 0;
2664 unsigned int start_point = 0;
2665 unsigned int end_point = 0;
2667 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2669 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil_defaultqueue.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2670 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2671 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_DRAG,
2672 EFL_UTIL_ERROR_INVALID_PARAMETER);
2674 edge_drag_data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)data;
2676 fingers = edge_drag_data->fingers;
2677 edge = edge_drag_data->edge;
2678 edge_size = edge_drag_data->edge_size;
2679 start_point = edge_drag_data->start_point;
2680 end_point = edge_drag_data->end_point;
2683 tizen_gesture_grab_edge_drag(_eflutil_defaultqueue.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2685 tizen_gesture_ungrab_edge_drag(_eflutil_defaultqueue.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2687 ret = _efl_util_gesture_verify_request_notified();
2693 _efl_util_gesture_grab_tap(efl_util_gesture_data data, Eina_Bool grabbed)
2695 int ret = EFL_UTIL_ERROR_NONE;
2696 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2697 Efl_Util_Gesture_Tap_Grab_Data *tap_data = NULL;
2698 unsigned int fingers = 0;
2699 unsigned int repeats = 0;
2701 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2703 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil_defaultqueue.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2704 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2705 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_TAP,
2706 EFL_UTIL_ERROR_INVALID_PARAMETER);
2708 tap_data = (Efl_Util_Gesture_Tap_Grab_Data *)data;
2710 fingers = tap_data->fingers;
2711 repeats = tap_data->repeats;
2714 tizen_gesture_grab_tap(_eflutil_defaultqueue.wl.gesture.proto, fingers, repeats);
2716 tizen_gesture_ungrab_tap(_eflutil_defaultqueue.wl.gesture.proto, fingers, repeats);
2718 ret = _efl_util_gesture_verify_request_notified();
2724 _efl_util_gesture_grab_palm_cover(efl_util_gesture_data data, Eina_Bool grabbed)
2726 int ret = EFL_UTIL_ERROR_NONE;
2727 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2729 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2731 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil_defaultqueue.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2732 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2733 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_PALM_COVER,
2734 EFL_UTIL_ERROR_INVALID_PARAMETER);
2737 tizen_gesture_grab_palm_cover(_eflutil_defaultqueue.wl.gesture.proto);
2739 tizen_gesture_ungrab_palm_cover(_eflutil_defaultqueue.wl.gesture.proto);
2741 ret = _efl_util_gesture_verify_request_notified();
2745 /* LCOV_EXCL_STOP */
2747 API efl_util_gesture_h
2748 efl_util_gesture_initialize(void)
2750 efl_util_gesture_h gesture_h = NULL;
2752 gesture_h = (efl_util_gesture_h)calloc(1, sizeof(struct _efl_util_gesture_h));
2755 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2756 goto out; /* LCOV_EXCL_LINE */
2759 if (_wl_init_default_queue() == (int)EINA_FALSE)
2761 set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED); /* LCOV_EXCL_LINE */
2762 goto out; /* LCOV_EXCL_LINE */
2765 while (!_eflutil_defaultqueue.wl.gesture.proto)
2766 wl_display_dispatch(_eflutil_defaultqueue.wl.dpy); /* LCOV_EXCL_LINE */
2768 if (_eflutil_defaultqueue.wl.gesture.event_init <= 0)
2770 if (ecore_event_init() <= 0)
2772 set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED); /* LCOV_EXCL_LINE */
2773 goto out; /* LCOV_EXCL_LINE */
2775 EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = ecore_event_type_new();
2776 EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = ecore_event_type_new();
2777 EFL_UTIL_EVENT_GESTURE_TAP = ecore_event_type_new();
2778 EFL_UTIL_EVENT_GESTURE_PALM_COVER = ecore_event_type_new();
2780 _eflutil_defaultqueue.wl.gesture.event_init++;
2781 gesture_h->init = EINA_TRUE;
2783 set_last_result(EFL_UTIL_ERROR_NONE);
2787 /* LCOV_EXCL_START */
2794 /* LCOV_EXCL_STOP */
2798 efl_util_gesture_deinitialize(efl_util_gesture_h gesture_h)
2800 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2801 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2806 _eflutil_defaultqueue.wl.gesture.event_init--;
2808 if (_eflutil_defaultqueue.wl.gesture.event_init <= 0)
2810 _eflutil_defaultqueue.wl.gesture.event_init = 0;
2811 ecore_event_shutdown();
2812 EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = 0;
2813 EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = 0;
2814 EFL_UTIL_EVENT_GESTURE_TAP = 0;
2815 EFL_UTIL_EVENT_GESTURE_PALM_COVER = 0;
2818 return EFL_UTIL_ERROR_NONE;
2821 API efl_util_gesture_data
2822 efl_util_gesture_edge_swipe_new(efl_util_gesture_h gesture_h, unsigned int fingers, efl_util_gesture_edge_e edge)
2824 Efl_Util_Gesture_Edge_Swipe_Grab_Data *data;
2826 if (!gesture_h || gesture_h->init == EINA_FALSE)
2828 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2832 if (edge <= EFL_UTIL_GESTURE_EDGE_NONE || edge > EFL_UTIL_GESTURE_EDGE_LEFT)
2834 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2838 data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Edge_Swipe_Grab_Data));
2841 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2842 return NULL; /* LCOV_EXCL_LINE */
2845 data->base.type = TIZEN_GESTURE_TYPE_EDGE_SWIPE;
2846 data->fingers = fingers;
2848 data->edge_size = EFL_UTIL_GESTURE_EDGE_SIZE_FULL;
2850 set_last_result(EFL_UTIL_ERROR_NONE);
2852 return (void *)data;
2856 efl_util_gesture_edge_swipe_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2858 if (!gesture_h || gesture_h->init == EINA_FALSE)
2860 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2865 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2871 return EFL_UTIL_ERROR_NONE;
2875 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)
2877 Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = data;
2879 EINA_SAFETY_ON_NULL_RETURN_VAL(edge_swipe_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2880 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_swipe_data->base.type == TIZEN_GESTURE_TYPE_EDGE_SWIPE,
2881 EFL_UTIL_ERROR_INVALID_PARAMETER);
2882 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_size == EFL_UTIL_GESTURE_EDGE_SIZE_PARTIAL,
2883 EFL_UTIL_ERROR_INVALID_PARAMETER);
2884 EINA_SAFETY_ON_FALSE_RETURN_VAL(end_point > start_point, EFL_UTIL_ERROR_INVALID_PARAMETER);
2886 edge_swipe_data->edge_size = edge_size;
2887 edge_swipe_data->start_point = start_point;
2888 edge_swipe_data->end_point = end_point;
2890 return EFL_UTIL_ERROR_NONE;
2893 API efl_util_gesture_data
2894 efl_util_gesture_edge_drag_new(efl_util_gesture_h gesture_h, unsigned int fingers, efl_util_gesture_edge_e edge)
2896 Efl_Util_Gesture_Edge_Drag_Grab_Data *data;
2898 if (!gesture_h || gesture_h->init == EINA_FALSE)
2900 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2904 if (edge <= EFL_UTIL_GESTURE_EDGE_NONE || edge > EFL_UTIL_GESTURE_EDGE_LEFT)
2906 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2910 data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Edge_Drag_Grab_Data));
2913 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2914 return NULL; /* LCOV_EXCL_LINE */
2917 data->base.type = TIZEN_GESTURE_TYPE_EDGE_DRAG;
2918 data->fingers = fingers;
2920 data->edge_size = EFL_UTIL_GESTURE_EDGE_SIZE_FULL;
2922 set_last_result(EFL_UTIL_ERROR_NONE);
2924 return (void *)data;
2928 efl_util_gesture_edge_drag_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2930 if (!gesture_h || gesture_h->init == EINA_FALSE)
2932 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2937 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2943 return EFL_UTIL_ERROR_NONE;
2947 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)
2949 Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = data;
2951 EINA_SAFETY_ON_NULL_RETURN_VAL(edge_drag_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2952 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_drag_data->base.type == TIZEN_GESTURE_TYPE_EDGE_DRAG,
2953 EFL_UTIL_ERROR_INVALID_PARAMETER);
2954 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_size == EFL_UTIL_GESTURE_EDGE_SIZE_PARTIAL,
2955 EFL_UTIL_ERROR_INVALID_PARAMETER);
2956 EINA_SAFETY_ON_FALSE_RETURN_VAL(end_point > start_point, EFL_UTIL_ERROR_INVALID_PARAMETER);
2958 edge_drag_data->edge_size = edge_size;
2959 edge_drag_data->start_point = start_point;
2960 edge_drag_data->end_point = end_point;
2962 return EFL_UTIL_ERROR_NONE;
2965 API efl_util_gesture_data
2966 efl_util_gesture_tap_new(efl_util_gesture_h gesture_h, unsigned int fingers, unsigned int repeats)
2968 Efl_Util_Gesture_Tap_Grab_Data *data;
2970 if (!gesture_h || gesture_h->init == EINA_FALSE)
2972 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2976 if (fingers <= 1 || repeats <= 1)
2978 set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED);
2982 data = (Efl_Util_Gesture_Tap_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Tap_Grab_Data));
2985 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2986 return NULL; /* LCOV_EXCL_LINE */
2989 data->base.type = TIZEN_GESTURE_TYPE_TAP;
2990 data->fingers = fingers;
2991 data->repeats = repeats;
2993 set_last_result(EFL_UTIL_ERROR_NONE);
2995 return (void *)data;
2999 efl_util_gesture_tap_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
3001 if (!gesture_h || gesture_h->init == EINA_FALSE)
3003 return EFL_UTIL_ERROR_INVALID_PARAMETER;
3008 return EFL_UTIL_ERROR_INVALID_PARAMETER;
3014 return EFL_UTIL_ERROR_NONE;
3017 API efl_util_gesture_data
3018 efl_util_gesture_palm_cover_new(efl_util_gesture_h gesture_h)
3020 Efl_Util_Gesture_Palm_Cover_Grab_Data *data;
3022 if (!gesture_h || gesture_h->init == EINA_FALSE)
3024 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
3028 data = (Efl_Util_Gesture_Palm_Cover_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Palm_Cover_Grab_Data));
3031 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
3032 return NULL; /* LCOV_EXCL_LINE */
3035 data->base.type = TIZEN_GESTURE_TYPE_PALM_COVER;
3037 set_last_result(EFL_UTIL_ERROR_NONE);
3039 return (void *)data;
3043 efl_util_gesture_palm_cover_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
3045 if (!gesture_h || gesture_h->init == EINA_FALSE)
3047 return EFL_UTIL_ERROR_INVALID_PARAMETER;
3052 return EFL_UTIL_ERROR_INVALID_PARAMETER;
3058 return EFL_UTIL_ERROR_NONE;
3061 /* LCOV_EXCL_START */
3063 efl_util_gesture_grab(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
3065 int ret = EFL_UTIL_ERROR_NONE;
3066 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
3068 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
3070 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
3071 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
3072 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
3074 switch (base_data->type)
3076 case TIZEN_GESTURE_TYPE_EDGE_SWIPE:
3077 ret = _efl_util_gesture_grab_edge_swipe(data, EINA_TRUE);
3079 case TIZEN_GESTURE_TYPE_EDGE_DRAG:
3080 ret = _efl_util_gesture_grab_edge_drag(data, EINA_TRUE);
3082 case TIZEN_GESTURE_TYPE_TAP:
3083 ret = _efl_util_gesture_grab_tap(data, EINA_TRUE);
3085 case TIZEN_GESTURE_TYPE_PALM_COVER:
3086 ret = _efl_util_gesture_grab_palm_cover(data, EINA_TRUE);
3089 return EFL_UTIL_ERROR_INVALID_PARAMETER;
3096 efl_util_gesture_ungrab(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
3098 int ret = EFL_UTIL_ERROR_NONE;
3099 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
3101 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
3103 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
3104 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
3105 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
3107 switch (base_data->type)
3109 case TIZEN_GESTURE_TYPE_EDGE_SWIPE:
3110 ret = _efl_util_gesture_grab_edge_swipe(data, EINA_FALSE);
3112 case TIZEN_GESTURE_TYPE_EDGE_DRAG:
3113 ret = _efl_util_gesture_grab_edge_drag(data, EINA_FALSE);
3115 case TIZEN_GESTURE_TYPE_TAP:
3116 ret = _efl_util_gesture_grab_tap(data, EINA_FALSE);
3118 case TIZEN_GESTURE_TYPE_PALM_COVER:
3119 ret = _efl_util_gesture_grab_palm_cover(data, EINA_FALSE);
3122 return EFL_UTIL_ERROR_INVALID_PARAMETER;
3127 /* LCOV_EXCL_STOP */
3130 efl_util_gesture_select(efl_util_gesture_h gesture_h, Evas_Object *window, efl_util_gesture_data data)
3132 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
3133 Ecore_Wl2_Window *wlwin;
3134 struct wl_surface *surface;
3137 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
3139 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
3140 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
3141 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
3142 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
3144 if (base_data->type != TIZEN_GESTURE_TYPE_PALM_COVER)
3145 return EFL_UTIL_ERROR_NOT_SUPPORTED;
3147 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
3148 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
3150 surface = ecore_wl2_window_surface_get(wlwin);
3151 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
3152 EFL_UTIL_ERROR_INVALID_PARAMETER);
3154 tizen_gesture_select_palm_cover(_eflutil_defaultqueue.wl.gesture.proto, surface);
3156 ret = _efl_util_gesture_verify_request_notified();
3162 efl_util_gesture_deselect(efl_util_gesture_h gesture_h, Evas_Object *window, efl_util_gesture_data data)
3164 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
3165 Ecore_Wl2_Window *wlwin;
3166 struct wl_surface *surface;
3169 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
3171 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
3172 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
3173 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
3174 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
3176 if (base_data->type != TIZEN_GESTURE_TYPE_PALM_COVER)
3177 return EFL_UTIL_ERROR_NOT_SUPPORTED;
3179 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
3180 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
3182 surface = ecore_wl2_window_surface_get(wlwin);
3183 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
3184 EFL_UTIL_ERROR_INVALID_PARAMETER);
3186 tizen_gesture_deselect_palm_cover(_eflutil_defaultqueue.wl.gesture.proto, surface);
3188 ret = _efl_util_gesture_verify_request_notified();
3193 /* LCOV_EXCL_START */
3195 efl_util_gesture_activate_set(efl_util_gesture_h gesture_h, unsigned int type, Eina_Bool active)
3199 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
3200 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
3201 EINA_SAFETY_ON_TRUE_RETURN_VAL(type == EFL_UTIL_GESTURE_TYPE_NONE, EFL_UTIL_ERROR_INVALID_PARAMETER);
3203 tizen_gesture_activate_set(_eflutil_defaultqueue.wl.gesture.proto, NULL, type, active);
3205 ret = _efl_util_gesture_verify_request_notified();
3209 /* LCOV_EXCL_STOP */
3212 efl_util_gesture_activate_set_on_window(efl_util_gesture_h gesture_h, Evas_Object *window, unsigned int type, Eina_Bool active)
3214 Ecore_Wl2_Window *wlwin;
3215 struct wl_surface *surface;
3218 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
3219 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
3220 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
3221 EINA_SAFETY_ON_TRUE_RETURN_VAL(type == EFL_UTIL_GESTURE_TYPE_NONE, EFL_UTIL_ERROR_INVALID_PARAMETER);
3223 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
3224 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
3226 surface = ecore_wl2_window_surface_get(wlwin);
3227 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
3228 EFL_UTIL_ERROR_INVALID_PARAMETER);
3230 tizen_gesture_activate_set(_eflutil_defaultqueue.wl.gesture.proto, surface, type, active);
3232 ret = _efl_util_gesture_verify_request_notified();