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"
98 /* callback handler index */
99 #define CBH_NOTI_LEV 0
100 #define CBH_SCR_MODE 1
103 typedef void (*Efl_Util_Cb)(Evas_Object *, int, void *);
105 typedef struct _Efl_Util_Callback_Info
110 } Efl_Util_Callback_Info;
112 typedef struct _Efl_Util_Wl_Surface_Lv_Info
114 void *surface; /* wl_surface */
116 Eina_Bool wait_for_done;
118 } Efl_Util_Wl_Surface_Lv_Info;
120 typedef struct _Efl_Util_Wl_Surface_Scr_Mode_Info
122 void *surface; /* wl_surface */
124 Eina_Bool wait_for_done;
126 } Efl_Util_Wl_Surface_Scr_Mode_Info;
128 typedef struct _Efl_Util_Wl_Surface_Brightness_Info
130 void *surface; /* wl_surface */
132 Eina_Bool wait_for_done;
134 } Efl_Util_Wl_Surface_Brightness_Info;
136 typedef struct _Efl_Util_Wl_Output_Info
138 struct wl_output *output;
139 int offset_x, offset_y, width, height;
140 } Efl_Util_Wl_Output_Info;
142 typedef struct _Efl_Util_Gesture_Common_Grab_Data
145 } Efl_Util_Gesture_Common_Grab_Data;
147 typedef struct _Efl_Util_Gesture_Edge_Swipe_Grab_Data
149 Efl_Util_Gesture_Common_Grab_Data base;
151 unsigned int fingers;
152 efl_util_gesture_edge_e edge;
153 efl_util_gesture_edge_size_e edge_size;
154 unsigned int start_point;
155 unsigned int end_point;
156 } Efl_Util_Gesture_Edge_Swipe_Grab_Data;
158 typedef struct _Efl_Util_Gesture_Edge_Drag_Grab_Data
160 Efl_Util_Gesture_Common_Grab_Data base;
162 unsigned int fingers;
163 efl_util_gesture_edge_e edge;
164 efl_util_gesture_edge_size_e edge_size;
165 unsigned int start_point;
166 unsigned int end_point;
167 } Efl_Util_Gesture_Edge_Drag_Grab_Data;
169 typedef struct _Efl_Util_Gesture_Tap_Grab_Data
171 Efl_Util_Gesture_Common_Grab_Data base;
173 unsigned int fingers;
174 unsigned int repeats;
175 } Efl_Util_Gesture_Tap_Grab_Data;
177 typedef struct _Efl_Util_Gesture_Palm_Cover_Grab_Data
179 Efl_Util_Gesture_Common_Grab_Data base;
180 } Efl_Util_Gesture_Palm_Cover_Grab_Data;
182 typedef struct _Efl_Util_Data
184 /* wayland related stuffs */
188 Ecore_Wl2_Display *wl2_display;
189 struct wl_display *dpy;
190 struct wl_event_queue *queue;
192 Ecore_Fd_Handler *fd_hdl;
197 struct tizen_policy *proto;
198 Eina_Hash *hash_noti_lv;
199 Eina_Hash *hash_scr_mode;
203 struct wl_event_queue *queue;
204 struct screenshooter *screenshooter;
205 struct tizen_screenshooter *tz_screenshooter;
206 struct wayland_tbm_client *tbm_client;
207 Eina_List *output_list;
212 struct tizen_input_device_manager *devicemgr;
213 int request_notified;
218 struct tizen_display_policy *proto;
219 Eina_Hash *hash_brightness;
223 struct tizen_gesture *proto;
224 int request_notified;
231 Eina_List *info_list; /* list of callback info */
232 unsigned int atom; /* x11 atom */
233 } cb_handler[CBH_MAX];
236 static Efl_Util_Data _eflutil =
242 { 0, NULL, NULL, NULL }, /* tizen_policy protocol */
243 { NULL, NULL, NULL, NULL, NULL, 0 }, /* screenshooter protocol */
244 { NULL, -1 }, /* tizen_input_device_manager protocol */
245 { 0, NULL, NULL }, /* display_policy protocol */
246 { NULL, -1, EINA_FALSE } /* tizen_gesture protocol */
249 { NULL, 0 }, /* handler for notification level */
250 { NULL, 0 } /* handler for screen mode */
254 static Eina_Bool _cb_info_add(Evas_Object *win, Efl_Util_Cb cb, void *data, int idx);
255 static Eina_Bool _cb_info_del_by_win(Evas_Object *win, int idx);
256 static Eina_List *_cb_info_list_get(int idx);
257 static Efl_Util_Callback_Info *_cb_info_find_by_win(Evas_Object *win, int idx);
258 static Eina_Bool _wl_init(void);
259 static void _cb_wl_reg_global(void *data, struct wl_registry *reg, unsigned int name, const char *interface, unsigned int version);
260 static void _cb_wl_reg_global_remove(void *data, struct wl_registry *reg, unsigned int name);
261 static void _cb_wl_reg_screenshooter_global(void *data, struct wl_registry *reg, unsigned int name, const char *interface, unsigned int version);
262 static void _cb_wl_reg_screenshooter_global_remove(void *data, struct wl_registry *reg, unsigned int name);
263 static Efl_Util_Callback_Info *_cb_info_find_by_wlsurf(void *wlsurf, int idx);
264 static void _cb_wl_tz_policy_conformant(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface, uint32_t is_conformant);
265 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);
266 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);
267 static void _cb_wl_tz_policy_transient_for_done(void *data, struct tizen_policy *tizen_policy, uint32_t child_id);
268 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);
269 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);
270 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);
271 static void _cb_wl_tz_policy_allowed_aux_hint(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface_resource, int id);
272 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);
273 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);
275 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);
277 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);
278 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);
279 static void _cb_error(void *data EINA_UNUSED, struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED, uint32_t errorcode);
280 static void _cb_block_expired(void *data EINA_UNUSED, struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED);
282 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);
283 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);
284 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);
285 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);
286 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);
287 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);
288 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);
289 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);
290 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);
293 static const struct wl_registry_listener _wl_reg_listener =
296 _cb_wl_reg_global_remove
299 static const struct wl_registry_listener _wl_reg_screenshooter_listener =
301 _cb_wl_reg_screenshooter_global,
302 _cb_wl_reg_screenshooter_global_remove
305 struct tizen_policy_listener _wl_tz_policy_listener =
307 _cb_wl_tz_policy_conformant,
308 _cb_wl_tz_policy_conformant_area,
309 _cb_wl_tz_policy_notification_done,
310 _cb_wl_tz_policy_transient_for_done,
311 _cb_wl_tz_policy_scr_mode_done,
312 _cb_wl_tz_policy_iconify_state_changed,
313 _cb_wl_tz_policy_supported_aux_hints,
314 _cb_wl_tz_policy_allowed_aux_hint,
315 _cb_wl_tz_policy_aux_message,
316 _cb_wl_conformant_region,
319 struct tizen_input_device_manager_listener _wl_tz_devmgr_listener =
327 struct tizen_display_policy_listener _wl_tz_display_policy_listener =
329 _cb_wl_tz_display_policy_brightness_done,
332 struct tizen_gesture_listener _wl_tz_gesture_listener =
334 _cb_gesture_edge_swipe_notify,
335 _cb_gesture_edge_swipe,
336 _cb_gesture_edge_drag_notify,
337 _cb_gesture_edge_drag,
338 _cb_gesture_tap_notify,
340 _cb_gesture_palm_cover_notify,
341 _cb_gesture_palm_cover,
342 _cb_gesture_activate_notify
346 _cb_info_add(Evas_Object *win,
351 Efl_Util_Callback_Info *info;
353 info = _cb_info_find_by_win(win, idx);
356 _eflutil.cb_handler[idx].info_list
357 = eina_list_remove(_eflutil.cb_handler[idx].info_list,
362 info = (Efl_Util_Callback_Info *)calloc(1, sizeof(Efl_Util_Callback_Info));
363 if (!info) return EINA_FALSE;
369 _eflutil.cb_handler[idx].info_list
370 = eina_list_append(_eflutil.cb_handler[idx].info_list,
377 _cb_info_del_by_win(Evas_Object *win,
380 Efl_Util_Callback_Info *info;
382 info = _cb_info_find_by_win(win, idx);
383 if (!info) return EINA_FALSE;
385 _eflutil.cb_handler[idx].info_list
386 = eina_list_remove(_eflutil.cb_handler[idx].info_list,
394 _cb_info_list_get(int idx)
396 return _eflutil.cb_handler[idx].info_list;
399 static Efl_Util_Callback_Info *
400 _cb_info_find_by_win(Evas_Object *win,
404 Efl_Util_Callback_Info *info;
406 l = _cb_info_list_get(idx);
407 EINA_LIST_FOREACH(l, ll, info)
409 if (info->win == win) return info;
418 struct wl_display *display_wrapper = NULL;
419 struct wl_registry *reg = NULL;
421 if (_eflutil.wl.init) return EINA_TRUE;
425 _eflutil.wl.wl2_display = ecore_wl2_display_connect(NULL);
426 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.wl2_display, fail);
427 _eflutil.wl.dpy = ecore_wl2_display_get(_eflutil.wl.wl2_display);
428 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.dpy, fail);
430 display_wrapper = wl_proxy_create_wrapper(_eflutil.wl.dpy);
431 EINA_SAFETY_ON_NULL_GOTO(display_wrapper, fail);
433 _eflutil.wl.queue = wl_display_create_queue(_eflutil.wl.dpy);
434 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.queue, fail);
436 wl_proxy_set_queue((struct wl_proxy *)display_wrapper, _eflutil.wl.queue);
438 reg = wl_display_get_registry(display_wrapper);
439 wl_proxy_wrapper_destroy(display_wrapper);
440 display_wrapper = NULL;
441 EINA_SAFETY_ON_NULL_GOTO(reg, fail);
443 wl_registry_add_listener(reg, &_wl_reg_listener, NULL);
445 _eflutil.wl.init = EINA_TRUE;
450 wl_proxy_wrapper_destroy(display_wrapper);
452 if (_eflutil.wl.queue)
454 wl_event_queue_destroy(_eflutil.wl.queue);
455 _eflutil.wl.queue = NULL;
458 ecore_wl2_shutdown();
463 _cb_wl_output_geometry(void *data, struct wl_output *wl_output, int x, int y,
464 int physical_width, int physical_height, int subpixel,
465 const char *make, const char *model, int transform)
467 Efl_Util_Wl_Output_Info *output = wl_output_get_user_data(wl_output);
468 if (wl_output == output->output)
470 output->offset_x = x;
471 output->offset_y = y;
476 _cb_wl_output_mode(void *data, struct wl_output *wl_output, uint32_t flags,
477 int width, int height, int refresh)
479 Efl_Util_Wl_Output_Info *output = wl_output_get_user_data(wl_output);
480 if (wl_output == output->output && (flags & WL_OUTPUT_MODE_CURRENT))
482 output->width = width;
483 output->height = height;
488 _cb_wl_output_done(void *data, struct wl_output *wl_output)
493 _cb_wl_output_scale(void *data, struct wl_output *wl_output, int32_t factor)
497 static const struct wl_output_listener output_listener =
499 _cb_wl_output_geometry,
506 _cb_wl_screenshot_done(void *data, struct screenshooter *screenshooter)
508 Eina_Bool *shot_done = (Eina_Bool*)data;
510 *shot_done = EINA_TRUE;
513 static const struct screenshooter_listener screenshooter_listener =
515 _cb_wl_screenshot_done
519 _cb_tz_screenshot_format(void *data, struct tizen_screenshooter *tz_screenshooter, uint32_t format)
524 _cb_tz_screenshot_noti(void *data, struct tizen_screenshooter *tz_screenshooter, uint32_t noti)
526 _eflutil.wl.shot.noti = noti;
529 static const struct tizen_screenshooter_listener tz_screenshooter_listener =
531 _cb_tz_screenshot_format,
532 _cb_tz_screenshot_noti
536 _cb_wl_reg_global(void *data,
537 struct wl_registry *reg,
539 const char *interface,
540 unsigned int version)
542 if (!strcmp(interface, "tizen_policy"))
544 struct tizen_policy *proto;
545 proto = wl_registry_bind(reg,
547 &tizen_policy_interface,
551 tizen_policy_add_listener(proto,
552 &_wl_tz_policy_listener,
555 _eflutil.wl.policy.hash_noti_lv = eina_hash_pointer_new(free);
556 _eflutil.wl.policy.hash_scr_mode = eina_hash_pointer_new(free);
557 _eflutil.wl.policy.proto = proto;
558 _eflutil.wl.policy.id = id;
560 else if (strcmp(interface, "wl_output") == 0)
562 Efl_Util_Wl_Output_Info *output = calloc(1, sizeof(Efl_Util_Wl_Output_Info));
563 EINA_SAFETY_ON_NULL_RETURN(output);
565 _eflutil.wl.shot.output_list = eina_list_append(_eflutil.wl.shot.output_list, output);
567 output->output = wl_registry_bind(reg, id, &wl_output_interface, version);
568 wl_output_add_listener(output->output, &output_listener, output);
570 else if (strcmp(interface, "tizen_input_device_manager") == 0)
572 _eflutil.wl.devmgr.devicemgr = wl_registry_bind(reg, id, &tizen_input_device_manager_interface, version);
573 tizen_input_device_manager_add_listener(_eflutil.wl.devmgr.devicemgr, &_wl_tz_devmgr_listener, NULL);
575 else if (!strcmp(interface, "tizen_display_policy"))
577 _eflutil.wl.display_policy.proto = wl_registry_bind(reg, id, &tizen_display_policy_interface, version);
578 if (!_eflutil.wl.display_policy.proto) return;
580 tizen_display_policy_add_listener(_eflutil.wl.display_policy.proto,
581 &_wl_tz_display_policy_listener,
584 _eflutil.wl.display_policy.hash_brightness = eina_hash_pointer_new(free);
585 _eflutil.wl.display_policy.id = id;
587 else if (strcmp(interface, "tizen_gesture") == 0)
589 _eflutil.wl.gesture.proto = wl_registry_bind(reg, id, &tizen_gesture_interface, version);
590 tizen_gesture_add_listener(_eflutil.wl.gesture.proto, &_wl_tz_gesture_listener, NULL);
593 /* LCOV_EXCL_START */
595 _cb_wl_reg_global_remove(void *data,
596 struct wl_registry *reg,
599 /* unset each global id number to 0 since global id is started
600 * from number 1 on server side display structure
602 if (id == _eflutil.wl.policy.id)
604 _eflutil.wl.policy.id = 0;
605 _eflutil.wl.policy.proto = NULL;
606 eina_hash_free(_eflutil.wl.policy.hash_noti_lv);
607 eina_hash_free(_eflutil.wl.policy.hash_scr_mode);
609 else if (id == _eflutil.wl.display_policy.id)
611 _eflutil.wl.display_policy.id = 0;
612 _eflutil.wl.display_policy.proto = NULL;
613 eina_hash_free(_eflutil.wl.display_policy.hash_brightness);
619 _cb_wl_reg_screenshooter_global(void *data,
620 struct wl_registry *reg,
622 const char *interface,
623 unsigned int version)
625 if (strcmp(interface, "screenshooter") == 0)
627 _eflutil.wl.shot.screenshooter = wl_registry_bind(reg, name, &screenshooter_interface, version);
628 screenshooter_add_listener(_eflutil.wl.shot.screenshooter, &screenshooter_listener, NULL);
630 else if (strcmp(interface, "tizen_screenshooter") == 0)
632 _eflutil.wl.shot.tz_screenshooter = wl_registry_bind(reg, name, &tizen_screenshooter_interface, version);
633 tizen_screenshooter_add_listener(_eflutil.wl.shot.tz_screenshooter, &tz_screenshooter_listener, NULL);
635 wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
639 /* LCOV_EXCL_START */
641 _cb_wl_reg_screenshooter_global_remove(void *data,
642 struct wl_registry *reg,
647 static Efl_Util_Callback_Info *
648 _cb_info_find_by_wlsurf(void *wlsurf,
652 Efl_Util_Callback_Info *info;
653 Ecore_Wl2_Window *wlwin2 = NULL;
654 void *wlsurf2 = NULL;
656 l = _cb_info_list_get(idx);
657 EINA_LIST_FOREACH(l, ll, info)
659 wlwin2 = (Ecore_Wl2_Window *)elm_win_wl_window_get(info->win);
660 wlsurf2 = ecore_wl2_window_surface_get(wlwin2);
661 if (wlsurf== wlsurf2) return info;
668 _cb_wl_tz_policy_conformant(void *data, struct tizen_policy *tizen_policy,
669 struct wl_surface *surface, uint32_t is_conformant)
674 _cb_wl_tz_policy_conformant_area(void *data, struct tizen_policy *tizen_policy,
675 struct wl_surface *surface, uint32_t conformant_part,
676 uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h)
682 _cb_wl_tz_policy_notification_done(void *data,
683 struct tizen_policy *tizen_policy,
684 struct wl_surface *surface,
688 Efl_Util_Wl_Surface_Lv_Info *lv_info;
689 Efl_Util_Callback_Info *cb_info;
691 lv_info = eina_hash_find(_eflutil.wl.policy.hash_noti_lv, &surface);
694 lv_info->level = level;
695 lv_info->wait_for_done = EINA_FALSE;
696 lv_info->state = state;
699 if (state != TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED) return;
701 cb_info = _cb_info_find_by_wlsurf((void *)surface, CBH_NOTI_LEV);
702 if (!cb_info) return;
703 if (!cb_info->cb) return;
705 cb_info->cb(cb_info->win,
706 EFL_UTIL_ERROR_PERMISSION_DENIED,
710 /* LCOV_EXCL_START */
712 _cb_wl_tz_policy_transient_for_done(void *data, struct tizen_policy *tizen_policy, uint32_t child_id)
718 _cb_wl_tz_policy_scr_mode_done(void *data,
719 struct tizen_policy *tizen_policy,
720 struct wl_surface *surface,
725 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
726 Efl_Util_Callback_Info *cb_info;
728 scr_mode_info = eina_hash_find(_eflutil.wl.policy.hash_scr_mode, &surface);
731 scr_mode_info->mode = mode;
732 scr_mode_info->wait_for_done = EINA_FALSE;
733 scr_mode_info->state = state;
736 if (state != TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED) return;
738 cb_info = _cb_info_find_by_wlsurf((void *)surface, CBH_SCR_MODE);
739 if (!cb_info) return;
740 if (!cb_info->cb) return;
742 cb_info->cb(cb_info->win,
743 EFL_UTIL_ERROR_PERMISSION_DENIED,
747 /* LCOV_EXCL_START */
748 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)
752 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)
756 static void _cb_wl_tz_policy_allowed_aux_hint(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface_resource, int id)
760 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)
763 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)
769 _cb_wl_tz_display_policy_brightness_done(void *data,
770 struct tizen_display_policy *tizen_display_policy,
771 struct wl_surface *surface,
775 Efl_Util_Wl_Surface_Brightness_Info *brightness_info;
777 brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
780 brightness_info->brightness = brightness;
781 brightness_info->wait_for_done = EINA_FALSE;
782 brightness_info->state = state;
787 _cb_window_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
789 Efl_Util_Wl_Surface_Lv_Info *lv_info;
792 if (EINA_UNLIKELY(!lv_info))
795 eina_hash_del(_eflutil.wl.policy.hash_noti_lv, &lv_info->surface, lv_info);
799 efl_util_set_notification_window_level(Evas_Object *window,
800 efl_util_notification_level_e level)
804 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
805 EINA_SAFETY_ON_FALSE_RETURN_VAL((level >= EFL_UTIL_NOTIFICATION_LEVEL_NONE) &&
806 (level <= EFL_UTIL_NOTIFICATION_LEVEL_TOP),
807 EFL_UTIL_ERROR_INVALID_PARAMETER);
809 if (level == EFL_UTIL_NOTIFICATION_LEVEL_1)
811 dlog_print(DLOG_WARN, LOG_TAG,
812 "DEPRECATION WARNING: EFL_UTIL_NOTIFICATION_LEVEL_1 is deprecated and will be removed from next release. Use EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT instead.");
814 else if (level == EFL_UTIL_NOTIFICATION_LEVEL_2)
816 dlog_print(DLOG_WARN, LOG_TAG,
817 "DEPRECATION WARNING: EFL_UTIL_NOTIFICATION_LEVEL_2 is deprecated and will be removed from next release. Use EFL_UTIL_NOTIFICATION_LEVEL_MEDIUM instead.");
819 else if (level == EFL_UTIL_NOTIFICATION_LEVEL_3)
821 dlog_print(DLOG_WARN, LOG_TAG,
822 "DEPRECATION WARNING: EFL_UTIL_NOTIFICATION_LEVEL_3 is deprecated and will be removed from next release. Use EFL_UTIL_NOTIFICATION_LEVEL_TOP instead.");
826 Ecore_Wl2_Window *wlwin;
827 struct wl_surface *surface;
828 Efl_Util_Wl_Surface_Lv_Info *lv_info;
829 Ecore_Wl2_Window_Type wl_type;
832 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
834 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
835 EINA_SAFETY_ON_NULL_RETURN_VAL(wlwin, EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
837 type = elm_win_type_get(window);
838 if (type != ELM_WIN_NOTIFICATION)
840 wl_type = ecore_wl2_window_type_get(wlwin);
841 EINA_SAFETY_ON_FALSE_RETURN_VAL((wl_type == ECORE_WL2_WINDOW_TYPE_NOTIFICATION),
842 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
845 while (!_eflutil.wl.policy.proto)
846 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
848 surface = ecore_wl2_window_surface_get(wlwin);
849 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
850 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
852 lv_info = eina_hash_find(_eflutil.wl.policy.hash_noti_lv, &surface);
855 lv_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Lv_Info));
856 EINA_SAFETY_ON_NULL_RETURN_VAL(lv_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
858 lv_info->surface = surface;
859 lv_info->level = (int)level;
860 lv_info->wait_for_done = EINA_TRUE;
861 lv_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
862 eina_hash_add(_eflutil.wl.policy.hash_noti_lv,
866 evas_object_event_callback_add(window, EVAS_CALLBACK_DEL,
867 _cb_window_del, lv_info);
871 lv_info->level = (int)level;
872 lv_info->wait_for_done = EINA_TRUE;
873 lv_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
877 tizen_policy_set_notification_level(_eflutil.wl.policy.proto,
878 surface, (int)level);
880 if (lv_info->wait_for_done)
883 while (lv_info->wait_for_done && (count < 3))
885 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
886 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
890 if (lv_info->wait_for_done)
892 return EFL_UTIL_ERROR_INVALID_PARAMETER;
896 if (lv_info->state == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
898 return EFL_UTIL_ERROR_PERMISSION_DENIED;
903 return EFL_UTIL_ERROR_NONE;
907 efl_util_get_notification_window_level(Evas_Object *window,
908 efl_util_notification_level_e *level)
912 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
913 EINA_SAFETY_ON_NULL_RETURN_VAL(level, EFL_UTIL_ERROR_INVALID_PARAMETER);
916 Ecore_Wl2_Window *wlwin;
917 struct wl_surface *surface;
918 Efl_Util_Wl_Surface_Lv_Info *lv_info;
919 Ecore_Wl2_Window_Type wl_type;
922 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
924 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
925 EINA_SAFETY_ON_NULL_RETURN_VAL(wlwin, EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
927 type = elm_win_type_get(window);
928 if (type != ELM_WIN_NOTIFICATION)
930 wl_type = ecore_wl2_window_type_get(wlwin);
931 EINA_SAFETY_ON_FALSE_RETURN_VAL((wl_type == ECORE_WL2_WINDOW_TYPE_NOTIFICATION),
932 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
935 while (!_eflutil.wl.policy.proto)
936 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
938 surface = ecore_wl2_window_surface_get(wlwin);
939 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
940 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
942 lv_info = eina_hash_find(_eflutil.wl.policy.hash_noti_lv, &surface);
945 if (lv_info->wait_for_done)
948 while ((lv_info->wait_for_done) && (count < 3))
950 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
951 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
955 if (lv_info->wait_for_done)
957 *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
958 return EFL_UTIL_ERROR_INVALID_PARAMETER;
962 switch (lv_info->level)
964 case TIZEN_POLICY_LEVEL_1: *level = EFL_UTIL_NOTIFICATION_LEVEL_1; break;
965 case TIZEN_POLICY_LEVEL_2: *level = EFL_UTIL_NOTIFICATION_LEVEL_2; break;
966 case TIZEN_POLICY_LEVEL_3: *level = EFL_UTIL_NOTIFICATION_LEVEL_3; break;
967 case TIZEN_POLICY_LEVEL_NONE: *level = EFL_UTIL_NOTIFICATION_LEVEL_NONE; break;
968 case TIZEN_POLICY_LEVEL_DEFAULT: *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT; break;
969 case TIZEN_POLICY_LEVEL_MEDIUM: *level = EFL_UTIL_NOTIFICATION_LEVEL_MEDIUM; break;
970 case TIZEN_POLICY_LEVEL_HIGH: *level = EFL_UTIL_NOTIFICATION_LEVEL_HIGH; break;
971 case TIZEN_POLICY_LEVEL_TOP: *level = EFL_UTIL_NOTIFICATION_LEVEL_TOP; break;
972 default: *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
973 return EFL_UTIL_ERROR_INVALID_PARAMETER;
975 return EFL_UTIL_ERROR_NONE;
978 *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
980 return EFL_UTIL_ERROR_NONE;
984 efl_util_set_notification_window_level_error_cb(Evas_Object *window,
985 efl_util_notification_window_level_error_cb callback,
988 dlog_print(DLOG_WARN, LOG_TAG,
989 "DEPRECATION WARNING: efl_util_set_notification_window_level_error_cb() is deprecated and will be removed from next release. Use the return value of efl_util_set_notification_window_level() instead.");
991 Eina_Bool ret = EINA_FALSE;
993 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
994 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EFL_UTIL_ERROR_INVALID_PARAMETER);
996 ret = _cb_info_add(window,
997 (Efl_Util_Cb)callback,
1000 if (!ret) return EFL_UTIL_ERROR_OUT_OF_MEMORY;
1002 return EFL_UTIL_ERROR_NONE;
1006 efl_util_unset_notification_window_level_error_cb(Evas_Object *window)
1008 dlog_print(DLOG_WARN, LOG_TAG,
1009 "DEPRECATION WARNING: efl_util_unset_notification_window_level_error_cb() is deprecated and will be removed from next release. Use the return value of efl_util_set_notification_window_level() instead.");
1011 Eina_Bool ret = EINA_FALSE;
1013 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1015 ret = _cb_info_del_by_win(window, CBH_NOTI_LEV);
1016 if (!ret) return EFL_UTIL_ERROR_INVALID_PARAMETER;
1018 return EFL_UTIL_ERROR_NONE;
1022 efl_util_set_window_opaque_state(Evas_Object *window,
1027 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1028 EINA_SAFETY_ON_FALSE_RETURN_VAL(((opaque >= 0) && (opaque <= 1)),
1029 EFL_UTIL_ERROR_INVALID_PARAMETER);
1031 Ecore_Wl2_Window *wlwin;
1032 struct wl_surface *surface;
1034 if (!_eflutil.wl.policy.proto)
1039 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1041 while (!_eflutil.wl.policy.proto && ret != -1)
1042 ret = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1044 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.policy.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
1047 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
1049 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
1051 surface = ecore_wl2_window_surface_get(wlwin);
1053 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
1055 tizen_policy_set_opaque_state(_eflutil.wl.policy.proto, surface, opaque);
1057 return EFL_UTIL_ERROR_NONE;
1061 efl_util_set_window_screen_mode(Evas_Object *window,
1062 efl_util_screen_mode_e mode)
1064 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1065 EINA_SAFETY_ON_FALSE_RETURN_VAL(((mode >= EFL_UTIL_SCREEN_MODE_DEFAULT) &&
1066 (mode <= EFL_UTIL_SCREEN_MODE_ALWAYS_ON)),
1067 EFL_UTIL_ERROR_INVALID_PARAMETER);
1069 Ecore_Wl2_Window *wlwin;
1070 struct wl_surface *surface;
1071 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
1075 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1077 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
1080 while (!_eflutil.wl.policy.proto)
1081 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1083 surface = ecore_wl2_window_surface_get(wlwin);
1084 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1085 EFL_UTIL_ERROR_INVALID_PARAMETER);
1087 scr_mode_info = eina_hash_find(_eflutil.wl.policy.hash_scr_mode, &surface);
1090 scr_mode_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Scr_Mode_Info));
1091 EINA_SAFETY_ON_NULL_RETURN_VAL(scr_mode_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
1093 scr_mode_info->surface = surface;
1094 scr_mode_info->mode = (unsigned int)mode;
1095 scr_mode_info->wait_for_done = EINA_TRUE;
1096 scr_mode_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
1098 eina_hash_add(_eflutil.wl.policy.hash_scr_mode,
1104 scr_mode_info->mode = (unsigned int)mode;
1105 scr_mode_info->wait_for_done = EINA_TRUE;
1106 scr_mode_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
1109 tizen_policy_set_window_screen_mode(_eflutil.wl.policy.proto,
1110 surface, (unsigned int)mode);
1111 if (scr_mode_info->wait_for_done)
1114 while (scr_mode_info->wait_for_done && (count < 3))
1116 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
1117 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1121 if (scr_mode_info->wait_for_done)
1123 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1127 if (scr_mode_info->state == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
1129 return EFL_UTIL_ERROR_PERMISSION_DENIED;
1134 return EFL_UTIL_ERROR_NONE;
1137 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1141 efl_util_get_window_screen_mode(Evas_Object *window,
1142 efl_util_screen_mode_e *mode)
1144 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1145 EINA_SAFETY_ON_NULL_RETURN_VAL(mode, EFL_UTIL_ERROR_INVALID_PARAMETER);
1147 Ecore_Wl2_Window *wlwin;
1148 struct wl_surface *surface;
1149 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
1153 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1155 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
1158 while (!_eflutil.wl.policy.proto)
1159 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1161 surface = ecore_wl2_window_surface_get(wlwin);
1162 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1163 EFL_UTIL_ERROR_INVALID_PARAMETER);
1165 scr_mode_info = eina_hash_find(_eflutil.wl.policy.hash_scr_mode, &surface);
1168 if (scr_mode_info->wait_for_done)
1170 while (scr_mode_info->wait_for_done)
1172 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
1173 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1177 switch (scr_mode_info->mode)
1179 case TIZEN_POLICY_MODE_DEFAULT: *mode = EFL_UTIL_SCREEN_MODE_DEFAULT; break;
1180 case TIZEN_POLICY_MODE_ALWAYS_ON: *mode = EFL_UTIL_SCREEN_MODE_ALWAYS_ON; break;
1181 default: *mode = EFL_UTIL_SCREEN_MODE_DEFAULT;
1182 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1184 return EFL_UTIL_ERROR_NONE;
1188 *mode = EFL_UTIL_SCREEN_MODE_DEFAULT;
1189 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1193 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1197 efl_util_set_window_screen_mode_error_cb(Evas_Object *window,
1198 efl_util_window_screen_mode_error_cb callback,
1201 /* Wearable device cannot use this. */
1202 if (get_tizen_profile() == TIZEN_PROFILE_WEARABLE)
1203 return EFL_UTIL_ERROR_NO_SUCH_DEVICE;
1205 dlog_print(DLOG_WARN, LOG_TAG,
1206 "DEPRECATION WARNING: efl_util_set_window_screen_mode_error_cb() is deprecated and will be removed from next release. Use the return value of efl_util_set_window_screen_mode() instead.");
1208 Eina_Bool ret = EINA_FALSE;
1210 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1211 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EFL_UTIL_ERROR_INVALID_PARAMETER);
1213 ret = _cb_info_add(window,
1214 (Efl_Util_Cb)callback,
1217 if (!ret) return EFL_UTIL_ERROR_OUT_OF_MEMORY;
1219 return EFL_UTIL_ERROR_NONE;
1223 efl_util_unset_window_screen_mode_error_cb(Evas_Object *window)
1225 /* Wearable device cannot use this. */
1226 if (get_tizen_profile() == TIZEN_PROFILE_WEARABLE)
1227 return EFL_UTIL_ERROR_NO_SUCH_DEVICE;
1229 dlog_print(DLOG_WARN, LOG_TAG,
1230 "DEPRECATION WARNING: efl_util_unset_window_screen_mode_error_cb() is deprecated and will be removed from next release. Use the return value of efl_util_set_window_screen_mode() instead.");
1232 Eina_Bool ret = EINA_FALSE;
1234 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1236 ret = _cb_info_del_by_win(window, CBH_SCR_MODE);
1237 if (!ret) return EFL_UTIL_ERROR_INVALID_PARAMETER;
1239 return EFL_UTIL_ERROR_NONE;
1243 efl_util_set_window_brightness(Evas_Object *window, int brightness)
1245 Ecore_Wl2_Window *wlwin;
1246 struct wl_surface *surface;
1247 Efl_Util_Wl_Surface_Brightness_Info *brightness_info;
1250 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1251 EINA_SAFETY_ON_FALSE_RETURN_VAL(brightness <= 100, EFL_UTIL_ERROR_INVALID_PARAMETER);
1254 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1256 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
1259 while (!_eflutil.wl.display_policy.proto)
1260 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1262 surface = ecore_wl2_window_surface_get(wlwin);
1263 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1264 EFL_UTIL_ERROR_INVALID_PARAMETER);
1266 brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
1267 if (!brightness_info)
1269 brightness_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Brightness_Info));
1270 EINA_SAFETY_ON_NULL_RETURN_VAL(brightness_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
1272 brightness_info->surface = surface;
1273 brightness_info->brightness = brightness;
1274 brightness_info->wait_for_done = EINA_TRUE;
1275 brightness_info->state = TIZEN_DISPLAY_POLICY_ERROR_STATE_NONE;
1277 eina_hash_add(_eflutil.wl.display_policy.hash_brightness,
1283 brightness_info->brightness = brightness;
1284 brightness_info->wait_for_done = EINA_TRUE;
1285 brightness_info->state = TIZEN_DISPLAY_POLICY_ERROR_STATE_NONE;
1288 tizen_display_policy_set_window_brightness(_eflutil.wl.display_policy.proto,
1289 surface, brightness);
1290 if (brightness_info->wait_for_done)
1293 while (brightness_info->wait_for_done && (count < 3))
1295 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
1296 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1300 if (brightness_info->wait_for_done)
1302 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1306 if (brightness_info->state == TIZEN_DISPLAY_POLICY_ERROR_STATE_PERMISSION_DENIED)
1308 return EFL_UTIL_ERROR_PERMISSION_DENIED;
1312 return EFL_UTIL_ERROR_NONE;
1315 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1319 efl_util_get_window_brightness(Evas_Object *window, int *brightness)
1321 Ecore_Wl2_Window *wlwin;
1322 struct wl_surface *surface;
1323 Efl_Util_Wl_Surface_Brightness_Info *brightness_info;
1326 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1327 EINA_SAFETY_ON_NULL_RETURN_VAL(brightness, EFL_UTIL_ERROR_INVALID_PARAMETER);
1330 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1332 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
1333 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
1335 while (!_eflutil.wl.display_policy.proto)
1336 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1338 surface = ecore_wl2_window_surface_get(wlwin);
1339 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1340 EFL_UTIL_ERROR_INVALID_PARAMETER);
1342 brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
1343 if (brightness_info)
1345 if (brightness_info->wait_for_done)
1347 while (brightness_info->wait_for_done)
1349 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
1350 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1353 *brightness = brightness_info->brightness;
1358 return EFL_UTIL_ERROR_NONE;
1362 struct _efl_util_inputgen_h
1364 unsigned int init_type;
1369 _cb_device_add(void *data EINA_UNUSED,
1370 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1371 uint32_t serial EINA_UNUSED,
1372 const char *identifier EINA_UNUSED,
1373 struct tizen_input_device *device EINA_UNUSED,
1374 struct wl_seat *seat EINA_UNUSED)
1379 /* LCOV_EXCL_START */
1381 _cb_device_remove(void *data EINA_UNUSED,
1382 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1383 uint32_t serial EINA_UNUSED,
1384 const char *identifier EINA_UNUSED,
1385 struct tizen_input_device *device EINA_UNUSED,
1386 struct wl_seat *seat EINA_UNUSED)
1390 /* LCOV_EXCL_STOP */
1393 _cb_error(void *data EINA_UNUSED,
1394 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1397 _eflutil.wl.devmgr.request_notified = errorcode;
1400 /* LCOV_EXCL_START */
1402 _cb_block_expired(void *data EINA_UNUSED,
1403 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED)
1407 /* LCOV_EXCL_STOP */
1409 static efl_util_error_e
1410 _efl_util_input_convert_input_generator_error(int ret)
1414 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE:
1415 return EFL_UTIL_ERROR_NONE;
1416 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NO_PERMISSION:
1417 return EFL_UTIL_ERROR_PERMISSION_DENIED;
1418 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NO_SYSTEM_RESOURCES:
1419 return EFL_UTIL_ERROR_OUT_OF_MEMORY;
1420 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_INVALID_PARAMETER:
1421 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1423 return EFL_UTIL_ERROR_NONE;
1427 API efl_util_inputgen_h
1428 efl_util_input_initialize_generator(unsigned int dev_type)
1430 int ret = EFL_UTIL_ERROR_NONE;
1431 efl_util_inputgen_h inputgen_h = NULL;
1432 unsigned int clas = 0x0;
1435 dev_type & ~(EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN
1436 | EFL_UTIL_INPUT_DEVTYPE_KEYBOARD
1437 | EFL_UTIL_INPUT_DEVTYPE_POINTER))
1439 set_last_result(EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1443 inputgen_h = (efl_util_inputgen_h)calloc(1, sizeof(struct _efl_util_inputgen_h));
1446 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
1450 inputgen_h->init_type |= dev_type;
1453 if (ret == (int)EINA_FALSE)
1455 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1459 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN)
1460 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
1461 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD)
1462 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD;
1463 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_POINTER)
1464 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE;
1466 while (!_eflutil.wl.devmgr.devicemgr)
1467 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1469 tizen_input_device_manager_init_generator(_eflutil.wl.devmgr.devicemgr, clas);
1471 while (_eflutil.wl.devmgr.request_notified == -1)
1472 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1474 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1475 _eflutil.wl.devmgr.request_notified = -1;
1477 set_last_result(ret);
1478 if (ret != TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE)
1492 API efl_util_inputgen_h
1493 efl_util_input_initialize_generator_with_name(unsigned int dev_type, const char *name)
1495 int ret = EFL_UTIL_ERROR_NONE;
1496 efl_util_inputgen_h inputgen_h = NULL;
1497 unsigned int clas = 0x0;
1500 dev_type & ~(EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN
1501 | EFL_UTIL_INPUT_DEVTYPE_KEYBOARD
1502 | EFL_UTIL_INPUT_DEVTYPE_POINTER))
1504 set_last_result(EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1508 inputgen_h = (efl_util_inputgen_h)calloc(1, sizeof(struct _efl_util_inputgen_h));
1511 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
1515 inputgen_h->init_type |= dev_type;
1516 strncpy(inputgen_h->name, name, 31);
1519 if (ret == (int)EINA_FALSE)
1521 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1525 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN)
1526 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
1527 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD)
1528 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD;
1529 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_POINTER)
1530 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE;
1532 while (!_eflutil.wl.devmgr.devicemgr)
1533 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1535 tizen_input_device_manager_init_generator_with_name(_eflutil.wl.devmgr.devicemgr, clas, inputgen_h->name);
1537 while (_eflutil.wl.devmgr.request_notified == -1)
1538 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1540 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1541 _eflutil.wl.devmgr.request_notified = -1;
1543 set_last_result(ret);
1544 if (ret != TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE)
1560 efl_util_input_deinitialize_generator(efl_util_inputgen_h inputgen_h)
1562 int ret = EFL_UTIL_ERROR_NONE;
1563 unsigned int clas = 0x0;
1564 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1566 if (inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN)
1567 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
1568 if (inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD)
1569 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD;
1570 if (inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_POINTER)
1571 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE;
1576 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1578 tizen_input_device_manager_deinit_generator(_eflutil.wl.devmgr.devicemgr, clas);
1580 while (_eflutil.wl.devmgr.request_notified == -1)
1581 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1583 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1584 _eflutil.wl.devmgr.request_notified = -1;
1590 efl_util_input_generate_key(efl_util_inputgen_h inputgen_h, const char *key_name, int pressed)
1592 int ret = EFL_UTIL_ERROR_NONE;
1594 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1595 EINA_SAFETY_ON_NULL_RETURN_VAL(key_name, EFL_UTIL_ERROR_INVALID_PARAMETER);
1596 EINA_SAFETY_ON_FALSE_RETURN_VAL(pressed == 0 || pressed == 1, EFL_UTIL_ERROR_INVALID_PARAMETER);
1597 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1599 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1601 tizen_input_device_manager_generate_key(_eflutil.wl.devmgr.devicemgr, key_name, pressed);
1603 while (_eflutil.wl.devmgr.request_notified == -1)
1604 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1606 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1607 _eflutil.wl.devmgr.request_notified = -1;
1613 efl_util_input_generate_touch(efl_util_inputgen_h inputgen_h, int idx,
1614 efl_util_input_touch_type_e touch_type, int x, int y)
1617 enum tizen_input_device_manager_pointer_event_type type;
1619 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1620 EINA_SAFETY_ON_FALSE_RETURN_VAL(idx >= 0, EFL_UTIL_ERROR_INVALID_PARAMETER);
1621 EINA_SAFETY_ON_FALSE_RETURN_VAL((x > 0 && y > 0), EFL_UTIL_ERROR_INVALID_PARAMETER);
1622 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1624 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1628 case EFL_UTIL_INPUT_TOUCH_BEGIN:
1629 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_BEGIN;
1631 case EFL_UTIL_INPUT_TOUCH_UPDATE:
1632 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_UPDATE;
1634 case EFL_UTIL_INPUT_TOUCH_END:
1635 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_END;
1638 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1641 tizen_input_device_manager_generate_touch(_eflutil.wl.devmgr.devicemgr, type, x, y, idx);
1643 while (_eflutil.wl.devmgr.request_notified == -1)
1644 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1646 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1647 _eflutil.wl.devmgr.request_notified = -1;
1653 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)
1656 enum tizen_input_device_manager_pointer_event_type type;
1658 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1659 EINA_SAFETY_ON_FALSE_RETURN_VAL(buttons > 0, EFL_UTIL_ERROR_INVALID_PARAMETER);
1660 EINA_SAFETY_ON_FALSE_RETURN_VAL((x >= 0 && y >= 0), EFL_UTIL_ERROR_INVALID_PARAMETER);
1661 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_POINTER, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1663 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1665 switch(pointer_type)
1667 case EFL_UTIL_INPUT_POINTER_BUTTON_DOWN:
1668 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_BEGIN;
1670 case EFL_UTIL_INPUT_POINTER_MOVE:
1671 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_UPDATE;
1673 case EFL_UTIL_INPUT_POINTER_BUTTON_UP:
1674 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_END;
1677 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1680 tizen_input_device_manager_generate_pointer(_eflutil.wl.devmgr.devicemgr, type, x, y, buttons);
1682 while (_eflutil.wl.devmgr.request_notified == -1)
1683 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1685 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1686 _eflutil.wl.devmgr.request_notified = -1;
1692 struct _efl_util_screenshot_h
1697 Eina_Bool shot_done;
1702 Eina_Bool auto_rotation;
1705 /* scrrenshot handle */
1706 static efl_util_screenshot_h g_screenshot;
1707 static Eina_Bool shot_mutex_init;
1708 static pthread_mutex_t shot_lock;
1711 _screenshot_mutex_init(void)
1713 if (shot_mutex_init)
1716 if (pthread_mutex_init(&shot_lock, NULL))
1718 fprintf(stderr, "[screenshot] fail: mutex init"); /*LCOV_EXCL_LINE*/
1719 return EINA_FALSE; /*LCOV_EXCL_LINE*/
1722 shot_mutex_init = EINA_TRUE;
1728 _screenshot_mutex_destory(void)
1730 if (!shot_mutex_init)
1733 if (pthread_mutex_destroy(&shot_lock))
1735 fprintf(stderr, "[screenshot] fail: mutex destory"); /*LCOV_EXCL_LINE*/
1736 return EINA_FALSE; /*LCOV_EXCL_LINE*/
1739 shot_mutex_init = EINA_FALSE;
1745 _screenshot_mutex_lock(void)
1747 if (!_screenshot_mutex_init())
1750 pthread_mutex_lock(&shot_lock);
1754 _screenshot_mutex_unlock(void)
1756 pthread_mutex_unlock(&shot_lock);
1759 API efl_util_screenshot_h
1760 efl_util_screenshot_initialize(int width, int height)
1762 efl_util_screenshot_h screenshot = NULL;
1763 struct wl_display *display_wrapper = NULL;
1764 struct wl_registry *reg = NULL;
1767 EINA_SAFETY_ON_FALSE_GOTO(width > 0, fail_param);
1768 EINA_SAFETY_ON_FALSE_GOTO(height > 0, fail_param);
1770 _screenshot_mutex_lock();
1772 if (!_eflutil.wl.shot.screenshooter)
1775 if (ret == (int)EINA_FALSE)
1777 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1778 _screenshot_mutex_unlock();
1781 wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1783 display_wrapper = wl_proxy_create_wrapper(_eflutil.wl.dpy);
1784 EINA_SAFETY_ON_NULL_GOTO(display_wrapper, fail_memory);
1786 _eflutil.wl.shot.queue = wl_display_create_queue(_eflutil.wl.dpy);
1787 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.queue, fail_memory);
1789 wl_proxy_set_queue((struct wl_proxy *)display_wrapper, _eflutil.wl.shot.queue);
1791 reg = wl_display_get_registry(display_wrapper);
1792 wl_proxy_wrapper_destroy(display_wrapper);
1793 display_wrapper = NULL;
1794 EINA_SAFETY_ON_NULL_GOTO(reg, fail_init);
1796 wl_registry_add_listener(reg, &_wl_reg_screenshooter_listener, NULL);
1798 ret = wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
1799 EINA_SAFETY_ON_TRUE_GOTO(ret == -1, fail_init);
1800 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.screenshooter, fail_init);
1801 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.tz_screenshooter, fail_init);
1803 _eflutil.wl.shot.tbm_client = wayland_tbm_client_init(_eflutil.wl.dpy);
1804 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.tbm_client, fail_init);
1807 if (_eflutil.wl.shot.noti == 0)
1809 fprintf(stderr, "[screenshot] fail: privilege error\n"); /* LCOV_EXCL_LINE */
1815 if (g_screenshot->width != width || g_screenshot->height != height)
1817 g_screenshot->width = width;
1818 g_screenshot->height = height;
1821 _screenshot_mutex_unlock();
1823 return g_screenshot;
1826 screenshot = calloc(1, sizeof(struct _efl_util_screenshot_h));
1827 EINA_SAFETY_ON_NULL_GOTO(screenshot, fail_memory);
1829 screenshot->width = width;
1830 screenshot->height = height;
1831 screenshot->auto_rotation = EINA_TRUE;
1833 screenshot->bufmgr = wayland_tbm_client_get_bufmgr(_eflutil.wl.shot.tbm_client);
1834 EINA_SAFETY_ON_NULL_GOTO(screenshot->bufmgr, fail_init);
1836 g_screenshot = screenshot;
1837 set_last_result(EFL_UTIL_ERROR_NONE);
1839 screenshooter_set_user_data(_eflutil.wl.shot.screenshooter, &screenshot->shot_done);
1841 _screenshot_mutex_unlock();
1843 return g_screenshot;
1846 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1849 /* LCOV_EXCL_START */
1850 if (display_wrapper)
1851 wl_proxy_wrapper_destroy(display_wrapper);
1852 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
1856 efl_util_screenshot_deinitialize(screenshot);
1857 _screenshot_mutex_unlock();
1858 set_last_result(EFL_UTIL_ERROR_SCREENSHOT_INIT_FAIL);
1860 /* LCOV_EXCL_STOP */
1864 efl_util_screenshot_deinitialize(efl_util_screenshot_h screenshot)
1866 _screenshot_mutex_lock();
1870 _screenshot_mutex_unlock();
1871 _screenshot_mutex_destory();
1872 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1876 g_screenshot = NULL;
1878 if (_eflutil.wl.shot.queue)
1880 wl_event_queue_destroy(_eflutil.wl.shot.queue);
1881 _eflutil.wl.shot.queue = NULL;
1884 if (_eflutil.wl.shot.screenshooter)
1886 screenshooter_destroy(_eflutil.wl.shot.screenshooter);
1887 _eflutil.wl.shot.screenshooter = NULL;
1889 if (_eflutil.wl.shot.tz_screenshooter)
1891 tizen_screenshooter_destroy(_eflutil.wl.shot.tz_screenshooter);
1892 _eflutil.wl.shot.tz_screenshooter = NULL;
1895 _screenshot_mutex_unlock();
1896 _screenshot_mutex_destory();
1898 return EFL_UTIL_ERROR_NONE;
1903 efl_util_screenshot_take_tbm_surface(efl_util_screenshot_h screenshot)
1905 tbm_surface_h t_surface = NULL;
1906 struct wl_buffer *buffer = NULL;
1907 Efl_Util_Wl_Output_Info *output;
1910 _screenshot_mutex_lock();
1912 if (!screenshot || (screenshot != g_screenshot))
1914 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1915 _screenshot_mutex_unlock();
1919 output = eina_list_nth(_eflutil.wl.shot.output_list, 0);
1922 fprintf(stderr, "[screenshot] fail: no output for screenshot\n"); /* LCOV_EXCL_LINE */
1926 t_surface = tbm_surface_create(screenshot->width, screenshot->height, TBM_FORMAT_XRGB8888);
1929 fprintf(stderr, "[screenshot] fail: tbm_surface_create\n"); /* LCOV_EXCL_LINE */
1933 buffer = wayland_tbm_client_create_buffer(_eflutil.wl.shot.tbm_client, t_surface);
1936 fprintf(stderr, "[screenshot] fail: create wl_buffer for screenshot\n"); /* LCOV_EXCL_LINE */
1940 screenshooter_shoot(_eflutil.wl.shot.screenshooter, output->output, buffer);
1942 screenshot->shot_done = EINA_FALSE;
1943 while (!screenshot->shot_done && ret != -1)
1944 ret = wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
1948 fprintf(stderr, "[screenshot] fail: screenshooter_shoot\n"); /* LCOV_EXCL_LINE */
1952 wl_buffer_destroy(buffer);
1954 /* reset shot_done for next screenshot */
1955 screenshot->shot_done = EINA_FALSE;
1957 set_last_result(EFL_UTIL_ERROR_NONE);
1959 _screenshot_mutex_unlock();
1965 tbm_surface_destroy(t_surface);
1967 wl_buffer_destroy(buffer);
1969 set_last_result(EFL_UTIL_ERROR_SCREENSHOT_EXECUTION_FAIL);
1971 _screenshot_mutex_unlock();
1976 /* LCOV_EXCL_START */
1978 efl_util_screenshot_set_auto_rotation(efl_util_screenshot_h screenshot, int set)
1980 if (!screenshot || (screenshot != g_screenshot))
1981 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1983 if (!(set == 0 || set == 1))
1984 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1987 g_screenshot->auto_rotation = EINA_TRUE;
1989 g_screenshot->auto_rotation = EINA_FALSE;
1991 tizen_screenshooter_set_oneshot_auto_rotation(_eflutil.wl.shot.tz_screenshooter, g_screenshot->auto_rotation);
1993 return EFL_UTIL_ERROR_NONE;
1997 efl_util_screenshot_get_auto_rotation(efl_util_screenshot_h screenshot, int *set)
1999 if (!screenshot || (screenshot != g_screenshot) || !set)
2000 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2002 *set = g_screenshot->auto_rotation;
2004 return EFL_UTIL_ERROR_NONE;
2006 /* LCOV_EXCL_STOP */
2008 struct _efl_util_gesture_h
2013 API int EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = 0;
2014 API int EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = 0;
2015 API int EFL_UTIL_EVENT_GESTURE_TAP = 0;
2016 API int EFL_UTIL_EVENT_GESTURE_PALM_COVER = 0;
2018 /* LCOV_EXCL_START */
2020 _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)
2022 _eflutil.wl.gesture.request_notified = error;
2026 _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)
2028 efl_util_event_gesture_edge_swipe_s *ev = NULL;
2030 ev = (efl_util_event_gesture_edge_swipe_s *)calloc(1, sizeof(*ev));
2035 ev->fingers = fingers;
2040 ecore_event_add(EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE, ev, NULL, NULL);
2044 _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)
2046 _eflutil.wl.gesture.request_notified = error;
2050 _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)
2052 efl_util_event_gesture_edge_drag_s *ev = NULL;
2054 ev = (efl_util_event_gesture_edge_drag_s *)calloc(1, sizeof(*ev));
2059 ev->fingers = fingers;
2064 ecore_event_add(EFL_UTIL_EVENT_GESTURE_EDGE_DRAG, ev, NULL, NULL);
2068 _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)
2070 _eflutil.wl.gesture.request_notified = error;
2074 _cb_gesture_tap(void *data EINA_UNUSED, struct tizen_gesture *tizen_gesture EINA_UNUSED, uint32_t mode, uint32_t fingers, uint32_t repeats)
2076 efl_util_event_gesture_tap_s *ev = NULL;
2078 ev = (efl_util_event_gesture_tap_s *)calloc(1, sizeof(*ev));
2083 ev->fingers = fingers;
2084 ev->repeats = repeats;
2086 ecore_event_add(EFL_UTIL_EVENT_GESTURE_TAP, ev, NULL, NULL);
2088 /* LCOV_EXCL_STOP */
2091 _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)
2093 _eflutil.wl.gesture.request_notified = error;
2096 /* LCOV_EXCL_START */
2098 _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)
2100 efl_util_event_gesture_palm_cover_s *ev = NULL;
2102 ev = (efl_util_event_gesture_palm_cover_s *)calloc(1, sizeof(*ev));
2107 ev->duration = duration;
2111 ev->pressure = wl_fixed_to_int(pressure);
2113 ecore_event_add(EFL_UTIL_EVENT_GESTURE_PALM_COVER, ev, NULL, NULL);
2115 /* LCOV_EXCL_STOP */
2118 _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)
2120 _eflutil.wl.gesture.request_notified = error;
2123 static efl_util_error_e
2124 _efl_util_gesture_convert_error(int ret)
2128 case TIZEN_GESTURE_ERROR_NONE:
2129 return EFL_UTIL_ERROR_NONE;
2130 case TIZEN_GESTURE_ERROR_INVALID_DATA:
2131 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2132 case TIZEN_GESTURE_ERROR_NO_PERMISSION:
2133 return EFL_UTIL_ERROR_PERMISSION_DENIED;
2134 case TIZEN_GESTURE_ERROR_NO_SYSTEM_RESOURCES:
2135 return EFL_UTIL_ERROR_OUT_OF_MEMORY;
2136 case TIZEN_GESTURE_ERROR_GRABBED_ALREADY:
2137 return EFL_UTIL_ERROR_NO_RESOURCE_AVAILABLE;
2138 case TIZEN_GESTURE_ERROR_NOT_SUPPORTED:
2139 return EFL_UTIL_ERROR_NOT_SUPPORTED;
2141 return EFL_UTIL_ERROR_NONE;
2145 /* LCOV_EXCL_START */
2147 _efl_util_gesture_grab_edge_swipe(efl_util_gesture_data data)
2149 int ret = EFL_UTIL_ERROR_NONE;
2150 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2151 Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = NULL;
2152 unsigned int fingers = 0;
2153 unsigned int edge = 0;
2154 unsigned int edge_size = 0;
2155 unsigned int start_point = 0;
2156 unsigned int end_point = 0;
2158 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2160 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2161 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2162 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_SWIPE,
2163 EFL_UTIL_ERROR_INVALID_PARAMETER);
2165 edge_swipe_data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)data;
2167 fingers = edge_swipe_data->fingers;
2168 edge = edge_swipe_data->edge;
2169 edge_size = edge_swipe_data->edge_size;
2170 start_point = edge_swipe_data->start_point;
2171 end_point = edge_swipe_data->end_point;
2173 tizen_gesture_grab_edge_swipe(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2175 while (_eflutil.wl.gesture.request_notified == -1)
2176 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2178 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2179 _eflutil.wl.gesture.request_notified = -1;
2185 _efl_util_gesture_ungrab_edge_swipe(efl_util_gesture_data data)
2187 int ret = EFL_UTIL_ERROR_NONE;
2188 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2189 Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = NULL;
2190 unsigned int fingers = 0;
2191 unsigned int edge = 0;
2192 unsigned int edge_size = 0;
2193 unsigned int start_point = 0;
2194 unsigned int end_point = 0;
2196 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2198 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2199 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2200 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_SWIPE,
2201 EFL_UTIL_ERROR_INVALID_PARAMETER);
2203 edge_swipe_data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)data;
2205 fingers = edge_swipe_data->fingers;
2206 edge = edge_swipe_data->edge;
2207 edge_size = edge_swipe_data->edge_size;
2208 start_point = edge_swipe_data->start_point;
2209 end_point = edge_swipe_data->end_point;
2211 tizen_gesture_ungrab_edge_swipe(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2213 while (_eflutil.wl.gesture.request_notified == -1)
2214 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2216 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2217 _eflutil.wl.gesture.request_notified = -1;
2223 _efl_util_gesture_grab_edge_drag(efl_util_gesture_data data)
2225 int ret = EFL_UTIL_ERROR_NONE;
2226 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2227 Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = NULL;
2228 unsigned int fingers = 0;
2229 unsigned int edge = 0;
2230 unsigned int edge_size = 0;
2231 unsigned int start_point = 0;
2232 unsigned int end_point = 0;
2234 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2236 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2237 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2238 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_DRAG,
2239 EFL_UTIL_ERROR_INVALID_PARAMETER);
2241 edge_drag_data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)data;
2243 fingers = edge_drag_data->fingers;
2244 edge = edge_drag_data->edge;
2245 edge_size = edge_drag_data->edge_size;
2246 start_point = edge_drag_data->start_point;
2247 end_point = edge_drag_data->end_point;
2249 tizen_gesture_grab_edge_drag(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2251 while (_eflutil.wl.gesture.request_notified == -1)
2252 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2254 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2255 _eflutil.wl.gesture.request_notified = -1;
2261 _efl_util_gesture_ungrab_edge_drag(efl_util_gesture_data data)
2263 int ret = EFL_UTIL_ERROR_NONE;
2264 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2265 Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = NULL;
2266 unsigned int fingers = 0;
2267 unsigned int edge = 0;
2268 unsigned int edge_size = 0;
2269 unsigned int start_point = 0;
2270 unsigned int end_point = 0;
2272 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2274 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2275 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2276 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_DRAG,
2277 EFL_UTIL_ERROR_INVALID_PARAMETER);
2279 edge_drag_data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)data;
2281 fingers = edge_drag_data->fingers;
2282 edge = edge_drag_data->edge;
2283 edge_size = edge_drag_data->edge_size;
2284 start_point = edge_drag_data->start_point;
2285 end_point = edge_drag_data->end_point;
2287 tizen_gesture_ungrab_edge_drag(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2289 while (_eflutil.wl.gesture.request_notified == -1)
2290 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2292 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2293 _eflutil.wl.gesture.request_notified = -1;
2300 _efl_util_gesture_grab_tap(efl_util_gesture_data data)
2302 int ret = EFL_UTIL_ERROR_NONE;
2303 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2304 Efl_Util_Gesture_Tap_Grab_Data *tap_data = NULL;
2305 unsigned int fingers = 0;
2306 unsigned int repeats = 0;
2308 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2310 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2311 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2312 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_TAP,
2313 EFL_UTIL_ERROR_INVALID_PARAMETER);
2315 tap_data = (Efl_Util_Gesture_Tap_Grab_Data *)data;
2317 fingers = tap_data->fingers;
2318 repeats = tap_data->repeats;
2320 tizen_gesture_grab_tap(_eflutil.wl.gesture.proto, fingers, repeats);
2322 while (_eflutil.wl.gesture.request_notified == -1)
2323 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2325 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2326 _eflutil.wl.gesture.request_notified = -1;
2332 _efl_util_gesture_ungrab_tap(efl_util_gesture_data data)
2334 int ret = EFL_UTIL_ERROR_NONE;
2335 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2336 Efl_Util_Gesture_Tap_Grab_Data *tap_data = NULL;
2337 unsigned int fingers = 0;
2338 unsigned int repeats = 0;
2340 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2342 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2343 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2344 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_TAP,
2345 EFL_UTIL_ERROR_INVALID_PARAMETER);
2347 tap_data = (Efl_Util_Gesture_Tap_Grab_Data *)data;
2349 fingers = tap_data->fingers;
2350 repeats = tap_data->repeats;
2352 tizen_gesture_ungrab_tap(_eflutil.wl.gesture.proto, fingers, repeats);
2354 while (_eflutil.wl.gesture.request_notified == -1)
2355 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2357 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2358 _eflutil.wl.gesture.request_notified = -1;
2364 _efl_util_gesture_grab_palm_cover(efl_util_gesture_data data)
2366 int ret = EFL_UTIL_ERROR_NONE;
2367 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2369 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2371 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2372 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2373 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_PALM_COVER,
2374 EFL_UTIL_ERROR_INVALID_PARAMETER);
2376 tizen_gesture_grab_palm_cover(_eflutil.wl.gesture.proto);
2378 while (_eflutil.wl.gesture.request_notified == -1)
2379 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2381 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2382 _eflutil.wl.gesture.request_notified = -1;
2388 _efl_util_gesture_ungrab_palm_cover(efl_util_gesture_data data)
2390 int ret = EFL_UTIL_ERROR_NONE;
2391 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2393 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2395 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2396 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2397 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_PALM_COVER,
2398 EFL_UTIL_ERROR_INVALID_PARAMETER);
2400 tizen_gesture_ungrab_palm_cover(_eflutil.wl.gesture.proto);
2402 while (_eflutil.wl.gesture.request_notified == -1)
2403 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2405 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2406 _eflutil.wl.gesture.request_notified = -1;
2412 _efl_util_fd_cb(void *data, Ecore_Fd_Handler *hdl)
2414 if (_eflutil.wl.dpy && _eflutil.wl.queue)
2416 wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2417 return ECORE_CALLBACK_RENEW;
2421 return ECORE_CALLBACK_CANCEL;
2424 /* LCOV_EXCL_STOP */
2426 API efl_util_gesture_h
2427 efl_util_gesture_initialize(void)
2429 efl_util_gesture_h gesture_h = NULL;
2432 gesture_h = (efl_util_gesture_h)calloc(1, sizeof(struct _efl_util_gesture_h));
2435 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2436 goto out; /* LCOV_EXCL_LINE */
2439 if (_wl_init() == (int)EINA_FALSE)
2441 set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED); /* LCOV_EXCL_LINE */
2442 goto out; /* LCOV_EXCL_LINE */
2445 while (!_eflutil.wl.gesture.proto)
2446 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue); /* LCOV_EXCL_LINE */
2448 if (_eflutil.wl.gesture.event_init <= 0)
2450 if (ecore_event_init() <= 0)
2452 set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED); /* LCOV_EXCL_LINE */
2453 goto out; /* LCOV_EXCL_LINE */
2455 EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = ecore_event_type_new();
2456 EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = ecore_event_type_new();
2457 EFL_UTIL_EVENT_GESTURE_TAP = ecore_event_type_new();
2458 EFL_UTIL_EVENT_GESTURE_PALM_COVER = ecore_event_type_new();
2460 dpy_fd = wl_display_get_fd(_eflutil.wl.dpy);
2461 _eflutil.wl.dpy_fd = fcntl(dpy_fd, F_DUPFD_CLOEXEC, 0);
2462 if (_eflutil.wl.dpy_fd >= 0)
2463 _eflutil.wl.fd_hdl = ecore_main_fd_handler_add(_eflutil.wl.dpy_fd,
2464 ECORE_FD_READ | ECORE_FD_WRITE | ECORE_FD_ERROR,
2465 _efl_util_fd_cb, NULL,
2468 _eflutil.wl.gesture.event_init++;
2469 gesture_h->init = EINA_TRUE;
2471 set_last_result(EFL_UTIL_ERROR_NONE);
2475 /* LCOV_EXCL_START */
2482 /* LCOV_EXCL_STOP */
2486 efl_util_gesture_deinitialize(efl_util_gesture_h gesture_h)
2488 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2489 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2494 _eflutil.wl.gesture.event_init--;
2496 if (_eflutil.wl.gesture.event_init <= 0)
2498 _eflutil.wl.gesture.event_init = 0;
2499 ecore_event_shutdown();
2500 EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = 0;
2501 EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = 0;
2502 EFL_UTIL_EVENT_GESTURE_TAP = 0;
2503 EFL_UTIL_EVENT_GESTURE_PALM_COVER = 0;
2504 if (_eflutil.wl.dpy_fd >= 0)
2506 ecore_main_fd_handler_del(_eflutil.wl.fd_hdl);
2507 _eflutil.wl.fd_hdl = NULL;
2508 close(_eflutil.wl.dpy_fd);
2509 _eflutil.wl.dpy_fd = -1;
2513 return EFL_UTIL_ERROR_NONE;
2516 API efl_util_gesture_data
2517 efl_util_gesture_edge_swipe_new(efl_util_gesture_h gesture_h, unsigned int fingers, efl_util_gesture_edge_e edge)
2519 Efl_Util_Gesture_Edge_Swipe_Grab_Data *data;
2521 if (!gesture_h || gesture_h->init == EINA_FALSE)
2523 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2527 if (edge <= EFL_UTIL_GESTURE_EDGE_NONE || edge > EFL_UTIL_GESTURE_EDGE_LEFT)
2529 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2533 data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Edge_Swipe_Grab_Data));
2536 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2537 return NULL; /* LCOV_EXCL_LINE */
2540 data->base.type = TIZEN_GESTURE_TYPE_EDGE_SWIPE;
2541 data->fingers = fingers;
2543 data->edge_size = EFL_UTIL_GESTURE_EDGE_SIZE_FULL;
2545 set_last_result(EFL_UTIL_ERROR_NONE);
2547 return (void *)data;
2551 efl_util_gesture_edge_swipe_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2553 if (!gesture_h || gesture_h->init == EINA_FALSE)
2555 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2560 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2566 return EFL_UTIL_ERROR_NONE;
2570 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)
2572 Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = data;
2574 EINA_SAFETY_ON_NULL_RETURN_VAL(edge_swipe_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2575 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_swipe_data->base.type == TIZEN_GESTURE_TYPE_EDGE_SWIPE,
2576 EFL_UTIL_ERROR_INVALID_PARAMETER);
2577 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_size == EFL_UTIL_GESTURE_EDGE_SIZE_PARTIAL,
2578 EFL_UTIL_ERROR_INVALID_PARAMETER);
2579 EINA_SAFETY_ON_FALSE_RETURN_VAL(end_point > start_point, EFL_UTIL_ERROR_INVALID_PARAMETER);
2581 edge_swipe_data->edge_size = edge_size;
2582 edge_swipe_data->start_point = start_point;
2583 edge_swipe_data->end_point = end_point;
2585 return EFL_UTIL_ERROR_NONE;
2588 API efl_util_gesture_data
2589 efl_util_gesture_edge_drag_new(efl_util_gesture_h gesture_h, unsigned int fingers, efl_util_gesture_edge_e edge)
2591 Efl_Util_Gesture_Edge_Drag_Grab_Data *data;
2593 if (!gesture_h || gesture_h->init == EINA_FALSE)
2595 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2599 if (edge <= EFL_UTIL_GESTURE_EDGE_NONE || edge > EFL_UTIL_GESTURE_EDGE_LEFT)
2601 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2605 data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Edge_Drag_Grab_Data));
2608 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2609 return NULL; /* LCOV_EXCL_LINE */
2612 data->base.type = TIZEN_GESTURE_TYPE_EDGE_DRAG;
2613 data->fingers = fingers;
2615 data->edge_size = EFL_UTIL_GESTURE_EDGE_SIZE_FULL;
2617 set_last_result(EFL_UTIL_ERROR_NONE);
2619 return (void *)data;
2623 efl_util_gesture_edge_drag_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2625 if (!gesture_h || gesture_h->init == EINA_FALSE)
2627 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2632 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2638 return EFL_UTIL_ERROR_NONE;
2642 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)
2644 Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = data;
2646 EINA_SAFETY_ON_NULL_RETURN_VAL(edge_drag_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2647 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_drag_data->base.type == TIZEN_GESTURE_TYPE_EDGE_DRAG,
2648 EFL_UTIL_ERROR_INVALID_PARAMETER);
2649 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_size == EFL_UTIL_GESTURE_EDGE_SIZE_PARTIAL,
2650 EFL_UTIL_ERROR_INVALID_PARAMETER);
2651 EINA_SAFETY_ON_FALSE_RETURN_VAL(end_point > start_point, EFL_UTIL_ERROR_INVALID_PARAMETER);
2653 edge_drag_data->edge_size = edge_size;
2654 edge_drag_data->start_point = start_point;
2655 edge_drag_data->end_point = end_point;
2657 return EFL_UTIL_ERROR_NONE;
2660 API efl_util_gesture_data
2661 efl_util_gesture_tap_new(efl_util_gesture_h gesture_h, unsigned int fingers, unsigned int repeats)
2663 Efl_Util_Gesture_Tap_Grab_Data *data;
2665 if (!gesture_h || gesture_h->init == EINA_FALSE)
2667 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2671 if (fingers <= 1 || repeats <= 1)
2673 set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED);
2677 data = (Efl_Util_Gesture_Tap_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Tap_Grab_Data));
2680 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2681 return NULL; /* LCOV_EXCL_LINE */
2684 data->base.type = TIZEN_GESTURE_TYPE_TAP;
2685 data->fingers = fingers;
2686 data->repeats = repeats;
2688 set_last_result(EFL_UTIL_ERROR_NONE);
2690 return (void *)data;
2694 efl_util_gesture_tap_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2696 if (!gesture_h || gesture_h->init == EINA_FALSE)
2698 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2703 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2709 return EFL_UTIL_ERROR_NONE;
2712 API efl_util_gesture_data
2713 efl_util_gesture_palm_cover_new(efl_util_gesture_h gesture_h)
2715 Efl_Util_Gesture_Palm_Cover_Grab_Data *data;
2717 if (!gesture_h || gesture_h->init == EINA_FALSE)
2719 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2723 data = (Efl_Util_Gesture_Palm_Cover_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Palm_Cover_Grab_Data));
2726 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2727 return NULL; /* LCOV_EXCL_LINE */
2730 data->base.type = TIZEN_GESTURE_TYPE_PALM_COVER;
2732 set_last_result(EFL_UTIL_ERROR_NONE);
2734 return (void *)data;
2738 efl_util_gesture_palm_cover_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2740 if (!gesture_h || gesture_h->init == EINA_FALSE)
2742 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2747 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2753 return EFL_UTIL_ERROR_NONE;
2756 /* LCOV_EXCL_START */
2758 efl_util_gesture_grab(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2760 int ret = EFL_UTIL_ERROR_NONE;
2761 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2763 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2765 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2766 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2767 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2769 switch (base_data->type)
2771 case TIZEN_GESTURE_TYPE_EDGE_SWIPE:
2772 ret = _efl_util_gesture_grab_edge_swipe(data);
2774 case TIZEN_GESTURE_TYPE_EDGE_DRAG:
2775 ret = _efl_util_gesture_grab_edge_drag(data);
2777 case TIZEN_GESTURE_TYPE_TAP:
2778 ret = _efl_util_gesture_grab_tap(data);
2780 case TIZEN_GESTURE_TYPE_PALM_COVER:
2781 ret = _efl_util_gesture_grab_palm_cover(data);
2784 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2791 efl_util_gesture_ungrab(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2793 int ret = EFL_UTIL_ERROR_NONE;
2794 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2796 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2798 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2799 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2800 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2802 switch (base_data->type)
2804 case TIZEN_GESTURE_TYPE_EDGE_SWIPE:
2805 ret = _efl_util_gesture_ungrab_edge_swipe(data);
2807 case TIZEN_GESTURE_TYPE_EDGE_DRAG:
2808 ret = _efl_util_gesture_ungrab_edge_drag(data);
2810 case TIZEN_GESTURE_TYPE_TAP:
2811 ret = _efl_util_gesture_ungrab_tap(data);
2813 case TIZEN_GESTURE_TYPE_PALM_COVER:
2814 ret = _efl_util_gesture_ungrab_palm_cover(data);
2817 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2822 /* LCOV_EXCL_STOP */
2825 efl_util_gesture_select(efl_util_gesture_h gesture_h, Evas_Object *window, efl_util_gesture_data data)
2827 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2828 Ecore_Wl2_Window *wlwin;
2829 struct wl_surface *surface;
2832 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2834 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2835 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2836 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
2837 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2839 if (base_data->type != TIZEN_GESTURE_TYPE_PALM_COVER)
2840 return EFL_UTIL_ERROR_NOT_SUPPORTED;
2842 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
2843 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
2845 surface = ecore_wl2_window_surface_get(wlwin);
2846 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
2847 EFL_UTIL_ERROR_INVALID_PARAMETER);
2849 tizen_gesture_select_palm_cover(_eflutil.wl.gesture.proto, surface);
2851 while (_eflutil.wl.gesture.request_notified == -1)
2852 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2854 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2855 _eflutil.wl.gesture.request_notified = -1;
2861 efl_util_gesture_deselect(efl_util_gesture_h gesture_h, Evas_Object *window, efl_util_gesture_data data)
2863 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2864 Ecore_Wl2_Window *wlwin;
2865 struct wl_surface *surface;
2868 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2870 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2871 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2872 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
2873 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2875 if (base_data->type != TIZEN_GESTURE_TYPE_PALM_COVER)
2876 return EFL_UTIL_ERROR_NOT_SUPPORTED;
2878 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
2879 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
2881 surface = ecore_wl2_window_surface_get(wlwin);
2882 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
2883 EFL_UTIL_ERROR_INVALID_PARAMETER);
2885 tizen_gesture_deselect_palm_cover(_eflutil.wl.gesture.proto, surface);
2887 while (_eflutil.wl.gesture.request_notified == -1)
2888 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2890 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2891 _eflutil.wl.gesture.request_notified = -1;
2896 /* LCOV_EXCL_START */
2898 efl_util_gesture_activate_set(efl_util_gesture_h gesture_h, unsigned int type, Eina_Bool active)
2902 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2903 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2904 EINA_SAFETY_ON_TRUE_RETURN_VAL(type == EFL_UTIL_GESTURE_TYPE_NONE, EFL_UTIL_ERROR_INVALID_PARAMETER);
2906 tizen_gesture_activate_set(_eflutil.wl.gesture.proto, NULL, type, active);
2908 while (_eflutil.wl.gesture.request_notified == -1)
2909 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2911 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2912 _eflutil.wl.gesture.request_notified = -1;
2916 /* LCOV_EXCL_STOP */
2919 efl_util_gesture_activate_set_on_window(efl_util_gesture_h gesture_h, Evas_Object *window, unsigned int type, Eina_Bool active)
2921 Ecore_Wl2_Window *wlwin;
2922 struct wl_surface *surface;
2925 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2926 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2927 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
2928 EINA_SAFETY_ON_TRUE_RETURN_VAL(type == EFL_UTIL_GESTURE_TYPE_NONE, EFL_UTIL_ERROR_INVALID_PARAMETER);
2930 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
2931 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
2933 surface = ecore_wl2_window_surface_get(wlwin);
2934 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
2935 EFL_UTIL_ERROR_INVALID_PARAMETER);
2937 tizen_gesture_activate_set(_eflutil.wl.gesture.proto, surface, type, active);
2939 while (_eflutil.wl.gesture.request_notified == -1)
2940 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2942 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2943 _eflutil.wl.gesture.request_notified = -1;