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;
193 struct tizen_policy *proto;
194 Eina_Hash *hash_noti_lv;
195 Eina_Hash *hash_scr_mode;
199 struct wl_event_queue *queue;
200 struct screenshooter *screenshooter;
201 struct tizen_screenshooter *tz_screenshooter;
202 struct wayland_tbm_client *tbm_client;
203 Eina_List *output_list;
208 struct tizen_input_device_manager *devicemgr;
209 int request_notified;
213 struct tizen_display_policy *proto;
214 Eina_Hash *hash_brightness;
218 struct tizen_gesture *proto;
219 int request_notified;
226 Eina_List *info_list; /* list of callback info */
227 unsigned int atom; /* x11 atom */
228 } cb_handler[CBH_MAX];
231 static Efl_Util_Data _eflutil =
236 { NULL, NULL, NULL }, /* tizen_policy protocol */
237 { NULL, NULL, NULL, NULL, NULL, 0 }, /* screenshooter protocol */
238 { NULL, -1 }, /* tizen_input_device_manager protocol */
239 { NULL, NULL }, /* display_policy protocol */
240 { NULL, -1, EINA_FALSE } /* tizen_gesture protocol */
243 { NULL, 0 }, /* handler for notification level */
244 { NULL, 0 } /* handler for screen mode */
248 static Eina_Bool _cb_info_add(Evas_Object *win, Efl_Util_Cb cb, void *data, int idx);
249 static Eina_Bool _cb_info_del_by_win(Evas_Object *win, int idx);
250 static Eina_List *_cb_info_list_get(int idx);
251 static Efl_Util_Callback_Info *_cb_info_find_by_win(Evas_Object *win, int idx);
252 static Eina_Bool _wl_init(void);
253 static void _cb_wl_reg_global(void *data, struct wl_registry *reg, unsigned int name, const char *interface, unsigned int version);
254 static void _cb_wl_reg_global_remove(void *data, struct wl_registry *reg, unsigned int name);
255 static void _cb_wl_reg_screenshooter_global(void *data, struct wl_registry *reg, unsigned int name, const char *interface, unsigned int version);
256 static void _cb_wl_reg_screenshooter_global_remove(void *data, struct wl_registry *reg, unsigned int name);
257 static Efl_Util_Callback_Info *_cb_info_find_by_wlsurf(void *wlsurf, int idx);
258 static void _cb_wl_tz_policy_conformant(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface, uint32_t is_conformant);
259 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);
260 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);
261 static void _cb_wl_tz_policy_transient_for_done(void *data, struct tizen_policy *tizen_policy, uint32_t child_id);
262 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);
263 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);
264 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);
265 static void _cb_wl_tz_policy_allowed_aux_hint(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface_resource, int id);
266 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);
268 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);
270 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);
271 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);
272 static void _cb_error(void *data EINA_UNUSED, struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED, uint32_t errorcode);
273 static void _cb_block_expired(void *data EINA_UNUSED, struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED);
275 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);
276 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);
277 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);
278 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);
279 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);
280 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);
281 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);
282 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);
283 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);
286 static const struct wl_registry_listener _wl_reg_listener =
289 _cb_wl_reg_global_remove
292 static const struct wl_registry_listener _wl_reg_screenshooter_listener =
294 _cb_wl_reg_screenshooter_global,
295 _cb_wl_reg_screenshooter_global_remove
298 struct tizen_policy_listener _wl_tz_policy_listener =
300 _cb_wl_tz_policy_conformant,
301 _cb_wl_tz_policy_conformant_area,
302 _cb_wl_tz_policy_notification_done,
303 _cb_wl_tz_policy_transient_for_done,
304 _cb_wl_tz_policy_scr_mode_done,
305 _cb_wl_tz_policy_iconify_state_changed,
306 _cb_wl_tz_policy_supported_aux_hints,
307 _cb_wl_tz_policy_allowed_aux_hint,
308 _cb_wl_tz_policy_aux_message,
311 struct tizen_input_device_manager_listener _wl_tz_devmgr_listener =
319 struct tizen_display_policy_listener _wl_tz_display_policy_listener =
321 _cb_wl_tz_display_policy_brightness_done,
324 struct tizen_gesture_listener _wl_tz_gesture_listener =
326 _cb_gesture_edge_swipe_notify,
327 _cb_gesture_edge_swipe,
328 _cb_gesture_edge_drag_notify,
329 _cb_gesture_edge_drag,
330 _cb_gesture_tap_notify,
332 _cb_gesture_palm_cover_notify,
333 _cb_gesture_palm_cover,
334 _cb_gesture_activate_notify
338 _cb_info_add(Evas_Object *win,
343 Efl_Util_Callback_Info *info;
345 info = _cb_info_find_by_win(win, idx);
348 _eflutil.cb_handler[idx].info_list
349 = eina_list_remove(_eflutil.cb_handler[idx].info_list,
354 info = (Efl_Util_Callback_Info *)calloc(1, sizeof(Efl_Util_Callback_Info));
355 if (!info) return EINA_FALSE;
361 _eflutil.cb_handler[idx].info_list
362 = eina_list_append(_eflutil.cb_handler[idx].info_list,
369 _cb_info_del_by_win(Evas_Object *win,
372 Efl_Util_Callback_Info *info;
374 info = _cb_info_find_by_win(win, idx);
375 if (!info) return EINA_FALSE;
377 _eflutil.cb_handler[idx].info_list
378 = eina_list_remove(_eflutil.cb_handler[idx].info_list,
386 _cb_info_list_get(int idx)
388 return _eflutil.cb_handler[idx].info_list;
391 static Efl_Util_Callback_Info *
392 _cb_info_find_by_win(Evas_Object *win,
396 Efl_Util_Callback_Info *info;
398 l = _cb_info_list_get(idx);
399 EINA_LIST_FOREACH(l, ll, info)
401 if (info->win == win) return info;
410 struct wl_display *display_wrapper = NULL;
411 struct wl_registry *reg = NULL;
413 if (_eflutil.wl.init) return EINA_TRUE;
417 _eflutil.wl.dpy = ecore_wl_display_get();
418 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.dpy, fail);
420 display_wrapper = wl_proxy_create_wrapper(_eflutil.wl.dpy);
421 EINA_SAFETY_ON_NULL_GOTO(display_wrapper, fail);
423 _eflutil.wl.queue = wl_display_create_queue(_eflutil.wl.dpy);
424 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.queue, fail);
426 wl_proxy_set_queue((struct wl_proxy *)display_wrapper, _eflutil.wl.queue);
428 reg = wl_display_get_registry(display_wrapper);
429 wl_proxy_wrapper_destroy(display_wrapper);
430 display_wrapper = NULL;
431 EINA_SAFETY_ON_NULL_GOTO(reg, fail);
433 wl_registry_add_listener(reg, &_wl_reg_listener, NULL);
435 _eflutil.wl.init = EINA_TRUE;
440 wl_proxy_wrapper_destroy(display_wrapper);
442 if (_eflutil.wl.queue)
444 wl_event_queue_destroy(_eflutil.wl.queue);
445 _eflutil.wl.queue = NULL;
453 _cb_wl_output_geometry(void *data, struct wl_output *wl_output, int x, int y,
454 int physical_width, int physical_height, int subpixel,
455 const char *make, const char *model, int transform)
457 Efl_Util_Wl_Output_Info *output = wl_output_get_user_data(wl_output);
458 if (wl_output == output->output)
460 output->offset_x = x;
461 output->offset_y = y;
466 _cb_wl_output_mode(void *data, struct wl_output *wl_output, uint32_t flags,
467 int width, int height, int refresh)
469 Efl_Util_Wl_Output_Info *output = wl_output_get_user_data(wl_output);
470 if (wl_output == output->output && (flags & WL_OUTPUT_MODE_CURRENT))
472 output->width = width;
473 output->height = height;
478 _cb_wl_output_done(void *data, struct wl_output *wl_output)
483 _cb_wl_output_scale(void *data, struct wl_output *wl_output, int32_t factor)
487 static const struct wl_output_listener output_listener =
489 _cb_wl_output_geometry,
496 _cb_wl_screenshot_done(void *data, struct screenshooter *screenshooter)
498 Eina_Bool *shot_done = (Eina_Bool*)data;
500 *shot_done = EINA_TRUE;
503 static const struct screenshooter_listener screenshooter_listener =
505 _cb_wl_screenshot_done
509 _cb_tz_screenshot_format(void *data, struct tizen_screenshooter *tz_screenshooter, uint32_t format)
514 _cb_tz_screenshot_noti(void *data, struct tizen_screenshooter *tz_screenshooter, uint32_t noti)
516 _eflutil.wl.shot.noti = noti;
519 static const struct tizen_screenshooter_listener tz_screenshooter_listener =
521 _cb_tz_screenshot_format,
522 _cb_tz_screenshot_noti
526 _cb_wl_reg_global(void *data,
527 struct wl_registry *reg,
529 const char *interface,
530 unsigned int version)
532 if (!strcmp(interface, "tizen_policy"))
534 struct tizen_policy *proto;
535 proto = wl_registry_bind(reg,
537 &tizen_policy_interface,
541 tizen_policy_add_listener(proto,
542 &_wl_tz_policy_listener,
545 _eflutil.wl.policy.hash_noti_lv = eina_hash_pointer_new(free);
546 _eflutil.wl.policy.hash_scr_mode = eina_hash_pointer_new(free);
547 _eflutil.wl.policy.proto = proto;
549 else if (strcmp(interface, "wl_output") == 0)
551 Efl_Util_Wl_Output_Info *output = calloc(1, sizeof(Efl_Util_Wl_Output_Info));
552 EINA_SAFETY_ON_NULL_RETURN(output);
554 _eflutil.wl.shot.output_list = eina_list_append(_eflutil.wl.shot.output_list, output);
556 output->output = wl_registry_bind(reg, name, &wl_output_interface, version);
557 wl_output_add_listener(output->output, &output_listener, output);
559 else if (strcmp(interface, "tizen_input_device_manager") == 0)
561 _eflutil.wl.devmgr.devicemgr = wl_registry_bind(reg, name, &tizen_input_device_manager_interface, version);
562 tizen_input_device_manager_add_listener(_eflutil.wl.devmgr.devicemgr, &_wl_tz_devmgr_listener, NULL);
564 else if (!strcmp(interface, "tizen_display_policy"))
566 _eflutil.wl.display_policy.proto = wl_registry_bind(reg, name, &tizen_display_policy_interface, version);
567 if (!_eflutil.wl.display_policy.proto) return;
569 tizen_display_policy_add_listener(_eflutil.wl.display_policy.proto,
570 &_wl_tz_display_policy_listener,
573 _eflutil.wl.display_policy.hash_brightness = eina_hash_pointer_new(free);
575 else if (strcmp(interface, "tizen_gesture") == 0)
577 _eflutil.wl.gesture.proto = wl_registry_bind(reg, name, &tizen_gesture_interface, version);
578 tizen_gesture_add_listener(_eflutil.wl.gesture.proto, &_wl_tz_gesture_listener, NULL);
581 /* LCOV_EXCL_START */
583 _cb_wl_reg_global_remove(void *data,
584 struct wl_registry *reg,
587 _eflutil.wl.policy.proto = NULL;
588 eina_hash_free(_eflutil.wl.policy.hash_noti_lv);
589 eina_hash_free(_eflutil.wl.policy.hash_scr_mode);
591 _eflutil.wl.display_policy.proto = NULL;
592 eina_hash_free(_eflutil.wl.display_policy.hash_brightness);
597 _cb_wl_reg_screenshooter_global(void *data,
598 struct wl_registry *reg,
600 const char *interface,
601 unsigned int version)
603 if (strcmp(interface, "screenshooter") == 0)
605 _eflutil.wl.shot.screenshooter = wl_registry_bind(reg, name, &screenshooter_interface, version);
606 screenshooter_add_listener(_eflutil.wl.shot.screenshooter, &screenshooter_listener, NULL);
608 else if (strcmp(interface, "tizen_screenshooter") == 0)
610 _eflutil.wl.shot.tz_screenshooter = wl_registry_bind(reg, name, &tizen_screenshooter_interface, version);
611 tizen_screenshooter_add_listener(_eflutil.wl.shot.tz_screenshooter, &tz_screenshooter_listener, NULL);
613 wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
617 /* LCOV_EXCL_START */
619 _cb_wl_reg_screenshooter_global_remove(void *data,
620 struct wl_registry *reg,
625 static Efl_Util_Callback_Info *
626 _cb_info_find_by_wlsurf(void *wlsurf,
630 Efl_Util_Callback_Info *info;
631 Ecore_Wl_Window *wlwin2 = NULL;
632 void *wlsurf2 = NULL;
634 l = _cb_info_list_get(idx);
635 EINA_LIST_FOREACH(l, ll, info)
637 wlwin2 = elm_win_wl_window_get(info->win);
638 wlsurf2 = ecore_wl_window_surface_get(wlwin2);
639 if (wlsurf== wlsurf2) return info;
646 _cb_wl_tz_policy_conformant(void *data, struct tizen_policy *tizen_policy,
647 struct wl_surface *surface, uint32_t is_conformant)
652 _cb_wl_tz_policy_conformant_area(void *data, struct tizen_policy *tizen_policy,
653 struct wl_surface *surface, uint32_t conformant_part,
654 uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h)
660 _cb_wl_tz_policy_notification_done(void *data,
661 struct tizen_policy *tizen_policy,
662 struct wl_surface *surface,
666 Efl_Util_Wl_Surface_Lv_Info *lv_info;
667 Efl_Util_Callback_Info *cb_info;
669 lv_info = eina_hash_find(_eflutil.wl.policy.hash_noti_lv, &surface);
672 lv_info->level = level;
673 lv_info->wait_for_done = EINA_FALSE;
674 lv_info->state = state;
677 if (state != TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED) return;
679 cb_info = _cb_info_find_by_wlsurf((void *)surface, CBH_NOTI_LEV);
680 if (!cb_info) return;
681 if (!cb_info->cb) return;
683 cb_info->cb(cb_info->win,
684 EFL_UTIL_ERROR_PERMISSION_DENIED,
688 /* LCOV_EXCL_START */
690 _cb_wl_tz_policy_transient_for_done(void *data, struct tizen_policy *tizen_policy, uint32_t child_id)
696 _cb_wl_tz_policy_scr_mode_done(void *data,
697 struct tizen_policy *tizen_policy,
698 struct wl_surface *surface,
703 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
704 Efl_Util_Callback_Info *cb_info;
706 scr_mode_info = eina_hash_find(_eflutil.wl.policy.hash_scr_mode, &surface);
709 scr_mode_info->mode = mode;
710 scr_mode_info->wait_for_done = EINA_FALSE;
711 scr_mode_info->state = state;
714 if (state != TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED) return;
716 cb_info = _cb_info_find_by_wlsurf((void *)surface, CBH_SCR_MODE);
717 if (!cb_info) return;
718 if (!cb_info->cb) return;
720 cb_info->cb(cb_info->win,
721 EFL_UTIL_ERROR_PERMISSION_DENIED,
725 /* LCOV_EXCL_START */
726 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)
730 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)
734 static void _cb_wl_tz_policy_allowed_aux_hint(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface_resource, int id)
738 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)
744 _cb_wl_tz_display_policy_brightness_done(void *data,
745 struct tizen_display_policy *tizen_display_policy,
746 struct wl_surface *surface,
750 Efl_Util_Wl_Surface_Brightness_Info *brightness_info;
752 brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
755 brightness_info->brightness = brightness;
756 brightness_info->wait_for_done = EINA_FALSE;
757 brightness_info->state = state;
762 _cb_window_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
764 Efl_Util_Wl_Surface_Lv_Info *lv_info;
767 if (EINA_UNLIKELY(!lv_info))
770 eina_hash_del(_eflutil.wl.policy.hash_noti_lv, &lv_info->surface, lv_info);
774 efl_util_set_notification_window_level(Evas_Object *window,
775 efl_util_notification_level_e level)
779 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
780 EINA_SAFETY_ON_FALSE_RETURN_VAL((level >= EFL_UTIL_NOTIFICATION_LEVEL_NONE) &&
781 (level <= EFL_UTIL_NOTIFICATION_LEVEL_TOP),
782 EFL_UTIL_ERROR_INVALID_PARAMETER);
784 if (level == EFL_UTIL_NOTIFICATION_LEVEL_1)
786 dlog_print(DLOG_WARN, LOG_TAG,
787 "DEPRECATION WARNING: EFL_UTIL_NOTIFICATION_LEVEL_1 is deprecated and will be removed from next release. Use EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT instead.");
789 else if (level == EFL_UTIL_NOTIFICATION_LEVEL_2)
791 dlog_print(DLOG_WARN, LOG_TAG,
792 "DEPRECATION WARNING: EFL_UTIL_NOTIFICATION_LEVEL_2 is deprecated and will be removed from next release. Use EFL_UTIL_NOTIFICATION_LEVEL_MEDIUM instead.");
794 else if (level == EFL_UTIL_NOTIFICATION_LEVEL_3)
796 dlog_print(DLOG_WARN, LOG_TAG,
797 "DEPRECATION WARNING: EFL_UTIL_NOTIFICATION_LEVEL_3 is deprecated and will be removed from next release. Use EFL_UTIL_NOTIFICATION_LEVEL_TOP instead.");
801 Ecore_Wl_Window *wlwin;
802 struct wl_surface *surface;
803 Efl_Util_Wl_Surface_Lv_Info *lv_info;
804 Ecore_Wl_Window_Type wl_type;
807 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
809 wlwin = elm_win_wl_window_get(window);
810 EINA_SAFETY_ON_NULL_RETURN_VAL(wlwin, EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
812 type = elm_win_type_get(window);
813 if (type != ELM_WIN_NOTIFICATION)
815 wl_type = ecore_wl_window_type_get(wlwin);
816 EINA_SAFETY_ON_FALSE_RETURN_VAL((wl_type == ECORE_WL_WINDOW_TYPE_NOTIFICATION),
817 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
820 while (!_eflutil.wl.policy.proto)
821 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
823 surface = ecore_wl_window_surface_get(wlwin);
824 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
825 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
827 lv_info = eina_hash_find(_eflutil.wl.policy.hash_noti_lv, &surface);
830 lv_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Lv_Info));
831 EINA_SAFETY_ON_NULL_RETURN_VAL(lv_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
833 lv_info->surface = surface;
834 lv_info->level = (int)level;
835 lv_info->wait_for_done = EINA_TRUE;
836 lv_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
837 eina_hash_add(_eflutil.wl.policy.hash_noti_lv,
841 evas_object_event_callback_add(window, EVAS_CALLBACK_DEL,
842 _cb_window_del, lv_info);
846 lv_info->level = (int)level;
847 lv_info->wait_for_done = EINA_TRUE;
848 lv_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
852 tizen_policy_set_notification_level(_eflutil.wl.policy.proto,
853 surface, (int)level);
855 if (lv_info->wait_for_done)
858 while (lv_info->wait_for_done && (count < 3))
861 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
865 if (lv_info->wait_for_done)
867 return EFL_UTIL_ERROR_INVALID_PARAMETER;
871 if (lv_info->state == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
873 return EFL_UTIL_ERROR_PERMISSION_DENIED;
878 return EFL_UTIL_ERROR_NONE;
882 efl_util_get_notification_window_level(Evas_Object *window,
883 efl_util_notification_level_e *level)
887 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
888 EINA_SAFETY_ON_NULL_RETURN_VAL(level, EFL_UTIL_ERROR_INVALID_PARAMETER);
891 Ecore_Wl_Window *wlwin;
892 struct wl_surface *surface;
893 Efl_Util_Wl_Surface_Lv_Info *lv_info;
894 Ecore_Wl_Window_Type wl_type;
897 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
899 wlwin = elm_win_wl_window_get(window);
900 EINA_SAFETY_ON_NULL_RETURN_VAL(wlwin, EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
902 type = elm_win_type_get(window);
903 if (type != ELM_WIN_NOTIFICATION)
905 wl_type = ecore_wl_window_type_get(wlwin);
906 EINA_SAFETY_ON_FALSE_RETURN_VAL((wl_type == ECORE_WL_WINDOW_TYPE_NOTIFICATION),
907 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
910 while (!_eflutil.wl.policy.proto)
911 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
913 surface = ecore_wl_window_surface_get(wlwin);
914 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
915 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
917 lv_info = eina_hash_find(_eflutil.wl.policy.hash_noti_lv, &surface);
920 if (lv_info->wait_for_done)
923 while ((lv_info->wait_for_done) && (count < 3))
926 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
930 if (lv_info->wait_for_done)
932 *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
933 return EFL_UTIL_ERROR_INVALID_PARAMETER;
937 switch (lv_info->level)
939 case TIZEN_POLICY_LEVEL_1: *level = EFL_UTIL_NOTIFICATION_LEVEL_1; break;
940 case TIZEN_POLICY_LEVEL_2: *level = EFL_UTIL_NOTIFICATION_LEVEL_2; break;
941 case TIZEN_POLICY_LEVEL_3: *level = EFL_UTIL_NOTIFICATION_LEVEL_3; break;
942 case TIZEN_POLICY_LEVEL_NONE: *level = EFL_UTIL_NOTIFICATION_LEVEL_NONE; break;
943 case TIZEN_POLICY_LEVEL_DEFAULT: *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT; break;
944 case TIZEN_POLICY_LEVEL_MEDIUM: *level = EFL_UTIL_NOTIFICATION_LEVEL_MEDIUM; break;
945 case TIZEN_POLICY_LEVEL_HIGH: *level = EFL_UTIL_NOTIFICATION_LEVEL_HIGH; break;
946 case TIZEN_POLICY_LEVEL_TOP: *level = EFL_UTIL_NOTIFICATION_LEVEL_TOP; break;
947 default: *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
948 return EFL_UTIL_ERROR_INVALID_PARAMETER;
950 return EFL_UTIL_ERROR_NONE;
953 *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
955 return EFL_UTIL_ERROR_NONE;
959 efl_util_set_notification_window_level_error_cb(Evas_Object *window,
960 efl_util_notification_window_level_error_cb callback,
963 dlog_print(DLOG_WARN, LOG_TAG,
964 "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.");
966 Eina_Bool ret = EINA_FALSE;
968 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
969 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EFL_UTIL_ERROR_INVALID_PARAMETER);
971 ret = _cb_info_add(window,
972 (Efl_Util_Cb)callback,
975 if (!ret) return EFL_UTIL_ERROR_OUT_OF_MEMORY;
977 return EFL_UTIL_ERROR_NONE;
981 efl_util_unset_notification_window_level_error_cb(Evas_Object *window)
983 dlog_print(DLOG_WARN, LOG_TAG,
984 "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.");
986 Eina_Bool ret = EINA_FALSE;
988 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
990 ret = _cb_info_del_by_win(window, CBH_NOTI_LEV);
991 if (!ret) return EFL_UTIL_ERROR_INVALID_PARAMETER;
993 return EFL_UTIL_ERROR_NONE;
997 efl_util_set_window_opaque_state(Evas_Object *window,
1002 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1003 EINA_SAFETY_ON_FALSE_RETURN_VAL(((opaque >= 0) && (opaque <= 1)),
1004 EFL_UTIL_ERROR_INVALID_PARAMETER);
1006 Ecore_Wl_Window *wlwin;
1007 struct wl_surface *surface;
1009 if (!_eflutil.wl.policy.proto)
1014 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1016 while (!_eflutil.wl.policy.proto && ret != -1)
1017 ret = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1019 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.policy.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
1022 wlwin = elm_win_wl_window_get(window);
1024 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
1026 surface = ecore_wl_window_surface_get(wlwin);
1028 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
1030 tizen_policy_set_opaque_state(_eflutil.wl.policy.proto, surface, opaque);
1032 return EFL_UTIL_ERROR_NONE;
1036 efl_util_set_window_screen_mode(Evas_Object *window,
1037 efl_util_screen_mode_e mode)
1039 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1040 EINA_SAFETY_ON_FALSE_RETURN_VAL(((mode >= EFL_UTIL_SCREEN_MODE_DEFAULT) &&
1041 (mode <= EFL_UTIL_SCREEN_MODE_ALWAYS_ON)),
1042 EFL_UTIL_ERROR_INVALID_PARAMETER);
1044 Ecore_Wl_Window *wlwin;
1045 struct wl_surface *surface;
1046 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
1050 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1052 wlwin = elm_win_wl_window_get(window);
1055 while (!_eflutil.wl.policy.proto)
1056 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1058 surface = ecore_wl_window_surface_get(wlwin);
1059 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1060 EFL_UTIL_ERROR_INVALID_PARAMETER);
1062 scr_mode_info = eina_hash_find(_eflutil.wl.policy.hash_scr_mode, &surface);
1065 scr_mode_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Scr_Mode_Info));
1066 EINA_SAFETY_ON_NULL_RETURN_VAL(scr_mode_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
1068 scr_mode_info->surface = surface;
1069 scr_mode_info->mode = (unsigned int)mode;
1070 scr_mode_info->wait_for_done = EINA_TRUE;
1071 scr_mode_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
1073 eina_hash_add(_eflutil.wl.policy.hash_scr_mode,
1079 scr_mode_info->mode = (unsigned int)mode;
1080 scr_mode_info->wait_for_done = EINA_TRUE;
1081 scr_mode_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
1084 tizen_policy_set_window_screen_mode(_eflutil.wl.policy.proto,
1085 surface, (unsigned int)mode);
1086 if (scr_mode_info->wait_for_done)
1089 while (scr_mode_info->wait_for_done && (count < 3))
1092 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1096 if (scr_mode_info->wait_for_done)
1098 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1102 if (scr_mode_info->state == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
1104 return EFL_UTIL_ERROR_PERMISSION_DENIED;
1109 return EFL_UTIL_ERROR_NONE;
1112 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1116 efl_util_get_window_screen_mode(Evas_Object *window,
1117 efl_util_screen_mode_e *mode)
1119 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1120 EINA_SAFETY_ON_NULL_RETURN_VAL(mode, EFL_UTIL_ERROR_INVALID_PARAMETER);
1122 Ecore_Wl_Window *wlwin;
1123 struct wl_surface *surface;
1124 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
1128 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1130 wlwin = elm_win_wl_window_get(window);
1133 while (!_eflutil.wl.policy.proto)
1134 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1136 surface = ecore_wl_window_surface_get(wlwin);
1137 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1138 EFL_UTIL_ERROR_INVALID_PARAMETER);
1140 scr_mode_info = eina_hash_find(_eflutil.wl.policy.hash_scr_mode, &surface);
1143 if (scr_mode_info->wait_for_done)
1145 while (scr_mode_info->wait_for_done)
1148 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1152 switch (scr_mode_info->mode)
1154 case TIZEN_POLICY_MODE_DEFAULT: *mode = EFL_UTIL_SCREEN_MODE_DEFAULT; break;
1155 case TIZEN_POLICY_MODE_ALWAYS_ON: *mode = EFL_UTIL_SCREEN_MODE_ALWAYS_ON; break;
1156 default: *mode = EFL_UTIL_SCREEN_MODE_DEFAULT;
1157 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1159 return EFL_UTIL_ERROR_NONE;
1163 *mode = EFL_UTIL_SCREEN_MODE_DEFAULT;
1164 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1168 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1172 efl_util_set_window_screen_mode_error_cb(Evas_Object *window,
1173 efl_util_window_screen_mode_error_cb callback,
1176 /* Wearable device cannot use this. */
1177 if (get_tizen_profile() == TIZEN_PROFILE_WEARABLE)
1178 return EFL_UTIL_ERROR_NO_SUCH_DEVICE;
1180 dlog_print(DLOG_WARN, LOG_TAG,
1181 "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.");
1183 Eina_Bool ret = EINA_FALSE;
1185 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1186 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EFL_UTIL_ERROR_INVALID_PARAMETER);
1188 ret = _cb_info_add(window,
1189 (Efl_Util_Cb)callback,
1192 if (!ret) return EFL_UTIL_ERROR_OUT_OF_MEMORY;
1194 return EFL_UTIL_ERROR_NONE;
1198 efl_util_unset_window_screen_mode_error_cb(Evas_Object *window)
1200 /* Wearable device cannot use this. */
1201 if (get_tizen_profile() == TIZEN_PROFILE_WEARABLE)
1202 return EFL_UTIL_ERROR_NO_SUCH_DEVICE;
1204 dlog_print(DLOG_WARN, LOG_TAG,
1205 "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.");
1207 Eina_Bool ret = EINA_FALSE;
1209 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1211 ret = _cb_info_del_by_win(window, CBH_SCR_MODE);
1212 if (!ret) return EFL_UTIL_ERROR_INVALID_PARAMETER;
1214 return EFL_UTIL_ERROR_NONE;
1218 efl_util_set_window_brightness(Evas_Object *window, int brightness)
1220 Ecore_Wl_Window *wlwin;
1221 struct wl_surface *surface;
1222 Efl_Util_Wl_Surface_Brightness_Info *brightness_info;
1225 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1226 EINA_SAFETY_ON_FALSE_RETURN_VAL(brightness <= 100, EFL_UTIL_ERROR_INVALID_PARAMETER);
1229 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1231 wlwin = elm_win_wl_window_get(window);
1234 while (!_eflutil.wl.display_policy.proto)
1235 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1237 surface = ecore_wl_window_surface_get(wlwin);
1238 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1239 EFL_UTIL_ERROR_INVALID_PARAMETER);
1241 brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
1242 if (!brightness_info)
1244 brightness_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Brightness_Info));
1245 EINA_SAFETY_ON_NULL_RETURN_VAL(brightness_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
1247 brightness_info->surface = surface;
1248 brightness_info->brightness = brightness;
1249 brightness_info->wait_for_done = EINA_TRUE;
1250 brightness_info->state = TIZEN_DISPLAY_POLICY_ERROR_STATE_NONE;
1252 eina_hash_add(_eflutil.wl.display_policy.hash_brightness,
1258 brightness_info->brightness = brightness;
1259 brightness_info->wait_for_done = EINA_TRUE;
1260 brightness_info->state = TIZEN_DISPLAY_POLICY_ERROR_STATE_NONE;
1263 tizen_display_policy_set_window_brightness(_eflutil.wl.display_policy.proto,
1264 surface, brightness);
1265 if (brightness_info->wait_for_done)
1268 while (brightness_info->wait_for_done && (count < 3))
1271 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1275 if (brightness_info->wait_for_done)
1277 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1281 if (brightness_info->state == TIZEN_DISPLAY_POLICY_ERROR_STATE_PERMISSION_DENIED)
1283 return EFL_UTIL_ERROR_PERMISSION_DENIED;
1287 return EFL_UTIL_ERROR_NONE;
1290 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1294 efl_util_get_window_brightness(Evas_Object *window, int *brightness)
1296 Ecore_Wl_Window *wlwin;
1297 struct wl_surface *surface;
1298 Efl_Util_Wl_Surface_Brightness_Info *brightness_info;
1301 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1302 EINA_SAFETY_ON_NULL_RETURN_VAL(brightness, EFL_UTIL_ERROR_INVALID_PARAMETER);
1305 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1307 wlwin = elm_win_wl_window_get(window);
1308 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
1310 while (!_eflutil.wl.display_policy.proto)
1311 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1313 surface = ecore_wl_window_surface_get(wlwin);
1314 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1315 EFL_UTIL_ERROR_INVALID_PARAMETER);
1317 brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
1318 if (brightness_info)
1320 if (brightness_info->wait_for_done)
1322 while (brightness_info->wait_for_done)
1325 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1328 *brightness = brightness_info->brightness;
1333 return EFL_UTIL_ERROR_NONE;
1337 struct _efl_util_inputgen_h
1339 unsigned int init_type;
1344 _cb_device_add(void *data EINA_UNUSED,
1345 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1346 uint32_t serial EINA_UNUSED,
1347 const char *identifier EINA_UNUSED,
1348 struct tizen_input_device *device EINA_UNUSED,
1349 struct wl_seat *seat EINA_UNUSED)
1354 /* LCOV_EXCL_START */
1356 _cb_device_remove(void *data EINA_UNUSED,
1357 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1358 uint32_t serial EINA_UNUSED,
1359 const char *identifier EINA_UNUSED,
1360 struct tizen_input_device *device EINA_UNUSED,
1361 struct wl_seat *seat EINA_UNUSED)
1365 /* LCOV_EXCL_STOP */
1368 _cb_error(void *data EINA_UNUSED,
1369 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1372 _eflutil.wl.devmgr.request_notified = errorcode;
1375 /* LCOV_EXCL_START */
1377 _cb_block_expired(void *data EINA_UNUSED,
1378 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED)
1382 /* LCOV_EXCL_STOP */
1384 static efl_util_error_e
1385 _efl_util_input_convert_input_generator_error(int ret)
1389 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE:
1390 return EFL_UTIL_ERROR_NONE;
1391 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NO_PERMISSION:
1392 return EFL_UTIL_ERROR_PERMISSION_DENIED;
1393 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NO_SYSTEM_RESOURCES:
1394 return EFL_UTIL_ERROR_OUT_OF_MEMORY;
1395 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_INVALID_PARAMETER:
1396 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1398 return EFL_UTIL_ERROR_NONE;
1402 API efl_util_inputgen_h
1403 efl_util_input_initialize_generator(unsigned int dev_type)
1405 int ret = EFL_UTIL_ERROR_NONE;
1406 efl_util_inputgen_h inputgen_h = NULL;
1407 unsigned int clas = 0x0;
1410 dev_type & ~(EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN
1411 | EFL_UTIL_INPUT_DEVTYPE_KEYBOARD
1412 | EFL_UTIL_INPUT_DEVTYPE_POINTER))
1414 set_last_result(EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1418 inputgen_h = (efl_util_inputgen_h)calloc(1, sizeof(struct _efl_util_inputgen_h));
1421 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
1425 inputgen_h->init_type |= dev_type;
1428 if (ret == (int)EINA_FALSE)
1430 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1434 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN)
1435 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
1436 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD)
1437 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD;
1438 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_POINTER)
1439 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE;
1441 while (!_eflutil.wl.devmgr.devicemgr)
1442 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1444 tizen_input_device_manager_init_generator(_eflutil.wl.devmgr.devicemgr, clas);
1446 while (_eflutil.wl.devmgr.request_notified == -1)
1447 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1449 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1450 _eflutil.wl.devmgr.request_notified = -1;
1452 set_last_result(ret);
1453 if (ret != TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE)
1467 API efl_util_inputgen_h
1468 efl_util_input_initialize_generator_with_name(unsigned int dev_type, const char *name)
1470 int ret = EFL_UTIL_ERROR_NONE;
1471 efl_util_inputgen_h inputgen_h = NULL;
1472 unsigned int clas = 0x0;
1475 dev_type & ~(EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN
1476 | EFL_UTIL_INPUT_DEVTYPE_KEYBOARD
1477 | EFL_UTIL_INPUT_DEVTYPE_POINTER))
1479 set_last_result(EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1483 inputgen_h = (efl_util_inputgen_h)calloc(1, sizeof(struct _efl_util_inputgen_h));
1486 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
1490 inputgen_h->init_type |= dev_type;
1491 strncpy(inputgen_h->name, name, 31);
1494 if (ret == (int)EINA_FALSE)
1496 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1500 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN)
1501 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
1502 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD)
1503 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD;
1504 if (dev_type & EFL_UTIL_INPUT_DEVTYPE_POINTER)
1505 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE;
1507 while (!_eflutil.wl.devmgr.devicemgr)
1508 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1510 tizen_input_device_manager_init_generator_with_name(_eflutil.wl.devmgr.devicemgr, clas, inputgen_h->name);
1512 while (_eflutil.wl.devmgr.request_notified == -1)
1513 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1515 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1516 _eflutil.wl.devmgr.request_notified = -1;
1518 set_last_result(ret);
1519 if (ret != TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE)
1535 efl_util_input_deinitialize_generator(efl_util_inputgen_h inputgen_h)
1537 int ret = EFL_UTIL_ERROR_NONE;
1538 unsigned int clas = 0x0;
1539 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1541 if (inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN)
1542 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
1543 if (inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD)
1544 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD;
1545 if (inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_POINTER)
1546 clas |= TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE;
1551 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1553 tizen_input_device_manager_deinit_generator(_eflutil.wl.devmgr.devicemgr, clas);
1555 while (_eflutil.wl.devmgr.request_notified == -1)
1556 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1558 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1559 _eflutil.wl.devmgr.request_notified = -1;
1565 efl_util_input_generate_key(efl_util_inputgen_h inputgen_h, const char *key_name, int pressed)
1567 int ret = EFL_UTIL_ERROR_NONE;
1569 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1570 EINA_SAFETY_ON_NULL_RETURN_VAL(key_name, EFL_UTIL_ERROR_INVALID_PARAMETER);
1571 EINA_SAFETY_ON_FALSE_RETURN_VAL(pressed == 0 || pressed == 1, EFL_UTIL_ERROR_INVALID_PARAMETER);
1572 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1574 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1576 tizen_input_device_manager_generate_key(_eflutil.wl.devmgr.devicemgr, key_name, pressed);
1578 while (_eflutil.wl.devmgr.request_notified == -1)
1579 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1581 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1582 _eflutil.wl.devmgr.request_notified = -1;
1588 efl_util_input_generate_touch(efl_util_inputgen_h inputgen_h, int idx,
1589 efl_util_input_touch_type_e touch_type, int x, int y)
1592 enum tizen_input_device_manager_pointer_event_type type;
1594 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1595 EINA_SAFETY_ON_FALSE_RETURN_VAL(idx >= 0, EFL_UTIL_ERROR_INVALID_PARAMETER);
1596 EINA_SAFETY_ON_FALSE_RETURN_VAL((x > 0 && y > 0), EFL_UTIL_ERROR_INVALID_PARAMETER);
1597 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1599 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1603 case EFL_UTIL_INPUT_TOUCH_BEGIN:
1604 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_BEGIN;
1606 case EFL_UTIL_INPUT_TOUCH_UPDATE:
1607 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_UPDATE;
1609 case EFL_UTIL_INPUT_TOUCH_END:
1610 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_END;
1613 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1616 tizen_input_device_manager_generate_touch(_eflutil.wl.devmgr.devicemgr, type, x, y, idx);
1618 while (_eflutil.wl.devmgr.request_notified == -1)
1619 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1621 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1622 _eflutil.wl.devmgr.request_notified = -1;
1628 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)
1631 enum tizen_input_device_manager_pointer_event_type type;
1633 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1634 EINA_SAFETY_ON_FALSE_RETURN_VAL(buttons > 0, EFL_UTIL_ERROR_INVALID_PARAMETER);
1635 EINA_SAFETY_ON_FALSE_RETURN_VAL((x >= 0 && y >= 0), EFL_UTIL_ERROR_INVALID_PARAMETER);
1636 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_POINTER, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1638 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1640 switch(pointer_type)
1642 case EFL_UTIL_INPUT_POINTER_BUTTON_DOWN:
1643 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_BEGIN;
1645 case EFL_UTIL_INPUT_POINTER_MOVE:
1646 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_UPDATE;
1648 case EFL_UTIL_INPUT_POINTER_BUTTON_UP:
1649 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_END;
1652 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1655 tizen_input_device_manager_generate_pointer(_eflutil.wl.devmgr.devicemgr, type, x, y, buttons);
1657 while (_eflutil.wl.devmgr.request_notified == -1)
1658 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1660 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1661 _eflutil.wl.devmgr.request_notified = -1;
1667 struct _efl_util_screenshot_h
1672 Eina_Bool shot_done;
1677 Eina_Bool auto_rotation;
1680 /* scrrenshot handle */
1681 static efl_util_screenshot_h g_screenshot;
1682 static Eina_Bool shot_mutex_init;
1683 static pthread_mutex_t shot_lock;
1686 _screenshot_mutex_init(void)
1688 if (shot_mutex_init)
1691 if (pthread_mutex_init(&shot_lock, NULL))
1693 fprintf(stderr, "[screenshot] fail: mutex init"); /*LCOV_EXCL_LINE*/
1694 return EINA_FALSE; /*LCOV_EXCL_LINE*/
1697 shot_mutex_init = EINA_TRUE;
1703 _screenshot_mutex_destory(void)
1705 if (!shot_mutex_init)
1708 if (pthread_mutex_destroy(&shot_lock))
1710 fprintf(stderr, "[screenshot] fail: mutex destory"); /*LCOV_EXCL_LINE*/
1711 return EINA_FALSE; /*LCOV_EXCL_LINE*/
1714 shot_mutex_init = EINA_FALSE;
1720 _screenshot_mutex_lock(void)
1722 if (!_screenshot_mutex_init())
1725 pthread_mutex_lock(&shot_lock);
1729 _screenshot_mutex_unlock(void)
1731 pthread_mutex_unlock(&shot_lock);
1734 API efl_util_screenshot_h
1735 efl_util_screenshot_initialize(int width, int height)
1737 efl_util_screenshot_h screenshot = NULL;
1738 struct wl_display *display_wrapper = NULL;
1739 struct wl_registry *reg = NULL;
1742 EINA_SAFETY_ON_FALSE_GOTO(width > 0, fail_param);
1743 EINA_SAFETY_ON_FALSE_GOTO(height > 0, fail_param);
1745 _screenshot_mutex_lock();
1747 if (!_eflutil.wl.shot.screenshooter)
1750 if (ret == (int)EINA_FALSE)
1752 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1753 _screenshot_mutex_unlock();
1756 wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1758 display_wrapper = wl_proxy_create_wrapper(_eflutil.wl.dpy);
1759 EINA_SAFETY_ON_NULL_GOTO(display_wrapper, fail_memory);
1761 _eflutil.wl.shot.queue = wl_display_create_queue(_eflutil.wl.dpy);
1762 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.queue, fail_memory);
1764 wl_proxy_set_queue((struct wl_proxy *)display_wrapper, _eflutil.wl.shot.queue);
1766 reg = wl_display_get_registry(display_wrapper);
1767 wl_proxy_wrapper_destroy(display_wrapper);
1768 display_wrapper = NULL;
1769 EINA_SAFETY_ON_NULL_GOTO(reg, fail_init);
1771 wl_registry_add_listener(reg, &_wl_reg_screenshooter_listener, NULL);
1773 ret = wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
1774 EINA_SAFETY_ON_TRUE_GOTO(ret == -1, fail_init);
1775 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.screenshooter, fail_init);
1776 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.tz_screenshooter, fail_init);
1778 _eflutil.wl.shot.tbm_client = wayland_tbm_client_init(_eflutil.wl.dpy);
1779 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.tbm_client, fail_init);
1782 if (_eflutil.wl.shot.noti == 0)
1784 fprintf(stderr, "[screenshot] fail: privilege error\n"); /* LCOV_EXCL_LINE */
1790 if (g_screenshot->width != width || g_screenshot->height != height)
1792 g_screenshot->width = width;
1793 g_screenshot->height = height;
1796 _screenshot_mutex_unlock();
1798 return g_screenshot;
1801 screenshot = calloc(1, sizeof(struct _efl_util_screenshot_h));
1802 EINA_SAFETY_ON_NULL_GOTO(screenshot, fail_memory);
1804 screenshot->width = width;
1805 screenshot->height = height;
1806 screenshot->auto_rotation = EINA_TRUE;
1808 screenshot->bufmgr = wayland_tbm_client_get_bufmgr(_eflutil.wl.shot.tbm_client);
1809 EINA_SAFETY_ON_NULL_GOTO(screenshot->bufmgr, fail_init);
1811 g_screenshot = screenshot;
1812 set_last_result(EFL_UTIL_ERROR_NONE);
1814 screenshooter_set_user_data(_eflutil.wl.shot.screenshooter, &screenshot->shot_done);
1816 _screenshot_mutex_unlock();
1818 return g_screenshot;
1821 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1824 /* LCOV_EXCL_START */
1825 if (display_wrapper)
1826 wl_proxy_wrapper_destroy(display_wrapper);
1827 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
1831 efl_util_screenshot_deinitialize(screenshot);
1832 _screenshot_mutex_unlock();
1833 set_last_result(EFL_UTIL_ERROR_SCREENSHOT_INIT_FAIL);
1835 /* LCOV_EXCL_STOP */
1839 efl_util_screenshot_deinitialize(efl_util_screenshot_h screenshot)
1841 _screenshot_mutex_lock();
1845 _screenshot_mutex_unlock();
1846 _screenshot_mutex_destory();
1847 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1851 g_screenshot = NULL;
1853 if (_eflutil.wl.shot.queue)
1855 wl_event_queue_destroy(_eflutil.wl.shot.queue);
1856 _eflutil.wl.shot.queue = NULL;
1859 if (_eflutil.wl.shot.screenshooter)
1861 screenshooter_destroy(_eflutil.wl.shot.screenshooter);
1862 _eflutil.wl.shot.screenshooter = NULL;
1864 if (_eflutil.wl.shot.tz_screenshooter)
1866 tizen_screenshooter_destroy(_eflutil.wl.shot.tz_screenshooter);
1867 _eflutil.wl.shot.tz_screenshooter = NULL;
1870 _screenshot_mutex_unlock();
1871 _screenshot_mutex_destory();
1873 return EFL_UTIL_ERROR_NONE;
1878 efl_util_screenshot_take_tbm_surface(efl_util_screenshot_h screenshot)
1880 tbm_surface_h t_surface = NULL;
1881 struct wl_buffer *buffer = NULL;
1882 Efl_Util_Wl_Output_Info *output;
1885 _screenshot_mutex_lock();
1887 if (!screenshot || (screenshot != g_screenshot))
1889 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1890 _screenshot_mutex_unlock();
1894 output = eina_list_nth(_eflutil.wl.shot.output_list, 0);
1897 fprintf(stderr, "[screenshot] fail: no output for screenshot\n"); /* LCOV_EXCL_LINE */
1901 t_surface = tbm_surface_create(screenshot->width, screenshot->height, TBM_FORMAT_XRGB8888);
1904 fprintf(stderr, "[screenshot] fail: tbm_surface_create\n"); /* LCOV_EXCL_LINE */
1908 buffer = wayland_tbm_client_create_buffer(_eflutil.wl.shot.tbm_client, t_surface);
1911 fprintf(stderr, "[screenshot] fail: create wl_buffer for screenshot\n"); /* LCOV_EXCL_LINE */
1915 screenshooter_shoot(_eflutil.wl.shot.screenshooter, output->output, buffer);
1917 screenshot->shot_done = EINA_FALSE;
1918 while (!screenshot->shot_done && ret != -1)
1919 ret = wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.shot.queue);
1923 fprintf(stderr, "[screenshot] fail: screenshooter_shoot\n"); /* LCOV_EXCL_LINE */
1927 wl_buffer_destroy(buffer);
1929 /* reset shot_done for next screenshot */
1930 screenshot->shot_done = EINA_FALSE;
1932 set_last_result(EFL_UTIL_ERROR_NONE);
1934 _screenshot_mutex_unlock();
1940 tbm_surface_destroy(t_surface);
1942 wl_buffer_destroy(buffer);
1944 set_last_result(EFL_UTIL_ERROR_SCREENSHOT_EXECUTION_FAIL);
1946 _screenshot_mutex_unlock();
1952 efl_util_screenshot_set_auto_rotation(efl_util_screenshot_h screenshot, int set)
1954 if (!screenshot || (screenshot != g_screenshot))
1955 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1957 if (!(set == 0 || set == 1))
1958 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1961 g_screenshot->auto_rotation = EINA_TRUE;
1963 g_screenshot->auto_rotation = EINA_FALSE;
1965 tizen_screenshooter_set_oneshot_auto_rotation(_eflutil.wl.shot.tz_screenshooter, g_screenshot->auto_rotation);
1967 return EFL_UTIL_ERROR_NONE;
1971 efl_util_screenshot_get_auto_rotation(efl_util_screenshot_h screenshot, int *set)
1973 if (!screenshot || (screenshot != g_screenshot) || !set)
1974 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1976 *set = g_screenshot->auto_rotation;
1978 return EFL_UTIL_ERROR_NONE;
1981 struct _efl_util_gesture_h
1986 API int EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = 0;
1987 API int EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = 0;
1988 API int EFL_UTIL_EVENT_GESTURE_TAP = 0;
1989 API int EFL_UTIL_EVENT_GESTURE_PALM_COVER = 0;
1992 _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)
1994 _eflutil.wl.gesture.request_notified = error;
1998 _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)
2000 efl_util_event_gesture_edge_swipe_s *ev = NULL;
2002 ev = (efl_util_event_gesture_edge_swipe_s *)calloc(1, sizeof(*ev));
2007 ev->fingers = fingers;
2012 ecore_event_add(EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE, ev, NULL, NULL);
2016 _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)
2018 _eflutil.wl.gesture.request_notified = error;
2022 _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)
2024 efl_util_event_gesture_edge_drag_s *ev = NULL;
2026 ev = (efl_util_event_gesture_edge_drag_s *)calloc(1, sizeof(*ev));
2031 ev->fingers = fingers;
2036 ecore_event_add(EFL_UTIL_EVENT_GESTURE_EDGE_DRAG, ev, NULL, NULL);
2040 _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)
2042 _eflutil.wl.gesture.request_notified = error;
2046 _cb_gesture_tap(void *data EINA_UNUSED, struct tizen_gesture *tizen_gesture EINA_UNUSED, uint32_t mode, uint32_t fingers, uint32_t repeats)
2048 efl_util_event_gesture_tap_s *ev = NULL;
2050 ev = (efl_util_event_gesture_tap_s *)calloc(1, sizeof(*ev));
2055 ev->fingers = fingers;
2056 ev->repeats = repeats;
2058 ecore_event_add(EFL_UTIL_EVENT_GESTURE_TAP, ev, NULL, NULL);
2062 _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)
2064 _eflutil.wl.gesture.request_notified = error;
2068 _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)
2070 efl_util_event_gesture_palm_cover_s *ev = NULL;
2072 ev = (efl_util_event_gesture_palm_cover_s *)calloc(1, sizeof(*ev));
2077 ev->duration = duration;
2081 ev->pressure = wl_fixed_to_int(pressure);
2083 ecore_event_add(EFL_UTIL_EVENT_GESTURE_PALM_COVER, ev, NULL, NULL);
2087 _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)
2089 _eflutil.wl.gesture.request_notified = error;
2092 static efl_util_error_e
2093 _efl_util_gesture_convert_error(int ret)
2097 case TIZEN_GESTURE_ERROR_NONE:
2098 return EFL_UTIL_ERROR_NONE;
2099 case TIZEN_GESTURE_ERROR_INVALID_DATA:
2100 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2101 case TIZEN_GESTURE_ERROR_NO_PERMISSION:
2102 return EFL_UTIL_ERROR_PERMISSION_DENIED;
2103 case TIZEN_GESTURE_ERROR_NO_SYSTEM_RESOURCES:
2104 return EFL_UTIL_ERROR_OUT_OF_MEMORY;
2105 case TIZEN_GESTURE_ERROR_GRABBED_ALREADY:
2106 return EFL_UTIL_ERROR_NO_RESOURCE_AVAILABLE;
2107 case TIZEN_GESTURE_ERROR_NOT_SUPPORTED:
2108 return EFL_UTIL_ERROR_NOT_SUPPORTED;
2110 return EFL_UTIL_ERROR_NONE;
2115 _efl_util_gesture_grab_edge_swipe(efl_util_gesture_data data)
2117 int ret = EFL_UTIL_ERROR_NONE;
2118 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2119 Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = NULL;
2120 unsigned int fingers = 0;
2121 unsigned int edge = 0;
2122 unsigned int edge_size = 0;
2123 unsigned int start_point = 0;
2124 unsigned int end_point = 0;
2126 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2128 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2129 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2130 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_SWIPE,
2131 EFL_UTIL_ERROR_INVALID_PARAMETER);
2133 edge_swipe_data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)data;
2135 fingers = edge_swipe_data->fingers;
2136 edge = edge_swipe_data->edge;
2137 edge_size = edge_swipe_data->edge_size;
2138 start_point = edge_swipe_data->start_point;
2139 end_point = edge_swipe_data->end_point;
2141 tizen_gesture_grab_edge_swipe(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2143 while (_eflutil.wl.gesture.request_notified == -1)
2144 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2146 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2147 _eflutil.wl.gesture.request_notified = -1;
2153 _efl_util_gesture_ungrab_edge_swipe(efl_util_gesture_data data)
2155 int ret = EFL_UTIL_ERROR_NONE;
2156 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2157 Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = NULL;
2158 unsigned int fingers = 0;
2159 unsigned int edge = 0;
2160 unsigned int edge_size = 0;
2161 unsigned int start_point = 0;
2162 unsigned int end_point = 0;
2164 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2166 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2167 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2168 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_SWIPE,
2169 EFL_UTIL_ERROR_INVALID_PARAMETER);
2171 edge_swipe_data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)data;
2173 fingers = edge_swipe_data->fingers;
2174 edge = edge_swipe_data->edge;
2175 edge_size = edge_swipe_data->edge_size;
2176 start_point = edge_swipe_data->start_point;
2177 end_point = edge_swipe_data->end_point;
2179 tizen_gesture_ungrab_edge_swipe(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2181 while (_eflutil.wl.gesture.request_notified == -1)
2182 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2184 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2185 _eflutil.wl.gesture.request_notified = -1;
2191 _efl_util_gesture_grab_edge_drag(efl_util_gesture_data data)
2193 int ret = EFL_UTIL_ERROR_NONE;
2194 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2195 Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = NULL;
2196 unsigned int fingers = 0;
2197 unsigned int edge = 0;
2198 unsigned int edge_size = 0;
2199 unsigned int start_point = 0;
2200 unsigned int end_point = 0;
2202 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2204 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2205 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2206 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_DRAG,
2207 EFL_UTIL_ERROR_INVALID_PARAMETER);
2209 edge_drag_data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)data;
2211 fingers = edge_drag_data->fingers;
2212 edge = edge_drag_data->edge;
2213 edge_size = edge_drag_data->edge_size;
2214 start_point = edge_drag_data->start_point;
2215 end_point = edge_drag_data->end_point;
2217 tizen_gesture_grab_edge_drag(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2219 while (_eflutil.wl.gesture.request_notified == -1)
2220 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2222 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2223 _eflutil.wl.gesture.request_notified = -1;
2229 _efl_util_gesture_ungrab_edge_drag(efl_util_gesture_data data)
2231 int ret = EFL_UTIL_ERROR_NONE;
2232 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2233 Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = NULL;
2234 unsigned int fingers = 0;
2235 unsigned int edge = 0;
2236 unsigned int edge_size = 0;
2237 unsigned int start_point = 0;
2238 unsigned int end_point = 0;
2240 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2242 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2243 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2244 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_EDGE_DRAG,
2245 EFL_UTIL_ERROR_INVALID_PARAMETER);
2247 edge_drag_data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)data;
2249 fingers = edge_drag_data->fingers;
2250 edge = edge_drag_data->edge;
2251 edge_size = edge_drag_data->edge_size;
2252 start_point = edge_drag_data->start_point;
2253 end_point = edge_drag_data->end_point;
2255 tizen_gesture_ungrab_edge_drag(_eflutil.wl.gesture.proto, fingers, edge, edge_size, start_point, end_point);
2257 while (_eflutil.wl.gesture.request_notified == -1)
2258 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2260 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2261 _eflutil.wl.gesture.request_notified = -1;
2268 _efl_util_gesture_grab_tap(efl_util_gesture_data data)
2270 int ret = EFL_UTIL_ERROR_NONE;
2271 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2272 Efl_Util_Gesture_Tap_Grab_Data *tap_data = NULL;
2273 unsigned int fingers = 0;
2274 unsigned int repeats = 0;
2276 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2278 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2279 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2280 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_TAP,
2281 EFL_UTIL_ERROR_INVALID_PARAMETER);
2283 tap_data = (Efl_Util_Gesture_Tap_Grab_Data *)data;
2285 fingers = tap_data->fingers;
2286 repeats = tap_data->repeats;
2288 tizen_gesture_grab_tap(_eflutil.wl.gesture.proto, fingers, repeats);
2290 while (_eflutil.wl.gesture.request_notified == -1)
2291 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2293 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2294 _eflutil.wl.gesture.request_notified = -1;
2300 _efl_util_gesture_ungrab_tap(efl_util_gesture_data data)
2302 int ret = EFL_UTIL_ERROR_NONE;
2303 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2304 Efl_Util_Gesture_Tap_Grab_Data *tap_data = NULL;
2305 unsigned int fingers = 0;
2306 unsigned int repeats = 0;
2308 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2310 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2311 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2312 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_TAP,
2313 EFL_UTIL_ERROR_INVALID_PARAMETER);
2315 tap_data = (Efl_Util_Gesture_Tap_Grab_Data *)data;
2317 fingers = tap_data->fingers;
2318 repeats = tap_data->repeats;
2320 tizen_gesture_ungrab_tap(_eflutil.wl.gesture.proto, fingers, repeats);
2322 while (_eflutil.wl.gesture.request_notified == -1)
2323 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2325 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2326 _eflutil.wl.gesture.request_notified = -1;
2332 _efl_util_gesture_grab_palm_cover(efl_util_gesture_data data)
2334 int ret = EFL_UTIL_ERROR_NONE;
2335 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2337 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2339 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2340 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2341 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_PALM_COVER,
2342 EFL_UTIL_ERROR_INVALID_PARAMETER);
2344 tizen_gesture_grab_palm_cover(_eflutil.wl.gesture.proto);
2346 while (_eflutil.wl.gesture.request_notified == -1)
2347 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2349 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2350 _eflutil.wl.gesture.request_notified = -1;
2356 _efl_util_gesture_ungrab_palm_cover(efl_util_gesture_data data)
2358 int ret = EFL_UTIL_ERROR_NONE;
2359 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2361 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2363 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.gesture.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
2364 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2365 EINA_SAFETY_ON_FALSE_RETURN_VAL(base_data->type == TIZEN_GESTURE_TYPE_PALM_COVER,
2366 EFL_UTIL_ERROR_INVALID_PARAMETER);
2368 tizen_gesture_ungrab_palm_cover(_eflutil.wl.gesture.proto);
2370 while (_eflutil.wl.gesture.request_notified == -1)
2371 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2373 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2374 _eflutil.wl.gesture.request_notified = -1;
2379 API efl_util_gesture_h
2380 efl_util_gesture_initialize(void)
2382 efl_util_gesture_h gesture_h = NULL;
2384 gesture_h = (efl_util_gesture_h)calloc(1, sizeof(struct _efl_util_gesture_h));
2387 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
2391 if (_wl_init() == (int)EINA_FALSE)
2393 set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED);
2397 while (!_eflutil.wl.gesture.proto)
2398 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2400 if (_eflutil.wl.gesture.event_init <= 0)
2402 if (ecore_event_init() <= 0)
2404 set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED);
2407 EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = ecore_event_type_new();
2408 EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = ecore_event_type_new();
2409 EFL_UTIL_EVENT_GESTURE_TAP = ecore_event_type_new();
2410 EFL_UTIL_EVENT_GESTURE_PALM_COVER = ecore_event_type_new();
2412 _eflutil.wl.gesture.event_init++;
2414 set_last_result(EFL_UTIL_ERROR_NONE);
2427 efl_util_gesture_deinitialize(efl_util_gesture_h gesture_h)
2429 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2430 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2435 _eflutil.wl.gesture.event_init--;
2437 if (_eflutil.wl.gesture.event_init <= 0)
2439 _eflutil.wl.gesture.event_init = 0;
2440 ecore_event_shutdown();
2441 EFL_UTIL_EVENT_GESTURE_EDGE_SWIPE = 0;
2442 EFL_UTIL_EVENT_GESTURE_EDGE_DRAG = 0;
2443 EFL_UTIL_EVENT_GESTURE_TAP = 0;
2444 EFL_UTIL_EVENT_GESTURE_PALM_COVER = 0;
2447 return EFL_UTIL_ERROR_NONE;
2450 API efl_util_gesture_data
2451 efl_util_gesture_edge_swipe_new(efl_util_gesture_h gesture_h, unsigned int fingers, efl_util_gesture_edge_e edge)
2453 Efl_Util_Gesture_Edge_Swipe_Grab_Data *data;
2455 if (!gesture_h || gesture_h->init == EINA_FALSE)
2457 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2461 if (edge <= EFL_UTIL_GESTURE_EDGE_NONE || edge > EFL_UTIL_GESTURE_EDGE_LEFT)
2463 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2467 data = (Efl_Util_Gesture_Edge_Swipe_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Edge_Swipe_Grab_Data));
2470 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
2474 data->base.type = TIZEN_GESTURE_TYPE_EDGE_SWIPE;
2475 data->fingers = fingers;
2477 data->edge_size = EFL_UTIL_GESTURE_EDGE_SIZE_FULL;
2479 set_last_result(EFL_UTIL_ERROR_NONE);
2481 return (void *)data;
2485 efl_util_gesture_edge_swipe_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2487 if (!gesture_h || gesture_h->init == EINA_FALSE)
2489 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2494 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2500 return EFL_UTIL_ERROR_NONE;
2504 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)
2506 Efl_Util_Gesture_Edge_Swipe_Grab_Data *edge_swipe_data = data;
2508 EINA_SAFETY_ON_NULL_RETURN_VAL(edge_swipe_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2509 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_swipe_data->base.type == TIZEN_GESTURE_TYPE_EDGE_SWIPE,
2510 EFL_UTIL_ERROR_INVALID_PARAMETER);
2511 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_size == EFL_UTIL_GESTURE_EDGE_SIZE_PARTIAL,
2512 EFL_UTIL_ERROR_INVALID_PARAMETER);
2513 EINA_SAFETY_ON_FALSE_RETURN_VAL(end_point > start_point, EFL_UTIL_ERROR_INVALID_PARAMETER);
2515 edge_swipe_data->edge_size = edge_size;
2516 edge_swipe_data->start_point = start_point;
2517 edge_swipe_data->end_point = end_point;
2519 return EFL_UTIL_ERROR_NONE;
2522 API efl_util_gesture_data
2523 efl_util_gesture_edge_drag_new(efl_util_gesture_h gesture_h, unsigned int fingers, efl_util_gesture_edge_e edge)
2525 Efl_Util_Gesture_Edge_Drag_Grab_Data *data;
2527 if (!gesture_h || gesture_h->init == EINA_FALSE)
2529 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2533 if (edge <= EFL_UTIL_GESTURE_EDGE_NONE || edge > EFL_UTIL_GESTURE_EDGE_LEFT)
2535 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2539 data = (Efl_Util_Gesture_Edge_Drag_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Edge_Drag_Grab_Data));
2542 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
2546 data->base.type = TIZEN_GESTURE_TYPE_EDGE_DRAG;
2547 data->fingers = fingers;
2549 data->edge_size = EFL_UTIL_GESTURE_EDGE_SIZE_FULL;
2551 set_last_result(EFL_UTIL_ERROR_NONE);
2553 return (void *)data;
2557 efl_util_gesture_edge_drag_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2559 if (!gesture_h || gesture_h->init == EINA_FALSE)
2561 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2566 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2572 return EFL_UTIL_ERROR_NONE;
2576 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)
2578 Efl_Util_Gesture_Edge_Drag_Grab_Data *edge_drag_data = data;
2580 EINA_SAFETY_ON_NULL_RETURN_VAL(edge_drag_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2581 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_drag_data->base.type == TIZEN_GESTURE_TYPE_EDGE_DRAG,
2582 EFL_UTIL_ERROR_INVALID_PARAMETER);
2583 EINA_SAFETY_ON_FALSE_RETURN_VAL(edge_size == EFL_UTIL_GESTURE_EDGE_SIZE_PARTIAL,
2584 EFL_UTIL_ERROR_INVALID_PARAMETER);
2585 EINA_SAFETY_ON_FALSE_RETURN_VAL(end_point > start_point, EFL_UTIL_ERROR_INVALID_PARAMETER);
2587 edge_drag_data->edge_size = edge_size;
2588 edge_drag_data->start_point = start_point;
2589 edge_drag_data->end_point = end_point;
2591 return EFL_UTIL_ERROR_NONE;
2594 API efl_util_gesture_data
2595 efl_util_gesture_tap_new(efl_util_gesture_h gesture_h, unsigned int fingers, unsigned int repeats)
2597 Efl_Util_Gesture_Tap_Grab_Data *data;
2599 if (!gesture_h || gesture_h->init == EINA_FALSE)
2601 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2605 if (fingers <= 1 || repeats <= 1)
2607 set_last_result(EFL_UTIL_ERROR_NOT_SUPPORTED);
2611 data = (Efl_Util_Gesture_Tap_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Tap_Grab_Data));
2614 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
2618 data->base.type = TIZEN_GESTURE_TYPE_TAP;
2619 data->fingers = fingers;
2620 data->repeats = repeats;
2622 set_last_result(EFL_UTIL_ERROR_NONE);
2624 return (void *)data;
2628 efl_util_gesture_tap_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2630 if (!gesture_h || gesture_h->init == EINA_FALSE)
2632 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2637 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2643 return EFL_UTIL_ERROR_NONE;
2646 API efl_util_gesture_data
2647 efl_util_gesture_palm_cover_new(efl_util_gesture_h gesture_h)
2649 Efl_Util_Gesture_Palm_Cover_Grab_Data *data;
2651 if (!gesture_h || gesture_h->init == EINA_FALSE)
2653 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2657 data = (Efl_Util_Gesture_Palm_Cover_Grab_Data *)calloc(1, sizeof(Efl_Util_Gesture_Palm_Cover_Grab_Data));
2660 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
2664 data->base.type = TIZEN_GESTURE_TYPE_PALM_COVER;
2666 set_last_result(EFL_UTIL_ERROR_NONE);
2668 return (void *)data;
2672 efl_util_gesture_palm_cover_free(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2674 if (!gesture_h || gesture_h->init == EINA_FALSE)
2676 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2681 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2687 return EFL_UTIL_ERROR_NONE;
2691 efl_util_gesture_grab(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2693 int ret = EFL_UTIL_ERROR_NONE;
2694 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2696 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2698 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2699 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2700 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2702 switch (base_data->type)
2704 case TIZEN_GESTURE_TYPE_EDGE_SWIPE:
2705 ret = _efl_util_gesture_grab_edge_swipe(data);
2707 case TIZEN_GESTURE_TYPE_EDGE_DRAG:
2708 ret = _efl_util_gesture_grab_edge_drag(data);
2710 case TIZEN_GESTURE_TYPE_TAP:
2711 ret = _efl_util_gesture_grab_tap(data);
2713 case TIZEN_GESTURE_TYPE_PALM_COVER:
2714 ret = _efl_util_gesture_grab_palm_cover(data);
2717 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2724 efl_util_gesture_ungrab(efl_util_gesture_h gesture_h, efl_util_gesture_data data)
2726 int ret = EFL_UTIL_ERROR_NONE;
2727 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2729 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2731 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2732 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2733 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2735 switch (base_data->type)
2737 case TIZEN_GESTURE_TYPE_EDGE_SWIPE:
2738 ret = _efl_util_gesture_ungrab_edge_swipe(data);
2740 case TIZEN_GESTURE_TYPE_EDGE_DRAG:
2741 ret = _efl_util_gesture_ungrab_edge_drag(data);
2743 case TIZEN_GESTURE_TYPE_TAP:
2744 ret = _efl_util_gesture_ungrab_tap(data);
2746 case TIZEN_GESTURE_TYPE_PALM_COVER:
2747 ret = _efl_util_gesture_ungrab_palm_cover(data);
2750 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2757 efl_util_gesture_select(efl_util_gesture_h gesture_h, Evas_Object *window, efl_util_gesture_data data)
2759 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2760 Ecore_Wl_Window *wlwin;
2761 struct wl_surface *surface;
2764 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2766 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2767 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2768 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
2769 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2771 if (base_data->type != TIZEN_GESTURE_TYPE_PALM_COVER)
2772 return EFL_UTIL_ERROR_NOT_SUPPORTED;
2774 wlwin = elm_win_wl_window_get(window);
2775 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
2777 surface = ecore_wl_window_surface_get(wlwin);
2778 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
2779 EFL_UTIL_ERROR_INVALID_PARAMETER);
2781 tizen_gesture_select_palm_cover(_eflutil.wl.gesture.proto, surface);
2783 while (_eflutil.wl.gesture.request_notified == -1)
2784 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2786 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2787 _eflutil.wl.gesture.request_notified = -1;
2793 efl_util_gesture_deselect(efl_util_gesture_h gesture_h, Evas_Object *window, efl_util_gesture_data data)
2795 Efl_Util_Gesture_Common_Grab_Data *base_data = NULL;
2796 Ecore_Wl_Window *wlwin;
2797 struct wl_surface *surface;
2800 base_data = (Efl_Util_Gesture_Common_Grab_Data *)data;
2802 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2803 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2804 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
2805 EINA_SAFETY_ON_NULL_RETURN_VAL(base_data, EFL_UTIL_ERROR_INVALID_PARAMETER);
2807 if (base_data->type != TIZEN_GESTURE_TYPE_PALM_COVER)
2808 return EFL_UTIL_ERROR_NOT_SUPPORTED;
2810 wlwin = elm_win_wl_window_get(window);
2811 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
2813 surface = ecore_wl_window_surface_get(wlwin);
2814 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
2815 EFL_UTIL_ERROR_INVALID_PARAMETER);
2817 tizen_gesture_deselect_palm_cover(_eflutil.wl.gesture.proto, surface);
2819 while (_eflutil.wl.gesture.request_notified == -1)
2820 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2822 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2823 _eflutil.wl.gesture.request_notified = -1;
2829 efl_util_gesture_activate_set(efl_util_gesture_h gesture_h, unsigned int type, Eina_Bool active)
2833 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2834 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2835 EINA_SAFETY_ON_TRUE_RETURN_VAL(type == EFL_UTIL_GESTURE_TYPE_NONE, EFL_UTIL_ERROR_INVALID_PARAMETER);
2837 tizen_gesture_activate_set(_eflutil.wl.gesture.proto, NULL, type, active);
2839 while (_eflutil.wl.gesture.request_notified == -1)
2840 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2842 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2843 _eflutil.wl.gesture.request_notified = -1;
2849 efl_util_gesture_activate_set_on_window(efl_util_gesture_h gesture_h, Evas_Object *window, unsigned int type, Eina_Bool active)
2851 Ecore_Wl_Window *wlwin;
2852 struct wl_surface *surface;
2855 EINA_SAFETY_ON_NULL_RETURN_VAL(gesture_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
2856 EINA_SAFETY_ON_FALSE_RETURN_VAL(gesture_h->init, EFL_UTIL_ERROR_INVALID_PARAMETER);
2857 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
2858 EINA_SAFETY_ON_TRUE_RETURN_VAL(type == EFL_UTIL_GESTURE_TYPE_NONE, EFL_UTIL_ERROR_INVALID_PARAMETER);
2860 wlwin = elm_win_wl_window_get(window);
2861 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
2863 surface = ecore_wl_window_surface_get(wlwin);
2864 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
2865 EFL_UTIL_ERROR_INVALID_PARAMETER);
2867 tizen_gesture_activate_set(_eflutil.wl.gesture.proto, surface, type, active);
2869 while (_eflutil.wl.gesture.request_notified == -1)
2870 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2872 ret = _efl_util_gesture_convert_error(_eflutil.wl.gesture.request_notified);
2873 _eflutil.wl.gesture.request_notified = -1;