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;
721 int ret_dispatch = 0;
724 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
726 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
727 EINA_SAFETY_ON_NULL_RETURN_VAL(wlwin, EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
729 type = elm_win_type_get(window);
730 if (type != ELM_WIN_NOTIFICATION)
732 wl_type = ecore_wl2_window_type_get(wlwin);
733 EINA_SAFETY_ON_FALSE_RETURN_VAL((wl_type == ECORE_WL2_WINDOW_TYPE_NOTIFICATION),
734 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
737 while (!_eflutil.wl.policy.proto && (ret_dispatch != -1))
738 ret_dispatch = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
740 surface = ecore_wl2_window_surface_get(wlwin);
741 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
742 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
744 lv_info = eina_hash_find(_eflutil.wl.policy.hash_noti_lv, &surface);
747 lv_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Lv_Info));
748 EINA_SAFETY_ON_NULL_RETURN_VAL(lv_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
750 lv_info->surface = surface;
751 lv_info->level = (int)level;
752 lv_info->wait_for_done = EINA_TRUE;
753 lv_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
754 eina_hash_add(_eflutil.wl.policy.hash_noti_lv,
758 evas_object_event_callback_add(window, EVAS_CALLBACK_DEL,
759 _cb_window_del, lv_info);
763 lv_info->level = (int)level;
764 lv_info->wait_for_done = EINA_TRUE;
765 lv_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
769 tizen_policy_set_notification_level(_eflutil.wl.policy.proto,
770 surface, (int)level);
772 if (lv_info->wait_for_done)
776 while (lv_info->wait_for_done && (count < NUM_EVENT_WAIT_DONE_COUNT) && (ret_dispatch != -1))
778 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
779 ret_dispatch = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
783 if (lv_info->wait_for_done)
785 return EFL_UTIL_ERROR_INVALID_PARAMETER;
789 if (lv_info->state == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
791 return EFL_UTIL_ERROR_PERMISSION_DENIED;
796 return EFL_UTIL_ERROR_NONE;
800 efl_util_get_notification_window_level(Evas_Object *window,
801 efl_util_notification_level_e *level)
805 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
806 EINA_SAFETY_ON_NULL_RETURN_VAL(level, EFL_UTIL_ERROR_INVALID_PARAMETER);
809 Ecore_Wl2_Window *wlwin;
810 struct wl_surface *surface;
811 Efl_Util_Wl_Surface_Lv_Info *lv_info;
812 Ecore_Wl2_Window_Type wl_type;
813 int ret_dispatch = 0;
816 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
818 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
819 EINA_SAFETY_ON_NULL_RETURN_VAL(wlwin, EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
821 type = elm_win_type_get(window);
822 if (type != ELM_WIN_NOTIFICATION)
824 wl_type = ecore_wl2_window_type_get(wlwin);
825 EINA_SAFETY_ON_FALSE_RETURN_VAL((wl_type == ECORE_WL2_WINDOW_TYPE_NOTIFICATION),
826 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
829 while (!_eflutil.wl.policy.proto && (ret_dispatch != -1))
830 ret_dispatch = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
832 surface = ecore_wl2_window_surface_get(wlwin);
833 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
834 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
836 lv_info = eina_hash_find(_eflutil.wl.policy.hash_noti_lv, &surface);
839 if (lv_info->wait_for_done)
843 while ((lv_info->wait_for_done) && (count < NUM_EVENT_WAIT_DONE_COUNT) && (ret_dispatch != -1))
845 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
846 ret_dispatch = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
850 if (lv_info->wait_for_done)
852 *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
853 return EFL_UTIL_ERROR_INVALID_PARAMETER;
857 switch (lv_info->level)
859 case TIZEN_POLICY_LEVEL_NONE: *level = EFL_UTIL_NOTIFICATION_LEVEL_NONE; break;
860 case TIZEN_POLICY_LEVEL_DEFAULT: *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT; break;
861 case TIZEN_POLICY_LEVEL_MEDIUM: *level = EFL_UTIL_NOTIFICATION_LEVEL_MEDIUM; break;
862 case TIZEN_POLICY_LEVEL_HIGH: *level = EFL_UTIL_NOTIFICATION_LEVEL_HIGH; break;
863 case TIZEN_POLICY_LEVEL_TOP: *level = EFL_UTIL_NOTIFICATION_LEVEL_TOP; break;
864 default: *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
865 return EFL_UTIL_ERROR_INVALID_PARAMETER;
867 return EFL_UTIL_ERROR_NONE;
870 *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
872 return EFL_UTIL_ERROR_NONE;
876 efl_util_set_window_opaque_state(Evas_Object *window,
881 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
882 EINA_SAFETY_ON_FALSE_RETURN_VAL(((opaque >= 0) && (opaque <= 1)),
883 EFL_UTIL_ERROR_INVALID_PARAMETER);
885 Ecore_Wl2_Window *wlwin;
886 struct wl_surface *surface;
888 if (!_eflutil.wl.policy.proto)
893 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
895 while (!_eflutil.wl.policy.proto && ret != -1)
896 ret = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
898 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.policy.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
901 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
903 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
905 surface = ecore_wl2_window_surface_get(wlwin);
907 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
909 tizen_policy_set_opaque_state(_eflutil.wl.policy.proto, surface, opaque);
911 return EFL_UTIL_ERROR_NONE;
915 efl_util_set_window_screen_mode(Evas_Object *window,
916 efl_util_screen_mode_e mode)
918 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
919 EINA_SAFETY_ON_FALSE_RETURN_VAL(((mode >= EFL_UTIL_SCREEN_MODE_DEFAULT) &&
920 (mode <= EFL_UTIL_SCREEN_MODE_ALWAYS_ON)),
921 EFL_UTIL_ERROR_INVALID_PARAMETER);
923 Ecore_Wl2_Window *wlwin;
924 struct wl_surface *surface;
925 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
927 int ret_dispatch = 0;
930 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
932 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
935 while (!_eflutil.wl.policy.proto && (ret_dispatch != -1))
936 ret_dispatch = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
938 surface = ecore_wl2_window_surface_get(wlwin);
939 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
940 EFL_UTIL_ERROR_INVALID_PARAMETER);
942 scr_mode_info = eina_hash_find(_eflutil.wl.policy.hash_scr_mode, &surface);
945 scr_mode_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Scr_Mode_Info));
946 EINA_SAFETY_ON_NULL_RETURN_VAL(scr_mode_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
948 scr_mode_info->surface = surface;
949 scr_mode_info->mode = (unsigned int)mode;
950 scr_mode_info->wait_for_done = EINA_TRUE;
951 scr_mode_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
953 eina_hash_add(_eflutil.wl.policy.hash_scr_mode,
959 scr_mode_info->mode = (unsigned int)mode;
960 scr_mode_info->wait_for_done = EINA_TRUE;
961 scr_mode_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
964 tizen_policy_set_window_screen_mode(_eflutil.wl.policy.proto,
965 surface, (unsigned int)mode);
966 if (scr_mode_info->wait_for_done)
970 while (scr_mode_info->wait_for_done && (count < NUM_EVENT_WAIT_DONE_COUNT) && (ret_dispatch != -1))
972 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
973 ret_dispatch = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
977 if (scr_mode_info->wait_for_done)
979 return EFL_UTIL_ERROR_INVALID_PARAMETER;
983 if (scr_mode_info->state == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
985 return EFL_UTIL_ERROR_PERMISSION_DENIED;
990 return EFL_UTIL_ERROR_NONE;
993 return EFL_UTIL_ERROR_INVALID_PARAMETER;
997 efl_util_get_window_screen_mode(Evas_Object *window,
998 efl_util_screen_mode_e *mode)
1000 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1001 EINA_SAFETY_ON_NULL_RETURN_VAL(mode, EFL_UTIL_ERROR_INVALID_PARAMETER);
1003 Ecore_Wl2_Window *wlwin;
1004 struct wl_surface *surface;
1005 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
1007 int ret_dispatch = 0;
1010 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1012 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
1015 while (!_eflutil.wl.policy.proto && (ret_dispatch != -1))
1016 ret_dispatch = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1018 surface = ecore_wl2_window_surface_get(wlwin);
1019 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1020 EFL_UTIL_ERROR_INVALID_PARAMETER);
1022 scr_mode_info = eina_hash_find(_eflutil.wl.policy.hash_scr_mode, &surface);
1025 if (scr_mode_info->wait_for_done)
1028 while (scr_mode_info->wait_for_done && (ret_dispatch != -1))
1030 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
1031 ret_dispatch = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1035 switch (scr_mode_info->mode)
1037 case TIZEN_POLICY_MODE_DEFAULT: *mode = EFL_UTIL_SCREEN_MODE_DEFAULT; break;
1038 case TIZEN_POLICY_MODE_ALWAYS_ON: *mode = EFL_UTIL_SCREEN_MODE_ALWAYS_ON; break;
1039 default: *mode = EFL_UTIL_SCREEN_MODE_DEFAULT;
1040 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1042 return EFL_UTIL_ERROR_NONE;
1046 *mode = EFL_UTIL_SCREEN_MODE_DEFAULT;
1047 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1051 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1055 efl_util_set_window_brightness(Evas_Object *window, int brightness)
1057 Ecore_Wl2_Window *wlwin;
1058 struct wl_surface *surface;
1059 Efl_Util_Wl_Surface_Brightness_Info *brightness_info;
1061 int ret_dispatch = 0;
1063 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1064 EINA_SAFETY_ON_FALSE_RETURN_VAL(brightness <= 100, EFL_UTIL_ERROR_INVALID_PARAMETER);
1067 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1069 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
1072 while (!_eflutil.wl.display_policy.proto && (ret_dispatch != -1))
1073 ret_dispatch = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1075 surface = ecore_wl2_window_surface_get(wlwin);
1076 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1077 EFL_UTIL_ERROR_INVALID_PARAMETER);
1079 brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
1080 if (!brightness_info)
1082 brightness_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Brightness_Info));
1083 EINA_SAFETY_ON_NULL_RETURN_VAL(brightness_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
1085 brightness_info->surface = surface;
1086 brightness_info->brightness = brightness;
1087 brightness_info->wait_for_done = EINA_TRUE;
1088 brightness_info->state = TIZEN_DISPLAY_POLICY_ERROR_STATE_NONE;
1090 eina_hash_add(_eflutil.wl.display_policy.hash_brightness,
1096 brightness_info->brightness = brightness;
1097 brightness_info->wait_for_done = EINA_TRUE;
1098 brightness_info->state = TIZEN_DISPLAY_POLICY_ERROR_STATE_NONE;
1101 tizen_display_policy_set_window_brightness(_eflutil.wl.display_policy.proto,
1102 surface, brightness);
1103 if (brightness_info->wait_for_done)
1107 while (brightness_info->wait_for_done && (count < NUM_EVENT_WAIT_DONE_COUNT) && (ret_dispatch != -1))
1109 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
1110 ret_dispatch = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1114 if (brightness_info->wait_for_done)
1116 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1120 if (brightness_info->state == TIZEN_DISPLAY_POLICY_ERROR_STATE_PERMISSION_DENIED)
1122 return EFL_UTIL_ERROR_PERMISSION_DENIED;
1126 return EFL_UTIL_ERROR_NONE;
1129 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1133 efl_util_get_window_brightness(Evas_Object *window, int *brightness)
1135 Ecore_Wl2_Window *wlwin;
1136 struct wl_surface *surface;
1137 Efl_Util_Wl_Surface_Brightness_Info *brightness_info;
1139 int ret_dispatch = 0;
1141 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1142 EINA_SAFETY_ON_NULL_RETURN_VAL(brightness, EFL_UTIL_ERROR_INVALID_PARAMETER);
1145 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1147 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
1148 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
1150 while (!_eflutil.wl.display_policy.proto && (ret_dispatch != -1))
1151 ret_dispatch = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1153 surface = ecore_wl2_window_surface_get(wlwin);
1154 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1155 EFL_UTIL_ERROR_INVALID_PARAMETER);
1157 brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
1158 if (brightness_info)
1160 if (brightness_info->wait_for_done)
1163 while (brightness_info->wait_for_done && (ret_dispatch != -1))
1165 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
1166 ret_dispatch = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1169 *brightness = brightness_info->brightness;
1174 return EFL_UTIL_ERROR_NONE;
1177 struct _efl_util_inputgen_h
1179 unsigned int init_type;
1181 E_Devicemgr_Inputgen_Touch_Axis *axis_info;
1185 _cb_device_add(void *data EINA_UNUSED,
1186 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1187 uint32_t serial EINA_UNUSED,
1188 const char *identifier EINA_UNUSED,
1189 struct tizen_input_device *device,
1190 struct wl_seat *seat EINA_UNUSED)
1196 _cb_device_remove(void *data EINA_UNUSED,
1197 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1198 uint32_t serial EINA_UNUSED,
1199 const char *identifier EINA_UNUSED,
1200 struct tizen_input_device *device,
1201 struct wl_seat *seat EINA_UNUSED)
1207 _cb_error(void *data EINA_UNUSED,
1208 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1211 _eflutil.wl.devmgr.request_notified = errorcode;
1214 /* LCOV_EXCL_START */
1216 _cb_block_expired(void *data EINA_UNUSED,
1217 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED)
1221 /* LCOV_EXCL_STOP */
1224 _cb_max_touch_count(void *data EINA_UNUSED,
1225 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1226 uint32_t serial EINA_UNUSED,
1228 struct wl_seat *seat EINA_UNUSED)
1230 _eflutil.wl.devmgr.max_touch_count = max_count;
1233 static efl_util_error_e
1234 _efl_util_input_convert_input_generator_error(int ret)
1238 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE:
1239 return EFL_UTIL_ERROR_NONE;
1240 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NO_PERMISSION:
1241 return EFL_UTIL_ERROR_PERMISSION_DENIED;
1242 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NO_SYSTEM_RESOURCES:
1243 return EFL_UTIL_ERROR_OUT_OF_MEMORY;
1244 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_INVALID_PARAMETER:
1245 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1246 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NOT_ALLOWED:
1247 return EFL_UTIL_ERROR_NO_RESOURCE_AVAILABLE;
1249 return EFL_UTIL_ERROR_NONE;
1253 static efl_util_inputgen_h
1254 _efl_util_input_create_inputgen(unsigned int dev_type, const char *name, int *ret, int with_name)
1256 efl_util_inputgen_h inputgen_h = NULL;
1257 unsigned int clas = 0x0;
1258 int ret_dispatch = 0;
1261 dev_type & ~(EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN
1262 | EFL_UTIL_INPUT_DEVTYPE_KEYBOARD
1263 | EFL_UTIL_INPUT_DEVTYPE_POINTER))
1265 set_last_result(EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1269 inputgen_h = (efl_util_inputgen_h)calloc(1, sizeof(struct _efl_util_inputgen_h));
1272 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
1276 inputgen_h->init_type |= dev_type;
1279 if (name) strncpy(inputgen_h->name, name, 31);
1280 else strncpy(inputgen_h->name, "Input Generator", 31);
1284 if (*ret == (int)EINA_FALSE)
1286 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1290 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN)
1291 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
1292 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD)
1293 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD;
1294 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_POINTER)
1295 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE;
1297 while (!_eflutil.wl.devmgr.devicemgr && (ret_dispatch != -1))
1298 ret_dispatch = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1301 tizen_input_device_manager_init_generator_with_sync(_eflutil.wl.devmgr.devicemgr, clas, inputgen_h->name);
1302 else if (with_name == 1)
1303 tizen_input_device_manager_init_generator_with_name(_eflutil.wl.devmgr.devicemgr, clas, inputgen_h->name);
1305 tizen_input_device_manager_init_generator(_eflutil.wl.devmgr.devicemgr, clas);
1308 while ((_eflutil.wl.devmgr.request_notified == -1) && (ret_dispatch != -1))
1309 ret_dispatch = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1311 *ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1312 _eflutil.wl.devmgr.request_notified = -1;
1314 set_last_result(*ret);
1315 if (*ret != TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE)
1329 API efl_util_inputgen_h
1330 efl_util_input_initialize_generator(unsigned int dev_type)
1332 int ret = EFL_UTIL_ERROR_NONE;
1333 efl_util_inputgen_h inputgen_h = NULL;
1335 inputgen_h = _efl_util_input_create_inputgen(dev_type, NULL, &ret, 0);
1342 API efl_util_inputgen_h
1343 efl_util_input_initialize_generator_with_name(unsigned int dev_type, const char *name)
1345 int ret = EFL_UTIL_ERROR_NONE;
1346 efl_util_inputgen_h inputgen_h = NULL;
1348 inputgen_h = _efl_util_input_create_inputgen(dev_type, name, &ret, 1);
1355 API efl_util_inputgen_h
1356 efl_util_input_initialize_generator_with_sync(unsigned int dev_type, const char *name)
1358 int ret = EFL_UTIL_ERROR_NONE;
1359 efl_util_inputgen_h inputgen_h = NULL;
1361 inputgen_h = _efl_util_input_create_inputgen(dev_type, name, &ret, 2);
1369 efl_util_input_set_touch_count(int max_count)
1371 int ret = EFL_UTIL_ERROR_NONE;
1372 int ret_dispatch = 0;
1375 if (ret == (int)EINA_FALSE)
1377 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1380 while (!_eflutil.wl.devmgr.devicemgr && (ret_dispatch != -1))
1381 ret_dispatch = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1383 if (_eflutil.wl.devmgr.max_touch_count >= max_count)
1384 return EFL_UTIL_ERROR_NONE;
1386 tizen_input_device_manager_set_touch_count(_eflutil.wl.devmgr.devicemgr, max_count);
1389 while ((_eflutil.wl.devmgr.request_notified == -1) && (ret_dispatch != -1))
1390 ret_dispatch = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1392 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1393 _eflutil.wl.devmgr.request_notified = -1;
1395 if (ret == EFL_UTIL_ERROR_NONE)
1397 _eflutil.wl.devmgr.request_touch_count = max_count;
1404 efl_util_input_deinitialize_generator(efl_util_inputgen_h inputgen_h)
1406 int ret = EFL_UTIL_ERROR_NONE;
1407 unsigned int clas = 0x0;
1408 int ret_dispatch = 0;
1409 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1411 if (inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN)
1412 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
1413 if (inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD)
1414 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD;
1415 if (inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_POINTER)
1416 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE;
1418 if (inputgen_h->axis_info)
1419 free(inputgen_h->axis_info);
1424 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1426 tizen_input_device_manager_deinit_generator(_eflutil.wl.devmgr.devicemgr, clas);
1428 while ((_eflutil.wl.devmgr.request_notified == -1) && (ret_dispatch != -1))
1429 ret_dispatch = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1431 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1432 _eflutil.wl.devmgr.request_notified = -1;
1438 efl_util_input_generate_key(efl_util_inputgen_h inputgen_h, const char *key_name, int pressed)
1440 int ret = EFL_UTIL_ERROR_NONE;
1441 int ret_dispatch = 0;
1443 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1444 EINA_SAFETY_ON_NULL_RETURN_VAL(key_name, EFL_UTIL_ERROR_INVALID_PARAMETER);
1445 EINA_SAFETY_ON_FALSE_RETURN_VAL(pressed == 0 || pressed == 1, EFL_UTIL_ERROR_INVALID_PARAMETER);
1446 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1448 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1450 tizen_input_device_manager_generate_key(_eflutil.wl.devmgr.devicemgr, key_name, pressed);
1452 while ((_eflutil.wl.devmgr.request_notified == -1) && (ret_dispatch != -1))
1453 ret_dispatch = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1455 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1456 _eflutil.wl.devmgr.request_notified = -1;
1462 efl_util_input_generate_touch(efl_util_inputgen_h inputgen_h, int idx,
1463 efl_util_input_touch_type_e touch_type, int x, int y)
1466 int ret_dispatch = 0;
1467 enum tizen_input_device_manager_pointer_event_type type;
1469 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1470 EINA_SAFETY_ON_FALSE_RETURN_VAL(idx >= 0, EFL_UTIL_ERROR_INVALID_PARAMETER);
1471 EINA_SAFETY_ON_FALSE_RETURN_VAL((x > 0 && y > 0), EFL_UTIL_ERROR_INVALID_PARAMETER);
1472 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1474 if (_eflutil.wl.devmgr.request_touch_count != 0 &&
1475 _eflutil.wl.devmgr.max_touch_count != _eflutil.wl.devmgr.request_touch_count &&
1476 (ret_dispatch != -1))
1477 ret_dispatch = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1479 if (idx >= _eflutil.wl.devmgr.max_touch_count)
1480 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1482 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1486 case EFL_UTIL_INPUT_TOUCH_BEGIN:
1487 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_BEGIN;
1489 case EFL_UTIL_INPUT_TOUCH_UPDATE:
1490 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_UPDATE;
1492 case EFL_UTIL_INPUT_TOUCH_END:
1493 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_END;
1496 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1499 tizen_input_device_manager_generate_touch(_eflutil.wl.devmgr.devicemgr, type, x, y, idx);
1502 while ((_eflutil.wl.devmgr.request_notified == -1) && (ret_dispatch != -1))
1503 ret_dispatch = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1505 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1506 _eflutil.wl.devmgr.request_notified = -1;
1512 _efl_util_input_generate_touch_axis_send(unsigned int type, double value)
1515 int ret_dispatch = 0;
1517 tizen_input_device_manager_generate_axis(_eflutil.wl.devmgr.devicemgr, type, wl_fixed_from_double(value));
1519 while ((_eflutil.wl.devmgr.request_notified == -1) && (ret_dispatch != -1))
1520 ret_dispatch = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1522 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1523 _eflutil.wl.devmgr.request_notified = -1;
1529 _efl_util_input_generate_touch_axis_cleanup(efl_util_inputgen_h inputgen_h, int idx)
1534 inputgen_h->axis_info[idx].radius_x = 1.0;
1535 inputgen_h->axis_info[idx].radius_y = 1.0;
1536 inputgen_h->axis_info[idx].pressure = 1.0;
1537 inputgen_h->axis_info[idx].angle = 0.0;
1538 inputgen_h->axis_info[idx].palm = 0.0;
1542 for (i = 0; i < EFL_UTIL_INPUT_GENERATOR_TOUCH_MAX_FINGER; i++)
1544 inputgen_h->axis_info[i].radius_x = 1.0;
1545 inputgen_h->axis_info[i].radius_y = 1.0;
1546 inputgen_h->axis_info[i].pressure = 1.0;
1547 inputgen_h->axis_info[i].angle = 0.0;
1548 inputgen_h->axis_info[i].palm = 0.0;
1554 _efl_util_input_generate_touch_axis_process(efl_util_inputgen_h inputgen_h, int idx, double radius_x,
1555 double radius_y, double pressure, double angle, double palm)
1557 int ret = EFL_UTIL_ERROR_NONE;
1559 if (!inputgen_h->axis_info)
1561 inputgen_h->axis_info = calloc(EFL_UTIL_INPUT_GENERATOR_TOUCH_MAX_FINGER,
1562 sizeof(E_Devicemgr_Inputgen_Touch_Axis));
1563 _efl_util_input_generate_touch_axis_cleanup(inputgen_h, -1);
1566 if (inputgen_h->axis_info[idx].radius_x != radius_x)
1568 ret = _efl_util_input_generate_touch_axis_send(TIZEN_INPUT_DEVICE_MANAGER_AXIS_TYPE_RADIUS_X, radius_x);
1569 if (ret != EFL_UTIL_ERROR_NONE) return ret;
1570 inputgen_h->axis_info[idx].radius_x = radius_x;
1572 if (inputgen_h->axis_info[idx].radius_y != radius_y)
1574 ret = _efl_util_input_generate_touch_axis_send(TIZEN_INPUT_DEVICE_MANAGER_AXIS_TYPE_RADIUS_Y, radius_y);
1575 if (ret != EFL_UTIL_ERROR_NONE) return ret;
1576 inputgen_h->axis_info[idx].radius_y = radius_y;
1578 if (inputgen_h->axis_info[idx].pressure != pressure)
1580 ret = _efl_util_input_generate_touch_axis_send(TIZEN_INPUT_DEVICE_MANAGER_AXIS_TYPE_PRESSURE, pressure);
1581 if (ret != EFL_UTIL_ERROR_NONE) return ret;
1582 inputgen_h->axis_info[idx].pressure = pressure;
1584 if (inputgen_h->axis_info[idx].angle != angle)
1586 ret = _efl_util_input_generate_touch_axis_send(TIZEN_INPUT_DEVICE_MANAGER_AXIS_TYPE_ANGLE, angle);
1587 if (ret != EFL_UTIL_ERROR_NONE) return ret;
1588 inputgen_h->axis_info[idx].angle = angle;
1590 if (inputgen_h->axis_info[idx].palm != palm)
1592 ret = _efl_util_input_generate_touch_axis_send(TIZEN_INPUT_DEVICE_MANAGER_AXIS_TYPE_PALM, palm);
1593 if (ret != EFL_UTIL_ERROR_NONE) return ret;
1594 inputgen_h->axis_info[idx].palm = palm;
1601 efl_util_input_generate_touch_axis(efl_util_inputgen_h inputgen_h, int idx,
1602 efl_util_input_touch_type_e touch_type, int x, int y,
1603 double radius_x, double radius_y,
1604 double pressure, double angle, double palm)
1607 int ret_dispatch = 0;
1608 enum tizen_input_device_manager_pointer_event_type type;
1610 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1611 EINA_SAFETY_ON_FALSE_RETURN_VAL(idx >= 0, EFL_UTIL_ERROR_INVALID_PARAMETER);
1612 EINA_SAFETY_ON_FALSE_RETURN_VAL((x >= 0 && y >= 0), EFL_UTIL_ERROR_INVALID_PARAMETER);
1613 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1614 EINA_SAFETY_ON_FALSE_RETURN_VAL((radius_x >= 0.0 && radius_y >= 0.0), EFL_UTIL_ERROR_INVALID_PARAMETER);
1615 EINA_SAFETY_ON_FALSE_RETURN_VAL((pressure >= 0.0 && palm >= 0.0), EFL_UTIL_ERROR_INVALID_PARAMETER);
1617 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1618 version = tizen_input_device_manager_get_version(_eflutil.wl.devmgr.devicemgr);
1619 EINA_SAFETY_ON_FALSE_RETURN_VAL((version >= 3), EFL_UTIL_ERROR_NOT_SUPPORTED);
1623 case EFL_UTIL_INPUT_TOUCH_BEGIN:
1624 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_BEGIN;
1626 case EFL_UTIL_INPUT_TOUCH_UPDATE:
1627 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_UPDATE;
1629 case EFL_UTIL_INPUT_TOUCH_END:
1630 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_END;
1633 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1636 if (touch_type != EFL_UTIL_INPUT_TOUCH_END)
1637 _efl_util_input_generate_touch_axis_process(inputgen_h, idx, radius_x, radius_y, pressure, angle, palm);
1639 _efl_util_input_generate_touch_axis_cleanup(inputgen_h, idx);
1641 tizen_input_device_manager_generate_touch(_eflutil.wl.devmgr.devicemgr, type, x, y, idx);
1643 while ((_eflutil.wl.devmgr.request_notified == -1) && (ret_dispatch != -1))
1644 ret_dispatch = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1646 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1647 _eflutil.wl.devmgr.request_notified = -1;
1654 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)
1657 int ret_dispatch = 0;
1658 enum tizen_input_device_manager_pointer_event_type type;
1660 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1661 EINA_SAFETY_ON_FALSE_RETURN_VAL(buttons > 0, EFL_UTIL_ERROR_INVALID_PARAMETER);
1662 EINA_SAFETY_ON_FALSE_RETURN_VAL((x >= 0 && y >= 0), EFL_UTIL_ERROR_INVALID_PARAMETER);
1663 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_POINTER, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1665 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1667 switch(pointer_type)
1669 case EFL_UTIL_INPUT_POINTER_BUTTON_DOWN:
1670 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_BEGIN;
1672 case EFL_UTIL_INPUT_POINTER_MOVE:
1673 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_UPDATE;
1675 case EFL_UTIL_INPUT_POINTER_BUTTON_UP:
1676 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_END;
1679 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1682 tizen_input_device_manager_generate_pointer(_eflutil.wl.devmgr.devicemgr, type, x, y, buttons);
1684 while ((_eflutil.wl.devmgr.request_notified == -1) && (ret_dispatch != -1))
1685 ret_dispatch = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1687 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1688 _eflutil.wl.devmgr.request_notified = -1;
1694 efl_util_input_generate_wheel(efl_util_inputgen_h inputgen_h, efl_util_input_pointer_wheel_type_e wheel_type, int value)
1697 int ret_dispatch = 0;
1698 enum tizen_input_device_manager_pointer_event_type type;
1700 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1701 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_POINTER, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1703 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1704 version = tizen_input_device_manager_get_version(_eflutil.wl.devmgr.devicemgr);
1705 EINA_SAFETY_ON_FALSE_RETURN_VAL((version >= 3), EFL_UTIL_ERROR_NOT_SUPPORTED);
1709 case EFL_UTIL_INPUT_POINTER_WHEEL_VERT:
1710 type = TIZEN_INPUT_DEVICE_MANAGER_AXIS_TYPE_WHEEL;
1712 case EFL_UTIL_INPUT_POINTER_WHEEL_HORZ:
1713 type = TIZEN_INPUT_DEVICE_MANAGER_AXIS_TYPE_HWHEEL;
1716 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1719 tizen_input_device_manager_generate_axis(_eflutil.wl.devmgr.devicemgr, type, wl_fixed_from_int(value));
1721 while ((_eflutil.wl.devmgr.request_notified == -1) && (ret_dispatch != -1))
1722 ret_dispatch = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1724 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1725 _eflutil.wl.devmgr.request_notified = -1;
1732 struct _efl_util_screenshot_h
1737 Eina_Bool shot_done;
1742 Eina_Bool auto_rotation;
1745 /* scrrenshot handle */
1746 static efl_util_screenshot_h g_screenshot;
1747 static Eina_Bool shot_mutex_init;
1748 static pthread_mutex_t shot_lock;
1751 _screenshot_mutex_init(void)
1753 if (shot_mutex_init)
1756 if (pthread_mutex_init(&shot_lock, NULL))
1758 fprintf(stderr, "[screenshot] fail: mutex init"); /*LCOV_EXCL_LINE*/
1759 return EINA_FALSE; /*LCOV_EXCL_LINE*/
1762 shot_mutex_init = EINA_TRUE;
1768 _screenshot_mutex_destory(void)
1770 if (!shot_mutex_init)
1773 if (pthread_mutex_destroy(&shot_lock))
1775 fprintf(stderr, "[screenshot] fail: mutex destory"); /*LCOV_EXCL_LINE*/
1776 return EINA_FALSE; /*LCOV_EXCL_LINE*/
1779 shot_mutex_init = EINA_FALSE;
1785 _screenshot_mutex_lock(void)
1787 if (!_screenshot_mutex_init())
1790 pthread_mutex_lock(&shot_lock);
1794 _screenshot_mutex_unlock(void)
1796 pthread_mutex_unlock(&shot_lock);
1800 _efl_util_wl_screenshooter_init()
1802 struct wl_display *display_wrapper = NULL;
1803 struct wl_registry *registry = NULL;
1806 if (_wl_init() == EINA_FALSE)
1809 wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1811 display_wrapper = wl_proxy_create_wrapper(_eflutil.wl.dpy);
1812 EINA_SAFETY_ON_NULL_RETURN_VAL(display_wrapper, EINA_FALSE);
1814 _eflutil.wl.shot.queue = wl_display_create_queue(_eflutil.wl.dpy);
1815 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.queue, fail_create_queue);
1817 wl_proxy_set_queue((struct wl_proxy *)display_wrapper, _eflutil.wl.shot.queue);
1819 registry = wl_display_get_registry(display_wrapper);
1820 EINA_SAFETY_ON_NULL_GOTO(registry, fail_get_registry);
1822 wl_registry_add_listener(registry, &_wl_reg_screenshooter_listener, NULL);
1824 ret = wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
1825 EINA_SAFETY_ON_TRUE_GOTO(ret == -1, fail_roundtrip);
1826 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.tz_screenshooter, fail_roundtrip);
1828 _eflutil.wl.shot.tbm_client = wayland_tbm_client_init(_eflutil.wl.dpy);
1829 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.tbm_client, fail_tbm_client_init);
1831 wl_registry_destroy(registry);
1832 wl_proxy_wrapper_destroy(display_wrapper);
1834 if (_eflutil.wl.shot.noti == 0)
1836 fprintf(stderr, "[screenshot] fail: privilege error\n"); /* LCOV_EXCL_LINE */
1842 fail_tbm_client_init:
1843 tizen_screenshooter_destroy(_eflutil.wl.shot.tz_screenshooter);
1844 _eflutil.wl.shot.tz_screenshooter = NULL;
1846 wl_registry_destroy(registry);
1848 wl_event_queue_destroy(_eflutil.wl.shot.queue);
1849 _eflutil.wl.shot.queue = NULL;
1851 wl_proxy_wrapper_destroy(display_wrapper);
1857 _efl_util_wl_screenshooter_deinit()
1859 if (_eflutil.wl.shot.tbm_client)
1861 wayland_tbm_client_deinit(_eflutil.wl.shot.tbm_client);
1862 _eflutil.wl.shot.tbm_client = NULL;
1865 if (_eflutil.wl.shot.tz_screenshooter)
1867 tizen_screenshooter_destroy(_eflutil.wl.shot.tz_screenshooter);
1868 _eflutil.wl.shot.tz_screenshooter = NULL;
1871 if (_eflutil.wl.shot.queue)
1873 wl_event_queue_destroy(_eflutil.wl.shot.queue);
1874 _eflutil.wl.shot.queue = NULL;
1878 API efl_util_screenshot_h
1879 efl_util_screenshot_initialize(int width, int height)
1881 efl_util_screenshot_h screenshot = NULL;
1883 if (width <= 0 || height <= 0)
1885 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1889 _screenshot_mutex_lock();
1893 if (g_screenshot->width != width || g_screenshot->height != height)
1895 g_screenshot->width = width;
1896 g_screenshot->height = height;
1898 set_last_result(EFL_UTIL_ERROR_NONE);
1900 _screenshot_mutex_unlock();
1902 return g_screenshot;
1905 screenshot = calloc(1, sizeof(struct _efl_util_screenshot_h));
1906 if (screenshot == NULL)
1908 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
1910 _screenshot_mutex_unlock();
1915 if (!_eflutil.wl.shot.tz_screenshooter)
1917 if (_efl_util_wl_screenshooter_init() == EINA_FALSE)
1919 if (_eflutil.wl.shot.noti == 0)
1920 set_last_result(EFL_UTIL_ERROR_PERMISSION_DENIED);
1922 set_last_result(EFL_UTIL_ERROR_SCREENSHOT_INIT_FAIL);
1926 _screenshot_mutex_unlock();
1932 screenshot->width = width;
1933 screenshot->height = height;
1934 screenshot->auto_rotation = EINA_TRUE;
1936 screenshot->bufmgr = wayland_tbm_client_get_bufmgr(_eflutil.wl.shot.tbm_client);
1937 EINA_SAFETY_ON_NULL_GOTO(screenshot->bufmgr, fail_get_bufmgr);
1939 g_screenshot = screenshot;
1940 set_last_result(EFL_UTIL_ERROR_NONE);
1942 tizen_screenshooter_set_user_data(_eflutil.wl.shot.tz_screenshooter, &screenshot->shot_done);
1944 _screenshot_mutex_unlock();
1946 return g_screenshot;
1948 /* LCOV_EXCL_START */
1950 set_last_result(EFL_UTIL_ERROR_SCREENSHOT_INIT_FAIL);
1951 _screenshot_mutex_unlock();
1952 efl_util_screenshot_deinitialize(screenshot);
1955 /* LCOV_EXCL_STOP */
1959 efl_util_screenshot_deinitialize(efl_util_screenshot_h screenshot)
1961 _screenshot_mutex_lock();
1965 _screenshot_mutex_unlock();
1966 _screenshot_mutex_destory();
1967 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1971 g_screenshot = NULL;
1973 _efl_util_wl_screenshooter_deinit();
1975 _screenshot_mutex_unlock();
1976 _screenshot_mutex_destory();
1978 return EFL_UTIL_ERROR_NONE;
1983 efl_util_screenshot_take_tbm_surface(efl_util_screenshot_h screenshot)
1985 tbm_surface_h t_surface = NULL;
1986 struct wl_buffer *buffer = NULL;
1987 Efl_Util_Wl_Output_Info *output;
1990 _screenshot_mutex_lock();
1992 if (!screenshot || (screenshot != g_screenshot))
1994 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1995 _screenshot_mutex_unlock();
1999 output = eina_list_nth(_eflutil.wl.shot.output_list, 0);
2002 fprintf(stderr, "[screenshot] fail: no output for screenshot\n"); /* LCOV_EXCL_LINE */
2006 t_surface = tbm_surface_create(screenshot->width, screenshot->height, TBM_FORMAT_XRGB8888);
2009 fprintf(stderr, "[screenshot] fail: tbm_surface_create\n"); /* LCOV_EXCL_LINE */
2013 buffer = wayland_tbm_client_create_buffer(_eflutil.wl.shot.tbm_client, t_surface);
2016 fprintf(stderr, "[screenshot] fail: create wl_buffer for screenshot\n"); /* LCOV_EXCL_LINE */
2020 tizen_screenshooter_shoot(_eflutil.wl.shot.tz_screenshooter, output->output, buffer);
2022 screenshot->shot_done = EINA_FALSE;
2024 while (!screenshot->shot_done && ret != -1)
2025 ret = wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
2029 fprintf(stderr, "[screenshot] fail: tizen_screenshooter_shoot\n"); /* LCOV_EXCL_LINE */
2033 wayland_tbm_client_destroy_buffer(_eflutil.wl.shot.tbm_client, buffer);
2035 /* reset shot_done for next screenshot */
2036 screenshot->shot_done = EINA_FALSE;
2038 set_last_result(EFL_UTIL_ERROR_NONE);
2040 _screenshot_mutex_unlock();
2046 tbm_surface_destroy(t_surface);
2048 wayland_tbm_client_destroy_buffer(_eflutil.wl.shot.tbm_client, buffer);
2050 set_last_result(EFL_UTIL_ERROR_SCREENSHOT_EXECUTION_FAIL);
2052 _screenshot_mutex_unlock();
2058 efl_util_screenshot_set_auto_rotation(efl_util_screenshot_h screenshot, int set)
2060 if (!screenshot || (screenshot != g_screenshot))
2061 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2063 if (!(set == 0 || set == 1))
2064 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2067 g_screenshot->auto_rotation = EINA_TRUE;
2069 g_screenshot->auto_rotation = EINA_FALSE;
2071 tizen_screenshooter_set_oneshot_auto_rotation(_eflutil.wl.shot.tz_screenshooter, g_screenshot->auto_rotation);
2073 return EFL_UTIL_ERROR_NONE;
2077 efl_util_screenshot_get_auto_rotation(efl_util_screenshot_h screenshot, int *set)
2079 if (!screenshot || (screenshot != g_screenshot) || !set)
2080 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2082 *set = g_screenshot->auto_rotation;
2084 return EFL_UTIL_ERROR_NONE;
2087 /* LCOV_EXCL_START */
2088 struct _efl_util_screenmirror_h
2090 struct tizen_screenmirror *tz_screenmirror;
2096 Eina_List *buffer_list;
2098 Eina_Bool mirror_working;
2101 Eina_Bool cb_content;
2102 efl_util_screenmirror_handler user_func;
2106 typedef struct _efl_util_mirror_buffer efl_util_mirror_buffer;
2107 struct _efl_util_mirror_buffer
2109 struct wl_buffer *buffer;
2111 tbm_surface_h t_surface;
2114 static efl_util_screenmirror_h g_screenmirror;
2117 _efl_util_screenmirror_loop(void *data)
2119 efl_util_screenmirror_h screenmirror;
2122 screenmirror = (efl_util_screenmirror_h)data;
2126 if (!screenmirror->mirror_working)
2129 ret = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
2132 fprintf(stderr, "[screenmirror] fail: dispatch_queue\n");
2140 static efl_util_mirror_buffer *
2141 _efl_util_create_mirror_buffer(efl_util_screenmirror_h screenmirror)
2143 efl_util_mirror_buffer *mbuffer;
2145 mbuffer = calloc(1, sizeof(struct _efl_util_mirror_buffer));
2146 EINA_SAFETY_ON_NULL_RETURN_VAL(mbuffer, NULL);
2148 mbuffer->w = screenmirror->width;
2149 mbuffer->h = screenmirror->height;
2151 mbuffer->t_surface = tbm_surface_internal_create_with_flags(mbuffer->w,
2152 mbuffer->h, TBM_FORMAT_ARGB8888, TBM_BO_SCANOUT);
2153 EINA_SAFETY_ON_NULL_GOTO(mbuffer->t_surface, fail_create_surface);
2155 mbuffer->buffer = wayland_tbm_client_create_buffer(_eflutil.wl.shot.tbm_client, mbuffer->t_surface);
2156 EINA_SAFETY_ON_NULL_GOTO(mbuffer->buffer, fail_create_buffer);
2161 tbm_surface_destroy(mbuffer->t_surface);
2162 fail_create_surface:
2169 _efl_util_destroy_mirror_buffer(efl_util_mirror_buffer *mbuffer)
2171 EINA_SAFETY_ON_NULL_RETURN(mbuffer);
2173 if (mbuffer->buffer)
2174 wl_buffer_destroy(mbuffer->buffer);
2180 _efl_util_screenmirror_handle_dequeued(void *data,
2181 struct tizen_screenmirror *tz_screenmirror, struct wl_buffer *buffer)
2183 efl_util_screenmirror_h screenmirror;
2184 efl_util_mirror_buffer *mbuffer;
2187 screenmirror = (efl_util_screenmirror_h)data;
2188 screenmirror->cb_start = EINA_TRUE;
2190 EINA_LIST_FOREACH_SAFE(screenmirror->buffer_list, l, ll, mbuffer)
2192 if (mbuffer->buffer == buffer)
2194 if (mbuffer->w != screenmirror->width || mbuffer->h != screenmirror->height ||
2195 !screenmirror->mirror_working)
2196 tbm_surface_destroy(mbuffer->t_surface);
2198 screenmirror->user_func(screenmirror, mbuffer->t_surface, screenmirror->user_data);
2200 screenmirror->buffer_list = eina_list_remove_list(screenmirror->buffer_list, l);
2201 _efl_util_destroy_mirror_buffer(mbuffer);
2207 mbuffer = _efl_util_create_mirror_buffer(screenmirror);
2208 if (mbuffer == NULL)
2210 fprintf(stderr, "[screenmirror] fail: buffer create\n");
2213 screenmirror->buffer_list = eina_list_append(screenmirror->buffer_list, mbuffer);
2214 tizen_screenmirror_queue(screenmirror->tz_screenmirror, mbuffer->buffer);
2218 _efl_util_screenmirror_handle_content(void *data,
2219 struct tizen_screenmirror *tz_screenmirror, uint32_t content)
2221 efl_util_screenmirror_h screenmirror = NULL;
2223 screenmirror = (efl_util_screenmirror_h)data;
2224 screenmirror->cb_content = EINA_TRUE;
2228 _efl_util_screenmirror_handle_stop(void *data, struct tizen_screenmirror *tz_screenmirror)
2230 efl_util_screenmirror_h screenmirror = NULL;
2232 screenmirror = (efl_util_screenmirror_h)data;
2233 screenmirror->cb_stop = EINA_TRUE;
2236 static const struct tizen_screenmirror_listener efl_util_screenmirror_listener = {
2237 _efl_util_screenmirror_handle_dequeued,
2238 _efl_util_screenmirror_handle_content,
2239 _efl_util_screenmirror_handle_stop
2242 API efl_util_screenmirror_h
2243 efl_util_screenmirror_initialize(int width, int height)
2245 efl_util_screenmirror_h screenmirror = NULL;
2246 efl_util_mirror_buffer *mbuffer;
2247 Efl_Util_Wl_Output_Info *output;
2250 if (width <= 0 || height <= 0)
2252 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2256 _screenshot_mutex_lock();
2260 if (g_screenmirror->mirror_working)
2262 set_last_result(EFL_UTIL_ERROR_INVALID_OPERATION);
2263 _screenshot_mutex_unlock();
2268 g_screenmirror->width = width;
2269 g_screenmirror->height = height;
2270 set_last_result(EFL_UTIL_ERROR_NONE);
2271 _screenshot_mutex_unlock();
2272 return g_screenmirror;
2276 screenmirror = calloc(1, sizeof(struct _efl_util_screenmirror_h));
2277 if (screenmirror == NULL)
2279 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
2280 _screenshot_mutex_unlock();
2284 if (!_eflutil.wl.shot.tz_screenshooter)
2286 if (_efl_util_wl_screenshooter_init() == EINA_FALSE)
2288 if (_eflutil.wl.shot.noti == 0)
2289 set_last_result(EFL_UTIL_ERROR_PERMISSION_DENIED);
2291 set_last_result(EFL_UTIL_ERROR_SCREENSHOT_INIT_FAIL);
2297 output = eina_list_nth(_eflutil.wl.shot.output_list, 0);
2300 set_last_result(EFL_UTIL_ERROR_NO_RESOURCE_AVAILABLE);
2301 fprintf(stderr, "[screenmirror] fail: no output for screenmirror\n");
2302 goto fail_get_output;
2305 screenmirror->tz_screenmirror = tizen_screenshooter_get_screenmirror(_eflutil.wl.shot.tz_screenshooter, output->output);
2306 wl_proxy_set_queue((struct wl_proxy *)screenmirror->tz_screenmirror, _eflutil.wl.shot.queue);
2307 tizen_screenmirror_add_listener(screenmirror->tz_screenmirror, &efl_util_screenmirror_listener, screenmirror);
2308 tizen_screenmirror_set_stretch(screenmirror->tz_screenmirror, TIZEN_SCREENMIRROR_STRETCH_KEEP_RATIO);
2309 screenmirror->width = width;
2310 screenmirror->height = height;
2312 g_screenmirror = screenmirror;
2314 for (i = 0; i < 1; i++)
2316 mbuffer = _efl_util_create_mirror_buffer(screenmirror);
2319 screenmirror->buffer_list = eina_list_append(screenmirror->buffer_list, mbuffer);
2320 tizen_screenmirror_queue(screenmirror->tz_screenmirror, mbuffer->buffer);
2323 fprintf(stderr, "[screenmirror] fail: buffer create %d\n", i);
2325 while (!screenmirror->cb_content && ret != -1)
2326 ret = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
2328 _screenshot_mutex_unlock();
2330 return screenmirror;
2335 _screenshot_mutex_unlock();
2340 efl_util_screenmirror_deinitialize(efl_util_screenmirror_h screenmirror)
2342 efl_util_mirror_buffer *mbuffer;
2345 _screenshot_mutex_lock();
2347 if (!screenmirror || (screenmirror != g_screenmirror))
2349 _screenshot_mutex_unlock();
2350 _screenshot_mutex_destory();
2351 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2354 if (screenmirror->mirror_working)
2356 fprintf(stderr, "[screenmirror] fail: execute stop before deinit\n");
2357 _screenshot_mutex_unlock();
2358 _screenshot_mutex_destory();
2359 return EFL_UTIL_ERROR_INVALID_OPERATION;
2362 EINA_LIST_FOREACH(screenmirror->buffer_list, l, mbuffer)
2364 tbm_surface_destroy(mbuffer->t_surface);
2365 _efl_util_destroy_mirror_buffer(mbuffer);
2367 eina_list_free(screenmirror->buffer_list);
2369 tizen_screenmirror_destroy(screenmirror->tz_screenmirror);
2371 g_screenmirror = NULL;
2373 _efl_util_wl_screenshooter_deinit();
2375 _screenshot_mutex_unlock();
2376 _screenshot_mutex_destory();
2378 return EFL_UTIL_ERROR_NONE;
2382 efl_util_screenmirror_set_handler(efl_util_screenmirror_h screenmirror,
2383 efl_util_screenmirror_handler func, void *data)
2385 _screenshot_mutex_lock();
2387 if (!screenmirror || (screenmirror != g_screenmirror) || !func)
2389 _screenshot_mutex_unlock();
2390 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2392 screenmirror->user_func = func;
2393 screenmirror->user_data = data;
2395 _screenshot_mutex_unlock();
2397 return EFL_UTIL_ERROR_NONE;
2401 efl_util_screenmirror_start(efl_util_screenmirror_h screenmirror)
2405 _screenshot_mutex_lock();
2407 if (!screenmirror || (screenmirror != g_screenmirror))
2409 _screenshot_mutex_unlock();
2410 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2412 else if (!screenmirror->user_func)
2414 _screenshot_mutex_unlock();
2415 return EFL_UTIL_ERROR_SCREENSHOT_EXECUTION_FAIL;
2417 else if (screenmirror->mirror_working)
2419 _screenshot_mutex_unlock();
2420 return EFL_UTIL_ERROR_NONE;
2423 screenmirror->cb_start = EINA_FALSE;
2424 screenmirror->mirror_working = EINA_TRUE;
2425 tizen_screenmirror_start(screenmirror->tz_screenmirror);
2426 while (!screenmirror->cb_start && ret != -1)
2427 ret = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
2430 fprintf(stderr, "[screenmirror] fail: tizen_screenmirror_start\n");
2431 _screenshot_mutex_unlock();
2432 return EFL_UTIL_ERROR_SCREENSHOT_EXECUTION_FAIL;
2435 ret = pthread_create(&screenmirror->thread, NULL, _efl_util_screenmirror_loop, screenmirror);
2438 fprintf(stderr, "[screenmirror] fail: thread create fail\n");
2439 _screenshot_mutex_unlock();
2440 return EFL_UTIL_ERROR_SCREENSHOT_EXECUTION_FAIL;
2443 pthread_setname_np(screenmirror->thread, "e_util_mirror");
2445 _screenshot_mutex_unlock();
2447 return EFL_UTIL_ERROR_NONE;
2451 efl_util_screenmirror_stop(efl_util_screenmirror_h screenmirror)
2455 _screenshot_mutex_lock();
2457 if (!screenmirror || (screenmirror != g_screenmirror))
2459 _screenshot_mutex_unlock();
2460 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2462 else if (!screenmirror->mirror_working)
2464 _screenshot_mutex_unlock();
2465 return EFL_UTIL_ERROR_NONE;
2467 screenmirror->mirror_working = EINA_FALSE;
2468 pthread_join(screenmirror->thread, NULL);
2469 tizen_screenmirror_stop(screenmirror->tz_screenmirror);
2470 screenmirror->cb_stop = EINA_FALSE;
2472 while (!screenmirror->cb_stop && ret != -1)
2473 ret = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
2476 fprintf(stderr, "[screenmirror] fail: tizen_screenmirror_stop\n");
2477 _screenshot_mutex_unlock();
2478 return EFL_UTIL_ERROR_SCREENSHOT_EXECUTION_FAIL;
2481 _screenshot_mutex_unlock();
2483 return EFL_UTIL_ERROR_NONE;
2485 /* LCOV_EXCL_STOP */
2487 struct _efl_util_gesture_h
2492 API int EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = 0;
2493 API int EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = 0;
2494 API int EFL_UTIL_EVENT_GESTURE_TAP = 0;
2495 API int EFL_UTIL_EVENT_GESTURE_PALM_COVER = 0;
2497 /* LCOV_EXCL_START */
2499 _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)
2501 _eflutil_defaultqueue.wl.gesture.request_notified = error;
2505 _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)
2507 efl_util_event_gesture_edge_swipe_s *ev = NULL;
2509 ev = (efl_util_event_gesture_edge_swipe_s *)calloc(1, sizeof(*ev));
2514 ev->fingers = fingers;
2519 ecore_event_add(EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE, ev, NULL, NULL);
2523 _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)
2525 _eflutil_defaultqueue.wl.gesture.request_notified = error;
2529 _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)
2531 efl_util_event_gesture_edge_drag_s *ev = NULL;
2533 ev = (efl_util_event_gesture_edge_drag_s *)calloc(1, sizeof(*ev));
2538 ev->fingers = fingers;
2543 ecore_event_add(EFL_UTIL_EVENT_GESTURE_EDGE_DRAG, ev, NULL, NULL);
2547 _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)
2549 _eflutil_defaultqueue.wl.gesture.request_notified = error;
2553 _cb_gesture_tap(void *data EINA_UNUSED, struct tizen_gesture *tizen_gesture EINA_UNUSED, uint32_t mode, uint32_t fingers, uint32_t repeats)
2555 efl_util_event_gesture_tap_s *ev = NULL;
2557 ev = (efl_util_event_gesture_tap_s *)calloc(1, sizeof(*ev));
2562 ev->fingers = fingers;
2563 ev->repeats = repeats;
2565 ecore_event_add(EFL_UTIL_EVENT_GESTURE_TAP, ev, NULL, NULL);
2567 /* LCOV_EXCL_STOP */
2570 _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)
2572 _eflutil_defaultqueue.wl.gesture.request_notified = error;
2575 /* LCOV_EXCL_START */
2577 _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)
2579 efl_util_event_gesture_palm_cover_s *ev = NULL;
2581 ev = (efl_util_event_gesture_palm_cover_s *)calloc(1, sizeof(*ev));
2586 ev->duration = duration;
2590 ev->pressure = wl_fixed_to_int(pressure);
2592 ecore_event_add(EFL_UTIL_EVENT_GESTURE_PALM_COVER, ev, NULL, NULL);
2594 /* LCOV_EXCL_STOP */
2597 _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)
2599 _eflutil_defaultqueue.wl.gesture.request_notified = error;
2602 static efl_util_error_e
2603 _efl_util_gesture_convert_error(int ret)
2607 case TIZEN_GESTURE_ERROR_NONE:
2608 return EFL_UTIL_ERROR_NONE;
2609 case TIZEN_GESTURE_ERROR_INVALID_DATA:
2610 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2611 case TIZEN_GESTURE_ERROR_NO_PERMISSION:
2612 return EFL_UTIL_ERROR_PERMISSION_DENIED;
2613 case TIZEN_GESTURE_ERROR_NO_SYSTEM_RESOURCES:
2614 return EFL_UTIL_ERROR_OUT_OF_MEMORY;
2615 case TIZEN_GESTURE_ERROR_GRABBED_ALREADY:
2616 return EFL_UTIL_ERROR_NO_RESOURCE_AVAILABLE;
2617 case TIZEN_GESTURE_ERROR_NOT_SUPPORTED:
2618 return EFL_UTIL_ERROR_NOT_SUPPORTED;
2620 return EFL_UTIL_ERROR_NONE;
2624 /* LCOV_EXCL_START */
2625 static efl_util_error_e
2626 _efl_util_gesture_verify_request_notified()
2628 int ret = EFL_UTIL_ERROR_NONE;
2630 while (_eflutil_defaultqueue.wl.gesture.request_notified == -1)
2631 wl_display_dispatch(_eflutil_defaultqueue.wl.dpy);
2633 ret = _efl_util_gesture_convert_error(_eflutil_defaultqueue.wl.gesture.request_notified);
2634 _eflutil_defaultqueue.wl.gesture.request_notified = -1;
2640 _efl_util_gesture_grab_edge_swipe(efl_util_gesture_data data, Eina_Bool grabbed)
2642 int ret = EFL_UTIL_ERROR_NONE;
2643 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2644 Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = NULL;
2645 unsigned int fingers = 0;
2646 unsigned int edge = 0;
2647 unsigned int edge_size = 0;
2648 unsigned int start_point = 0;
2649 unsigned int end_point = 0;
2651 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2653 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil_defaultqueue.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2654 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2655 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_SWIPE,
2656 EFL_UTIL_ERROR_INVALID_PARAMETER);
2658 edge_swipe_data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)data;
2660 fingers = edge_swipe_data->fingers;
2661 edge = edge_swipe_data->edge;
2662 edge_size = edge_swipe_data->edge_size;
2663 start_point = edge_swipe_data->start_point;
2664 end_point = edge_swipe_data->end_point;
2667 tizen_gesture_grab_edge_swipe(_eflutil_defaultqueue.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2669 tizen_gesture_ungrab_edge_swipe(_eflutil_defaultqueue.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2671 ret = _efl_util_gesture_verify_request_notified();
2677 _efl_util_gesture_grab_edge_drag(efl_util_gesture_data data, Eina_Bool grabbed)
2679 int ret = EFL_UTIL_ERROR_NONE;
2680 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2681 Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = NULL;
2682 unsigned int fingers = 0;
2683 unsigned int edge = 0;
2684 unsigned int edge_size = 0;
2685 unsigned int start_point = 0;
2686 unsigned int end_point = 0;
2688 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2690 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil_defaultqueue.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2691 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2692 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_DRAG,
2693 EFL_UTIL_ERROR_INVALID_PARAMETER);
2695 edge_drag_data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)data;
2697 fingers = edge_drag_data->fingers;
2698 edge = edge_drag_data->edge;
2699 edge_size = edge_drag_data->edge_size;
2700 start_point = edge_drag_data->start_point;
2701 end_point = edge_drag_data->end_point;
2704 tizen_gesture_grab_edge_drag(_eflutil_defaultqueue.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2706 tizen_gesture_ungrab_edge_drag(_eflutil_defaultqueue.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2708 ret = _efl_util_gesture_verify_request_notified();
2714 _efl_util_gesture_grab_tap(efl_util_gesture_data data, Eina_Bool grabbed)
2716 int ret = EFL_UTIL_ERROR_NONE;
2717 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2718 Efl_Util_Gesture_Tap_Grab_Data *tap_data = NULL;
2719 unsigned int fingers = 0;
2720 unsigned int repeats = 0;
2722 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2724 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil_defaultqueue.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2725 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2726 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_TAP,
2727 EFL_UTIL_ERROR_INVALID_PARAMETER);
2729 tap_data = (Efl_Util_Gesture_Tap_Grab_Data *)data;
2731 fingers = tap_data->fingers;
2732 repeats = tap_data->repeats;
2735 tizen_gesture_grab_tap(_eflutil_defaultqueue.wl.gesture.proto, fingers, repeats);
2737 tizen_gesture_ungrab_tap(_eflutil_defaultqueue.wl.gesture.proto, fingers, repeats);
2739 ret = _efl_util_gesture_verify_request_notified();
2745 _efl_util_gesture_grab_palm_cover(efl_util_gesture_data data, Eina_Bool grabbed)
2747 int ret = EFL_UTIL_ERROR_NONE;
2748 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2750 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2752 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil_defaultqueue.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2753 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2754 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_PALM_COVER,
2755 EFL_UTIL_ERROR_INVALID_PARAMETER);
2758 tizen_gesture_grab_palm_cover(_eflutil_defaultqueue.wl.gesture.proto);
2760 tizen_gesture_ungrab_palm_cover(_eflutil_defaultqueue.wl.gesture.proto);
2762 ret = _efl_util_gesture_verify_request_notified();
2766 /* LCOV_EXCL_STOP */
2768 API efl_util_gesture_h
2769 efl_util_gesture_initialize(void)
2771 efl_util_gesture_h gesture_h = NULL;
2773 gesture_h = (efl_util_gesture_h)calloc(1, sizeof(struct _efl_util_gesture_h));
2776 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2777 goto out; /* LCOV_EXCL_LINE */
2780 if (_wl_init_default_queue() == (int)EINA_FALSE)
2782 set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED); /* LCOV_EXCL_LINE */
2783 goto out; /* LCOV_EXCL_LINE */
2786 while (!_eflutil_defaultqueue.wl.gesture.proto)
2787 wl_display_dispatch(_eflutil_defaultqueue.wl.dpy); /* LCOV_EXCL_LINE */
2789 if (_eflutil_defaultqueue.wl.gesture.event_init <= 0)
2791 if (ecore_event_init() <= 0)
2793 set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED); /* LCOV_EXCL_LINE */
2794 goto out; /* LCOV_EXCL_LINE */
2796 EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = ecore_event_type_new();
2797 EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = ecore_event_type_new();
2798 EFL_UTIL_EVENT_GESTURE_TAP = ecore_event_type_new();
2799 EFL_UTIL_EVENT_GESTURE_PALM_COVER = ecore_event_type_new();
2801 _eflutil_defaultqueue.wl.gesture.event_init++;
2802 gesture_h->init = EINA_TRUE;
2804 set_last_result(EFL_UTIL_ERROR_NONE);
2808 /* LCOV_EXCL_START */
2815 /* LCOV_EXCL_STOP */
2819 efl_util_gesture_deinitialize(efl_util_gesture_h gesture_h)
2821 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2822 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2827 _eflutil_defaultqueue.wl.gesture.event_init--;
2829 if (_eflutil_defaultqueue.wl.gesture.event_init <= 0)
2831 _eflutil_defaultqueue.wl.gesture.event_init = 0;
2832 ecore_event_shutdown();
2833 EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = 0;
2834 EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = 0;
2835 EFL_UTIL_EVENT_GESTURE_TAP = 0;
2836 EFL_UTIL_EVENT_GESTURE_PALM_COVER = 0;
2839 return EFL_UTIL_ERROR_NONE;
2842 API efl_util_gesture_data
2843 efl_util_gesture_edge_swipe_new(efl_util_gesture_h gesture_h, unsigned int fingers, efl_util_gesture_edge_e edge)
2845 Efl_Util_Gesture_Edge_Swipe_Grab_Data *data;
2847 if (!gesture_h || gesture_h->init == EINA_FALSE)
2849 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2853 if (edge <= EFL_UTIL_GESTURE_EDGE_NONE || edge > EFL_UTIL_GESTURE_EDGE_LEFT)
2855 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2859 data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Edge_Swipe_Grab_Data));
2862 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2863 return NULL; /* LCOV_EXCL_LINE */
2866 data->base.type = TIZEN_GESTURE_TYPE_EDGE_SWIPE;
2867 data->fingers = fingers;
2869 data->edge_size = EFL_UTIL_GESTURE_EDGE_SIZE_FULL;
2871 set_last_result(EFL_UTIL_ERROR_NONE);
2873 return (void *)data;
2877 efl_util_gesture_edge_swipe_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2879 if (!gesture_h || gesture_h->init == EINA_FALSE)
2881 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2886 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2892 return EFL_UTIL_ERROR_NONE;
2896 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)
2898 Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = data;
2900 EINA_SAFETY_ON_NULL_RETURN_VAL(edge_swipe_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2901 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_swipe_data->base.type == TIZEN_GESTURE_TYPE_EDGE_SWIPE,
2902 EFL_UTIL_ERROR_INVALID_PARAMETER);
2903 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_size == EFL_UTIL_GESTURE_EDGE_SIZE_PARTIAL,
2904 EFL_UTIL_ERROR_INVALID_PARAMETER);
2905 EINA_SAFETY_ON_FALSE_RETURN_VAL(end_point > start_point, EFL_UTIL_ERROR_INVALID_PARAMETER);
2907 edge_swipe_data->edge_size = edge_size;
2908 edge_swipe_data->start_point = start_point;
2909 edge_swipe_data->end_point = end_point;
2911 return EFL_UTIL_ERROR_NONE;
2914 API efl_util_gesture_data
2915 efl_util_gesture_edge_drag_new(efl_util_gesture_h gesture_h, unsigned int fingers, efl_util_gesture_edge_e edge)
2917 Efl_Util_Gesture_Edge_Drag_Grab_Data *data;
2919 if (!gesture_h || gesture_h->init == EINA_FALSE)
2921 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2925 if (edge <= EFL_UTIL_GESTURE_EDGE_NONE || edge > EFL_UTIL_GESTURE_EDGE_LEFT)
2927 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2931 data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Edge_Drag_Grab_Data));
2934 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2935 return NULL; /* LCOV_EXCL_LINE */
2938 data->base.type = TIZEN_GESTURE_TYPE_EDGE_DRAG;
2939 data->fingers = fingers;
2941 data->edge_size = EFL_UTIL_GESTURE_EDGE_SIZE_FULL;
2943 set_last_result(EFL_UTIL_ERROR_NONE);
2945 return (void *)data;
2949 efl_util_gesture_edge_drag_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2951 if (!gesture_h || gesture_h->init == EINA_FALSE)
2953 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2958 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2964 return EFL_UTIL_ERROR_NONE;
2968 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)
2970 Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = data;
2972 EINA_SAFETY_ON_NULL_RETURN_VAL(edge_drag_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2973 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_drag_data->base.type == TIZEN_GESTURE_TYPE_EDGE_DRAG,
2974 EFL_UTIL_ERROR_INVALID_PARAMETER);
2975 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_size == EFL_UTIL_GESTURE_EDGE_SIZE_PARTIAL,
2976 EFL_UTIL_ERROR_INVALID_PARAMETER);
2977 EINA_SAFETY_ON_FALSE_RETURN_VAL(end_point > start_point, EFL_UTIL_ERROR_INVALID_PARAMETER);
2979 edge_drag_data->edge_size = edge_size;
2980 edge_drag_data->start_point = start_point;
2981 edge_drag_data->end_point = end_point;
2983 return EFL_UTIL_ERROR_NONE;
2986 API efl_util_gesture_data
2987 efl_util_gesture_tap_new(efl_util_gesture_h gesture_h, unsigned int fingers, unsigned int repeats)
2989 Efl_Util_Gesture_Tap_Grab_Data *data;
2991 if (!gesture_h || gesture_h->init == EINA_FALSE)
2993 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2997 if (fingers <= 1 || repeats <= 1)
2999 set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED);
3003 data = (Efl_Util_Gesture_Tap_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Tap_Grab_Data));
3006 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
3007 return NULL; /* LCOV_EXCL_LINE */
3010 data->base.type = TIZEN_GESTURE_TYPE_TAP;
3011 data->fingers = fingers;
3012 data->repeats = repeats;
3014 set_last_result(EFL_UTIL_ERROR_NONE);
3016 return (void *)data;
3020 efl_util_gesture_tap_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
3022 if (!gesture_h || gesture_h->init == EINA_FALSE)
3024 return EFL_UTIL_ERROR_INVALID_PARAMETER;
3029 return EFL_UTIL_ERROR_INVALID_PARAMETER;
3035 return EFL_UTIL_ERROR_NONE;
3038 API efl_util_gesture_data
3039 efl_util_gesture_palm_cover_new(efl_util_gesture_h gesture_h)
3041 Efl_Util_Gesture_Palm_Cover_Grab_Data *data;
3043 if (!gesture_h || gesture_h->init == EINA_FALSE)
3045 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
3049 data = (Efl_Util_Gesture_Palm_Cover_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Palm_Cover_Grab_Data));
3052 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
3053 return NULL; /* LCOV_EXCL_LINE */
3056 data->base.type = TIZEN_GESTURE_TYPE_PALM_COVER;
3058 set_last_result(EFL_UTIL_ERROR_NONE);
3060 return (void *)data;
3064 efl_util_gesture_palm_cover_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
3066 if (!gesture_h || gesture_h->init == EINA_FALSE)
3068 return EFL_UTIL_ERROR_INVALID_PARAMETER;
3073 return EFL_UTIL_ERROR_INVALID_PARAMETER;
3079 return EFL_UTIL_ERROR_NONE;
3082 /* LCOV_EXCL_START */
3084 efl_util_gesture_grab(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
3086 int ret = EFL_UTIL_ERROR_NONE;
3087 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
3089 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
3091 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
3092 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
3093 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
3095 switch (base_data->type)
3097 case TIZEN_GESTURE_TYPE_EDGE_SWIPE:
3098 ret = _efl_util_gesture_grab_edge_swipe(data, EINA_TRUE);
3100 case TIZEN_GESTURE_TYPE_EDGE_DRAG:
3101 ret = _efl_util_gesture_grab_edge_drag(data, EINA_TRUE);
3103 case TIZEN_GESTURE_TYPE_TAP:
3104 ret = _efl_util_gesture_grab_tap(data, EINA_TRUE);
3106 case TIZEN_GESTURE_TYPE_PALM_COVER:
3107 ret = _efl_util_gesture_grab_palm_cover(data, EINA_TRUE);
3110 return EFL_UTIL_ERROR_INVALID_PARAMETER;
3117 efl_util_gesture_ungrab(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
3119 int ret = EFL_UTIL_ERROR_NONE;
3120 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
3122 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
3124 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
3125 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
3126 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
3128 switch (base_data->type)
3130 case TIZEN_GESTURE_TYPE_EDGE_SWIPE:
3131 ret = _efl_util_gesture_grab_edge_swipe(data, EINA_FALSE);
3133 case TIZEN_GESTURE_TYPE_EDGE_DRAG:
3134 ret = _efl_util_gesture_grab_edge_drag(data, EINA_FALSE);
3136 case TIZEN_GESTURE_TYPE_TAP:
3137 ret = _efl_util_gesture_grab_tap(data, EINA_FALSE);
3139 case TIZEN_GESTURE_TYPE_PALM_COVER:
3140 ret = _efl_util_gesture_grab_palm_cover(data, EINA_FALSE);
3143 return EFL_UTIL_ERROR_INVALID_PARAMETER;
3148 /* LCOV_EXCL_STOP */
3151 efl_util_gesture_select(efl_util_gesture_h gesture_h, Evas_Object *window, efl_util_gesture_data data)
3153 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
3154 Ecore_Wl2_Window *wlwin;
3155 struct wl_surface *surface;
3158 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
3160 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
3161 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
3162 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
3163 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
3165 if (base_data->type != TIZEN_GESTURE_TYPE_PALM_COVER)
3166 return EFL_UTIL_ERROR_NOT_SUPPORTED;
3168 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
3169 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
3171 surface = ecore_wl2_window_surface_get(wlwin);
3172 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
3173 EFL_UTIL_ERROR_INVALID_PARAMETER);
3175 tizen_gesture_select_palm_cover(_eflutil_defaultqueue.wl.gesture.proto, surface);
3177 ret = _efl_util_gesture_verify_request_notified();
3183 efl_util_gesture_deselect(efl_util_gesture_h gesture_h, Evas_Object *window, efl_util_gesture_data data)
3185 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
3186 Ecore_Wl2_Window *wlwin;
3187 struct wl_surface *surface;
3190 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
3192 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
3193 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
3194 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
3195 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
3197 if (base_data->type != TIZEN_GESTURE_TYPE_PALM_COVER)
3198 return EFL_UTIL_ERROR_NOT_SUPPORTED;
3200 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
3201 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
3203 surface = ecore_wl2_window_surface_get(wlwin);
3204 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
3205 EFL_UTIL_ERROR_INVALID_PARAMETER);
3207 tizen_gesture_deselect_palm_cover(_eflutil_defaultqueue.wl.gesture.proto, surface);
3209 ret = _efl_util_gesture_verify_request_notified();
3214 /* LCOV_EXCL_START */
3216 efl_util_gesture_activate_set(efl_util_gesture_h gesture_h, unsigned int type, Eina_Bool active)
3220 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
3221 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
3222 EINA_SAFETY_ON_TRUE_RETURN_VAL(type == EFL_UTIL_GESTURE_TYPE_NONE, EFL_UTIL_ERROR_INVALID_PARAMETER);
3224 tizen_gesture_activate_set(_eflutil_defaultqueue.wl.gesture.proto, NULL, type, active);
3226 ret = _efl_util_gesture_verify_request_notified();
3230 /* LCOV_EXCL_STOP */
3233 efl_util_gesture_activate_set_on_window(efl_util_gesture_h gesture_h, Evas_Object *window, unsigned int type, Eina_Bool active)
3235 Ecore_Wl2_Window *wlwin;
3236 struct wl_surface *surface;
3239 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
3240 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
3241 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
3242 EINA_SAFETY_ON_TRUE_RETURN_VAL(type == EFL_UTIL_GESTURE_TYPE_NONE, EFL_UTIL_ERROR_INVALID_PARAMETER);
3244 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
3245 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
3247 surface = ecore_wl2_window_surface_get(wlwin);
3248 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
3249 EFL_UTIL_ERROR_INVALID_PARAMETER);
3251 tizen_gesture_activate_set(_eflutil_defaultqueue.wl.gesture.proto, surface, type, active);
3253 ret = _efl_util_gesture_verify_request_notified();