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();
1955 efl_util_screenshot_set_auto_rotation(efl_util_screenshot_h screenshot, int set)
1957 if (!screenshot || (screenshot != g_screenshot))
1958 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1960 if (!(set == 0 || set == 1))
1961 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1964 g_screenshot->auto_rotation = EINA_TRUE;
1966 g_screenshot->auto_rotation = EINA_FALSE;
1968 tizen_screenshooter_set_oneshot_auto_rotation(_eflutil.wl.shot.tz_screenshooter, g_screenshot->auto_rotation);
1970 return EFL_UTIL_ERROR_NONE;
1974 efl_util_screenshot_get_auto_rotation(efl_util_screenshot_h screenshot, int *set)
1976 if (!screenshot || (screenshot != g_screenshot) || !set)
1977 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1979 *set = g_screenshot->auto_rotation;
1981 return EFL_UTIL_ERROR_NONE;
1984 struct _efl_util_gesture_h
1989 API int EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = 0;
1990 API int EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = 0;
1991 API int EFL_UTIL_EVENT_GESTURE_TAP = 0;
1992 API int EFL_UTIL_EVENT_GESTURE_PALM_COVER = 0;
1995 _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)
1997 _eflutil.wl.gesture.request_notified = error;
2001 _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)
2003 efl_util_event_gesture_edge_swipe_s *ev = NULL;
2005 ev = (efl_util_event_gesture_edge_swipe_s *)calloc(1, sizeof(*ev));
2010 ev->fingers = fingers;
2015 ecore_event_add(EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE, ev, NULL, NULL);
2019 _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)
2021 _eflutil.wl.gesture.request_notified = error;
2025 _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)
2027 efl_util_event_gesture_edge_drag_s *ev = NULL;
2029 ev = (efl_util_event_gesture_edge_drag_s *)calloc(1, sizeof(*ev));
2034 ev->fingers = fingers;
2039 ecore_event_add(EFL_UTIL_EVENT_GESTURE_EDGE_DRAG, ev, NULL, NULL);
2043 _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)
2045 _eflutil.wl.gesture.request_notified = error;
2049 _cb_gesture_tap(void *data EINA_UNUSED, struct tizen_gesture *tizen_gesture EINA_UNUSED, uint32_t mode, uint32_t fingers, uint32_t repeats)
2051 efl_util_event_gesture_tap_s *ev = NULL;
2053 ev = (efl_util_event_gesture_tap_s *)calloc(1, sizeof(*ev));
2058 ev->fingers = fingers;
2059 ev->repeats = repeats;
2061 ecore_event_add(EFL_UTIL_EVENT_GESTURE_TAP, ev, NULL, NULL);
2065 _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)
2067 _eflutil.wl.gesture.request_notified = error;
2071 _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)
2073 efl_util_event_gesture_palm_cover_s *ev = NULL;
2075 ev = (efl_util_event_gesture_palm_cover_s *)calloc(1, sizeof(*ev));
2080 ev->duration = duration;
2084 ev->pressure = wl_fixed_to_int(pressure);
2086 ecore_event_add(EFL_UTIL_EVENT_GESTURE_PALM_COVER, ev, NULL, NULL);
2090 _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)
2092 _eflutil.wl.gesture.request_notified = error;
2095 static efl_util_error_e
2096 _efl_util_gesture_convert_error(int ret)
2100 case TIZEN_GESTURE_ERROR_NONE:
2101 return EFL_UTIL_ERROR_NONE;
2102 case TIZEN_GESTURE_ERROR_INVALID_DATA:
2103 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2104 case TIZEN_GESTURE_ERROR_NO_PERMISSION:
2105 return EFL_UTIL_ERROR_PERMISSION_DENIED;
2106 case TIZEN_GESTURE_ERROR_NO_SYSTEM_RESOURCES:
2107 return EFL_UTIL_ERROR_OUT_OF_MEMORY;
2108 case TIZEN_GESTURE_ERROR_GRABBED_ALREADY:
2109 return EFL_UTIL_ERROR_NO_RESOURCE_AVAILABLE;
2110 case TIZEN_GESTURE_ERROR_NOT_SUPPORTED:
2111 return EFL_UTIL_ERROR_NOT_SUPPORTED;
2113 return EFL_UTIL_ERROR_NONE;
2118 _efl_util_gesture_grab_edge_swipe(efl_util_gesture_data data)
2120 int ret = EFL_UTIL_ERROR_NONE;
2121 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2122 Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = NULL;
2123 unsigned int fingers = 0;
2124 unsigned int edge = 0;
2125 unsigned int edge_size = 0;
2126 unsigned int start_point = 0;
2127 unsigned int end_point = 0;
2129 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2131 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2132 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2133 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_SWIPE,
2134 EFL_UTIL_ERROR_INVALID_PARAMETER);
2136 edge_swipe_data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)data;
2138 fingers = edge_swipe_data->fingers;
2139 edge = edge_swipe_data->edge;
2140 edge_size = edge_swipe_data->edge_size;
2141 start_point = edge_swipe_data->start_point;
2142 end_point = edge_swipe_data->end_point;
2144 tizen_gesture_grab_edge_swipe(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2146 while (_eflutil.wl.gesture.request_notified == -1)
2147 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2149 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2150 _eflutil.wl.gesture.request_notified = -1;
2156 _efl_util_gesture_ungrab_edge_swipe(efl_util_gesture_data data)
2158 int ret = EFL_UTIL_ERROR_NONE;
2159 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2160 Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = NULL;
2161 unsigned int fingers = 0;
2162 unsigned int edge = 0;
2163 unsigned int edge_size = 0;
2164 unsigned int start_point = 0;
2165 unsigned int end_point = 0;
2167 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2169 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2170 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2171 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_SWIPE,
2172 EFL_UTIL_ERROR_INVALID_PARAMETER);
2174 edge_swipe_data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)data;
2176 fingers = edge_swipe_data->fingers;
2177 edge = edge_swipe_data->edge;
2178 edge_size = edge_swipe_data->edge_size;
2179 start_point = edge_swipe_data->start_point;
2180 end_point = edge_swipe_data->end_point;
2182 tizen_gesture_ungrab_edge_swipe(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2184 while (_eflutil.wl.gesture.request_notified == -1)
2185 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2187 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2188 _eflutil.wl.gesture.request_notified = -1;
2194 _efl_util_gesture_grab_edge_drag(efl_util_gesture_data data)
2196 int ret = EFL_UTIL_ERROR_NONE;
2197 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2198 Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = NULL;
2199 unsigned int fingers = 0;
2200 unsigned int edge = 0;
2201 unsigned int edge_size = 0;
2202 unsigned int start_point = 0;
2203 unsigned int end_point = 0;
2205 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2207 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2208 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2209 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_DRAG,
2210 EFL_UTIL_ERROR_INVALID_PARAMETER);
2212 edge_drag_data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)data;
2214 fingers = edge_drag_data->fingers;
2215 edge = edge_drag_data->edge;
2216 edge_size = edge_drag_data->edge_size;
2217 start_point = edge_drag_data->start_point;
2218 end_point = edge_drag_data->end_point;
2220 tizen_gesture_grab_edge_drag(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2222 while (_eflutil.wl.gesture.request_notified == -1)
2223 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2225 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2226 _eflutil.wl.gesture.request_notified = -1;
2232 _efl_util_gesture_ungrab_edge_drag(efl_util_gesture_data data)
2234 int ret = EFL_UTIL_ERROR_NONE;
2235 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2236 Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = NULL;
2237 unsigned int fingers = 0;
2238 unsigned int edge = 0;
2239 unsigned int edge_size = 0;
2240 unsigned int start_point = 0;
2241 unsigned int end_point = 0;
2243 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2245 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2246 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2247 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_DRAG,
2248 EFL_UTIL_ERROR_INVALID_PARAMETER);
2250 edge_drag_data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)data;
2252 fingers = edge_drag_data->fingers;
2253 edge = edge_drag_data->edge;
2254 edge_size = edge_drag_data->edge_size;
2255 start_point = edge_drag_data->start_point;
2256 end_point = edge_drag_data->end_point;
2258 tizen_gesture_ungrab_edge_drag(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2260 while (_eflutil.wl.gesture.request_notified == -1)
2261 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2263 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2264 _eflutil.wl.gesture.request_notified = -1;
2271 _efl_util_gesture_grab_tap(efl_util_gesture_data data)
2273 int ret = EFL_UTIL_ERROR_NONE;
2274 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2275 Efl_Util_Gesture_Tap_Grab_Data *tap_data = NULL;
2276 unsigned int fingers = 0;
2277 unsigned int repeats = 0;
2279 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2281 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2282 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2283 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_TAP,
2284 EFL_UTIL_ERROR_INVALID_PARAMETER);
2286 tap_data = (Efl_Util_Gesture_Tap_Grab_Data *)data;
2288 fingers = tap_data->fingers;
2289 repeats = tap_data->repeats;
2291 tizen_gesture_grab_tap(_eflutil.wl.gesture.proto, fingers, repeats);
2293 while (_eflutil.wl.gesture.request_notified == -1)
2294 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2296 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2297 _eflutil.wl.gesture.request_notified = -1;
2303 _efl_util_gesture_ungrab_tap(efl_util_gesture_data data)
2305 int ret = EFL_UTIL_ERROR_NONE;
2306 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2307 Efl_Util_Gesture_Tap_Grab_Data *tap_data = NULL;
2308 unsigned int fingers = 0;
2309 unsigned int repeats = 0;
2311 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2313 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2314 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2315 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_TAP,
2316 EFL_UTIL_ERROR_INVALID_PARAMETER);
2318 tap_data = (Efl_Util_Gesture_Tap_Grab_Data *)data;
2320 fingers = tap_data->fingers;
2321 repeats = tap_data->repeats;
2323 tizen_gesture_ungrab_tap(_eflutil.wl.gesture.proto, fingers, repeats);
2325 while (_eflutil.wl.gesture.request_notified == -1)
2326 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2328 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2329 _eflutil.wl.gesture.request_notified = -1;
2335 _efl_util_gesture_grab_palm_cover(efl_util_gesture_data data)
2337 int ret = EFL_UTIL_ERROR_NONE;
2338 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2340 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2342 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2343 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2344 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_PALM_COVER,
2345 EFL_UTIL_ERROR_INVALID_PARAMETER);
2347 tizen_gesture_grab_palm_cover(_eflutil.wl.gesture.proto);
2349 while (_eflutil.wl.gesture.request_notified == -1)
2350 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2352 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2353 _eflutil.wl.gesture.request_notified = -1;
2359 _efl_util_gesture_ungrab_palm_cover(efl_util_gesture_data data)
2361 int ret = EFL_UTIL_ERROR_NONE;
2362 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2364 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2366 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2367 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2368 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_PALM_COVER,
2369 EFL_UTIL_ERROR_INVALID_PARAMETER);
2371 tizen_gesture_ungrab_palm_cover(_eflutil.wl.gesture.proto);
2373 while (_eflutil.wl.gesture.request_notified == -1)
2374 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2376 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2377 _eflutil.wl.gesture.request_notified = -1;
2383 _efl_util_fd_cb(void *data, Ecore_Fd_Handler *hdl)
2385 if (_eflutil.wl.dpy && _eflutil.wl.queue)
2387 wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2388 return ECORE_CALLBACK_RENEW;
2392 return ECORE_CALLBACK_CANCEL;
2396 API efl_util_gesture_h
2397 efl_util_gesture_initialize(void)
2399 efl_util_gesture_h gesture_h = NULL;
2402 gesture_h = (efl_util_gesture_h)calloc(1, sizeof(struct _efl_util_gesture_h));
2405 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
2409 if (_wl_init() == (int)EINA_FALSE)
2411 set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED);
2415 while (!_eflutil.wl.gesture.proto)
2416 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2418 if (_eflutil.wl.gesture.event_init <= 0)
2420 if (ecore_event_init() <= 0)
2422 set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED);
2425 EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = ecore_event_type_new();
2426 EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = ecore_event_type_new();
2427 EFL_UTIL_EVENT_GESTURE_TAP = ecore_event_type_new();
2428 EFL_UTIL_EVENT_GESTURE_PALM_COVER = ecore_event_type_new();
2430 dpy_fd = wl_display_get_fd(_eflutil.wl.dpy);
2431 _eflutil.wl.dpy_fd = fcntl(dpy_fd, F_DUPFD_CLOEXEC, 0);
2432 if (_eflutil.wl.dpy_fd >= 0)
2433 _eflutil.wl.fd_hdl = ecore_main_fd_handler_add(_eflutil.wl.dpy_fd,
2434 ECORE_FD_READ | ECORE_FD_WRITE | ECORE_FD_ERROR,
2435 _efl_util_fd_cb, NULL,
2438 _eflutil.wl.gesture.event_init++;
2439 gesture_h->init = EINA_TRUE;
2441 set_last_result(EFL_UTIL_ERROR_NONE);
2454 efl_util_gesture_deinitialize(efl_util_gesture_h gesture_h)
2456 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2457 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2462 _eflutil.wl.gesture.event_init--;
2464 if (_eflutil.wl.gesture.event_init <= 0)
2466 _eflutil.wl.gesture.event_init = 0;
2467 ecore_event_shutdown();
2468 EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = 0;
2469 EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = 0;
2470 EFL_UTIL_EVENT_GESTURE_TAP = 0;
2471 EFL_UTIL_EVENT_GESTURE_PALM_COVER = 0;
2472 if (_eflutil.wl.dpy_fd >= 0)
2474 ecore_main_fd_handler_del(_eflutil.wl.fd_hdl);
2475 _eflutil.wl.fd_hdl = NULL;
2476 close(_eflutil.wl.dpy_fd);
2477 _eflutil.wl.dpy_fd = -1;
2481 return EFL_UTIL_ERROR_NONE;
2484 API efl_util_gesture_data
2485 efl_util_gesture_edge_swipe_new(efl_util_gesture_h gesture_h, unsigned int fingers, efl_util_gesture_edge_e edge)
2487 Efl_Util_Gesture_Edge_Swipe_Grab_Data *data;
2489 if (!gesture_h || gesture_h->init == EINA_FALSE)
2491 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2495 if (edge <= EFL_UTIL_GESTURE_EDGE_NONE || edge > EFL_UTIL_GESTURE_EDGE_LEFT)
2497 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2501 data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Edge_Swipe_Grab_Data));
2504 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
2508 data->base.type = TIZEN_GESTURE_TYPE_EDGE_SWIPE;
2509 data->fingers = fingers;
2511 data->edge_size = EFL_UTIL_GESTURE_EDGE_SIZE_FULL;
2513 set_last_result(EFL_UTIL_ERROR_NONE);
2515 return (void *)data;
2519 efl_util_gesture_edge_swipe_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2521 if (!gesture_h || gesture_h->init == EINA_FALSE)
2523 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2528 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2534 return EFL_UTIL_ERROR_NONE;
2538 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)
2540 Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = data;
2542 EINA_SAFETY_ON_NULL_RETURN_VAL(edge_swipe_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2543 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_swipe_data->base.type == TIZEN_GESTURE_TYPE_EDGE_SWIPE,
2544 EFL_UTIL_ERROR_INVALID_PARAMETER);
2545 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_size == EFL_UTIL_GESTURE_EDGE_SIZE_PARTIAL,
2546 EFL_UTIL_ERROR_INVALID_PARAMETER);
2547 EINA_SAFETY_ON_FALSE_RETURN_VAL(end_point > start_point, EFL_UTIL_ERROR_INVALID_PARAMETER);
2549 edge_swipe_data->edge_size = edge_size;
2550 edge_swipe_data->start_point = start_point;
2551 edge_swipe_data->end_point = end_point;
2553 return EFL_UTIL_ERROR_NONE;
2556 API efl_util_gesture_data
2557 efl_util_gesture_edge_drag_new(efl_util_gesture_h gesture_h, unsigned int fingers, efl_util_gesture_edge_e edge)
2559 Efl_Util_Gesture_Edge_Drag_Grab_Data *data;
2561 if (!gesture_h || gesture_h->init == EINA_FALSE)
2563 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2567 if (edge <= EFL_UTIL_GESTURE_EDGE_NONE || edge > EFL_UTIL_GESTURE_EDGE_LEFT)
2569 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2573 data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Edge_Drag_Grab_Data));
2576 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
2580 data->base.type = TIZEN_GESTURE_TYPE_EDGE_DRAG;
2581 data->fingers = fingers;
2583 data->edge_size = EFL_UTIL_GESTURE_EDGE_SIZE_FULL;
2585 set_last_result(EFL_UTIL_ERROR_NONE);
2587 return (void *)data;
2591 efl_util_gesture_edge_drag_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2593 if (!gesture_h || gesture_h->init == EINA_FALSE)
2595 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2600 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2606 return EFL_UTIL_ERROR_NONE;
2610 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)
2612 Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = data;
2614 EINA_SAFETY_ON_NULL_RETURN_VAL(edge_drag_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2615 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_drag_data->base.type == TIZEN_GESTURE_TYPE_EDGE_DRAG,
2616 EFL_UTIL_ERROR_INVALID_PARAMETER);
2617 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_size == EFL_UTIL_GESTURE_EDGE_SIZE_PARTIAL,
2618 EFL_UTIL_ERROR_INVALID_PARAMETER);
2619 EINA_SAFETY_ON_FALSE_RETURN_VAL(end_point > start_point, EFL_UTIL_ERROR_INVALID_PARAMETER);
2621 edge_drag_data->edge_size = edge_size;
2622 edge_drag_data->start_point = start_point;
2623 edge_drag_data->end_point = end_point;
2625 return EFL_UTIL_ERROR_NONE;
2628 API efl_util_gesture_data
2629 efl_util_gesture_tap_new(efl_util_gesture_h gesture_h, unsigned int fingers, unsigned int repeats)
2631 Efl_Util_Gesture_Tap_Grab_Data *data;
2633 if (!gesture_h || gesture_h->init == EINA_FALSE)
2635 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2639 if (fingers <= 1 || repeats <= 1)
2641 set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED);
2645 data = (Efl_Util_Gesture_Tap_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Tap_Grab_Data));
2648 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
2652 data->base.type = TIZEN_GESTURE_TYPE_TAP;
2653 data->fingers = fingers;
2654 data->repeats = repeats;
2656 set_last_result(EFL_UTIL_ERROR_NONE);
2658 return (void *)data;
2662 efl_util_gesture_tap_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2664 if (!gesture_h || gesture_h->init == EINA_FALSE)
2666 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2671 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2677 return EFL_UTIL_ERROR_NONE;
2680 API efl_util_gesture_data
2681 efl_util_gesture_palm_cover_new(efl_util_gesture_h gesture_h)
2683 Efl_Util_Gesture_Palm_Cover_Grab_Data *data;
2685 if (!gesture_h || gesture_h->init == EINA_FALSE)
2687 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2691 data = (Efl_Util_Gesture_Palm_Cover_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Palm_Cover_Grab_Data));
2694 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
2698 data->base.type = TIZEN_GESTURE_TYPE_PALM_COVER;
2700 set_last_result(EFL_UTIL_ERROR_NONE);
2702 return (void *)data;
2706 efl_util_gesture_palm_cover_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2708 if (!gesture_h || gesture_h->init == EINA_FALSE)
2710 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2715 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2721 return EFL_UTIL_ERROR_NONE;
2725 efl_util_gesture_grab(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2727 int ret = EFL_UTIL_ERROR_NONE;
2728 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2730 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2732 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2733 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2734 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2736 switch (base_data->type)
2738 case TIZEN_GESTURE_TYPE_EDGE_SWIPE:
2739 ret = _efl_util_gesture_grab_edge_swipe(data);
2741 case TIZEN_GESTURE_TYPE_EDGE_DRAG:
2742 ret = _efl_util_gesture_grab_edge_drag(data);
2744 case TIZEN_GESTURE_TYPE_TAP:
2745 ret = _efl_util_gesture_grab_tap(data);
2747 case TIZEN_GESTURE_TYPE_PALM_COVER:
2748 ret = _efl_util_gesture_grab_palm_cover(data);
2751 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2758 efl_util_gesture_ungrab(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2760 int ret = EFL_UTIL_ERROR_NONE;
2761 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2763 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2765 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2766 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2767 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2769 switch (base_data->type)
2771 case TIZEN_GESTURE_TYPE_EDGE_SWIPE:
2772 ret = _efl_util_gesture_ungrab_edge_swipe(data);
2774 case TIZEN_GESTURE_TYPE_EDGE_DRAG:
2775 ret = _efl_util_gesture_ungrab_edge_drag(data);
2777 case TIZEN_GESTURE_TYPE_TAP:
2778 ret = _efl_util_gesture_ungrab_tap(data);
2780 case TIZEN_GESTURE_TYPE_PALM_COVER:
2781 ret = _efl_util_gesture_ungrab_palm_cover(data);
2784 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2791 efl_util_gesture_select(efl_util_gesture_h gesture_h, Evas_Object *window, efl_util_gesture_data data)
2793 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2794 Ecore_Wl_Window *wlwin;
2795 struct wl_surface *surface;
2798 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2800 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2801 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2802 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
2803 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2805 if (base_data->type != TIZEN_GESTURE_TYPE_PALM_COVER)
2806 return EFL_UTIL_ERROR_NOT_SUPPORTED;
2808 wlwin = elm_win_wl_window_get(window);
2809 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
2811 surface = ecore_wl_window_surface_get(wlwin);
2812 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
2813 EFL_UTIL_ERROR_INVALID_PARAMETER);
2815 tizen_gesture_select_palm_cover(_eflutil.wl.gesture.proto, surface);
2817 while (_eflutil.wl.gesture.request_notified == -1)
2818 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2820 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2821 _eflutil.wl.gesture.request_notified = -1;
2827 efl_util_gesture_deselect(efl_util_gesture_h gesture_h, Evas_Object *window, efl_util_gesture_data data)
2829 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2830 Ecore_Wl_Window *wlwin;
2831 struct wl_surface *surface;
2834 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2836 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2837 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2838 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
2839 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2841 if (base_data->type != TIZEN_GESTURE_TYPE_PALM_COVER)
2842 return EFL_UTIL_ERROR_NOT_SUPPORTED;
2844 wlwin = elm_win_wl_window_get(window);
2845 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
2847 surface = ecore_wl_window_surface_get(wlwin);
2848 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
2849 EFL_UTIL_ERROR_INVALID_PARAMETER);
2851 tizen_gesture_deselect_palm_cover(_eflutil.wl.gesture.proto, surface);
2853 while (_eflutil.wl.gesture.request_notified == -1)
2854 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2856 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2857 _eflutil.wl.gesture.request_notified = -1;
2863 efl_util_gesture_activate_set(efl_util_gesture_h gesture_h, unsigned int type, Eina_Bool active)
2867 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2868 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2869 EINA_SAFETY_ON_TRUE_RETURN_VAL(type == EFL_UTIL_GESTURE_TYPE_NONE, EFL_UTIL_ERROR_INVALID_PARAMETER);
2871 tizen_gesture_activate_set(_eflutil.wl.gesture.proto, NULL, type, active);
2873 while (_eflutil.wl.gesture.request_notified == -1)
2874 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2876 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2877 _eflutil.wl.gesture.request_notified = -1;
2883 efl_util_gesture_activate_set_on_window(efl_util_gesture_h gesture_h, Evas_Object *window, unsigned int type, Eina_Bool active)
2885 Ecore_Wl_Window *wlwin;
2886 struct wl_surface *surface;
2889 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2890 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2891 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
2892 EINA_SAFETY_ON_TRUE_RETURN_VAL(type == EFL_UTIL_GESTURE_TYPE_NONE, EFL_UTIL_ERROR_INVALID_PARAMETER);
2894 wlwin = elm_win_wl_window_get(window);
2895 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
2897 surface = ecore_wl_window_surface_get(wlwin);
2898 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
2899 EFL_UTIL_ERROR_INVALID_PARAMETER);
2901 tizen_gesture_activate_set(_eflutil.wl.gesture.proto, surface, type, active);
2903 while (_eflutil.wl.gesture.request_notified == -1)
2904 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2906 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2907 _eflutil.wl.gesture.request_notified = -1;