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);
270 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);
272 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);
274 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);
275 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);
276 static void _cb_error(void *data EINA_UNUSED, struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED, uint32_t errorcode);
277 static void _cb_block_expired(void *data EINA_UNUSED, struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED);
279 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);
280 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);
281 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);
282 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);
283 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);
284 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);
285 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);
286 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);
287 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);
290 static const struct wl_registry_listener _wl_reg_listener =
293 _cb_wl_reg_global_remove
296 static const struct wl_registry_listener _wl_reg_screenshooter_listener =
298 _cb_wl_reg_screenshooter_global,
299 _cb_wl_reg_screenshooter_global_remove
302 struct tizen_policy_listener _wl_tz_policy_listener =
304 _cb_wl_tz_policy_conformant,
305 _cb_wl_tz_policy_conformant_area,
306 _cb_wl_tz_policy_notification_done,
307 _cb_wl_tz_policy_transient_for_done,
308 _cb_wl_tz_policy_scr_mode_done,
309 _cb_wl_tz_policy_iconify_state_changed,
310 _cb_wl_tz_policy_supported_aux_hints,
311 _cb_wl_tz_policy_allowed_aux_hint,
312 _cb_wl_tz_policy_aux_message,
313 _cb_wl_conformant_region,
316 struct tizen_input_device_manager_listener _wl_tz_devmgr_listener =
324 struct tizen_display_policy_listener _wl_tz_display_policy_listener =
326 _cb_wl_tz_display_policy_brightness_done,
329 struct tizen_gesture_listener _wl_tz_gesture_listener =
331 _cb_gesture_edge_swipe_notify,
332 _cb_gesture_edge_swipe,
333 _cb_gesture_edge_drag_notify,
334 _cb_gesture_edge_drag,
335 _cb_gesture_tap_notify,
337 _cb_gesture_palm_cover_notify,
338 _cb_gesture_palm_cover,
339 _cb_gesture_activate_notify
343 _cb_info_add(Evas_Object *win,
348 Efl_Util_Callback_Info *info;
350 info = _cb_info_find_by_win(win, idx);
353 _eflutil.cb_handler[idx].info_list
354 = eina_list_remove(_eflutil.cb_handler[idx].info_list,
359 info = (Efl_Util_Callback_Info *)calloc(1, sizeof(Efl_Util_Callback_Info));
360 if (!info) return EINA_FALSE;
366 _eflutil.cb_handler[idx].info_list
367 = eina_list_append(_eflutil.cb_handler[idx].info_list,
374 _cb_info_del_by_win(Evas_Object *win,
377 Efl_Util_Callback_Info *info;
379 info = _cb_info_find_by_win(win, idx);
380 if (!info) return EINA_FALSE;
382 _eflutil.cb_handler[idx].info_list
383 = eina_list_remove(_eflutil.cb_handler[idx].info_list,
391 _cb_info_list_get(int idx)
393 return _eflutil.cb_handler[idx].info_list;
396 static Efl_Util_Callback_Info *
397 _cb_info_find_by_win(Evas_Object *win,
401 Efl_Util_Callback_Info *info;
403 l = _cb_info_list_get(idx);
404 EINA_LIST_FOREACH(l, ll, info)
406 if (info->win == win) return info;
415 struct wl_display *display_wrapper = NULL;
416 struct wl_registry *reg = NULL;
418 if (_eflutil.wl.init) return EINA_TRUE;
422 _eflutil.wl.dpy = ecore_wl_display_get();
423 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.dpy, fail);
425 display_wrapper = wl_proxy_create_wrapper(_eflutil.wl.dpy);
426 EINA_SAFETY_ON_NULL_GOTO(display_wrapper, fail);
428 _eflutil.wl.queue = wl_display_create_queue(_eflutil.wl.dpy);
429 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.queue, fail);
431 wl_proxy_set_queue((struct wl_proxy *)display_wrapper, _eflutil.wl.queue);
433 reg = wl_display_get_registry(display_wrapper);
434 wl_proxy_wrapper_destroy(display_wrapper);
435 display_wrapper = NULL;
436 EINA_SAFETY_ON_NULL_GOTO(reg, fail);
438 wl_registry_add_listener(reg, &_wl_reg_listener, NULL);
440 _eflutil.wl.init = EINA_TRUE;
445 wl_proxy_wrapper_destroy(display_wrapper);
447 if (_eflutil.wl.queue)
449 wl_event_queue_destroy(_eflutil.wl.queue);
450 _eflutil.wl.queue = NULL;
458 _cb_wl_output_geometry(void *data, struct wl_output *wl_output, int x, int y,
459 int physical_width, int physical_height, int subpixel,
460 const char *make, const char *model, int transform)
462 Efl_Util_Wl_Output_Info *output = wl_output_get_user_data(wl_output);
463 if (wl_output == output->output)
465 output->offset_x = x;
466 output->offset_y = y;
471 _cb_wl_output_mode(void *data, struct wl_output *wl_output, uint32_t flags,
472 int width, int height, int refresh)
474 Efl_Util_Wl_Output_Info *output = wl_output_get_user_data(wl_output);
475 if (wl_output == output->output && (flags & WL_OUTPUT_MODE_CURRENT))
477 output->width = width;
478 output->height = height;
483 _cb_wl_output_done(void *data, struct wl_output *wl_output)
488 _cb_wl_output_scale(void *data, struct wl_output *wl_output, int32_t factor)
492 static const struct wl_output_listener output_listener =
494 _cb_wl_output_geometry,
501 _cb_wl_screenshot_done(void *data, struct screenshooter *screenshooter)
503 Eina_Bool *shot_done = (Eina_Bool*)data;
505 *shot_done = EINA_TRUE;
508 static const struct screenshooter_listener screenshooter_listener =
510 _cb_wl_screenshot_done
514 _cb_tz_screenshot_format(void *data, struct tizen_screenshooter *tz_screenshooter, uint32_t format)
519 _cb_tz_screenshot_noti(void *data, struct tizen_screenshooter *tz_screenshooter, uint32_t noti)
521 _eflutil.wl.shot.noti = noti;
524 static const struct tizen_screenshooter_listener tz_screenshooter_listener =
526 _cb_tz_screenshot_format,
527 _cb_tz_screenshot_noti
531 _cb_wl_reg_global(void *data,
532 struct wl_registry *reg,
534 const char *interface,
535 unsigned int version)
537 if (!strcmp(interface, "tizen_policy"))
539 struct tizen_policy *proto;
540 proto = wl_registry_bind(reg,
542 &tizen_policy_interface,
546 tizen_policy_add_listener(proto,
547 &_wl_tz_policy_listener,
550 _eflutil.wl.policy.hash_noti_lv = eina_hash_pointer_new(free);
551 _eflutil.wl.policy.hash_scr_mode = eina_hash_pointer_new(free);
552 _eflutil.wl.policy.proto = proto;
554 else if (strcmp(interface, "wl_output") == 0)
556 Efl_Util_Wl_Output_Info *output = calloc(1, sizeof(Efl_Util_Wl_Output_Info));
557 EINA_SAFETY_ON_NULL_RETURN(output);
559 _eflutil.wl.shot.output_list = eina_list_append(_eflutil.wl.shot.output_list, output);
561 output->output = wl_registry_bind(reg, name, &wl_output_interface, version);
562 wl_output_add_listener(output->output, &output_listener, output);
564 else if (strcmp(interface, "tizen_input_device_manager") == 0)
566 _eflutil.wl.devmgr.devicemgr = wl_registry_bind(reg, name, &tizen_input_device_manager_interface, version);
567 tizen_input_device_manager_add_listener(_eflutil.wl.devmgr.devicemgr, &_wl_tz_devmgr_listener, NULL);
569 else if (!strcmp(interface, "tizen_display_policy"))
571 _eflutil.wl.display_policy.proto = wl_registry_bind(reg, name, &tizen_display_policy_interface, version);
572 if (!_eflutil.wl.display_policy.proto) return;
574 tizen_display_policy_add_listener(_eflutil.wl.display_policy.proto,
575 &_wl_tz_display_policy_listener,
578 _eflutil.wl.display_policy.hash_brightness = eina_hash_pointer_new(free);
580 else if (strcmp(interface, "tizen_gesture") == 0)
582 _eflutil.wl.gesture.proto = wl_registry_bind(reg, name, &tizen_gesture_interface, version);
583 tizen_gesture_add_listener(_eflutil.wl.gesture.proto, &_wl_tz_gesture_listener, NULL);
586 /* LCOV_EXCL_START */
588 _cb_wl_reg_global_remove(void *data,
589 struct wl_registry *reg,
592 _eflutil.wl.policy.proto = NULL;
593 eina_hash_free(_eflutil.wl.policy.hash_noti_lv);
594 eina_hash_free(_eflutil.wl.policy.hash_scr_mode);
596 _eflutil.wl.display_policy.proto = NULL;
597 eina_hash_free(_eflutil.wl.display_policy.hash_brightness);
602 _cb_wl_reg_screenshooter_global(void *data,
603 struct wl_registry *reg,
605 const char *interface,
606 unsigned int version)
608 if (strcmp(interface, "screenshooter") == 0)
610 _eflutil.wl.shot.screenshooter = wl_registry_bind(reg, name, &screenshooter_interface, version);
611 screenshooter_add_listener(_eflutil.wl.shot.screenshooter, &screenshooter_listener, NULL);
613 else if (strcmp(interface, "tizen_screenshooter") == 0)
615 _eflutil.wl.shot.tz_screenshooter = wl_registry_bind(reg, name, &tizen_screenshooter_interface, version);
616 tizen_screenshooter_add_listener(_eflutil.wl.shot.tz_screenshooter, &tz_screenshooter_listener, NULL);
618 wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
622 /* LCOV_EXCL_START */
624 _cb_wl_reg_screenshooter_global_remove(void *data,
625 struct wl_registry *reg,
630 static Efl_Util_Callback_Info *
631 _cb_info_find_by_wlsurf(void *wlsurf,
635 Efl_Util_Callback_Info *info;
636 Ecore_Wl_Window *wlwin2 = NULL;
637 void *wlsurf2 = NULL;
639 l = _cb_info_list_get(idx);
640 EINA_LIST_FOREACH(l, ll, info)
642 wlwin2 = elm_win_wl_window_get(info->win);
643 wlsurf2 = ecore_wl_window_surface_get(wlwin2);
644 if (wlsurf== wlsurf2) return info;
651 _cb_wl_tz_policy_conformant(void *data, struct tizen_policy *tizen_policy,
652 struct wl_surface *surface, uint32_t is_conformant)
657 _cb_wl_tz_policy_conformant_area(void *data, struct tizen_policy *tizen_policy,
658 struct wl_surface *surface, uint32_t conformant_part,
659 uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h)
665 _cb_wl_tz_policy_notification_done(void *data,
666 struct tizen_policy *tizen_policy,
667 struct wl_surface *surface,
671 Efl_Util_Wl_Surface_Lv_Info *lv_info;
672 Efl_Util_Callback_Info *cb_info;
674 lv_info = eina_hash_find(_eflutil.wl.policy.hash_noti_lv, &surface);
677 lv_info->level = level;
678 lv_info->wait_for_done = EINA_FALSE;
679 lv_info->state = state;
682 if (state != TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED) return;
684 cb_info = _cb_info_find_by_wlsurf((void *)surface, CBH_NOTI_LEV);
685 if (!cb_info) return;
686 if (!cb_info->cb) return;
688 cb_info->cb(cb_info->win,
689 EFL_UTIL_ERROR_PERMISSION_DENIED,
693 /* LCOV_EXCL_START */
695 _cb_wl_tz_policy_transient_for_done(void *data, struct tizen_policy *tizen_policy, uint32_t child_id)
701 _cb_wl_tz_policy_scr_mode_done(void *data,
702 struct tizen_policy *tizen_policy,
703 struct wl_surface *surface,
708 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
709 Efl_Util_Callback_Info *cb_info;
711 scr_mode_info = eina_hash_find(_eflutil.wl.policy.hash_scr_mode, &surface);
714 scr_mode_info->mode = mode;
715 scr_mode_info->wait_for_done = EINA_FALSE;
716 scr_mode_info->state = state;
719 if (state != TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED) return;
721 cb_info = _cb_info_find_by_wlsurf((void *)surface, CBH_SCR_MODE);
722 if (!cb_info) return;
723 if (!cb_info->cb) return;
725 cb_info->cb(cb_info->win,
726 EFL_UTIL_ERROR_PERMISSION_DENIED,
730 /* LCOV_EXCL_START */
731 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)
735 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)
739 static void _cb_wl_tz_policy_allowed_aux_hint(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface_resource, int id)
743 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)
746 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)
752 _cb_wl_tz_display_policy_brightness_done(void *data,
753 struct tizen_display_policy *tizen_display_policy,
754 struct wl_surface *surface,
758 Efl_Util_Wl_Surface_Brightness_Info *brightness_info;
760 brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
763 brightness_info->brightness = brightness;
764 brightness_info->wait_for_done = EINA_FALSE;
765 brightness_info->state = state;
770 _cb_window_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
772 Efl_Util_Wl_Surface_Lv_Info *lv_info;
775 if (EINA_UNLIKELY(!lv_info))
778 eina_hash_del(_eflutil.wl.policy.hash_noti_lv, &lv_info->surface, lv_info);
782 efl_util_set_notification_window_level(Evas_Object *window,
783 efl_util_notification_level_e level)
787 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
788 EINA_SAFETY_ON_FALSE_RETURN_VAL((level >= EFL_UTIL_NOTIFICATION_LEVEL_NONE) &&
789 (level <= EFL_UTIL_NOTIFICATION_LEVEL_TOP),
790 EFL_UTIL_ERROR_INVALID_PARAMETER);
792 if (level == EFL_UTIL_NOTIFICATION_LEVEL_1)
794 dlog_print(DLOG_WARN, LOG_TAG,
795 "DEPRECATION WARNING: EFL_UTIL_NOTIFICATION_LEVEL_1 is deprecated and will be removed from next release. Use EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT instead.");
797 else if (level == EFL_UTIL_NOTIFICATION_LEVEL_2)
799 dlog_print(DLOG_WARN, LOG_TAG,
800 "DEPRECATION WARNING: EFL_UTIL_NOTIFICATION_LEVEL_2 is deprecated and will be removed from next release. Use EFL_UTIL_NOTIFICATION_LEVEL_MEDIUM instead.");
802 else if (level == EFL_UTIL_NOTIFICATION_LEVEL_3)
804 dlog_print(DLOG_WARN, LOG_TAG,
805 "DEPRECATION WARNING: EFL_UTIL_NOTIFICATION_LEVEL_3 is deprecated and will be removed from next release. Use EFL_UTIL_NOTIFICATION_LEVEL_TOP instead.");
809 Ecore_Wl_Window *wlwin;
810 struct wl_surface *surface;
811 Efl_Util_Wl_Surface_Lv_Info *lv_info;
812 Ecore_Wl_Window_Type wl_type;
815 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
817 wlwin = elm_win_wl_window_get(window);
818 EINA_SAFETY_ON_NULL_RETURN_VAL(wlwin, EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
820 type = elm_win_type_get(window);
821 if (type != ELM_WIN_NOTIFICATION)
823 wl_type = ecore_wl_window_type_get(wlwin);
824 EINA_SAFETY_ON_FALSE_RETURN_VAL((wl_type == ECORE_WL_WINDOW_TYPE_NOTIFICATION),
825 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
828 while (!_eflutil.wl.policy.proto)
829 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
831 surface = ecore_wl_window_surface_get(wlwin);
832 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
833 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
835 lv_info = eina_hash_find(_eflutil.wl.policy.hash_noti_lv, &surface);
838 lv_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Lv_Info));
839 EINA_SAFETY_ON_NULL_RETURN_VAL(lv_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
841 lv_info->surface = surface;
842 lv_info->level = (int)level;
843 lv_info->wait_for_done = EINA_TRUE;
844 lv_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
845 eina_hash_add(_eflutil.wl.policy.hash_noti_lv,
849 evas_object_event_callback_add(window, EVAS_CALLBACK_DEL,
850 _cb_window_del, lv_info);
854 lv_info->level = (int)level;
855 lv_info->wait_for_done = EINA_TRUE;
856 lv_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
860 tizen_policy_set_notification_level(_eflutil.wl.policy.proto,
861 surface, (int)level);
863 if (lv_info->wait_for_done)
866 while (lv_info->wait_for_done && (count < 3))
869 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
873 if (lv_info->wait_for_done)
875 return EFL_UTIL_ERROR_INVALID_PARAMETER;
879 if (lv_info->state == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
881 return EFL_UTIL_ERROR_PERMISSION_DENIED;
886 return EFL_UTIL_ERROR_NONE;
890 efl_util_get_notification_window_level(Evas_Object *window,
891 efl_util_notification_level_e *level)
895 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
896 EINA_SAFETY_ON_NULL_RETURN_VAL(level, EFL_UTIL_ERROR_INVALID_PARAMETER);
899 Ecore_Wl_Window *wlwin;
900 struct wl_surface *surface;
901 Efl_Util_Wl_Surface_Lv_Info *lv_info;
902 Ecore_Wl_Window_Type wl_type;
905 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
907 wlwin = elm_win_wl_window_get(window);
908 EINA_SAFETY_ON_NULL_RETURN_VAL(wlwin, EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
910 type = elm_win_type_get(window);
911 if (type != ELM_WIN_NOTIFICATION)
913 wl_type = ecore_wl_window_type_get(wlwin);
914 EINA_SAFETY_ON_FALSE_RETURN_VAL((wl_type == ECORE_WL_WINDOW_TYPE_NOTIFICATION),
915 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
918 while (!_eflutil.wl.policy.proto)
919 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
921 surface = ecore_wl_window_surface_get(wlwin);
922 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
923 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
925 lv_info = eina_hash_find(_eflutil.wl.policy.hash_noti_lv, &surface);
928 if (lv_info->wait_for_done)
931 while ((lv_info->wait_for_done) && (count < 3))
934 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
938 if (lv_info->wait_for_done)
940 *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
941 return EFL_UTIL_ERROR_INVALID_PARAMETER;
945 switch (lv_info->level)
947 case TIZEN_POLICY_LEVEL_1: *level = EFL_UTIL_NOTIFICATION_LEVEL_1; break;
948 case TIZEN_POLICY_LEVEL_2: *level = EFL_UTIL_NOTIFICATION_LEVEL_2; break;
949 case TIZEN_POLICY_LEVEL_3: *level = EFL_UTIL_NOTIFICATION_LEVEL_3; break;
950 case TIZEN_POLICY_LEVEL_NONE: *level = EFL_UTIL_NOTIFICATION_LEVEL_NONE; break;
951 case TIZEN_POLICY_LEVEL_DEFAULT: *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT; break;
952 case TIZEN_POLICY_LEVEL_MEDIUM: *level = EFL_UTIL_NOTIFICATION_LEVEL_MEDIUM; break;
953 case TIZEN_POLICY_LEVEL_HIGH: *level = EFL_UTIL_NOTIFICATION_LEVEL_HIGH; break;
954 case TIZEN_POLICY_LEVEL_TOP: *level = EFL_UTIL_NOTIFICATION_LEVEL_TOP; break;
955 default: *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
956 return EFL_UTIL_ERROR_INVALID_PARAMETER;
958 return EFL_UTIL_ERROR_NONE;
961 *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
963 return EFL_UTIL_ERROR_NONE;
967 efl_util_set_notification_window_level_error_cb(Evas_Object *window,
968 efl_util_notification_window_level_error_cb callback,
971 dlog_print(DLOG_WARN, LOG_TAG,
972 "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.");
974 Eina_Bool ret = EINA_FALSE;
976 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
977 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EFL_UTIL_ERROR_INVALID_PARAMETER);
979 ret = _cb_info_add(window,
980 (Efl_Util_Cb)callback,
983 if (!ret) return EFL_UTIL_ERROR_OUT_OF_MEMORY;
985 return EFL_UTIL_ERROR_NONE;
989 efl_util_unset_notification_window_level_error_cb(Evas_Object *window)
991 dlog_print(DLOG_WARN, LOG_TAG,
992 "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.");
994 Eina_Bool ret = EINA_FALSE;
996 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
998 ret = _cb_info_del_by_win(window, CBH_NOTI_LEV);
999 if (!ret) return EFL_UTIL_ERROR_INVALID_PARAMETER;
1001 return EFL_UTIL_ERROR_NONE;
1005 efl_util_set_window_opaque_state(Evas_Object *window,
1010 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1011 EINA_SAFETY_ON_FALSE_RETURN_VAL(((opaque >= 0) && (opaque <= 1)),
1012 EFL_UTIL_ERROR_INVALID_PARAMETER);
1014 Ecore_Wl_Window *wlwin;
1015 struct wl_surface *surface;
1017 if (!_eflutil.wl.policy.proto)
1022 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1024 while (!_eflutil.wl.policy.proto && ret != -1)
1025 ret = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1027 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.policy.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
1030 wlwin = elm_win_wl_window_get(window);
1032 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
1034 surface = ecore_wl_window_surface_get(wlwin);
1036 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
1038 tizen_policy_set_opaque_state(_eflutil.wl.policy.proto, surface, opaque);
1040 return EFL_UTIL_ERROR_NONE;
1044 efl_util_set_window_screen_mode(Evas_Object *window,
1045 efl_util_screen_mode_e mode)
1047 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1048 EINA_SAFETY_ON_FALSE_RETURN_VAL(((mode >= EFL_UTIL_SCREEN_MODE_DEFAULT) &&
1049 (mode <= EFL_UTIL_SCREEN_MODE_ALWAYS_ON)),
1050 EFL_UTIL_ERROR_INVALID_PARAMETER);
1052 Ecore_Wl_Window *wlwin;
1053 struct wl_surface *surface;
1054 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
1058 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1060 wlwin = elm_win_wl_window_get(window);
1063 while (!_eflutil.wl.policy.proto)
1064 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1066 surface = ecore_wl_window_surface_get(wlwin);
1067 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1068 EFL_UTIL_ERROR_INVALID_PARAMETER);
1070 scr_mode_info = eina_hash_find(_eflutil.wl.policy.hash_scr_mode, &surface);
1073 scr_mode_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Scr_Mode_Info));
1074 EINA_SAFETY_ON_NULL_RETURN_VAL(scr_mode_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
1076 scr_mode_info->surface = surface;
1077 scr_mode_info->mode = (unsigned int)mode;
1078 scr_mode_info->wait_for_done = EINA_TRUE;
1079 scr_mode_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
1081 eina_hash_add(_eflutil.wl.policy.hash_scr_mode,
1087 scr_mode_info->mode = (unsigned int)mode;
1088 scr_mode_info->wait_for_done = EINA_TRUE;
1089 scr_mode_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
1092 tizen_policy_set_window_screen_mode(_eflutil.wl.policy.proto,
1093 surface, (unsigned int)mode);
1094 if (scr_mode_info->wait_for_done)
1097 while (scr_mode_info->wait_for_done && (count < 3))
1100 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1104 if (scr_mode_info->wait_for_done)
1106 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1110 if (scr_mode_info->state == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
1112 return EFL_UTIL_ERROR_PERMISSION_DENIED;
1117 return EFL_UTIL_ERROR_NONE;
1120 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1124 efl_util_get_window_screen_mode(Evas_Object *window,
1125 efl_util_screen_mode_e *mode)
1127 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1128 EINA_SAFETY_ON_NULL_RETURN_VAL(mode, EFL_UTIL_ERROR_INVALID_PARAMETER);
1130 Ecore_Wl_Window *wlwin;
1131 struct wl_surface *surface;
1132 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
1136 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1138 wlwin = elm_win_wl_window_get(window);
1141 while (!_eflutil.wl.policy.proto)
1142 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1144 surface = ecore_wl_window_surface_get(wlwin);
1145 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1146 EFL_UTIL_ERROR_INVALID_PARAMETER);
1148 scr_mode_info = eina_hash_find(_eflutil.wl.policy.hash_scr_mode, &surface);
1151 if (scr_mode_info->wait_for_done)
1153 while (scr_mode_info->wait_for_done)
1156 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1160 switch (scr_mode_info->mode)
1162 case TIZEN_POLICY_MODE_DEFAULT: *mode = EFL_UTIL_SCREEN_MODE_DEFAULT; break;
1163 case TIZEN_POLICY_MODE_ALWAYS_ON: *mode = EFL_UTIL_SCREEN_MODE_ALWAYS_ON; break;
1164 default: *mode = EFL_UTIL_SCREEN_MODE_DEFAULT;
1165 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1167 return EFL_UTIL_ERROR_NONE;
1171 *mode = EFL_UTIL_SCREEN_MODE_DEFAULT;
1172 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1176 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1180 efl_util_set_window_screen_mode_error_cb(Evas_Object *window,
1181 efl_util_window_screen_mode_error_cb callback,
1184 /* Wearable device cannot use this. */
1185 if (get_tizen_profile() == TIZEN_PROFILE_WEARABLE)
1186 return EFL_UTIL_ERROR_NO_SUCH_DEVICE;
1188 dlog_print(DLOG_WARN, LOG_TAG,
1189 "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.");
1191 Eina_Bool ret = EINA_FALSE;
1193 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1194 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EFL_UTIL_ERROR_INVALID_PARAMETER);
1196 ret = _cb_info_add(window,
1197 (Efl_Util_Cb)callback,
1200 if (!ret) return EFL_UTIL_ERROR_OUT_OF_MEMORY;
1202 return EFL_UTIL_ERROR_NONE;
1206 efl_util_unset_window_screen_mode_error_cb(Evas_Object *window)
1208 /* Wearable device cannot use this. */
1209 if (get_tizen_profile() == TIZEN_PROFILE_WEARABLE)
1210 return EFL_UTIL_ERROR_NO_SUCH_DEVICE;
1212 dlog_print(DLOG_WARN, LOG_TAG,
1213 "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.");
1215 Eina_Bool ret = EINA_FALSE;
1217 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1219 ret = _cb_info_del_by_win(window, CBH_SCR_MODE);
1220 if (!ret) return EFL_UTIL_ERROR_INVALID_PARAMETER;
1222 return EFL_UTIL_ERROR_NONE;
1226 efl_util_set_window_brightness(Evas_Object *window, int brightness)
1228 Ecore_Wl_Window *wlwin;
1229 struct wl_surface *surface;
1230 Efl_Util_Wl_Surface_Brightness_Info *brightness_info;
1233 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1234 EINA_SAFETY_ON_FALSE_RETURN_VAL(brightness <= 100, EFL_UTIL_ERROR_INVALID_PARAMETER);
1237 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1239 wlwin = elm_win_wl_window_get(window);
1242 while (!_eflutil.wl.display_policy.proto)
1243 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1245 surface = ecore_wl_window_surface_get(wlwin);
1246 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1247 EFL_UTIL_ERROR_INVALID_PARAMETER);
1249 brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
1250 if (!brightness_info)
1252 brightness_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Brightness_Info));
1253 EINA_SAFETY_ON_NULL_RETURN_VAL(brightness_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
1255 brightness_info->surface = surface;
1256 brightness_info->brightness = brightness;
1257 brightness_info->wait_for_done = EINA_TRUE;
1258 brightness_info->state = TIZEN_DISPLAY_POLICY_ERROR_STATE_NONE;
1260 eina_hash_add(_eflutil.wl.display_policy.hash_brightness,
1266 brightness_info->brightness = brightness;
1267 brightness_info->wait_for_done = EINA_TRUE;
1268 brightness_info->state = TIZEN_DISPLAY_POLICY_ERROR_STATE_NONE;
1271 tizen_display_policy_set_window_brightness(_eflutil.wl.display_policy.proto,
1272 surface, brightness);
1273 if (brightness_info->wait_for_done)
1276 while (brightness_info->wait_for_done && (count < 3))
1279 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1283 if (brightness_info->wait_for_done)
1285 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1289 if (brightness_info->state == TIZEN_DISPLAY_POLICY_ERROR_STATE_PERMISSION_DENIED)
1291 return EFL_UTIL_ERROR_PERMISSION_DENIED;
1295 return EFL_UTIL_ERROR_NONE;
1298 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1302 efl_util_get_window_brightness(Evas_Object *window, int *brightness)
1304 Ecore_Wl_Window *wlwin;
1305 struct wl_surface *surface;
1306 Efl_Util_Wl_Surface_Brightness_Info *brightness_info;
1309 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1310 EINA_SAFETY_ON_NULL_RETURN_VAL(brightness, EFL_UTIL_ERROR_INVALID_PARAMETER);
1313 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1315 wlwin = elm_win_wl_window_get(window);
1316 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
1318 while (!_eflutil.wl.display_policy.proto)
1319 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1321 surface = ecore_wl_window_surface_get(wlwin);
1322 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1323 EFL_UTIL_ERROR_INVALID_PARAMETER);
1325 brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
1326 if (brightness_info)
1328 if (brightness_info->wait_for_done)
1330 while (brightness_info->wait_for_done)
1333 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1336 *brightness = brightness_info->brightness;
1341 return EFL_UTIL_ERROR_NONE;
1345 struct _efl_util_inputgen_h
1347 unsigned int init_type;
1352 _cb_device_add(void *data EINA_UNUSED,
1353 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1354 uint32_t serial EINA_UNUSED,
1355 const char *identifier EINA_UNUSED,
1356 struct tizen_input_device *device EINA_UNUSED,
1357 struct wl_seat *seat EINA_UNUSED)
1362 /* LCOV_EXCL_START */
1364 _cb_device_remove(void *data EINA_UNUSED,
1365 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1366 uint32_t serial EINA_UNUSED,
1367 const char *identifier EINA_UNUSED,
1368 struct tizen_input_device *device EINA_UNUSED,
1369 struct wl_seat *seat EINA_UNUSED)
1373 /* LCOV_EXCL_STOP */
1376 _cb_error(void *data EINA_UNUSED,
1377 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1380 _eflutil.wl.devmgr.request_notified = errorcode;
1383 /* LCOV_EXCL_START */
1385 _cb_block_expired(void *data EINA_UNUSED,
1386 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED)
1390 /* LCOV_EXCL_STOP */
1392 static efl_util_error_e
1393 _efl_util_input_convert_input_generator_error(int ret)
1397 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE:
1398 return EFL_UTIL_ERROR_NONE;
1399 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NO_PERMISSION:
1400 return EFL_UTIL_ERROR_PERMISSION_DENIED;
1401 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NO_SYSTEM_RESOURCES:
1402 return EFL_UTIL_ERROR_OUT_OF_MEMORY;
1403 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_INVALID_PARAMETER:
1404 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1406 return EFL_UTIL_ERROR_NONE;
1410 API efl_util_inputgen_h
1411 efl_util_input_initialize_generator(unsigned int dev_type)
1413 int ret = EFL_UTIL_ERROR_NONE;
1414 efl_util_inputgen_h inputgen_h = NULL;
1415 unsigned int clas = 0x0;
1418 dev_type & ~(EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN
1419 | EFL_UTIL_INPUT_DEVTYPE_KEYBOARD
1420 | EFL_UTIL_INPUT_DEVTYPE_POINTER))
1422 set_last_result(EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1426 inputgen_h = (efl_util_inputgen_h)calloc(1, sizeof(struct _efl_util_inputgen_h));
1429 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
1433 inputgen_h->init_type |= dev_type;
1436 if (ret == (int)EINA_FALSE)
1438 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1442 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN)
1443 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
1444 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD)
1445 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD;
1446 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_POINTER)
1447 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE;
1449 while (!_eflutil.wl.devmgr.devicemgr)
1450 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1452 tizen_input_device_manager_init_generator(_eflutil.wl.devmgr.devicemgr, clas);
1454 while (_eflutil.wl.devmgr.request_notified == -1)
1455 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1457 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1458 _eflutil.wl.devmgr.request_notified = -1;
1460 set_last_result(ret);
1461 if (ret != TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE)
1475 API efl_util_inputgen_h
1476 efl_util_input_initialize_generator_with_name(unsigned int dev_type, const char *name)
1478 int ret = EFL_UTIL_ERROR_NONE;
1479 efl_util_inputgen_h inputgen_h = NULL;
1480 unsigned int clas = 0x0;
1483 dev_type & ~(EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN
1484 | EFL_UTIL_INPUT_DEVTYPE_KEYBOARD
1485 | EFL_UTIL_INPUT_DEVTYPE_POINTER))
1487 set_last_result(EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1491 inputgen_h = (efl_util_inputgen_h)calloc(1, sizeof(struct _efl_util_inputgen_h));
1494 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
1498 inputgen_h->init_type |= dev_type;
1499 strncpy(inputgen_h->name, name, 31);
1502 if (ret == (int)EINA_FALSE)
1504 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1508 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN)
1509 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
1510 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD)
1511 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD;
1512 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_POINTER)
1513 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE;
1515 while (!_eflutil.wl.devmgr.devicemgr)
1516 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1518 tizen_input_device_manager_init_generator_with_name(_eflutil.wl.devmgr.devicemgr, clas, inputgen_h->name);
1520 while (_eflutil.wl.devmgr.request_notified == -1)
1521 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1523 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1524 _eflutil.wl.devmgr.request_notified = -1;
1526 set_last_result(ret);
1527 if (ret != TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE)
1543 efl_util_input_deinitialize_generator(efl_util_inputgen_h inputgen_h)
1545 int ret = EFL_UTIL_ERROR_NONE;
1546 unsigned int clas = 0x0;
1547 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1549 if (inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN)
1550 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
1551 if (inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD)
1552 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD;
1553 if (inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_POINTER)
1554 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE;
1559 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1561 tizen_input_device_manager_deinit_generator(_eflutil.wl.devmgr.devicemgr, clas);
1563 while (_eflutil.wl.devmgr.request_notified == -1)
1564 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1566 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1567 _eflutil.wl.devmgr.request_notified = -1;
1573 efl_util_input_generate_key(efl_util_inputgen_h inputgen_h, const char *key_name, int pressed)
1575 int ret = EFL_UTIL_ERROR_NONE;
1577 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1578 EINA_SAFETY_ON_NULL_RETURN_VAL(key_name, EFL_UTIL_ERROR_INVALID_PARAMETER);
1579 EINA_SAFETY_ON_FALSE_RETURN_VAL(pressed == 0 || pressed == 1, EFL_UTIL_ERROR_INVALID_PARAMETER);
1580 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1582 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1584 tizen_input_device_manager_generate_key(_eflutil.wl.devmgr.devicemgr, key_name, pressed);
1586 while (_eflutil.wl.devmgr.request_notified == -1)
1587 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1589 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1590 _eflutil.wl.devmgr.request_notified = -1;
1596 efl_util_input_generate_touch(efl_util_inputgen_h inputgen_h, int idx,
1597 efl_util_input_touch_type_e touch_type, int x, int y)
1600 enum tizen_input_device_manager_pointer_event_type type;
1602 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1603 EINA_SAFETY_ON_FALSE_RETURN_VAL(idx >= 0, EFL_UTIL_ERROR_INVALID_PARAMETER);
1604 EINA_SAFETY_ON_FALSE_RETURN_VAL((x > 0 && y > 0), EFL_UTIL_ERROR_INVALID_PARAMETER);
1605 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1607 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1611 case EFL_UTIL_INPUT_TOUCH_BEGIN:
1612 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_BEGIN;
1614 case EFL_UTIL_INPUT_TOUCH_UPDATE:
1615 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_UPDATE;
1617 case EFL_UTIL_INPUT_TOUCH_END:
1618 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_END;
1621 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1624 tizen_input_device_manager_generate_touch(_eflutil.wl.devmgr.devicemgr, type, x, y, idx);
1626 while (_eflutil.wl.devmgr.request_notified == -1)
1627 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1629 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1630 _eflutil.wl.devmgr.request_notified = -1;
1636 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)
1639 enum tizen_input_device_manager_pointer_event_type type;
1641 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1642 EINA_SAFETY_ON_FALSE_RETURN_VAL(buttons > 0, EFL_UTIL_ERROR_INVALID_PARAMETER);
1643 EINA_SAFETY_ON_FALSE_RETURN_VAL((x >= 0 && y >= 0), EFL_UTIL_ERROR_INVALID_PARAMETER);
1644 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_POINTER, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1646 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1648 switch(pointer_type)
1650 case EFL_UTIL_INPUT_POINTER_BUTTON_DOWN:
1651 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_BEGIN;
1653 case EFL_UTIL_INPUT_POINTER_MOVE:
1654 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_UPDATE;
1656 case EFL_UTIL_INPUT_POINTER_BUTTON_UP:
1657 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_END;
1660 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1663 tizen_input_device_manager_generate_pointer(_eflutil.wl.devmgr.devicemgr, type, x, y, buttons);
1665 while (_eflutil.wl.devmgr.request_notified == -1)
1666 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1668 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1669 _eflutil.wl.devmgr.request_notified = -1;
1675 struct _efl_util_screenshot_h
1680 Eina_Bool shot_done;
1685 Eina_Bool auto_rotation;
1688 /* scrrenshot handle */
1689 static efl_util_screenshot_h g_screenshot;
1690 static Eina_Bool shot_mutex_init;
1691 static pthread_mutex_t shot_lock;
1694 _screenshot_mutex_init(void)
1696 if (shot_mutex_init)
1699 if (pthread_mutex_init(&shot_lock, NULL))
1701 fprintf(stderr, "[screenshot] fail: mutex init"); /*LCOV_EXCL_LINE*/
1702 return EINA_FALSE; /*LCOV_EXCL_LINE*/
1705 shot_mutex_init = EINA_TRUE;
1711 _screenshot_mutex_destory(void)
1713 if (!shot_mutex_init)
1716 if (pthread_mutex_destroy(&shot_lock))
1718 fprintf(stderr, "[screenshot] fail: mutex destory"); /*LCOV_EXCL_LINE*/
1719 return EINA_FALSE; /*LCOV_EXCL_LINE*/
1722 shot_mutex_init = EINA_FALSE;
1728 _screenshot_mutex_lock(void)
1730 if (!_screenshot_mutex_init())
1733 pthread_mutex_lock(&shot_lock);
1737 _screenshot_mutex_unlock(void)
1739 pthread_mutex_unlock(&shot_lock);
1742 API efl_util_screenshot_h
1743 efl_util_screenshot_initialize(int width, int height)
1745 efl_util_screenshot_h screenshot = NULL;
1746 struct wl_display *display_wrapper = NULL;
1747 struct wl_registry *reg = NULL;
1750 EINA_SAFETY_ON_FALSE_GOTO(width > 0, fail_param);
1751 EINA_SAFETY_ON_FALSE_GOTO(height > 0, fail_param);
1753 _screenshot_mutex_lock();
1755 if (!_eflutil.wl.shot.screenshooter)
1758 if (ret == (int)EINA_FALSE)
1760 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1761 _screenshot_mutex_unlock();
1764 wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1766 display_wrapper = wl_proxy_create_wrapper(_eflutil.wl.dpy);
1767 EINA_SAFETY_ON_NULL_GOTO(display_wrapper, fail_memory);
1769 _eflutil.wl.shot.queue = wl_display_create_queue(_eflutil.wl.dpy);
1770 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.queue, fail_memory);
1772 wl_proxy_set_queue((struct wl_proxy *)display_wrapper, _eflutil.wl.shot.queue);
1774 reg = wl_display_get_registry(display_wrapper);
1775 wl_proxy_wrapper_destroy(display_wrapper);
1776 display_wrapper = NULL;
1777 EINA_SAFETY_ON_NULL_GOTO(reg, fail_init);
1779 wl_registry_add_listener(reg, &_wl_reg_screenshooter_listener, NULL);
1781 ret = wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
1782 EINA_SAFETY_ON_TRUE_GOTO(ret == -1, fail_init);
1783 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.screenshooter, fail_init);
1784 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.tz_screenshooter, fail_init);
1786 _eflutil.wl.shot.tbm_client = wayland_tbm_client_init(_eflutil.wl.dpy);
1787 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.tbm_client, fail_init);
1790 if (_eflutil.wl.shot.noti == 0)
1792 fprintf(stderr, "[screenshot] fail: privilege error\n"); /* LCOV_EXCL_LINE */
1798 if (g_screenshot->width != width || g_screenshot->height != height)
1800 g_screenshot->width = width;
1801 g_screenshot->height = height;
1804 _screenshot_mutex_unlock();
1806 return g_screenshot;
1809 screenshot = calloc(1, sizeof(struct _efl_util_screenshot_h));
1810 EINA_SAFETY_ON_NULL_GOTO(screenshot, fail_memory);
1812 screenshot->width = width;
1813 screenshot->height = height;
1814 screenshot->auto_rotation = EINA_TRUE;
1816 screenshot->bufmgr = wayland_tbm_client_get_bufmgr(_eflutil.wl.shot.tbm_client);
1817 EINA_SAFETY_ON_NULL_GOTO(screenshot->bufmgr, fail_init);
1819 g_screenshot = screenshot;
1820 set_last_result(EFL_UTIL_ERROR_NONE);
1822 screenshooter_set_user_data(_eflutil.wl.shot.screenshooter, &screenshot->shot_done);
1824 _screenshot_mutex_unlock();
1826 return g_screenshot;
1829 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1832 /* LCOV_EXCL_START */
1833 if (display_wrapper)
1834 wl_proxy_wrapper_destroy(display_wrapper);
1835 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
1839 efl_util_screenshot_deinitialize(screenshot);
1840 _screenshot_mutex_unlock();
1841 set_last_result(EFL_UTIL_ERROR_SCREENSHOT_INIT_FAIL);
1843 /* LCOV_EXCL_STOP */
1847 efl_util_screenshot_deinitialize(efl_util_screenshot_h screenshot)
1849 _screenshot_mutex_lock();
1853 _screenshot_mutex_unlock();
1854 _screenshot_mutex_destory();
1855 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1859 g_screenshot = NULL;
1861 if (_eflutil.wl.shot.queue)
1863 wl_event_queue_destroy(_eflutil.wl.shot.queue);
1864 _eflutil.wl.shot.queue = NULL;
1867 if (_eflutil.wl.shot.screenshooter)
1869 screenshooter_destroy(_eflutil.wl.shot.screenshooter);
1870 _eflutil.wl.shot.screenshooter = NULL;
1872 if (_eflutil.wl.shot.tz_screenshooter)
1874 tizen_screenshooter_destroy(_eflutil.wl.shot.tz_screenshooter);
1875 _eflutil.wl.shot.tz_screenshooter = NULL;
1878 _screenshot_mutex_unlock();
1879 _screenshot_mutex_destory();
1881 return EFL_UTIL_ERROR_NONE;
1886 efl_util_screenshot_take_tbm_surface(efl_util_screenshot_h screenshot)
1888 tbm_surface_h t_surface = NULL;
1889 struct wl_buffer *buffer = NULL;
1890 Efl_Util_Wl_Output_Info *output;
1893 _screenshot_mutex_lock();
1895 if (!screenshot || (screenshot != g_screenshot))
1897 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1898 _screenshot_mutex_unlock();
1902 output = eina_list_nth(_eflutil.wl.shot.output_list, 0);
1905 fprintf(stderr, "[screenshot] fail: no output for screenshot\n"); /* LCOV_EXCL_LINE */
1909 t_surface = tbm_surface_create(screenshot->width, screenshot->height, TBM_FORMAT_XRGB8888);
1912 fprintf(stderr, "[screenshot] fail: tbm_surface_create\n"); /* LCOV_EXCL_LINE */
1916 buffer = wayland_tbm_client_create_buffer(_eflutil.wl.shot.tbm_client, t_surface);
1919 fprintf(stderr, "[screenshot] fail: create wl_buffer for screenshot\n"); /* LCOV_EXCL_LINE */
1923 screenshooter_shoot(_eflutil.wl.shot.screenshooter, output->output, buffer);
1925 screenshot->shot_done = EINA_FALSE;
1926 while (!screenshot->shot_done && ret != -1)
1927 ret = wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
1931 fprintf(stderr, "[screenshot] fail: screenshooter_shoot\n"); /* LCOV_EXCL_LINE */
1935 wl_buffer_destroy(buffer);
1937 /* reset shot_done for next screenshot */
1938 screenshot->shot_done = EINA_FALSE;
1940 set_last_result(EFL_UTIL_ERROR_NONE);
1942 _screenshot_mutex_unlock();
1948 tbm_surface_destroy(t_surface);
1950 wl_buffer_destroy(buffer);
1952 set_last_result(EFL_UTIL_ERROR_SCREENSHOT_EXECUTION_FAIL);
1954 _screenshot_mutex_unlock();
1959 /* LCOV_EXCL_START */
1961 efl_util_screenshot_set_auto_rotation(efl_util_screenshot_h screenshot, int set)
1963 if (!screenshot || (screenshot != g_screenshot))
1964 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1966 if (!(set == 0 || set == 1))
1967 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1970 g_screenshot->auto_rotation = EINA_TRUE;
1972 g_screenshot->auto_rotation = EINA_FALSE;
1974 tizen_screenshooter_set_oneshot_auto_rotation(_eflutil.wl.shot.tz_screenshooter, g_screenshot->auto_rotation);
1976 return EFL_UTIL_ERROR_NONE;
1980 efl_util_screenshot_get_auto_rotation(efl_util_screenshot_h screenshot, int *set)
1982 if (!screenshot || (screenshot != g_screenshot) || !set)
1983 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1985 *set = g_screenshot->auto_rotation;
1987 return EFL_UTIL_ERROR_NONE;
1989 /* LCOV_EXCL_STOP */
1991 struct _efl_util_gesture_h
1996 API int EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = 0;
1997 API int EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = 0;
1998 API int EFL_UTIL_EVENT_GESTURE_TAP = 0;
1999 API int EFL_UTIL_EVENT_GESTURE_PALM_COVER = 0;
2001 /* LCOV_EXCL_START */
2003 _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)
2005 _eflutil.wl.gesture.request_notified = error;
2009 _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)
2011 efl_util_event_gesture_edge_swipe_s *ev = NULL;
2013 ev = (efl_util_event_gesture_edge_swipe_s *)calloc(1, sizeof(*ev));
2018 ev->fingers = fingers;
2023 ecore_event_add(EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE, ev, NULL, NULL);
2027 _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)
2029 _eflutil.wl.gesture.request_notified = error;
2033 _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)
2035 efl_util_event_gesture_edge_drag_s *ev = NULL;
2037 ev = (efl_util_event_gesture_edge_drag_s *)calloc(1, sizeof(*ev));
2042 ev->fingers = fingers;
2047 ecore_event_add(EFL_UTIL_EVENT_GESTURE_EDGE_DRAG, ev, NULL, NULL);
2051 _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)
2053 _eflutil.wl.gesture.request_notified = error;
2057 _cb_gesture_tap(void *data EINA_UNUSED, struct tizen_gesture *tizen_gesture EINA_UNUSED, uint32_t mode, uint32_t fingers, uint32_t repeats)
2059 efl_util_event_gesture_tap_s *ev = NULL;
2061 ev = (efl_util_event_gesture_tap_s *)calloc(1, sizeof(*ev));
2066 ev->fingers = fingers;
2067 ev->repeats = repeats;
2069 ecore_event_add(EFL_UTIL_EVENT_GESTURE_TAP, ev, NULL, NULL);
2071 /* LCOV_EXCL_STOP */
2074 _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)
2076 _eflutil.wl.gesture.request_notified = error;
2079 /* LCOV_EXCL_START */
2081 _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)
2083 efl_util_event_gesture_palm_cover_s *ev = NULL;
2085 ev = (efl_util_event_gesture_palm_cover_s *)calloc(1, sizeof(*ev));
2090 ev->duration = duration;
2094 ev->pressure = wl_fixed_to_int(pressure);
2096 ecore_event_add(EFL_UTIL_EVENT_GESTURE_PALM_COVER, ev, NULL, NULL);
2098 /* LCOV_EXCL_STOP */
2101 _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)
2103 _eflutil.wl.gesture.request_notified = error;
2106 static efl_util_error_e
2107 _efl_util_gesture_convert_error(int ret)
2111 case TIZEN_GESTURE_ERROR_NONE:
2112 return EFL_UTIL_ERROR_NONE;
2113 case TIZEN_GESTURE_ERROR_INVALID_DATA:
2114 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2115 case TIZEN_GESTURE_ERROR_NO_PERMISSION:
2116 return EFL_UTIL_ERROR_PERMISSION_DENIED;
2117 case TIZEN_GESTURE_ERROR_NO_SYSTEM_RESOURCES:
2118 return EFL_UTIL_ERROR_OUT_OF_MEMORY;
2119 case TIZEN_GESTURE_ERROR_GRABBED_ALREADY:
2120 return EFL_UTIL_ERROR_NO_RESOURCE_AVAILABLE;
2121 case TIZEN_GESTURE_ERROR_NOT_SUPPORTED:
2122 return EFL_UTIL_ERROR_NOT_SUPPORTED;
2124 return EFL_UTIL_ERROR_NONE;
2128 /* LCOV_EXCL_START */
2130 _efl_util_gesture_grab_edge_swipe(efl_util_gesture_data data)
2132 int ret = EFL_UTIL_ERROR_NONE;
2133 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2134 Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = NULL;
2135 unsigned int fingers = 0;
2136 unsigned int edge = 0;
2137 unsigned int edge_size = 0;
2138 unsigned int start_point = 0;
2139 unsigned int end_point = 0;
2141 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2143 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2144 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2145 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_SWIPE,
2146 EFL_UTIL_ERROR_INVALID_PARAMETER);
2148 edge_swipe_data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)data;
2150 fingers = edge_swipe_data->fingers;
2151 edge = edge_swipe_data->edge;
2152 edge_size = edge_swipe_data->edge_size;
2153 start_point = edge_swipe_data->start_point;
2154 end_point = edge_swipe_data->end_point;
2156 tizen_gesture_grab_edge_swipe(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2158 while (_eflutil.wl.gesture.request_notified == -1)
2159 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2161 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2162 _eflutil.wl.gesture.request_notified = -1;
2168 _efl_util_gesture_ungrab_edge_swipe(efl_util_gesture_data data)
2170 int ret = EFL_UTIL_ERROR_NONE;
2171 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2172 Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = NULL;
2173 unsigned int fingers = 0;
2174 unsigned int edge = 0;
2175 unsigned int edge_size = 0;
2176 unsigned int start_point = 0;
2177 unsigned int end_point = 0;
2179 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2181 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2182 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2183 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_SWIPE,
2184 EFL_UTIL_ERROR_INVALID_PARAMETER);
2186 edge_swipe_data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)data;
2188 fingers = edge_swipe_data->fingers;
2189 edge = edge_swipe_data->edge;
2190 edge_size = edge_swipe_data->edge_size;
2191 start_point = edge_swipe_data->start_point;
2192 end_point = edge_swipe_data->end_point;
2194 tizen_gesture_ungrab_edge_swipe(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2196 while (_eflutil.wl.gesture.request_notified == -1)
2197 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2199 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2200 _eflutil.wl.gesture.request_notified = -1;
2206 _efl_util_gesture_grab_edge_drag(efl_util_gesture_data data)
2208 int ret = EFL_UTIL_ERROR_NONE;
2209 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2210 Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = NULL;
2211 unsigned int fingers = 0;
2212 unsigned int edge = 0;
2213 unsigned int edge_size = 0;
2214 unsigned int start_point = 0;
2215 unsigned int end_point = 0;
2217 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2219 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2220 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2221 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_DRAG,
2222 EFL_UTIL_ERROR_INVALID_PARAMETER);
2224 edge_drag_data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)data;
2226 fingers = edge_drag_data->fingers;
2227 edge = edge_drag_data->edge;
2228 edge_size = edge_drag_data->edge_size;
2229 start_point = edge_drag_data->start_point;
2230 end_point = edge_drag_data->end_point;
2232 tizen_gesture_grab_edge_drag(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2234 while (_eflutil.wl.gesture.request_notified == -1)
2235 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2237 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2238 _eflutil.wl.gesture.request_notified = -1;
2244 _efl_util_gesture_ungrab_edge_drag(efl_util_gesture_data data)
2246 int ret = EFL_UTIL_ERROR_NONE;
2247 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2248 Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = NULL;
2249 unsigned int fingers = 0;
2250 unsigned int edge = 0;
2251 unsigned int edge_size = 0;
2252 unsigned int start_point = 0;
2253 unsigned int end_point = 0;
2255 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2257 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2258 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2259 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_DRAG,
2260 EFL_UTIL_ERROR_INVALID_PARAMETER);
2262 edge_drag_data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)data;
2264 fingers = edge_drag_data->fingers;
2265 edge = edge_drag_data->edge;
2266 edge_size = edge_drag_data->edge_size;
2267 start_point = edge_drag_data->start_point;
2268 end_point = edge_drag_data->end_point;
2270 tizen_gesture_ungrab_edge_drag(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2272 while (_eflutil.wl.gesture.request_notified == -1)
2273 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2275 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2276 _eflutil.wl.gesture.request_notified = -1;
2283 _efl_util_gesture_grab_tap(efl_util_gesture_data data)
2285 int ret = EFL_UTIL_ERROR_NONE;
2286 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2287 Efl_Util_Gesture_Tap_Grab_Data *tap_data = NULL;
2288 unsigned int fingers = 0;
2289 unsigned int repeats = 0;
2291 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2293 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2294 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2295 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_TAP,
2296 EFL_UTIL_ERROR_INVALID_PARAMETER);
2298 tap_data = (Efl_Util_Gesture_Tap_Grab_Data *)data;
2300 fingers = tap_data->fingers;
2301 repeats = tap_data->repeats;
2303 tizen_gesture_grab_tap(_eflutil.wl.gesture.proto, fingers, repeats);
2305 while (_eflutil.wl.gesture.request_notified == -1)
2306 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2308 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2309 _eflutil.wl.gesture.request_notified = -1;
2315 _efl_util_gesture_ungrab_tap(efl_util_gesture_data data)
2317 int ret = EFL_UTIL_ERROR_NONE;
2318 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2319 Efl_Util_Gesture_Tap_Grab_Data *tap_data = NULL;
2320 unsigned int fingers = 0;
2321 unsigned int repeats = 0;
2323 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2325 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2326 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2327 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_TAP,
2328 EFL_UTIL_ERROR_INVALID_PARAMETER);
2330 tap_data = (Efl_Util_Gesture_Tap_Grab_Data *)data;
2332 fingers = tap_data->fingers;
2333 repeats = tap_data->repeats;
2335 tizen_gesture_ungrab_tap(_eflutil.wl.gesture.proto, fingers, repeats);
2337 while (_eflutil.wl.gesture.request_notified == -1)
2338 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2340 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2341 _eflutil.wl.gesture.request_notified = -1;
2347 _efl_util_gesture_grab_palm_cover(efl_util_gesture_data data)
2349 int ret = EFL_UTIL_ERROR_NONE;
2350 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2352 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2354 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2355 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2356 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_PALM_COVER,
2357 EFL_UTIL_ERROR_INVALID_PARAMETER);
2359 tizen_gesture_grab_palm_cover(_eflutil.wl.gesture.proto);
2361 while (_eflutil.wl.gesture.request_notified == -1)
2362 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2364 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2365 _eflutil.wl.gesture.request_notified = -1;
2371 _efl_util_gesture_ungrab_palm_cover(efl_util_gesture_data data)
2373 int ret = EFL_UTIL_ERROR_NONE;
2374 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2376 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2378 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2379 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2380 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_PALM_COVER,
2381 EFL_UTIL_ERROR_INVALID_PARAMETER);
2383 tizen_gesture_ungrab_palm_cover(_eflutil.wl.gesture.proto);
2385 while (_eflutil.wl.gesture.request_notified == -1)
2386 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2388 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2389 _eflutil.wl.gesture.request_notified = -1;
2395 _efl_util_fd_cb(void *data, Ecore_Fd_Handler *hdl)
2397 if (_eflutil.wl.dpy && _eflutil.wl.queue)
2399 wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2400 return ECORE_CALLBACK_RENEW;
2404 return ECORE_CALLBACK_CANCEL;
2407 /* LCOV_EXCL_STOP */
2409 API efl_util_gesture_h
2410 efl_util_gesture_initialize(void)
2412 efl_util_gesture_h gesture_h = NULL;
2415 gesture_h = (efl_util_gesture_h)calloc(1, sizeof(struct _efl_util_gesture_h));
2418 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2419 goto out; /* LCOV_EXCL_LINE */
2422 if (_wl_init() == (int)EINA_FALSE)
2424 set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED); /* LCOV_EXCL_LINE */
2425 goto out; /* LCOV_EXCL_LINE */
2428 while (!_eflutil.wl.gesture.proto)
2429 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue); /* LCOV_EXCL_LINE */
2431 if (_eflutil.wl.gesture.event_init <= 0)
2433 if (ecore_event_init() <= 0)
2435 set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED); /* LCOV_EXCL_LINE */
2436 goto out; /* LCOV_EXCL_LINE */
2438 EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = ecore_event_type_new();
2439 EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = ecore_event_type_new();
2440 EFL_UTIL_EVENT_GESTURE_TAP = ecore_event_type_new();
2441 EFL_UTIL_EVENT_GESTURE_PALM_COVER = ecore_event_type_new();
2443 dpy_fd = wl_display_get_fd(_eflutil.wl.dpy);
2444 _eflutil.wl.dpy_fd = fcntl(dpy_fd, F_DUPFD_CLOEXEC, 0);
2445 if (_eflutil.wl.dpy_fd >= 0)
2446 _eflutil.wl.fd_hdl = ecore_main_fd_handler_add(_eflutil.wl.dpy_fd,
2447 ECORE_FD_READ | ECORE_FD_WRITE | ECORE_FD_ERROR,
2448 _efl_util_fd_cb, NULL,
2451 _eflutil.wl.gesture.event_init++;
2452 gesture_h->init = EINA_TRUE;
2454 set_last_result(EFL_UTIL_ERROR_NONE);
2458 /* LCOV_EXCL_START */
2465 /* LCOV_EXCL_STOP */
2469 efl_util_gesture_deinitialize(efl_util_gesture_h gesture_h)
2471 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2472 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2477 _eflutil.wl.gesture.event_init--;
2479 if (_eflutil.wl.gesture.event_init <= 0)
2481 _eflutil.wl.gesture.event_init = 0;
2482 ecore_event_shutdown();
2483 EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = 0;
2484 EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = 0;
2485 EFL_UTIL_EVENT_GESTURE_TAP = 0;
2486 EFL_UTIL_EVENT_GESTURE_PALM_COVER = 0;
2487 if (_eflutil.wl.dpy_fd >= 0)
2489 ecore_main_fd_handler_del(_eflutil.wl.fd_hdl);
2490 _eflutil.wl.fd_hdl = NULL;
2491 close(_eflutil.wl.dpy_fd);
2492 _eflutil.wl.dpy_fd = -1;
2496 return EFL_UTIL_ERROR_NONE;
2499 API efl_util_gesture_data
2500 efl_util_gesture_edge_swipe_new(efl_util_gesture_h gesture_h, unsigned int fingers, efl_util_gesture_edge_e edge)
2502 Efl_Util_Gesture_Edge_Swipe_Grab_Data *data;
2504 if (!gesture_h || gesture_h->init == EINA_FALSE)
2506 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2510 if (edge <= EFL_UTIL_GESTURE_EDGE_NONE || edge > EFL_UTIL_GESTURE_EDGE_LEFT)
2512 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2516 data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Edge_Swipe_Grab_Data));
2519 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2520 return NULL; /* LCOV_EXCL_LINE */
2523 data->base.type = TIZEN_GESTURE_TYPE_EDGE_SWIPE;
2524 data->fingers = fingers;
2526 data->edge_size = EFL_UTIL_GESTURE_EDGE_SIZE_FULL;
2528 set_last_result(EFL_UTIL_ERROR_NONE);
2530 return (void *)data;
2534 efl_util_gesture_edge_swipe_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2536 if (!gesture_h || gesture_h->init == EINA_FALSE)
2538 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2543 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2549 return EFL_UTIL_ERROR_NONE;
2553 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)
2555 Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = data;
2557 EINA_SAFETY_ON_NULL_RETURN_VAL(edge_swipe_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2558 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_swipe_data->base.type == TIZEN_GESTURE_TYPE_EDGE_SWIPE,
2559 EFL_UTIL_ERROR_INVALID_PARAMETER);
2560 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_size == EFL_UTIL_GESTURE_EDGE_SIZE_PARTIAL,
2561 EFL_UTIL_ERROR_INVALID_PARAMETER);
2562 EINA_SAFETY_ON_FALSE_RETURN_VAL(end_point > start_point, EFL_UTIL_ERROR_INVALID_PARAMETER);
2564 edge_swipe_data->edge_size = edge_size;
2565 edge_swipe_data->start_point = start_point;
2566 edge_swipe_data->end_point = end_point;
2568 return EFL_UTIL_ERROR_NONE;
2571 API efl_util_gesture_data
2572 efl_util_gesture_edge_drag_new(efl_util_gesture_h gesture_h, unsigned int fingers, efl_util_gesture_edge_e edge)
2574 Efl_Util_Gesture_Edge_Drag_Grab_Data *data;
2576 if (!gesture_h || gesture_h->init == EINA_FALSE)
2578 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2582 if (edge <= EFL_UTIL_GESTURE_EDGE_NONE || edge > EFL_UTIL_GESTURE_EDGE_LEFT)
2584 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2588 data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Edge_Drag_Grab_Data));
2591 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2592 return NULL; /* LCOV_EXCL_LINE */
2595 data->base.type = TIZEN_GESTURE_TYPE_EDGE_DRAG;
2596 data->fingers = fingers;
2598 data->edge_size = EFL_UTIL_GESTURE_EDGE_SIZE_FULL;
2600 set_last_result(EFL_UTIL_ERROR_NONE);
2602 return (void *)data;
2606 efl_util_gesture_edge_drag_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2608 if (!gesture_h || gesture_h->init == EINA_FALSE)
2610 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2615 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2621 return EFL_UTIL_ERROR_NONE;
2625 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)
2627 Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = data;
2629 EINA_SAFETY_ON_NULL_RETURN_VAL(edge_drag_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2630 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_drag_data->base.type == TIZEN_GESTURE_TYPE_EDGE_DRAG,
2631 EFL_UTIL_ERROR_INVALID_PARAMETER);
2632 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_size == EFL_UTIL_GESTURE_EDGE_SIZE_PARTIAL,
2633 EFL_UTIL_ERROR_INVALID_PARAMETER);
2634 EINA_SAFETY_ON_FALSE_RETURN_VAL(end_point > start_point, EFL_UTIL_ERROR_INVALID_PARAMETER);
2636 edge_drag_data->edge_size = edge_size;
2637 edge_drag_data->start_point = start_point;
2638 edge_drag_data->end_point = end_point;
2640 return EFL_UTIL_ERROR_NONE;
2643 API efl_util_gesture_data
2644 efl_util_gesture_tap_new(efl_util_gesture_h gesture_h, unsigned int fingers, unsigned int repeats)
2646 Efl_Util_Gesture_Tap_Grab_Data *data;
2648 if (!gesture_h || gesture_h->init == EINA_FALSE)
2650 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2654 if (fingers <= 1 || repeats <= 1)
2656 set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED);
2660 data = (Efl_Util_Gesture_Tap_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Tap_Grab_Data));
2663 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2664 return NULL; /* LCOV_EXCL_LINE */
2667 data->base.type = TIZEN_GESTURE_TYPE_TAP;
2668 data->fingers = fingers;
2669 data->repeats = repeats;
2671 set_last_result(EFL_UTIL_ERROR_NONE);
2673 return (void *)data;
2677 efl_util_gesture_tap_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2679 if (!gesture_h || gesture_h->init == EINA_FALSE)
2681 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2686 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2692 return EFL_UTIL_ERROR_NONE;
2695 API efl_util_gesture_data
2696 efl_util_gesture_palm_cover_new(efl_util_gesture_h gesture_h)
2698 Efl_Util_Gesture_Palm_Cover_Grab_Data *data;
2700 if (!gesture_h || gesture_h->init == EINA_FALSE)
2702 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2706 data = (Efl_Util_Gesture_Palm_Cover_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Palm_Cover_Grab_Data));
2709 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY); /* LCOV_EXCL_LINE */
2710 return NULL; /* LCOV_EXCL_LINE */
2713 data->base.type = TIZEN_GESTURE_TYPE_PALM_COVER;
2715 set_last_result(EFL_UTIL_ERROR_NONE);
2717 return (void *)data;
2721 efl_util_gesture_palm_cover_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2723 if (!gesture_h || gesture_h->init == EINA_FALSE)
2725 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2730 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2736 return EFL_UTIL_ERROR_NONE;
2739 /* LCOV_EXCL_START */
2741 efl_util_gesture_grab(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2743 int ret = EFL_UTIL_ERROR_NONE;
2744 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2746 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2748 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2749 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2750 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2752 switch (base_data->type)
2754 case TIZEN_GESTURE_TYPE_EDGE_SWIPE:
2755 ret = _efl_util_gesture_grab_edge_swipe(data);
2757 case TIZEN_GESTURE_TYPE_EDGE_DRAG:
2758 ret = _efl_util_gesture_grab_edge_drag(data);
2760 case TIZEN_GESTURE_TYPE_TAP:
2761 ret = _efl_util_gesture_grab_tap(data);
2763 case TIZEN_GESTURE_TYPE_PALM_COVER:
2764 ret = _efl_util_gesture_grab_palm_cover(data);
2767 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2774 efl_util_gesture_ungrab(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2776 int ret = EFL_UTIL_ERROR_NONE;
2777 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2779 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2781 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2782 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2783 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2785 switch (base_data->type)
2787 case TIZEN_GESTURE_TYPE_EDGE_SWIPE:
2788 ret = _efl_util_gesture_ungrab_edge_swipe(data);
2790 case TIZEN_GESTURE_TYPE_EDGE_DRAG:
2791 ret = _efl_util_gesture_ungrab_edge_drag(data);
2793 case TIZEN_GESTURE_TYPE_TAP:
2794 ret = _efl_util_gesture_ungrab_tap(data);
2796 case TIZEN_GESTURE_TYPE_PALM_COVER:
2797 ret = _efl_util_gesture_ungrab_palm_cover(data);
2800 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2805 /* LCOV_EXCL_STOP */
2808 efl_util_gesture_select(efl_util_gesture_h gesture_h, Evas_Object *window, efl_util_gesture_data data)
2810 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2811 Ecore_Wl_Window *wlwin;
2812 struct wl_surface *surface;
2815 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2817 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2818 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2819 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
2820 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2822 if (base_data->type != TIZEN_GESTURE_TYPE_PALM_COVER)
2823 return EFL_UTIL_ERROR_NOT_SUPPORTED;
2825 wlwin = elm_win_wl_window_get(window);
2826 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
2828 surface = ecore_wl_window_surface_get(wlwin);
2829 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
2830 EFL_UTIL_ERROR_INVALID_PARAMETER);
2832 tizen_gesture_select_palm_cover(_eflutil.wl.gesture.proto, surface);
2834 while (_eflutil.wl.gesture.request_notified == -1)
2835 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2837 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2838 _eflutil.wl.gesture.request_notified = -1;
2844 efl_util_gesture_deselect(efl_util_gesture_h gesture_h, Evas_Object *window, efl_util_gesture_data data)
2846 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2847 Ecore_Wl_Window *wlwin;
2848 struct wl_surface *surface;
2851 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2853 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2854 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2855 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
2856 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2858 if (base_data->type != TIZEN_GESTURE_TYPE_PALM_COVER)
2859 return EFL_UTIL_ERROR_NOT_SUPPORTED;
2861 wlwin = elm_win_wl_window_get(window);
2862 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
2864 surface = ecore_wl_window_surface_get(wlwin);
2865 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
2866 EFL_UTIL_ERROR_INVALID_PARAMETER);
2868 tizen_gesture_deselect_palm_cover(_eflutil.wl.gesture.proto, surface);
2870 while (_eflutil.wl.gesture.request_notified == -1)
2871 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2873 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2874 _eflutil.wl.gesture.request_notified = -1;
2879 /* LCOV_EXCL_START */
2881 efl_util_gesture_activate_set(efl_util_gesture_h gesture_h, unsigned int type, Eina_Bool active)
2885 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2886 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2887 EINA_SAFETY_ON_TRUE_RETURN_VAL(type == EFL_UTIL_GESTURE_TYPE_NONE, EFL_UTIL_ERROR_INVALID_PARAMETER);
2889 tizen_gesture_activate_set(_eflutil.wl.gesture.proto, NULL, type, active);
2891 while (_eflutil.wl.gesture.request_notified == -1)
2892 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2894 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2895 _eflutil.wl.gesture.request_notified = -1;
2899 /* LCOV_EXCL_STOP */
2902 efl_util_gesture_activate_set_on_window(efl_util_gesture_h gesture_h, Evas_Object *window, unsigned int type, Eina_Bool active)
2904 Ecore_Wl_Window *wlwin;
2905 struct wl_surface *surface;
2908 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2909 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2910 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
2911 EINA_SAFETY_ON_TRUE_RETURN_VAL(type == EFL_UTIL_GESTURE_TYPE_NONE, EFL_UTIL_ERROR_INVALID_PARAMETER);
2913 wlwin = elm_win_wl_window_get(window);
2914 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
2916 surface = ecore_wl_window_surface_get(wlwin);
2917 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
2918 EFL_UTIL_ERROR_INVALID_PARAMETER);
2920 tizen_gesture_activate_set(_eflutil.wl.gesture.proto, surface, type, active);
2922 while (_eflutil.wl.gesture.request_notified == -1)
2923 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2925 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2926 _eflutil.wl.gesture.request_notified = -1;