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"
23 #include <Elementary.h>
24 #include <Ecore_Evas.h>
29 #endif /* end of X11 */
32 #include <Ecore_Wayland.h>
33 #include <wayland-client.h>
34 #include "tizen_notification-client-protocol.h"
35 #include "tizen_window_screen-client-protocol.h"
36 #endif /* end of WAYLAND */
38 /* callback handler index */
39 #define CBH_NOTI_LEV 0
40 #define CBH_SCR_MODE 1
43 typedef void (*Efl_Util_Cb)(Evas_Object *, int, void *);
45 typedef struct _Efl_Util_Callback_Info
50 } Efl_Util_Callback_Info;
52 typedef struct _Efl_Util_Wl_Surface_Lv_Info
54 void *surface; /* wl_surface */
56 Eina_Bool wait_for_done;
57 } Efl_Util_Wl_Surface_Lv_Info;
59 typedef struct _Efl_Util_Wl_Surface_Scr_Mode_Info
61 void *surface; /* wl_surface */
63 Eina_Bool wait_for_done;
64 } Efl_Util_Wl_Surface_Scr_Mode_Info;
66 typedef struct _Efl_Util_Data
68 /* x11 related stuffs */
72 Ecore_Event_Handler *handler; /* x11 client message handler */
75 #endif /* end of X11 */
80 Eina_List *info_list; /* list of callback info */
81 unsigned int atom; /* x11 atom */
82 } cb_handler[CBH_MAX];
84 /* wayland related stuffs */
89 struct wl_display *dpy;
92 struct tizen_notification *proto;
97 struct tizen_window_screen *proto;
100 #endif /* end of WAYLAND */
104 static Efl_Util_Data _eflutil =
111 #endif /* end of X11 */
114 { NULL, 0 }, /* handler for notification level */
115 { NULL, 0 } /* handler for screen mode */
121 { NULL, NULL }, /* tizen_notification protocol */
122 { NULL, NULL } /* tizen_window_screen protocol */
123 #endif /* end of WAYLAND */
127 static Eina_Bool _cb_info_add(Evas_Object *win, Efl_Util_Cb cb, void *data, int idx);
128 static Eina_Bool _cb_info_del_by_win(Evas_Object *win, int idx);
129 static Eina_List *_cb_info_list_get(int idx);
130 static Efl_Util_Callback_Info *_cb_info_find_by_win(Evas_Object *win, int idx);
132 static Efl_Util_Callback_Info *_cb_info_find_by_xwin(unsigned int xwin);
133 static Eina_Bool _cb_x11_client_msg(void *data, int type, void *event);
134 static Eina_Bool _x11_init(void);
135 #endif /* end of X11 */
137 static Eina_Bool _wl_init(void);
138 static void _cb_wl_reg_global(void *data, struct wl_registry *reg, unsigned int name, const char *interface, unsigned int version);
139 static void _cb_wl_reg_global_remove(void *data, struct wl_registry *reg, unsigned int name);
140 static Efl_Util_Callback_Info *_cb_info_find_by_wlsurf(void *wlsurf, int idx);
141 static void _cb_wl_tz_noti_lv_done(void *data, struct tizen_notification *proto, struct wl_surface *surface, int32_t level, uint32_t state);
142 static void _cb_wl_tz_scr_mode_done(void *data, struct tizen_window_screen *proto, struct wl_surface *surface, uint32_t mode, uint32_t state);
144 static const struct wl_registry_listener _wl_reg_listener =
147 _cb_wl_reg_global_remove
150 struct tizen_notification_listener _wl_tz_noti_lv_listener =
152 _cb_wl_tz_noti_lv_done
155 struct tizen_window_screen_listener _wl_tz_scr_mode_listener =
157 _cb_wl_tz_scr_mode_done
159 #endif /* end of WAYLAND */
162 _cb_info_add(Evas_Object *win,
167 Efl_Util_Callback_Info *info;
169 info = _cb_info_find_by_win(win, idx);
172 _eflutil.cb_handler[idx].info_list
173 = eina_list_remove(_eflutil.cb_handler[idx].info_list,
178 info = (Efl_Util_Callback_Info *)calloc(1, sizeof(Efl_Util_Callback_Info));
179 if (!info) return EINA_FALSE;
185 _eflutil.cb_handler[idx].info_list
186 = eina_list_append(_eflutil.cb_handler[idx].info_list,
190 if (!_eflutil.x11.handler)
191 _eflutil.x11.handler = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE,
194 #endif /* end of X11 */
200 _cb_info_del_by_win(Evas_Object *win,
203 Efl_Util_Callback_Info *info;
206 info = _cb_info_find_by_win(win, idx);
207 if (!info) return EINA_FALSE;
209 _eflutil.cb_handler[idx].info_list
210 = eina_list_remove(_eflutil.cb_handler[idx].info_list,
214 count = eina_list_count(_eflutil.cb_handler[idx].info_list);
215 if ((count == 0) && (_eflutil.x11.handler))
217 ecore_event_handler_del(_eflutil.x11.handler);
218 _eflutil.x11.handler = NULL;
225 _cb_info_list_get(int idx)
227 return _eflutil.cb_handler[idx].info_list;
230 static Efl_Util_Callback_Info *
231 _cb_info_find_by_win(Evas_Object *win,
235 Efl_Util_Callback_Info *info;
237 l = _cb_info_list_get(idx);
238 EINA_LIST_FOREACH(l, ll, info)
240 if (info->win == win) return info;
247 static Efl_Util_Callback_Info *
248 _cb_info_find_by_xwin(unsigned int xwin,
252 Efl_Util_Callback_Info *info;
255 l = _cb_info_list_get(idx);
256 EINA_LIST_FOREACH(l, ll, info)
258 xwin2 = elm_win_xwindow_get(info->win);
259 if (xwin == xwin2) return info;
266 _cb_x11_client_msg(void *data,
270 Ecore_X_Event_Client_Message *ev;
272 Efl_Util_Callback_Info *info;
275 if (!ev) return ECORE_CALLBACK_PASS_ON;
278 if (xwin == 0) return ECORE_CALLBACK_PASS_ON;
280 if (ev->message_type == _eflutil.atom.noti_lv)
282 info = _cb_info_find_by_xwin(xwin, CBH_NOTI_LEV);
284 /* permission denied */
285 if ((ev->data.l[1] == 0) &&
290 EFL_UTIL_ERROR_PERMISSION_DENIED,
294 else if (ev->message_type == _eflutil.atom.scr_mode)
296 info = _cb_info_find_by_xwin(xwin, CBH_SCR_MODE);
298 /* permission denied */
299 if ((ev->data.l[1] == 0) &&
304 EFL_UTIL_ERROR_PERMISSION_DENIED,
308 return ECORE_CALLBACK_PASS_ON;
314 if (_eflutil.x11.init) return EINA_TRUE;
316 _eflutil.x11.dpy = ecore_x_display_get();
317 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.x11.dpy, EINA_FALSE);
319 _eflutil.x11.init = EINA_TRUE;
323 #endif /* end of X11 */
329 struct wl_registry *reg;
331 if (_eflutil.wl.init) return EINA_TRUE;
333 _eflutil.wl.dpy = ecore_wl_display_get();
334 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.dpy, EINA_FALSE);
336 reg = wl_display_get_registry(_eflutil.wl.dpy);
337 EINA_SAFETY_ON_NULL_RETURN_VAL(reg, EINA_FALSE);
339 wl_registry_add_listener(reg, &_wl_reg_listener, NULL);
341 _eflutil.wl.init = EINA_TRUE;
347 _cb_wl_reg_global(void *data,
348 struct wl_registry *reg,
350 const char *interface,
351 unsigned int version)
353 if (!strcmp(interface, "tizen_notification"))
355 struct tizen_notification *proto;
356 proto = wl_registry_bind(reg,
358 &tizen_notification_interface,
362 tizen_notification_add_listener(proto,
363 &_wl_tz_noti_lv_listener,
366 _eflutil.wl.noti_lv.hash = eina_hash_pointer_new(free);
367 _eflutil.wl.noti_lv.proto = proto;
369 else if (!strcmp(interface, "tizen_window_screen"))
371 struct tizen_window_screen *proto;
372 proto = wl_registry_bind(reg,
374 &tizen_window_screen_interface,
378 tizen_window_screen_add_listener(proto,
379 &_wl_tz_scr_mode_listener,
382 _eflutil.wl.scr_mode.hash = eina_hash_pointer_new(free);
383 _eflutil.wl.scr_mode.proto = proto;
388 _cb_wl_reg_global_remove(void *data,
389 struct wl_registry *reg,
392 _eflutil.wl.noti_lv.proto = NULL;
393 eina_hash_free(_eflutil.wl.noti_lv.hash);
394 _eflutil.wl.scr_mode.proto = NULL;
395 eina_hash_free(_eflutil.wl.scr_mode.hash);
398 static Efl_Util_Callback_Info *
399 _cb_info_find_by_wlsurf(void *wlsurf,
403 Efl_Util_Callback_Info *info;
404 Ecore_Wl_Window *wlwin2 = NULL;
405 void *wlsurf2 = NULL;
407 l = _cb_info_list_get(idx);
408 EINA_LIST_FOREACH(l, ll, info)
410 wlwin2 = elm_win_wl_window_get(info->win);
411 wlsurf2 = ecore_wl_window_surface_get(wlwin2);
412 if (wlsurf== wlsurf2) return info;
419 _cb_wl_tz_noti_lv_done(void *data,
420 struct tizen_notification *proto,
421 struct wl_surface *surface,
425 Efl_Util_Wl_Surface_Lv_Info *lv_info;
426 Efl_Util_Callback_Info *cb_info;
428 lv_info = eina_hash_find(_eflutil.wl.noti_lv.hash, &surface);
431 lv_info->level = level;
432 lv_info->wait_for_done = EINA_FALSE;
435 if (state != TIZEN_NOTIFICATION_ERROR_STATE_PERMISSION_DENIED) return;
437 cb_info = _cb_info_find_by_wlsurf((void *)surface, CBH_NOTI_LEV);
438 if (!cb_info) return;
439 if (!cb_info->cb) return;
441 cb_info->cb(cb_info->win,
442 EFL_UTIL_ERROR_PERMISSION_DENIED,
447 _cb_wl_tz_scr_mode_done(void *data,
448 struct tizen_window_screen *proto,
449 struct wl_surface *surface,
454 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
455 Efl_Util_Callback_Info *cb_info;
457 scr_mode_info = eina_hash_find(_eflutil.wl.scr_mode.hash, &surface);
460 scr_mode_info->mode = mode;
461 scr_mode_info->wait_for_done = EINA_FALSE;
464 if (state != TIZEN_WINDOW_SCREEN_ERROR_STATE_PERMISSION_DENIED) return;
466 cb_info = _cb_info_find_by_wlsurf((void *)surface, CBH_SCR_MODE);
467 if (!cb_info) return;
468 if (!cb_info->cb) return;
470 cb_info->cb(cb_info->win,
471 EFL_UTIL_ERROR_PERMISSION_DENIED,
474 #endif /* end of WAYLAND */
477 efl_util_set_notification_window_level(Evas_Object *window,
478 efl_util_notification_level_e level)
482 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
483 EINA_SAFETY_ON_FALSE_RETURN_VAL((level >= EFL_UTIL_NOTIFICATION_LEVEL_1) &&
484 (level <= EFL_UTIL_NOTIFICATION_LEVEL_TOP),
485 EFL_UTIL_ERROR_INVALID_PARAMETER);
488 Ecore_X_Window_Type window_type;
492 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
494 xwin = elm_win_xwindow_get(window);
497 if (ecore_x_netwm_window_type_get(xwin, &window_type) == EINA_TRUE)
499 // success to get window type
500 if (window_type != ECORE_X_WINDOW_TYPE_NOTIFICATION)
502 // given EFL window's type is not notification type.
503 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
507 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
509 utilx_set_system_notification_level(_eflutil.x11.dpy,
512 return EFL_UTIL_ERROR_NONE;
514 #endif /* end of X11 */
518 Ecore_Wl_Window *wlwin;
519 struct wl_surface *surface;
520 Efl_Util_Wl_Surface_Lv_Info *lv_info;
523 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
525 type = elm_win_type_get(window);
526 EINA_SAFETY_ON_FALSE_RETURN_VAL((type == ELM_WIN_NOTIFICATION),
527 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
529 wlwin = elm_win_wl_window_get(window);
532 while (!_eflutil.wl.noti_lv.proto)
533 wl_display_dispatch(_eflutil.wl.dpy);
535 surface = ecore_wl_window_surface_get(wlwin);
536 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
537 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
539 lv_info = eina_hash_find(_eflutil.wl.noti_lv.hash, &surface);
542 lv_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Lv_Info));
543 EINA_SAFETY_ON_NULL_RETURN_VAL(lv_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
545 lv_info->surface = surface;
546 lv_info->level = (int)level;
547 lv_info->wait_for_done = EINA_TRUE;
549 eina_hash_add(_eflutil.wl.noti_lv.hash,
555 lv_info->level = (int)level;
556 lv_info->wait_for_done = EINA_TRUE;
559 tizen_notification_set_level(_eflutil.wl.noti_lv.proto,
563 return EFL_UTIL_ERROR_NONE;
565 #endif /* end of WAYLAND */
567 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
571 efl_util_get_notification_window_level(Evas_Object *window,
572 efl_util_notification_level_e *level)
576 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
577 EINA_SAFETY_ON_NULL_RETURN_VAL(level, EFL_UTIL_ERROR_INVALID_PARAMETER);
580 Ecore_X_Window_Type window_type;
581 Utilx_Notification_Level utilx_level;
585 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
587 xwin = elm_win_xwindow_get(window);
590 if (ecore_x_netwm_window_type_get(xwin, &window_type) == EINA_TRUE)
592 // success to get window type
593 if (window_type != ECORE_X_WINDOW_TYPE_NOTIFICATION)
595 // given EFL window's type is not notification type.
596 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
599 utilx_level = utilx_get_system_notification_level(_eflutil.x11.dpy, xwin);
600 if (utilx_level == UTILX_NOTIFICATION_LEVEL_LOW)
601 *level = EFL_UTIL_NOTIFICATION_LEVEL_1;
602 else if(utilx_level == UTILX_NOTIFICATION_LEVEL_NORMAL)
603 *level = EFL_UTIL_NOTIFICATION_LEVEL_2;
604 else if(utilx_level == UTILX_NOTIFICATION_LEVEL_HIGH)
605 *level = EFL_UTIL_NOTIFICATION_LEVEL_3;
607 return EFL_UTIL_ERROR_INVALID_PARAMETER;
610 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
612 return EFL_UTIL_ERROR_NONE;
614 #endif /* end of X11 */
618 Ecore_Wl_Window *wlwin;
619 struct wl_surface *surface;
620 Efl_Util_Wl_Surface_Lv_Info *lv_info;
623 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
625 type = elm_win_type_get(window);
626 EINA_SAFETY_ON_FALSE_RETURN_VAL((type == ELM_WIN_NOTIFICATION),
627 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
629 wlwin = elm_win_wl_window_get(window);
632 while (!_eflutil.wl.noti_lv.proto)
633 wl_display_dispatch(_eflutil.wl.dpy);
635 surface = ecore_wl_window_surface_get(wlwin);
636 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
637 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
639 lv_info = eina_hash_find(_eflutil.wl.noti_lv.hash, &surface);
642 if (lv_info->wait_for_done)
644 if (ecore_wl_window_shell_surface_get(wlwin) ||
645 ecore_wl_window_xdg_surface_get(wlwin))
647 while (lv_info->wait_for_done)
650 wl_display_dispatch(_eflutil.wl.dpy);
655 *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
656 return EFL_UTIL_ERROR_INVALID_PARAMETER;
660 switch (lv_info->level)
662 case TIZEN_NOTIFICATION_LEVEL_1: *level = EFL_UTIL_NOTIFICATION_LEVEL_1; break;
663 case TIZEN_NOTIFICATION_LEVEL_2: *level = EFL_UTIL_NOTIFICATION_LEVEL_2; break;
664 case TIZEN_NOTIFICATION_LEVEL_3: *level = EFL_UTIL_NOTIFICATION_LEVEL_3; break;
665 case TIZEN_NOTIFICATION_LEVEL_NONE: *level = EFL_UTIL_NOTIFICATION_LEVEL_NONE; break;
666 case TIZEN_NOTIFICATION_LEVEL_DEFAULT: *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT; break;
667 case TIZEN_NOTIFICATION_LEVEL_MEDIUM: *level = EFL_UTIL_NOTIFICATION_LEVEL_MEDIUM; break;
668 case TIZEN_NOTIFICATION_LEVEL_HIGH: *level = EFL_UTIL_NOTIFICATION_LEVEL_HIGH; break;
669 case TIZEN_NOTIFICATION_LEVEL_TOP: *level = EFL_UTIL_NOTIFICATION_LEVEL_TOP; break;
670 default: *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
671 return EFL_UTIL_ERROR_INVALID_PARAMETER;
673 return EFL_UTIL_ERROR_NONE;
676 *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
678 return EFL_UTIL_ERROR_NONE;
680 #endif /* end of WAYLAND */
681 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
685 efl_util_set_notification_window_level_error_cb(Evas_Object *window,
686 efl_util_notification_window_level_error_cb callback,
689 Eina_Bool ret = EINA_FALSE;
691 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
692 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EFL_UTIL_ERROR_INVALID_PARAMETER);
694 ret = _cb_info_add(window,
695 (Efl_Util_Cb)callback,
698 if (!ret) return EFL_UTIL_ERROR_OUT_OF_MEMORY;
701 if (!_eflutil.atom.noti_lv)
702 _eflutil.atom.noti_lv = ecore_x_atom_get("_E_NOTIFICATION_LEVEL_ACCESS_RESULT");
703 #endif /* end of X11 */
705 return EFL_UTIL_ERROR_NONE;
709 efl_util_unset_notification_window_level_error_cb(Evas_Object *window)
711 Eina_Bool ret = EINA_FALSE;
713 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
715 ret = _cb_info_del_by_win(window, CBH_NOTI_LEV);
716 if (!ret) return EFL_UTIL_ERROR_INVALID_PARAMETER;
718 return EFL_UTIL_ERROR_NONE;
722 efl_util_set_window_opaque_state(Evas_Object *window,
727 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
728 EINA_SAFETY_ON_FALSE_RETURN_VAL(((opaque >= 0) && (opaque <= 1)),
729 EFL_UTIL_ERROR_INVALID_PARAMETER);
733 Utilx_Opaque_State state;
737 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
739 xwin = elm_win_xwindow_get(window);
740 EINA_SAFETY_ON_NULL_RETURN_VAL(xwin, EFL_UTIL_ERROR_INVALID_PARAMETER);
743 state = UTILX_OPAQUE_STATE_ON;
745 state = UTILX_OPAQUE_STATE_OFF;
747 ret = utilx_set_window_opaque_state(_eflutil.x11.dpy,
752 return EFL_UTIL_ERROR_INVALID_PARAMETER;
754 return EFL_UTIL_ERROR_NONE;
755 #endif /* end of X11 */
758 Ecore_Wl_Window *wlwin;
762 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
764 wlwin = elm_win_wl_window_get(window);
767 evas_object_geometry_get(window, &x, &y, &w, &h);
770 ecore_wl_window_opaque_region_set(wlwin, x, y, w, h);
772 ecore_wl_window_opaque_region_set(wlwin, 0, 0, 0, 0);
774 return EFL_UTIL_ERROR_NONE;
777 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
778 #endif /* end of WAYLAND */
782 efl_util_set_window_screen_mode(Evas_Object *window,
783 efl_util_screen_mode_e mode)
785 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
786 EINA_SAFETY_ON_FALSE_RETURN_VAL(((mode >= EFL_UTIL_SCREEN_MODE_DEFAULT) &&
787 (mode <= EFL_UTIL_SCREEN_MODE_ALWAYS_ON)),
788 EFL_UTIL_ERROR_INVALID_PARAMETER);
795 e = evas_object_evas_get(window);
796 EINA_SAFETY_ON_NULL_RETURN_VAL(e, EFL_UTIL_ERROR_INVALID_PARAMETER);
798 ee = ecore_evas_ecore_evas_get(e);
799 EINA_SAFETY_ON_NULL_RETURN_VAL(ee, EFL_UTIL_ERROR_INVALID_PARAMETER);
801 id = ecore_evas_aux_hint_id_get(ee, "wm.policy.win.lcd.lock");
802 if (mode == EFL_UTIL_SCREEN_MODE_ALWAYS_ON)
805 ecore_evas_aux_hint_add(ee, "wm.policy.win.lcd.lock", "1");
807 ecore_evas_aux_hint_val_set(ee, id, "1");
809 else if (mode == EFL_UTIL_SCREEN_MODE_DEFAULT)
812 ecore_evas_aux_hint_add(ee, "wm.policy.win.lcd.lock", "0");
814 ecore_evas_aux_hint_val_set(ee, id, "0");
817 return EFL_UTIL_ERROR_INVALID_PARAMETER;
819 return EFL_UTIL_ERROR_NONE;
820 #endif /* end of X11 */
823 Ecore_Wl_Window *wlwin;
824 struct wl_surface *surface;
825 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
829 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
831 wlwin = elm_win_wl_window_get(window);
834 while (!_eflutil.wl.scr_mode.proto)
835 wl_display_dispatch(_eflutil.wl.dpy);
837 surface = ecore_wl_window_surface_get(wlwin);
838 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
839 EFL_UTIL_ERROR_INVALID_PARAMETER);
841 scr_mode_info = eina_hash_find(_eflutil.wl.scr_mode.hash, &surface);
844 scr_mode_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Scr_Mode_Info));
845 EINA_SAFETY_ON_NULL_RETURN_VAL(scr_mode_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
847 scr_mode_info->surface = surface;
848 scr_mode_info->mode = (unsigned int)mode;
849 scr_mode_info->wait_for_done = EINA_TRUE;
851 eina_hash_add(_eflutil.wl.scr_mode.hash,
857 scr_mode_info->mode = (unsigned int)mode;
858 scr_mode_info->wait_for_done = EINA_TRUE;
861 tizen_window_screen_set_mode(_eflutil.wl.scr_mode.proto,
865 return EFL_UTIL_ERROR_NONE;
868 return EFL_UTIL_ERROR_INVALID_PARAMETER;
869 #endif /* end of WAYLAND */
873 efl_util_get_window_screen_mode(Evas_Object *window,
874 efl_util_screen_mode_e *mode)
876 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
877 EINA_SAFETY_ON_NULL_RETURN_VAL(mode, EFL_UTIL_ERROR_INVALID_PARAMETER);
885 e = evas_object_evas_get(window);
886 EINA_SAFETY_ON_NULL_RETURN_VAL(e, EFL_UTIL_ERROR_INVALID_PARAMETER);
888 ee = ecore_evas_ecore_evas_get(e);
889 EINA_SAFETY_ON_NULL_RETURN_VAL(ee, EFL_UTIL_ERROR_INVALID_PARAMETER);
891 id = ecore_evas_aux_hint_id_get(ee, "wm.policy.win.lcd.lock");
892 EINA_SAFETY_ON_TRUE_RETURN_VAL((id == -1), EFL_UTIL_ERROR_INVALID_PARAMETER);
894 str = ecore_evas_aux_hint_val_get(ee, id);
895 EINA_SAFETY_ON_NULL_RETURN_VAL(str, EFL_UTIL_ERROR_INVALID_PARAMETER);
897 if (strncmp(str, "1", strlen("1")) == 0)
898 *mode = EFL_UTIL_SCREEN_MODE_ALWAYS_ON;
900 *mode = EFL_UTIL_SCREEN_MODE_DEFAULT;
902 return EFL_UTIL_ERROR_NONE;
903 #endif /* end of X11 */
906 Ecore_Wl_Window *wlwin;
907 struct wl_surface *surface;
908 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
912 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
914 wlwin = elm_win_wl_window_get(window);
917 while (!_eflutil.wl.scr_mode.proto)
918 wl_display_dispatch(_eflutil.wl.dpy);
920 surface = ecore_wl_window_surface_get(wlwin);
921 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
922 EFL_UTIL_ERROR_INVALID_PARAMETER);
924 scr_mode_info = eina_hash_find(_eflutil.wl.scr_mode.hash, &surface);
927 if (scr_mode_info->wait_for_done)
929 while (scr_mode_info->wait_for_done)
932 wl_display_dispatch(_eflutil.wl.dpy);
936 switch (scr_mode_info->mode)
938 case TIZEN_WINDOW_SCREEN_MODE_DEFAULT: *mode = EFL_UTIL_SCREEN_MODE_DEFAULT; break;
939 case TIZEN_WINDOW_SCREEN_MODE_ALWAYS_ON: *mode = EFL_UTIL_SCREEN_MODE_ALWAYS_ON; break;
940 default: *mode = EFL_UTIL_SCREEN_MODE_DEFAULT;
941 return EFL_UTIL_ERROR_INVALID_PARAMETER;
943 return EFL_UTIL_ERROR_NONE;
947 *mode = EFL_UTIL_SCREEN_MODE_DEFAULT;
948 return EFL_UTIL_ERROR_INVALID_PARAMETER;
952 return EFL_UTIL_ERROR_INVALID_PARAMETER;
953 #endif /* end of WAYLAND */
957 efl_util_set_window_screen_mode_error_cb(Evas_Object *window,
958 efl_util_window_screen_mode_error_cb callback,
961 Eina_Bool ret = EINA_FALSE;
963 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
964 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EFL_UTIL_ERROR_INVALID_PARAMETER);
966 ret = _cb_info_add(window,
967 (Efl_Util_Cb)callback,
970 if (!ret) return EFL_UTIL_ERROR_OUT_OF_MEMORY;
973 if (!_eflutil.atom.scr_mode)
974 _eflutil.atom.scr_mode = ecore_x_atom_get("_E_SCREEN_MODE_ACCESS_RESULT");
975 #endif /* end of X11 */
977 return EFL_UTIL_ERROR_NONE;
981 efl_util_unset_window_screen_mode_error_cb(Evas_Object *window)
983 Eina_Bool ret = EINA_FALSE;
985 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
987 ret = _cb_info_del_by_win(window, CBH_SCR_MODE);
988 if (!ret) return EFL_UTIL_ERROR_INVALID_PARAMETER;
990 return EFL_UTIL_ERROR_NONE;
994 efl_util_input_initialize_generator(efl_util_input_device_type_e dev_type)
996 return EFL_UTIL_ERROR_NONE;
1000 efl_util_input_deinitialize_generator(void)
1006 efl_util_input_generate_key(const char *key_name,
1009 return EFL_UTIL_ERROR_NONE;
1013 efl_util_input_generate_touch(int idx,
1014 efl_util_input_touch_type_e touch_type,
1018 return EFL_UTIL_ERROR_NONE;
1021 API efl_util_screenshot_h
1022 efl_util_screenshot_initialize(int width,
1029 efl_util_screenshot_take_tbm_surface(efl_util_screenshot_h screenshot)
1035 efl_util_screenshot_deinitialize(efl_util_screenshot_h screenshot)
1037 return EFL_UTIL_ERROR_NONE;