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;
196 struct tizen_policy *proto;
197 Eina_Hash *hash_noti_lv;
198 Eina_Hash *hash_scr_mode;
202 struct wl_event_queue *queue;
203 struct screenshooter *screenshooter;
204 struct tizen_screenshooter *tz_screenshooter;
205 struct wayland_tbm_client *tbm_client;
206 Eina_List *output_list;
211 struct tizen_input_device_manager *devicemgr;
212 int request_notified;
216 struct tizen_display_policy *proto;
217 Eina_Hash *hash_brightness;
221 struct tizen_gesture *proto;
222 int request_notified;
229 Eina_List *info_list; /* list of callback info */
230 unsigned int atom; /* x11 atom */
231 } cb_handler[CBH_MAX];
234 static Efl_Util_Data _eflutil =
240 { NULL, NULL, NULL }, /* tizen_policy protocol */
241 { NULL, NULL, NULL, NULL, NULL, 0 }, /* screenshooter protocol */
242 { NULL, -1 }, /* tizen_input_device_manager protocol */
243 { NULL, NULL }, /* display_policy protocol */
244 { NULL, -1, EINA_FALSE } /* tizen_gesture protocol */
247 { NULL, 0 }, /* handler for notification level */
248 { NULL, 0 } /* handler for screen mode */
252 static Eina_Bool _cb_info_add(Evas_Object *win, Efl_Util_Cb cb, void *data, int idx);
253 static Eina_Bool _cb_info_del_by_win(Evas_Object *win, int idx);
254 static Eina_List *_cb_info_list_get(int idx);
255 static Efl_Util_Callback_Info *_cb_info_find_by_win(Evas_Object *win, int idx);
256 static Eina_Bool _wl_init(void);
257 static void _cb_wl_reg_global(void *data, struct wl_registry *reg, unsigned int name, const char *interface, unsigned int version);
258 static void _cb_wl_reg_global_remove(void *data, struct wl_registry *reg, unsigned int name);
259 static void _cb_wl_reg_screenshooter_global(void *data, struct wl_registry *reg, unsigned int name, const char *interface, unsigned int version);
260 static void _cb_wl_reg_screenshooter_global_remove(void *data, struct wl_registry *reg, unsigned int name);
261 static Efl_Util_Callback_Info *_cb_info_find_by_wlsurf(void *wlsurf, int idx);
262 static void _cb_wl_tz_policy_conformant(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface, uint32_t is_conformant);
263 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);
264 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);
265 static void _cb_wl_tz_policy_transient_for_done(void *data, struct tizen_policy *tizen_policy, uint32_t child_id);
266 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);
267 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);
268 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);
269 static void _cb_wl_tz_policy_allowed_aux_hint(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface_resource, int id);
270 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);
271 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);
273 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);
275 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);
276 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);
277 static void _cb_error(void *data EINA_UNUSED, struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED, uint32_t errorcode);
278 static void _cb_block_expired(void *data EINA_UNUSED, struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED);
280 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);
281 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);
282 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);
283 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);
284 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);
285 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);
286 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);
287 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);
288 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);
291 static const struct wl_registry_listener _wl_reg_listener =
294 _cb_wl_reg_global_remove
297 static const struct wl_registry_listener _wl_reg_screenshooter_listener =
299 _cb_wl_reg_screenshooter_global,
300 _cb_wl_reg_screenshooter_global_remove
303 struct tizen_policy_listener _wl_tz_policy_listener =
305 _cb_wl_tz_policy_conformant,
306 _cb_wl_tz_policy_conformant_area,
307 _cb_wl_tz_policy_notification_done,
308 _cb_wl_tz_policy_transient_for_done,
309 _cb_wl_tz_policy_scr_mode_done,
310 _cb_wl_tz_policy_iconify_state_changed,
311 _cb_wl_tz_policy_supported_aux_hints,
312 _cb_wl_tz_policy_allowed_aux_hint,
313 _cb_wl_tz_policy_aux_message,
314 _cb_wl_conformant_region,
317 struct tizen_input_device_manager_listener _wl_tz_devmgr_listener =
325 struct tizen_display_policy_listener _wl_tz_display_policy_listener =
327 _cb_wl_tz_display_policy_brightness_done,
330 struct tizen_gesture_listener _wl_tz_gesture_listener =
332 _cb_gesture_edge_swipe_notify,
333 _cb_gesture_edge_swipe,
334 _cb_gesture_edge_drag_notify,
335 _cb_gesture_edge_drag,
336 _cb_gesture_tap_notify,
338 _cb_gesture_palm_cover_notify,
339 _cb_gesture_palm_cover,
340 _cb_gesture_activate_notify
344 _cb_info_add(Evas_Object *win,
349 Efl_Util_Callback_Info *info;
351 info = _cb_info_find_by_win(win, idx);
354 _eflutil.cb_handler[idx].info_list
355 = eina_list_remove(_eflutil.cb_handler[idx].info_list,
360 info = (Efl_Util_Callback_Info *)calloc(1, sizeof(Efl_Util_Callback_Info));
361 if (!info) return EINA_FALSE;
367 _eflutil.cb_handler[idx].info_list
368 = eina_list_append(_eflutil.cb_handler[idx].info_list,
375 _cb_info_del_by_win(Evas_Object *win,
378 Efl_Util_Callback_Info *info;
380 info = _cb_info_find_by_win(win, idx);
381 if (!info) return EINA_FALSE;
383 _eflutil.cb_handler[idx].info_list
384 = eina_list_remove(_eflutil.cb_handler[idx].info_list,
392 _cb_info_list_get(int idx)
394 return _eflutil.cb_handler[idx].info_list;
397 static Efl_Util_Callback_Info *
398 _cb_info_find_by_win(Evas_Object *win,
402 Efl_Util_Callback_Info *info;
404 l = _cb_info_list_get(idx);
405 EINA_LIST_FOREACH(l, ll, info)
407 if (info->win == win) return info;
416 struct wl_display *display_wrapper = NULL;
417 struct wl_registry *reg = NULL;
419 if (_eflutil.wl.init) return EINA_TRUE;
423 _eflutil.wl.wl2_display = ecore_wl2_display_connect(NULL);
424 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.wl2_display, fail);
425 _eflutil.wl.dpy = ecore_wl2_display_get(_eflutil.wl.wl2_display);
426 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.dpy, fail);
428 display_wrapper = wl_proxy_create_wrapper(_eflutil.wl.dpy);
429 EINA_SAFETY_ON_NULL_GOTO(display_wrapper, fail);
431 _eflutil.wl.queue = wl_display_create_queue(_eflutil.wl.dpy);
432 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.queue, fail);
434 wl_proxy_set_queue((struct wl_proxy *)display_wrapper, _eflutil.wl.queue);
436 reg = wl_display_get_registry(display_wrapper);
437 wl_proxy_wrapper_destroy(display_wrapper);
438 display_wrapper = NULL;
439 EINA_SAFETY_ON_NULL_GOTO(reg, fail);
441 wl_registry_add_listener(reg, &_wl_reg_listener, NULL);
443 _eflutil.wl.init = EINA_TRUE;
448 wl_proxy_wrapper_destroy(display_wrapper);
450 if (_eflutil.wl.queue)
452 wl_event_queue_destroy(_eflutil.wl.queue);
453 _eflutil.wl.queue = NULL;
456 ecore_wl2_shutdown();
461 _cb_wl_output_geometry(void *data, struct wl_output *wl_output, int x, int y,
462 int physical_width, int physical_height, int subpixel,
463 const char *make, const char *model, int transform)
465 Efl_Util_Wl_Output_Info *output = wl_output_get_user_data(wl_output);
466 if (wl_output == output->output)
468 output->offset_x = x;
469 output->offset_y = y;
474 _cb_wl_output_mode(void *data, struct wl_output *wl_output, uint32_t flags,
475 int width, int height, int refresh)
477 Efl_Util_Wl_Output_Info *output = wl_output_get_user_data(wl_output);
478 if (wl_output == output->output && (flags & WL_OUTPUT_MODE_CURRENT))
480 output->width = width;
481 output->height = height;
486 _cb_wl_output_done(void *data, struct wl_output *wl_output)
491 _cb_wl_output_scale(void *data, struct wl_output *wl_output, int32_t factor)
495 static const struct wl_output_listener output_listener =
497 _cb_wl_output_geometry,
504 _cb_wl_screenshot_done(void *data, struct screenshooter *screenshooter)
506 Eina_Bool *shot_done = (Eina_Bool*)data;
508 *shot_done = EINA_TRUE;
511 static const struct screenshooter_listener screenshooter_listener =
513 _cb_wl_screenshot_done
517 _cb_tz_screenshot_format(void *data, struct tizen_screenshooter *tz_screenshooter, uint32_t format)
522 _cb_tz_screenshot_noti(void *data, struct tizen_screenshooter *tz_screenshooter, uint32_t noti)
524 _eflutil.wl.shot.noti = noti;
527 static const struct tizen_screenshooter_listener tz_screenshooter_listener =
529 _cb_tz_screenshot_format,
530 _cb_tz_screenshot_noti
534 _cb_wl_reg_global(void *data,
535 struct wl_registry *reg,
537 const char *interface,
538 unsigned int version)
540 if (!strcmp(interface, "tizen_policy"))
542 struct tizen_policy *proto;
543 proto = wl_registry_bind(reg,
545 &tizen_policy_interface,
549 tizen_policy_add_listener(proto,
550 &_wl_tz_policy_listener,
553 _eflutil.wl.policy.hash_noti_lv = eina_hash_pointer_new(free);
554 _eflutil.wl.policy.hash_scr_mode = eina_hash_pointer_new(free);
555 _eflutil.wl.policy.proto = proto;
557 else if (strcmp(interface, "wl_output") == 0)
559 Efl_Util_Wl_Output_Info *output = calloc(1, sizeof(Efl_Util_Wl_Output_Info));
560 EINA_SAFETY_ON_NULL_RETURN(output);
562 _eflutil.wl.shot.output_list = eina_list_append(_eflutil.wl.shot.output_list, output);
564 output->output = wl_registry_bind(reg, name, &wl_output_interface, version);
565 wl_output_add_listener(output->output, &output_listener, output);
567 else if (strcmp(interface, "tizen_input_device_manager") == 0)
569 _eflutil.wl.devmgr.devicemgr = wl_registry_bind(reg, name, &tizen_input_device_manager_interface, version);
570 tizen_input_device_manager_add_listener(_eflutil.wl.devmgr.devicemgr, &_wl_tz_devmgr_listener, NULL);
572 else if (!strcmp(interface, "tizen_display_policy"))
574 _eflutil.wl.display_policy.proto = wl_registry_bind(reg, name, &tizen_display_policy_interface, version);
575 if (!_eflutil.wl.display_policy.proto) return;
577 tizen_display_policy_add_listener(_eflutil.wl.display_policy.proto,
578 &_wl_tz_display_policy_listener,
581 _eflutil.wl.display_policy.hash_brightness = eina_hash_pointer_new(free);
583 else if (strcmp(interface, "tizen_gesture") == 0)
585 _eflutil.wl.gesture.proto = wl_registry_bind(reg, name, &tizen_gesture_interface, version);
586 tizen_gesture_add_listener(_eflutil.wl.gesture.proto, &_wl_tz_gesture_listener, NULL);
589 /* LCOV_EXCL_START */
591 _cb_wl_reg_global_remove(void *data,
592 struct wl_registry *reg,
595 _eflutil.wl.policy.proto = NULL;
596 eina_hash_free(_eflutil.wl.policy.hash_noti_lv);
597 eina_hash_free(_eflutil.wl.policy.hash_scr_mode);
599 _eflutil.wl.display_policy.proto = NULL;
600 eina_hash_free(_eflutil.wl.display_policy.hash_brightness);
605 _cb_wl_reg_screenshooter_global(void *data,
606 struct wl_registry *reg,
608 const char *interface,
609 unsigned int version)
611 if (strcmp(interface, "screenshooter") == 0)
613 _eflutil.wl.shot.screenshooter = wl_registry_bind(reg, name, &screenshooter_interface, version);
614 screenshooter_add_listener(_eflutil.wl.shot.screenshooter, &screenshooter_listener, NULL);
616 else if (strcmp(interface, "tizen_screenshooter") == 0)
618 _eflutil.wl.shot.tz_screenshooter = wl_registry_bind(reg, name, &tizen_screenshooter_interface, version);
619 tizen_screenshooter_add_listener(_eflutil.wl.shot.tz_screenshooter, &tz_screenshooter_listener, NULL);
621 wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
625 /* LCOV_EXCL_START */
627 _cb_wl_reg_screenshooter_global_remove(void *data,
628 struct wl_registry *reg,
633 static Efl_Util_Callback_Info *
634 _cb_info_find_by_wlsurf(void *wlsurf,
638 Efl_Util_Callback_Info *info;
639 Ecore_Wl2_Window *wlwin2 = NULL;
640 void *wlsurf2 = NULL;
642 l = _cb_info_list_get(idx);
643 EINA_LIST_FOREACH(l, ll, info)
645 wlwin2 = (Ecore_Wl2_Window *)elm_win_wl_window_get(info->win);
646 wlsurf2 = ecore_wl2_window_surface_get(wlwin2);
647 if (wlsurf== wlsurf2) return info;
654 _cb_wl_tz_policy_conformant(void *data, struct tizen_policy *tizen_policy,
655 struct wl_surface *surface, uint32_t is_conformant)
660 _cb_wl_tz_policy_conformant_area(void *data, struct tizen_policy *tizen_policy,
661 struct wl_surface *surface, uint32_t conformant_part,
662 uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h)
668 _cb_wl_tz_policy_notification_done(void *data,
669 struct tizen_policy *tizen_policy,
670 struct wl_surface *surface,
674 Efl_Util_Wl_Surface_Lv_Info *lv_info;
675 Efl_Util_Callback_Info *cb_info;
677 lv_info = eina_hash_find(_eflutil.wl.policy.hash_noti_lv, &surface);
680 lv_info->level = level;
681 lv_info->wait_for_done = EINA_FALSE;
682 lv_info->state = state;
685 if (state != TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED) return;
687 cb_info = _cb_info_find_by_wlsurf((void *)surface, CBH_NOTI_LEV);
688 if (!cb_info) return;
689 if (!cb_info->cb) return;
691 cb_info->cb(cb_info->win,
692 EFL_UTIL_ERROR_PERMISSION_DENIED,
696 /* LCOV_EXCL_START */
698 _cb_wl_tz_policy_transient_for_done(void *data, struct tizen_policy *tizen_policy, uint32_t child_id)
704 _cb_wl_tz_policy_scr_mode_done(void *data,
705 struct tizen_policy *tizen_policy,
706 struct wl_surface *surface,
711 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
712 Efl_Util_Callback_Info *cb_info;
714 scr_mode_info = eina_hash_find(_eflutil.wl.policy.hash_scr_mode, &surface);
717 scr_mode_info->mode = mode;
718 scr_mode_info->wait_for_done = EINA_FALSE;
719 scr_mode_info->state = state;
722 if (state != TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED) return;
724 cb_info = _cb_info_find_by_wlsurf((void *)surface, CBH_SCR_MODE);
725 if (!cb_info) return;
726 if (!cb_info->cb) return;
728 cb_info->cb(cb_info->win,
729 EFL_UTIL_ERROR_PERMISSION_DENIED,
733 /* LCOV_EXCL_START */
734 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)
738 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)
742 static void _cb_wl_tz_policy_allowed_aux_hint(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface_resource, int id)
746 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)
749 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)
755 _cb_wl_tz_display_policy_brightness_done(void *data,
756 struct tizen_display_policy *tizen_display_policy,
757 struct wl_surface *surface,
761 Efl_Util_Wl_Surface_Brightness_Info *brightness_info;
763 brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
766 brightness_info->brightness = brightness;
767 brightness_info->wait_for_done = EINA_FALSE;
768 brightness_info->state = state;
773 _cb_window_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
775 Efl_Util_Wl_Surface_Lv_Info *lv_info;
778 if (EINA_UNLIKELY(!lv_info))
781 eina_hash_del(_eflutil.wl.policy.hash_noti_lv, &lv_info->surface, lv_info);
785 efl_util_set_notification_window_level(Evas_Object *window,
786 efl_util_notification_level_e level)
790 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
791 EINA_SAFETY_ON_FALSE_RETURN_VAL((level >= EFL_UTIL_NOTIFICATION_LEVEL_NONE) &&
792 (level <= EFL_UTIL_NOTIFICATION_LEVEL_TOP),
793 EFL_UTIL_ERROR_INVALID_PARAMETER);
795 if (level == EFL_UTIL_NOTIFICATION_LEVEL_1)
797 dlog_print(DLOG_WARN, LOG_TAG,
798 "DEPRECATION WARNING: EFL_UTIL_NOTIFICATION_LEVEL_1 is deprecated and will be removed from next release. Use EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT instead.");
800 else if (level == EFL_UTIL_NOTIFICATION_LEVEL_2)
802 dlog_print(DLOG_WARN, LOG_TAG,
803 "DEPRECATION WARNING: EFL_UTIL_NOTIFICATION_LEVEL_2 is deprecated and will be removed from next release. Use EFL_UTIL_NOTIFICATION_LEVEL_MEDIUM instead.");
805 else if (level == EFL_UTIL_NOTIFICATION_LEVEL_3)
807 dlog_print(DLOG_WARN, LOG_TAG,
808 "DEPRECATION WARNING: EFL_UTIL_NOTIFICATION_LEVEL_3 is deprecated and will be removed from next release. Use EFL_UTIL_NOTIFICATION_LEVEL_TOP instead.");
812 Ecore_Wl2_Window *wlwin;
813 struct wl_surface *surface;
814 Efl_Util_Wl_Surface_Lv_Info *lv_info;
815 Ecore_Wl2_Window_Type wl_type;
818 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
820 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
821 EINA_SAFETY_ON_NULL_RETURN_VAL(wlwin, EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
823 type = elm_win_type_get(window);
824 if (type != ELM_WIN_NOTIFICATION)
826 wl_type = ecore_wl2_window_type_get(wlwin);
827 EINA_SAFETY_ON_FALSE_RETURN_VAL((wl_type == ECORE_WL2_WINDOW_TYPE_NOTIFICATION),
828 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
831 while (!_eflutil.wl.policy.proto)
832 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
834 surface = ecore_wl2_window_surface_get(wlwin);
835 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
836 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
838 lv_info = eina_hash_find(_eflutil.wl.policy.hash_noti_lv, &surface);
841 lv_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Lv_Info));
842 EINA_SAFETY_ON_NULL_RETURN_VAL(lv_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
844 lv_info->surface = surface;
845 lv_info->level = (int)level;
846 lv_info->wait_for_done = EINA_TRUE;
847 lv_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
848 eina_hash_add(_eflutil.wl.policy.hash_noti_lv,
852 evas_object_event_callback_add(window, EVAS_CALLBACK_DEL,
853 _cb_window_del, lv_info);
857 lv_info->level = (int)level;
858 lv_info->wait_for_done = EINA_TRUE;
859 lv_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
863 tizen_policy_set_notification_level(_eflutil.wl.policy.proto,
864 surface, (int)level);
866 if (lv_info->wait_for_done)
869 while (lv_info->wait_for_done && (count < 3))
871 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
872 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
876 if (lv_info->wait_for_done)
878 return EFL_UTIL_ERROR_INVALID_PARAMETER;
882 if (lv_info->state == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
884 return EFL_UTIL_ERROR_PERMISSION_DENIED;
889 return EFL_UTIL_ERROR_NONE;
893 efl_util_get_notification_window_level(Evas_Object *window,
894 efl_util_notification_level_e *level)
898 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
899 EINA_SAFETY_ON_NULL_RETURN_VAL(level, EFL_UTIL_ERROR_INVALID_PARAMETER);
902 Ecore_Wl2_Window *wlwin;
903 struct wl_surface *surface;
904 Efl_Util_Wl_Surface_Lv_Info *lv_info;
905 Ecore_Wl2_Window_Type wl_type;
908 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
910 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
911 EINA_SAFETY_ON_NULL_RETURN_VAL(wlwin, EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
913 type = elm_win_type_get(window);
914 if (type != ELM_WIN_NOTIFICATION)
916 wl_type = ecore_wl2_window_type_get(wlwin);
917 EINA_SAFETY_ON_FALSE_RETURN_VAL((wl_type == ECORE_WL2_WINDOW_TYPE_NOTIFICATION),
918 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
921 while (!_eflutil.wl.policy.proto)
922 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
924 surface = ecore_wl2_window_surface_get(wlwin);
925 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
926 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
928 lv_info = eina_hash_find(_eflutil.wl.policy.hash_noti_lv, &surface);
931 if (lv_info->wait_for_done)
934 while ((lv_info->wait_for_done) && (count < 3))
936 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
937 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
941 if (lv_info->wait_for_done)
943 *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
944 return EFL_UTIL_ERROR_INVALID_PARAMETER;
948 switch (lv_info->level)
950 case TIZEN_POLICY_LEVEL_1: *level = EFL_UTIL_NOTIFICATION_LEVEL_1; break;
951 case TIZEN_POLICY_LEVEL_2: *level = EFL_UTIL_NOTIFICATION_LEVEL_2; break;
952 case TIZEN_POLICY_LEVEL_3: *level = EFL_UTIL_NOTIFICATION_LEVEL_3; break;
953 case TIZEN_POLICY_LEVEL_NONE: *level = EFL_UTIL_NOTIFICATION_LEVEL_NONE; break;
954 case TIZEN_POLICY_LEVEL_DEFAULT: *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT; break;
955 case TIZEN_POLICY_LEVEL_MEDIUM: *level = EFL_UTIL_NOTIFICATION_LEVEL_MEDIUM; break;
956 case TIZEN_POLICY_LEVEL_HIGH: *level = EFL_UTIL_NOTIFICATION_LEVEL_HIGH; break;
957 case TIZEN_POLICY_LEVEL_TOP: *level = EFL_UTIL_NOTIFICATION_LEVEL_TOP; break;
958 default: *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
959 return EFL_UTIL_ERROR_INVALID_PARAMETER;
961 return EFL_UTIL_ERROR_NONE;
964 *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
966 return EFL_UTIL_ERROR_NONE;
970 efl_util_set_notification_window_level_error_cb(Evas_Object *window,
971 efl_util_notification_window_level_error_cb callback,
974 dlog_print(DLOG_WARN, LOG_TAG,
975 "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.");
977 Eina_Bool ret = EINA_FALSE;
979 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
980 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EFL_UTIL_ERROR_INVALID_PARAMETER);
982 ret = _cb_info_add(window,
983 (Efl_Util_Cb)callback,
986 if (!ret) return EFL_UTIL_ERROR_OUT_OF_MEMORY;
988 return EFL_UTIL_ERROR_NONE;
992 efl_util_unset_notification_window_level_error_cb(Evas_Object *window)
994 dlog_print(DLOG_WARN, LOG_TAG,
995 "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.");
997 Eina_Bool ret = EINA_FALSE;
999 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1001 ret = _cb_info_del_by_win(window, CBH_NOTI_LEV);
1002 if (!ret) return EFL_UTIL_ERROR_INVALID_PARAMETER;
1004 return EFL_UTIL_ERROR_NONE;
1008 efl_util_set_window_opaque_state(Evas_Object *window,
1013 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1014 EINA_SAFETY_ON_FALSE_RETURN_VAL(((opaque >= 0) && (opaque <= 1)),
1015 EFL_UTIL_ERROR_INVALID_PARAMETER);
1017 Ecore_Wl2_Window *wlwin;
1018 struct wl_surface *surface;
1020 if (!_eflutil.wl.policy.proto)
1025 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1027 while (!_eflutil.wl.policy.proto && ret != -1)
1028 ret = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1030 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.policy.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
1033 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
1035 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
1037 surface = ecore_wl2_window_surface_get(wlwin);
1039 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
1041 tizen_policy_set_opaque_state(_eflutil.wl.policy.proto, surface, opaque);
1043 return EFL_UTIL_ERROR_NONE;
1047 efl_util_set_window_screen_mode(Evas_Object *window,
1048 efl_util_screen_mode_e mode)
1050 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1051 EINA_SAFETY_ON_FALSE_RETURN_VAL(((mode >= EFL_UTIL_SCREEN_MODE_DEFAULT) &&
1052 (mode <= EFL_UTIL_SCREEN_MODE_ALWAYS_ON)),
1053 EFL_UTIL_ERROR_INVALID_PARAMETER);
1055 Ecore_Wl2_Window *wlwin;
1056 struct wl_surface *surface;
1057 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
1061 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1063 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
1066 while (!_eflutil.wl.policy.proto)
1067 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1069 surface = ecore_wl2_window_surface_get(wlwin);
1070 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1071 EFL_UTIL_ERROR_INVALID_PARAMETER);
1073 scr_mode_info = eina_hash_find(_eflutil.wl.policy.hash_scr_mode, &surface);
1076 scr_mode_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Scr_Mode_Info));
1077 EINA_SAFETY_ON_NULL_RETURN_VAL(scr_mode_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
1079 scr_mode_info->surface = surface;
1080 scr_mode_info->mode = (unsigned int)mode;
1081 scr_mode_info->wait_for_done = EINA_TRUE;
1082 scr_mode_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
1084 eina_hash_add(_eflutil.wl.policy.hash_scr_mode,
1090 scr_mode_info->mode = (unsigned int)mode;
1091 scr_mode_info->wait_for_done = EINA_TRUE;
1092 scr_mode_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
1095 tizen_policy_set_window_screen_mode(_eflutil.wl.policy.proto,
1096 surface, (unsigned int)mode);
1097 if (scr_mode_info->wait_for_done)
1100 while (scr_mode_info->wait_for_done && (count < 3))
1102 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
1103 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1107 if (scr_mode_info->wait_for_done)
1109 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1113 if (scr_mode_info->state == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
1115 return EFL_UTIL_ERROR_PERMISSION_DENIED;
1120 return EFL_UTIL_ERROR_NONE;
1123 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1127 efl_util_get_window_screen_mode(Evas_Object *window,
1128 efl_util_screen_mode_e *mode)
1130 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1131 EINA_SAFETY_ON_NULL_RETURN_VAL(mode, EFL_UTIL_ERROR_INVALID_PARAMETER);
1133 Ecore_Wl2_Window *wlwin;
1134 struct wl_surface *surface;
1135 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
1139 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1141 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
1144 while (!_eflutil.wl.policy.proto)
1145 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1147 surface = ecore_wl2_window_surface_get(wlwin);
1148 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1149 EFL_UTIL_ERROR_INVALID_PARAMETER);
1151 scr_mode_info = eina_hash_find(_eflutil.wl.policy.hash_scr_mode, &surface);
1154 if (scr_mode_info->wait_for_done)
1156 while (scr_mode_info->wait_for_done)
1158 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
1159 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1163 switch (scr_mode_info->mode)
1165 case TIZEN_POLICY_MODE_DEFAULT: *mode = EFL_UTIL_SCREEN_MODE_DEFAULT; break;
1166 case TIZEN_POLICY_MODE_ALWAYS_ON: *mode = EFL_UTIL_SCREEN_MODE_ALWAYS_ON; break;
1167 default: *mode = EFL_UTIL_SCREEN_MODE_DEFAULT;
1168 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1170 return EFL_UTIL_ERROR_NONE;
1174 *mode = EFL_UTIL_SCREEN_MODE_DEFAULT;
1175 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1179 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1183 efl_util_set_window_screen_mode_error_cb(Evas_Object *window,
1184 efl_util_window_screen_mode_error_cb callback,
1187 /* Wearable device cannot use this. */
1188 if (get_tizen_profile() == TIZEN_PROFILE_WEARABLE)
1189 return EFL_UTIL_ERROR_NO_SUCH_DEVICE;
1191 dlog_print(DLOG_WARN, LOG_TAG,
1192 "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.");
1194 Eina_Bool ret = EINA_FALSE;
1196 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1197 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EFL_UTIL_ERROR_INVALID_PARAMETER);
1199 ret = _cb_info_add(window,
1200 (Efl_Util_Cb)callback,
1203 if (!ret) return EFL_UTIL_ERROR_OUT_OF_MEMORY;
1205 return EFL_UTIL_ERROR_NONE;
1209 efl_util_unset_window_screen_mode_error_cb(Evas_Object *window)
1211 /* Wearable device cannot use this. */
1212 if (get_tizen_profile() == TIZEN_PROFILE_WEARABLE)
1213 return EFL_UTIL_ERROR_NO_SUCH_DEVICE;
1215 dlog_print(DLOG_WARN, LOG_TAG,
1216 "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.");
1218 Eina_Bool ret = EINA_FALSE;
1220 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1222 ret = _cb_info_del_by_win(window, CBH_SCR_MODE);
1223 if (!ret) return EFL_UTIL_ERROR_INVALID_PARAMETER;
1225 return EFL_UTIL_ERROR_NONE;
1229 efl_util_set_window_brightness(Evas_Object *window, int brightness)
1231 Ecore_Wl2_Window *wlwin;
1232 struct wl_surface *surface;
1233 Efl_Util_Wl_Surface_Brightness_Info *brightness_info;
1236 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1237 EINA_SAFETY_ON_FALSE_RETURN_VAL(brightness <= 100, EFL_UTIL_ERROR_INVALID_PARAMETER);
1240 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1242 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
1245 while (!_eflutil.wl.display_policy.proto)
1246 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1248 surface = ecore_wl2_window_surface_get(wlwin);
1249 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1250 EFL_UTIL_ERROR_INVALID_PARAMETER);
1252 brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
1253 if (!brightness_info)
1255 brightness_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Brightness_Info));
1256 EINA_SAFETY_ON_NULL_RETURN_VAL(brightness_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
1258 brightness_info->surface = surface;
1259 brightness_info->brightness = brightness;
1260 brightness_info->wait_for_done = EINA_TRUE;
1261 brightness_info->state = TIZEN_DISPLAY_POLICY_ERROR_STATE_NONE;
1263 eina_hash_add(_eflutil.wl.display_policy.hash_brightness,
1269 brightness_info->brightness = brightness;
1270 brightness_info->wait_for_done = EINA_TRUE;
1271 brightness_info->state = TIZEN_DISPLAY_POLICY_ERROR_STATE_NONE;
1274 tizen_display_policy_set_window_brightness(_eflutil.wl.display_policy.proto,
1275 surface, brightness);
1276 if (brightness_info->wait_for_done)
1279 while (brightness_info->wait_for_done && (count < 3))
1281 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
1282 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1286 if (brightness_info->wait_for_done)
1288 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1292 if (brightness_info->state == TIZEN_DISPLAY_POLICY_ERROR_STATE_PERMISSION_DENIED)
1294 return EFL_UTIL_ERROR_PERMISSION_DENIED;
1298 return EFL_UTIL_ERROR_NONE;
1301 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1305 efl_util_get_window_brightness(Evas_Object *window, int *brightness)
1307 Ecore_Wl2_Window *wlwin;
1308 struct wl_surface *surface;
1309 Efl_Util_Wl_Surface_Brightness_Info *brightness_info;
1312 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1313 EINA_SAFETY_ON_NULL_RETURN_VAL(brightness, EFL_UTIL_ERROR_INVALID_PARAMETER);
1316 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1318 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
1319 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
1321 while (!_eflutil.wl.display_policy.proto)
1322 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1324 surface = ecore_wl2_window_surface_get(wlwin);
1325 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1326 EFL_UTIL_ERROR_INVALID_PARAMETER);
1328 brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
1329 if (brightness_info)
1331 if (brightness_info->wait_for_done)
1333 while (brightness_info->wait_for_done)
1335 ecore_wl2_display_flush(_eflutil.wl.wl2_display);
1336 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1339 *brightness = brightness_info->brightness;
1344 return EFL_UTIL_ERROR_NONE;
1348 struct _efl_util_inputgen_h
1350 unsigned int init_type;
1355 _cb_device_add(void *data EINA_UNUSED,
1356 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1357 uint32_t serial EINA_UNUSED,
1358 const char *identifier EINA_UNUSED,
1359 struct tizen_input_device *device EINA_UNUSED,
1360 struct wl_seat *seat EINA_UNUSED)
1365 /* LCOV_EXCL_START */
1367 _cb_device_remove(void *data EINA_UNUSED,
1368 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1369 uint32_t serial EINA_UNUSED,
1370 const char *identifier EINA_UNUSED,
1371 struct tizen_input_device *device EINA_UNUSED,
1372 struct wl_seat *seat EINA_UNUSED)
1376 /* LCOV_EXCL_STOP */
1379 _cb_error(void *data EINA_UNUSED,
1380 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1383 _eflutil.wl.devmgr.request_notified = errorcode;
1386 /* LCOV_EXCL_START */
1388 _cb_block_expired(void *data EINA_UNUSED,
1389 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED)
1393 /* LCOV_EXCL_STOP */
1395 static efl_util_error_e
1396 _efl_util_input_convert_input_generator_error(int ret)
1400 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE:
1401 return EFL_UTIL_ERROR_NONE;
1402 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NO_PERMISSION:
1403 return EFL_UTIL_ERROR_PERMISSION_DENIED;
1404 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NO_SYSTEM_RESOURCES:
1405 return EFL_UTIL_ERROR_OUT_OF_MEMORY;
1406 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_INVALID_PARAMETER:
1407 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1409 return EFL_UTIL_ERROR_NONE;
1413 API efl_util_inputgen_h
1414 efl_util_input_initialize_generator(unsigned int dev_type)
1416 int ret = EFL_UTIL_ERROR_NONE;
1417 efl_util_inputgen_h inputgen_h = NULL;
1418 unsigned int clas = 0x0;
1421 dev_type & ~(EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN
1422 | EFL_UTIL_INPUT_DEVTYPE_KEYBOARD
1423 | EFL_UTIL_INPUT_DEVTYPE_POINTER))
1425 set_last_result(EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1429 inputgen_h = (efl_util_inputgen_h)calloc(1, sizeof(struct _efl_util_inputgen_h));
1432 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
1436 inputgen_h->init_type |= dev_type;
1439 if (ret == (int)EINA_FALSE)
1441 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1445 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN)
1446 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
1447 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD)
1448 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD;
1449 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_POINTER)
1450 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE;
1452 while (!_eflutil.wl.devmgr.devicemgr)
1453 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1455 tizen_input_device_manager_init_generator(_eflutil.wl.devmgr.devicemgr, clas);
1457 while (_eflutil.wl.devmgr.request_notified == -1)
1458 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1460 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1461 _eflutil.wl.devmgr.request_notified = -1;
1463 set_last_result(ret);
1464 if (ret != TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE)
1478 API efl_util_inputgen_h
1479 efl_util_input_initialize_generator_with_name(unsigned int dev_type, const char *name)
1481 int ret = EFL_UTIL_ERROR_NONE;
1482 efl_util_inputgen_h inputgen_h = NULL;
1483 unsigned int clas = 0x0;
1486 dev_type & ~(EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN
1487 | EFL_UTIL_INPUT_DEVTYPE_KEYBOARD
1488 | EFL_UTIL_INPUT_DEVTYPE_POINTER))
1490 set_last_result(EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1494 inputgen_h = (efl_util_inputgen_h)calloc(1, sizeof(struct _efl_util_inputgen_h));
1497 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
1501 inputgen_h->init_type |= dev_type;
1502 strncpy(inputgen_h->name, name, 31);
1505 if (ret == (int)EINA_FALSE)
1507 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1511 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN)
1512 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
1513 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD)
1514 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD;
1515 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_POINTER)
1516 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE;
1518 while (!_eflutil.wl.devmgr.devicemgr)
1519 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1521 tizen_input_device_manager_init_generator_with_name(_eflutil.wl.devmgr.devicemgr, clas, inputgen_h->name);
1523 while (_eflutil.wl.devmgr.request_notified == -1)
1524 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1526 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1527 _eflutil.wl.devmgr.request_notified = -1;
1529 set_last_result(ret);
1530 if (ret != TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE)
1546 efl_util_input_deinitialize_generator(efl_util_inputgen_h inputgen_h)
1548 int ret = EFL_UTIL_ERROR_NONE;
1549 unsigned int clas = 0x0;
1550 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1552 if (inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN)
1553 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
1554 if (inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD)
1555 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD;
1556 if (inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_POINTER)
1557 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE;
1562 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1564 tizen_input_device_manager_deinit_generator(_eflutil.wl.devmgr.devicemgr, clas);
1566 while (_eflutil.wl.devmgr.request_notified == -1)
1567 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1569 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1570 _eflutil.wl.devmgr.request_notified = -1;
1576 efl_util_input_generate_key(efl_util_inputgen_h inputgen_h, const char *key_name, int pressed)
1578 int ret = EFL_UTIL_ERROR_NONE;
1580 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1581 EINA_SAFETY_ON_NULL_RETURN_VAL(key_name, EFL_UTIL_ERROR_INVALID_PARAMETER);
1582 EINA_SAFETY_ON_FALSE_RETURN_VAL(pressed == 0 || pressed == 1, EFL_UTIL_ERROR_INVALID_PARAMETER);
1583 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1585 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1587 tizen_input_device_manager_generate_key(_eflutil.wl.devmgr.devicemgr, key_name, pressed);
1589 while (_eflutil.wl.devmgr.request_notified == -1)
1590 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1592 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1593 _eflutil.wl.devmgr.request_notified = -1;
1599 efl_util_input_generate_touch(efl_util_inputgen_h inputgen_h, int idx,
1600 efl_util_input_touch_type_e touch_type, int x, int y)
1603 enum tizen_input_device_manager_pointer_event_type type;
1605 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1606 EINA_SAFETY_ON_FALSE_RETURN_VAL(idx >= 0, EFL_UTIL_ERROR_INVALID_PARAMETER);
1607 EINA_SAFETY_ON_FALSE_RETURN_VAL((x > 0 && y > 0), EFL_UTIL_ERROR_INVALID_PARAMETER);
1608 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1610 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1614 case EFL_UTIL_INPUT_TOUCH_BEGIN:
1615 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_BEGIN;
1617 case EFL_UTIL_INPUT_TOUCH_UPDATE:
1618 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_UPDATE;
1620 case EFL_UTIL_INPUT_TOUCH_END:
1621 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_END;
1624 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1627 tizen_input_device_manager_generate_touch(_eflutil.wl.devmgr.devicemgr, type, x, y, idx);
1629 while (_eflutil.wl.devmgr.request_notified == -1)
1630 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1632 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1633 _eflutil.wl.devmgr.request_notified = -1;
1639 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)
1642 enum tizen_input_device_manager_pointer_event_type type;
1644 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1645 EINA_SAFETY_ON_FALSE_RETURN_VAL(buttons > 0, EFL_UTIL_ERROR_INVALID_PARAMETER);
1646 EINA_SAFETY_ON_FALSE_RETURN_VAL((x >= 0 && y >= 0), EFL_UTIL_ERROR_INVALID_PARAMETER);
1647 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_POINTER, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1649 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1651 switch(pointer_type)
1653 case EFL_UTIL_INPUT_POINTER_BUTTON_DOWN:
1654 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_BEGIN;
1656 case EFL_UTIL_INPUT_POINTER_MOVE:
1657 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_UPDATE;
1659 case EFL_UTIL_INPUT_POINTER_BUTTON_UP:
1660 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_END;
1663 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1666 tizen_input_device_manager_generate_pointer(_eflutil.wl.devmgr.devicemgr, type, x, y, buttons);
1668 while (_eflutil.wl.devmgr.request_notified == -1)
1669 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1671 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1672 _eflutil.wl.devmgr.request_notified = -1;
1678 struct _efl_util_screenshot_h
1683 Eina_Bool shot_done;
1688 Eina_Bool auto_rotation;
1691 /* scrrenshot handle */
1692 static efl_util_screenshot_h g_screenshot;
1693 static Eina_Bool shot_mutex_init;
1694 static pthread_mutex_t shot_lock;
1697 _screenshot_mutex_init(void)
1699 if (shot_mutex_init)
1702 if (pthread_mutex_init(&shot_lock, NULL))
1704 fprintf(stderr, "[screenshot] fail: mutex init"); /*LCOV_EXCL_LINE*/
1705 return EINA_FALSE; /*LCOV_EXCL_LINE*/
1708 shot_mutex_init = EINA_TRUE;
1714 _screenshot_mutex_destory(void)
1716 if (!shot_mutex_init)
1719 if (pthread_mutex_destroy(&shot_lock))
1721 fprintf(stderr, "[screenshot] fail: mutex destory"); /*LCOV_EXCL_LINE*/
1722 return EINA_FALSE; /*LCOV_EXCL_LINE*/
1725 shot_mutex_init = EINA_FALSE;
1731 _screenshot_mutex_lock(void)
1733 if (!_screenshot_mutex_init())
1736 pthread_mutex_lock(&shot_lock);
1740 _screenshot_mutex_unlock(void)
1742 pthread_mutex_unlock(&shot_lock);
1745 API efl_util_screenshot_h
1746 efl_util_screenshot_initialize(int width, int height)
1748 efl_util_screenshot_h screenshot = NULL;
1749 struct wl_display *display_wrapper = NULL;
1750 struct wl_registry *reg = NULL;
1753 EINA_SAFETY_ON_FALSE_GOTO(width > 0, fail_param);
1754 EINA_SAFETY_ON_FALSE_GOTO(height > 0, fail_param);
1756 _screenshot_mutex_lock();
1758 if (!_eflutil.wl.shot.screenshooter)
1761 if (ret == (int)EINA_FALSE)
1763 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1764 _screenshot_mutex_unlock();
1767 wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1769 display_wrapper = wl_proxy_create_wrapper(_eflutil.wl.dpy);
1770 EINA_SAFETY_ON_NULL_GOTO(display_wrapper, fail_memory);
1772 _eflutil.wl.shot.queue = wl_display_create_queue(_eflutil.wl.dpy);
1773 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.queue, fail_memory);
1775 wl_proxy_set_queue((struct wl_proxy *)display_wrapper, _eflutil.wl.shot.queue);
1777 reg = wl_display_get_registry(display_wrapper);
1778 wl_proxy_wrapper_destroy(display_wrapper);
1779 display_wrapper = NULL;
1780 EINA_SAFETY_ON_NULL_GOTO(reg, fail_init);
1782 wl_registry_add_listener(reg, &_wl_reg_screenshooter_listener, NULL);
1784 ret = wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
1785 EINA_SAFETY_ON_TRUE_GOTO(ret == -1, fail_init);
1786 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.screenshooter, fail_init);
1787 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.tz_screenshooter, fail_init);
1789 _eflutil.wl.shot.tbm_client = wayland_tbm_client_init(_eflutil.wl.dpy);
1790 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.tbm_client, fail_init);
1793 if (_eflutil.wl.shot.noti == 0)
1795 fprintf(stderr, "[screenshot] fail: privilege error\n"); /* LCOV_EXCL_LINE */
1801 if (g_screenshot->width != width || g_screenshot->height != height)
1803 g_screenshot->width = width;
1804 g_screenshot->height = height;
1807 _screenshot_mutex_unlock();
1809 return g_screenshot;
1812 screenshot = calloc(1, sizeof(struct _efl_util_screenshot_h));
1813 EINA_SAFETY_ON_NULL_GOTO(screenshot, fail_memory);
1815 screenshot->width = width;
1816 screenshot->height = height;
1817 screenshot->auto_rotation = EINA_TRUE;
1819 screenshot->bufmgr = wayland_tbm_client_get_bufmgr(_eflutil.wl.shot.tbm_client);
1820 EINA_SAFETY_ON_NULL_GOTO(screenshot->bufmgr, fail_init);
1822 g_screenshot = screenshot;
1823 set_last_result(EFL_UTIL_ERROR_NONE);
1825 screenshooter_set_user_data(_eflutil.wl.shot.screenshooter, &screenshot->shot_done);
1827 _screenshot_mutex_unlock();
1829 return g_screenshot;
1832 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1835 /* LCOV_EXCL_START */
1836 if (display_wrapper)
1837 wl_proxy_wrapper_destroy(display_wrapper);
1838 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
1842 efl_util_screenshot_deinitialize(screenshot);
1843 _screenshot_mutex_unlock();
1844 set_last_result(EFL_UTIL_ERROR_SCREENSHOT_INIT_FAIL);
1846 /* LCOV_EXCL_STOP */
1850 efl_util_screenshot_deinitialize(efl_util_screenshot_h screenshot)
1852 _screenshot_mutex_lock();
1856 _screenshot_mutex_unlock();
1857 _screenshot_mutex_destory();
1858 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1862 g_screenshot = NULL;
1864 if (_eflutil.wl.shot.queue)
1866 wl_event_queue_destroy(_eflutil.wl.shot.queue);
1867 _eflutil.wl.shot.queue = NULL;
1870 if (_eflutil.wl.shot.screenshooter)
1872 screenshooter_destroy(_eflutil.wl.shot.screenshooter);
1873 _eflutil.wl.shot.screenshooter = NULL;
1875 if (_eflutil.wl.shot.tz_screenshooter)
1877 tizen_screenshooter_destroy(_eflutil.wl.shot.tz_screenshooter);
1878 _eflutil.wl.shot.tz_screenshooter = NULL;
1881 _screenshot_mutex_unlock();
1882 _screenshot_mutex_destory();
1884 return EFL_UTIL_ERROR_NONE;
1889 efl_util_screenshot_take_tbm_surface(efl_util_screenshot_h screenshot)
1891 tbm_surface_h t_surface = NULL;
1892 struct wl_buffer *buffer = NULL;
1893 Efl_Util_Wl_Output_Info *output;
1896 _screenshot_mutex_lock();
1898 if (!screenshot || (screenshot != g_screenshot))
1900 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1901 _screenshot_mutex_unlock();
1905 output = eina_list_nth(_eflutil.wl.shot.output_list, 0);
1908 fprintf(stderr, "[screenshot] fail: no output for screenshot\n"); /* LCOV_EXCL_LINE */
1912 t_surface = tbm_surface_create(screenshot->width, screenshot->height, TBM_FORMAT_XRGB8888);
1915 fprintf(stderr, "[screenshot] fail: tbm_surface_create\n"); /* LCOV_EXCL_LINE */
1919 buffer = wayland_tbm_client_create_buffer(_eflutil.wl.shot.tbm_client, t_surface);
1922 fprintf(stderr, "[screenshot] fail: create wl_buffer for screenshot\n"); /* LCOV_EXCL_LINE */
1926 screenshooter_shoot(_eflutil.wl.shot.screenshooter, output->output, buffer);
1928 screenshot->shot_done = EINA_FALSE;
1929 while (!screenshot->shot_done && ret != -1)
1930 ret = wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
1934 fprintf(stderr, "[screenshot] fail: screenshooter_shoot\n"); /* LCOV_EXCL_LINE */
1938 wl_buffer_destroy(buffer);
1940 /* reset shot_done for next screenshot */
1941 screenshot->shot_done = EINA_FALSE;
1943 set_last_result(EFL_UTIL_ERROR_NONE);
1945 _screenshot_mutex_unlock();
1951 tbm_surface_destroy(t_surface);
1953 wl_buffer_destroy(buffer);
1955 set_last_result(EFL_UTIL_ERROR_SCREENSHOT_EXECUTION_FAIL);
1957 _screenshot_mutex_unlock();
1962 /* LCOV_EXCL_START */
1964 efl_util_screenshot_set_auto_rotation(efl_util_screenshot_h screenshot, int set)
1966 if (!screenshot || (screenshot != g_screenshot))
1967 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1969 if (!(set == 0 || set == 1))
1970 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1973 g_screenshot->auto_rotation = EINA_TRUE;
1975 g_screenshot->auto_rotation = EINA_FALSE;
1977 tizen_screenshooter_set_oneshot_auto_rotation(_eflutil.wl.shot.tz_screenshooter, g_screenshot->auto_rotation);
1979 return EFL_UTIL_ERROR_NONE;
1983 efl_util_screenshot_get_auto_rotation(efl_util_screenshot_h screenshot, int *set)
1985 if (!screenshot || (screenshot != g_screenshot) || !set)
1986 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1988 *set = g_screenshot->auto_rotation;
1990 return EFL_UTIL_ERROR_NONE;
1992 /* LCOV_EXCL_STOP */
1994 struct _efl_util_gesture_h
1999 API int EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = 0;
2000 API int EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = 0;
2001 API int EFL_UTIL_EVENT_GESTURE_TAP = 0;
2002 API int EFL_UTIL_EVENT_GESTURE_PALM_COVER = 0;
2004 /* LCOV_EXCL_START */
2006 _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)
2008 _eflutil.wl.gesture.request_notified = error;
2012 _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)
2014 efl_util_event_gesture_edge_swipe_s *ev = NULL;
2016 ev = (efl_util_event_gesture_edge_swipe_s *)calloc(1, sizeof(*ev));
2021 ev->fingers = fingers;
2026 ecore_event_add(EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE, ev, NULL, NULL);
2030 _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)
2032 _eflutil.wl.gesture.request_notified = error;
2036 _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)
2038 efl_util_event_gesture_edge_drag_s *ev = NULL;
2040 ev = (efl_util_event_gesture_edge_drag_s *)calloc(1, sizeof(*ev));
2045 ev->fingers = fingers;
2050 ecore_event_add(EFL_UTIL_EVENT_GESTURE_EDGE_DRAG, ev, NULL, NULL);
2054 _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)
2056 _eflutil.wl.gesture.request_notified = error;
2060 _cb_gesture_tap(void *data EINA_UNUSED, struct tizen_gesture *tizen_gesture EINA_UNUSED, uint32_t mode, uint32_t fingers, uint32_t repeats)
2062 efl_util_event_gesture_tap_s *ev = NULL;
2064 ev = (efl_util_event_gesture_tap_s *)calloc(1, sizeof(*ev));
2069 ev->fingers = fingers;
2070 ev->repeats = repeats;
2072 ecore_event_add(EFL_UTIL_EVENT_GESTURE_TAP, ev, NULL, NULL);
2074 /* LCOV_EXCL_STOP */
2077 _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)
2079 _eflutil.wl.gesture.request_notified = error;
2082 /* LCOV_EXCL_START */
2084 _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)
2086 efl_util_event_gesture_palm_cover_s *ev = NULL;
2088 ev = (efl_util_event_gesture_palm_cover_s *)calloc(1, sizeof(*ev));
2093 ev->duration = duration;
2097 ev->pressure = wl_fixed_to_int(pressure);
2099 ecore_event_add(EFL_UTIL_EVENT_GESTURE_PALM_COVER, ev, NULL, NULL);
2101 /* LCOV_EXCL_STOP */
2104 _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)
2106 _eflutil.wl.gesture.request_notified = error;
2109 static efl_util_error_e
2110 _efl_util_gesture_convert_error(int ret)
2114 case TIZEN_GESTURE_ERROR_NONE:
2115 return EFL_UTIL_ERROR_NONE;
2116 case TIZEN_GESTURE_ERROR_INVALID_DATA:
2117 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2118 case TIZEN_GESTURE_ERROR_NO_PERMISSION:
2119 return EFL_UTIL_ERROR_PERMISSION_DENIED;
2120 case TIZEN_GESTURE_ERROR_NO_SYSTEM_RESOURCES:
2121 return EFL_UTIL_ERROR_OUT_OF_MEMORY;
2122 case TIZEN_GESTURE_ERROR_GRABBED_ALREADY:
2123 return EFL_UTIL_ERROR_NO_RESOURCE_AVAILABLE;
2124 case TIZEN_GESTURE_ERROR_NOT_SUPPORTED:
2125 return EFL_UTIL_ERROR_NOT_SUPPORTED;
2127 return EFL_UTIL_ERROR_NONE;
2131 /* LCOV_EXCL_START */
2133 _efl_util_gesture_grab_edge_swipe(efl_util_gesture_data data)
2135 int ret = EFL_UTIL_ERROR_NONE;
2136 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2137 Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = NULL;
2138 unsigned int fingers = 0;
2139 unsigned int edge = 0;
2140 unsigned int edge_size = 0;
2141 unsigned int start_point = 0;
2142 unsigned int end_point = 0;
2144 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2146 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2147 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2148 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_SWIPE,
2149 EFL_UTIL_ERROR_INVALID_PARAMETER);
2151 edge_swipe_data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)data;
2153 fingers = edge_swipe_data->fingers;
2154 edge = edge_swipe_data->edge;
2155 edge_size = edge_swipe_data->edge_size;
2156 start_point = edge_swipe_data->start_point;
2157 end_point = edge_swipe_data->end_point;
2159 tizen_gesture_grab_edge_swipe(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2161 while (_eflutil.wl.gesture.request_notified == -1)
2162 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2164 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2165 _eflutil.wl.gesture.request_notified = -1;
2171 _efl_util_gesture_ungrab_edge_swipe(efl_util_gesture_data data)
2173 int ret = EFL_UTIL_ERROR_NONE;
2174 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2175 Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = NULL;
2176 unsigned int fingers = 0;
2177 unsigned int edge = 0;
2178 unsigned int edge_size = 0;
2179 unsigned int start_point = 0;
2180 unsigned int end_point = 0;
2182 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2184 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2185 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2186 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_SWIPE,
2187 EFL_UTIL_ERROR_INVALID_PARAMETER);
2189 edge_swipe_data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)data;
2191 fingers = edge_swipe_data->fingers;
2192 edge = edge_swipe_data->edge;
2193 edge_size = edge_swipe_data->edge_size;
2194 start_point = edge_swipe_data->start_point;
2195 end_point = edge_swipe_data->end_point;
2197 tizen_gesture_ungrab_edge_swipe(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2199 while (_eflutil.wl.gesture.request_notified == -1)
2200 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2202 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2203 _eflutil.wl.gesture.request_notified = -1;
2209 _efl_util_gesture_grab_edge_drag(efl_util_gesture_data data)
2211 int ret = EFL_UTIL_ERROR_NONE;
2212 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2213 Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = NULL;
2214 unsigned int fingers = 0;
2215 unsigned int edge = 0;
2216 unsigned int edge_size = 0;
2217 unsigned int start_point = 0;
2218 unsigned int end_point = 0;
2220 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2222 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2223 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2224 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_DRAG,
2225 EFL_UTIL_ERROR_INVALID_PARAMETER);
2227 edge_drag_data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)data;
2229 fingers = edge_drag_data->fingers;
2230 edge = edge_drag_data->edge;
2231 edge_size = edge_drag_data->edge_size;
2232 start_point = edge_drag_data->start_point;
2233 end_point = edge_drag_data->end_point;
2235 tizen_gesture_grab_edge_drag(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2237 while (_eflutil.wl.gesture.request_notified == -1)
2238 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2240 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2241 _eflutil.wl.gesture.request_notified = -1;
2247 _efl_util_gesture_ungrab_edge_drag(efl_util_gesture_data data)
2249 int ret = EFL_UTIL_ERROR_NONE;
2250 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2251 Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = NULL;
2252 unsigned int fingers = 0;
2253 unsigned int edge = 0;
2254 unsigned int edge_size = 0;
2255 unsigned int start_point = 0;
2256 unsigned int end_point = 0;
2258 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2260 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2261 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2262 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_DRAG,
2263 EFL_UTIL_ERROR_INVALID_PARAMETER);
2265 edge_drag_data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)data;
2267 fingers = edge_drag_data->fingers;
2268 edge = edge_drag_data->edge;
2269 edge_size = edge_drag_data->edge_size;
2270 start_point = edge_drag_data->start_point;
2271 end_point = edge_drag_data->end_point;
2273 tizen_gesture_ungrab_edge_drag(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2275 while (_eflutil.wl.gesture.request_notified == -1)
2276 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2278 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2279 _eflutil.wl.gesture.request_notified = -1;
2286 _efl_util_gesture_grab_tap(efl_util_gesture_data data)
2288 int ret = EFL_UTIL_ERROR_NONE;
2289 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2290 Efl_Util_Gesture_Tap_Grab_Data *tap_data = NULL;
2291 unsigned int fingers = 0;
2292 unsigned int repeats = 0;
2294 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2296 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2297 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2298 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_TAP,
2299 EFL_UTIL_ERROR_INVALID_PARAMETER);
2301 tap_data = (Efl_Util_Gesture_Tap_Grab_Data *)data;
2303 fingers = tap_data->fingers;
2304 repeats = tap_data->repeats;
2306 tizen_gesture_grab_tap(_eflutil.wl.gesture.proto, fingers, repeats);
2308 while (_eflutil.wl.gesture.request_notified == -1)
2309 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2311 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2312 _eflutil.wl.gesture.request_notified = -1;
2318 _efl_util_gesture_ungrab_tap(efl_util_gesture_data data)
2320 int ret = EFL_UTIL_ERROR_NONE;
2321 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2322 Efl_Util_Gesture_Tap_Grab_Data *tap_data = NULL;
2323 unsigned int fingers = 0;
2324 unsigned int repeats = 0;
2326 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2328 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2329 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2330 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_TAP,
2331 EFL_UTIL_ERROR_INVALID_PARAMETER);
2333 tap_data = (Efl_Util_Gesture_Tap_Grab_Data *)data;
2335 fingers = tap_data->fingers;
2336 repeats = tap_data->repeats;
2338 tizen_gesture_ungrab_tap(_eflutil.wl.gesture.proto, fingers, repeats);
2340 while (_eflutil.wl.gesture.request_notified == -1)
2341 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2343 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2344 _eflutil.wl.gesture.request_notified = -1;
2350 _efl_util_gesture_grab_palm_cover(efl_util_gesture_data data)
2352 int ret = EFL_UTIL_ERROR_NONE;
2353 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2355 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2357 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2358 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2359 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_PALM_COVER,
2360 EFL_UTIL_ERROR_INVALID_PARAMETER);
2362 tizen_gesture_grab_palm_cover(_eflutil.wl.gesture.proto);
2364 while (_eflutil.wl.gesture.request_notified == -1)
2365 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2367 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2368 _eflutil.wl.gesture.request_notified = -1;
2374 _efl_util_gesture_ungrab_palm_cover(efl_util_gesture_data data)
2376 int ret = EFL_UTIL_ERROR_NONE;
2377 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2379 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2381 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2382 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2383 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_PALM_COVER,
2384 EFL_UTIL_ERROR_INVALID_PARAMETER);
2386 tizen_gesture_ungrab_palm_cover(_eflutil.wl.gesture.proto);
2388 while (_eflutil.wl.gesture.request_notified == -1)
2389 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2391 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2392 _eflutil.wl.gesture.request_notified = -1;
2398 _efl_util_fd_cb(void *data, Ecore_Fd_Handler *hdl)
2400 if (_eflutil.wl.dpy && _eflutil.wl.queue)
2402 wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2403 return ECORE_CALLBACK_RENEW;
2407 return ECORE_CALLBACK_CANCEL;
2410 /* LCOV_EXCL_STOP */
2412 API efl_util_gesture_h
2413 efl_util_gesture_initialize(void)
2415 efl_util_gesture_h gesture_h = NULL;
2418 gesture_h = (efl_util_gesture_h)calloc(1, sizeof(struct _efl_util_gesture_h));
2421 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2422 goto out; /* LCOV_EXCL_LINE */
2425 if (_wl_init() == (int)EINA_FALSE)
2427 set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED); /* LCOV_EXCL_LINE */
2428 goto out; /* LCOV_EXCL_LINE */
2431 while (!_eflutil.wl.gesture.proto)
2432 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue); /* LCOV_EXCL_LINE */
2434 if (_eflutil.wl.gesture.event_init <= 0)
2436 if (ecore_event_init() <= 0)
2438 set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED); /* LCOV_EXCL_LINE */
2439 goto out; /* LCOV_EXCL_LINE */
2441 EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = ecore_event_type_new();
2442 EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = ecore_event_type_new();
2443 EFL_UTIL_EVENT_GESTURE_TAP = ecore_event_type_new();
2444 EFL_UTIL_EVENT_GESTURE_PALM_COVER = ecore_event_type_new();
2446 dpy_fd = wl_display_get_fd(_eflutil.wl.dpy);
2447 _eflutil.wl.dpy_fd = fcntl(dpy_fd, F_DUPFD_CLOEXEC, 0);
2448 if (_eflutil.wl.dpy_fd >= 0)
2449 _eflutil.wl.fd_hdl = ecore_main_fd_handler_add(_eflutil.wl.dpy_fd,
2450 ECORE_FD_READ | ECORE_FD_WRITE | ECORE_FD_ERROR,
2451 _efl_util_fd_cb, NULL,
2454 _eflutil.wl.gesture.event_init++;
2455 gesture_h->init = EINA_TRUE;
2457 set_last_result(EFL_UTIL_ERROR_NONE);
2461 /* LCOV_EXCL_START */
2468 /* LCOV_EXCL_STOP */
2472 efl_util_gesture_deinitialize(efl_util_gesture_h gesture_h)
2474 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2475 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2480 _eflutil.wl.gesture.event_init--;
2482 if (_eflutil.wl.gesture.event_init <= 0)
2484 _eflutil.wl.gesture.event_init = 0;
2485 ecore_event_shutdown();
2486 EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = 0;
2487 EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = 0;
2488 EFL_UTIL_EVENT_GESTURE_TAP = 0;
2489 EFL_UTIL_EVENT_GESTURE_PALM_COVER = 0;
2490 if (_eflutil.wl.dpy_fd >= 0)
2492 ecore_main_fd_handler_del(_eflutil.wl.fd_hdl);
2493 _eflutil.wl.fd_hdl = NULL;
2494 close(_eflutil.wl.dpy_fd);
2495 _eflutil.wl.dpy_fd = -1;
2499 return EFL_UTIL_ERROR_NONE;
2502 API efl_util_gesture_data
2503 efl_util_gesture_edge_swipe_new(efl_util_gesture_h gesture_h, unsigned int fingers, efl_util_gesture_edge_e edge)
2505 Efl_Util_Gesture_Edge_Swipe_Grab_Data *data;
2507 if (!gesture_h || gesture_h->init == EINA_FALSE)
2509 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2513 if (edge <= EFL_UTIL_GESTURE_EDGE_NONE || edge > EFL_UTIL_GESTURE_EDGE_LEFT)
2515 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2519 data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Edge_Swipe_Grab_Data));
2522 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2523 return NULL; /* LCOV_EXCL_LINE */
2526 data->base.type = TIZEN_GESTURE_TYPE_EDGE_SWIPE;
2527 data->fingers = fingers;
2529 data->edge_size = EFL_UTIL_GESTURE_EDGE_SIZE_FULL;
2531 set_last_result(EFL_UTIL_ERROR_NONE);
2533 return (void *)data;
2537 efl_util_gesture_edge_swipe_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2539 if (!gesture_h || gesture_h->init == EINA_FALSE)
2541 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2546 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2552 return EFL_UTIL_ERROR_NONE;
2556 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)
2558 Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = data;
2560 EINA_SAFETY_ON_NULL_RETURN_VAL(edge_swipe_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2561 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_swipe_data->base.type == TIZEN_GESTURE_TYPE_EDGE_SWIPE,
2562 EFL_UTIL_ERROR_INVALID_PARAMETER);
2563 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_size == EFL_UTIL_GESTURE_EDGE_SIZE_PARTIAL,
2564 EFL_UTIL_ERROR_INVALID_PARAMETER);
2565 EINA_SAFETY_ON_FALSE_RETURN_VAL(end_point > start_point, EFL_UTIL_ERROR_INVALID_PARAMETER);
2567 edge_swipe_data->edge_size = edge_size;
2568 edge_swipe_data->start_point = start_point;
2569 edge_swipe_data->end_point = end_point;
2571 return EFL_UTIL_ERROR_NONE;
2574 API efl_util_gesture_data
2575 efl_util_gesture_edge_drag_new(efl_util_gesture_h gesture_h, unsigned int fingers, efl_util_gesture_edge_e edge)
2577 Efl_Util_Gesture_Edge_Drag_Grab_Data *data;
2579 if (!gesture_h || gesture_h->init == EINA_FALSE)
2581 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2585 if (edge <= EFL_UTIL_GESTURE_EDGE_NONE || edge > EFL_UTIL_GESTURE_EDGE_LEFT)
2587 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2591 data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Edge_Drag_Grab_Data));
2594 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2595 return NULL; /* LCOV_EXCL_LINE */
2598 data->base.type = TIZEN_GESTURE_TYPE_EDGE_DRAG;
2599 data->fingers = fingers;
2601 data->edge_size = EFL_UTIL_GESTURE_EDGE_SIZE_FULL;
2603 set_last_result(EFL_UTIL_ERROR_NONE);
2605 return (void *)data;
2609 efl_util_gesture_edge_drag_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2611 if (!gesture_h || gesture_h->init == EINA_FALSE)
2613 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2618 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2624 return EFL_UTIL_ERROR_NONE;
2628 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)
2630 Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = data;
2632 EINA_SAFETY_ON_NULL_RETURN_VAL(edge_drag_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2633 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_drag_data->base.type == TIZEN_GESTURE_TYPE_EDGE_DRAG,
2634 EFL_UTIL_ERROR_INVALID_PARAMETER);
2635 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_size == EFL_UTIL_GESTURE_EDGE_SIZE_PARTIAL,
2636 EFL_UTIL_ERROR_INVALID_PARAMETER);
2637 EINA_SAFETY_ON_FALSE_RETURN_VAL(end_point > start_point, EFL_UTIL_ERROR_INVALID_PARAMETER);
2639 edge_drag_data->edge_size = edge_size;
2640 edge_drag_data->start_point = start_point;
2641 edge_drag_data->end_point = end_point;
2643 return EFL_UTIL_ERROR_NONE;
2646 API efl_util_gesture_data
2647 efl_util_gesture_tap_new(efl_util_gesture_h gesture_h, unsigned int fingers, unsigned int repeats)
2649 Efl_Util_Gesture_Tap_Grab_Data *data;
2651 if (!gesture_h || gesture_h->init == EINA_FALSE)
2653 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2657 if (fingers <= 1 || repeats <= 1)
2659 set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED);
2663 data = (Efl_Util_Gesture_Tap_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Tap_Grab_Data));
2666 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2667 return NULL; /* LCOV_EXCL_LINE */
2670 data->base.type = TIZEN_GESTURE_TYPE_TAP;
2671 data->fingers = fingers;
2672 data->repeats = repeats;
2674 set_last_result(EFL_UTIL_ERROR_NONE);
2676 return (void *)data;
2680 efl_util_gesture_tap_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2682 if (!gesture_h || gesture_h->init == EINA_FALSE)
2684 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2689 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2695 return EFL_UTIL_ERROR_NONE;
2698 API efl_util_gesture_data
2699 efl_util_gesture_palm_cover_new(efl_util_gesture_h gesture_h)
2701 Efl_Util_Gesture_Palm_Cover_Grab_Data *data;
2703 if (!gesture_h || gesture_h->init == EINA_FALSE)
2705 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2709 data = (Efl_Util_Gesture_Palm_Cover_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Palm_Cover_Grab_Data));
2712 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2713 return NULL; /* LCOV_EXCL_LINE */
2716 data->base.type = TIZEN_GESTURE_TYPE_PALM_COVER;
2718 set_last_result(EFL_UTIL_ERROR_NONE);
2720 return (void *)data;
2724 efl_util_gesture_palm_cover_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2726 if (!gesture_h || gesture_h->init == EINA_FALSE)
2728 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2733 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2739 return EFL_UTIL_ERROR_NONE;
2742 /* LCOV_EXCL_START */
2744 efl_util_gesture_grab(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2746 int ret = EFL_UTIL_ERROR_NONE;
2747 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2749 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2751 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2752 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2753 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2755 switch (base_data->type)
2757 case TIZEN_GESTURE_TYPE_EDGE_SWIPE:
2758 ret = _efl_util_gesture_grab_edge_swipe(data);
2760 case TIZEN_GESTURE_TYPE_EDGE_DRAG:
2761 ret = _efl_util_gesture_grab_edge_drag(data);
2763 case TIZEN_GESTURE_TYPE_TAP:
2764 ret = _efl_util_gesture_grab_tap(data);
2766 case TIZEN_GESTURE_TYPE_PALM_COVER:
2767 ret = _efl_util_gesture_grab_palm_cover(data);
2770 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2777 efl_util_gesture_ungrab(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2779 int ret = EFL_UTIL_ERROR_NONE;
2780 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2782 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2784 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2785 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2786 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2788 switch (base_data->type)
2790 case TIZEN_GESTURE_TYPE_EDGE_SWIPE:
2791 ret = _efl_util_gesture_ungrab_edge_swipe(data);
2793 case TIZEN_GESTURE_TYPE_EDGE_DRAG:
2794 ret = _efl_util_gesture_ungrab_edge_drag(data);
2796 case TIZEN_GESTURE_TYPE_TAP:
2797 ret = _efl_util_gesture_ungrab_tap(data);
2799 case TIZEN_GESTURE_TYPE_PALM_COVER:
2800 ret = _efl_util_gesture_ungrab_palm_cover(data);
2803 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2808 /* LCOV_EXCL_STOP */
2811 efl_util_gesture_select(efl_util_gesture_h gesture_h, Evas_Object *window, efl_util_gesture_data data)
2813 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2814 Ecore_Wl2_Window *wlwin;
2815 struct wl_surface *surface;
2818 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2820 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2821 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2822 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
2823 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2825 if (base_data->type != TIZEN_GESTURE_TYPE_PALM_COVER)
2826 return EFL_UTIL_ERROR_NOT_SUPPORTED;
2828 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
2829 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
2831 surface = ecore_wl2_window_surface_get(wlwin);
2832 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
2833 EFL_UTIL_ERROR_INVALID_PARAMETER);
2835 tizen_gesture_select_palm_cover(_eflutil.wl.gesture.proto, surface);
2837 while (_eflutil.wl.gesture.request_notified == -1)
2838 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2840 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2841 _eflutil.wl.gesture.request_notified = -1;
2847 efl_util_gesture_deselect(efl_util_gesture_h gesture_h, Evas_Object *window, efl_util_gesture_data data)
2849 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2850 Ecore_Wl2_Window *wlwin;
2851 struct wl_surface *surface;
2854 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2856 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2857 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2858 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
2859 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2861 if (base_data->type != TIZEN_GESTURE_TYPE_PALM_COVER)
2862 return EFL_UTIL_ERROR_NOT_SUPPORTED;
2864 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
2865 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
2867 surface = ecore_wl2_window_surface_get(wlwin);
2868 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
2869 EFL_UTIL_ERROR_INVALID_PARAMETER);
2871 tizen_gesture_deselect_palm_cover(_eflutil.wl.gesture.proto, surface);
2873 while (_eflutil.wl.gesture.request_notified == -1)
2874 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2876 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2877 _eflutil.wl.gesture.request_notified = -1;
2882 /* LCOV_EXCL_START */
2884 efl_util_gesture_activate_set(efl_util_gesture_h gesture_h, unsigned int type, Eina_Bool active)
2888 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2889 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2890 EINA_SAFETY_ON_TRUE_RETURN_VAL(type == EFL_UTIL_GESTURE_TYPE_NONE, EFL_UTIL_ERROR_INVALID_PARAMETER);
2892 tizen_gesture_activate_set(_eflutil.wl.gesture.proto, NULL, type, active);
2894 while (_eflutil.wl.gesture.request_notified == -1)
2895 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2897 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2898 _eflutil.wl.gesture.request_notified = -1;
2902 /* LCOV_EXCL_STOP */
2905 efl_util_gesture_activate_set_on_window(efl_util_gesture_h gesture_h, Evas_Object *window, unsigned int type, Eina_Bool active)
2907 Ecore_Wl2_Window *wlwin;
2908 struct wl_surface *surface;
2911 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2912 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2913 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
2914 EINA_SAFETY_ON_TRUE_RETURN_VAL(type == EFL_UTIL_GESTURE_TYPE_NONE, EFL_UTIL_ERROR_INVALID_PARAMETER);
2916 wlwin = (Ecore_Wl2_Window *)elm_win_wl_window_get(window);
2917 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
2919 surface = ecore_wl2_window_surface_get(wlwin);
2920 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
2921 EFL_UTIL_ERROR_INVALID_PARAMETER);
2923 tizen_gesture_activate_set(_eflutil.wl.gesture.proto, surface, type, active);
2925 while (_eflutil.wl.gesture.request_notified == -1)
2926 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2928 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2929 _eflutil.wl.gesture.request_notified = -1;