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
99 typedef struct _Efl_Util_Wl_Surface_Lv_Info
101 void *surface; /* wl_surface */
103 Eina_Bool wait_for_done;
105 } Efl_Util_Wl_Surface_Lv_Info;
107 typedef struct _Efl_Util_Wl_Surface_Scr_Mode_Info
109 void *surface; /* wl_surface */
111 Eina_Bool wait_for_done;
113 } Efl_Util_Wl_Surface_Scr_Mode_Info;
115 typedef struct _Efl_Util_Wl_Surface_Brightness_Info
117 void *surface; /* wl_surface */
119 Eina_Bool wait_for_done;
121 } Efl_Util_Wl_Surface_Brightness_Info;
123 typedef struct _Efl_Util_Wl_Output_Info
125 struct wl_output *output;
126 int offset_x, offset_y, width, height;
127 } Efl_Util_Wl_Output_Info;
129 typedef struct _Efl_Util_Gesture_Common_Grab_Data
132 } Efl_Util_Gesture_Common_Grab_Data;
134 typedef struct _Efl_Util_Gesture_Edge_Swipe_Grab_Data
136 Efl_Util_Gesture_Common_Grab_Data base;
138 unsigned int fingers;
139 efl_util_gesture_edge_e edge;
140 efl_util_gesture_edge_size_e edge_size;
141 unsigned int start_point;
142 unsigned int end_point;
143 } Efl_Util_Gesture_Edge_Swipe_Grab_Data;
145 typedef struct _Efl_Util_Gesture_Edge_Drag_Grab_Data
147 Efl_Util_Gesture_Common_Grab_Data base;
149 unsigned int fingers;
150 efl_util_gesture_edge_e edge;
151 efl_util_gesture_edge_size_e edge_size;
152 unsigned int start_point;
153 unsigned int end_point;
154 } Efl_Util_Gesture_Edge_Drag_Grab_Data;
156 typedef struct _Efl_Util_Gesture_Tap_Grab_Data
158 Efl_Util_Gesture_Common_Grab_Data base;
160 unsigned int fingers;
161 unsigned int repeats;
162 } Efl_Util_Gesture_Tap_Grab_Data;
164 typedef struct _Efl_Util_Gesture_Palm_Cover_Grab_Data
166 Efl_Util_Gesture_Common_Grab_Data base;
167 } Efl_Util_Gesture_Palm_Cover_Grab_Data;
169 typedef struct _Efl_Util_Device_Info
171 struct tizen_input_device *device;
172 Ecore_Device_Class clas;
173 Eina_Stringshare *name;
174 } Efl_Util_Device_Info;
176 typedef struct _Efl_Util_Data
178 /* wayland related stuffs */
182 Ecore_Wl2_Display *wl2_display;
183 struct wl_display *dpy;
184 struct wl_event_queue *queue;
186 Ecore_Fd_Handler *fd_hdl;
191 struct tizen_policy *proto;
192 Eina_Hash *hash_noti_lv;
193 Eina_Hash *hash_scr_mode;
197 struct wl_event_queue *queue;
198 struct screenshooter *screenshooter;
199 struct tizen_screenshooter *tz_screenshooter;
200 struct wayland_tbm_client *tbm_client;
201 Eina_List *output_list;
206 struct tizen_input_device_manager *devicemgr;
207 int request_notified;
209 Eina_List *wait_devices;
210 struct wl_event_source *wait_timer;
215 struct tizen_display_policy *proto;
216 Eina_Hash *hash_brightness;
220 struct tizen_gesture *proto;
221 int request_notified;
227 static Efl_Util_Data _eflutil =
233 { 0, NULL, NULL, NULL }, /* tizen_policy protocol */
234 { NULL, NULL, NULL, NULL, NULL, 0 }, /* screenshooter protocol */
235 { NULL, -1 }, /* tizen_input_device_manager protocol */
236 { 0, NULL, NULL }, /* display_policy protocol */
237 { NULL, -1, EINA_FALSE } /* tizen_gesture protocol */
241 static Eina_Bool _wl_init(void);
242 static void _cb_wl_reg_global(void *data, struct wl_registry *reg, unsigned int name, const char *interface, unsigned int version);
243 static void _cb_wl_reg_global_remove(void *data, struct wl_registry *reg, unsigned int name);
244 static void _cb_wl_reg_screenshooter_global(void *data, struct wl_registry *reg, unsigned int name, const char *interface, unsigned int version);
245 static void _cb_wl_reg_screenshooter_global_remove(void *data, struct wl_registry *reg, unsigned int name);
246 static void _cb_wl_tz_policy_conformant(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface, uint32_t is_conformant);
247 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);
248 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);
249 static void _cb_wl_tz_policy_transient_for_done(void *data, struct tizen_policy *tizen_policy, uint32_t child_id);
250 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);
251 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);
252 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);
253 static void _cb_wl_tz_policy_allowed_aux_hint(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface_resource, int id);
254 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);
255 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);
257 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);
259 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);
260 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);
261 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);
263 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);
264 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);
265 static void _cb_error(void *data EINA_UNUSED, struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED, uint32_t errorcode);
266 static void _cb_block_expired(void *data EINA_UNUSED, struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED);
268 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);
269 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);
270 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);
271 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);
272 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);
273 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);
274 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);
275 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);
276 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);
279 static const struct wl_registry_listener _wl_reg_listener =
282 _cb_wl_reg_global_remove
285 static const struct wl_registry_listener _wl_reg_screenshooter_listener =
287 _cb_wl_reg_screenshooter_global,
288 _cb_wl_reg_screenshooter_global_remove
291 struct tizen_policy_listener _wl_tz_policy_listener =
293 _cb_wl_tz_policy_conformant,
294 _cb_wl_tz_policy_conformant_area,
295 _cb_wl_tz_policy_notification_done,
296 _cb_wl_tz_policy_transient_for_done,
297 _cb_wl_tz_policy_scr_mode_done,
298 _cb_wl_tz_policy_iconify_state_changed,
299 _cb_wl_tz_policy_supported_aux_hints,
300 _cb_wl_tz_policy_allowed_aux_hint,
301 _cb_wl_tz_policy_aux_message,
302 _cb_wl_conformant_region,
305 static const struct tizen_input_device_listener _wl_tz_input_device_listener =
312 struct tizen_input_device_manager_listener _wl_tz_devmgr_listener =
320 struct tizen_display_policy_listener _wl_tz_display_policy_listener =
322 _cb_wl_tz_display_policy_brightness_done,
325 struct tizen_gesture_listener _wl_tz_gesture_listener =
327 _cb_gesture_edge_swipe_notify,
328 _cb_gesture_edge_swipe,
329 _cb_gesture_edge_drag_notify,
330 _cb_gesture_edge_drag,
331 _cb_gesture_tap_notify,
333 _cb_gesture_palm_cover_notify,
334 _cb_gesture_palm_cover,
335 _cb_gesture_activate_notify
341 struct wl_display *display_wrapper = NULL;
342 struct wl_registry *reg = NULL;
344 if (_eflutil.wl.init) return EINA_TRUE;
348 _eflutil.wl.wl2_display = ecore_wl2_display_connect(NULL);
349 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.wl2_display, fail);
350 _eflutil.wl.dpy = ecore_wl2_display_get(_eflutil.wl.wl2_display);
351 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.dpy, fail);
353 display_wrapper = wl_proxy_create_wrapper(_eflutil.wl.dpy);
354 EINA_SAFETY_ON_NULL_GOTO(display_wrapper, fail);
356 _eflutil.wl.queue = wl_display_create_queue(_eflutil.wl.dpy);
357 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.queue, fail);
359 wl_proxy_set_queue((struct wl_proxy *)display_wrapper, _eflutil.wl.queue);
361 reg = wl_display_get_registry(display_wrapper);
362 wl_proxy_wrapper_destroy(display_wrapper);
363 display_wrapper = NULL;
364 EINA_SAFETY_ON_NULL_GOTO(reg, fail);
366 wl_registry_add_listener(reg, &_wl_reg_listener, NULL);
368 _eflutil.wl.init = EINA_TRUE;
373 wl_proxy_wrapper_destroy(display_wrapper);
375 if (_eflutil.wl.queue)
377 wl_event_queue_destroy(_eflutil.wl.queue);
378 _eflutil.wl.queue = NULL;
381 ecore_wl2_shutdown();
386 _cb_wl_output_geometry(void *data, struct wl_output *wl_output, int x, int y,
387 int physical_width, int physical_height, int subpixel,
388 const char *make, const char *model, int transform)
390 Efl_Util_Wl_Output_Info *output = wl_output_get_user_data(wl_output);
391 if (wl_output == output->output)
393 output->offset_x = x;
394 output->offset_y = y;
399 _cb_wl_output_mode(void *data, struct wl_output *wl_output, uint32_t flags,
400 int width, int height, int refresh)
402 Efl_Util_Wl_Output_Info *output = wl_output_get_user_data(wl_output);
403 if (wl_output == output->output && (flags & WL_OUTPUT_MODE_CURRENT))
405 output->width = width;
406 output->height = height;
411 _cb_wl_output_done(void *data, struct wl_output *wl_output)
416 _cb_wl_output_scale(void *data, struct wl_output *wl_output, int32_t factor)
420 static const struct wl_output_listener output_listener =
422 _cb_wl_output_geometry,
429 _cb_wl_screenshot_done(void *data, struct screenshooter *screenshooter)
431 Eina_Bool *shot_done = (Eina_Bool*)data;
433 *shot_done = EINA_TRUE;
436 static const struct screenshooter_listener screenshooter_listener =
438 _cb_wl_screenshot_done
442 _cb_tz_screenshot_format(void *data, struct tizen_screenshooter *tz_screenshooter, uint32_t format)
447 _cb_tz_screenshot_noti(void *data, struct tizen_screenshooter *tz_screenshooter, uint32_t noti)
449 _eflutil.wl.shot.noti = noti;
452 static const struct tizen_screenshooter_listener tz_screenshooter_listener =
454 _cb_tz_screenshot_format,
455 _cb_tz_screenshot_noti
459 _cb_wl_reg_global(void *data,
460 struct wl_registry *reg,
462 const char *interface,
463 unsigned int version)
465 if (!strcmp(interface, "tizen_policy"))
467 struct tizen_policy *proto;
468 proto = wl_registry_bind(reg,
470 &tizen_policy_interface,
474 tizen_policy_add_listener(proto,
475 &_wl_tz_policy_listener,
478 _eflutil.wl.policy.hash_noti_lv = eina_hash_pointer_new(free);
479 _eflutil.wl.policy.hash_scr_mode = eina_hash_pointer_new(free);
480 _eflutil.wl.policy.proto = proto;
481 _eflutil.wl.policy.id = id;
483 else if (strcmp(interface, "wl_output") == 0)
485 Efl_Util_Wl_Output_Info *output = calloc(1, sizeof(Efl_Util_Wl_Output_Info));
486 EINA_SAFETY_ON_NULL_RETURN(output);
488 _eflutil.wl.shot.output_list = eina_list_append(_eflutil.wl.shot.output_list, output);
490 output->output = wl_registry_bind(reg, id, &wl_output_interface, version);
491 wl_output_add_listener(output->output, &output_listener, output);
493 else if (strcmp(interface, "tizen_input_device_manager") == 0)
495 _eflutil.wl.devmgr.devicemgr = wl_registry_bind(reg, id, &tizen_input_device_manager_interface, version);
496 tizen_input_device_manager_add_listener(_eflutil.wl.devmgr.devicemgr, &_wl_tz_devmgr_listener, NULL);
498 else if (!strcmp(interface, "tizen_display_policy"))
500 _eflutil.wl.display_policy.proto = wl_registry_bind(reg, id, &tizen_display_policy_interface, version);
501 if (!_eflutil.wl.display_policy.proto) return;
503 tizen_display_policy_add_listener(_eflutil.wl.display_policy.proto,
504 &_wl_tz_display_policy_listener,
507 _eflutil.wl.display_policy.hash_brightness = eina_hash_pointer_new(free);
508 _eflutil.wl.display_policy.id = id;
510 else if (strcmp(interface, "tizen_gesture") == 0)
512 _eflutil.wl.gesture.proto = wl_registry_bind(reg, id, &tizen_gesture_interface, version);
513 tizen_gesture_add_listener(_eflutil.wl.gesture.proto, &_wl_tz_gesture_listener, NULL);
516 /* LCOV_EXCL_START */
518 _cb_wl_reg_global_remove(void *data,
519 struct wl_registry *reg,
522 /* unset each global id number to 0 since global id is started
523 * from number 1 on server side display structure
525 if (id == _eflutil.wl.policy.id)
527 _eflutil.wl.policy.id = 0;
528 _eflutil.wl.policy.proto = NULL;
529 eina_hash_free(_eflutil.wl.policy.hash_noti_lv);
530 eina_hash_free(_eflutil.wl.policy.hash_scr_mode);
532 else if (id == _eflutil.wl.display_policy.id)
534 _eflutil.wl.display_policy.id = 0;
535 _eflutil.wl.display_policy.proto = NULL;
536 eina_hash_free(_eflutil.wl.display_policy.hash_brightness);
542 _cb_wl_reg_screenshooter_global(void *data,
543 struct wl_registry *reg,
545 const char *interface,
546 unsigned int version)
548 if (strcmp(interface, "screenshooter") == 0)
550 _eflutil.wl.shot.screenshooter = wl_registry_bind(reg, name, &screenshooter_interface, version);
551 screenshooter_add_listener(_eflutil.wl.shot.screenshooter, &screenshooter_listener, NULL);
553 else if (strcmp(interface, "tizen_screenshooter") == 0)
555 _eflutil.wl.shot.tz_screenshooter = wl_registry_bind(reg, name, &tizen_screenshooter_interface, version);
556 tizen_screenshooter_add_listener(_eflutil.wl.shot.tz_screenshooter, &tz_screenshooter_listener, NULL);
558 wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
562 /* LCOV_EXCL_START */
564 _cb_wl_reg_screenshooter_global_remove(void *data,
565 struct wl_registry *reg,
571 _cb_wl_tz_policy_conformant(void *data, struct tizen_policy *tizen_policy,
572 struct wl_surface *surface, uint32_t is_conformant)
577 _cb_wl_tz_policy_conformant_area(void *data, struct tizen_policy *tizen_policy,
578 struct wl_surface *surface, uint32_t conformant_part,
579 uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h)
585 _cb_wl_tz_policy_notification_done(void *data,
586 struct tizen_policy *tizen_policy,
587 struct wl_surface *surface,
591 Efl_Util_Wl_Surface_Lv_Info *lv_info;
593 lv_info = eina_hash_find(_eflutil.wl.policy.hash_noti_lv, &surface);
596 lv_info->level = level;
597 lv_info->wait_for_done = EINA_FALSE;
598 lv_info->state = state;
602 /* LCOV_EXCL_START */
604 _cb_wl_tz_policy_transient_for_done(void *data, struct tizen_policy *tizen_policy, uint32_t child_id)
610 _cb_wl_tz_policy_scr_mode_done(void *data,
611 struct tizen_policy *tizen_policy,
612 struct wl_surface *surface,
616 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
618 scr_mode_info = eina_hash_find(_eflutil.wl.policy.hash_scr_mode, &surface);
621 scr_mode_info->mode = mode;
622 scr_mode_info->wait_for_done = EINA_FALSE;
623 scr_mode_info->state = state;
627 /* LCOV_EXCL_START */
628 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)
632 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)
636 static void _cb_wl_tz_policy_allowed_aux_hint(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface_resource, int id)
640 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)
643 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)
649 _cb_wl_tz_display_policy_brightness_done(void *data,
650 struct tizen_display_policy *tizen_display_policy,
651 struct wl_surface *surface,
655 Efl_Util_Wl_Surface_Brightness_Info *brightness_info;
657 brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
660 brightness_info->brightness = brightness;
661 brightness_info->wait_for_done = EINA_FALSE;
662 brightness_info->state = state;
667 _cb_window_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
669 Efl_Util_Wl_Surface_Lv_Info *lv_info;
672 if (EINA_UNLIKELY(!lv_info))
675 eina_hash_del(_eflutil.wl.policy.hash_noti_lv, &lv_info->surface, lv_info);
679 efl_util_set_notification_window_level(Evas_Object *window,
680 efl_util_notification_level_e level)
684 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
685 EINA_SAFETY_ON_FALSE_RETURN_VAL((level >= EFL_UTIL_NOTIFICATION_LEVEL_NONE) &&
686 (level <= EFL_UTIL_NOTIFICATION_LEVEL_TOP),
687 EFL_UTIL_ERROR_INVALID_PARAMETER);
690 Ecore_Wl2_Window *wlwin;
691 struct wl_surface *surface;
692 Efl_Util_Wl_Surface_Lv_Info *lv_info;
693 Ecore_Wl2_Window_Type wl_type;
696 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
698 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
699 EINA_SAFETY_ON_NULL_RETURN_VAL(wlwin, EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
701 type = elm_win_type_get(window);
702 if (type != ELM_WIN_NOTIFICATION)
704 wl_type = ecore_wl2_window_type_get(wlwin);
705 EINA_SAFETY_ON_FALSE_RETURN_VAL((wl_type == ECORE_WL2_WINDOW_TYPE_NOTIFICATION),
706 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
709 while (!_eflutil.wl.policy.proto)
710 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
712 surface = ecore_wl2_window_surface_get(wlwin);
713 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
714 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
716 lv_info = eina_hash_find(_eflutil.wl.policy.hash_noti_lv, &surface);
719 lv_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Lv_Info));
720 EINA_SAFETY_ON_NULL_RETURN_VAL(lv_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
722 lv_info->surface = surface;
723 lv_info->level = (int)level;
724 lv_info->wait_for_done = EINA_TRUE;
725 lv_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
726 eina_hash_add(_eflutil.wl.policy.hash_noti_lv,
730 evas_object_event_callback_add(window, EVAS_CALLBACK_DEL,
731 _cb_window_del, lv_info);
735 lv_info->level = (int)level;
736 lv_info->wait_for_done = EINA_TRUE;
737 lv_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
741 tizen_policy_set_notification_level(_eflutil.wl.policy.proto,
742 surface, (int)level);
744 if (lv_info->wait_for_done)
747 while (lv_info->wait_for_done && (count < 3))
749 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
750 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
754 if (lv_info->wait_for_done)
756 return EFL_UTIL_ERROR_INVALID_PARAMETER;
760 if (lv_info->state == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
762 return EFL_UTIL_ERROR_PERMISSION_DENIED;
767 return EFL_UTIL_ERROR_NONE;
771 efl_util_get_notification_window_level(Evas_Object *window,
772 efl_util_notification_level_e *level)
776 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
777 EINA_SAFETY_ON_NULL_RETURN_VAL(level, EFL_UTIL_ERROR_INVALID_PARAMETER);
780 Ecore_Wl2_Window *wlwin;
781 struct wl_surface *surface;
782 Efl_Util_Wl_Surface_Lv_Info *lv_info;
783 Ecore_Wl2_Window_Type wl_type;
786 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
788 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
789 EINA_SAFETY_ON_NULL_RETURN_VAL(wlwin, EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
791 type = elm_win_type_get(window);
792 if (type != ELM_WIN_NOTIFICATION)
794 wl_type = ecore_wl2_window_type_get(wlwin);
795 EINA_SAFETY_ON_FALSE_RETURN_VAL((wl_type == ECORE_WL2_WINDOW_TYPE_NOTIFICATION),
796 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
799 while (!_eflutil.wl.policy.proto)
800 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
802 surface = ecore_wl2_window_surface_get(wlwin);
803 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
804 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
806 lv_info = eina_hash_find(_eflutil.wl.policy.hash_noti_lv, &surface);
809 if (lv_info->wait_for_done)
812 while ((lv_info->wait_for_done) && (count < 3))
814 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
815 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
819 if (lv_info->wait_for_done)
821 *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
822 return EFL_UTIL_ERROR_INVALID_PARAMETER;
826 switch (lv_info->level)
828 case TIZEN_POLICY_LEVEL_NONE: *level = EFL_UTIL_NOTIFICATION_LEVEL_NONE; break;
829 case TIZEN_POLICY_LEVEL_DEFAULT: *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT; break;
830 case TIZEN_POLICY_LEVEL_MEDIUM: *level = EFL_UTIL_NOTIFICATION_LEVEL_MEDIUM; break;
831 case TIZEN_POLICY_LEVEL_HIGH: *level = EFL_UTIL_NOTIFICATION_LEVEL_HIGH; break;
832 case TIZEN_POLICY_LEVEL_TOP: *level = EFL_UTIL_NOTIFICATION_LEVEL_TOP; break;
833 default: *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
834 return EFL_UTIL_ERROR_INVALID_PARAMETER;
836 return EFL_UTIL_ERROR_NONE;
839 *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
841 return EFL_UTIL_ERROR_NONE;
845 efl_util_set_window_opaque_state(Evas_Object *window,
850 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
851 EINA_SAFETY_ON_FALSE_RETURN_VAL(((opaque >= 0) && (opaque <= 1)),
852 EFL_UTIL_ERROR_INVALID_PARAMETER);
854 Ecore_Wl2_Window *wlwin;
855 struct wl_surface *surface;
857 if (!_eflutil.wl.policy.proto)
862 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
864 while (!_eflutil.wl.policy.proto && ret != -1)
865 ret = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
867 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.policy.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
870 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
872 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
874 surface = ecore_wl2_window_surface_get(wlwin);
876 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
878 tizen_policy_set_opaque_state(_eflutil.wl.policy.proto, surface, opaque);
880 return EFL_UTIL_ERROR_NONE;
884 efl_util_set_window_screen_mode(Evas_Object *window,
885 efl_util_screen_mode_e mode)
887 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
888 EINA_SAFETY_ON_FALSE_RETURN_VAL(((mode >= EFL_UTIL_SCREEN_MODE_DEFAULT) &&
889 (mode <= EFL_UTIL_SCREEN_MODE_ALWAYS_ON)),
890 EFL_UTIL_ERROR_INVALID_PARAMETER);
892 Ecore_Wl2_Window *wlwin;
893 struct wl_surface *surface;
894 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
898 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
900 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
903 while (!_eflutil.wl.policy.proto)
904 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
906 surface = ecore_wl2_window_surface_get(wlwin);
907 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
908 EFL_UTIL_ERROR_INVALID_PARAMETER);
910 scr_mode_info = eina_hash_find(_eflutil.wl.policy.hash_scr_mode, &surface);
913 scr_mode_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Scr_Mode_Info));
914 EINA_SAFETY_ON_NULL_RETURN_VAL(scr_mode_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
916 scr_mode_info->surface = surface;
917 scr_mode_info->mode = (unsigned int)mode;
918 scr_mode_info->wait_for_done = EINA_TRUE;
919 scr_mode_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
921 eina_hash_add(_eflutil.wl.policy.hash_scr_mode,
927 scr_mode_info->mode = (unsigned int)mode;
928 scr_mode_info->wait_for_done = EINA_TRUE;
929 scr_mode_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
932 tizen_policy_set_window_screen_mode(_eflutil.wl.policy.proto,
933 surface, (unsigned int)mode);
934 if (scr_mode_info->wait_for_done)
937 while (scr_mode_info->wait_for_done && (count < 3))
939 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
940 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
944 if (scr_mode_info->wait_for_done)
946 return EFL_UTIL_ERROR_INVALID_PARAMETER;
950 if (scr_mode_info->state == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
952 return EFL_UTIL_ERROR_PERMISSION_DENIED;
957 return EFL_UTIL_ERROR_NONE;
960 return EFL_UTIL_ERROR_INVALID_PARAMETER;
964 efl_util_get_window_screen_mode(Evas_Object *window,
965 efl_util_screen_mode_e *mode)
967 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
968 EINA_SAFETY_ON_NULL_RETURN_VAL(mode, EFL_UTIL_ERROR_INVALID_PARAMETER);
970 Ecore_Wl2_Window *wlwin;
971 struct wl_surface *surface;
972 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
976 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
978 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
981 while (!_eflutil.wl.policy.proto)
982 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
984 surface = ecore_wl2_window_surface_get(wlwin);
985 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
986 EFL_UTIL_ERROR_INVALID_PARAMETER);
988 scr_mode_info = eina_hash_find(_eflutil.wl.policy.hash_scr_mode, &surface);
991 if (scr_mode_info->wait_for_done)
993 while (scr_mode_info->wait_for_done)
995 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
996 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1000 switch (scr_mode_info->mode)
1002 case TIZEN_POLICY_MODE_DEFAULT: *mode = EFL_UTIL_SCREEN_MODE_DEFAULT; break;
1003 case TIZEN_POLICY_MODE_ALWAYS_ON: *mode = EFL_UTIL_SCREEN_MODE_ALWAYS_ON; break;
1004 default: *mode = EFL_UTIL_SCREEN_MODE_DEFAULT;
1005 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1007 return EFL_UTIL_ERROR_NONE;
1011 *mode = EFL_UTIL_SCREEN_MODE_DEFAULT;
1012 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1016 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1020 efl_util_set_window_brightness(Evas_Object *window, int brightness)
1022 Ecore_Wl2_Window *wlwin;
1023 struct wl_surface *surface;
1024 Efl_Util_Wl_Surface_Brightness_Info *brightness_info;
1027 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1028 EINA_SAFETY_ON_FALSE_RETURN_VAL(brightness <= 100, EFL_UTIL_ERROR_INVALID_PARAMETER);
1031 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1033 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
1036 while (!_eflutil.wl.display_policy.proto)
1037 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1039 surface = ecore_wl2_window_surface_get(wlwin);
1040 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1041 EFL_UTIL_ERROR_INVALID_PARAMETER);
1043 brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
1044 if (!brightness_info)
1046 brightness_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Brightness_Info));
1047 EINA_SAFETY_ON_NULL_RETURN_VAL(brightness_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
1049 brightness_info->surface = surface;
1050 brightness_info->brightness = brightness;
1051 brightness_info->wait_for_done = EINA_TRUE;
1052 brightness_info->state = TIZEN_DISPLAY_POLICY_ERROR_STATE_NONE;
1054 eina_hash_add(_eflutil.wl.display_policy.hash_brightness,
1060 brightness_info->brightness = brightness;
1061 brightness_info->wait_for_done = EINA_TRUE;
1062 brightness_info->state = TIZEN_DISPLAY_POLICY_ERROR_STATE_NONE;
1065 tizen_display_policy_set_window_brightness(_eflutil.wl.display_policy.proto,
1066 surface, brightness);
1067 if (brightness_info->wait_for_done)
1070 while (brightness_info->wait_for_done && (count < 3))
1072 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
1073 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1077 if (brightness_info->wait_for_done)
1079 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1083 if (brightness_info->state == TIZEN_DISPLAY_POLICY_ERROR_STATE_PERMISSION_DENIED)
1085 return EFL_UTIL_ERROR_PERMISSION_DENIED;
1089 return EFL_UTIL_ERROR_NONE;
1092 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1096 efl_util_get_window_brightness(Evas_Object *window, int *brightness)
1098 Ecore_Wl2_Window *wlwin;
1099 struct wl_surface *surface;
1100 Efl_Util_Wl_Surface_Brightness_Info *brightness_info;
1103 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1104 EINA_SAFETY_ON_NULL_RETURN_VAL(brightness, EFL_UTIL_ERROR_INVALID_PARAMETER);
1107 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1109 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
1110 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
1112 while (!_eflutil.wl.display_policy.proto)
1113 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1115 surface = ecore_wl2_window_surface_get(wlwin);
1116 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1117 EFL_UTIL_ERROR_INVALID_PARAMETER);
1119 brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
1120 if (brightness_info)
1122 if (brightness_info->wait_for_done)
1124 while (brightness_info->wait_for_done)
1126 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
1127 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1130 *brightness = brightness_info->brightness;
1135 return EFL_UTIL_ERROR_NONE;
1139 struct _efl_util_inputgen_h
1141 unsigned int init_type;
1146 _efl_util_input_check_wait_device_full(void)
1148 Eina_List *l, *ll, *l_next;
1149 Efl_Util_Device_Info *dev, *wait_dev;
1152 wait_cnt = eina_list_count(_eflutil.wl.devmgr.wait_devices);
1153 if (wait_cnt <= 0) return EINA_TRUE;
1155 EINA_LIST_FOREACH(_eflutil.wl.devmgr.devices, l, dev)
1157 EINA_LIST_FOREACH_SAFE(_eflutil.wl.devmgr.wait_devices, ll, l_next, wait_dev)
1159 if ((dev->clas == wait_dev->clas) &&
1160 (!strncmp(dev->name, wait_dev->name, eina_stringshare_strlen(wait_dev->name))))
1162 eina_stringshare_del(wait_dev->name);
1163 _eflutil.wl.devmgr.wait_devices = eina_list_remove_list(_eflutil.wl.devmgr.wait_devices, ll);
1167 if (wait_cnt <= 0) return EINA_TRUE;
1178 _efl_util_input_check_wait_device(const char *name, unsigned int type)
1180 Eina_List *l, *l_next;
1181 Efl_Util_Device_Info *wait_dev;
1184 wait_cnt = eina_list_count(_eflutil.wl.devmgr.wait_devices);
1185 if (wait_cnt <= 0) return EINA_TRUE;
1187 EINA_LIST_FOREACH_SAFE(_eflutil.wl.devmgr.wait_devices, l, l_next, wait_dev)
1189 if ((type == wait_dev->clas) &&
1190 (!strncmp(name, wait_dev->name, eina_stringshare_strlen(wait_dev->name))))
1192 eina_stringshare_del(wait_dev->name);
1193 _eflutil.wl.devmgr.wait_devices = eina_list_remove_list(_eflutil.wl.devmgr.wait_devices, l);
1197 if (wait_cnt <= 0) return EINA_TRUE;
1207 _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)
1209 Efl_Util_Device_Info *dev;
1211 if (!(dev = data)) return;
1212 dev->clas = (Ecore_Device_Class)clas;
1213 dev->name = eina_stringshare_add(name);
1215 if (_eflutil.wl.devmgr.wait_timer &&
1216 _efl_util_input_check_wait_device(name, clas))
1218 wl_event_source_remove(_eflutil.wl.devmgr.wait_timer);
1219 _eflutil.wl.devmgr.wait_timer = NULL;
1223 /* LCOV_EXCL_START */
1225 _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)
1231 _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)
1235 /* LCOV_EXCL_STOP */
1238 _cb_device_add(void *data EINA_UNUSED,
1239 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1240 uint32_t serial EINA_UNUSED,
1241 const char *identifier EINA_UNUSED,
1242 struct tizen_input_device *device,
1243 struct wl_seat *seat EINA_UNUSED)
1245 Efl_Util_Device_Info *dev;
1247 EINA_SAFETY_ON_NULL_RETURN(device);
1249 dev = (Efl_Util_Device_Info *)calloc(1, sizeof(Efl_Util_Device_Info));
1250 EINA_SAFETY_ON_NULL_RETURN(dev);
1252 dev->device = device;
1253 tizen_input_device_add_listener(device, &_wl_tz_input_device_listener, dev);
1255 _eflutil.wl.devmgr.devices = eina_list_append(_eflutil.wl.devmgr.devices, dev);
1259 _cb_device_remove(void *data EINA_UNUSED,
1260 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1261 uint32_t serial EINA_UNUSED,
1262 const char *identifier EINA_UNUSED,
1263 struct tizen_input_device *device,
1264 struct wl_seat *seat EINA_UNUSED)
1266 Eina_List *l, *l_next;
1267 Efl_Util_Device_Info *dev;
1269 EINA_LIST_FOREACH_SAFE(_eflutil.wl.devmgr.devices, l, l_next, dev)
1271 if (dev->device == device)
1273 if (dev->name) eina_stringshare_del(dev->name);
1274 tizen_input_device_release(dev->device);
1276 _eflutil.wl.devmgr.devices = eina_list_remove_list(_eflutil.wl.devmgr.devices, l);
1285 _cb_error(void *data EINA_UNUSED,
1286 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1289 _eflutil.wl.devmgr.request_notified = errorcode;
1292 /* LCOV_EXCL_START */
1294 _cb_block_expired(void *data EINA_UNUSED,
1295 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED)
1299 /* LCOV_EXCL_STOP */
1301 static efl_util_error_e
1302 _efl_util_input_convert_input_generator_error(int ret)
1306 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE:
1307 return EFL_UTIL_ERROR_NONE;
1308 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NO_PERMISSION:
1309 return EFL_UTIL_ERROR_PERMISSION_DENIED;
1310 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NO_SYSTEM_RESOURCES:
1311 return EFL_UTIL_ERROR_OUT_OF_MEMORY;
1312 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_INVALID_PARAMETER:
1313 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1315 return EFL_UTIL_ERROR_NONE;
1319 /* LCOV_EXCL_START */
1321 _timer_wait(void *data)
1323 Efl_Util_Device_Info *dev;
1325 _eflutil.wl.devmgr.request_notified = TIZEN_INPUT_DEVICE_MANAGER_ERROR_NO_SYSTEM_RESOURCES;
1327 if (eina_list_count(_eflutil.wl.devmgr.wait_devices) > 0)
1329 EINA_LIST_FREE(_eflutil.wl.devmgr.wait_devices, dev)
1331 eina_stringshare_del(dev->name);
1336 wl_event_source_remove(_eflutil.wl.devmgr.wait_timer);
1337 _eflutil.wl.devmgr.wait_timer = NULL;
1341 /* LCOV_EXCL_STOP */
1344 _efl_util_input_initialize_wait_device(void)
1346 struct wl_event_loop *loop;
1349 if (_efl_util_input_check_wait_device_full()) return;
1351 loop = wl_event_loop_create();
1352 _eflutil.wl.devmgr.wait_timer = wl_event_loop_add_timer(loop, _timer_wait, NULL);
1353 if (_eflutil.wl.devmgr.wait_timer)
1354 ret = wl_event_source_timer_update(_eflutil.wl.devmgr.wait_timer,
1355 EFL_UTIL_INPUT_GENERATOR_DEFAULT_TIME_OUT);
1357 while (_eflutil.wl.devmgr.wait_timer)
1359 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1360 ret = wl_event_loop_dispatch(loop, EFL_UTIL_INPUT_GENERATOR_DEFAULT_DISPATCH_TIME_OUT);
1361 if (ret != 0) _timer_wait(NULL);
1366 _efl_util_input_initialize_append_device(const char *name, Ecore_Device_Class clas)
1368 Efl_Util_Device_Info *dev;
1370 dev = (Efl_Util_Device_Info *)calloc(1, sizeof(Efl_Util_Device_Info));
1371 EINA_SAFETY_ON_NULL_RETURN(dev);
1373 dev->name = eina_stringshare_add(name);
1376 _eflutil.wl.devmgr.wait_devices = eina_list_append(_eflutil.wl.devmgr.wait_devices, dev);
1380 _efl_util_input_initialize_add_wait_device(const char *name, unsigned int dev_type)
1382 EINA_SAFETY_ON_NULL_RETURN(name);
1384 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN)
1385 _efl_util_input_initialize_append_device(name, ECORE_DEVICE_CLASS_TOUCH);
1387 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD)
1388 _efl_util_input_initialize_append_device(name, ECORE_DEVICE_CLASS_KEYBOARD);
1390 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_POINTER)
1391 _efl_util_input_initialize_append_device(name, ECORE_DEVICE_CLASS_MOUSE);
1394 API efl_util_inputgen_h
1395 efl_util_input_initialize_generator(unsigned int dev_type)
1397 int ret = EFL_UTIL_ERROR_NONE;
1398 efl_util_inputgen_h inputgen_h = NULL;
1399 unsigned int clas = 0x0;
1402 dev_type & ~(EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN
1403 | EFL_UTIL_INPUT_DEVTYPE_KEYBOARD
1404 | EFL_UTIL_INPUT_DEVTYPE_POINTER))
1406 set_last_result(EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1410 inputgen_h = (efl_util_inputgen_h)calloc(1, sizeof(struct _efl_util_inputgen_h));
1413 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
1417 inputgen_h->init_type |= dev_type;
1420 if (ret == (int)EINA_FALSE)
1422 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1426 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN)
1427 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
1428 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD)
1429 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD;
1430 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_POINTER)
1431 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE;
1433 while (!_eflutil.wl.devmgr.devicemgr)
1434 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1436 tizen_input_device_manager_init_generator(_eflutil.wl.devmgr.devicemgr, clas);
1438 while (_eflutil.wl.devmgr.request_notified == -1)
1439 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1441 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1442 _eflutil.wl.devmgr.request_notified = -1;
1444 set_last_result(ret);
1445 if (ret != TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE)
1459 API efl_util_inputgen_h
1460 efl_util_input_initialize_generator_with_name(unsigned int dev_type, const char *name)
1462 int ret = EFL_UTIL_ERROR_NONE;
1463 efl_util_inputgen_h inputgen_h = NULL;
1464 unsigned int clas = 0x0;
1467 dev_type & ~(EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN
1468 | EFL_UTIL_INPUT_DEVTYPE_KEYBOARD
1469 | EFL_UTIL_INPUT_DEVTYPE_POINTER))
1471 set_last_result(EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1475 inputgen_h = (efl_util_inputgen_h)calloc(1, sizeof(struct _efl_util_inputgen_h));
1478 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
1482 inputgen_h->init_type |= dev_type;
1483 strncpy(inputgen_h->name, name, 31);
1486 if (ret == (int)EINA_FALSE)
1488 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1492 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN)
1493 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
1494 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD)
1495 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD;
1496 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_POINTER)
1497 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE;
1499 while (!_eflutil.wl.devmgr.devicemgr)
1500 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1502 tizen_input_device_manager_init_generator_with_name(_eflutil.wl.devmgr.devicemgr, clas, inputgen_h->name);
1504 while (_eflutil.wl.devmgr.request_notified == -1)
1505 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1507 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1508 _eflutil.wl.devmgr.request_notified = -1;
1510 set_last_result(ret);
1511 if (ret != TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE)
1525 API efl_util_inputgen_h
1526 efl_util_input_initialize_generator_with_sync(unsigned int dev_type, const char *name)
1528 int ret = EFL_UTIL_ERROR_NONE;
1529 efl_util_inputgen_h inputgen_h = NULL;
1530 unsigned int clas = 0x0;
1533 dev_type & ~(EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN
1534 | EFL_UTIL_INPUT_DEVTYPE_KEYBOARD
1535 | EFL_UTIL_INPUT_DEVTYPE_POINTER))
1537 set_last_result(EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1541 inputgen_h = (efl_util_inputgen_h)calloc(1, sizeof(struct _efl_util_inputgen_h));
1544 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
1548 inputgen_h->init_type |= dev_type;
1549 if (name) strncpy(inputgen_h->name, name, 31);
1550 else strncpy(inputgen_h->name, "Input Generator", 31);
1553 if (ret == (int)EINA_FALSE)
1555 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1559 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN)
1560 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
1561 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD)
1562 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD;
1563 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_POINTER)
1564 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE;
1566 while (!_eflutil.wl.devmgr.devicemgr)
1567 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1569 tizen_input_device_manager_init_generator_with_name(_eflutil.wl.devmgr.devicemgr, clas, inputgen_h->name);
1571 while (_eflutil.wl.devmgr.request_notified == -1)
1572 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1574 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1575 _eflutil.wl.devmgr.request_notified = -1;
1577 if (ret == EFL_UTIL_ERROR_NONE)
1579 _efl_util_input_initialize_add_wait_device(inputgen_h->name, dev_type);
1580 _efl_util_input_initialize_wait_device();
1581 if (_eflutil.wl.devmgr.request_notified != -1)
1583 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1584 _eflutil.wl.devmgr.request_notified = -1;
1588 set_last_result(ret);
1589 if (ret != TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE)
1604 efl_util_input_deinitialize_generator(efl_util_inputgen_h inputgen_h)
1606 int ret = EFL_UTIL_ERROR_NONE;
1607 unsigned int clas = 0x0;
1608 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1610 if (inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN)
1611 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
1612 if (inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD)
1613 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD;
1614 if (inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_POINTER)
1615 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE;
1620 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1622 tizen_input_device_manager_deinit_generator(_eflutil.wl.devmgr.devicemgr, clas);
1624 while (_eflutil.wl.devmgr.request_notified == -1)
1625 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1627 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1628 _eflutil.wl.devmgr.request_notified = -1;
1634 efl_util_input_generate_key(efl_util_inputgen_h inputgen_h, const char *key_name, int pressed)
1636 int ret = EFL_UTIL_ERROR_NONE;
1638 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1639 EINA_SAFETY_ON_NULL_RETURN_VAL(key_name, EFL_UTIL_ERROR_INVALID_PARAMETER);
1640 EINA_SAFETY_ON_FALSE_RETURN_VAL(pressed == 0 || pressed == 1, EFL_UTIL_ERROR_INVALID_PARAMETER);
1641 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1643 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1645 tizen_input_device_manager_generate_key(_eflutil.wl.devmgr.devicemgr, key_name, pressed);
1647 while (_eflutil.wl.devmgr.request_notified == -1)
1648 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1650 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1651 _eflutil.wl.devmgr.request_notified = -1;
1657 efl_util_input_generate_touch(efl_util_inputgen_h inputgen_h, int idx,
1658 efl_util_input_touch_type_e touch_type, int x, int y)
1661 enum tizen_input_device_manager_pointer_event_type type;
1663 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1664 EINA_SAFETY_ON_FALSE_RETURN_VAL(idx >= 0, EFL_UTIL_ERROR_INVALID_PARAMETER);
1665 EINA_SAFETY_ON_FALSE_RETURN_VAL((x > 0 && y > 0), EFL_UTIL_ERROR_INVALID_PARAMETER);
1666 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1668 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1672 case EFL_UTIL_INPUT_TOUCH_BEGIN:
1673 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_BEGIN;
1675 case EFL_UTIL_INPUT_TOUCH_UPDATE:
1676 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_UPDATE;
1678 case EFL_UTIL_INPUT_TOUCH_END:
1679 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_END;
1682 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1685 tizen_input_device_manager_generate_touch(_eflutil.wl.devmgr.devicemgr, type, x, y, idx);
1687 while (_eflutil.wl.devmgr.request_notified == -1)
1688 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1690 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1691 _eflutil.wl.devmgr.request_notified = -1;
1697 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)
1700 enum tizen_input_device_manager_pointer_event_type type;
1702 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1703 EINA_SAFETY_ON_FALSE_RETURN_VAL(buttons > 0, EFL_UTIL_ERROR_INVALID_PARAMETER);
1704 EINA_SAFETY_ON_FALSE_RETURN_VAL((x >= 0 && y >= 0), EFL_UTIL_ERROR_INVALID_PARAMETER);
1705 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_POINTER, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1707 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1709 switch(pointer_type)
1711 case EFL_UTIL_INPUT_POINTER_BUTTON_DOWN:
1712 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_BEGIN;
1714 case EFL_UTIL_INPUT_POINTER_MOVE:
1715 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_UPDATE;
1717 case EFL_UTIL_INPUT_POINTER_BUTTON_UP:
1718 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_END;
1721 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1724 tizen_input_device_manager_generate_pointer(_eflutil.wl.devmgr.devicemgr, type, x, y, buttons);
1726 while (_eflutil.wl.devmgr.request_notified == -1)
1727 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1729 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1730 _eflutil.wl.devmgr.request_notified = -1;
1736 struct _efl_util_screenshot_h
1741 Eina_Bool shot_done;
1746 Eina_Bool auto_rotation;
1749 /* scrrenshot handle */
1750 static efl_util_screenshot_h g_screenshot;
1751 static Eina_Bool shot_mutex_init;
1752 static pthread_mutex_t shot_lock;
1755 _screenshot_mutex_init(void)
1757 if (shot_mutex_init)
1760 if (pthread_mutex_init(&shot_lock, NULL))
1762 fprintf(stderr, "[screenshot] fail: mutex init"); /*LCOV_EXCL_LINE*/
1763 return EINA_FALSE; /*LCOV_EXCL_LINE*/
1766 shot_mutex_init = EINA_TRUE;
1772 _screenshot_mutex_destory(void)
1774 if (!shot_mutex_init)
1777 if (pthread_mutex_destroy(&shot_lock))
1779 fprintf(stderr, "[screenshot] fail: mutex destory"); /*LCOV_EXCL_LINE*/
1780 return EINA_FALSE; /*LCOV_EXCL_LINE*/
1783 shot_mutex_init = EINA_FALSE;
1789 _screenshot_mutex_lock(void)
1791 if (!_screenshot_mutex_init())
1794 pthread_mutex_lock(&shot_lock);
1798 _screenshot_mutex_unlock(void)
1800 pthread_mutex_unlock(&shot_lock);
1803 API efl_util_screenshot_h
1804 efl_util_screenshot_initialize(int width, int height)
1806 efl_util_screenshot_h screenshot = NULL;
1807 struct wl_display *display_wrapper = NULL;
1808 struct wl_registry *reg = NULL;
1811 EINA_SAFETY_ON_FALSE_GOTO(width > 0, fail_param);
1812 EINA_SAFETY_ON_FALSE_GOTO(height > 0, fail_param);
1814 _screenshot_mutex_lock();
1816 if (!_eflutil.wl.shot.screenshooter)
1819 if (ret == (int)EINA_FALSE)
1821 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1822 _screenshot_mutex_unlock();
1825 wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1827 display_wrapper = wl_proxy_create_wrapper(_eflutil.wl.dpy);
1828 EINA_SAFETY_ON_NULL_GOTO(display_wrapper, fail_memory);
1830 _eflutil.wl.shot.queue = wl_display_create_queue(_eflutil.wl.dpy);
1831 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.queue, fail_memory);
1833 wl_proxy_set_queue((struct wl_proxy *)display_wrapper, _eflutil.wl.shot.queue);
1835 reg = wl_display_get_registry(display_wrapper);
1836 wl_proxy_wrapper_destroy(display_wrapper);
1837 display_wrapper = NULL;
1838 EINA_SAFETY_ON_NULL_GOTO(reg, fail_init);
1840 wl_registry_add_listener(reg, &_wl_reg_screenshooter_listener, NULL);
1842 ret = wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
1843 EINA_SAFETY_ON_TRUE_GOTO(ret == -1, fail_init);
1844 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.screenshooter, fail_init);
1845 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.tz_screenshooter, fail_init);
1847 _eflutil.wl.shot.tbm_client = wayland_tbm_client_init(_eflutil.wl.dpy);
1848 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.tbm_client, fail_init);
1850 wl_registry_destroy(reg);
1854 if (_eflutil.wl.shot.noti == 0)
1856 fprintf(stderr, "[screenshot] fail: privilege error\n"); /* LCOV_EXCL_LINE */
1862 if (g_screenshot->width != width || g_screenshot->height != height)
1864 g_screenshot->width = width;
1865 g_screenshot->height = height;
1868 _screenshot_mutex_unlock();
1870 return g_screenshot;
1873 screenshot = calloc(1, sizeof(struct _efl_util_screenshot_h));
1874 EINA_SAFETY_ON_NULL_GOTO(screenshot, fail_memory);
1876 screenshot->width = width;
1877 screenshot->height = height;
1878 screenshot->auto_rotation = EINA_TRUE;
1880 screenshot->bufmgr = wayland_tbm_client_get_bufmgr(_eflutil.wl.shot.tbm_client);
1881 EINA_SAFETY_ON_NULL_GOTO(screenshot->bufmgr, fail_init);
1883 g_screenshot = screenshot;
1884 set_last_result(EFL_UTIL_ERROR_NONE);
1886 screenshooter_set_user_data(_eflutil.wl.shot.screenshooter, &screenshot->shot_done);
1888 _screenshot_mutex_unlock();
1890 return g_screenshot;
1893 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1896 /* LCOV_EXCL_START */
1897 if (display_wrapper)
1898 wl_proxy_wrapper_destroy(display_wrapper);
1899 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
1903 wl_registry_destroy(reg);
1905 efl_util_screenshot_deinitialize(screenshot);
1906 _screenshot_mutex_unlock();
1907 set_last_result(EFL_UTIL_ERROR_SCREENSHOT_INIT_FAIL);
1909 /* LCOV_EXCL_STOP */
1913 efl_util_screenshot_deinitialize(efl_util_screenshot_h screenshot)
1915 _screenshot_mutex_lock();
1919 _screenshot_mutex_unlock();
1920 _screenshot_mutex_destory();
1921 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1925 g_screenshot = NULL;
1927 if (_eflutil.wl.shot.screenshooter)
1929 screenshooter_destroy(_eflutil.wl.shot.screenshooter);
1930 _eflutil.wl.shot.screenshooter = NULL;
1932 if (_eflutil.wl.shot.tz_screenshooter)
1934 tizen_screenshooter_destroy(_eflutil.wl.shot.tz_screenshooter);
1935 _eflutil.wl.shot.tz_screenshooter = NULL;
1938 if (_eflutil.wl.shot.queue)
1940 wl_event_queue_destroy(_eflutil.wl.shot.queue);
1941 _eflutil.wl.shot.queue = NULL;
1944 _screenshot_mutex_unlock();
1945 _screenshot_mutex_destory();
1947 return EFL_UTIL_ERROR_NONE;
1952 efl_util_screenshot_take_tbm_surface(efl_util_screenshot_h screenshot)
1954 tbm_surface_h t_surface = NULL;
1955 struct wl_buffer *buffer = NULL;
1956 Efl_Util_Wl_Output_Info *output;
1959 _screenshot_mutex_lock();
1961 if (!screenshot || (screenshot != g_screenshot))
1963 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1964 _screenshot_mutex_unlock();
1968 output = eina_list_nth(_eflutil.wl.shot.output_list, 0);
1971 fprintf(stderr, "[screenshot] fail: no output for screenshot\n"); /* LCOV_EXCL_LINE */
1975 t_surface = tbm_surface_create(screenshot->width, screenshot->height, TBM_FORMAT_XRGB8888);
1978 fprintf(stderr, "[screenshot] fail: tbm_surface_create\n"); /* LCOV_EXCL_LINE */
1982 buffer = wayland_tbm_client_create_buffer(_eflutil.wl.shot.tbm_client, t_surface);
1985 fprintf(stderr, "[screenshot] fail: create wl_buffer for screenshot\n"); /* LCOV_EXCL_LINE */
1989 screenshooter_shoot(_eflutil.wl.shot.screenshooter, output->output, buffer);
1991 screenshot->shot_done = EINA_FALSE;
1992 while (!screenshot->shot_done && ret != -1)
1993 ret = wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
1997 fprintf(stderr, "[screenshot] fail: screenshooter_shoot\n"); /* LCOV_EXCL_LINE */
2001 wl_buffer_destroy(buffer);
2003 /* reset shot_done for next screenshot */
2004 screenshot->shot_done = EINA_FALSE;
2006 set_last_result(EFL_UTIL_ERROR_NONE);
2008 _screenshot_mutex_unlock();
2014 tbm_surface_destroy(t_surface);
2016 wl_buffer_destroy(buffer);
2018 set_last_result(EFL_UTIL_ERROR_SCREENSHOT_EXECUTION_FAIL);
2020 _screenshot_mutex_unlock();
2025 /* LCOV_EXCL_START */
2027 efl_util_screenshot_set_auto_rotation(efl_util_screenshot_h screenshot, int set)
2029 if (!screenshot || (screenshot != g_screenshot))
2030 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2032 if (!(set == 0 || set == 1))
2033 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2036 g_screenshot->auto_rotation = EINA_TRUE;
2038 g_screenshot->auto_rotation = EINA_FALSE;
2040 tizen_screenshooter_set_oneshot_auto_rotation(_eflutil.wl.shot.tz_screenshooter, g_screenshot->auto_rotation);
2042 return EFL_UTIL_ERROR_NONE;
2046 efl_util_screenshot_get_auto_rotation(efl_util_screenshot_h screenshot, int *set)
2048 if (!screenshot || (screenshot != g_screenshot) || !set)
2049 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2051 *set = g_screenshot->auto_rotation;
2053 return EFL_UTIL_ERROR_NONE;
2055 /* LCOV_EXCL_STOP */
2057 struct _efl_util_gesture_h
2062 API int EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = 0;
2063 API int EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = 0;
2064 API int EFL_UTIL_EVENT_GESTURE_TAP = 0;
2065 API int EFL_UTIL_EVENT_GESTURE_PALM_COVER = 0;
2067 /* LCOV_EXCL_START */
2069 _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)
2071 _eflutil.wl.gesture.request_notified = error;
2075 _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)
2077 efl_util_event_gesture_edge_swipe_s *ev = NULL;
2079 ev = (efl_util_event_gesture_edge_swipe_s *)calloc(1, sizeof(*ev));
2084 ev->fingers = fingers;
2089 ecore_event_add(EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE, ev, NULL, NULL);
2093 _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)
2095 _eflutil.wl.gesture.request_notified = error;
2099 _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)
2101 efl_util_event_gesture_edge_drag_s *ev = NULL;
2103 ev = (efl_util_event_gesture_edge_drag_s *)calloc(1, sizeof(*ev));
2108 ev->fingers = fingers;
2113 ecore_event_add(EFL_UTIL_EVENT_GESTURE_EDGE_DRAG, ev, NULL, NULL);
2117 _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)
2119 _eflutil.wl.gesture.request_notified = error;
2123 _cb_gesture_tap(void *data EINA_UNUSED, struct tizen_gesture *tizen_gesture EINA_UNUSED, uint32_t mode, uint32_t fingers, uint32_t repeats)
2125 efl_util_event_gesture_tap_s *ev = NULL;
2127 ev = (efl_util_event_gesture_tap_s *)calloc(1, sizeof(*ev));
2132 ev->fingers = fingers;
2133 ev->repeats = repeats;
2135 ecore_event_add(EFL_UTIL_EVENT_GESTURE_TAP, ev, NULL, NULL);
2137 /* LCOV_EXCL_STOP */
2140 _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)
2142 _eflutil.wl.gesture.request_notified = error;
2145 /* LCOV_EXCL_START */
2147 _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)
2149 efl_util_event_gesture_palm_cover_s *ev = NULL;
2151 ev = (efl_util_event_gesture_palm_cover_s *)calloc(1, sizeof(*ev));
2156 ev->duration = duration;
2160 ev->pressure = wl_fixed_to_int(pressure);
2162 ecore_event_add(EFL_UTIL_EVENT_GESTURE_PALM_COVER, ev, NULL, NULL);
2164 /* LCOV_EXCL_STOP */
2167 _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)
2169 _eflutil.wl.gesture.request_notified = error;
2172 static efl_util_error_e
2173 _efl_util_gesture_convert_error(int ret)
2177 case TIZEN_GESTURE_ERROR_NONE:
2178 return EFL_UTIL_ERROR_NONE;
2179 case TIZEN_GESTURE_ERROR_INVALID_DATA:
2180 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2181 case TIZEN_GESTURE_ERROR_NO_PERMISSION:
2182 return EFL_UTIL_ERROR_PERMISSION_DENIED;
2183 case TIZEN_GESTURE_ERROR_NO_SYSTEM_RESOURCES:
2184 return EFL_UTIL_ERROR_OUT_OF_MEMORY;
2185 case TIZEN_GESTURE_ERROR_GRABBED_ALREADY:
2186 return EFL_UTIL_ERROR_NO_RESOURCE_AVAILABLE;
2187 case TIZEN_GESTURE_ERROR_NOT_SUPPORTED:
2188 return EFL_UTIL_ERROR_NOT_SUPPORTED;
2190 return EFL_UTIL_ERROR_NONE;
2194 /* LCOV_EXCL_START */
2196 _efl_util_gesture_grab_edge_swipe(efl_util_gesture_data data)
2198 int ret = EFL_UTIL_ERROR_NONE;
2199 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2200 Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = NULL;
2201 unsigned int fingers = 0;
2202 unsigned int edge = 0;
2203 unsigned int edge_size = 0;
2204 unsigned int start_point = 0;
2205 unsigned int end_point = 0;
2207 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2209 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2210 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2211 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_SWIPE,
2212 EFL_UTIL_ERROR_INVALID_PARAMETER);
2214 edge_swipe_data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)data;
2216 fingers = edge_swipe_data->fingers;
2217 edge = edge_swipe_data->edge;
2218 edge_size = edge_swipe_data->edge_size;
2219 start_point = edge_swipe_data->start_point;
2220 end_point = edge_swipe_data->end_point;
2222 tizen_gesture_grab_edge_swipe(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2224 while (_eflutil.wl.gesture.request_notified == -1)
2225 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2227 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2228 _eflutil.wl.gesture.request_notified = -1;
2234 _efl_util_gesture_ungrab_edge_swipe(efl_util_gesture_data data)
2236 int ret = EFL_UTIL_ERROR_NONE;
2237 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2238 Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = NULL;
2239 unsigned int fingers = 0;
2240 unsigned int edge = 0;
2241 unsigned int edge_size = 0;
2242 unsigned int start_point = 0;
2243 unsigned int end_point = 0;
2245 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2247 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2248 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2249 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_SWIPE,
2250 EFL_UTIL_ERROR_INVALID_PARAMETER);
2252 edge_swipe_data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)data;
2254 fingers = edge_swipe_data->fingers;
2255 edge = edge_swipe_data->edge;
2256 edge_size = edge_swipe_data->edge_size;
2257 start_point = edge_swipe_data->start_point;
2258 end_point = edge_swipe_data->end_point;
2260 tizen_gesture_ungrab_edge_swipe(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2262 while (_eflutil.wl.gesture.request_notified == -1)
2263 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2265 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2266 _eflutil.wl.gesture.request_notified = -1;
2272 _efl_util_gesture_grab_edge_drag(efl_util_gesture_data data)
2274 int ret = EFL_UTIL_ERROR_NONE;
2275 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2276 Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = NULL;
2277 unsigned int fingers = 0;
2278 unsigned int edge = 0;
2279 unsigned int edge_size = 0;
2280 unsigned int start_point = 0;
2281 unsigned int end_point = 0;
2283 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2285 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2286 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2287 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_DRAG,
2288 EFL_UTIL_ERROR_INVALID_PARAMETER);
2290 edge_drag_data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)data;
2292 fingers = edge_drag_data->fingers;
2293 edge = edge_drag_data->edge;
2294 edge_size = edge_drag_data->edge_size;
2295 start_point = edge_drag_data->start_point;
2296 end_point = edge_drag_data->end_point;
2298 tizen_gesture_grab_edge_drag(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2300 while (_eflutil.wl.gesture.request_notified == -1)
2301 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2303 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2304 _eflutil.wl.gesture.request_notified = -1;
2310 _efl_util_gesture_ungrab_edge_drag(efl_util_gesture_data data)
2312 int ret = EFL_UTIL_ERROR_NONE;
2313 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2314 Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = NULL;
2315 unsigned int fingers = 0;
2316 unsigned int edge = 0;
2317 unsigned int edge_size = 0;
2318 unsigned int start_point = 0;
2319 unsigned int end_point = 0;
2321 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2323 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2324 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2325 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_DRAG,
2326 EFL_UTIL_ERROR_INVALID_PARAMETER);
2328 edge_drag_data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)data;
2330 fingers = edge_drag_data->fingers;
2331 edge = edge_drag_data->edge;
2332 edge_size = edge_drag_data->edge_size;
2333 start_point = edge_drag_data->start_point;
2334 end_point = edge_drag_data->end_point;
2336 tizen_gesture_ungrab_edge_drag(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2338 while (_eflutil.wl.gesture.request_notified == -1)
2339 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2341 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2342 _eflutil.wl.gesture.request_notified = -1;
2349 _efl_util_gesture_grab_tap(efl_util_gesture_data data)
2351 int ret = EFL_UTIL_ERROR_NONE;
2352 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2353 Efl_Util_Gesture_Tap_Grab_Data *tap_data = NULL;
2354 unsigned int fingers = 0;
2355 unsigned int repeats = 0;
2357 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2359 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2360 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2361 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_TAP,
2362 EFL_UTIL_ERROR_INVALID_PARAMETER);
2364 tap_data = (Efl_Util_Gesture_Tap_Grab_Data *)data;
2366 fingers = tap_data->fingers;
2367 repeats = tap_data->repeats;
2369 tizen_gesture_grab_tap(_eflutil.wl.gesture.proto, fingers, repeats);
2371 while (_eflutil.wl.gesture.request_notified == -1)
2372 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2374 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2375 _eflutil.wl.gesture.request_notified = -1;
2381 _efl_util_gesture_ungrab_tap(efl_util_gesture_data data)
2383 int ret = EFL_UTIL_ERROR_NONE;
2384 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2385 Efl_Util_Gesture_Tap_Grab_Data *tap_data = NULL;
2386 unsigned int fingers = 0;
2387 unsigned int repeats = 0;
2389 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2391 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2392 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2393 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_TAP,
2394 EFL_UTIL_ERROR_INVALID_PARAMETER);
2396 tap_data = (Efl_Util_Gesture_Tap_Grab_Data *)data;
2398 fingers = tap_data->fingers;
2399 repeats = tap_data->repeats;
2401 tizen_gesture_ungrab_tap(_eflutil.wl.gesture.proto, fingers, repeats);
2403 while (_eflutil.wl.gesture.request_notified == -1)
2404 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2406 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2407 _eflutil.wl.gesture.request_notified = -1;
2413 _efl_util_gesture_grab_palm_cover(efl_util_gesture_data data)
2415 int ret = EFL_UTIL_ERROR_NONE;
2416 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2418 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2420 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2421 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2422 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_PALM_COVER,
2423 EFL_UTIL_ERROR_INVALID_PARAMETER);
2425 tizen_gesture_grab_palm_cover(_eflutil.wl.gesture.proto);
2427 while (_eflutil.wl.gesture.request_notified == -1)
2428 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2430 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2431 _eflutil.wl.gesture.request_notified = -1;
2437 _efl_util_gesture_ungrab_palm_cover(efl_util_gesture_data data)
2439 int ret = EFL_UTIL_ERROR_NONE;
2440 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2442 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2444 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2445 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2446 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_PALM_COVER,
2447 EFL_UTIL_ERROR_INVALID_PARAMETER);
2449 tizen_gesture_ungrab_palm_cover(_eflutil.wl.gesture.proto);
2451 while (_eflutil.wl.gesture.request_notified == -1)
2452 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2454 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2455 _eflutil.wl.gesture.request_notified = -1;
2461 _efl_util_fd_cb(void *data, Ecore_Fd_Handler *hdl)
2463 if (_eflutil.wl.dpy && _eflutil.wl.queue)
2465 wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2466 return ECORE_CALLBACK_RENEW;
2470 return ECORE_CALLBACK_CANCEL;
2473 /* LCOV_EXCL_STOP */
2475 API efl_util_gesture_h
2476 efl_util_gesture_initialize(void)
2478 efl_util_gesture_h gesture_h = NULL;
2481 gesture_h = (efl_util_gesture_h)calloc(1, sizeof(struct _efl_util_gesture_h));
2484 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2485 goto out; /* LCOV_EXCL_LINE */
2488 if (_wl_init() == (int)EINA_FALSE)
2490 set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED); /* LCOV_EXCL_LINE */
2491 goto out; /* LCOV_EXCL_LINE */
2494 while (!_eflutil.wl.gesture.proto)
2495 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue); /* LCOV_EXCL_LINE */
2497 if (_eflutil.wl.gesture.event_init <= 0)
2499 if (ecore_event_init() <= 0)
2501 set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED); /* LCOV_EXCL_LINE */
2502 goto out; /* LCOV_EXCL_LINE */
2504 EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = ecore_event_type_new();
2505 EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = ecore_event_type_new();
2506 EFL_UTIL_EVENT_GESTURE_TAP = ecore_event_type_new();
2507 EFL_UTIL_EVENT_GESTURE_PALM_COVER = ecore_event_type_new();
2509 dpy_fd = wl_display_get_fd(_eflutil.wl.dpy);
2510 _eflutil.wl.dpy_fd = fcntl(dpy_fd, F_DUPFD_CLOEXEC, 0);
2511 if (_eflutil.wl.dpy_fd >= 0)
2512 _eflutil.wl.fd_hdl = ecore_main_fd_handler_add(_eflutil.wl.dpy_fd,
2513 ECORE_FD_READ | ECORE_FD_WRITE | ECORE_FD_ERROR,
2514 _efl_util_fd_cb, NULL,
2517 _eflutil.wl.gesture.event_init++;
2518 gesture_h->init = EINA_TRUE;
2520 set_last_result(EFL_UTIL_ERROR_NONE);
2524 /* LCOV_EXCL_START */
2531 /* LCOV_EXCL_STOP */
2535 efl_util_gesture_deinitialize(efl_util_gesture_h gesture_h)
2537 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2538 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2543 _eflutil.wl.gesture.event_init--;
2545 if (_eflutil.wl.gesture.event_init <= 0)
2547 _eflutil.wl.gesture.event_init = 0;
2548 ecore_event_shutdown();
2549 EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = 0;
2550 EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = 0;
2551 EFL_UTIL_EVENT_GESTURE_TAP = 0;
2552 EFL_UTIL_EVENT_GESTURE_PALM_COVER = 0;
2553 if (_eflutil.wl.dpy_fd >= 0)
2555 ecore_main_fd_handler_del(_eflutil.wl.fd_hdl);
2556 _eflutil.wl.fd_hdl = NULL;
2557 close(_eflutil.wl.dpy_fd);
2558 _eflutil.wl.dpy_fd = -1;
2562 return EFL_UTIL_ERROR_NONE;
2565 API efl_util_gesture_data
2566 efl_util_gesture_edge_swipe_new(efl_util_gesture_h gesture_h, unsigned int fingers, efl_util_gesture_edge_e edge)
2568 Efl_Util_Gesture_Edge_Swipe_Grab_Data *data;
2570 if (!gesture_h || gesture_h->init == EINA_FALSE)
2572 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2576 if (edge <= EFL_UTIL_GESTURE_EDGE_NONE || edge > EFL_UTIL_GESTURE_EDGE_LEFT)
2578 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2582 data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Edge_Swipe_Grab_Data));
2585 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2586 return NULL; /* LCOV_EXCL_LINE */
2589 data->base.type = TIZEN_GESTURE_TYPE_EDGE_SWIPE;
2590 data->fingers = fingers;
2592 data->edge_size = EFL_UTIL_GESTURE_EDGE_SIZE_FULL;
2594 set_last_result(EFL_UTIL_ERROR_NONE);
2596 return (void *)data;
2600 efl_util_gesture_edge_swipe_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2602 if (!gesture_h || gesture_h->init == EINA_FALSE)
2604 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2609 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2615 return EFL_UTIL_ERROR_NONE;
2619 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)
2621 Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = data;
2623 EINA_SAFETY_ON_NULL_RETURN_VAL(edge_swipe_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2624 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_swipe_data->base.type == TIZEN_GESTURE_TYPE_EDGE_SWIPE,
2625 EFL_UTIL_ERROR_INVALID_PARAMETER);
2626 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_size == EFL_UTIL_GESTURE_EDGE_SIZE_PARTIAL,
2627 EFL_UTIL_ERROR_INVALID_PARAMETER);
2628 EINA_SAFETY_ON_FALSE_RETURN_VAL(end_point > start_point, EFL_UTIL_ERROR_INVALID_PARAMETER);
2630 edge_swipe_data->edge_size = edge_size;
2631 edge_swipe_data->start_point = start_point;
2632 edge_swipe_data->end_point = end_point;
2634 return EFL_UTIL_ERROR_NONE;
2637 API efl_util_gesture_data
2638 efl_util_gesture_edge_drag_new(efl_util_gesture_h gesture_h, unsigned int fingers, efl_util_gesture_edge_e edge)
2640 Efl_Util_Gesture_Edge_Drag_Grab_Data *data;
2642 if (!gesture_h || gesture_h->init == EINA_FALSE)
2644 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2648 if (edge <= EFL_UTIL_GESTURE_EDGE_NONE || edge > EFL_UTIL_GESTURE_EDGE_LEFT)
2650 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2654 data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Edge_Drag_Grab_Data));
2657 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2658 return NULL; /* LCOV_EXCL_LINE */
2661 data->base.type = TIZEN_GESTURE_TYPE_EDGE_DRAG;
2662 data->fingers = fingers;
2664 data->edge_size = EFL_UTIL_GESTURE_EDGE_SIZE_FULL;
2666 set_last_result(EFL_UTIL_ERROR_NONE);
2668 return (void *)data;
2672 efl_util_gesture_edge_drag_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2674 if (!gesture_h || gesture_h->init == EINA_FALSE)
2676 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2681 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2687 return EFL_UTIL_ERROR_NONE;
2691 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)
2693 Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = data;
2695 EINA_SAFETY_ON_NULL_RETURN_VAL(edge_drag_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2696 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_drag_data->base.type == TIZEN_GESTURE_TYPE_EDGE_DRAG,
2697 EFL_UTIL_ERROR_INVALID_PARAMETER);
2698 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_size == EFL_UTIL_GESTURE_EDGE_SIZE_PARTIAL,
2699 EFL_UTIL_ERROR_INVALID_PARAMETER);
2700 EINA_SAFETY_ON_FALSE_RETURN_VAL(end_point > start_point, EFL_UTIL_ERROR_INVALID_PARAMETER);
2702 edge_drag_data->edge_size = edge_size;
2703 edge_drag_data->start_point = start_point;
2704 edge_drag_data->end_point = end_point;
2706 return EFL_UTIL_ERROR_NONE;
2709 API efl_util_gesture_data
2710 efl_util_gesture_tap_new(efl_util_gesture_h gesture_h, unsigned int fingers, unsigned int repeats)
2712 Efl_Util_Gesture_Tap_Grab_Data *data;
2714 if (!gesture_h || gesture_h->init == EINA_FALSE)
2716 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2720 if (fingers <= 1 || repeats <= 1)
2722 set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED);
2726 data = (Efl_Util_Gesture_Tap_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Tap_Grab_Data));
2729 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2730 return NULL; /* LCOV_EXCL_LINE */
2733 data->base.type = TIZEN_GESTURE_TYPE_TAP;
2734 data->fingers = fingers;
2735 data->repeats = repeats;
2737 set_last_result(EFL_UTIL_ERROR_NONE);
2739 return (void *)data;
2743 efl_util_gesture_tap_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2745 if (!gesture_h || gesture_h->init == EINA_FALSE)
2747 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2752 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2758 return EFL_UTIL_ERROR_NONE;
2761 API efl_util_gesture_data
2762 efl_util_gesture_palm_cover_new(efl_util_gesture_h gesture_h)
2764 Efl_Util_Gesture_Palm_Cover_Grab_Data *data;
2766 if (!gesture_h || gesture_h->init == EINA_FALSE)
2768 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2772 data = (Efl_Util_Gesture_Palm_Cover_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Palm_Cover_Grab_Data));
2775 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2776 return NULL; /* LCOV_EXCL_LINE */
2779 data->base.type = TIZEN_GESTURE_TYPE_PALM_COVER;
2781 set_last_result(EFL_UTIL_ERROR_NONE);
2783 return (void *)data;
2787 efl_util_gesture_palm_cover_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2789 if (!gesture_h || gesture_h->init == EINA_FALSE)
2791 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2796 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2802 return EFL_UTIL_ERROR_NONE;
2805 /* LCOV_EXCL_START */
2807 efl_util_gesture_grab(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2809 int ret = EFL_UTIL_ERROR_NONE;
2810 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2812 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2814 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2815 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2816 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2818 switch (base_data->type)
2820 case TIZEN_GESTURE_TYPE_EDGE_SWIPE:
2821 ret = _efl_util_gesture_grab_edge_swipe(data);
2823 case TIZEN_GESTURE_TYPE_EDGE_DRAG:
2824 ret = _efl_util_gesture_grab_edge_drag(data);
2826 case TIZEN_GESTURE_TYPE_TAP:
2827 ret = _efl_util_gesture_grab_tap(data);
2829 case TIZEN_GESTURE_TYPE_PALM_COVER:
2830 ret = _efl_util_gesture_grab_palm_cover(data);
2833 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2840 efl_util_gesture_ungrab(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2842 int ret = EFL_UTIL_ERROR_NONE;
2843 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2845 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2847 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2848 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2849 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2851 switch (base_data->type)
2853 case TIZEN_GESTURE_TYPE_EDGE_SWIPE:
2854 ret = _efl_util_gesture_ungrab_edge_swipe(data);
2856 case TIZEN_GESTURE_TYPE_EDGE_DRAG:
2857 ret = _efl_util_gesture_ungrab_edge_drag(data);
2859 case TIZEN_GESTURE_TYPE_TAP:
2860 ret = _efl_util_gesture_ungrab_tap(data);
2862 case TIZEN_GESTURE_TYPE_PALM_COVER:
2863 ret = _efl_util_gesture_ungrab_palm_cover(data);
2866 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2871 /* LCOV_EXCL_STOP */
2874 efl_util_gesture_select(efl_util_gesture_h gesture_h, Evas_Object *window, efl_util_gesture_data data)
2876 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2877 Ecore_Wl2_Window *wlwin;
2878 struct wl_surface *surface;
2881 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2883 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2884 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2885 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
2886 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2888 if (base_data->type != TIZEN_GESTURE_TYPE_PALM_COVER)
2889 return EFL_UTIL_ERROR_NOT_SUPPORTED;
2891 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
2892 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
2894 surface = ecore_wl2_window_surface_get(wlwin);
2895 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
2896 EFL_UTIL_ERROR_INVALID_PARAMETER);
2898 tizen_gesture_select_palm_cover(_eflutil.wl.gesture.proto, surface);
2900 while (_eflutil.wl.gesture.request_notified == -1)
2901 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2903 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2904 _eflutil.wl.gesture.request_notified = -1;
2910 efl_util_gesture_deselect(efl_util_gesture_h gesture_h, Evas_Object *window, efl_util_gesture_data data)
2912 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2913 Ecore_Wl2_Window *wlwin;
2914 struct wl_surface *surface;
2917 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2919 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2920 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2921 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
2922 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2924 if (base_data->type != TIZEN_GESTURE_TYPE_PALM_COVER)
2925 return EFL_UTIL_ERROR_NOT_SUPPORTED;
2927 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
2928 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
2930 surface = ecore_wl2_window_surface_get(wlwin);
2931 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
2932 EFL_UTIL_ERROR_INVALID_PARAMETER);
2934 tizen_gesture_deselect_palm_cover(_eflutil.wl.gesture.proto, surface);
2936 while (_eflutil.wl.gesture.request_notified == -1)
2937 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2939 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2940 _eflutil.wl.gesture.request_notified = -1;
2945 /* LCOV_EXCL_START */
2947 efl_util_gesture_activate_set(efl_util_gesture_h gesture_h, unsigned int type, Eina_Bool active)
2951 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2952 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2953 EINA_SAFETY_ON_TRUE_RETURN_VAL(type == EFL_UTIL_GESTURE_TYPE_NONE, EFL_UTIL_ERROR_INVALID_PARAMETER);
2955 tizen_gesture_activate_set(_eflutil.wl.gesture.proto, NULL, type, active);
2957 while (_eflutil.wl.gesture.request_notified == -1)
2958 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2960 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2961 _eflutil.wl.gesture.request_notified = -1;
2965 /* LCOV_EXCL_STOP */
2968 efl_util_gesture_activate_set_on_window(efl_util_gesture_h gesture_h, Evas_Object *window, unsigned int type, Eina_Bool active)
2970 Ecore_Wl2_Window *wlwin;
2971 struct wl_surface *surface;
2974 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2975 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2976 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
2977 EINA_SAFETY_ON_TRUE_RETURN_VAL(type == EFL_UTIL_GESTURE_TYPE_NONE, EFL_UTIL_ERROR_INVALID_PARAMETER);
2979 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
2980 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
2982 surface = ecore_wl2_window_surface_get(wlwin);
2983 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
2984 EFL_UTIL_ERROR_INVALID_PARAMETER);
2986 tizen_gesture_activate_set(_eflutil.wl.gesture.proto, surface, type, active);
2988 while (_eflutil.wl.gesture.request_notified == -1)
2989 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2991 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2992 _eflutil.wl.gesture.request_notified = -1;