2 * Copyright (c) 2011-2017 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #define LOG_TAG "TIZEN_N_EFL_UTIL"
24 #include <sys/types.h>
28 #include <tbm_bufmgr.h>
29 #include <tbm_surface.h>
30 #include <tbm_surface_internal.h>
31 #include <Elementary.h>
32 #include <Ecore_Evas.h>
35 #include <Ecore_Wl2.h>
36 #include <wayland-client.h>
37 #include <wayland-tbm-client.h>
38 #include <tizen-extension-client-protocol.h>
39 #include <screenshooter-client-protocol.h>
41 #include <efl_util_screenshot_extension.h>
48 /* Determine Tizen profile at runtime */
49 #include <system_info.h>
51 TIZEN_PROFILE_UNKNOWN = 0,
52 TIZEN_PROFILE_MOBILE = 0x1,
53 TIZEN_PROFILE_WEARABLE = 0x2,
54 TIZEN_PROFILE_TV = 0x4,
55 TIZEN_PROFILE_IVI = 0x8,
56 TIZEN_PROFILE_COMMON = 0x10,
58 static tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN;
59 static tizen_profile_t _get_tizen_profile()
62 system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
63 switch (*profileName) {
66 profile = TIZEN_PROFILE_MOBILE;
70 profile = TIZEN_PROFILE_WEARABLE;
74 profile = TIZEN_PROFILE_TV;
78 profile = TIZEN_PROFILE_IVI;
80 default: // common or unknown ==> ALL ARE COMMON.
81 profile = TIZEN_PROFILE_COMMON;
87 static inline tizen_profile_t get_tizen_profile()
89 if (__builtin_expect(profile != TIZEN_PROFILE_UNKNOWN, 1))
91 return _get_tizen_profile();
95 #define LOG_TAG "TIZEN_N_EFL_UTIL"
96 #define EFL_UTIL_INPUT_GENERATOR_DEFAULT_TIME_OUT 1000
97 #define EFL_UTIL_INPUT_GENERATOR_DEFAULT_DISPATCH_TIME_OUT 10
98 #define EFL_UTIL_INPUT_GENERATOR_TOUCH_MAX_FINGER 10
100 typedef struct _Efl_Util_Wl_Surface_Lv_Info
102 void *surface; /* wl_surface */
104 Eina_Bool wait_for_done;
106 } Efl_Util_Wl_Surface_Lv_Info;
108 typedef struct _Efl_Util_Wl_Surface_Scr_Mode_Info
110 void *surface; /* wl_surface */
112 Eina_Bool wait_for_done;
114 } Efl_Util_Wl_Surface_Scr_Mode_Info;
116 typedef struct _Efl_Util_Wl_Surface_Brightness_Info
118 void *surface; /* wl_surface */
120 Eina_Bool wait_for_done;
122 } Efl_Util_Wl_Surface_Brightness_Info;
124 typedef struct _Efl_Util_Wl_Output_Info
126 struct wl_output *output;
127 int offset_x, offset_y, width, height;
128 } Efl_Util_Wl_Output_Info;
130 typedef struct _Efl_Util_Gesture_Common_Grab_Data
133 } Efl_Util_Gesture_Common_Grab_Data;
135 typedef struct _Efl_Util_Gesture_Edge_Swipe_Grab_Data
137 Efl_Util_Gesture_Common_Grab_Data base;
139 unsigned int fingers;
140 efl_util_gesture_edge_e edge;
141 efl_util_gesture_edge_size_e edge_size;
142 unsigned int start_point;
143 unsigned int end_point;
144 } Efl_Util_Gesture_Edge_Swipe_Grab_Data;
146 typedef struct _Efl_Util_Gesture_Edge_Drag_Grab_Data
148 Efl_Util_Gesture_Common_Grab_Data base;
150 unsigned int fingers;
151 efl_util_gesture_edge_e edge;
152 efl_util_gesture_edge_size_e edge_size;
153 unsigned int start_point;
154 unsigned int end_point;
155 } Efl_Util_Gesture_Edge_Drag_Grab_Data;
157 typedef struct _Efl_Util_Gesture_Tap_Grab_Data
159 Efl_Util_Gesture_Common_Grab_Data base;
161 unsigned int fingers;
162 unsigned int repeats;
163 } Efl_Util_Gesture_Tap_Grab_Data;
165 typedef struct _Efl_Util_Gesture_Palm_Cover_Grab_Data
167 Efl_Util_Gesture_Common_Grab_Data base;
168 } Efl_Util_Gesture_Palm_Cover_Grab_Data;
170 typedef struct _Efl_Util_Device_Info
172 struct tizen_input_device *device;
173 Ecore_Device_Class clas;
174 Eina_Stringshare *name;
175 } Efl_Util_Device_Info;
177 typedef struct _E_Devicemgr_Inputgen_Touch_Axis
184 } E_Devicemgr_Inputgen_Touch_Axis;
186 typedef struct _Efl_Util_Data
188 /* wayland related stuffs */
192 Ecore_Wl2_Display *wl2_display;
193 struct wl_display *dpy;
194 struct wl_event_queue *queue;
199 struct tizen_policy *proto;
200 Eina_Hash *hash_noti_lv;
201 Eina_Hash *hash_scr_mode;
205 struct wl_event_queue *queue;
206 struct screenshooter *screenshooter;
207 struct tizen_screenshooter *tz_screenshooter;
208 struct wayland_tbm_client *tbm_client;
209 Eina_List *output_list;
214 struct tizen_input_device_manager *devicemgr;
215 int request_notified;
217 Eina_List *wait_devices;
218 struct wl_event_source *wait_timer;
220 int request_touch_count;
222 struct wl_seat *seat;
226 struct tizen_display_policy *proto;
227 Eina_Hash *hash_brightness;
232 typedef struct _Efl_Util_Data_Default_Queue
234 /* wayland related stuffs */
238 Ecore_Wl2_Display *wl2_display;
239 struct wl_display *dpy;
244 struct tizen_gesture *proto;
245 int request_notified;
249 } Efl_Util_Data_Default_Queue;
252 static Efl_Util_Data _eflutil =
257 { 0, NULL, NULL, NULL }, /* tizen_policy protocol */
258 { NULL, NULL, NULL, NULL, NULL, 0 }, /* screenshooter protocol */
259 { NULL, -1, NULL, NULL, NULL, 0, 0 }, /* tizen_input_device_manager protocol */
260 NULL, /* wl_seat protocol */
261 { 0, NULL, NULL } /* display_policy protocol */
265 static Efl_Util_Data_Default_Queue _eflutil_defaultqueue =
270 { 0, NULL, -1, 0 } /* gesture protocol */
275 static Eina_Bool _wl_init(void);
276 static Eina_Bool _wl_init_default_queue(void);
277 static void _cb_wl_reg_global(void *data, struct wl_registry *reg, unsigned int name, const char *interface, unsigned int version);
278 static void _cb_wl_reg_global_remove(void *data, struct wl_registry *reg, unsigned int name);
279 static void _cb_wl_default_queue_reg_global(void *data, struct wl_registry *reg, unsigned int name, const char *interface, unsigned int version);
280 static void _cb_wl_default_queue_reg_global_remove(void *data, struct wl_registry *reg, unsigned int name);
281 static void _cb_wl_reg_screenshooter_global(void *data, struct wl_registry *reg, unsigned int name, const char *interface, unsigned int version);
282 static void _cb_wl_reg_screenshooter_global_remove(void *data, struct wl_registry *reg, unsigned int name);
283 static void _cb_wl_tz_policy_conformant(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface, uint32_t is_conformant);
284 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);
285 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);
286 static void _cb_wl_tz_policy_transient_for_done(void *data, struct tizen_policy *tizen_policy, uint32_t child_id);
287 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);
288 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);
289 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);
290 static void _cb_wl_tz_policy_allowed_aux_hint(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface_resource, int id);
291 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);
292 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);
294 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);
296 static void _cb_device_info(void *data, struct tizen_input_device *tizen_input_device EINA_UNUSED, const char *name, uint32_t clas, uint32_t subclas EINA_UNUSED, struct wl_array *axes EINA_UNUSED);
297 static void _cb_event_device(void *data EINA_UNUSED, struct tizen_input_device *tizen_input_device EINA_UNUSED, unsigned int serial EINA_UNUSED, const char *name EINA_UNUSED, uint32_t time EINA_UNUSED);
298 static void _cb_axis(void *data EINA_UNUSED, struct tizen_input_device *tizen_input_device EINA_UNUSED, uint32_t axis_type EINA_UNUSED, wl_fixed_t value EINA_UNUSED);
300 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);
301 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);
302 static void _cb_error(void *data EINA_UNUSED, struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED, uint32_t errorcode);
303 static void _cb_block_expired(void *data EINA_UNUSED, struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED);
304 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);
306 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);
307 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);
308 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);
309 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);
310 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);
311 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);
312 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);
313 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);
314 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);
317 static const struct wl_registry_listener _wl_reg_listener =
320 _cb_wl_reg_global_remove
323 static const struct wl_registry_listener _wl_reg_screenshooter_listener =
325 _cb_wl_reg_screenshooter_global,
326 _cb_wl_reg_screenshooter_global_remove
329 struct tizen_policy_listener _wl_tz_policy_listener =
331 _cb_wl_tz_policy_conformant,
332 _cb_wl_tz_policy_conformant_area,
333 _cb_wl_tz_policy_notification_done,
334 _cb_wl_tz_policy_transient_for_done,
335 _cb_wl_tz_policy_scr_mode_done,
336 _cb_wl_tz_policy_iconify_state_changed,
337 _cb_wl_tz_policy_supported_aux_hints,
338 _cb_wl_tz_policy_allowed_aux_hint,
339 _cb_wl_tz_policy_aux_message,
340 _cb_wl_conformant_region,
343 static const struct tizen_input_device_listener _wl_tz_input_device_listener =
350 struct tizen_input_device_manager_listener _wl_tz_devmgr_listener =
359 struct tizen_display_policy_listener _wl_tz_display_policy_listener =
361 _cb_wl_tz_display_policy_brightness_done,
364 static const struct wl_registry_listener _wl_default_queue_reg_listener =
366 _cb_wl_default_queue_reg_global,
367 _cb_wl_default_queue_reg_global_remove
370 struct tizen_gesture_listener _wl_tz_gesture_listener =
372 _cb_gesture_edge_swipe_notify,
373 _cb_gesture_edge_swipe,
374 _cb_gesture_edge_drag_notify,
375 _cb_gesture_edge_drag,
376 _cb_gesture_tap_notify,
378 _cb_gesture_palm_cover_notify,
379 _cb_gesture_palm_cover,
380 _cb_gesture_activate_notify
386 struct wl_display *display_wrapper = NULL;
387 struct wl_registry *reg = NULL;
389 if (_eflutil.wl.init) return EINA_TRUE;
393 _eflutil.wl.wl2_display = ecore_wl2_display_connect(NULL);
394 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.wl2_display, fail);
395 _eflutil.wl.dpy = ecore_wl2_display_get(_eflutil.wl.wl2_display);
396 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.dpy, fail);
398 display_wrapper = wl_proxy_create_wrapper(_eflutil.wl.dpy);
399 EINA_SAFETY_ON_NULL_GOTO(display_wrapper, fail);
401 _eflutil.wl.queue = wl_display_create_queue(_eflutil.wl.dpy);
402 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.queue, fail);
404 wl_proxy_set_queue((struct wl_proxy *)display_wrapper, _eflutil.wl.queue);
406 reg = wl_display_get_registry(display_wrapper);
407 wl_proxy_wrapper_destroy(display_wrapper);
408 display_wrapper = NULL;
409 EINA_SAFETY_ON_NULL_GOTO(reg, fail);
411 wl_registry_add_listener(reg, &_wl_reg_listener, NULL);
413 _eflutil.wl.init = EINA_TRUE;
418 wl_proxy_wrapper_destroy(display_wrapper);
420 if (_eflutil.wl.queue)
422 wl_event_queue_destroy(_eflutil.wl.queue);
423 _eflutil.wl.queue = NULL;
426 ecore_wl2_shutdown();
431 _wl_init_default_queue(void)
433 struct wl_display *display_wrapper = NULL;
434 struct wl_registry *reg = NULL;
436 if (_eflutil_defaultqueue.wl.init) return EINA_TRUE;
438 if (ecore_wl2_init() <= 0) return EINA_FALSE;
440 _eflutil_defaultqueue.wl.wl2_display = ecore_wl2_connected_display_get(NULL);
441 EINA_SAFETY_ON_NULL_GOTO(_eflutil_defaultqueue.wl.wl2_display, fail);
442 _eflutil_defaultqueue.wl.dpy = ecore_wl2_display_get(_eflutil_defaultqueue.wl.wl2_display);
443 EINA_SAFETY_ON_NULL_GOTO(_eflutil_defaultqueue.wl.dpy, fail);
445 display_wrapper = wl_proxy_create_wrapper(_eflutil_defaultqueue.wl.dpy);
446 EINA_SAFETY_ON_NULL_GOTO(display_wrapper, fail);
448 reg = wl_display_get_registry(display_wrapper);
449 wl_proxy_wrapper_destroy(display_wrapper);
450 display_wrapper = NULL;
451 EINA_SAFETY_ON_NULL_GOTO(reg, fail);
453 wl_registry_add_listener(reg, &_wl_default_queue_reg_listener, NULL);
455 _eflutil_defaultqueue.wl.init = EINA_TRUE;
460 ecore_wl2_shutdown();
465 _cb_wl_output_geometry(void *data, struct wl_output *wl_output, int x, int y,
466 int physical_width, int physical_height, int subpixel,
467 const char *make, const char *model, int transform)
469 Efl_Util_Wl_Output_Info *output = wl_output_get_user_data(wl_output);
470 if (wl_output == output->output)
472 output->offset_x = x;
473 output->offset_y = y;
478 _cb_wl_output_mode(void *data, struct wl_output *wl_output, uint32_t flags,
479 int width, int height, int refresh)
481 Efl_Util_Wl_Output_Info *output = wl_output_get_user_data(wl_output);
482 if (wl_output == output->output && (flags & WL_OUTPUT_MODE_CURRENT))
484 output->width = width;
485 output->height = height;
490 _cb_wl_output_done(void *data, struct wl_output *wl_output)
495 _cb_wl_output_scale(void *data, struct wl_output *wl_output, int32_t factor)
499 static const struct wl_output_listener output_listener =
501 _cb_wl_output_geometry,
508 _cb_wl_screenshot_done(void *data, struct screenshooter *screenshooter)
510 Eina_Bool *shot_done = (Eina_Bool*)data;
512 *shot_done = EINA_TRUE;
515 static const struct screenshooter_listener screenshooter_listener =
517 _cb_wl_screenshot_done
521 _cb_tz_screenshot_format(void *data, struct tizen_screenshooter *tz_screenshooter, uint32_t format)
526 _cb_tz_screenshot_noti(void *data, struct tizen_screenshooter *tz_screenshooter, uint32_t noti)
528 _eflutil.wl.shot.noti = noti;
531 static const struct tizen_screenshooter_listener tz_screenshooter_listener =
533 _cb_tz_screenshot_format,
534 _cb_tz_screenshot_noti
538 _cb_seat_capabilities(void *data, struct wl_seat *seat, enum wl_seat_capability caps)
543 _cb_seat_name(void *data, struct wl_seat *seat EINA_UNUSED, const char *name)
547 static const struct wl_seat_listener _seat_listener =
549 _cb_seat_capabilities,
554 _cb_wl_reg_global(void *data,
555 struct wl_registry *reg,
557 const char *interface,
558 unsigned int version)
560 if (!strcmp(interface, "tizen_policy"))
562 struct tizen_policy *proto;
563 proto = wl_registry_bind(reg,
565 &tizen_policy_interface,
569 tizen_policy_add_listener(proto,
570 &_wl_tz_policy_listener,
573 _eflutil.wl.policy.hash_noti_lv = eina_hash_pointer_new(free);
574 _eflutil.wl.policy.hash_scr_mode = eina_hash_pointer_new(free);
575 _eflutil.wl.policy.proto = proto;
576 _eflutil.wl.policy.id = id;
578 else if (strcmp(interface, "wl_output") == 0)
580 Efl_Util_Wl_Output_Info *output = calloc(1, sizeof(Efl_Util_Wl_Output_Info));
581 EINA_SAFETY_ON_NULL_RETURN(output);
583 _eflutil.wl.shot.output_list = eina_list_append(_eflutil.wl.shot.output_list, output);
585 output->output = wl_registry_bind(reg, id, &wl_output_interface, version);
586 wl_output_add_listener(output->output, &output_listener, output);
588 else if(strcmp(interface, "wl_seat") == 0)
590 _eflutil.wl.seat = wl_registry_bind(reg, id, &wl_seat_interface, version);
591 wl_seat_add_listener(_eflutil.wl.seat, &_seat_listener, NULL);
593 else if (strcmp(interface, "tizen_input_device_manager") == 0)
595 _eflutil.wl.devmgr.devicemgr = wl_registry_bind(reg, id, &tizen_input_device_manager_interface, version);
596 tizen_input_device_manager_add_listener(_eflutil.wl.devmgr.devicemgr, &_wl_tz_devmgr_listener, NULL);
598 else if (!strcmp(interface, "tizen_display_policy"))
600 _eflutil.wl.display_policy.proto = wl_registry_bind(reg, id, &tizen_display_policy_interface, version);
601 if (!_eflutil.wl.display_policy.proto) return;
603 tizen_display_policy_add_listener(_eflutil.wl.display_policy.proto,
604 &_wl_tz_display_policy_listener,
607 _eflutil.wl.display_policy.hash_brightness = eina_hash_pointer_new(free);
608 _eflutil.wl.display_policy.id = id;
611 /* LCOV_EXCL_START */
613 _cb_wl_reg_global_remove(void *data,
614 struct wl_registry *reg,
617 /* unset each global id number to 0 since global id is started
618 * from number 1 on server side display structure
620 if (id == _eflutil.wl.policy.id)
622 _eflutil.wl.policy.id = 0;
623 _eflutil.wl.policy.proto = NULL;
624 eina_hash_free(_eflutil.wl.policy.hash_noti_lv);
625 eina_hash_free(_eflutil.wl.policy.hash_scr_mode);
627 else if (id == _eflutil.wl.display_policy.id)
629 _eflutil.wl.display_policy.id = 0;
630 _eflutil.wl.display_policy.proto = NULL;
631 eina_hash_free(_eflutil.wl.display_policy.hash_brightness);
637 _cb_wl_default_queue_reg_global(void *data,
638 struct wl_registry *reg,
640 const char *interface,
641 unsigned int version)
643 if (strcmp(interface, "tizen_gesture") == 0)
645 _eflutil_defaultqueue.wl.gesture.id = id;
646 _eflutil_defaultqueue.wl.gesture.proto = wl_registry_bind(reg, id, &tizen_gesture_interface, version);
647 tizen_gesture_add_listener(_eflutil_defaultqueue.wl.gesture.proto, &_wl_tz_gesture_listener, NULL);
650 /* LCOV_EXCL_START */
652 _cb_wl_default_queue_reg_global_remove(void *data,
653 struct wl_registry *reg,
656 if (id == _eflutil_defaultqueue.wl.gesture.id)
658 _eflutil_defaultqueue.wl.gesture.id = 0;
659 _eflutil_defaultqueue.wl.gesture.proto = NULL;
666 _cb_wl_reg_screenshooter_global(void *data,
667 struct wl_registry *reg,
669 const char *interface,
670 unsigned int version)
672 if (strcmp(interface, "screenshooter") == 0)
674 _eflutil.wl.shot.screenshooter = wl_registry_bind(reg, name, &screenshooter_interface, version);
675 screenshooter_add_listener(_eflutil.wl.shot.screenshooter, &screenshooter_listener, NULL);
677 else if (strcmp(interface, "tizen_screenshooter") == 0)
679 _eflutil.wl.shot.tz_screenshooter = wl_registry_bind(reg, name, &tizen_screenshooter_interface, version);
680 tizen_screenshooter_add_listener(_eflutil.wl.shot.tz_screenshooter, &tz_screenshooter_listener, NULL);
682 wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
686 /* LCOV_EXCL_START */
688 _cb_wl_reg_screenshooter_global_remove(void *data,
689 struct wl_registry *reg,
695 _cb_wl_tz_policy_conformant(void *data, struct tizen_policy *tizen_policy,
696 struct wl_surface *surface, uint32_t is_conformant)
701 _cb_wl_tz_policy_conformant_area(void *data, struct tizen_policy *tizen_policy,
702 struct wl_surface *surface, uint32_t conformant_part,
703 uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h)
709 _cb_wl_tz_policy_notification_done(void *data,
710 struct tizen_policy *tizen_policy,
711 struct wl_surface *surface,
715 Efl_Util_Wl_Surface_Lv_Info *lv_info;
717 lv_info = eina_hash_find(_eflutil.wl.policy.hash_noti_lv, &surface);
720 lv_info->level = level;
721 lv_info->wait_for_done = EINA_FALSE;
722 lv_info->state = state;
726 /* LCOV_EXCL_START */
728 _cb_wl_tz_policy_transient_for_done(void *data, struct tizen_policy *tizen_policy, uint32_t child_id)
734 _cb_wl_tz_policy_scr_mode_done(void *data,
735 struct tizen_policy *tizen_policy,
736 struct wl_surface *surface,
740 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
742 scr_mode_info = eina_hash_find(_eflutil.wl.policy.hash_scr_mode, &surface);
745 scr_mode_info->mode = mode;
746 scr_mode_info->wait_for_done = EINA_FALSE;
747 scr_mode_info->state = state;
751 /* LCOV_EXCL_START */
752 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)
756 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)
760 static void _cb_wl_tz_policy_allowed_aux_hint(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface_resource, int id)
764 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)
767 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)
773 _cb_wl_tz_display_policy_brightness_done(void *data,
774 struct tizen_display_policy *tizen_display_policy,
775 struct wl_surface *surface,
779 Efl_Util_Wl_Surface_Brightness_Info *brightness_info;
781 brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
784 brightness_info->brightness = brightness;
785 brightness_info->wait_for_done = EINA_FALSE;
786 brightness_info->state = state;
791 _cb_window_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
793 Efl_Util_Wl_Surface_Lv_Info *lv_info;
796 if (EINA_UNLIKELY(!lv_info))
799 eina_hash_del(_eflutil.wl.policy.hash_noti_lv, &lv_info->surface, lv_info);
803 efl_util_set_notification_window_level(Evas_Object *window,
804 efl_util_notification_level_e level)
808 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
809 EINA_SAFETY_ON_FALSE_RETURN_VAL((level >= EFL_UTIL_NOTIFICATION_LEVEL_NONE) &&
810 (level <= EFL_UTIL_NOTIFICATION_LEVEL_TOP),
811 EFL_UTIL_ERROR_INVALID_PARAMETER);
814 Ecore_Wl2_Window *wlwin;
815 struct wl_surface *surface;
816 Efl_Util_Wl_Surface_Lv_Info *lv_info;
817 Ecore_Wl2_Window_Type wl_type;
820 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
822 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
823 EINA_SAFETY_ON_NULL_RETURN_VAL(wlwin, EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
825 type = elm_win_type_get(window);
826 if (type != ELM_WIN_NOTIFICATION)
828 wl_type = ecore_wl2_window_type_get(wlwin);
829 EINA_SAFETY_ON_FALSE_RETURN_VAL((wl_type == ECORE_WL2_WINDOW_TYPE_NOTIFICATION),
830 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
833 while (!_eflutil.wl.policy.proto)
834 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
836 surface = ecore_wl2_window_surface_get(wlwin);
837 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
838 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
840 lv_info = eina_hash_find(_eflutil.wl.policy.hash_noti_lv, &surface);
843 lv_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Lv_Info));
844 EINA_SAFETY_ON_NULL_RETURN_VAL(lv_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
846 lv_info->surface = surface;
847 lv_info->level = (int)level;
848 lv_info->wait_for_done = EINA_TRUE;
849 lv_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
850 eina_hash_add(_eflutil.wl.policy.hash_noti_lv,
854 evas_object_event_callback_add(window, EVAS_CALLBACK_DEL,
855 _cb_window_del, lv_info);
859 lv_info->level = (int)level;
860 lv_info->wait_for_done = EINA_TRUE;
861 lv_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
865 tizen_policy_set_notification_level(_eflutil.wl.policy.proto,
866 surface, (int)level);
868 if (lv_info->wait_for_done)
871 while (lv_info->wait_for_done && (count < 3))
873 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
874 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
878 if (lv_info->wait_for_done)
880 return EFL_UTIL_ERROR_INVALID_PARAMETER;
884 if (lv_info->state == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
886 return EFL_UTIL_ERROR_PERMISSION_DENIED;
891 return EFL_UTIL_ERROR_NONE;
895 efl_util_get_notification_window_level(Evas_Object *window,
896 efl_util_notification_level_e *level)
900 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
901 EINA_SAFETY_ON_NULL_RETURN_VAL(level, EFL_UTIL_ERROR_INVALID_PARAMETER);
904 Ecore_Wl2_Window *wlwin;
905 struct wl_surface *surface;
906 Efl_Util_Wl_Surface_Lv_Info *lv_info;
907 Ecore_Wl2_Window_Type wl_type;
910 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
912 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
913 EINA_SAFETY_ON_NULL_RETURN_VAL(wlwin, EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
915 type = elm_win_type_get(window);
916 if (type != ELM_WIN_NOTIFICATION)
918 wl_type = ecore_wl2_window_type_get(wlwin);
919 EINA_SAFETY_ON_FALSE_RETURN_VAL((wl_type == ECORE_WL2_WINDOW_TYPE_NOTIFICATION),
920 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
923 while (!_eflutil.wl.policy.proto)
924 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
926 surface = ecore_wl2_window_surface_get(wlwin);
927 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
928 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
930 lv_info = eina_hash_find(_eflutil.wl.policy.hash_noti_lv, &surface);
933 if (lv_info->wait_for_done)
936 while ((lv_info->wait_for_done) && (count < 3))
938 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
939 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
943 if (lv_info->wait_for_done)
945 *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
946 return EFL_UTIL_ERROR_INVALID_PARAMETER;
950 switch (lv_info->level)
952 case TIZEN_POLICY_LEVEL_NONE: *level = EFL_UTIL_NOTIFICATION_LEVEL_NONE; break;
953 case TIZEN_POLICY_LEVEL_DEFAULT: *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT; break;
954 case TIZEN_POLICY_LEVEL_MEDIUM: *level = EFL_UTIL_NOTIFICATION_LEVEL_MEDIUM; break;
955 case TIZEN_POLICY_LEVEL_HIGH: *level = EFL_UTIL_NOTIFICATION_LEVEL_HIGH; break;
956 case TIZEN_POLICY_LEVEL_TOP: *level = EFL_UTIL_NOTIFICATION_LEVEL_TOP; break;
957 default: *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
958 return EFL_UTIL_ERROR_INVALID_PARAMETER;
960 return EFL_UTIL_ERROR_NONE;
963 *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
965 return EFL_UTIL_ERROR_NONE;
969 efl_util_set_window_opaque_state(Evas_Object *window,
974 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
975 EINA_SAFETY_ON_FALSE_RETURN_VAL(((opaque >= 0) && (opaque <= 1)),
976 EFL_UTIL_ERROR_INVALID_PARAMETER);
978 Ecore_Wl2_Window *wlwin;
979 struct wl_surface *surface;
981 if (!_eflutil.wl.policy.proto)
986 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
988 while (!_eflutil.wl.policy.proto && ret != -1)
989 ret = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
991 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.policy.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
994 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
996 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
998 surface = ecore_wl2_window_surface_get(wlwin);
1000 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
1002 tizen_policy_set_opaque_state(_eflutil.wl.policy.proto, surface, opaque);
1004 return EFL_UTIL_ERROR_NONE;
1008 efl_util_set_window_screen_mode(Evas_Object *window,
1009 efl_util_screen_mode_e mode)
1011 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1012 EINA_SAFETY_ON_FALSE_RETURN_VAL(((mode >= EFL_UTIL_SCREEN_MODE_DEFAULT) &&
1013 (mode <= EFL_UTIL_SCREEN_MODE_ALWAYS_ON)),
1014 EFL_UTIL_ERROR_INVALID_PARAMETER);
1016 Ecore_Wl2_Window *wlwin;
1017 struct wl_surface *surface;
1018 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
1022 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1024 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
1027 while (!_eflutil.wl.policy.proto)
1028 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1030 surface = ecore_wl2_window_surface_get(wlwin);
1031 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1032 EFL_UTIL_ERROR_INVALID_PARAMETER);
1034 scr_mode_info = eina_hash_find(_eflutil.wl.policy.hash_scr_mode, &surface);
1037 scr_mode_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Scr_Mode_Info));
1038 EINA_SAFETY_ON_NULL_RETURN_VAL(scr_mode_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
1040 scr_mode_info->surface = surface;
1041 scr_mode_info->mode = (unsigned int)mode;
1042 scr_mode_info->wait_for_done = EINA_TRUE;
1043 scr_mode_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
1045 eina_hash_add(_eflutil.wl.policy.hash_scr_mode,
1051 scr_mode_info->mode = (unsigned int)mode;
1052 scr_mode_info->wait_for_done = EINA_TRUE;
1053 scr_mode_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
1056 tizen_policy_set_window_screen_mode(_eflutil.wl.policy.proto,
1057 surface, (unsigned int)mode);
1058 if (scr_mode_info->wait_for_done)
1061 while (scr_mode_info->wait_for_done && (count < 3))
1063 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
1064 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1068 if (scr_mode_info->wait_for_done)
1070 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1074 if (scr_mode_info->state == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
1076 return EFL_UTIL_ERROR_PERMISSION_DENIED;
1081 return EFL_UTIL_ERROR_NONE;
1084 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1088 efl_util_get_window_screen_mode(Evas_Object *window,
1089 efl_util_screen_mode_e *mode)
1091 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1092 EINA_SAFETY_ON_NULL_RETURN_VAL(mode, EFL_UTIL_ERROR_INVALID_PARAMETER);
1094 Ecore_Wl2_Window *wlwin;
1095 struct wl_surface *surface;
1096 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
1100 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1102 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
1105 while (!_eflutil.wl.policy.proto)
1106 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1108 surface = ecore_wl2_window_surface_get(wlwin);
1109 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1110 EFL_UTIL_ERROR_INVALID_PARAMETER);
1112 scr_mode_info = eina_hash_find(_eflutil.wl.policy.hash_scr_mode, &surface);
1115 if (scr_mode_info->wait_for_done)
1117 while (scr_mode_info->wait_for_done)
1119 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
1120 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1124 switch (scr_mode_info->mode)
1126 case TIZEN_POLICY_MODE_DEFAULT: *mode = EFL_UTIL_SCREEN_MODE_DEFAULT; break;
1127 case TIZEN_POLICY_MODE_ALWAYS_ON: *mode = EFL_UTIL_SCREEN_MODE_ALWAYS_ON; break;
1128 default: *mode = EFL_UTIL_SCREEN_MODE_DEFAULT;
1129 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1131 return EFL_UTIL_ERROR_NONE;
1135 *mode = EFL_UTIL_SCREEN_MODE_DEFAULT;
1136 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1140 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1144 efl_util_set_window_brightness(Evas_Object *window, int brightness)
1146 Ecore_Wl2_Window *wlwin;
1147 struct wl_surface *surface;
1148 Efl_Util_Wl_Surface_Brightness_Info *brightness_info;
1151 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1152 EINA_SAFETY_ON_FALSE_RETURN_VAL(brightness <= 100, EFL_UTIL_ERROR_INVALID_PARAMETER);
1155 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1157 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
1160 while (!_eflutil.wl.display_policy.proto)
1161 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1163 surface = ecore_wl2_window_surface_get(wlwin);
1164 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1165 EFL_UTIL_ERROR_INVALID_PARAMETER);
1167 brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
1168 if (!brightness_info)
1170 brightness_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Brightness_Info));
1171 EINA_SAFETY_ON_NULL_RETURN_VAL(brightness_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
1173 brightness_info->surface = surface;
1174 brightness_info->brightness = brightness;
1175 brightness_info->wait_for_done = EINA_TRUE;
1176 brightness_info->state = TIZEN_DISPLAY_POLICY_ERROR_STATE_NONE;
1178 eina_hash_add(_eflutil.wl.display_policy.hash_brightness,
1184 brightness_info->brightness = brightness;
1185 brightness_info->wait_for_done = EINA_TRUE;
1186 brightness_info->state = TIZEN_DISPLAY_POLICY_ERROR_STATE_NONE;
1189 tizen_display_policy_set_window_brightness(_eflutil.wl.display_policy.proto,
1190 surface, brightness);
1191 if (brightness_info->wait_for_done)
1194 while (brightness_info->wait_for_done && (count < 3))
1196 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
1197 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1201 if (brightness_info->wait_for_done)
1203 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1207 if (brightness_info->state == TIZEN_DISPLAY_POLICY_ERROR_STATE_PERMISSION_DENIED)
1209 return EFL_UTIL_ERROR_PERMISSION_DENIED;
1213 return EFL_UTIL_ERROR_NONE;
1216 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1220 efl_util_get_window_brightness(Evas_Object *window, int *brightness)
1222 Ecore_Wl2_Window *wlwin;
1223 struct wl_surface *surface;
1224 Efl_Util_Wl_Surface_Brightness_Info *brightness_info;
1227 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1228 EINA_SAFETY_ON_NULL_RETURN_VAL(brightness, EFL_UTIL_ERROR_INVALID_PARAMETER);
1231 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1233 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
1234 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
1236 while (!_eflutil.wl.display_policy.proto)
1237 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1239 surface = ecore_wl2_window_surface_get(wlwin);
1240 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1241 EFL_UTIL_ERROR_INVALID_PARAMETER);
1243 brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
1244 if (brightness_info)
1246 if (brightness_info->wait_for_done)
1248 while (brightness_info->wait_for_done)
1250 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
1251 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1254 *brightness = brightness_info->brightness;
1259 return EFL_UTIL_ERROR_NONE;
1263 struct _efl_util_inputgen_h
1265 unsigned int init_type;
1267 E_Devicemgr_Inputgen_Touch_Axis *axis_info;
1271 _efl_util_input_check_wait_device_full(void)
1273 Eina_List *l, *ll, *l_next;
1274 Efl_Util_Device_Info *dev, *wait_dev;
1277 wait_cnt = eina_list_count(_eflutil.wl.devmgr.wait_devices);
1278 if (wait_cnt <= 0) return EINA_TRUE;
1280 EINA_LIST_FOREACH(_eflutil.wl.devmgr.devices, l, dev)
1282 EINA_LIST_FOREACH_SAFE(_eflutil.wl.devmgr.wait_devices, ll, l_next, wait_dev)
1284 if ((dev->clas == wait_dev->clas) &&
1285 (!strncmp(dev->name, wait_dev->name, eina_stringshare_strlen(wait_dev->name))))
1287 eina_stringshare_del(wait_dev->name);
1288 _eflutil.wl.devmgr.wait_devices = eina_list_remove_list(_eflutil.wl.devmgr.wait_devices, ll);
1292 if (wait_cnt <= 0) return EINA_TRUE;
1303 _efl_util_input_check_wait_device(const char *name, unsigned int type)
1305 Eina_List *l, *l_next;
1306 Efl_Util_Device_Info *wait_dev;
1309 wait_cnt = eina_list_count(_eflutil.wl.devmgr.wait_devices);
1310 if (wait_cnt <= 0) return EINA_TRUE;
1312 EINA_LIST_FOREACH_SAFE(_eflutil.wl.devmgr.wait_devices, l, l_next, wait_dev)
1314 if ((type == wait_dev->clas) &&
1315 (!strncmp(name, wait_dev->name, eina_stringshare_strlen(wait_dev->name))))
1317 eina_stringshare_del(wait_dev->name);
1318 _eflutil.wl.devmgr.wait_devices = eina_list_remove_list(_eflutil.wl.devmgr.wait_devices, l);
1322 if (wait_cnt <= 0) return EINA_TRUE;
1332 _cb_device_info(void *data, struct tizen_input_device *tizen_input_device EINA_UNUSED, const char *name, uint32_t clas, uint32_t subclas EINA_UNUSED, struct wl_array *axes EINA_UNUSED)
1334 Efl_Util_Device_Info *dev;
1336 if (!(dev = data)) return;
1337 dev->clas = (Ecore_Device_Class)clas;
1338 dev->name = eina_stringshare_add(name);
1340 if (_eflutil.wl.devmgr.wait_timer &&
1341 _efl_util_input_check_wait_device(name, clas))
1343 wl_event_source_remove(_eflutil.wl.devmgr.wait_timer);
1344 _eflutil.wl.devmgr.wait_timer = NULL;
1348 /* LCOV_EXCL_START */
1350 _cb_event_device(void *data EINA_UNUSED, struct tizen_input_device *tizen_input_device EINA_UNUSED, unsigned int serial EINA_UNUSED, const char *name EINA_UNUSED, uint32_t time EINA_UNUSED)
1356 _cb_axis(void *data EINA_UNUSED, struct tizen_input_device *tizen_input_device EINA_UNUSED, uint32_t axis_type EINA_UNUSED, wl_fixed_t value EINA_UNUSED)
1360 /* LCOV_EXCL_STOP */
1363 _cb_device_add(void *data EINA_UNUSED,
1364 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1365 uint32_t serial EINA_UNUSED,
1366 const char *identifier EINA_UNUSED,
1367 struct tizen_input_device *device,
1368 struct wl_seat *seat EINA_UNUSED)
1370 Efl_Util_Device_Info *dev;
1372 EINA_SAFETY_ON_NULL_RETURN(device);
1374 dev = (Efl_Util_Device_Info *)calloc(1, sizeof(Efl_Util_Device_Info));
1375 EINA_SAFETY_ON_NULL_RETURN(dev);
1377 dev->device = device;
1378 tizen_input_device_add_listener(device, &_wl_tz_input_device_listener, dev);
1380 _eflutil.wl.devmgr.devices = eina_list_append(_eflutil.wl.devmgr.devices, dev);
1384 _cb_device_remove(void *data EINA_UNUSED,
1385 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1386 uint32_t serial EINA_UNUSED,
1387 const char *identifier EINA_UNUSED,
1388 struct tizen_input_device *device,
1389 struct wl_seat *seat EINA_UNUSED)
1391 Eina_List *l, *l_next;
1392 Efl_Util_Device_Info *dev;
1394 EINA_LIST_FOREACH_SAFE(_eflutil.wl.devmgr.devices, l, l_next, dev)
1396 if (dev->device == device)
1398 if (dev->name) eina_stringshare_del(dev->name);
1399 tizen_input_device_release(dev->device);
1401 _eflutil.wl.devmgr.devices = eina_list_remove_list(_eflutil.wl.devmgr.devices, l);
1410 _cb_error(void *data EINA_UNUSED,
1411 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1414 _eflutil.wl.devmgr.request_notified = errorcode;
1417 /* LCOV_EXCL_START */
1419 _cb_block_expired(void *data EINA_UNUSED,
1420 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED)
1424 /* LCOV_EXCL_STOP */
1427 _cb_max_touch_count(void *data EINA_UNUSED,
1428 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1429 uint32_t serial EINA_UNUSED,
1431 struct wl_seat *seat EINA_UNUSED)
1433 _eflutil.wl.devmgr.max_touch_count = max_count;
1436 static efl_util_error_e
1437 _efl_util_input_convert_input_generator_error(int ret)
1441 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE:
1442 return EFL_UTIL_ERROR_NONE;
1443 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NO_PERMISSION:
1444 return EFL_UTIL_ERROR_PERMISSION_DENIED;
1445 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NO_SYSTEM_RESOURCES:
1446 return EFL_UTIL_ERROR_OUT_OF_MEMORY;
1447 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_INVALID_PARAMETER:
1448 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1449 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NOT_ALLOWED:
1450 return EFL_UTIL_ERROR_NO_RESOURCE_AVAILABLE;
1452 return EFL_UTIL_ERROR_NONE;
1456 /* LCOV_EXCL_START */
1458 _timer_wait(void *data)
1460 Efl_Util_Device_Info *dev;
1462 _eflutil.wl.devmgr.request_notified = TIZEN_INPUT_DEVICE_MANAGER_ERROR_NO_SYSTEM_RESOURCES;
1464 if (eina_list_count(_eflutil.wl.devmgr.wait_devices) > 0)
1466 EINA_LIST_FREE(_eflutil.wl.devmgr.wait_devices, dev)
1468 eina_stringshare_del(dev->name);
1473 wl_event_source_remove(_eflutil.wl.devmgr.wait_timer);
1474 _eflutil.wl.devmgr.wait_timer = NULL;
1478 /* LCOV_EXCL_STOP */
1481 _efl_util_input_initialize_wait_device(void)
1483 struct wl_event_loop *loop;
1486 if (_efl_util_input_check_wait_device_full()) return;
1488 loop = wl_event_loop_create();
1489 _eflutil.wl.devmgr.wait_timer = wl_event_loop_add_timer(loop, _timer_wait, NULL);
1490 if (_eflutil.wl.devmgr.wait_timer)
1492 ret = wl_event_source_timer_update(_eflutil.wl.devmgr.wait_timer,
1493 EFL_UTIL_INPUT_GENERATOR_DEFAULT_TIME_OUT);
1501 while (_eflutil.wl.devmgr.wait_timer)
1503 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1504 ret = wl_event_loop_dispatch(loop, EFL_UTIL_INPUT_GENERATOR_DEFAULT_DISPATCH_TIME_OUT);
1505 if (ret != 0) _timer_wait(NULL);
1510 _efl_util_input_initialize_append_device(const char *name, Ecore_Device_Class clas)
1512 Efl_Util_Device_Info *dev;
1514 dev = (Efl_Util_Device_Info *)calloc(1, sizeof(Efl_Util_Device_Info));
1515 EINA_SAFETY_ON_NULL_RETURN(dev);
1517 dev->name = eina_stringshare_add(name);
1520 _eflutil.wl.devmgr.wait_devices = eina_list_append(_eflutil.wl.devmgr.wait_devices, dev);
1524 _efl_util_input_initialize_add_wait_device(const char *name, unsigned int dev_type)
1526 EINA_SAFETY_ON_NULL_RETURN(name);
1528 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN)
1529 _efl_util_input_initialize_append_device(name, ECORE_DEVICE_CLASS_TOUCH);
1531 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD)
1532 _efl_util_input_initialize_append_device(name, ECORE_DEVICE_CLASS_KEYBOARD);
1534 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_POINTER)
1535 _efl_util_input_initialize_append_device(name, ECORE_DEVICE_CLASS_MOUSE);
1538 API efl_util_inputgen_h
1539 efl_util_input_initialize_generator(unsigned int dev_type)
1541 int ret = EFL_UTIL_ERROR_NONE;
1542 efl_util_inputgen_h inputgen_h = NULL;
1543 unsigned int clas = 0x0;
1546 dev_type & ~(EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN
1547 | EFL_UTIL_INPUT_DEVTYPE_KEYBOARD
1548 | EFL_UTIL_INPUT_DEVTYPE_POINTER))
1550 set_last_result(EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1554 inputgen_h = (efl_util_inputgen_h)calloc(1, sizeof(struct _efl_util_inputgen_h));
1557 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
1561 inputgen_h->init_type |= dev_type;
1564 if (ret == (int)EINA_FALSE)
1566 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1570 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN)
1571 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
1572 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD)
1573 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD;
1574 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_POINTER)
1575 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE;
1577 while (!_eflutil.wl.devmgr.devicemgr)
1578 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1580 tizen_input_device_manager_init_generator(_eflutil.wl.devmgr.devicemgr, clas);
1582 while (_eflutil.wl.devmgr.request_notified == -1)
1583 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1585 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1586 _eflutil.wl.devmgr.request_notified = -1;
1588 set_last_result(ret);
1589 if (ret != TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE)
1603 API efl_util_inputgen_h
1604 efl_util_input_initialize_generator_with_name(unsigned int dev_type, const char *name)
1606 int ret = EFL_UTIL_ERROR_NONE;
1607 efl_util_inputgen_h inputgen_h = NULL;
1608 unsigned int clas = 0x0;
1611 dev_type & ~(EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN
1612 | EFL_UTIL_INPUT_DEVTYPE_KEYBOARD
1613 | EFL_UTIL_INPUT_DEVTYPE_POINTER))
1615 set_last_result(EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1619 inputgen_h = (efl_util_inputgen_h)calloc(1, sizeof(struct _efl_util_inputgen_h));
1622 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
1626 inputgen_h->init_type |= dev_type;
1627 strncpy(inputgen_h->name, name, 31);
1630 if (ret == (int)EINA_FALSE)
1632 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1636 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN)
1637 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
1638 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD)
1639 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD;
1640 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_POINTER)
1641 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE;
1643 while (!_eflutil.wl.devmgr.devicemgr)
1644 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1646 tizen_input_device_manager_init_generator_with_name(_eflutil.wl.devmgr.devicemgr, clas, inputgen_h->name);
1648 while (_eflutil.wl.devmgr.request_notified == -1)
1649 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1651 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1652 _eflutil.wl.devmgr.request_notified = -1;
1654 set_last_result(ret);
1655 if (ret != TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE)
1669 API efl_util_inputgen_h
1670 efl_util_input_initialize_generator_with_sync(unsigned int dev_type, const char *name)
1672 int ret = EFL_UTIL_ERROR_NONE;
1673 efl_util_inputgen_h inputgen_h = NULL;
1674 unsigned int clas = 0x0;
1677 dev_type & ~(EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN
1678 | EFL_UTIL_INPUT_DEVTYPE_KEYBOARD
1679 | EFL_UTIL_INPUT_DEVTYPE_POINTER))
1681 set_last_result(EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1685 inputgen_h = (efl_util_inputgen_h)calloc(1, sizeof(struct _efl_util_inputgen_h));
1688 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
1692 inputgen_h->init_type |= dev_type;
1693 if (name) strncpy(inputgen_h->name, name, 31);
1694 else strncpy(inputgen_h->name, "Input Generator", 31);
1697 if (ret == (int)EINA_FALSE)
1699 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1703 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN)
1704 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
1705 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD)
1706 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD;
1707 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_POINTER)
1708 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE;
1710 while (!_eflutil.wl.devmgr.devicemgr)
1711 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1713 tizen_input_device_manager_init_generator_with_name(_eflutil.wl.devmgr.devicemgr, clas, inputgen_h->name);
1715 while (_eflutil.wl.devmgr.request_notified == -1)
1716 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1718 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1719 _eflutil.wl.devmgr.request_notified = -1;
1721 if (ret == EFL_UTIL_ERROR_NONE)
1723 _efl_util_input_initialize_add_wait_device(inputgen_h->name, dev_type);
1724 _efl_util_input_initialize_wait_device();
1725 if (_eflutil.wl.devmgr.request_notified != -1)
1727 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1728 _eflutil.wl.devmgr.request_notified = -1;
1732 set_last_result(ret);
1733 if (ret != TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE)
1748 efl_util_input_set_touch_count(int max_count)
1750 int ret = EFL_UTIL_ERROR_NONE;
1753 if (ret == (int)EINA_FALSE)
1755 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1758 while (!_eflutil.wl.devmgr.devicemgr)
1759 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1761 if (_eflutil.wl.devmgr.max_touch_count >= max_count)
1762 return EFL_UTIL_ERROR_NONE;
1764 tizen_input_device_manager_set_touch_count(_eflutil.wl.devmgr.devicemgr, max_count);
1766 while (_eflutil.wl.devmgr.request_notified == -1)
1767 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1769 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1770 _eflutil.wl.devmgr.request_notified = -1;
1772 if (ret == EFL_UTIL_ERROR_NONE)
1774 _eflutil.wl.devmgr.request_touch_count = max_count;
1781 efl_util_input_deinitialize_generator(efl_util_inputgen_h inputgen_h)
1783 int ret = EFL_UTIL_ERROR_NONE;
1784 unsigned int clas = 0x0;
1785 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1787 if (inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN)
1788 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
1789 if (inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD)
1790 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD;
1791 if (inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_POINTER)
1792 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE;
1794 if (inputgen_h->axis_info)
1795 free(inputgen_h->axis_info);
1800 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1802 tizen_input_device_manager_deinit_generator(_eflutil.wl.devmgr.devicemgr, clas);
1804 while (_eflutil.wl.devmgr.request_notified == -1)
1805 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1807 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1808 _eflutil.wl.devmgr.request_notified = -1;
1814 efl_util_input_generate_key(efl_util_inputgen_h inputgen_h, const char *key_name, int pressed)
1816 int ret = EFL_UTIL_ERROR_NONE;
1818 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1819 EINA_SAFETY_ON_NULL_RETURN_VAL(key_name, EFL_UTIL_ERROR_INVALID_PARAMETER);
1820 EINA_SAFETY_ON_FALSE_RETURN_VAL(pressed == 0 || pressed == 1, EFL_UTIL_ERROR_INVALID_PARAMETER);
1821 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1823 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1825 tizen_input_device_manager_generate_key(_eflutil.wl.devmgr.devicemgr, key_name, pressed);
1827 while (_eflutil.wl.devmgr.request_notified == -1)
1828 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1830 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1831 _eflutil.wl.devmgr.request_notified = -1;
1837 efl_util_input_generate_touch(efl_util_inputgen_h inputgen_h, int idx,
1838 efl_util_input_touch_type_e touch_type, int x, int y)
1841 enum tizen_input_device_manager_pointer_event_type type;
1843 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1844 EINA_SAFETY_ON_FALSE_RETURN_VAL(idx >= 0, EFL_UTIL_ERROR_INVALID_PARAMETER);
1845 EINA_SAFETY_ON_FALSE_RETURN_VAL((x > 0 && y > 0), EFL_UTIL_ERROR_INVALID_PARAMETER);
1846 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1848 if (idx >= _eflutil.wl.devmgr.max_touch_count)
1849 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1851 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1855 case EFL_UTIL_INPUT_TOUCH_BEGIN:
1856 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_BEGIN;
1858 case EFL_UTIL_INPUT_TOUCH_UPDATE:
1859 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_UPDATE;
1861 case EFL_UTIL_INPUT_TOUCH_END:
1862 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_END;
1865 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1868 tizen_input_device_manager_generate_touch(_eflutil.wl.devmgr.devicemgr, type, x, y, idx);
1870 while (_eflutil.wl.devmgr.request_notified == -1)
1871 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1873 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1874 _eflutil.wl.devmgr.request_notified = -1;
1880 _efl_util_input_generate_touch_axis_send(unsigned int type, double value)
1884 tizen_input_device_manager_generate_axis(_eflutil.wl.devmgr.devicemgr, type, wl_fixed_from_double(value));
1886 while (_eflutil.wl.devmgr.request_notified == -1)
1887 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1889 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1890 _eflutil.wl.devmgr.request_notified = -1;
1896 _efl_util_input_generate_touch_axis_cleanup(efl_util_inputgen_h inputgen_h, int idx)
1901 inputgen_h->axis_info[idx].radius_x = 1.0;
1902 inputgen_h->axis_info[idx].radius_y = 1.0;
1903 inputgen_h->axis_info[idx].pressure = 1.0;
1904 inputgen_h->axis_info[idx].angle = 0.0;
1905 inputgen_h->axis_info[idx].palm = 0.0;
1909 for (i = 0; i < EFL_UTIL_INPUT_GENERATOR_TOUCH_MAX_FINGER; i++)
1911 inputgen_h->axis_info[i].radius_x = 1.0;
1912 inputgen_h->axis_info[i].radius_y = 1.0;
1913 inputgen_h->axis_info[i].pressure = 1.0;
1914 inputgen_h->axis_info[i].angle = 0.0;
1915 inputgen_h->axis_info[i].palm = 0.0;
1921 _efl_util_input_generate_touch_axis_process(efl_util_inputgen_h inputgen_h, int idx, double radius_x,
1922 double radius_y, double pressure, double angle, double palm)
1924 int ret = EFL_UTIL_ERROR_NONE;
1926 if (!inputgen_h->axis_info)
1928 inputgen_h->axis_info = calloc(EFL_UTIL_INPUT_GENERATOR_TOUCH_MAX_FINGER,
1929 sizeof(E_Devicemgr_Inputgen_Touch_Axis));
1930 _efl_util_input_generate_touch_axis_cleanup(inputgen_h, -1);
1933 if (inputgen_h->axis_info[idx].radius_x != radius_x)
1935 ret = _efl_util_input_generate_touch_axis_send(TIZEN_INPUT_DEVICE_MANAGER_AXIS_TYPE_RADIUS_X, radius_x);
1936 if (ret != EFL_UTIL_ERROR_NONE) return ret;
1937 inputgen_h->axis_info[idx].radius_x = radius_x;
1939 if (inputgen_h->axis_info[idx].radius_y != radius_y)
1941 ret = _efl_util_input_generate_touch_axis_send(TIZEN_INPUT_DEVICE_MANAGER_AXIS_TYPE_RADIUS_Y, radius_y);
1942 if (ret != EFL_UTIL_ERROR_NONE) return ret;
1943 inputgen_h->axis_info[idx].radius_y = radius_y;
1945 if (inputgen_h->axis_info[idx].pressure != pressure)
1947 ret = _efl_util_input_generate_touch_axis_send(TIZEN_INPUT_DEVICE_MANAGER_AXIS_TYPE_PRESSURE, pressure);
1948 if (ret != EFL_UTIL_ERROR_NONE) return ret;
1949 inputgen_h->axis_info[idx].pressure = pressure;
1951 if (inputgen_h->axis_info[idx].angle != angle)
1953 ret = _efl_util_input_generate_touch_axis_send(TIZEN_INPUT_DEVICE_MANAGER_AXIS_TYPE_ANGLE, angle);
1954 if (ret != EFL_UTIL_ERROR_NONE) return ret;
1955 inputgen_h->axis_info[idx].angle = angle;
1957 if (inputgen_h->axis_info[idx].palm != palm)
1959 ret = _efl_util_input_generate_touch_axis_send(TIZEN_INPUT_DEVICE_MANAGER_AXIS_TYPE_PALM, palm);
1960 if (ret != EFL_UTIL_ERROR_NONE) return ret;
1961 inputgen_h->axis_info[idx].palm = palm;
1968 efl_util_input_generate_touch_axis(efl_util_inputgen_h inputgen_h, int idx,
1969 efl_util_input_touch_type_e touch_type, int x, int y,
1970 double radius_x, double radius_y,
1971 double pressure, double angle, double palm)
1974 enum tizen_input_device_manager_pointer_event_type type;
1976 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1977 EINA_SAFETY_ON_FALSE_RETURN_VAL(idx >= 0, EFL_UTIL_ERROR_INVALID_PARAMETER);
1978 EINA_SAFETY_ON_FALSE_RETURN_VAL((x >= 0 && y >= 0), EFL_UTIL_ERROR_INVALID_PARAMETER);
1979 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1980 EINA_SAFETY_ON_FALSE_RETURN_VAL((radius_x >= 0.0 && radius_y >= 0.0), EFL_UTIL_ERROR_INVALID_PARAMETER);
1981 EINA_SAFETY_ON_FALSE_RETURN_VAL((pressure >= 0.0 && palm >= 0.0), EFL_UTIL_ERROR_INVALID_PARAMETER);
1983 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1984 version = tizen_input_device_manager_get_version(_eflutil.wl.devmgr.devicemgr);
1985 EINA_SAFETY_ON_FALSE_RETURN_VAL((version >= 3), EFL_UTIL_ERROR_NOT_SUPPORTED);
1989 case EFL_UTIL_INPUT_TOUCH_BEGIN:
1990 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_BEGIN;
1992 case EFL_UTIL_INPUT_TOUCH_UPDATE:
1993 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_UPDATE;
1995 case EFL_UTIL_INPUT_TOUCH_END:
1996 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_END;
1999 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2002 if (touch_type != EFL_UTIL_INPUT_TOUCH_END)
2003 _efl_util_input_generate_touch_axis_process(inputgen_h, idx, radius_x, radius_y, pressure, angle, palm);
2005 _efl_util_input_generate_touch_axis_cleanup(inputgen_h, idx);
2007 tizen_input_device_manager_generate_touch(_eflutil.wl.devmgr.devicemgr, type, x, y, idx);
2009 while (_eflutil.wl.devmgr.request_notified == -1)
2010 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2012 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
2013 _eflutil.wl.devmgr.request_notified = -1;
2020 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)
2023 enum tizen_input_device_manager_pointer_event_type type;
2025 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2026 EINA_SAFETY_ON_FALSE_RETURN_VAL(buttons > 0, EFL_UTIL_ERROR_INVALID_PARAMETER);
2027 EINA_SAFETY_ON_FALSE_RETURN_VAL((x >= 0 && y >= 0), EFL_UTIL_ERROR_INVALID_PARAMETER);
2028 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_POINTER, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
2030 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
2032 switch(pointer_type)
2034 case EFL_UTIL_INPUT_POINTER_BUTTON_DOWN:
2035 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_BEGIN;
2037 case EFL_UTIL_INPUT_POINTER_MOVE:
2038 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_UPDATE;
2040 case EFL_UTIL_INPUT_POINTER_BUTTON_UP:
2041 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_END;
2044 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2047 tizen_input_device_manager_generate_pointer(_eflutil.wl.devmgr.devicemgr, type, x, y, buttons);
2049 while (_eflutil.wl.devmgr.request_notified == -1)
2050 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2052 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
2053 _eflutil.wl.devmgr.request_notified = -1;
2059 efl_util_input_generate_wheel(efl_util_inputgen_h inputgen_h, efl_util_input_pointer_wheel_type_e wheel_type, int value)
2062 enum tizen_input_device_manager_pointer_event_type type;
2064 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2065 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_POINTER, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
2067 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
2068 version = tizen_input_device_manager_get_version(_eflutil.wl.devmgr.devicemgr);
2069 EINA_SAFETY_ON_FALSE_RETURN_VAL((version >= 3), EFL_UTIL_ERROR_NOT_SUPPORTED);
2073 case EFL_UTIL_INPUT_POINTER_WHEEL_VERT:
2074 type = TIZEN_INPUT_DEVICE_MANAGER_AXIS_TYPE_WHEEL;
2076 case EFL_UTIL_INPUT_POINTER_WHEEL_HORZ:
2077 type = TIZEN_INPUT_DEVICE_MANAGER_AXIS_TYPE_HWHEEL;
2080 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2083 tizen_input_device_manager_generate_axis(_eflutil.wl.devmgr.devicemgr, type, wl_fixed_from_int(value));
2085 while (_eflutil.wl.devmgr.request_notified == -1)
2086 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2088 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
2089 _eflutil.wl.devmgr.request_notified = -1;
2096 struct _efl_util_screenshot_h
2101 Eina_Bool shot_done;
2106 Eina_Bool auto_rotation;
2109 /* scrrenshot handle */
2110 static efl_util_screenshot_h g_screenshot;
2111 static Eina_Bool shot_mutex_init;
2112 static pthread_mutex_t shot_lock;
2115 _screenshot_mutex_init(void)
2117 if (shot_mutex_init)
2120 if (pthread_mutex_init(&shot_lock, NULL))
2122 fprintf(stderr, "[screenshot] fail: mutex init"); /*LCOV_EXCL_LINE*/
2123 return EINA_FALSE; /*LCOV_EXCL_LINE*/
2126 shot_mutex_init = EINA_TRUE;
2132 _screenshot_mutex_destory(void)
2134 if (!shot_mutex_init)
2137 if (pthread_mutex_destroy(&shot_lock))
2139 fprintf(stderr, "[screenshot] fail: mutex destory"); /*LCOV_EXCL_LINE*/
2140 return EINA_FALSE; /*LCOV_EXCL_LINE*/
2143 shot_mutex_init = EINA_FALSE;
2149 _screenshot_mutex_lock(void)
2151 if (!_screenshot_mutex_init())
2154 pthread_mutex_lock(&shot_lock);
2158 _screenshot_mutex_unlock(void)
2160 pthread_mutex_unlock(&shot_lock);
2163 API efl_util_screenshot_h
2164 efl_util_screenshot_initialize(int width, int height)
2166 efl_util_screenshot_h screenshot = NULL;
2167 struct wl_display *display_wrapper = NULL;
2168 struct wl_registry *reg = NULL;
2171 if (width <= 0 || height <= 0)
2173 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2177 _screenshot_mutex_lock();
2181 screenshot = calloc(1, sizeof(struct _efl_util_screenshot_h));
2182 EINA_SAFETY_ON_NULL_GOTO(screenshot, fail_memory);
2185 if (!_eflutil.wl.shot.screenshooter)
2188 if (ret == (int)EINA_FALSE)
2190 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2191 _screenshot_mutex_unlock();
2196 wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2198 display_wrapper = wl_proxy_create_wrapper(_eflutil.wl.dpy);
2199 EINA_SAFETY_ON_NULL_GOTO(display_wrapper, fail_memory);
2201 _eflutil.wl.shot.queue = wl_display_create_queue(_eflutil.wl.dpy);
2202 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.queue, fail_memory);
2204 wl_proxy_set_queue((struct wl_proxy *)display_wrapper, _eflutil.wl.shot.queue);
2206 reg = wl_display_get_registry(display_wrapper);
2207 wl_proxy_wrapper_destroy(display_wrapper);
2208 display_wrapper = NULL;
2209 EINA_SAFETY_ON_NULL_GOTO(reg, fail_init);
2211 wl_registry_add_listener(reg, &_wl_reg_screenshooter_listener, NULL);
2213 ret = wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
2214 EINA_SAFETY_ON_TRUE_GOTO(ret == -1, fail_init);
2215 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.screenshooter, fail_init);
2216 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.tz_screenshooter, fail_init);
2218 _eflutil.wl.shot.tbm_client = wayland_tbm_client_init(_eflutil.wl.dpy);
2219 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.tbm_client, fail_init);
2221 wl_registry_destroy(reg);
2225 if (_eflutil.wl.shot.noti == 0)
2227 fprintf(stderr, "[screenshot] fail: privilege error\n"); /* LCOV_EXCL_LINE */
2233 if (g_screenshot->width != width || g_screenshot->height != height)
2235 g_screenshot->width = width;
2236 g_screenshot->height = height;
2238 set_last_result(EFL_UTIL_ERROR_NONE);
2240 _screenshot_mutex_unlock();
2242 return g_screenshot;
2245 screenshot->width = width;
2246 screenshot->height = height;
2247 screenshot->auto_rotation = EINA_TRUE;
2249 screenshot->bufmgr = wayland_tbm_client_get_bufmgr(_eflutil.wl.shot.tbm_client);
2250 EINA_SAFETY_ON_NULL_GOTO(screenshot->bufmgr, fail_init);
2252 g_screenshot = screenshot;
2253 set_last_result(EFL_UTIL_ERROR_NONE);
2255 screenshooter_set_user_data(_eflutil.wl.shot.screenshooter, &screenshot->shot_done);
2257 _screenshot_mutex_unlock();
2259 return g_screenshot;
2261 /* LCOV_EXCL_START */
2263 if (display_wrapper)
2264 wl_proxy_wrapper_destroy(display_wrapper);
2265 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
2268 _screenshot_mutex_unlock();
2273 wl_registry_destroy(reg);
2276 _screenshot_mutex_unlock();
2277 efl_util_screenshot_deinitialize(screenshot);
2279 if (_eflutil.wl.shot.noti == 0)
2280 set_last_result(EFL_UTIL_ERROR_PERMISSION_DENIED);
2282 set_last_result(EFL_UTIL_ERROR_SCREENSHOT_INIT_FAIL);
2284 /* LCOV_EXCL_STOP */
2288 efl_util_screenshot_deinitialize(efl_util_screenshot_h screenshot)
2290 _screenshot_mutex_lock();
2294 _screenshot_mutex_unlock();
2295 _screenshot_mutex_destory();
2296 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2300 g_screenshot = NULL;
2302 if (_eflutil.wl.shot.tbm_client)
2304 wayland_tbm_client_deinit(_eflutil.wl.shot.tbm_client);
2305 _eflutil.wl.shot.tbm_client = NULL;
2308 if (_eflutil.wl.shot.screenshooter)
2310 screenshooter_destroy(_eflutil.wl.shot.screenshooter);
2311 _eflutil.wl.shot.screenshooter = NULL;
2313 if (_eflutil.wl.shot.tz_screenshooter)
2315 tizen_screenshooter_destroy(_eflutil.wl.shot.tz_screenshooter);
2316 _eflutil.wl.shot.tz_screenshooter = NULL;
2319 if (_eflutil.wl.shot.queue)
2321 wl_event_queue_destroy(_eflutil.wl.shot.queue);
2322 _eflutil.wl.shot.queue = NULL;
2325 _screenshot_mutex_unlock();
2326 _screenshot_mutex_destory();
2328 return EFL_UTIL_ERROR_NONE;
2333 efl_util_screenshot_take_tbm_surface(efl_util_screenshot_h screenshot)
2335 tbm_surface_h t_surface = NULL;
2336 struct wl_buffer *buffer = NULL;
2337 Efl_Util_Wl_Output_Info *output;
2340 _screenshot_mutex_lock();
2342 if (!screenshot || (screenshot != g_screenshot))
2344 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2345 _screenshot_mutex_unlock();
2349 output = eina_list_nth(_eflutil.wl.shot.output_list, 0);
2352 fprintf(stderr, "[screenshot] fail: no output for screenshot\n"); /* LCOV_EXCL_LINE */
2356 t_surface = tbm_surface_create(screenshot->width, screenshot->height, TBM_FORMAT_XRGB8888);
2359 fprintf(stderr, "[screenshot] fail: tbm_surface_create\n"); /* LCOV_EXCL_LINE */
2363 buffer = wayland_tbm_client_create_buffer(_eflutil.wl.shot.tbm_client, t_surface);
2366 fprintf(stderr, "[screenshot] fail: create wl_buffer for screenshot\n"); /* LCOV_EXCL_LINE */
2370 screenshooter_shoot(_eflutil.wl.shot.screenshooter, output->output, buffer);
2372 screenshot->shot_done = EINA_FALSE;
2373 while (!screenshot->shot_done && ret != -1)
2374 ret = wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
2378 fprintf(stderr, "[screenshot] fail: screenshooter_shoot\n"); /* LCOV_EXCL_LINE */
2382 wayland_tbm_client_destroy_buffer(_eflutil.wl.shot.tbm_client, buffer);
2384 /* reset shot_done for next screenshot */
2385 screenshot->shot_done = EINA_FALSE;
2387 set_last_result(EFL_UTIL_ERROR_NONE);
2389 _screenshot_mutex_unlock();
2395 tbm_surface_destroy(t_surface);
2397 wayland_tbm_client_destroy_buffer(_eflutil.wl.shot.tbm_client, buffer);
2399 set_last_result(EFL_UTIL_ERROR_SCREENSHOT_EXECUTION_FAIL);
2401 _screenshot_mutex_unlock();
2407 efl_util_screenshot_set_auto_rotation(efl_util_screenshot_h screenshot, int set)
2409 if (!screenshot || (screenshot != g_screenshot))
2410 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2412 if (!(set == 0 || set == 1))
2413 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2416 g_screenshot->auto_rotation = EINA_TRUE;
2418 g_screenshot->auto_rotation = EINA_FALSE;
2420 tizen_screenshooter_set_oneshot_auto_rotation(_eflutil.wl.shot.tz_screenshooter, g_screenshot->auto_rotation);
2422 return EFL_UTIL_ERROR_NONE;
2426 efl_util_screenshot_get_auto_rotation(efl_util_screenshot_h screenshot, int *set)
2428 if (!screenshot || (screenshot != g_screenshot) || !set)
2429 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2431 *set = g_screenshot->auto_rotation;
2433 return EFL_UTIL_ERROR_NONE;
2436 struct _efl_util_gesture_h
2441 API int EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = 0;
2442 API int EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = 0;
2443 API int EFL_UTIL_EVENT_GESTURE_TAP = 0;
2444 API int EFL_UTIL_EVENT_GESTURE_PALM_COVER = 0;
2446 /* LCOV_EXCL_START */
2448 _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)
2450 _eflutil_defaultqueue.wl.gesture.request_notified = error;
2454 _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)
2456 efl_util_event_gesture_edge_swipe_s *ev = NULL;
2458 ev = (efl_util_event_gesture_edge_swipe_s *)calloc(1, sizeof(*ev));
2463 ev->fingers = fingers;
2468 ecore_event_add(EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE, ev, NULL, NULL);
2472 _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)
2474 _eflutil_defaultqueue.wl.gesture.request_notified = error;
2478 _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)
2480 efl_util_event_gesture_edge_drag_s *ev = NULL;
2482 ev = (efl_util_event_gesture_edge_drag_s *)calloc(1, sizeof(*ev));
2487 ev->fingers = fingers;
2492 ecore_event_add(EFL_UTIL_EVENT_GESTURE_EDGE_DRAG, ev, NULL, NULL);
2496 _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)
2498 _eflutil_defaultqueue.wl.gesture.request_notified = error;
2502 _cb_gesture_tap(void *data EINA_UNUSED, struct tizen_gesture *tizen_gesture EINA_UNUSED, uint32_t mode, uint32_t fingers, uint32_t repeats)
2504 efl_util_event_gesture_tap_s *ev = NULL;
2506 ev = (efl_util_event_gesture_tap_s *)calloc(1, sizeof(*ev));
2511 ev->fingers = fingers;
2512 ev->repeats = repeats;
2514 ecore_event_add(EFL_UTIL_EVENT_GESTURE_TAP, ev, NULL, NULL);
2516 /* LCOV_EXCL_STOP */
2519 _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)
2521 _eflutil_defaultqueue.wl.gesture.request_notified = error;
2524 /* LCOV_EXCL_START */
2526 _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)
2528 efl_util_event_gesture_palm_cover_s *ev = NULL;
2530 ev = (efl_util_event_gesture_palm_cover_s *)calloc(1, sizeof(*ev));
2535 ev->duration = duration;
2539 ev->pressure = wl_fixed_to_int(pressure);
2541 ecore_event_add(EFL_UTIL_EVENT_GESTURE_PALM_COVER, ev, NULL, NULL);
2543 /* LCOV_EXCL_STOP */
2546 _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)
2548 _eflutil_defaultqueue.wl.gesture.request_notified = error;
2551 static efl_util_error_e
2552 _efl_util_gesture_convert_error(int ret)
2556 case TIZEN_GESTURE_ERROR_NONE:
2557 return EFL_UTIL_ERROR_NONE;
2558 case TIZEN_GESTURE_ERROR_INVALID_DATA:
2559 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2560 case TIZEN_GESTURE_ERROR_NO_PERMISSION:
2561 return EFL_UTIL_ERROR_PERMISSION_DENIED;
2562 case TIZEN_GESTURE_ERROR_NO_SYSTEM_RESOURCES:
2563 return EFL_UTIL_ERROR_OUT_OF_MEMORY;
2564 case TIZEN_GESTURE_ERROR_GRABBED_ALREADY:
2565 return EFL_UTIL_ERROR_NO_RESOURCE_AVAILABLE;
2566 case TIZEN_GESTURE_ERROR_NOT_SUPPORTED:
2567 return EFL_UTIL_ERROR_NOT_SUPPORTED;
2569 return EFL_UTIL_ERROR_NONE;
2573 /* LCOV_EXCL_START */
2575 _efl_util_gesture_grab_edge_swipe(efl_util_gesture_data data)
2577 int ret = EFL_UTIL_ERROR_NONE;
2578 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2579 Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = NULL;
2580 unsigned int fingers = 0;
2581 unsigned int edge = 0;
2582 unsigned int edge_size = 0;
2583 unsigned int start_point = 0;
2584 unsigned int end_point = 0;
2586 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2588 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil_defaultqueue.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2589 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2590 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_SWIPE,
2591 EFL_UTIL_ERROR_INVALID_PARAMETER);
2593 edge_swipe_data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)data;
2595 fingers = edge_swipe_data->fingers;
2596 edge = edge_swipe_data->edge;
2597 edge_size = edge_swipe_data->edge_size;
2598 start_point = edge_swipe_data->start_point;
2599 end_point = edge_swipe_data->end_point;
2601 tizen_gesture_grab_edge_swipe(_eflutil_defaultqueue.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2603 while (_eflutil_defaultqueue.wl.gesture.request_notified == -1)
2604 wl_display_dispatch(_eflutil_defaultqueue.wl.dpy);
2606 ret = _efl_util_gesture_convert_error(_eflutil_defaultqueue.wl.gesture.request_notified);
2607 _eflutil_defaultqueue.wl.gesture.request_notified = -1;
2613 _efl_util_gesture_ungrab_edge_swipe(efl_util_gesture_data data)
2615 int ret = EFL_UTIL_ERROR_NONE;
2616 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2617 Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = NULL;
2618 unsigned int fingers = 0;
2619 unsigned int edge = 0;
2620 unsigned int edge_size = 0;
2621 unsigned int start_point = 0;
2622 unsigned int end_point = 0;
2624 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2626 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil_defaultqueue.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2627 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2628 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_SWIPE,
2629 EFL_UTIL_ERROR_INVALID_PARAMETER);
2631 edge_swipe_data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)data;
2633 fingers = edge_swipe_data->fingers;
2634 edge = edge_swipe_data->edge;
2635 edge_size = edge_swipe_data->edge_size;
2636 start_point = edge_swipe_data->start_point;
2637 end_point = edge_swipe_data->end_point;
2639 tizen_gesture_ungrab_edge_swipe(_eflutil_defaultqueue.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2641 while (_eflutil_defaultqueue.wl.gesture.request_notified == -1)
2642 wl_display_dispatch(_eflutil_defaultqueue.wl.dpy);
2644 ret = _efl_util_gesture_convert_error(_eflutil_defaultqueue.wl.gesture.request_notified);
2645 _eflutil_defaultqueue.wl.gesture.request_notified = -1;
2651 _efl_util_gesture_grab_edge_drag(efl_util_gesture_data data)
2653 int ret = EFL_UTIL_ERROR_NONE;
2654 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2655 Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = NULL;
2656 unsigned int fingers = 0;
2657 unsigned int edge = 0;
2658 unsigned int edge_size = 0;
2659 unsigned int start_point = 0;
2660 unsigned int end_point = 0;
2662 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2664 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil_defaultqueue.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2665 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2666 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_DRAG,
2667 EFL_UTIL_ERROR_INVALID_PARAMETER);
2669 edge_drag_data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)data;
2671 fingers = edge_drag_data->fingers;
2672 edge = edge_drag_data->edge;
2673 edge_size = edge_drag_data->edge_size;
2674 start_point = edge_drag_data->start_point;
2675 end_point = edge_drag_data->end_point;
2677 tizen_gesture_grab_edge_drag(_eflutil_defaultqueue.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2679 while (_eflutil_defaultqueue.wl.gesture.request_notified == -1)
2680 wl_display_dispatch(_eflutil_defaultqueue.wl.dpy);
2682 ret = _efl_util_gesture_convert_error(_eflutil_defaultqueue.wl.gesture.request_notified);
2683 _eflutil_defaultqueue.wl.gesture.request_notified = -1;
2689 _efl_util_gesture_ungrab_edge_drag(efl_util_gesture_data data)
2691 int ret = EFL_UTIL_ERROR_NONE;
2692 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2693 Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = NULL;
2694 unsigned int fingers = 0;
2695 unsigned int edge = 0;
2696 unsigned int edge_size = 0;
2697 unsigned int start_point = 0;
2698 unsigned int end_point = 0;
2700 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2702 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil_defaultqueue.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2703 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2704 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_DRAG,
2705 EFL_UTIL_ERROR_INVALID_PARAMETER);
2707 edge_drag_data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)data;
2709 fingers = edge_drag_data->fingers;
2710 edge = edge_drag_data->edge;
2711 edge_size = edge_drag_data->edge_size;
2712 start_point = edge_drag_data->start_point;
2713 end_point = edge_drag_data->end_point;
2715 tizen_gesture_ungrab_edge_drag(_eflutil_defaultqueue.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2717 while (_eflutil_defaultqueue.wl.gesture.request_notified == -1)
2718 wl_display_dispatch(_eflutil_defaultqueue.wl.dpy);
2720 ret = _efl_util_gesture_convert_error(_eflutil_defaultqueue.wl.gesture.request_notified);
2721 _eflutil_defaultqueue.wl.gesture.request_notified = -1;
2728 _efl_util_gesture_grab_tap(efl_util_gesture_data data)
2730 int ret = EFL_UTIL_ERROR_NONE;
2731 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2732 Efl_Util_Gesture_Tap_Grab_Data *tap_data = NULL;
2733 unsigned int fingers = 0;
2734 unsigned int repeats = 0;
2736 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2738 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil_defaultqueue.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2739 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2740 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_TAP,
2741 EFL_UTIL_ERROR_INVALID_PARAMETER);
2743 tap_data = (Efl_Util_Gesture_Tap_Grab_Data *)data;
2745 fingers = tap_data->fingers;
2746 repeats = tap_data->repeats;
2748 tizen_gesture_grab_tap(_eflutil_defaultqueue.wl.gesture.proto, fingers, repeats);
2750 while (_eflutil_defaultqueue.wl.gesture.request_notified == -1)
2751 wl_display_dispatch(_eflutil_defaultqueue.wl.dpy);
2753 ret = _efl_util_gesture_convert_error(_eflutil_defaultqueue.wl.gesture.request_notified);
2754 _eflutil_defaultqueue.wl.gesture.request_notified = -1;
2760 _efl_util_gesture_ungrab_tap(efl_util_gesture_data data)
2762 int ret = EFL_UTIL_ERROR_NONE;
2763 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2764 Efl_Util_Gesture_Tap_Grab_Data *tap_data = NULL;
2765 unsigned int fingers = 0;
2766 unsigned int repeats = 0;
2768 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2770 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil_defaultqueue.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2771 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2772 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_TAP,
2773 EFL_UTIL_ERROR_INVALID_PARAMETER);
2775 tap_data = (Efl_Util_Gesture_Tap_Grab_Data *)data;
2777 fingers = tap_data->fingers;
2778 repeats = tap_data->repeats;
2780 tizen_gesture_ungrab_tap(_eflutil_defaultqueue.wl.gesture.proto, fingers, repeats);
2782 while (_eflutil_defaultqueue.wl.gesture.request_notified == -1)
2783 wl_display_dispatch(_eflutil_defaultqueue.wl.dpy);
2785 ret = _efl_util_gesture_convert_error(_eflutil_defaultqueue.wl.gesture.request_notified);
2786 _eflutil_defaultqueue.wl.gesture.request_notified = -1;
2792 _efl_util_gesture_grab_palm_cover(efl_util_gesture_data data)
2794 int ret = EFL_UTIL_ERROR_NONE;
2795 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2797 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2799 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil_defaultqueue.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2800 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2801 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_PALM_COVER,
2802 EFL_UTIL_ERROR_INVALID_PARAMETER);
2804 tizen_gesture_grab_palm_cover(_eflutil_defaultqueue.wl.gesture.proto);
2806 while (_eflutil_defaultqueue.wl.gesture.request_notified == -1)
2807 wl_display_dispatch(_eflutil_defaultqueue.wl.dpy);
2809 ret = _efl_util_gesture_convert_error(_eflutil_defaultqueue.wl.gesture.request_notified);
2810 _eflutil_defaultqueue.wl.gesture.request_notified = -1;
2816 _efl_util_gesture_ungrab_palm_cover(efl_util_gesture_data data)
2818 int ret = EFL_UTIL_ERROR_NONE;
2819 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2821 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2823 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil_defaultqueue.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2824 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2825 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_PALM_COVER,
2826 EFL_UTIL_ERROR_INVALID_PARAMETER);
2828 tizen_gesture_ungrab_palm_cover(_eflutil_defaultqueue.wl.gesture.proto);
2830 while (_eflutil_defaultqueue.wl.gesture.request_notified == -1)
2831 wl_display_dispatch(_eflutil_defaultqueue.wl.dpy);
2833 ret = _efl_util_gesture_convert_error(_eflutil_defaultqueue.wl.gesture.request_notified);
2834 _eflutil_defaultqueue.wl.gesture.request_notified = -1;
2838 /* LCOV_EXCL_STOP */
2840 API efl_util_gesture_h
2841 efl_util_gesture_initialize(void)
2843 efl_util_gesture_h gesture_h = NULL;
2845 gesture_h = (efl_util_gesture_h)calloc(1, sizeof(struct _efl_util_gesture_h));
2848 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2849 goto out; /* LCOV_EXCL_LINE */
2852 if (_wl_init_default_queue() == (int)EINA_FALSE)
2854 set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED); /* LCOV_EXCL_LINE */
2855 goto out; /* LCOV_EXCL_LINE */
2858 while (!_eflutil_defaultqueue.wl.gesture.proto)
2859 wl_display_dispatch(_eflutil_defaultqueue.wl.dpy); /* LCOV_EXCL_LINE */
2861 if (_eflutil_defaultqueue.wl.gesture.event_init <= 0)
2863 if (ecore_event_init() <= 0)
2865 set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED); /* LCOV_EXCL_LINE */
2866 goto out; /* LCOV_EXCL_LINE */
2868 EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = ecore_event_type_new();
2869 EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = ecore_event_type_new();
2870 EFL_UTIL_EVENT_GESTURE_TAP = ecore_event_type_new();
2871 EFL_UTIL_EVENT_GESTURE_PALM_COVER = ecore_event_type_new();
2873 _eflutil_defaultqueue.wl.gesture.event_init++;
2874 gesture_h->init = EINA_TRUE;
2876 set_last_result(EFL_UTIL_ERROR_NONE);
2880 /* LCOV_EXCL_START */
2887 /* LCOV_EXCL_STOP */
2891 efl_util_gesture_deinitialize(efl_util_gesture_h gesture_h)
2893 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2894 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2899 _eflutil_defaultqueue.wl.gesture.event_init--;
2901 if (_eflutil_defaultqueue.wl.gesture.event_init <= 0)
2903 _eflutil_defaultqueue.wl.gesture.event_init = 0;
2904 ecore_event_shutdown();
2905 EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = 0;
2906 EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = 0;
2907 EFL_UTIL_EVENT_GESTURE_TAP = 0;
2908 EFL_UTIL_EVENT_GESTURE_PALM_COVER = 0;
2911 return EFL_UTIL_ERROR_NONE;
2914 API efl_util_gesture_data
2915 efl_util_gesture_edge_swipe_new(efl_util_gesture_h gesture_h, unsigned int fingers, efl_util_gesture_edge_e edge)
2917 Efl_Util_Gesture_Edge_Swipe_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_Swipe_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Edge_Swipe_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_SWIPE;
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_swipe_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_swipe_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_Swipe_Grab_Data *edge_swipe_data = data;
2972 EINA_SAFETY_ON_NULL_RETURN_VAL(edge_swipe_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2973 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_swipe_data->base.type == TIZEN_GESTURE_TYPE_EDGE_SWIPE,
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_swipe_data->edge_size = edge_size;
2980 edge_swipe_data->start_point = start_point;
2981 edge_swipe_data->end_point = end_point;
2983 return EFL_UTIL_ERROR_NONE;
2986 API efl_util_gesture_data
2987 efl_util_gesture_edge_drag_new(efl_util_gesture_h gesture_h, unsigned int fingers, efl_util_gesture_edge_e edge)
2989 Efl_Util_Gesture_Edge_Drag_Grab_Data *data;
2991 if (!gesture_h || gesture_h->init == EINA_FALSE)
2993 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2997 if (edge <= EFL_UTIL_GESTURE_EDGE_NONE || edge > EFL_UTIL_GESTURE_EDGE_LEFT)
2999 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
3003 data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Edge_Drag_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_EDGE_DRAG;
3011 data->fingers = fingers;
3013 data->edge_size = EFL_UTIL_GESTURE_EDGE_SIZE_FULL;
3015 set_last_result(EFL_UTIL_ERROR_NONE);
3017 return (void *)data;
3021 efl_util_gesture_edge_drag_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
3023 if (!gesture_h || gesture_h->init == EINA_FALSE)
3025 return EFL_UTIL_ERROR_INVALID_PARAMETER;
3030 return EFL_UTIL_ERROR_INVALID_PARAMETER;
3036 return EFL_UTIL_ERROR_NONE;
3040 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)
3042 Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = data;
3044 EINA_SAFETY_ON_NULL_RETURN_VAL(edge_drag_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
3045 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_drag_data->base.type == TIZEN_GESTURE_TYPE_EDGE_DRAG,
3046 EFL_UTIL_ERROR_INVALID_PARAMETER);
3047 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_size == EFL_UTIL_GESTURE_EDGE_SIZE_PARTIAL,
3048 EFL_UTIL_ERROR_INVALID_PARAMETER);
3049 EINA_SAFETY_ON_FALSE_RETURN_VAL(end_point > start_point, EFL_UTIL_ERROR_INVALID_PARAMETER);
3051 edge_drag_data->edge_size = edge_size;
3052 edge_drag_data->start_point = start_point;
3053 edge_drag_data->end_point = end_point;
3055 return EFL_UTIL_ERROR_NONE;
3058 API efl_util_gesture_data
3059 efl_util_gesture_tap_new(efl_util_gesture_h gesture_h, unsigned int fingers, unsigned int repeats)
3061 Efl_Util_Gesture_Tap_Grab_Data *data;
3063 if (!gesture_h || gesture_h->init == EINA_FALSE)
3065 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
3069 if (fingers <= 1 || repeats <= 1)
3071 set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED);
3075 data = (Efl_Util_Gesture_Tap_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Tap_Grab_Data));
3078 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
3079 return NULL; /* LCOV_EXCL_LINE */
3082 data->base.type = TIZEN_GESTURE_TYPE_TAP;
3083 data->fingers = fingers;
3084 data->repeats = repeats;
3086 set_last_result(EFL_UTIL_ERROR_NONE);
3088 return (void *)data;
3092 efl_util_gesture_tap_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
3094 if (!gesture_h || gesture_h->init == EINA_FALSE)
3096 return EFL_UTIL_ERROR_INVALID_PARAMETER;
3101 return EFL_UTIL_ERROR_INVALID_PARAMETER;
3107 return EFL_UTIL_ERROR_NONE;
3110 API efl_util_gesture_data
3111 efl_util_gesture_palm_cover_new(efl_util_gesture_h gesture_h)
3113 Efl_Util_Gesture_Palm_Cover_Grab_Data *data;
3115 if (!gesture_h || gesture_h->init == EINA_FALSE)
3117 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
3121 data = (Efl_Util_Gesture_Palm_Cover_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Palm_Cover_Grab_Data));
3124 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
3125 return NULL; /* LCOV_EXCL_LINE */
3128 data->base.type = TIZEN_GESTURE_TYPE_PALM_COVER;
3130 set_last_result(EFL_UTIL_ERROR_NONE);
3132 return (void *)data;
3136 efl_util_gesture_palm_cover_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
3138 if (!gesture_h || gesture_h->init == EINA_FALSE)
3140 return EFL_UTIL_ERROR_INVALID_PARAMETER;
3145 return EFL_UTIL_ERROR_INVALID_PARAMETER;
3151 return EFL_UTIL_ERROR_NONE;
3154 /* LCOV_EXCL_START */
3156 efl_util_gesture_grab(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
3158 int ret = EFL_UTIL_ERROR_NONE;
3159 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
3161 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
3163 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
3164 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
3165 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
3167 switch (base_data->type)
3169 case TIZEN_GESTURE_TYPE_EDGE_SWIPE:
3170 ret = _efl_util_gesture_grab_edge_swipe(data);
3172 case TIZEN_GESTURE_TYPE_EDGE_DRAG:
3173 ret = _efl_util_gesture_grab_edge_drag(data);
3175 case TIZEN_GESTURE_TYPE_TAP:
3176 ret = _efl_util_gesture_grab_tap(data);
3178 case TIZEN_GESTURE_TYPE_PALM_COVER:
3179 ret = _efl_util_gesture_grab_palm_cover(data);
3182 return EFL_UTIL_ERROR_INVALID_PARAMETER;
3189 efl_util_gesture_ungrab(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
3191 int ret = EFL_UTIL_ERROR_NONE;
3192 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
3194 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
3196 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
3197 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
3198 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
3200 switch (base_data->type)
3202 case TIZEN_GESTURE_TYPE_EDGE_SWIPE:
3203 ret = _efl_util_gesture_ungrab_edge_swipe(data);
3205 case TIZEN_GESTURE_TYPE_EDGE_DRAG:
3206 ret = _efl_util_gesture_ungrab_edge_drag(data);
3208 case TIZEN_GESTURE_TYPE_TAP:
3209 ret = _efl_util_gesture_ungrab_tap(data);
3211 case TIZEN_GESTURE_TYPE_PALM_COVER:
3212 ret = _efl_util_gesture_ungrab_palm_cover(data);
3215 return EFL_UTIL_ERROR_INVALID_PARAMETER;
3220 /* LCOV_EXCL_STOP */
3223 efl_util_gesture_select(efl_util_gesture_h gesture_h, Evas_Object *window, efl_util_gesture_data data)
3225 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
3226 Ecore_Wl2_Window *wlwin;
3227 struct wl_surface *surface;
3230 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
3232 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
3233 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
3234 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
3235 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
3237 if (base_data->type != TIZEN_GESTURE_TYPE_PALM_COVER)
3238 return EFL_UTIL_ERROR_NOT_SUPPORTED;
3240 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
3241 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
3243 surface = ecore_wl2_window_surface_get(wlwin);
3244 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
3245 EFL_UTIL_ERROR_INVALID_PARAMETER);
3247 tizen_gesture_select_palm_cover(_eflutil_defaultqueue.wl.gesture.proto, surface);
3249 while (_eflutil_defaultqueue.wl.gesture.request_notified == -1)
3250 wl_display_dispatch(_eflutil_defaultqueue.wl.dpy);
3252 ret = _efl_util_gesture_convert_error(_eflutil_defaultqueue.wl.gesture.request_notified);
3253 _eflutil_defaultqueue.wl.gesture.request_notified = -1;
3259 efl_util_gesture_deselect(efl_util_gesture_h gesture_h, Evas_Object *window, efl_util_gesture_data data)
3261 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
3262 Ecore_Wl2_Window *wlwin;
3263 struct wl_surface *surface;
3266 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
3268 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
3269 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
3270 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
3271 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
3273 if (base_data->type != TIZEN_GESTURE_TYPE_PALM_COVER)
3274 return EFL_UTIL_ERROR_NOT_SUPPORTED;
3276 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
3277 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
3279 surface = ecore_wl2_window_surface_get(wlwin);
3280 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
3281 EFL_UTIL_ERROR_INVALID_PARAMETER);
3283 tizen_gesture_deselect_palm_cover(_eflutil_defaultqueue.wl.gesture.proto, surface);
3285 while (_eflutil_defaultqueue.wl.gesture.request_notified == -1)
3286 wl_display_dispatch(_eflutil_defaultqueue.wl.dpy);
3288 ret = _efl_util_gesture_convert_error(_eflutil_defaultqueue.wl.gesture.request_notified);
3289 _eflutil_defaultqueue.wl.gesture.request_notified = -1;
3294 /* LCOV_EXCL_START */
3296 efl_util_gesture_activate_set(efl_util_gesture_h gesture_h, unsigned int type, Eina_Bool active)
3300 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
3301 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
3302 EINA_SAFETY_ON_TRUE_RETURN_VAL(type == EFL_UTIL_GESTURE_TYPE_NONE, EFL_UTIL_ERROR_INVALID_PARAMETER);
3304 tizen_gesture_activate_set(_eflutil_defaultqueue.wl.gesture.proto, NULL, type, active);
3306 while (_eflutil_defaultqueue.wl.gesture.request_notified == -1)
3307 wl_display_dispatch(_eflutil_defaultqueue.wl.dpy);
3309 ret = _efl_util_gesture_convert_error(_eflutil_defaultqueue.wl.gesture.request_notified);
3310 _eflutil_defaultqueue.wl.gesture.request_notified = -1;
3314 /* LCOV_EXCL_STOP */
3317 efl_util_gesture_activate_set_on_window(efl_util_gesture_h gesture_h, Evas_Object *window, unsigned int type, Eina_Bool active)
3319 Ecore_Wl2_Window *wlwin;
3320 struct wl_surface *surface;
3323 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
3324 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
3325 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
3326 EINA_SAFETY_ON_TRUE_RETURN_VAL(type == EFL_UTIL_GESTURE_TYPE_NONE, EFL_UTIL_ERROR_INVALID_PARAMETER);
3328 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
3329 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
3331 surface = ecore_wl2_window_surface_get(wlwin);
3332 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
3333 EFL_UTIL_ERROR_INVALID_PARAMETER);
3335 tizen_gesture_activate_set(_eflutil_defaultqueue.wl.gesture.proto, surface, type, active);
3337 while (_eflutil_defaultqueue.wl.gesture.request_notified == -1)
3338 wl_display_dispatch(_eflutil_defaultqueue.wl.dpy);
3340 ret = _efl_util_gesture_convert_error(_eflutil_defaultqueue.wl.gesture.request_notified);
3341 _eflutil_defaultqueue.wl.gesture.request_notified = -1;