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);
1806 wl_registry_destroy(reg);
1810 if (_eflutil.wl.shot.noti == 0)
1812 fprintf(stderr, "[screenshot] fail: privilege error\n"); /* LCOV_EXCL_LINE */
1818 if (g_screenshot->width != width || g_screenshot->height != height)
1820 g_screenshot->width = width;
1821 g_screenshot->height = height;
1824 _screenshot_mutex_unlock();
1826 return g_screenshot;
1829 screenshot = calloc(1, sizeof(struct _efl_util_screenshot_h));
1830 EINA_SAFETY_ON_NULL_GOTO(screenshot, fail_memory);
1832 screenshot->width = width;
1833 screenshot->height = height;
1834 screenshot->auto_rotation = EINA_TRUE;
1836 screenshot->bufmgr = wayland_tbm_client_get_bufmgr(_eflutil.wl.shot.tbm_client);
1837 EINA_SAFETY_ON_NULL_GOTO(screenshot->bufmgr, fail_init);
1839 g_screenshot = screenshot;
1840 set_last_result(EFL_UTIL_ERROR_NONE);
1842 screenshooter_set_user_data(_eflutil.wl.shot.screenshooter, &screenshot->shot_done);
1844 _screenshot_mutex_unlock();
1846 return g_screenshot;
1849 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1852 /* LCOV_EXCL_START */
1853 if (display_wrapper)
1854 wl_proxy_wrapper_destroy(display_wrapper);
1855 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
1859 wl_registry_destroy(reg);
1861 efl_util_screenshot_deinitialize(screenshot);
1862 _screenshot_mutex_unlock();
1863 set_last_result(EFL_UTIL_ERROR_SCREENSHOT_INIT_FAIL);
1865 /* LCOV_EXCL_STOP */
1869 efl_util_screenshot_deinitialize(efl_util_screenshot_h screenshot)
1871 _screenshot_mutex_lock();
1875 _screenshot_mutex_unlock();
1876 _screenshot_mutex_destory();
1877 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1881 g_screenshot = NULL;
1883 if (_eflutil.wl.shot.screenshooter)
1885 screenshooter_destroy(_eflutil.wl.shot.screenshooter);
1886 _eflutil.wl.shot.screenshooter = NULL;
1888 if (_eflutil.wl.shot.tz_screenshooter)
1890 tizen_screenshooter_destroy(_eflutil.wl.shot.tz_screenshooter);
1891 _eflutil.wl.shot.tz_screenshooter = NULL;
1894 if (_eflutil.wl.shot.queue)
1896 wl_event_queue_destroy(_eflutil.wl.shot.queue);
1897 _eflutil.wl.shot.queue = NULL;
1900 _screenshot_mutex_unlock();
1901 _screenshot_mutex_destory();
1903 return EFL_UTIL_ERROR_NONE;
1908 efl_util_screenshot_take_tbm_surface(efl_util_screenshot_h screenshot)
1910 tbm_surface_h t_surface = NULL;
1911 struct wl_buffer *buffer = NULL;
1912 Efl_Util_Wl_Output_Info *output;
1915 _screenshot_mutex_lock();
1917 if (!screenshot || (screenshot != g_screenshot))
1919 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1920 _screenshot_mutex_unlock();
1924 output = eina_list_nth(_eflutil.wl.shot.output_list, 0);
1927 fprintf(stderr, "[screenshot] fail: no output for screenshot\n"); /* LCOV_EXCL_LINE */
1931 t_surface = tbm_surface_create(screenshot->width, screenshot->height, TBM_FORMAT_XRGB8888);
1934 fprintf(stderr, "[screenshot] fail: tbm_surface_create\n"); /* LCOV_EXCL_LINE */
1938 buffer = wayland_tbm_client_create_buffer(_eflutil.wl.shot.tbm_client, t_surface);
1941 fprintf(stderr, "[screenshot] fail: create wl_buffer for screenshot\n"); /* LCOV_EXCL_LINE */
1945 screenshooter_shoot(_eflutil.wl.shot.screenshooter, output->output, buffer);
1947 screenshot->shot_done = EINA_FALSE;
1948 while (!screenshot->shot_done && ret != -1)
1949 ret = wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
1953 fprintf(stderr, "[screenshot] fail: screenshooter_shoot\n"); /* LCOV_EXCL_LINE */
1957 wl_buffer_destroy(buffer);
1959 /* reset shot_done for next screenshot */
1960 screenshot->shot_done = EINA_FALSE;
1962 set_last_result(EFL_UTIL_ERROR_NONE);
1964 _screenshot_mutex_unlock();
1970 tbm_surface_destroy(t_surface);
1972 wl_buffer_destroy(buffer);
1974 set_last_result(EFL_UTIL_ERROR_SCREENSHOT_EXECUTION_FAIL);
1976 _screenshot_mutex_unlock();
1981 /* LCOV_EXCL_START */
1983 efl_util_screenshot_set_auto_rotation(efl_util_screenshot_h screenshot, int set)
1985 if (!screenshot || (screenshot != g_screenshot))
1986 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1988 if (!(set == 0 || set == 1))
1989 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1992 g_screenshot->auto_rotation = EINA_TRUE;
1994 g_screenshot->auto_rotation = EINA_FALSE;
1996 tizen_screenshooter_set_oneshot_auto_rotation(_eflutil.wl.shot.tz_screenshooter, g_screenshot->auto_rotation);
1998 return EFL_UTIL_ERROR_NONE;
2002 efl_util_screenshot_get_auto_rotation(efl_util_screenshot_h screenshot, int *set)
2004 if (!screenshot || (screenshot != g_screenshot) || !set)
2005 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2007 *set = g_screenshot->auto_rotation;
2009 return EFL_UTIL_ERROR_NONE;
2011 /* LCOV_EXCL_STOP */
2013 struct _efl_util_gesture_h
2018 API int EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = 0;
2019 API int EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = 0;
2020 API int EFL_UTIL_EVENT_GESTURE_TAP = 0;
2021 API int EFL_UTIL_EVENT_GESTURE_PALM_COVER = 0;
2023 /* LCOV_EXCL_START */
2025 _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)
2027 _eflutil.wl.gesture.request_notified = error;
2031 _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)
2033 efl_util_event_gesture_edge_swipe_s *ev = NULL;
2035 ev = (efl_util_event_gesture_edge_swipe_s *)calloc(1, sizeof(*ev));
2040 ev->fingers = fingers;
2045 ecore_event_add(EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE, ev, NULL, NULL);
2049 _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)
2051 _eflutil.wl.gesture.request_notified = error;
2055 _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)
2057 efl_util_event_gesture_edge_drag_s *ev = NULL;
2059 ev = (efl_util_event_gesture_edge_drag_s *)calloc(1, sizeof(*ev));
2064 ev->fingers = fingers;
2069 ecore_event_add(EFL_UTIL_EVENT_GESTURE_EDGE_DRAG, ev, NULL, NULL);
2073 _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)
2075 _eflutil.wl.gesture.request_notified = error;
2079 _cb_gesture_tap(void *data EINA_UNUSED, struct tizen_gesture *tizen_gesture EINA_UNUSED, uint32_t mode, uint32_t fingers, uint32_t repeats)
2081 efl_util_event_gesture_tap_s *ev = NULL;
2083 ev = (efl_util_event_gesture_tap_s *)calloc(1, sizeof(*ev));
2088 ev->fingers = fingers;
2089 ev->repeats = repeats;
2091 ecore_event_add(EFL_UTIL_EVENT_GESTURE_TAP, ev, NULL, NULL);
2093 /* LCOV_EXCL_STOP */
2096 _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)
2098 _eflutil.wl.gesture.request_notified = error;
2101 /* LCOV_EXCL_START */
2103 _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)
2105 efl_util_event_gesture_palm_cover_s *ev = NULL;
2107 ev = (efl_util_event_gesture_palm_cover_s *)calloc(1, sizeof(*ev));
2112 ev->duration = duration;
2116 ev->pressure = wl_fixed_to_int(pressure);
2118 ecore_event_add(EFL_UTIL_EVENT_GESTURE_PALM_COVER, ev, NULL, NULL);
2120 /* LCOV_EXCL_STOP */
2123 _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)
2125 _eflutil.wl.gesture.request_notified = error;
2128 static efl_util_error_e
2129 _efl_util_gesture_convert_error(int ret)
2133 case TIZEN_GESTURE_ERROR_NONE:
2134 return EFL_UTIL_ERROR_NONE;
2135 case TIZEN_GESTURE_ERROR_INVALID_DATA:
2136 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2137 case TIZEN_GESTURE_ERROR_NO_PERMISSION:
2138 return EFL_UTIL_ERROR_PERMISSION_DENIED;
2139 case TIZEN_GESTURE_ERROR_NO_SYSTEM_RESOURCES:
2140 return EFL_UTIL_ERROR_OUT_OF_MEMORY;
2141 case TIZEN_GESTURE_ERROR_GRABBED_ALREADY:
2142 return EFL_UTIL_ERROR_NO_RESOURCE_AVAILABLE;
2143 case TIZEN_GESTURE_ERROR_NOT_SUPPORTED:
2144 return EFL_UTIL_ERROR_NOT_SUPPORTED;
2146 return EFL_UTIL_ERROR_NONE;
2150 /* LCOV_EXCL_START */
2152 _efl_util_gesture_grab_edge_swipe(efl_util_gesture_data data)
2154 int ret = EFL_UTIL_ERROR_NONE;
2155 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2156 Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = NULL;
2157 unsigned int fingers = 0;
2158 unsigned int edge = 0;
2159 unsigned int edge_size = 0;
2160 unsigned int start_point = 0;
2161 unsigned int end_point = 0;
2163 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2165 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2166 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2167 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_SWIPE,
2168 EFL_UTIL_ERROR_INVALID_PARAMETER);
2170 edge_swipe_data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)data;
2172 fingers = edge_swipe_data->fingers;
2173 edge = edge_swipe_data->edge;
2174 edge_size = edge_swipe_data->edge_size;
2175 start_point = edge_swipe_data->start_point;
2176 end_point = edge_swipe_data->end_point;
2178 tizen_gesture_grab_edge_swipe(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2180 while (_eflutil.wl.gesture.request_notified == -1)
2181 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2183 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2184 _eflutil.wl.gesture.request_notified = -1;
2190 _efl_util_gesture_ungrab_edge_swipe(efl_util_gesture_data data)
2192 int ret = EFL_UTIL_ERROR_NONE;
2193 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2194 Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = NULL;
2195 unsigned int fingers = 0;
2196 unsigned int edge = 0;
2197 unsigned int edge_size = 0;
2198 unsigned int start_point = 0;
2199 unsigned int end_point = 0;
2201 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2203 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2204 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2205 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_SWIPE,
2206 EFL_UTIL_ERROR_INVALID_PARAMETER);
2208 edge_swipe_data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)data;
2210 fingers = edge_swipe_data->fingers;
2211 edge = edge_swipe_data->edge;
2212 edge_size = edge_swipe_data->edge_size;
2213 start_point = edge_swipe_data->start_point;
2214 end_point = edge_swipe_data->end_point;
2216 tizen_gesture_ungrab_edge_swipe(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2218 while (_eflutil.wl.gesture.request_notified == -1)
2219 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2221 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2222 _eflutil.wl.gesture.request_notified = -1;
2228 _efl_util_gesture_grab_edge_drag(efl_util_gesture_data data)
2230 int ret = EFL_UTIL_ERROR_NONE;
2231 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2232 Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = NULL;
2233 unsigned int fingers = 0;
2234 unsigned int edge = 0;
2235 unsigned int edge_size = 0;
2236 unsigned int start_point = 0;
2237 unsigned int end_point = 0;
2239 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2241 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2242 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2243 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_DRAG,
2244 EFL_UTIL_ERROR_INVALID_PARAMETER);
2246 edge_drag_data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)data;
2248 fingers = edge_drag_data->fingers;
2249 edge = edge_drag_data->edge;
2250 edge_size = edge_drag_data->edge_size;
2251 start_point = edge_drag_data->start_point;
2252 end_point = edge_drag_data->end_point;
2254 tizen_gesture_grab_edge_drag(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2256 while (_eflutil.wl.gesture.request_notified == -1)
2257 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2259 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2260 _eflutil.wl.gesture.request_notified = -1;
2266 _efl_util_gesture_ungrab_edge_drag(efl_util_gesture_data data)
2268 int ret = EFL_UTIL_ERROR_NONE;
2269 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2270 Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = NULL;
2271 unsigned int fingers = 0;
2272 unsigned int edge = 0;
2273 unsigned int edge_size = 0;
2274 unsigned int start_point = 0;
2275 unsigned int end_point = 0;
2277 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2279 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2280 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2281 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_DRAG,
2282 EFL_UTIL_ERROR_INVALID_PARAMETER);
2284 edge_drag_data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)data;
2286 fingers = edge_drag_data->fingers;
2287 edge = edge_drag_data->edge;
2288 edge_size = edge_drag_data->edge_size;
2289 start_point = edge_drag_data->start_point;
2290 end_point = edge_drag_data->end_point;
2292 tizen_gesture_ungrab_edge_drag(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2294 while (_eflutil.wl.gesture.request_notified == -1)
2295 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2297 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2298 _eflutil.wl.gesture.request_notified = -1;
2305 _efl_util_gesture_grab_tap(efl_util_gesture_data data)
2307 int ret = EFL_UTIL_ERROR_NONE;
2308 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2309 Efl_Util_Gesture_Tap_Grab_Data *tap_data = NULL;
2310 unsigned int fingers = 0;
2311 unsigned int repeats = 0;
2313 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2315 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2316 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2317 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_TAP,
2318 EFL_UTIL_ERROR_INVALID_PARAMETER);
2320 tap_data = (Efl_Util_Gesture_Tap_Grab_Data *)data;
2322 fingers = tap_data->fingers;
2323 repeats = tap_data->repeats;
2325 tizen_gesture_grab_tap(_eflutil.wl.gesture.proto, fingers, repeats);
2327 while (_eflutil.wl.gesture.request_notified == -1)
2328 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2330 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2331 _eflutil.wl.gesture.request_notified = -1;
2337 _efl_util_gesture_ungrab_tap(efl_util_gesture_data data)
2339 int ret = EFL_UTIL_ERROR_NONE;
2340 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2341 Efl_Util_Gesture_Tap_Grab_Data *tap_data = NULL;
2342 unsigned int fingers = 0;
2343 unsigned int repeats = 0;
2345 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2347 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2348 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2349 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_TAP,
2350 EFL_UTIL_ERROR_INVALID_PARAMETER);
2352 tap_data = (Efl_Util_Gesture_Tap_Grab_Data *)data;
2354 fingers = tap_data->fingers;
2355 repeats = tap_data->repeats;
2357 tizen_gesture_ungrab_tap(_eflutil.wl.gesture.proto, fingers, repeats);
2359 while (_eflutil.wl.gesture.request_notified == -1)
2360 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2362 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2363 _eflutil.wl.gesture.request_notified = -1;
2369 _efl_util_gesture_grab_palm_cover(efl_util_gesture_data data)
2371 int ret = EFL_UTIL_ERROR_NONE;
2372 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2374 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2376 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2377 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2378 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_PALM_COVER,
2379 EFL_UTIL_ERROR_INVALID_PARAMETER);
2381 tizen_gesture_grab_palm_cover(_eflutil.wl.gesture.proto);
2383 while (_eflutil.wl.gesture.request_notified == -1)
2384 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2386 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2387 _eflutil.wl.gesture.request_notified = -1;
2393 _efl_util_gesture_ungrab_palm_cover(efl_util_gesture_data data)
2395 int ret = EFL_UTIL_ERROR_NONE;
2396 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2398 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2400 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2401 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2402 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_PALM_COVER,
2403 EFL_UTIL_ERROR_INVALID_PARAMETER);
2405 tizen_gesture_ungrab_palm_cover(_eflutil.wl.gesture.proto);
2407 while (_eflutil.wl.gesture.request_notified == -1)
2408 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2410 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2411 _eflutil.wl.gesture.request_notified = -1;
2417 _efl_util_fd_cb(void *data, Ecore_Fd_Handler *hdl)
2419 if (_eflutil.wl.dpy && _eflutil.wl.queue)
2421 wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2422 return ECORE_CALLBACK_RENEW;
2426 return ECORE_CALLBACK_CANCEL;
2429 /* LCOV_EXCL_STOP */
2431 API efl_util_gesture_h
2432 efl_util_gesture_initialize(void)
2434 efl_util_gesture_h gesture_h = NULL;
2437 gesture_h = (efl_util_gesture_h)calloc(1, sizeof(struct _efl_util_gesture_h));
2440 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2441 goto out; /* LCOV_EXCL_LINE */
2444 if (_wl_init() == (int)EINA_FALSE)
2446 set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED); /* LCOV_EXCL_LINE */
2447 goto out; /* LCOV_EXCL_LINE */
2450 while (!_eflutil.wl.gesture.proto)
2451 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue); /* LCOV_EXCL_LINE */
2453 if (_eflutil.wl.gesture.event_init <= 0)
2455 if (ecore_event_init() <= 0)
2457 set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED); /* LCOV_EXCL_LINE */
2458 goto out; /* LCOV_EXCL_LINE */
2460 EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = ecore_event_type_new();
2461 EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = ecore_event_type_new();
2462 EFL_UTIL_EVENT_GESTURE_TAP = ecore_event_type_new();
2463 EFL_UTIL_EVENT_GESTURE_PALM_COVER = ecore_event_type_new();
2465 dpy_fd = wl_display_get_fd(_eflutil.wl.dpy);
2466 _eflutil.wl.dpy_fd = fcntl(dpy_fd, F_DUPFD_CLOEXEC, 0);
2467 if (_eflutil.wl.dpy_fd >= 0)
2468 _eflutil.wl.fd_hdl = ecore_main_fd_handler_add(_eflutil.wl.dpy_fd,
2469 ECORE_FD_READ | ECORE_FD_WRITE | ECORE_FD_ERROR,
2470 _efl_util_fd_cb, NULL,
2473 _eflutil.wl.gesture.event_init++;
2474 gesture_h->init = EINA_TRUE;
2476 set_last_result(EFL_UTIL_ERROR_NONE);
2480 /* LCOV_EXCL_START */
2487 /* LCOV_EXCL_STOP */
2491 efl_util_gesture_deinitialize(efl_util_gesture_h gesture_h)
2493 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2494 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2499 _eflutil.wl.gesture.event_init--;
2501 if (_eflutil.wl.gesture.event_init <= 0)
2503 _eflutil.wl.gesture.event_init = 0;
2504 ecore_event_shutdown();
2505 EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = 0;
2506 EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = 0;
2507 EFL_UTIL_EVENT_GESTURE_TAP = 0;
2508 EFL_UTIL_EVENT_GESTURE_PALM_COVER = 0;
2509 if (_eflutil.wl.dpy_fd >= 0)
2511 ecore_main_fd_handler_del(_eflutil.wl.fd_hdl);
2512 _eflutil.wl.fd_hdl = NULL;
2513 close(_eflutil.wl.dpy_fd);
2514 _eflutil.wl.dpy_fd = -1;
2518 return EFL_UTIL_ERROR_NONE;
2521 API efl_util_gesture_data
2522 efl_util_gesture_edge_swipe_new(efl_util_gesture_h gesture_h, unsigned int fingers, efl_util_gesture_edge_e edge)
2524 Efl_Util_Gesture_Edge_Swipe_Grab_Data *data;
2526 if (!gesture_h || gesture_h->init == EINA_FALSE)
2528 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2532 if (edge <= EFL_UTIL_GESTURE_EDGE_NONE || edge > EFL_UTIL_GESTURE_EDGE_LEFT)
2534 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2538 data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Edge_Swipe_Grab_Data));
2541 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2542 return NULL; /* LCOV_EXCL_LINE */
2545 data->base.type = TIZEN_GESTURE_TYPE_EDGE_SWIPE;
2546 data->fingers = fingers;
2548 data->edge_size = EFL_UTIL_GESTURE_EDGE_SIZE_FULL;
2550 set_last_result(EFL_UTIL_ERROR_NONE);
2552 return (void *)data;
2556 efl_util_gesture_edge_swipe_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2558 if (!gesture_h || gesture_h->init == EINA_FALSE)
2560 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2565 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2571 return EFL_UTIL_ERROR_NONE;
2575 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)
2577 Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = data;
2579 EINA_SAFETY_ON_NULL_RETURN_VAL(edge_swipe_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2580 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_swipe_data->base.type == TIZEN_GESTURE_TYPE_EDGE_SWIPE,
2581 EFL_UTIL_ERROR_INVALID_PARAMETER);
2582 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_size == EFL_UTIL_GESTURE_EDGE_SIZE_PARTIAL,
2583 EFL_UTIL_ERROR_INVALID_PARAMETER);
2584 EINA_SAFETY_ON_FALSE_RETURN_VAL(end_point > start_point, EFL_UTIL_ERROR_INVALID_PARAMETER);
2586 edge_swipe_data->edge_size = edge_size;
2587 edge_swipe_data->start_point = start_point;
2588 edge_swipe_data->end_point = end_point;
2590 return EFL_UTIL_ERROR_NONE;
2593 API efl_util_gesture_data
2594 efl_util_gesture_edge_drag_new(efl_util_gesture_h gesture_h, unsigned int fingers, efl_util_gesture_edge_e edge)
2596 Efl_Util_Gesture_Edge_Drag_Grab_Data *data;
2598 if (!gesture_h || gesture_h->init == EINA_FALSE)
2600 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2604 if (edge <= EFL_UTIL_GESTURE_EDGE_NONE || edge > EFL_UTIL_GESTURE_EDGE_LEFT)
2606 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2610 data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Edge_Drag_Grab_Data));
2613 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2614 return NULL; /* LCOV_EXCL_LINE */
2617 data->base.type = TIZEN_GESTURE_TYPE_EDGE_DRAG;
2618 data->fingers = fingers;
2620 data->edge_size = EFL_UTIL_GESTURE_EDGE_SIZE_FULL;
2622 set_last_result(EFL_UTIL_ERROR_NONE);
2624 return (void *)data;
2628 efl_util_gesture_edge_drag_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2630 if (!gesture_h || gesture_h->init == EINA_FALSE)
2632 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2637 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2643 return EFL_UTIL_ERROR_NONE;
2647 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)
2649 Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = data;
2651 EINA_SAFETY_ON_NULL_RETURN_VAL(edge_drag_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2652 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_drag_data->base.type == TIZEN_GESTURE_TYPE_EDGE_DRAG,
2653 EFL_UTIL_ERROR_INVALID_PARAMETER);
2654 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_size == EFL_UTIL_GESTURE_EDGE_SIZE_PARTIAL,
2655 EFL_UTIL_ERROR_INVALID_PARAMETER);
2656 EINA_SAFETY_ON_FALSE_RETURN_VAL(end_point > start_point, EFL_UTIL_ERROR_INVALID_PARAMETER);
2658 edge_drag_data->edge_size = edge_size;
2659 edge_drag_data->start_point = start_point;
2660 edge_drag_data->end_point = end_point;
2662 return EFL_UTIL_ERROR_NONE;
2665 API efl_util_gesture_data
2666 efl_util_gesture_tap_new(efl_util_gesture_h gesture_h, unsigned int fingers, unsigned int repeats)
2668 Efl_Util_Gesture_Tap_Grab_Data *data;
2670 if (!gesture_h || gesture_h->init == EINA_FALSE)
2672 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2676 if (fingers <= 1 || repeats <= 1)
2678 set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED);
2682 data = (Efl_Util_Gesture_Tap_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Tap_Grab_Data));
2685 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2686 return NULL; /* LCOV_EXCL_LINE */
2689 data->base.type = TIZEN_GESTURE_TYPE_TAP;
2690 data->fingers = fingers;
2691 data->repeats = repeats;
2693 set_last_result(EFL_UTIL_ERROR_NONE);
2695 return (void *)data;
2699 efl_util_gesture_tap_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2701 if (!gesture_h || gesture_h->init == EINA_FALSE)
2703 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2708 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2714 return EFL_UTIL_ERROR_NONE;
2717 API efl_util_gesture_data
2718 efl_util_gesture_palm_cover_new(efl_util_gesture_h gesture_h)
2720 Efl_Util_Gesture_Palm_Cover_Grab_Data *data;
2722 if (!gesture_h || gesture_h->init == EINA_FALSE)
2724 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2728 data = (Efl_Util_Gesture_Palm_Cover_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Palm_Cover_Grab_Data));
2731 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2732 return NULL; /* LCOV_EXCL_LINE */
2735 data->base.type = TIZEN_GESTURE_TYPE_PALM_COVER;
2737 set_last_result(EFL_UTIL_ERROR_NONE);
2739 return (void *)data;
2743 efl_util_gesture_palm_cover_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 /* LCOV_EXCL_START */
2763 efl_util_gesture_grab(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2765 int ret = EFL_UTIL_ERROR_NONE;
2766 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2768 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2770 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2771 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2772 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2774 switch (base_data->type)
2776 case TIZEN_GESTURE_TYPE_EDGE_SWIPE:
2777 ret = _efl_util_gesture_grab_edge_swipe(data);
2779 case TIZEN_GESTURE_TYPE_EDGE_DRAG:
2780 ret = _efl_util_gesture_grab_edge_drag(data);
2782 case TIZEN_GESTURE_TYPE_TAP:
2783 ret = _efl_util_gesture_grab_tap(data);
2785 case TIZEN_GESTURE_TYPE_PALM_COVER:
2786 ret = _efl_util_gesture_grab_palm_cover(data);
2789 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2796 efl_util_gesture_ungrab(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2798 int ret = EFL_UTIL_ERROR_NONE;
2799 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2801 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2803 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2804 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2805 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2807 switch (base_data->type)
2809 case TIZEN_GESTURE_TYPE_EDGE_SWIPE:
2810 ret = _efl_util_gesture_ungrab_edge_swipe(data);
2812 case TIZEN_GESTURE_TYPE_EDGE_DRAG:
2813 ret = _efl_util_gesture_ungrab_edge_drag(data);
2815 case TIZEN_GESTURE_TYPE_TAP:
2816 ret = _efl_util_gesture_ungrab_tap(data);
2818 case TIZEN_GESTURE_TYPE_PALM_COVER:
2819 ret = _efl_util_gesture_ungrab_palm_cover(data);
2822 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2827 /* LCOV_EXCL_STOP */
2830 efl_util_gesture_select(efl_util_gesture_h gesture_h, Evas_Object *window, efl_util_gesture_data data)
2832 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2833 Ecore_Wl2_Window *wlwin;
2834 struct wl_surface *surface;
2837 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2839 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2840 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2841 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
2842 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2844 if (base_data->type != TIZEN_GESTURE_TYPE_PALM_COVER)
2845 return EFL_UTIL_ERROR_NOT_SUPPORTED;
2847 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
2848 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
2850 surface = ecore_wl2_window_surface_get(wlwin);
2851 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
2852 EFL_UTIL_ERROR_INVALID_PARAMETER);
2854 tizen_gesture_select_palm_cover(_eflutil.wl.gesture.proto, surface);
2856 while (_eflutil.wl.gesture.request_notified == -1)
2857 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2859 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2860 _eflutil.wl.gesture.request_notified = -1;
2866 efl_util_gesture_deselect(efl_util_gesture_h gesture_h, Evas_Object *window, efl_util_gesture_data data)
2868 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2869 Ecore_Wl2_Window *wlwin;
2870 struct wl_surface *surface;
2873 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2875 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2876 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2877 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
2878 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2880 if (base_data->type != TIZEN_GESTURE_TYPE_PALM_COVER)
2881 return EFL_UTIL_ERROR_NOT_SUPPORTED;
2883 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
2884 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
2886 surface = ecore_wl2_window_surface_get(wlwin);
2887 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
2888 EFL_UTIL_ERROR_INVALID_PARAMETER);
2890 tizen_gesture_deselect_palm_cover(_eflutil.wl.gesture.proto, surface);
2892 while (_eflutil.wl.gesture.request_notified == -1)
2893 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2895 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2896 _eflutil.wl.gesture.request_notified = -1;
2901 /* LCOV_EXCL_START */
2903 efl_util_gesture_activate_set(efl_util_gesture_h gesture_h, unsigned int type, Eina_Bool active)
2907 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2908 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2909 EINA_SAFETY_ON_TRUE_RETURN_VAL(type == EFL_UTIL_GESTURE_TYPE_NONE, EFL_UTIL_ERROR_INVALID_PARAMETER);
2911 tizen_gesture_activate_set(_eflutil.wl.gesture.proto, NULL, type, active);
2913 while (_eflutil.wl.gesture.request_notified == -1)
2914 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2916 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2917 _eflutil.wl.gesture.request_notified = -1;
2921 /* LCOV_EXCL_STOP */
2924 efl_util_gesture_activate_set_on_window(efl_util_gesture_h gesture_h, Evas_Object *window, unsigned int type, Eina_Bool active)
2926 Ecore_Wl2_Window *wlwin;
2927 struct wl_surface *surface;
2930 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2931 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2932 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
2933 EINA_SAFETY_ON_TRUE_RETURN_VAL(type == EFL_UTIL_GESTURE_TYPE_NONE, EFL_UTIL_ERROR_INVALID_PARAMETER);
2935 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
2936 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
2938 surface = ecore_wl2_window_surface_get(wlwin);
2939 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
2940 EFL_UTIL_ERROR_INVALID_PARAMETER);
2942 tizen_gesture_activate_set(_eflutil.wl.gesture.proto, surface, type, active);
2944 while (_eflutil.wl.gesture.request_notified == -1)
2945 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2947 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2948 _eflutil.wl.gesture.request_notified = -1;