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_Wayland.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 struct wl_display *dpy;
189 struct wl_event_queue *queue;
191 Ecore_Fd_Handler *fd_hdl;
195 struct tizen_policy *proto;
196 Eina_Hash *hash_noti_lv;
197 Eina_Hash *hash_scr_mode;
201 struct wl_event_queue *queue;
202 struct screenshooter *screenshooter;
203 struct tizen_screenshooter *tz_screenshooter;
204 struct wayland_tbm_client *tbm_client;
205 Eina_List *output_list;
210 struct tizen_input_device_manager *devicemgr;
211 int request_notified;
215 struct tizen_display_policy *proto;
216 Eina_Hash *hash_brightness;
220 struct tizen_gesture *proto;
221 int request_notified;
228 Eina_List *info_list; /* list of callback info */
229 unsigned int atom; /* x11 atom */
230 } cb_handler[CBH_MAX];
233 static Efl_Util_Data _eflutil =
239 { NULL, NULL, NULL }, /* tizen_policy protocol */
240 { NULL, NULL, NULL, NULL, NULL, 0 }, /* screenshooter protocol */
241 { NULL, -1 }, /* tizen_input_device_manager protocol */
242 { NULL, NULL }, /* display_policy protocol */
243 { NULL, -1, EINA_FALSE } /* tizen_gesture protocol */
246 { NULL, 0 }, /* handler for notification level */
247 { NULL, 0 } /* handler for screen mode */
251 static Eina_Bool _cb_info_add(Evas_Object *win, Efl_Util_Cb cb, void *data, int idx);
252 static Eina_Bool _cb_info_del_by_win(Evas_Object *win, int idx);
253 static Eina_List *_cb_info_list_get(int idx);
254 static Efl_Util_Callback_Info *_cb_info_find_by_win(Evas_Object *win, int idx);
255 static Eina_Bool _wl_init(void);
256 static void _cb_wl_reg_global(void *data, struct wl_registry *reg, unsigned int name, const char *interface, unsigned int version);
257 static void _cb_wl_reg_global_remove(void *data, struct wl_registry *reg, unsigned int name);
258 static void _cb_wl_reg_screenshooter_global(void *data, struct wl_registry *reg, unsigned int name, const char *interface, unsigned int version);
259 static void _cb_wl_reg_screenshooter_global_remove(void *data, struct wl_registry *reg, unsigned int name);
260 static Efl_Util_Callback_Info *_cb_info_find_by_wlsurf(void *wlsurf, int idx);
261 static void _cb_wl_tz_policy_conformant(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface, uint32_t is_conformant);
262 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);
263 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);
264 static void _cb_wl_tz_policy_transient_for_done(void *data, struct tizen_policy *tizen_policy, uint32_t child_id);
265 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);
266 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);
267 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);
268 static void _cb_wl_tz_policy_allowed_aux_hint(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface_resource, int id);
269 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_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);
273 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);
274 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);
275 static void _cb_error(void *data EINA_UNUSED, struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED, uint32_t errorcode);
276 static void _cb_block_expired(void *data EINA_UNUSED, struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED);
278 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);
279 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);
280 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);
281 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);
282 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);
283 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);
284 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);
285 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);
286 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);
289 static const struct wl_registry_listener _wl_reg_listener =
292 _cb_wl_reg_global_remove
295 static const struct wl_registry_listener _wl_reg_screenshooter_listener =
297 _cb_wl_reg_screenshooter_global,
298 _cb_wl_reg_screenshooter_global_remove
301 struct tizen_policy_listener _wl_tz_policy_listener =
303 _cb_wl_tz_policy_conformant,
304 _cb_wl_tz_policy_conformant_area,
305 _cb_wl_tz_policy_notification_done,
306 _cb_wl_tz_policy_transient_for_done,
307 _cb_wl_tz_policy_scr_mode_done,
308 _cb_wl_tz_policy_iconify_state_changed,
309 _cb_wl_tz_policy_supported_aux_hints,
310 _cb_wl_tz_policy_allowed_aux_hint,
311 _cb_wl_tz_policy_aux_message,
314 struct tizen_input_device_manager_listener _wl_tz_devmgr_listener =
322 struct tizen_display_policy_listener _wl_tz_display_policy_listener =
324 _cb_wl_tz_display_policy_brightness_done,
327 struct tizen_gesture_listener _wl_tz_gesture_listener =
329 _cb_gesture_edge_swipe_notify,
330 _cb_gesture_edge_swipe,
331 _cb_gesture_edge_drag_notify,
332 _cb_gesture_edge_drag,
333 _cb_gesture_tap_notify,
335 _cb_gesture_palm_cover_notify,
336 _cb_gesture_palm_cover,
337 _cb_gesture_activate_notify
341 _cb_info_add(Evas_Object *win,
346 Efl_Util_Callback_Info *info;
348 info = _cb_info_find_by_win(win, idx);
351 _eflutil.cb_handler[idx].info_list
352 = eina_list_remove(_eflutil.cb_handler[idx].info_list,
357 info = (Efl_Util_Callback_Info *)calloc(1, sizeof(Efl_Util_Callback_Info));
358 if (!info) return EINA_FALSE;
364 _eflutil.cb_handler[idx].info_list
365 = eina_list_append(_eflutil.cb_handler[idx].info_list,
372 _cb_info_del_by_win(Evas_Object *win,
375 Efl_Util_Callback_Info *info;
377 info = _cb_info_find_by_win(win, idx);
378 if (!info) return EINA_FALSE;
380 _eflutil.cb_handler[idx].info_list
381 = eina_list_remove(_eflutil.cb_handler[idx].info_list,
389 _cb_info_list_get(int idx)
391 return _eflutil.cb_handler[idx].info_list;
394 static Efl_Util_Callback_Info *
395 _cb_info_find_by_win(Evas_Object *win,
399 Efl_Util_Callback_Info *info;
401 l = _cb_info_list_get(idx);
402 EINA_LIST_FOREACH(l, ll, info)
404 if (info->win == win) return info;
413 struct wl_display *display_wrapper = NULL;
414 struct wl_registry *reg = NULL;
416 if (_eflutil.wl.init) return EINA_TRUE;
420 _eflutil.wl.dpy = ecore_wl_display_get();
421 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.dpy, fail);
423 display_wrapper = wl_proxy_create_wrapper(_eflutil.wl.dpy);
424 EINA_SAFETY_ON_NULL_GOTO(display_wrapper, fail);
426 _eflutil.wl.queue = wl_display_create_queue(_eflutil.wl.dpy);
427 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.queue, fail);
429 wl_proxy_set_queue((struct wl_proxy *)display_wrapper, _eflutil.wl.queue);
431 reg = wl_display_get_registry(display_wrapper);
432 wl_proxy_wrapper_destroy(display_wrapper);
433 display_wrapper = NULL;
434 EINA_SAFETY_ON_NULL_GOTO(reg, fail);
436 wl_registry_add_listener(reg, &_wl_reg_listener, NULL);
438 _eflutil.wl.init = EINA_TRUE;
443 wl_proxy_wrapper_destroy(display_wrapper);
445 if (_eflutil.wl.queue)
447 wl_event_queue_destroy(_eflutil.wl.queue);
448 _eflutil.wl.queue = NULL;
456 _cb_wl_output_geometry(void *data, struct wl_output *wl_output, int x, int y,
457 int physical_width, int physical_height, int subpixel,
458 const char *make, const char *model, int transform)
460 Efl_Util_Wl_Output_Info *output = wl_output_get_user_data(wl_output);
461 if (wl_output == output->output)
463 output->offset_x = x;
464 output->offset_y = y;
469 _cb_wl_output_mode(void *data, struct wl_output *wl_output, uint32_t flags,
470 int width, int height, int refresh)
472 Efl_Util_Wl_Output_Info *output = wl_output_get_user_data(wl_output);
473 if (wl_output == output->output && (flags & WL_OUTPUT_MODE_CURRENT))
475 output->width = width;
476 output->height = height;
481 _cb_wl_output_done(void *data, struct wl_output *wl_output)
486 _cb_wl_output_scale(void *data, struct wl_output *wl_output, int32_t factor)
490 static const struct wl_output_listener output_listener =
492 _cb_wl_output_geometry,
499 _cb_wl_screenshot_done(void *data, struct screenshooter *screenshooter)
501 Eina_Bool *shot_done = (Eina_Bool*)data;
503 *shot_done = EINA_TRUE;
506 static const struct screenshooter_listener screenshooter_listener =
508 _cb_wl_screenshot_done
512 _cb_tz_screenshot_format(void *data, struct tizen_screenshooter *tz_screenshooter, uint32_t format)
517 _cb_tz_screenshot_noti(void *data, struct tizen_screenshooter *tz_screenshooter, uint32_t noti)
519 _eflutil.wl.shot.noti = noti;
522 static const struct tizen_screenshooter_listener tz_screenshooter_listener =
524 _cb_tz_screenshot_format,
525 _cb_tz_screenshot_noti
529 _cb_wl_reg_global(void *data,
530 struct wl_registry *reg,
532 const char *interface,
533 unsigned int version)
535 if (!strcmp(interface, "tizen_policy"))
537 struct tizen_policy *proto;
538 proto = wl_registry_bind(reg,
540 &tizen_policy_interface,
544 tizen_policy_add_listener(proto,
545 &_wl_tz_policy_listener,
548 _eflutil.wl.policy.hash_noti_lv = eina_hash_pointer_new(free);
549 _eflutil.wl.policy.hash_scr_mode = eina_hash_pointer_new(free);
550 _eflutil.wl.policy.proto = proto;
552 else if (strcmp(interface, "wl_output") == 0)
554 Efl_Util_Wl_Output_Info *output = calloc(1, sizeof(Efl_Util_Wl_Output_Info));
555 EINA_SAFETY_ON_NULL_RETURN(output);
557 _eflutil.wl.shot.output_list = eina_list_append(_eflutil.wl.shot.output_list, output);
559 output->output = wl_registry_bind(reg, name, &wl_output_interface, version);
560 wl_output_add_listener(output->output, &output_listener, output);
562 else if (strcmp(interface, "tizen_input_device_manager") == 0)
564 _eflutil.wl.devmgr.devicemgr = wl_registry_bind(reg, name, &tizen_input_device_manager_interface, version);
565 tizen_input_device_manager_add_listener(_eflutil.wl.devmgr.devicemgr, &_wl_tz_devmgr_listener, NULL);
567 else if (!strcmp(interface, "tizen_display_policy"))
569 _eflutil.wl.display_policy.proto = wl_registry_bind(reg, name, &tizen_display_policy_interface, version);
570 if (!_eflutil.wl.display_policy.proto) return;
572 tizen_display_policy_add_listener(_eflutil.wl.display_policy.proto,
573 &_wl_tz_display_policy_listener,
576 _eflutil.wl.display_policy.hash_brightness = eina_hash_pointer_new(free);
578 else if (strcmp(interface, "tizen_gesture") == 0)
580 _eflutil.wl.gesture.proto = wl_registry_bind(reg, name, &tizen_gesture_interface, version);
581 tizen_gesture_add_listener(_eflutil.wl.gesture.proto, &_wl_tz_gesture_listener, NULL);
584 /* LCOV_EXCL_START */
586 _cb_wl_reg_global_remove(void *data,
587 struct wl_registry *reg,
590 _eflutil.wl.policy.proto = NULL;
591 eina_hash_free(_eflutil.wl.policy.hash_noti_lv);
592 eina_hash_free(_eflutil.wl.policy.hash_scr_mode);
594 _eflutil.wl.display_policy.proto = NULL;
595 eina_hash_free(_eflutil.wl.display_policy.hash_brightness);
600 _cb_wl_reg_screenshooter_global(void *data,
601 struct wl_registry *reg,
603 const char *interface,
604 unsigned int version)
606 if (strcmp(interface, "screenshooter") == 0)
608 _eflutil.wl.shot.screenshooter = wl_registry_bind(reg, name, &screenshooter_interface, version);
609 screenshooter_add_listener(_eflutil.wl.shot.screenshooter, &screenshooter_listener, NULL);
611 else if (strcmp(interface, "tizen_screenshooter") == 0)
613 _eflutil.wl.shot.tz_screenshooter = wl_registry_bind(reg, name, &tizen_screenshooter_interface, version);
614 tizen_screenshooter_add_listener(_eflutil.wl.shot.tz_screenshooter, &tz_screenshooter_listener, NULL);
616 wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
620 /* LCOV_EXCL_START */
622 _cb_wl_reg_screenshooter_global_remove(void *data,
623 struct wl_registry *reg,
628 static Efl_Util_Callback_Info *
629 _cb_info_find_by_wlsurf(void *wlsurf,
633 Efl_Util_Callback_Info *info;
634 Ecore_Wl_Window *wlwin2 = NULL;
635 void *wlsurf2 = NULL;
637 l = _cb_info_list_get(idx);
638 EINA_LIST_FOREACH(l, ll, info)
640 wlwin2 = elm_win_wl_window_get(info->win);
641 wlsurf2 = ecore_wl_window_surface_get(wlwin2);
642 if (wlsurf== wlsurf2) return info;
649 _cb_wl_tz_policy_conformant(void *data, struct tizen_policy *tizen_policy,
650 struct wl_surface *surface, uint32_t is_conformant)
655 _cb_wl_tz_policy_conformant_area(void *data, struct tizen_policy *tizen_policy,
656 struct wl_surface *surface, uint32_t conformant_part,
657 uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h)
663 _cb_wl_tz_policy_notification_done(void *data,
664 struct tizen_policy *tizen_policy,
665 struct wl_surface *surface,
669 Efl_Util_Wl_Surface_Lv_Info *lv_info;
670 Efl_Util_Callback_Info *cb_info;
672 lv_info = eina_hash_find(_eflutil.wl.policy.hash_noti_lv, &surface);
675 lv_info->level = level;
676 lv_info->wait_for_done = EINA_FALSE;
677 lv_info->state = state;
680 if (state != TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED) return;
682 cb_info = _cb_info_find_by_wlsurf((void *)surface, CBH_NOTI_LEV);
683 if (!cb_info) return;
684 if (!cb_info->cb) return;
686 cb_info->cb(cb_info->win,
687 EFL_UTIL_ERROR_PERMISSION_DENIED,
691 /* LCOV_EXCL_START */
693 _cb_wl_tz_policy_transient_for_done(void *data, struct tizen_policy *tizen_policy, uint32_t child_id)
699 _cb_wl_tz_policy_scr_mode_done(void *data,
700 struct tizen_policy *tizen_policy,
701 struct wl_surface *surface,
706 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
707 Efl_Util_Callback_Info *cb_info;
709 scr_mode_info = eina_hash_find(_eflutil.wl.policy.hash_scr_mode, &surface);
712 scr_mode_info->mode = mode;
713 scr_mode_info->wait_for_done = EINA_FALSE;
714 scr_mode_info->state = state;
717 if (state != TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED) return;
719 cb_info = _cb_info_find_by_wlsurf((void *)surface, CBH_SCR_MODE);
720 if (!cb_info) return;
721 if (!cb_info->cb) return;
723 cb_info->cb(cb_info->win,
724 EFL_UTIL_ERROR_PERMISSION_DENIED,
728 /* LCOV_EXCL_START */
729 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)
733 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)
737 static void _cb_wl_tz_policy_allowed_aux_hint(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface_resource, int id)
741 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)
747 _cb_wl_tz_display_policy_brightness_done(void *data,
748 struct tizen_display_policy *tizen_display_policy,
749 struct wl_surface *surface,
753 Efl_Util_Wl_Surface_Brightness_Info *brightness_info;
755 brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
758 brightness_info->brightness = brightness;
759 brightness_info->wait_for_done = EINA_FALSE;
760 brightness_info->state = state;
765 _cb_window_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
767 Efl_Util_Wl_Surface_Lv_Info *lv_info;
770 if (EINA_UNLIKELY(!lv_info))
773 eina_hash_del(_eflutil.wl.policy.hash_noti_lv, &lv_info->surface, lv_info);
777 efl_util_set_notification_window_level(Evas_Object *window,
778 efl_util_notification_level_e level)
782 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
783 EINA_SAFETY_ON_FALSE_RETURN_VAL((level >= EFL_UTIL_NOTIFICATION_LEVEL_NONE) &&
784 (level <= EFL_UTIL_NOTIFICATION_LEVEL_TOP),
785 EFL_UTIL_ERROR_INVALID_PARAMETER);
787 if (level == EFL_UTIL_NOTIFICATION_LEVEL_1)
789 dlog_print(DLOG_WARN, LOG_TAG,
790 "DEPRECATION WARNING: EFL_UTIL_NOTIFICATION_LEVEL_1 is deprecated and will be removed from next release. Use EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT instead.");
792 else if (level == EFL_UTIL_NOTIFICATION_LEVEL_2)
794 dlog_print(DLOG_WARN, LOG_TAG,
795 "DEPRECATION WARNING: EFL_UTIL_NOTIFICATION_LEVEL_2 is deprecated and will be removed from next release. Use EFL_UTIL_NOTIFICATION_LEVEL_MEDIUM instead.");
797 else if (level == EFL_UTIL_NOTIFICATION_LEVEL_3)
799 dlog_print(DLOG_WARN, LOG_TAG,
800 "DEPRECATION WARNING: EFL_UTIL_NOTIFICATION_LEVEL_3 is deprecated and will be removed from next release. Use EFL_UTIL_NOTIFICATION_LEVEL_TOP instead.");
804 Ecore_Wl_Window *wlwin;
805 struct wl_surface *surface;
806 Efl_Util_Wl_Surface_Lv_Info *lv_info;
807 Ecore_Wl_Window_Type wl_type;
810 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
812 wlwin = elm_win_wl_window_get(window);
813 EINA_SAFETY_ON_NULL_RETURN_VAL(wlwin, EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
815 type = elm_win_type_get(window);
816 if (type != ELM_WIN_NOTIFICATION)
818 wl_type = ecore_wl_window_type_get(wlwin);
819 EINA_SAFETY_ON_FALSE_RETURN_VAL((wl_type == ECORE_WL_WINDOW_TYPE_NOTIFICATION),
820 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
823 while (!_eflutil.wl.policy.proto)
824 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
826 surface = ecore_wl_window_surface_get(wlwin);
827 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
828 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
830 lv_info = eina_hash_find(_eflutil.wl.policy.hash_noti_lv, &surface);
833 lv_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Lv_Info));
834 EINA_SAFETY_ON_NULL_RETURN_VAL(lv_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
836 lv_info->surface = surface;
837 lv_info->level = (int)level;
838 lv_info->wait_for_done = EINA_TRUE;
839 lv_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
840 eina_hash_add(_eflutil.wl.policy.hash_noti_lv,
844 evas_object_event_callback_add(window, EVAS_CALLBACK_DEL,
845 _cb_window_del, lv_info);
849 lv_info->level = (int)level;
850 lv_info->wait_for_done = EINA_TRUE;
851 lv_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
855 tizen_policy_set_notification_level(_eflutil.wl.policy.proto,
856 surface, (int)level);
858 if (lv_info->wait_for_done)
861 while (lv_info->wait_for_done && (count < 3))
864 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
868 if (lv_info->wait_for_done)
870 return EFL_UTIL_ERROR_INVALID_PARAMETER;
874 if (lv_info->state == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
876 return EFL_UTIL_ERROR_PERMISSION_DENIED;
881 return EFL_UTIL_ERROR_NONE;
885 efl_util_get_notification_window_level(Evas_Object *window,
886 efl_util_notification_level_e *level)
890 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
891 EINA_SAFETY_ON_NULL_RETURN_VAL(level, EFL_UTIL_ERROR_INVALID_PARAMETER);
894 Ecore_Wl_Window *wlwin;
895 struct wl_surface *surface;
896 Efl_Util_Wl_Surface_Lv_Info *lv_info;
897 Ecore_Wl_Window_Type wl_type;
900 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
902 wlwin = elm_win_wl_window_get(window);
903 EINA_SAFETY_ON_NULL_RETURN_VAL(wlwin, EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
905 type = elm_win_type_get(window);
906 if (type != ELM_WIN_NOTIFICATION)
908 wl_type = ecore_wl_window_type_get(wlwin);
909 EINA_SAFETY_ON_FALSE_RETURN_VAL((wl_type == ECORE_WL_WINDOW_TYPE_NOTIFICATION),
910 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
913 while (!_eflutil.wl.policy.proto)
914 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
916 surface = ecore_wl_window_surface_get(wlwin);
917 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
918 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
920 lv_info = eina_hash_find(_eflutil.wl.policy.hash_noti_lv, &surface);
923 if (lv_info->wait_for_done)
926 while ((lv_info->wait_for_done) && (count < 3))
929 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
933 if (lv_info->wait_for_done)
935 *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
936 return EFL_UTIL_ERROR_INVALID_PARAMETER;
940 switch (lv_info->level)
942 case TIZEN_POLICY_LEVEL_1: *level = EFL_UTIL_NOTIFICATION_LEVEL_1; break;
943 case TIZEN_POLICY_LEVEL_2: *level = EFL_UTIL_NOTIFICATION_LEVEL_2; break;
944 case TIZEN_POLICY_LEVEL_3: *level = EFL_UTIL_NOTIFICATION_LEVEL_3; break;
945 case TIZEN_POLICY_LEVEL_NONE: *level = EFL_UTIL_NOTIFICATION_LEVEL_NONE; break;
946 case TIZEN_POLICY_LEVEL_DEFAULT: *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT; break;
947 case TIZEN_POLICY_LEVEL_MEDIUM: *level = EFL_UTIL_NOTIFICATION_LEVEL_MEDIUM; break;
948 case TIZEN_POLICY_LEVEL_HIGH: *level = EFL_UTIL_NOTIFICATION_LEVEL_HIGH; break;
949 case TIZEN_POLICY_LEVEL_TOP: *level = EFL_UTIL_NOTIFICATION_LEVEL_TOP; break;
950 default: *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
951 return EFL_UTIL_ERROR_INVALID_PARAMETER;
953 return EFL_UTIL_ERROR_NONE;
956 *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
958 return EFL_UTIL_ERROR_NONE;
962 efl_util_set_notification_window_level_error_cb(Evas_Object *window,
963 efl_util_notification_window_level_error_cb callback,
966 dlog_print(DLOG_WARN, LOG_TAG,
967 "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.");
969 Eina_Bool ret = EINA_FALSE;
971 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
972 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EFL_UTIL_ERROR_INVALID_PARAMETER);
974 ret = _cb_info_add(window,
975 (Efl_Util_Cb)callback,
978 if (!ret) return EFL_UTIL_ERROR_OUT_OF_MEMORY;
980 return EFL_UTIL_ERROR_NONE;
984 efl_util_unset_notification_window_level_error_cb(Evas_Object *window)
986 dlog_print(DLOG_WARN, LOG_TAG,
987 "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.");
989 Eina_Bool ret = EINA_FALSE;
991 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
993 ret = _cb_info_del_by_win(window, CBH_NOTI_LEV);
994 if (!ret) return EFL_UTIL_ERROR_INVALID_PARAMETER;
996 return EFL_UTIL_ERROR_NONE;
1000 efl_util_set_window_opaque_state(Evas_Object *window,
1005 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1006 EINA_SAFETY_ON_FALSE_RETURN_VAL(((opaque >= 0) && (opaque <= 1)),
1007 EFL_UTIL_ERROR_INVALID_PARAMETER);
1009 Ecore_Wl_Window *wlwin;
1010 struct wl_surface *surface;
1012 if (!_eflutil.wl.policy.proto)
1017 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1019 while (!_eflutil.wl.policy.proto && ret != -1)
1020 ret = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1022 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.policy.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
1025 wlwin = elm_win_wl_window_get(window);
1027 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
1029 surface = ecore_wl_window_surface_get(wlwin);
1031 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
1033 tizen_policy_set_opaque_state(_eflutil.wl.policy.proto, surface, opaque);
1035 return EFL_UTIL_ERROR_NONE;
1039 efl_util_set_window_screen_mode(Evas_Object *window,
1040 efl_util_screen_mode_e mode)
1042 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1043 EINA_SAFETY_ON_FALSE_RETURN_VAL(((mode >= EFL_UTIL_SCREEN_MODE_DEFAULT) &&
1044 (mode <= EFL_UTIL_SCREEN_MODE_ALWAYS_ON)),
1045 EFL_UTIL_ERROR_INVALID_PARAMETER);
1047 Ecore_Wl_Window *wlwin;
1048 struct wl_surface *surface;
1049 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
1053 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1055 wlwin = elm_win_wl_window_get(window);
1058 while (!_eflutil.wl.policy.proto)
1059 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1061 surface = ecore_wl_window_surface_get(wlwin);
1062 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1063 EFL_UTIL_ERROR_INVALID_PARAMETER);
1065 scr_mode_info = eina_hash_find(_eflutil.wl.policy.hash_scr_mode, &surface);
1068 scr_mode_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Scr_Mode_Info));
1069 EINA_SAFETY_ON_NULL_RETURN_VAL(scr_mode_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
1071 scr_mode_info->surface = surface;
1072 scr_mode_info->mode = (unsigned int)mode;
1073 scr_mode_info->wait_for_done = EINA_TRUE;
1074 scr_mode_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
1076 eina_hash_add(_eflutil.wl.policy.hash_scr_mode,
1082 scr_mode_info->mode = (unsigned int)mode;
1083 scr_mode_info->wait_for_done = EINA_TRUE;
1084 scr_mode_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
1087 tizen_policy_set_window_screen_mode(_eflutil.wl.policy.proto,
1088 surface, (unsigned int)mode);
1089 if (scr_mode_info->wait_for_done)
1092 while (scr_mode_info->wait_for_done && (count < 3))
1095 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1099 if (scr_mode_info->wait_for_done)
1101 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1105 if (scr_mode_info->state == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
1107 return EFL_UTIL_ERROR_PERMISSION_DENIED;
1112 return EFL_UTIL_ERROR_NONE;
1115 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1119 efl_util_get_window_screen_mode(Evas_Object *window,
1120 efl_util_screen_mode_e *mode)
1122 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1123 EINA_SAFETY_ON_NULL_RETURN_VAL(mode, EFL_UTIL_ERROR_INVALID_PARAMETER);
1125 Ecore_Wl_Window *wlwin;
1126 struct wl_surface *surface;
1127 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
1131 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1133 wlwin = elm_win_wl_window_get(window);
1136 while (!_eflutil.wl.policy.proto)
1137 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1139 surface = ecore_wl_window_surface_get(wlwin);
1140 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1141 EFL_UTIL_ERROR_INVALID_PARAMETER);
1143 scr_mode_info = eina_hash_find(_eflutil.wl.policy.hash_scr_mode, &surface);
1146 if (scr_mode_info->wait_for_done)
1148 while (scr_mode_info->wait_for_done)
1151 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1155 switch (scr_mode_info->mode)
1157 case TIZEN_POLICY_MODE_DEFAULT: *mode = EFL_UTIL_SCREEN_MODE_DEFAULT; break;
1158 case TIZEN_POLICY_MODE_ALWAYS_ON: *mode = EFL_UTIL_SCREEN_MODE_ALWAYS_ON; break;
1159 default: *mode = EFL_UTIL_SCREEN_MODE_DEFAULT;
1160 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1162 return EFL_UTIL_ERROR_NONE;
1166 *mode = EFL_UTIL_SCREEN_MODE_DEFAULT;
1167 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1171 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1175 efl_util_set_window_screen_mode_error_cb(Evas_Object *window,
1176 efl_util_window_screen_mode_error_cb callback,
1179 /* Wearable device cannot use this. */
1180 if (get_tizen_profile() == TIZEN_PROFILE_WEARABLE)
1181 return EFL_UTIL_ERROR_NO_SUCH_DEVICE;
1183 dlog_print(DLOG_WARN, LOG_TAG,
1184 "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.");
1186 Eina_Bool ret = EINA_FALSE;
1188 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1189 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EFL_UTIL_ERROR_INVALID_PARAMETER);
1191 ret = _cb_info_add(window,
1192 (Efl_Util_Cb)callback,
1195 if (!ret) return EFL_UTIL_ERROR_OUT_OF_MEMORY;
1197 return EFL_UTIL_ERROR_NONE;
1201 efl_util_unset_window_screen_mode_error_cb(Evas_Object *window)
1203 /* Wearable device cannot use this. */
1204 if (get_tizen_profile() == TIZEN_PROFILE_WEARABLE)
1205 return EFL_UTIL_ERROR_NO_SUCH_DEVICE;
1207 dlog_print(DLOG_WARN, LOG_TAG,
1208 "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.");
1210 Eina_Bool ret = EINA_FALSE;
1212 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1214 ret = _cb_info_del_by_win(window, CBH_SCR_MODE);
1215 if (!ret) return EFL_UTIL_ERROR_INVALID_PARAMETER;
1217 return EFL_UTIL_ERROR_NONE;
1221 efl_util_set_window_brightness(Evas_Object *window, int brightness)
1223 Ecore_Wl_Window *wlwin;
1224 struct wl_surface *surface;
1225 Efl_Util_Wl_Surface_Brightness_Info *brightness_info;
1228 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1229 EINA_SAFETY_ON_FALSE_RETURN_VAL(brightness <= 100, EFL_UTIL_ERROR_INVALID_PARAMETER);
1232 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1234 wlwin = elm_win_wl_window_get(window);
1237 while (!_eflutil.wl.display_policy.proto)
1238 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1240 surface = ecore_wl_window_surface_get(wlwin);
1241 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1242 EFL_UTIL_ERROR_INVALID_PARAMETER);
1244 brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
1245 if (!brightness_info)
1247 brightness_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Brightness_Info));
1248 EINA_SAFETY_ON_NULL_RETURN_VAL(brightness_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
1250 brightness_info->surface = surface;
1251 brightness_info->brightness = brightness;
1252 brightness_info->wait_for_done = EINA_TRUE;
1253 brightness_info->state = TIZEN_DISPLAY_POLICY_ERROR_STATE_NONE;
1255 eina_hash_add(_eflutil.wl.display_policy.hash_brightness,
1261 brightness_info->brightness = brightness;
1262 brightness_info->wait_for_done = EINA_TRUE;
1263 brightness_info->state = TIZEN_DISPLAY_POLICY_ERROR_STATE_NONE;
1266 tizen_display_policy_set_window_brightness(_eflutil.wl.display_policy.proto,
1267 surface, brightness);
1268 if (brightness_info->wait_for_done)
1271 while (brightness_info->wait_for_done && (count < 3))
1274 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1278 if (brightness_info->wait_for_done)
1280 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1284 if (brightness_info->state == TIZEN_DISPLAY_POLICY_ERROR_STATE_PERMISSION_DENIED)
1286 return EFL_UTIL_ERROR_PERMISSION_DENIED;
1290 return EFL_UTIL_ERROR_NONE;
1293 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1297 efl_util_get_window_brightness(Evas_Object *window, int *brightness)
1299 Ecore_Wl_Window *wlwin;
1300 struct wl_surface *surface;
1301 Efl_Util_Wl_Surface_Brightness_Info *brightness_info;
1304 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1305 EINA_SAFETY_ON_NULL_RETURN_VAL(brightness, EFL_UTIL_ERROR_INVALID_PARAMETER);
1308 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1310 wlwin = elm_win_wl_window_get(window);
1311 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
1313 while (!_eflutil.wl.display_policy.proto)
1314 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1316 surface = ecore_wl_window_surface_get(wlwin);
1317 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1318 EFL_UTIL_ERROR_INVALID_PARAMETER);
1320 brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
1321 if (brightness_info)
1323 if (brightness_info->wait_for_done)
1325 while (brightness_info->wait_for_done)
1328 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1331 *brightness = brightness_info->brightness;
1336 return EFL_UTIL_ERROR_NONE;
1340 struct _efl_util_inputgen_h
1342 unsigned int init_type;
1347 _cb_device_add(void *data EINA_UNUSED,
1348 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1349 uint32_t serial EINA_UNUSED,
1350 const char *identifier EINA_UNUSED,
1351 struct tizen_input_device *device EINA_UNUSED,
1352 struct wl_seat *seat EINA_UNUSED)
1357 /* LCOV_EXCL_START */
1359 _cb_device_remove(void *data EINA_UNUSED,
1360 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1361 uint32_t serial EINA_UNUSED,
1362 const char *identifier EINA_UNUSED,
1363 struct tizen_input_device *device EINA_UNUSED,
1364 struct wl_seat *seat EINA_UNUSED)
1368 /* LCOV_EXCL_STOP */
1371 _cb_error(void *data EINA_UNUSED,
1372 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1375 _eflutil.wl.devmgr.request_notified = errorcode;
1378 /* LCOV_EXCL_START */
1380 _cb_block_expired(void *data EINA_UNUSED,
1381 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED)
1385 /* LCOV_EXCL_STOP */
1387 static efl_util_error_e
1388 _efl_util_input_convert_input_generator_error(int ret)
1392 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE:
1393 return EFL_UTIL_ERROR_NONE;
1394 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NO_PERMISSION:
1395 return EFL_UTIL_ERROR_PERMISSION_DENIED;
1396 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NO_SYSTEM_RESOURCES:
1397 return EFL_UTIL_ERROR_OUT_OF_MEMORY;
1398 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_INVALID_PARAMETER:
1399 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1401 return EFL_UTIL_ERROR_NONE;
1405 API efl_util_inputgen_h
1406 efl_util_input_initialize_generator(unsigned int dev_type)
1408 int ret = EFL_UTIL_ERROR_NONE;
1409 efl_util_inputgen_h inputgen_h = NULL;
1410 unsigned int clas = 0x0;
1413 dev_type & ~(EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN
1414 | EFL_UTIL_INPUT_DEVTYPE_KEYBOARD
1415 | EFL_UTIL_INPUT_DEVTYPE_POINTER))
1417 set_last_result(EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1421 inputgen_h = (efl_util_inputgen_h)calloc(1, sizeof(struct _efl_util_inputgen_h));
1424 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
1428 inputgen_h->init_type |= dev_type;
1431 if (ret == (int)EINA_FALSE)
1433 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1437 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN)
1438 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
1439 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD)
1440 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD;
1441 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_POINTER)
1442 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE;
1444 while (!_eflutil.wl.devmgr.devicemgr)
1445 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1447 tizen_input_device_manager_init_generator(_eflutil.wl.devmgr.devicemgr, clas);
1449 while (_eflutil.wl.devmgr.request_notified == -1)
1450 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1452 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1453 _eflutil.wl.devmgr.request_notified = -1;
1455 set_last_result(ret);
1456 if (ret != TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE)
1470 API efl_util_inputgen_h
1471 efl_util_input_initialize_generator_with_name(unsigned int dev_type, const char *name)
1473 int ret = EFL_UTIL_ERROR_NONE;
1474 efl_util_inputgen_h inputgen_h = NULL;
1475 unsigned int clas = 0x0;
1478 dev_type & ~(EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN
1479 | EFL_UTIL_INPUT_DEVTYPE_KEYBOARD
1480 | EFL_UTIL_INPUT_DEVTYPE_POINTER))
1482 set_last_result(EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1486 inputgen_h = (efl_util_inputgen_h)calloc(1, sizeof(struct _efl_util_inputgen_h));
1489 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
1493 inputgen_h->init_type |= dev_type;
1494 strncpy(inputgen_h->name, name, 31);
1497 if (ret == (int)EINA_FALSE)
1499 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1503 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN)
1504 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
1505 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD)
1506 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD;
1507 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_POINTER)
1508 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE;
1510 while (!_eflutil.wl.devmgr.devicemgr)
1511 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1513 tizen_input_device_manager_init_generator_with_name(_eflutil.wl.devmgr.devicemgr, clas, inputgen_h->name);
1515 while (_eflutil.wl.devmgr.request_notified == -1)
1516 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1518 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1519 _eflutil.wl.devmgr.request_notified = -1;
1521 set_last_result(ret);
1522 if (ret != TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE)
1538 efl_util_input_deinitialize_generator(efl_util_inputgen_h inputgen_h)
1540 int ret = EFL_UTIL_ERROR_NONE;
1541 unsigned int clas = 0x0;
1542 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1544 if (inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN)
1545 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
1546 if (inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD)
1547 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD;
1548 if (inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_POINTER)
1549 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE;
1554 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1556 tizen_input_device_manager_deinit_generator(_eflutil.wl.devmgr.devicemgr, clas);
1558 while (_eflutil.wl.devmgr.request_notified == -1)
1559 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1561 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1562 _eflutil.wl.devmgr.request_notified = -1;
1568 efl_util_input_generate_key(efl_util_inputgen_h inputgen_h, const char *key_name, int pressed)
1570 int ret = EFL_UTIL_ERROR_NONE;
1572 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1573 EINA_SAFETY_ON_NULL_RETURN_VAL(key_name, EFL_UTIL_ERROR_INVALID_PARAMETER);
1574 EINA_SAFETY_ON_FALSE_RETURN_VAL(pressed == 0 || pressed == 1, EFL_UTIL_ERROR_INVALID_PARAMETER);
1575 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1577 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1579 tizen_input_device_manager_generate_key(_eflutil.wl.devmgr.devicemgr, key_name, pressed);
1581 while (_eflutil.wl.devmgr.request_notified == -1)
1582 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1584 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1585 _eflutil.wl.devmgr.request_notified = -1;
1591 efl_util_input_generate_touch(efl_util_inputgen_h inputgen_h, int idx,
1592 efl_util_input_touch_type_e touch_type, int x, int y)
1595 enum tizen_input_device_manager_pointer_event_type type;
1597 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1598 EINA_SAFETY_ON_FALSE_RETURN_VAL(idx >= 0, EFL_UTIL_ERROR_INVALID_PARAMETER);
1599 EINA_SAFETY_ON_FALSE_RETURN_VAL((x > 0 && y > 0), EFL_UTIL_ERROR_INVALID_PARAMETER);
1600 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1602 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1606 case EFL_UTIL_INPUT_TOUCH_BEGIN:
1607 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_BEGIN;
1609 case EFL_UTIL_INPUT_TOUCH_UPDATE:
1610 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_UPDATE;
1612 case EFL_UTIL_INPUT_TOUCH_END:
1613 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_END;
1616 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1619 tizen_input_device_manager_generate_touch(_eflutil.wl.devmgr.devicemgr, type, x, y, idx);
1621 while (_eflutil.wl.devmgr.request_notified == -1)
1622 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1624 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1625 _eflutil.wl.devmgr.request_notified = -1;
1631 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)
1634 enum tizen_input_device_manager_pointer_event_type type;
1636 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1637 EINA_SAFETY_ON_FALSE_RETURN_VAL(buttons > 0, EFL_UTIL_ERROR_INVALID_PARAMETER);
1638 EINA_SAFETY_ON_FALSE_RETURN_VAL((x >= 0 && y >= 0), EFL_UTIL_ERROR_INVALID_PARAMETER);
1639 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_POINTER, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1641 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1643 switch(pointer_type)
1645 case EFL_UTIL_INPUT_POINTER_BUTTON_DOWN:
1646 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_BEGIN;
1648 case EFL_UTIL_INPUT_POINTER_MOVE:
1649 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_UPDATE;
1651 case EFL_UTIL_INPUT_POINTER_BUTTON_UP:
1652 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_END;
1655 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1658 tizen_input_device_manager_generate_pointer(_eflutil.wl.devmgr.devicemgr, type, x, y, buttons);
1660 while (_eflutil.wl.devmgr.request_notified == -1)
1661 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1663 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1664 _eflutil.wl.devmgr.request_notified = -1;
1670 struct _efl_util_screenshot_h
1675 Eina_Bool shot_done;
1680 Eina_Bool auto_rotation;
1683 /* scrrenshot handle */
1684 static efl_util_screenshot_h g_screenshot;
1685 static Eina_Bool shot_mutex_init;
1686 static pthread_mutex_t shot_lock;
1689 _screenshot_mutex_init(void)
1691 if (shot_mutex_init)
1694 if (pthread_mutex_init(&shot_lock, NULL))
1696 fprintf(stderr, "[screenshot] fail: mutex init"); /*LCOV_EXCL_LINE*/
1697 return EINA_FALSE; /*LCOV_EXCL_LINE*/
1700 shot_mutex_init = EINA_TRUE;
1706 _screenshot_mutex_destory(void)
1708 if (!shot_mutex_init)
1711 if (pthread_mutex_destroy(&shot_lock))
1713 fprintf(stderr, "[screenshot] fail: mutex destory"); /*LCOV_EXCL_LINE*/
1714 return EINA_FALSE; /*LCOV_EXCL_LINE*/
1717 shot_mutex_init = EINA_FALSE;
1723 _screenshot_mutex_lock(void)
1725 if (!_screenshot_mutex_init())
1728 pthread_mutex_lock(&shot_lock);
1732 _screenshot_mutex_unlock(void)
1734 pthread_mutex_unlock(&shot_lock);
1737 API efl_util_screenshot_h
1738 efl_util_screenshot_initialize(int width, int height)
1740 efl_util_screenshot_h screenshot = NULL;
1741 struct wl_display *display_wrapper = NULL;
1742 struct wl_registry *reg = NULL;
1745 EINA_SAFETY_ON_FALSE_GOTO(width > 0, fail_param);
1746 EINA_SAFETY_ON_FALSE_GOTO(height > 0, fail_param);
1748 _screenshot_mutex_lock();
1750 if (!_eflutil.wl.shot.screenshooter)
1753 if (ret == (int)EINA_FALSE)
1755 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1756 _screenshot_mutex_unlock();
1759 wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1761 display_wrapper = wl_proxy_create_wrapper(_eflutil.wl.dpy);
1762 EINA_SAFETY_ON_NULL_GOTO(display_wrapper, fail_memory);
1764 _eflutil.wl.shot.queue = wl_display_create_queue(_eflutil.wl.dpy);
1765 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.queue, fail_memory);
1767 wl_proxy_set_queue((struct wl_proxy *)display_wrapper, _eflutil.wl.shot.queue);
1769 reg = wl_display_get_registry(display_wrapper);
1770 wl_proxy_wrapper_destroy(display_wrapper);
1771 display_wrapper = NULL;
1772 EINA_SAFETY_ON_NULL_GOTO(reg, fail_init);
1774 wl_registry_add_listener(reg, &_wl_reg_screenshooter_listener, NULL);
1776 ret = wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
1777 EINA_SAFETY_ON_TRUE_GOTO(ret == -1, fail_init);
1778 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.screenshooter, fail_init);
1779 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.tz_screenshooter, fail_init);
1781 _eflutil.wl.shot.tbm_client = wayland_tbm_client_init(_eflutil.wl.dpy);
1782 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.tbm_client, fail_init);
1785 if (_eflutil.wl.shot.noti == 0)
1787 fprintf(stderr, "[screenshot] fail: privilege error\n"); /* LCOV_EXCL_LINE */
1793 if (g_screenshot->width != width || g_screenshot->height != height)
1795 g_screenshot->width = width;
1796 g_screenshot->height = height;
1799 _screenshot_mutex_unlock();
1801 return g_screenshot;
1804 screenshot = calloc(1, sizeof(struct _efl_util_screenshot_h));
1805 EINA_SAFETY_ON_NULL_GOTO(screenshot, fail_memory);
1807 screenshot->width = width;
1808 screenshot->height = height;
1809 screenshot->auto_rotation = EINA_TRUE;
1811 screenshot->bufmgr = wayland_tbm_client_get_bufmgr(_eflutil.wl.shot.tbm_client);
1812 EINA_SAFETY_ON_NULL_GOTO(screenshot->bufmgr, fail_init);
1814 g_screenshot = screenshot;
1815 set_last_result(EFL_UTIL_ERROR_NONE);
1817 screenshooter_set_user_data(_eflutil.wl.shot.screenshooter, &screenshot->shot_done);
1819 _screenshot_mutex_unlock();
1821 return g_screenshot;
1824 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1827 /* LCOV_EXCL_START */
1828 if (display_wrapper)
1829 wl_proxy_wrapper_destroy(display_wrapper);
1830 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
1834 efl_util_screenshot_deinitialize(screenshot);
1835 _screenshot_mutex_unlock();
1836 set_last_result(EFL_UTIL_ERROR_SCREENSHOT_INIT_FAIL);
1838 /* LCOV_EXCL_STOP */
1842 efl_util_screenshot_deinitialize(efl_util_screenshot_h screenshot)
1844 _screenshot_mutex_lock();
1848 _screenshot_mutex_unlock();
1849 _screenshot_mutex_destory();
1850 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1854 g_screenshot = NULL;
1856 if (_eflutil.wl.shot.queue)
1858 wl_event_queue_destroy(_eflutil.wl.shot.queue);
1859 _eflutil.wl.shot.queue = NULL;
1862 if (_eflutil.wl.shot.screenshooter)
1864 screenshooter_destroy(_eflutil.wl.shot.screenshooter);
1865 _eflutil.wl.shot.screenshooter = NULL;
1867 if (_eflutil.wl.shot.tz_screenshooter)
1869 tizen_screenshooter_destroy(_eflutil.wl.shot.tz_screenshooter);
1870 _eflutil.wl.shot.tz_screenshooter = NULL;
1873 _screenshot_mutex_unlock();
1874 _screenshot_mutex_destory();
1876 return EFL_UTIL_ERROR_NONE;
1881 efl_util_screenshot_take_tbm_surface(efl_util_screenshot_h screenshot)
1883 tbm_surface_h t_surface = NULL;
1884 struct wl_buffer *buffer = NULL;
1885 Efl_Util_Wl_Output_Info *output;
1888 _screenshot_mutex_lock();
1890 if (!screenshot || (screenshot != g_screenshot))
1892 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1893 _screenshot_mutex_unlock();
1897 output = eina_list_nth(_eflutil.wl.shot.output_list, 0);
1900 fprintf(stderr, "[screenshot] fail: no output for screenshot\n"); /* LCOV_EXCL_LINE */
1904 t_surface = tbm_surface_create(screenshot->width, screenshot->height, TBM_FORMAT_XRGB8888);
1907 fprintf(stderr, "[screenshot] fail: tbm_surface_create\n"); /* LCOV_EXCL_LINE */
1911 buffer = wayland_tbm_client_create_buffer(_eflutil.wl.shot.tbm_client, t_surface);
1914 fprintf(stderr, "[screenshot] fail: create wl_buffer for screenshot\n"); /* LCOV_EXCL_LINE */
1918 screenshooter_shoot(_eflutil.wl.shot.screenshooter, output->output, buffer);
1920 screenshot->shot_done = EINA_FALSE;
1921 while (!screenshot->shot_done && ret != -1)
1922 ret = wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
1926 fprintf(stderr, "[screenshot] fail: screenshooter_shoot\n"); /* LCOV_EXCL_LINE */
1930 wl_buffer_destroy(buffer);
1932 /* reset shot_done for next screenshot */
1933 screenshot->shot_done = EINA_FALSE;
1935 set_last_result(EFL_UTIL_ERROR_NONE);
1937 _screenshot_mutex_unlock();
1943 tbm_surface_destroy(t_surface);
1945 wl_buffer_destroy(buffer);
1947 set_last_result(EFL_UTIL_ERROR_SCREENSHOT_EXECUTION_FAIL);
1949 _screenshot_mutex_unlock();
1954 /* LCOV_EXCL_START */
1956 efl_util_screenshot_set_auto_rotation(efl_util_screenshot_h screenshot, int set)
1958 if (!screenshot || (screenshot != g_screenshot))
1959 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1961 if (!(set == 0 || set == 1))
1962 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1965 g_screenshot->auto_rotation = EINA_TRUE;
1967 g_screenshot->auto_rotation = EINA_FALSE;
1969 tizen_screenshooter_set_oneshot_auto_rotation(_eflutil.wl.shot.tz_screenshooter, g_screenshot->auto_rotation);
1971 return EFL_UTIL_ERROR_NONE;
1975 efl_util_screenshot_get_auto_rotation(efl_util_screenshot_h screenshot, int *set)
1977 if (!screenshot || (screenshot != g_screenshot) || !set)
1978 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1980 *set = g_screenshot->auto_rotation;
1982 return EFL_UTIL_ERROR_NONE;
1984 /* LCOV_EXCL_STOP */
1986 struct _efl_util_gesture_h
1991 API int EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = 0;
1992 API int EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = 0;
1993 API int EFL_UTIL_EVENT_GESTURE_TAP = 0;
1994 API int EFL_UTIL_EVENT_GESTURE_PALM_COVER = 0;
1996 /* LCOV_EXCL_START */
1998 _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)
2000 _eflutil.wl.gesture.request_notified = error;
2004 _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)
2006 efl_util_event_gesture_edge_swipe_s *ev = NULL;
2008 ev = (efl_util_event_gesture_edge_swipe_s *)calloc(1, sizeof(*ev));
2013 ev->fingers = fingers;
2018 ecore_event_add(EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE, ev, NULL, NULL);
2022 _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)
2024 _eflutil.wl.gesture.request_notified = error;
2028 _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)
2030 efl_util_event_gesture_edge_drag_s *ev = NULL;
2032 ev = (efl_util_event_gesture_edge_drag_s *)calloc(1, sizeof(*ev));
2037 ev->fingers = fingers;
2042 ecore_event_add(EFL_UTIL_EVENT_GESTURE_EDGE_DRAG, ev, NULL, NULL);
2046 _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)
2048 _eflutil.wl.gesture.request_notified = error;
2052 _cb_gesture_tap(void *data EINA_UNUSED, struct tizen_gesture *tizen_gesture EINA_UNUSED, uint32_t mode, uint32_t fingers, uint32_t repeats)
2054 efl_util_event_gesture_tap_s *ev = NULL;
2056 ev = (efl_util_event_gesture_tap_s *)calloc(1, sizeof(*ev));
2061 ev->fingers = fingers;
2062 ev->repeats = repeats;
2064 ecore_event_add(EFL_UTIL_EVENT_GESTURE_TAP, ev, NULL, NULL);
2066 /* LCOV_EXCL_STOP */
2069 _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)
2071 _eflutil.wl.gesture.request_notified = error;
2074 /* LCOV_EXCL_START */
2076 _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)
2078 efl_util_event_gesture_palm_cover_s *ev = NULL;
2080 ev = (efl_util_event_gesture_palm_cover_s *)calloc(1, sizeof(*ev));
2085 ev->duration = duration;
2089 ev->pressure = wl_fixed_to_int(pressure);
2091 ecore_event_add(EFL_UTIL_EVENT_GESTURE_PALM_COVER, ev, NULL, NULL);
2093 /* LCOV_EXCL_STOP */
2096 _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)
2098 _eflutil.wl.gesture.request_notified = error;
2101 static efl_util_error_e
2102 _efl_util_gesture_convert_error(int ret)
2106 case TIZEN_GESTURE_ERROR_NONE:
2107 return EFL_UTIL_ERROR_NONE;
2108 case TIZEN_GESTURE_ERROR_INVALID_DATA:
2109 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2110 case TIZEN_GESTURE_ERROR_NO_PERMISSION:
2111 return EFL_UTIL_ERROR_PERMISSION_DENIED;
2112 case TIZEN_GESTURE_ERROR_NO_SYSTEM_RESOURCES:
2113 return EFL_UTIL_ERROR_OUT_OF_MEMORY;
2114 case TIZEN_GESTURE_ERROR_GRABBED_ALREADY:
2115 return EFL_UTIL_ERROR_NO_RESOURCE_AVAILABLE;
2116 case TIZEN_GESTURE_ERROR_NOT_SUPPORTED:
2117 return EFL_UTIL_ERROR_NOT_SUPPORTED;
2119 return EFL_UTIL_ERROR_NONE;
2123 /* LCOV_EXCL_START */
2125 _efl_util_gesture_grab_edge_swipe(efl_util_gesture_data data)
2127 int ret = EFL_UTIL_ERROR_NONE;
2128 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2129 Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = NULL;
2130 unsigned int fingers = 0;
2131 unsigned int edge = 0;
2132 unsigned int edge_size = 0;
2133 unsigned int start_point = 0;
2134 unsigned int end_point = 0;
2136 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2138 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2139 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2140 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_SWIPE,
2141 EFL_UTIL_ERROR_INVALID_PARAMETER);
2143 edge_swipe_data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)data;
2145 fingers = edge_swipe_data->fingers;
2146 edge = edge_swipe_data->edge;
2147 edge_size = edge_swipe_data->edge_size;
2148 start_point = edge_swipe_data->start_point;
2149 end_point = edge_swipe_data->end_point;
2151 tizen_gesture_grab_edge_swipe(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2153 while (_eflutil.wl.gesture.request_notified == -1)
2154 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2156 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2157 _eflutil.wl.gesture.request_notified = -1;
2163 _efl_util_gesture_ungrab_edge_swipe(efl_util_gesture_data data)
2165 int ret = EFL_UTIL_ERROR_NONE;
2166 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2167 Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = NULL;
2168 unsigned int fingers = 0;
2169 unsigned int edge = 0;
2170 unsigned int edge_size = 0;
2171 unsigned int start_point = 0;
2172 unsigned int end_point = 0;
2174 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2176 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2177 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2178 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_SWIPE,
2179 EFL_UTIL_ERROR_INVALID_PARAMETER);
2181 edge_swipe_data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)data;
2183 fingers = edge_swipe_data->fingers;
2184 edge = edge_swipe_data->edge;
2185 edge_size = edge_swipe_data->edge_size;
2186 start_point = edge_swipe_data->start_point;
2187 end_point = edge_swipe_data->end_point;
2189 tizen_gesture_ungrab_edge_swipe(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2191 while (_eflutil.wl.gesture.request_notified == -1)
2192 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2194 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2195 _eflutil.wl.gesture.request_notified = -1;
2201 _efl_util_gesture_grab_edge_drag(efl_util_gesture_data data)
2203 int ret = EFL_UTIL_ERROR_NONE;
2204 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2205 Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = NULL;
2206 unsigned int fingers = 0;
2207 unsigned int edge = 0;
2208 unsigned int edge_size = 0;
2209 unsigned int start_point = 0;
2210 unsigned int end_point = 0;
2212 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2214 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2215 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2216 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_DRAG,
2217 EFL_UTIL_ERROR_INVALID_PARAMETER);
2219 edge_drag_data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)data;
2221 fingers = edge_drag_data->fingers;
2222 edge = edge_drag_data->edge;
2223 edge_size = edge_drag_data->edge_size;
2224 start_point = edge_drag_data->start_point;
2225 end_point = edge_drag_data->end_point;
2227 tizen_gesture_grab_edge_drag(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2229 while (_eflutil.wl.gesture.request_notified == -1)
2230 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2232 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2233 _eflutil.wl.gesture.request_notified = -1;
2239 _efl_util_gesture_ungrab_edge_drag(efl_util_gesture_data data)
2241 int ret = EFL_UTIL_ERROR_NONE;
2242 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2243 Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = NULL;
2244 unsigned int fingers = 0;
2245 unsigned int edge = 0;
2246 unsigned int edge_size = 0;
2247 unsigned int start_point = 0;
2248 unsigned int end_point = 0;
2250 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2252 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2253 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2254 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_DRAG,
2255 EFL_UTIL_ERROR_INVALID_PARAMETER);
2257 edge_drag_data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)data;
2259 fingers = edge_drag_data->fingers;
2260 edge = edge_drag_data->edge;
2261 edge_size = edge_drag_data->edge_size;
2262 start_point = edge_drag_data->start_point;
2263 end_point = edge_drag_data->end_point;
2265 tizen_gesture_ungrab_edge_drag(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2267 while (_eflutil.wl.gesture.request_notified == -1)
2268 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2270 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2271 _eflutil.wl.gesture.request_notified = -1;
2278 _efl_util_gesture_grab_tap(efl_util_gesture_data data)
2280 int ret = EFL_UTIL_ERROR_NONE;
2281 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2282 Efl_Util_Gesture_Tap_Grab_Data *tap_data = NULL;
2283 unsigned int fingers = 0;
2284 unsigned int repeats = 0;
2286 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2288 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2289 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2290 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_TAP,
2291 EFL_UTIL_ERROR_INVALID_PARAMETER);
2293 tap_data = (Efl_Util_Gesture_Tap_Grab_Data *)data;
2295 fingers = tap_data->fingers;
2296 repeats = tap_data->repeats;
2298 tizen_gesture_grab_tap(_eflutil.wl.gesture.proto, fingers, repeats);
2300 while (_eflutil.wl.gesture.request_notified == -1)
2301 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2303 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2304 _eflutil.wl.gesture.request_notified = -1;
2310 _efl_util_gesture_ungrab_tap(efl_util_gesture_data data)
2312 int ret = EFL_UTIL_ERROR_NONE;
2313 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2314 Efl_Util_Gesture_Tap_Grab_Data *tap_data = NULL;
2315 unsigned int fingers = 0;
2316 unsigned int repeats = 0;
2318 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2320 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2321 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2322 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_TAP,
2323 EFL_UTIL_ERROR_INVALID_PARAMETER);
2325 tap_data = (Efl_Util_Gesture_Tap_Grab_Data *)data;
2327 fingers = tap_data->fingers;
2328 repeats = tap_data->repeats;
2330 tizen_gesture_ungrab_tap(_eflutil.wl.gesture.proto, fingers, repeats);
2332 while (_eflutil.wl.gesture.request_notified == -1)
2333 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2335 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2336 _eflutil.wl.gesture.request_notified = -1;
2342 _efl_util_gesture_grab_palm_cover(efl_util_gesture_data data)
2344 int ret = EFL_UTIL_ERROR_NONE;
2345 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2347 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2349 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2350 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2351 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_PALM_COVER,
2352 EFL_UTIL_ERROR_INVALID_PARAMETER);
2354 tizen_gesture_grab_palm_cover(_eflutil.wl.gesture.proto);
2356 while (_eflutil.wl.gesture.request_notified == -1)
2357 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2359 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2360 _eflutil.wl.gesture.request_notified = -1;
2366 _efl_util_gesture_ungrab_palm_cover(efl_util_gesture_data data)
2368 int ret = EFL_UTIL_ERROR_NONE;
2369 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2371 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2373 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2374 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2375 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_PALM_COVER,
2376 EFL_UTIL_ERROR_INVALID_PARAMETER);
2378 tizen_gesture_ungrab_palm_cover(_eflutil.wl.gesture.proto);
2380 while (_eflutil.wl.gesture.request_notified == -1)
2381 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2383 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2384 _eflutil.wl.gesture.request_notified = -1;
2390 _efl_util_fd_cb(void *data, Ecore_Fd_Handler *hdl)
2392 if (_eflutil.wl.dpy && _eflutil.wl.queue)
2394 wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2395 return ECORE_CALLBACK_RENEW;
2399 return ECORE_CALLBACK_CANCEL;
2402 /* LCOV_EXCL_STOP */
2404 API efl_util_gesture_h
2405 efl_util_gesture_initialize(void)
2407 efl_util_gesture_h gesture_h = NULL;
2410 gesture_h = (efl_util_gesture_h)calloc(1, sizeof(struct _efl_util_gesture_h));
2413 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2414 goto out; /* LCOV_EXCL_LINE */
2417 if (_wl_init() == (int)EINA_FALSE)
2419 set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED); /* LCOV_EXCL_LINE */
2420 goto out; /* LCOV_EXCL_LINE */
2423 while (!_eflutil.wl.gesture.proto)
2424 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue); /* LCOV_EXCL_LINE */
2426 if (_eflutil.wl.gesture.event_init <= 0)
2428 if (ecore_event_init() <= 0)
2430 set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED); /* LCOV_EXCL_LINE */
2431 goto out; /* LCOV_EXCL_LINE */
2433 EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = ecore_event_type_new();
2434 EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = ecore_event_type_new();
2435 EFL_UTIL_EVENT_GESTURE_TAP = ecore_event_type_new();
2436 EFL_UTIL_EVENT_GESTURE_PALM_COVER = ecore_event_type_new();
2438 dpy_fd = wl_display_get_fd(_eflutil.wl.dpy);
2439 _eflutil.wl.dpy_fd = fcntl(dpy_fd, F_DUPFD_CLOEXEC, 0);
2440 if (_eflutil.wl.dpy_fd >= 0)
2441 _eflutil.wl.fd_hdl = ecore_main_fd_handler_add(_eflutil.wl.dpy_fd,
2442 ECORE_FD_READ | ECORE_FD_WRITE | ECORE_FD_ERROR,
2443 _efl_util_fd_cb, NULL,
2446 _eflutil.wl.gesture.event_init++;
2447 gesture_h->init = EINA_TRUE;
2449 set_last_result(EFL_UTIL_ERROR_NONE);
2453 /* LCOV_EXCL_START */
2460 /* LCOV_EXCL_STOP */
2464 efl_util_gesture_deinitialize(efl_util_gesture_h gesture_h)
2466 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2467 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2472 _eflutil.wl.gesture.event_init--;
2474 if (_eflutil.wl.gesture.event_init <= 0)
2476 _eflutil.wl.gesture.event_init = 0;
2477 ecore_event_shutdown();
2478 EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = 0;
2479 EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = 0;
2480 EFL_UTIL_EVENT_GESTURE_TAP = 0;
2481 EFL_UTIL_EVENT_GESTURE_PALM_COVER = 0;
2482 if (_eflutil.wl.dpy_fd >= 0)
2484 ecore_main_fd_handler_del(_eflutil.wl.fd_hdl);
2485 _eflutil.wl.fd_hdl = NULL;
2486 close(_eflutil.wl.dpy_fd);
2487 _eflutil.wl.dpy_fd = -1;
2491 return EFL_UTIL_ERROR_NONE;
2494 API efl_util_gesture_data
2495 efl_util_gesture_edge_swipe_new(efl_util_gesture_h gesture_h, unsigned int fingers, efl_util_gesture_edge_e edge)
2497 Efl_Util_Gesture_Edge_Swipe_Grab_Data *data;
2499 if (!gesture_h || gesture_h->init == EINA_FALSE)
2501 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2505 if (edge <= EFL_UTIL_GESTURE_EDGE_NONE || edge > EFL_UTIL_GESTURE_EDGE_LEFT)
2507 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2511 data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Edge_Swipe_Grab_Data));
2514 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2515 return NULL; /* LCOV_EXCL_LINE */
2518 data->base.type = TIZEN_GESTURE_TYPE_EDGE_SWIPE;
2519 data->fingers = fingers;
2521 data->edge_size = EFL_UTIL_GESTURE_EDGE_SIZE_FULL;
2523 set_last_result(EFL_UTIL_ERROR_NONE);
2525 return (void *)data;
2529 efl_util_gesture_edge_swipe_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2531 if (!gesture_h || gesture_h->init == EINA_FALSE)
2533 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2538 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2544 return EFL_UTIL_ERROR_NONE;
2548 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)
2550 Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = data;
2552 EINA_SAFETY_ON_NULL_RETURN_VAL(edge_swipe_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2553 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_swipe_data->base.type == TIZEN_GESTURE_TYPE_EDGE_SWIPE,
2554 EFL_UTIL_ERROR_INVALID_PARAMETER);
2555 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_size == EFL_UTIL_GESTURE_EDGE_SIZE_PARTIAL,
2556 EFL_UTIL_ERROR_INVALID_PARAMETER);
2557 EINA_SAFETY_ON_FALSE_RETURN_VAL(end_point > start_point, EFL_UTIL_ERROR_INVALID_PARAMETER);
2559 edge_swipe_data->edge_size = edge_size;
2560 edge_swipe_data->start_point = start_point;
2561 edge_swipe_data->end_point = end_point;
2563 return EFL_UTIL_ERROR_NONE;
2566 API efl_util_gesture_data
2567 efl_util_gesture_edge_drag_new(efl_util_gesture_h gesture_h, unsigned int fingers, efl_util_gesture_edge_e edge)
2569 Efl_Util_Gesture_Edge_Drag_Grab_Data *data;
2571 if (!gesture_h || gesture_h->init == EINA_FALSE)
2573 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2577 if (edge <= EFL_UTIL_GESTURE_EDGE_NONE || edge > EFL_UTIL_GESTURE_EDGE_LEFT)
2579 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2583 data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Edge_Drag_Grab_Data));
2586 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2587 return NULL; /* LCOV_EXCL_LINE */
2590 data->base.type = TIZEN_GESTURE_TYPE_EDGE_DRAG;
2591 data->fingers = fingers;
2593 data->edge_size = EFL_UTIL_GESTURE_EDGE_SIZE_FULL;
2595 set_last_result(EFL_UTIL_ERROR_NONE);
2597 return (void *)data;
2601 efl_util_gesture_edge_drag_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2603 if (!gesture_h || gesture_h->init == EINA_FALSE)
2605 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2610 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2616 return EFL_UTIL_ERROR_NONE;
2620 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)
2622 Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = data;
2624 EINA_SAFETY_ON_NULL_RETURN_VAL(edge_drag_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2625 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_drag_data->base.type == TIZEN_GESTURE_TYPE_EDGE_DRAG,
2626 EFL_UTIL_ERROR_INVALID_PARAMETER);
2627 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_size == EFL_UTIL_GESTURE_EDGE_SIZE_PARTIAL,
2628 EFL_UTIL_ERROR_INVALID_PARAMETER);
2629 EINA_SAFETY_ON_FALSE_RETURN_VAL(end_point > start_point, EFL_UTIL_ERROR_INVALID_PARAMETER);
2631 edge_drag_data->edge_size = edge_size;
2632 edge_drag_data->start_point = start_point;
2633 edge_drag_data->end_point = end_point;
2635 return EFL_UTIL_ERROR_NONE;
2638 API efl_util_gesture_data
2639 efl_util_gesture_tap_new(efl_util_gesture_h gesture_h, unsigned int fingers, unsigned int repeats)
2641 Efl_Util_Gesture_Tap_Grab_Data *data;
2643 if (!gesture_h || gesture_h->init == EINA_FALSE)
2645 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2649 if (fingers <= 1 || repeats <= 1)
2651 set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED);
2655 data = (Efl_Util_Gesture_Tap_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Tap_Grab_Data));
2658 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2659 return NULL; /* LCOV_EXCL_LINE */
2662 data->base.type = TIZEN_GESTURE_TYPE_TAP;
2663 data->fingers = fingers;
2664 data->repeats = repeats;
2666 set_last_result(EFL_UTIL_ERROR_NONE);
2668 return (void *)data;
2672 efl_util_gesture_tap_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2674 if (!gesture_h || gesture_h->init == EINA_FALSE)
2676 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2681 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2687 return EFL_UTIL_ERROR_NONE;
2690 API efl_util_gesture_data
2691 efl_util_gesture_palm_cover_new(efl_util_gesture_h gesture_h)
2693 Efl_Util_Gesture_Palm_Cover_Grab_Data *data;
2695 if (!gesture_h || gesture_h->init == EINA_FALSE)
2697 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2701 data = (Efl_Util_Gesture_Palm_Cover_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Palm_Cover_Grab_Data));
2704 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2705 return NULL; /* LCOV_EXCL_LINE */
2708 data->base.type = TIZEN_GESTURE_TYPE_PALM_COVER;
2710 set_last_result(EFL_UTIL_ERROR_NONE);
2712 return (void *)data;
2716 efl_util_gesture_palm_cover_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2718 if (!gesture_h || gesture_h->init == EINA_FALSE)
2720 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2725 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2731 return EFL_UTIL_ERROR_NONE;
2734 /* LCOV_EXCL_START */
2736 efl_util_gesture_grab(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2738 int ret = EFL_UTIL_ERROR_NONE;
2739 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2741 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2743 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2744 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2745 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2747 switch (base_data->type)
2749 case TIZEN_GESTURE_TYPE_EDGE_SWIPE:
2750 ret = _efl_util_gesture_grab_edge_swipe(data);
2752 case TIZEN_GESTURE_TYPE_EDGE_DRAG:
2753 ret = _efl_util_gesture_grab_edge_drag(data);
2755 case TIZEN_GESTURE_TYPE_TAP:
2756 ret = _efl_util_gesture_grab_tap(data);
2758 case TIZEN_GESTURE_TYPE_PALM_COVER:
2759 ret = _efl_util_gesture_grab_palm_cover(data);
2762 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2769 efl_util_gesture_ungrab(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2771 int ret = EFL_UTIL_ERROR_NONE;
2772 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2774 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2776 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2777 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2778 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2780 switch (base_data->type)
2782 case TIZEN_GESTURE_TYPE_EDGE_SWIPE:
2783 ret = _efl_util_gesture_ungrab_edge_swipe(data);
2785 case TIZEN_GESTURE_TYPE_EDGE_DRAG:
2786 ret = _efl_util_gesture_ungrab_edge_drag(data);
2788 case TIZEN_GESTURE_TYPE_TAP:
2789 ret = _efl_util_gesture_ungrab_tap(data);
2791 case TIZEN_GESTURE_TYPE_PALM_COVER:
2792 ret = _efl_util_gesture_ungrab_palm_cover(data);
2795 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2800 /* LCOV_EXCL_STOP */
2803 efl_util_gesture_select(efl_util_gesture_h gesture_h, Evas_Object *window, efl_util_gesture_data data)
2805 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2806 Ecore_Wl_Window *wlwin;
2807 struct wl_surface *surface;
2810 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2812 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2813 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2814 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
2815 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2817 if (base_data->type != TIZEN_GESTURE_TYPE_PALM_COVER)
2818 return EFL_UTIL_ERROR_NOT_SUPPORTED;
2820 wlwin = elm_win_wl_window_get(window);
2821 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
2823 surface = ecore_wl_window_surface_get(wlwin);
2824 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
2825 EFL_UTIL_ERROR_INVALID_PARAMETER);
2827 tizen_gesture_select_palm_cover(_eflutil.wl.gesture.proto, surface);
2829 while (_eflutil.wl.gesture.request_notified == -1)
2830 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2832 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2833 _eflutil.wl.gesture.request_notified = -1;
2839 efl_util_gesture_deselect(efl_util_gesture_h gesture_h, Evas_Object *window, efl_util_gesture_data data)
2841 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2842 Ecore_Wl_Window *wlwin;
2843 struct wl_surface *surface;
2846 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2848 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2849 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2850 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
2851 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2853 if (base_data->type != TIZEN_GESTURE_TYPE_PALM_COVER)
2854 return EFL_UTIL_ERROR_NOT_SUPPORTED;
2856 wlwin = elm_win_wl_window_get(window);
2857 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
2859 surface = ecore_wl_window_surface_get(wlwin);
2860 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
2861 EFL_UTIL_ERROR_INVALID_PARAMETER);
2863 tizen_gesture_deselect_palm_cover(_eflutil.wl.gesture.proto, surface);
2865 while (_eflutil.wl.gesture.request_notified == -1)
2866 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2868 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2869 _eflutil.wl.gesture.request_notified = -1;
2874 /* LCOV_EXCL_START */
2876 efl_util_gesture_activate_set(efl_util_gesture_h gesture_h, unsigned int type, Eina_Bool active)
2880 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2881 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2882 EINA_SAFETY_ON_TRUE_RETURN_VAL(type == EFL_UTIL_GESTURE_TYPE_NONE, EFL_UTIL_ERROR_INVALID_PARAMETER);
2884 tizen_gesture_activate_set(_eflutil.wl.gesture.proto, NULL, type, active);
2886 while (_eflutil.wl.gesture.request_notified == -1)
2887 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2889 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2890 _eflutil.wl.gesture.request_notified = -1;
2894 /* LCOV_EXCL_STOP */
2897 efl_util_gesture_activate_set_on_window(efl_util_gesture_h gesture_h, Evas_Object *window, unsigned int type, Eina_Bool active)
2899 Ecore_Wl_Window *wlwin;
2900 struct wl_surface *surface;
2903 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2904 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2905 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
2906 EINA_SAFETY_ON_TRUE_RETURN_VAL(type == EFL_UTIL_GESTURE_TYPE_NONE, EFL_UTIL_ERROR_INVALID_PARAMETER);
2908 wlwin = elm_win_wl_window_get(window);
2909 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
2911 surface = ecore_wl_window_surface_get(wlwin);
2912 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
2913 EFL_UTIL_ERROR_INVALID_PARAMETER);
2915 tizen_gesture_activate_set(_eflutil.wl.gesture.proto, surface, type, active);
2917 while (_eflutil.wl.gesture.request_notified == -1)
2918 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2920 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2921 _eflutil.wl.gesture.request_notified = -1;