2 * Copyright (c) 2011-2015 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>
34 #include <Ecore_Wayland.h>
35 #include <wayland-client.h>
36 #include <wayland-tbm-client.h>
37 #include <tizen-extension-client-protocol.h>
38 #include <screenshooter-client-protocol.h>
45 #define LOG_TAG "TIZEN_N_EFL_UTIL"
48 /* callback handler index */
49 #define CBH_NOTI_LEV 0
50 #define CBH_SCR_MODE 1
53 typedef void (*Efl_Util_Cb)(Evas_Object *, int, void *);
55 typedef struct _Efl_Util_Callback_Info
60 } Efl_Util_Callback_Info;
62 typedef struct _Efl_Util_Wl_Surface_Lv_Info
64 void *surface; /* wl_surface */
66 Eina_Bool wait_for_done;
68 } Efl_Util_Wl_Surface_Lv_Info;
70 typedef struct _Efl_Util_Wl_Surface_Scr_Mode_Info
72 void *surface; /* wl_surface */
74 Eina_Bool wait_for_done;
76 } Efl_Util_Wl_Surface_Scr_Mode_Info;
78 typedef struct _Efl_Util_Wl_Surface_Brightness_Info
80 void *surface; /* wl_surface */
82 Eina_Bool wait_for_done;
84 } Efl_Util_Wl_Surface_Brightness_Info;
86 typedef struct _Efl_Util_Wl_Output_Info
88 struct wl_output *output;
89 int offset_x, offset_y, width, height;
90 } Efl_Util_Wl_Output_Info;
92 typedef struct _Efl_Util_Data
94 /* wayland related stuffs */
98 struct wl_display *dpy;
99 struct wl_event_queue *queue;
103 struct tizen_policy *proto;
104 Eina_Hash *hash_noti_lv;
105 Eina_Hash *hash_scr_mode;
109 struct screenshooter *screenshooter;
110 struct wayland_tbm_client *tbm_client;
111 Eina_List *output_list;
115 struct tizen_input_device_manager *devicemgr;
116 int request_notified;
120 struct tizen_display_policy *proto;
121 Eina_Hash *hash_brightness;
127 Eina_List *info_list; /* list of callback info */
128 unsigned int atom; /* x11 atom */
129 } cb_handler[CBH_MAX];
132 static Efl_Util_Data _eflutil =
137 { NULL, NULL, NULL }, /* tizen_policy protocol */
138 { NULL, NULL, NULL }, /* screenshooter protocol */
139 { NULL, -1 } /* tizen_input_device_manager protocol */
142 { NULL, 0 }, /* handler for notification level */
143 { NULL, 0 } /* handler for screen mode */
147 static Eina_Bool _cb_info_add(Evas_Object *win, Efl_Util_Cb cb, void *data, int idx);
148 static Eina_Bool _cb_info_del_by_win(Evas_Object *win, int idx);
149 static Eina_List *_cb_info_list_get(int idx);
150 static Efl_Util_Callback_Info *_cb_info_find_by_win(Evas_Object *win, int idx);
151 static Eina_Bool _wl_init(void);
152 static void _cb_wl_reg_global(void *data, struct wl_registry *reg, unsigned int name, const char *interface, unsigned int version);
153 static void _cb_wl_reg_global_remove(void *data, struct wl_registry *reg, unsigned int name);
154 static Efl_Util_Callback_Info *_cb_info_find_by_wlsurf(void *wlsurf, int idx);
155 static void _cb_wl_tz_policy_conformant(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface, uint32_t is_conformant);
156 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);
157 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);
158 static void _cb_wl_tz_policy_transient_for_done(void *data, struct tizen_policy *tizen_policy, uint32_t child_id);
159 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);
160 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);
161 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);
162 static void _cb_wl_tz_policy_allowed_aux_hint(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface_resource, int id);
163 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);
165 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);
167 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);
168 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);
169 static void _cb_error(void *data EINA_UNUSED, struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED, uint32_t errorcode);
170 static void _cb_block_expired(void *data EINA_UNUSED, struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED);
172 static const struct wl_registry_listener _wl_reg_listener =
175 _cb_wl_reg_global_remove
178 struct tizen_policy_listener _wl_tz_policy_listener =
180 _cb_wl_tz_policy_conformant,
181 _cb_wl_tz_policy_conformant_area,
182 _cb_wl_tz_policy_notification_done,
183 _cb_wl_tz_policy_transient_for_done,
184 _cb_wl_tz_policy_scr_mode_done,
185 _cb_wl_tz_policy_iconify_state_changed,
186 _cb_wl_tz_policy_supported_aux_hints,
187 _cb_wl_tz_policy_allowed_aux_hint,
188 _cb_wl_tz_policy_aux_message,
191 struct tizen_input_device_manager_listener _wl_tz_devmgr_listener =
199 struct tizen_display_policy_listener _wl_tz_display_policy_listener =
201 _cb_wl_tz_display_policy_brightness_done,
205 _cb_info_add(Evas_Object *win,
210 Efl_Util_Callback_Info *info;
212 info = _cb_info_find_by_win(win, idx);
215 _eflutil.cb_handler[idx].info_list
216 = eina_list_remove(_eflutil.cb_handler[idx].info_list,
221 info = (Efl_Util_Callback_Info *)calloc(1, sizeof(Efl_Util_Callback_Info));
222 if (!info) return EINA_FALSE;
228 _eflutil.cb_handler[idx].info_list
229 = eina_list_append(_eflutil.cb_handler[idx].info_list,
236 _cb_info_del_by_win(Evas_Object *win,
239 Efl_Util_Callback_Info *info;
241 info = _cb_info_find_by_win(win, idx);
242 if (!info) return EINA_FALSE;
244 _eflutil.cb_handler[idx].info_list
245 = eina_list_remove(_eflutil.cb_handler[idx].info_list,
253 _cb_info_list_get(int idx)
255 return _eflutil.cb_handler[idx].info_list;
258 static Efl_Util_Callback_Info *
259 _cb_info_find_by_win(Evas_Object *win,
263 Efl_Util_Callback_Info *info;
265 l = _cb_info_list_get(idx);
266 EINA_LIST_FOREACH(l, ll, info)
268 if (info->win == win) return info;
277 struct wl_registry *reg = NULL;
279 if (_eflutil.wl.init) return EINA_TRUE;
283 _eflutil.wl.dpy = ecore_wl_display_get();
284 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.dpy, fail);
286 _eflutil.wl.queue = wl_display_create_queue(_eflutil.wl.dpy);
287 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.queue, fail);
289 reg = wl_display_get_registry(_eflutil.wl.dpy);
290 EINA_SAFETY_ON_NULL_GOTO(reg, fail);
292 wl_proxy_set_queue((struct wl_proxy*)reg, _eflutil.wl.queue);
293 wl_registry_add_listener(reg, &_wl_reg_listener, NULL);
295 _eflutil.wl.init = EINA_TRUE;
299 if (_eflutil.wl.queue)
301 wl_event_queue_destroy(_eflutil.wl.queue);
302 _eflutil.wl.queue = NULL;
310 _cb_wl_output_geometry(void *data, struct wl_output *wl_output, int x, int y,
311 int physical_width, int physical_height, int subpixel,
312 const char *make, const char *model, int transform)
314 Efl_Util_Wl_Output_Info *output = wl_output_get_user_data(wl_output);
315 if (wl_output == output->output)
317 output->offset_x = x;
318 output->offset_y = y;
323 _cb_wl_output_mode(void *data, struct wl_output *wl_output, uint32_t flags,
324 int width, int height, int refresh)
326 Efl_Util_Wl_Output_Info *output = wl_output_get_user_data(wl_output);
327 if (wl_output == output->output && (flags & WL_OUTPUT_MODE_CURRENT))
329 output->width = width;
330 output->height = height;
335 _cb_wl_output_done(void *data, struct wl_output *wl_output)
340 _cb_wl_output_scale(void *data, struct wl_output *wl_output, int32_t factor)
344 static const struct wl_output_listener output_listener =
346 _cb_wl_output_geometry,
353 _cb_wl_screenshot_done(void *data, struct screenshooter *screenshooter)
355 Eina_Bool *shot_done = (Eina_Bool*)data;
357 *shot_done = EINA_TRUE;
360 static const struct screenshooter_listener screenshooter_listener =
362 _cb_wl_screenshot_done
366 _cb_wl_reg_global(void *data,
367 struct wl_registry *reg,
369 const char *interface,
370 unsigned int version)
372 if (!strcmp(interface, "tizen_policy"))
374 struct tizen_policy *proto;
375 proto = wl_registry_bind(reg,
377 &tizen_policy_interface,
381 tizen_policy_add_listener(proto,
382 &_wl_tz_policy_listener,
385 _eflutil.wl.policy.hash_noti_lv = eina_hash_pointer_new(free);
386 _eflutil.wl.policy.hash_scr_mode = eina_hash_pointer_new(free);
387 _eflutil.wl.policy.proto = proto;
389 else if (strcmp(interface, "wl_output") == 0)
391 Efl_Util_Wl_Output_Info *output = calloc(1, sizeof(Efl_Util_Wl_Output_Info));
392 EINA_SAFETY_ON_NULL_RETURN(output);
394 _eflutil.wl.shot.output_list = eina_list_append(_eflutil.wl.shot.output_list, output);
396 output->output = wl_registry_bind(reg, name, &wl_output_interface, version);
397 wl_output_add_listener(output->output, &output_listener, output);
399 else if (strcmp(interface, "screenshooter") == 0)
401 _eflutil.wl.shot.screenshooter = wl_registry_bind(reg, name, &screenshooter_interface, version);
402 screenshooter_add_listener(_eflutil.wl.shot.screenshooter, &screenshooter_listener, NULL);
404 else if (strcmp(interface, "tizen_input_device_manager") == 0)
406 _eflutil.wl.devmgr.devicemgr = wl_registry_bind(reg, name, &tizen_input_device_manager_interface, version);
407 tizen_input_device_manager_add_listener(_eflutil.wl.devmgr.devicemgr, &_wl_tz_devmgr_listener, NULL);
409 else if (!strcmp(interface, "tizen_display_policy"))
411 _eflutil.wl.display_policy.proto = wl_registry_bind(reg, name, &tizen_display_policy_interface, version);
412 if (!_eflutil.wl.display_policy.proto) return;
414 tizen_display_policy_add_listener(_eflutil.wl.display_policy.proto,
415 &_wl_tz_display_policy_listener,
418 _eflutil.wl.display_policy.hash_brightness = eina_hash_pointer_new(free);
422 /* LCOV_EXCL_START */
424 _cb_wl_reg_global_remove(void *data,
425 struct wl_registry *reg,
428 _eflutil.wl.policy.proto = NULL;
429 eina_hash_free(_eflutil.wl.policy.hash_noti_lv);
430 eina_hash_free(_eflutil.wl.policy.hash_scr_mode);
432 _eflutil.wl.display_policy.proto = NULL;
433 eina_hash_free(_eflutil.wl.display_policy.hash_brightness);
436 static Efl_Util_Callback_Info *
437 _cb_info_find_by_wlsurf(void *wlsurf,
441 Efl_Util_Callback_Info *info;
442 Ecore_Wl_Window *wlwin2 = NULL;
443 void *wlsurf2 = NULL;
445 l = _cb_info_list_get(idx);
446 EINA_LIST_FOREACH(l, ll, info)
448 wlwin2 = elm_win_wl_window_get(info->win);
449 wlsurf2 = ecore_wl_window_surface_get(wlwin2);
450 if (wlsurf== wlsurf2) return info;
457 _cb_wl_tz_policy_conformant(void *data, struct tizen_policy *tizen_policy,
458 struct wl_surface *surface, uint32_t is_conformant)
463 _cb_wl_tz_policy_conformant_area(void *data, struct tizen_policy *tizen_policy,
464 struct wl_surface *surface, uint32_t conformant_part,
465 uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h)
471 _cb_wl_tz_policy_notification_done(void *data,
472 struct tizen_policy *tizen_policy,
473 struct wl_surface *surface,
477 Efl_Util_Wl_Surface_Lv_Info *lv_info;
478 Efl_Util_Callback_Info *cb_info;
480 lv_info = eina_hash_find(_eflutil.wl.policy.hash_noti_lv, &surface);
483 lv_info->level = level;
484 lv_info->wait_for_done = EINA_FALSE;
485 lv_info->state = state;
488 if (state != TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED) return;
490 cb_info = _cb_info_find_by_wlsurf((void *)surface, CBH_NOTI_LEV);
491 if (!cb_info) return;
492 if (!cb_info->cb) return;
494 cb_info->cb(cb_info->win,
495 EFL_UTIL_ERROR_PERMISSION_DENIED,
499 /* LCOV_EXCL_START */
501 _cb_wl_tz_policy_transient_for_done(void *data, struct tizen_policy *tizen_policy, uint32_t child_id)
507 _cb_wl_tz_policy_scr_mode_done(void *data,
508 struct tizen_policy *tizen_policy,
509 struct wl_surface *surface,
514 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
515 Efl_Util_Callback_Info *cb_info;
517 scr_mode_info = eina_hash_find(_eflutil.wl.policy.hash_scr_mode, &surface);
520 scr_mode_info->mode = mode;
521 scr_mode_info->wait_for_done = EINA_FALSE;
522 scr_mode_info->state = state;
525 if (state != TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED) return;
527 cb_info = _cb_info_find_by_wlsurf((void *)surface, CBH_SCR_MODE);
528 if (!cb_info) return;
529 if (!cb_info->cb) return;
531 cb_info->cb(cb_info->win,
532 EFL_UTIL_ERROR_PERMISSION_DENIED,
536 /* LCOV_EXCL_START */
537 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)
541 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)
545 static void _cb_wl_tz_policy_allowed_aux_hint(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface_resource, int id)
549 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)
555 _cb_wl_tz_display_policy_brightness_done(void *data,
556 struct tizen_display_policy *tizen_display_policy,
557 struct wl_surface *surface,
561 Efl_Util_Wl_Surface_Brightness_Info *brightness_info;
563 brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
566 brightness_info->brightness = brightness;
567 brightness_info->wait_for_done = EINA_FALSE;
568 brightness_info->state = state;
573 _cb_window_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
575 Efl_Util_Wl_Surface_Lv_Info *lv_info;
578 if (EINA_UNLIKELY(!lv_info))
581 eina_hash_del(_eflutil.wl.policy.hash_noti_lv, &lv_info->surface, lv_info);
585 efl_util_set_notification_window_level(Evas_Object *window,
586 efl_util_notification_level_e level)
590 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
591 EINA_SAFETY_ON_FALSE_RETURN_VAL((level >= EFL_UTIL_NOTIFICATION_LEVEL_NONE) &&
592 (level <= EFL_UTIL_NOTIFICATION_LEVEL_TOP),
593 EFL_UTIL_ERROR_INVALID_PARAMETER);
595 if (level == EFL_UTIL_NOTIFICATION_LEVEL_1)
597 dlog_print(DLOG_WARN, LOG_TAG,
598 "DEPRECATION WARNING: EFL_UTIL_NOTIFICATION_LEVEL_1 is deprecated and will be removed from next release. Use EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT instead.");
600 else if (level == EFL_UTIL_NOTIFICATION_LEVEL_2)
602 dlog_print(DLOG_WARN, LOG_TAG,
603 "DEPRECATION WARNING: EFL_UTIL_NOTIFICATION_LEVEL_2 is deprecated and will be removed from next release. Use EFL_UTIL_NOTIFICATION_LEVEL_MEDIUM instead.");
605 else if (level == EFL_UTIL_NOTIFICATION_LEVEL_3)
607 dlog_print(DLOG_WARN, LOG_TAG,
608 "DEPRECATION WARNING: EFL_UTIL_NOTIFICATION_LEVEL_3 is deprecated and will be removed from next release. Use EFL_UTIL_NOTIFICATION_LEVEL_TOP instead.");
612 Ecore_Wl_Window *wlwin;
613 struct wl_surface *surface;
614 Efl_Util_Wl_Surface_Lv_Info *lv_info;
615 Ecore_Wl_Window_Type wl_type;
618 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
620 wlwin = elm_win_wl_window_get(window);
621 EINA_SAFETY_ON_NULL_RETURN_VAL(wlwin, EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
623 type = elm_win_type_get(window);
624 if (type != ELM_WIN_NOTIFICATION)
626 wl_type = ecore_wl_window_type_get(wlwin);
627 EINA_SAFETY_ON_FALSE_RETURN_VAL((wl_type == ECORE_WL_WINDOW_TYPE_NOTIFICATION),
628 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
631 while (!_eflutil.wl.policy.proto)
632 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
634 surface = ecore_wl_window_surface_get(wlwin);
635 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
636 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
638 lv_info = eina_hash_find(_eflutil.wl.policy.hash_noti_lv, &surface);
641 lv_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Lv_Info));
642 EINA_SAFETY_ON_NULL_RETURN_VAL(lv_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
644 lv_info->surface = surface;
645 lv_info->level = (int)level;
646 lv_info->wait_for_done = EINA_TRUE;
647 lv_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
648 eina_hash_add(_eflutil.wl.policy.hash_noti_lv,
652 evas_object_event_callback_add(window, EVAS_CALLBACK_DEL,
653 _cb_window_del, lv_info);
657 lv_info->level = (int)level;
658 lv_info->wait_for_done = EINA_TRUE;
659 lv_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
663 tizen_policy_set_notification_level(_eflutil.wl.policy.proto,
664 surface, (int)level);
666 if (lv_info->wait_for_done)
669 while (lv_info->wait_for_done && (count < 3))
672 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
676 if (lv_info->wait_for_done)
678 return EFL_UTIL_ERROR_INVALID_PARAMETER;
682 if (lv_info->state == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
684 return EFL_UTIL_ERROR_PERMISSION_DENIED;
689 return EFL_UTIL_ERROR_NONE;
693 efl_util_get_notification_window_level(Evas_Object *window,
694 efl_util_notification_level_e *level)
698 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
699 EINA_SAFETY_ON_NULL_RETURN_VAL(level, EFL_UTIL_ERROR_INVALID_PARAMETER);
702 Ecore_Wl_Window *wlwin;
703 struct wl_surface *surface;
704 Efl_Util_Wl_Surface_Lv_Info *lv_info;
705 Ecore_Wl_Window_Type wl_type;
708 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
710 wlwin = elm_win_wl_window_get(window);
711 EINA_SAFETY_ON_NULL_RETURN_VAL(wlwin, EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
713 type = elm_win_type_get(window);
714 if (type != ELM_WIN_NOTIFICATION)
716 wl_type = ecore_wl_window_type_get(wlwin);
717 EINA_SAFETY_ON_FALSE_RETURN_VAL((wl_type == ECORE_WL_WINDOW_TYPE_NOTIFICATION),
718 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
721 while (!_eflutil.wl.policy.proto)
722 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
724 surface = ecore_wl_window_surface_get(wlwin);
725 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
726 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
728 lv_info = eina_hash_find(_eflutil.wl.policy.hash_noti_lv, &surface);
731 if (lv_info->wait_for_done)
734 while ((lv_info->wait_for_done) && (count < 3))
737 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
741 if (lv_info->wait_for_done)
743 *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
744 return EFL_UTIL_ERROR_INVALID_PARAMETER;
748 switch (lv_info->level)
750 case TIZEN_POLICY_LEVEL_1: *level = EFL_UTIL_NOTIFICATION_LEVEL_1; break;
751 case TIZEN_POLICY_LEVEL_2: *level = EFL_UTIL_NOTIFICATION_LEVEL_2; break;
752 case TIZEN_POLICY_LEVEL_3: *level = EFL_UTIL_NOTIFICATION_LEVEL_3; break;
753 case TIZEN_POLICY_LEVEL_NONE: *level = EFL_UTIL_NOTIFICATION_LEVEL_NONE; break;
754 case TIZEN_POLICY_LEVEL_DEFAULT: *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT; break;
755 case TIZEN_POLICY_LEVEL_MEDIUM: *level = EFL_UTIL_NOTIFICATION_LEVEL_MEDIUM; break;
756 case TIZEN_POLICY_LEVEL_HIGH: *level = EFL_UTIL_NOTIFICATION_LEVEL_HIGH; break;
757 case TIZEN_POLICY_LEVEL_TOP: *level = EFL_UTIL_NOTIFICATION_LEVEL_TOP; break;
758 default: *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
759 return EFL_UTIL_ERROR_INVALID_PARAMETER;
761 return EFL_UTIL_ERROR_NONE;
764 *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
766 return EFL_UTIL_ERROR_NONE;
770 efl_util_set_notification_window_level_error_cb(Evas_Object *window,
771 efl_util_notification_window_level_error_cb callback,
774 dlog_print(DLOG_WARN, LOG_TAG,
775 "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.");
777 Eina_Bool ret = EINA_FALSE;
779 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
780 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EFL_UTIL_ERROR_INVALID_PARAMETER);
782 ret = _cb_info_add(window,
783 (Efl_Util_Cb)callback,
786 if (!ret) return EFL_UTIL_ERROR_OUT_OF_MEMORY;
788 return EFL_UTIL_ERROR_NONE;
792 efl_util_unset_notification_window_level_error_cb(Evas_Object *window)
794 dlog_print(DLOG_WARN, LOG_TAG,
795 "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.");
797 Eina_Bool ret = EINA_FALSE;
799 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
801 ret = _cb_info_del_by_win(window, CBH_NOTI_LEV);
802 if (!ret) return EFL_UTIL_ERROR_INVALID_PARAMETER;
804 return EFL_UTIL_ERROR_NONE;
808 efl_util_set_window_opaque_state(Evas_Object *window,
813 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
814 EINA_SAFETY_ON_FALSE_RETURN_VAL(((opaque >= 0) && (opaque <= 1)),
815 EFL_UTIL_ERROR_INVALID_PARAMETER);
817 Ecore_Wl_Window *wlwin;
818 struct wl_surface *surface;
820 if (!_eflutil.wl.policy.proto)
825 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
827 while (!_eflutil.wl.policy.proto && ret != -1)
828 ret = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
830 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.policy.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
833 wlwin = elm_win_wl_window_get(window);
835 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
837 surface = ecore_wl_window_surface_get(wlwin);
839 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
841 tizen_policy_set_opaque_state(_eflutil.wl.policy.proto, surface, opaque);
843 return EFL_UTIL_ERROR_NONE;
847 efl_util_set_window_screen_mode(Evas_Object *window,
848 efl_util_screen_mode_e mode)
850 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
851 EINA_SAFETY_ON_FALSE_RETURN_VAL(((mode >= EFL_UTIL_SCREEN_MODE_DEFAULT) &&
852 (mode <= EFL_UTIL_SCREEN_MODE_ALWAYS_ON)),
853 EFL_UTIL_ERROR_INVALID_PARAMETER);
855 Ecore_Wl_Window *wlwin;
856 struct wl_surface *surface;
857 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
861 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
863 wlwin = elm_win_wl_window_get(window);
866 while (!_eflutil.wl.policy.proto)
867 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
869 surface = ecore_wl_window_surface_get(wlwin);
870 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
871 EFL_UTIL_ERROR_INVALID_PARAMETER);
873 scr_mode_info = eina_hash_find(_eflutil.wl.policy.hash_scr_mode, &surface);
876 scr_mode_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Scr_Mode_Info));
877 EINA_SAFETY_ON_NULL_RETURN_VAL(scr_mode_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
879 scr_mode_info->surface = surface;
880 scr_mode_info->mode = (unsigned int)mode;
881 scr_mode_info->wait_for_done = EINA_TRUE;
882 scr_mode_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
884 eina_hash_add(_eflutil.wl.policy.hash_scr_mode,
890 scr_mode_info->mode = (unsigned int)mode;
891 scr_mode_info->wait_for_done = EINA_TRUE;
892 scr_mode_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
895 tizen_policy_set_window_screen_mode(_eflutil.wl.policy.proto,
896 surface, (unsigned int)mode);
897 if (scr_mode_info->wait_for_done)
900 while (scr_mode_info->wait_for_done && (count < 3))
903 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
907 if (scr_mode_info->wait_for_done)
909 return EFL_UTIL_ERROR_INVALID_PARAMETER;
913 if (scr_mode_info->state == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
915 return EFL_UTIL_ERROR_PERMISSION_DENIED;
920 return EFL_UTIL_ERROR_NONE;
923 return EFL_UTIL_ERROR_INVALID_PARAMETER;
927 efl_util_get_window_screen_mode(Evas_Object *window,
928 efl_util_screen_mode_e *mode)
930 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
931 EINA_SAFETY_ON_NULL_RETURN_VAL(mode, EFL_UTIL_ERROR_INVALID_PARAMETER);
933 Ecore_Wl_Window *wlwin;
934 struct wl_surface *surface;
935 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
939 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
941 wlwin = elm_win_wl_window_get(window);
944 while (!_eflutil.wl.policy.proto)
945 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
947 surface = ecore_wl_window_surface_get(wlwin);
948 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
949 EFL_UTIL_ERROR_INVALID_PARAMETER);
951 scr_mode_info = eina_hash_find(_eflutil.wl.policy.hash_scr_mode, &surface);
954 if (scr_mode_info->wait_for_done)
956 while (scr_mode_info->wait_for_done)
959 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
963 switch (scr_mode_info->mode)
965 case TIZEN_POLICY_MODE_DEFAULT: *mode = EFL_UTIL_SCREEN_MODE_DEFAULT; break;
966 case TIZEN_POLICY_MODE_ALWAYS_ON: *mode = EFL_UTIL_SCREEN_MODE_ALWAYS_ON; break;
967 default: *mode = EFL_UTIL_SCREEN_MODE_DEFAULT;
968 return EFL_UTIL_ERROR_INVALID_PARAMETER;
970 return EFL_UTIL_ERROR_NONE;
974 *mode = EFL_UTIL_SCREEN_MODE_DEFAULT;
975 return EFL_UTIL_ERROR_INVALID_PARAMETER;
979 return EFL_UTIL_ERROR_INVALID_PARAMETER;
982 #ifndef TIZEN_WEARABLE
984 efl_util_set_window_screen_mode_error_cb(Evas_Object *window,
985 efl_util_window_screen_mode_error_cb callback,
988 dlog_print(DLOG_WARN, LOG_TAG,
989 "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.");
991 Eina_Bool ret = EINA_FALSE;
993 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
994 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EFL_UTIL_ERROR_INVALID_PARAMETER);
996 ret = _cb_info_add(window,
997 (Efl_Util_Cb)callback,
1000 if (!ret) return EFL_UTIL_ERROR_OUT_OF_MEMORY;
1002 return EFL_UTIL_ERROR_NONE;
1006 efl_util_unset_window_screen_mode_error_cb(Evas_Object *window)
1008 dlog_print(DLOG_WARN, LOG_TAG,
1009 "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.");
1011 Eina_Bool ret = EINA_FALSE;
1013 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1015 ret = _cb_info_del_by_win(window, CBH_SCR_MODE);
1016 if (!ret) return EFL_UTIL_ERROR_INVALID_PARAMETER;
1018 return EFL_UTIL_ERROR_NONE;
1023 efl_util_set_window_brightness(Evas_Object *window, int brightness)
1025 Ecore_Wl_Window *wlwin;
1026 struct wl_surface *surface;
1027 Efl_Util_Wl_Surface_Brightness_Info *brightness_info;
1030 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1031 EINA_SAFETY_ON_FALSE_RETURN_VAL(brightness <= 100, EFL_UTIL_ERROR_INVALID_PARAMETER);
1034 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1036 wlwin = elm_win_wl_window_get(window);
1039 while (!_eflutil.wl.display_policy.proto)
1040 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1042 surface = ecore_wl_window_surface_get(wlwin);
1043 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1044 EFL_UTIL_ERROR_INVALID_PARAMETER);
1046 brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
1047 if (!brightness_info)
1049 brightness_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Brightness_Info));
1050 EINA_SAFETY_ON_NULL_RETURN_VAL(brightness_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
1052 brightness_info->surface = surface;
1053 brightness_info->brightness = brightness;
1054 brightness_info->wait_for_done = EINA_TRUE;
1055 brightness_info->state = TIZEN_DISPLAY_POLICY_ERROR_STATE_NONE;
1057 eina_hash_add(_eflutil.wl.display_policy.hash_brightness,
1063 brightness_info->brightness = brightness;
1064 brightness_info->wait_for_done = EINA_TRUE;
1065 brightness_info->state = TIZEN_DISPLAY_POLICY_ERROR_STATE_NONE;
1068 tizen_display_policy_set_window_brightness(_eflutil.wl.display_policy.proto,
1069 surface, brightness);
1070 if (brightness_info->wait_for_done)
1073 while (brightness_info->wait_for_done && (count < 3))
1076 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1080 if (brightness_info->wait_for_done)
1082 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1086 if (brightness_info->state == TIZEN_DISPLAY_POLICY_ERROR_STATE_PERMISSION_DENIED)
1088 return EFL_UTIL_ERROR_PERMISSION_DENIED;
1092 return EFL_UTIL_ERROR_NONE;
1095 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1099 efl_util_get_window_brightness(Evas_Object *window, int *brightness)
1101 Ecore_Wl_Window *wlwin;
1102 struct wl_surface *surface;
1103 Efl_Util_Wl_Surface_Brightness_Info *brightness_info;
1106 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1107 EINA_SAFETY_ON_NULL_RETURN_VAL(brightness, EFL_UTIL_ERROR_INVALID_PARAMETER);
1110 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1112 wlwin = elm_win_wl_window_get(window);
1113 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
1115 while (!_eflutil.wl.display_policy.proto)
1116 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1118 surface = ecore_wl_window_surface_get(wlwin);
1119 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1120 EFL_UTIL_ERROR_INVALID_PARAMETER);
1122 brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
1123 if (brightness_info)
1125 if (brightness_info->wait_for_done)
1127 while (brightness_info->wait_for_done)
1130 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1133 *brightness = brightness_info->brightness;
1138 return EFL_UTIL_ERROR_NONE;
1142 struct _efl_util_inputgen_h
1144 unsigned int init_type;
1148 _cb_device_add(void *data EINA_UNUSED,
1149 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1150 uint32_t serial EINA_UNUSED,
1151 const char *identifier EINA_UNUSED,
1152 struct tizen_input_device *device EINA_UNUSED,
1153 struct wl_seat *seat EINA_UNUSED)
1158 /* LCOV_EXCL_START */
1160 _cb_device_remove(void *data EINA_UNUSED,
1161 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1162 uint32_t serial EINA_UNUSED,
1163 const char *identifier EINA_UNUSED,
1164 struct tizen_input_device *device EINA_UNUSED,
1165 struct wl_seat *seat EINA_UNUSED)
1169 /* LCOV_EXCL_STOP */
1172 _cb_error(void *data EINA_UNUSED,
1173 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1176 _eflutil.wl.devmgr.request_notified = errorcode;
1179 /* LCOV_EXCL_START */
1181 _cb_block_expired(void *data EINA_UNUSED,
1182 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED)
1186 /* LCOV_EXCL_STOP */
1188 static efl_util_error_e
1189 _efl_util_input_convert_input_generator_error(int ret)
1193 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE:
1194 return EFL_UTIL_ERROR_NONE;
1195 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NO_PERMISSION:
1196 return EFL_UTIL_ERROR_PERMISSION_DENIED;
1197 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NO_SYSTEM_RESOURCES:
1198 return EFL_UTIL_ERROR_OUT_OF_MEMORY;
1199 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_INVALID_PARAMETER:
1200 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1202 return EFL_UTIL_ERROR_NONE;
1206 API efl_util_inputgen_h
1207 efl_util_input_initialize_generator(unsigned int dev_type)
1209 int ret = EFL_UTIL_ERROR_NONE;
1210 efl_util_inputgen_h inputgen_h = NULL;
1213 dev_type & ~(EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN
1214 | EFL_UTIL_INPUT_DEVTYPE_KEYBOARD
1215 | EFL_UTIL_INPUT_DEVTYPE_POINTER))
1217 set_last_result(EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1221 inputgen_h = (efl_util_inputgen_h)calloc(1, sizeof(struct _efl_util_inputgen_h));
1224 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
1228 inputgen_h->init_type |= dev_type;
1231 if (ret == (int)EINA_FALSE)
1233 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1237 while (!_eflutil.wl.devmgr.devicemgr)
1238 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1240 tizen_input_device_manager_init_generator(_eflutil.wl.devmgr.devicemgr);
1242 while (_eflutil.wl.devmgr.request_notified == -1)
1243 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1245 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1246 _eflutil.wl.devmgr.request_notified = -1;
1248 set_last_result(ret);
1249 if (ret != TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE)
1264 efl_util_input_deinitialize_generator(efl_util_inputgen_h inputgen_h)
1266 int ret = EFL_UTIL_ERROR_NONE;
1267 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1272 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1274 tizen_input_device_manager_deinit_generator(_eflutil.wl.devmgr.devicemgr);
1276 while (_eflutil.wl.devmgr.request_notified == -1)
1277 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1279 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1280 _eflutil.wl.devmgr.request_notified = -1;
1286 efl_util_input_generate_key(efl_util_inputgen_h inputgen_h, const char *key_name, int pressed)
1288 int ret = EFL_UTIL_ERROR_NONE;
1290 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1291 EINA_SAFETY_ON_NULL_RETURN_VAL(key_name, EFL_UTIL_ERROR_INVALID_PARAMETER);
1292 EINA_SAFETY_ON_FALSE_RETURN_VAL(pressed == 0 || pressed == 1, EFL_UTIL_ERROR_INVALID_PARAMETER);
1293 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1295 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1297 tizen_input_device_manager_generate_key(_eflutil.wl.devmgr.devicemgr, key_name, pressed);
1299 while (_eflutil.wl.devmgr.request_notified == -1)
1300 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1302 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1303 _eflutil.wl.devmgr.request_notified = -1;
1309 efl_util_input_generate_touch(efl_util_inputgen_h inputgen_h, int idx,
1310 efl_util_input_touch_type_e touch_type, int x, int y)
1313 enum tizen_input_device_manager_pointer_event_type type;
1315 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1316 EINA_SAFETY_ON_FALSE_RETURN_VAL(idx >= 0, EFL_UTIL_ERROR_INVALID_PARAMETER);
1317 EINA_SAFETY_ON_FALSE_RETURN_VAL((x > 0 && y > 0), EFL_UTIL_ERROR_INVALID_PARAMETER);
1318 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1320 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1324 case EFL_UTIL_INPUT_TOUCH_BEGIN:
1325 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_BEGIN;
1327 case EFL_UTIL_INPUT_TOUCH_UPDATE:
1328 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_UPDATE;
1330 case EFL_UTIL_INPUT_TOUCH_END:
1331 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_END;
1334 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1337 tizen_input_device_manager_generate_touch(_eflutil.wl.devmgr.devicemgr, type, x, y, idx);
1339 while (_eflutil.wl.devmgr.request_notified == -1)
1340 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1342 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1343 _eflutil.wl.devmgr.request_notified = -1;
1349 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)
1352 enum tizen_input_device_manager_pointer_event_type type;
1354 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1355 EINA_SAFETY_ON_FALSE_RETURN_VAL(buttons > 0, EFL_UTIL_ERROR_INVALID_PARAMETER);
1356 EINA_SAFETY_ON_FALSE_RETURN_VAL((x >= 0 && y >= 0), EFL_UTIL_ERROR_INVALID_PARAMETER);
1357 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_POINTER, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1359 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1361 switch(pointer_type)
1363 case EFL_UTIL_INPUT_POINTER_BUTTON_DOWN:
1364 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_BEGIN;
1366 case EFL_UTIL_INPUT_POINTER_MOVE:
1367 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_UPDATE;
1369 case EFL_UTIL_INPUT_POINTER_BUTTON_UP:
1370 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_END;
1373 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1376 tizen_input_device_manager_generate_pointer(_eflutil.wl.devmgr.devicemgr, type, x, y, buttons);
1378 while (_eflutil.wl.devmgr.request_notified == -1)
1379 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1381 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1382 _eflutil.wl.devmgr.request_notified = -1;
1388 struct _efl_util_screenshot_h
1393 Eina_Bool shot_done;
1399 /* scrrenshot handle */
1400 static efl_util_screenshot_h g_screenshot;
1402 API efl_util_screenshot_h
1403 efl_util_screenshot_initialize(int width, int height)
1405 efl_util_screenshot_h screenshot = NULL;
1407 if (!_eflutil.wl.shot.screenshooter)
1411 while (!_eflutil.wl.shot.screenshooter && ret != -1)
1412 ret = wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1413 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.screenshooter, fail_init);
1415 _eflutil.wl.shot.tbm_client = wayland_tbm_client_init(_eflutil.wl.dpy);
1416 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.tbm_client, fail_init);
1419 EINA_SAFETY_ON_FALSE_GOTO(width > 0, fail_param);
1420 EINA_SAFETY_ON_FALSE_GOTO(height > 0, fail_param);
1424 if (g_screenshot->width != width || g_screenshot->height != height)
1426 g_screenshot->width = width;
1427 g_screenshot->height = height;
1430 return g_screenshot;
1433 screenshot = calloc(1, sizeof(struct _efl_util_screenshot_h));
1434 EINA_SAFETY_ON_NULL_GOTO(screenshot, fail_memory);
1436 screenshot->width = width;
1437 screenshot->height = height;
1439 screenshot->bufmgr = wayland_tbm_client_get_bufmgr(_eflutil.wl.shot.tbm_client);
1440 EINA_SAFETY_ON_NULL_GOTO(screenshot->bufmgr, fail_init);
1442 g_screenshot = screenshot;
1443 set_last_result(EFL_UTIL_ERROR_NONE);
1445 screenshooter_set_user_data(_eflutil.wl.shot.screenshooter, &screenshot->shot_done);
1447 return g_screenshot;
1450 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1453 /* LCOV_EXCL_START */
1454 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
1456 /* LCOV_EXCL_STOP */
1459 efl_util_screenshot_deinitialize(screenshot);
1460 set_last_result(EFL_UTIL_ERROR_SCREENSHOT_INIT_FAIL);
1465 efl_util_screenshot_deinitialize(efl_util_screenshot_h screenshot)
1468 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1471 g_screenshot = NULL;
1473 if (_eflutil.wl.shot.screenshooter)
1474 screenshooter_set_user_data(_eflutil.wl.shot.screenshooter, NULL);
1476 return EFL_UTIL_ERROR_NONE;
1481 efl_util_screenshot_take_tbm_surface(efl_util_screenshot_h screenshot)
1483 tbm_surface_h t_surface = NULL;
1484 struct wl_buffer *buffer = NULL;
1485 Efl_Util_Wl_Output_Info *output;
1488 if (!screenshot || (screenshot != g_screenshot))
1490 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1494 output = eina_list_nth(_eflutil.wl.shot.output_list, 0);
1497 fprintf(stderr, "[screenshot] fail: no output for screenshot\n"); /* LCOV_EXCL_LINE */
1501 t_surface = tbm_surface_create(screenshot->width, screenshot->height, TBM_FORMAT_XRGB8888);
1504 fprintf(stderr, "[screenshot] fail: tbm_surface_create\n"); /* LCOV_EXCL_LINE */
1508 buffer = wayland_tbm_client_create_buffer(_eflutil.wl.shot.tbm_client, t_surface);
1511 fprintf(stderr, "[screenshot] fail: create wl_buffer for screenshot\n"); /* LCOV_EXCL_LINE */
1515 screenshooter_shoot(_eflutil.wl.shot.screenshooter, output->output, buffer);
1517 screenshot->shot_done = EINA_FALSE;
1518 while (!screenshot->shot_done && ret != -1)
1519 ret = wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1523 fprintf(stderr, "[screenshot] fail: screenshooter_shoot\n"); /* LCOV_EXCL_LINE */
1527 wl_buffer_destroy(buffer);
1529 /* reset shot_done for next screenshot */
1530 screenshot->shot_done = EINA_FALSE;
1536 tbm_surface_destroy(t_surface);
1538 wl_buffer_destroy(buffer);
1540 set_last_result(EFL_UTIL_ERROR_SCREENSHOT_EXECUTION_FAIL);