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>
36 #include <X11/extensions/Xvlib.h>
37 #include <X11/extensions/Xvproto.h>
38 #include <X11/extensions/Xdamage.h>
42 #endif /* end of X11 */
45 #include <Ecore_Wayland.h>
46 #include <wayland-client.h>
47 #include <wayland-tbm-client.h>
48 #include <tizen-extension-client-protocol.h>
49 #include <screenshooter-client-protocol.h>
50 #endif /* end of WAYLAND */
52 /* callback handler index */
53 #define CBH_NOTI_LEV 0
54 #define CBH_SCR_MODE 1
57 typedef void (*Efl_Util_Cb)(Evas_Object *, int, void *);
59 typedef struct _Efl_Util_Callback_Info
64 } Efl_Util_Callback_Info;
67 typedef struct _Efl_Util_Wl_Surface_Lv_Info
69 void *surface; /* wl_surface */
71 Eina_Bool wait_for_done;
73 } Efl_Util_Wl_Surface_Lv_Info;
75 typedef struct _Efl_Util_Wl_Surface_Scr_Mode_Info
77 void *surface; /* wl_surface */
79 Eina_Bool wait_for_done;
81 } Efl_Util_Wl_Surface_Scr_Mode_Info;
83 typedef struct _Efl_Util_Wl_Surface_Brightness_Info
85 void *surface; /* wl_surface */
87 Eina_Bool wait_for_done;
89 } Efl_Util_Wl_Surface_Brightness_Info;
91 typedef struct _Efl_Util_Wl_Output_Info
93 struct wl_output *output;
94 int offset_x, offset_y, width, height;
95 } Efl_Util_Wl_Output_Info;
98 typedef struct _Efl_Util_Data
101 /* x11 related stuffs */
105 Ecore_Event_Handler *handler; /* x11 client message handler */
106 Ecore_X_Display *dpy;
108 #endif /* end of X11 */
111 /* wayland related stuffs */
115 struct wl_display *dpy;
116 struct wl_event_queue *queue;
120 struct tizen_policy *proto;
121 Eina_Hash *hash_noti_lv;
122 Eina_Hash *hash_scr_mode;
126 struct screenshooter *screenshooter;
127 struct wayland_tbm_client *tbm_client;
128 Eina_List *output_list;
132 struct tizen_input_device_manager *devicemgr;
133 int request_notified;
137 struct tizen_display_policy *proto;
138 Eina_Hash *hash_brightness;
141 #endif /* end of WAYLAND */
145 Eina_List *info_list; /* list of callback info */
146 unsigned int atom; /* x11 atom */
147 } cb_handler[CBH_MAX];
150 static Efl_Util_Data _eflutil =
158 #endif /* end of X11 */
163 { NULL, NULL, NULL }, /* tizen_policy protocol */
164 { NULL, NULL, NULL }, /* screenshooter protocol */
165 { NULL, -1 } /* tizen_input_device_manager protocol */
167 #endif /* end of WAYLAND */
169 { NULL, 0 }, /* handler for notification level */
170 { NULL, 0 } /* handler for screen mode */
174 static Eina_Bool _cb_info_add(Evas_Object *win, Efl_Util_Cb cb, void *data, int idx);
175 static Eina_Bool _cb_info_del_by_win(Evas_Object *win, int idx);
176 static Eina_List *_cb_info_list_get(int idx);
177 static Efl_Util_Callback_Info *_cb_info_find_by_win(Evas_Object *win, int idx);
179 static Efl_Util_Callback_Info *_cb_info_find_by_xwin(unsigned int xwin, int idx);
180 static Eina_Bool _cb_x11_client_msg(void *data, int type, void *event);
181 static Eina_Bool _x11_init(void);
182 #endif /* end of X11 */
184 static Eina_Bool _wl_init(void);
185 static void _cb_wl_reg_global(void *data, struct wl_registry *reg, unsigned int name, const char *interface, unsigned int version);
186 static void _cb_wl_reg_global_remove(void *data, struct wl_registry *reg, unsigned int name);
187 static Efl_Util_Callback_Info *_cb_info_find_by_wlsurf(void *wlsurf, int idx);
188 static void _cb_wl_tz_policy_conformant(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface, uint32_t is_conformant);
189 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);
190 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);
191 static void _cb_wl_tz_policy_transient_for_done(void *data, struct tizen_policy *tizen_policy, uint32_t child_id);
192 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);
193 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);
194 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);
195 static void _cb_wl_tz_policy_allowed_aux_hint(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface_resource, int id);
197 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);
199 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);
200 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);
201 static void _cb_error(void *data EINA_UNUSED, struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED, uint32_t errorcode);
202 static void _cb_block_expired(void *data EINA_UNUSED, struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED);
204 static const struct wl_registry_listener _wl_reg_listener =
207 _cb_wl_reg_global_remove
210 struct tizen_policy_listener _wl_tz_policy_listener =
212 _cb_wl_tz_policy_conformant,
213 _cb_wl_tz_policy_conformant_area,
214 _cb_wl_tz_policy_notification_done,
215 _cb_wl_tz_policy_transient_for_done,
216 _cb_wl_tz_policy_scr_mode_done,
217 _cb_wl_tz_policy_iconify_state_changed,
218 _cb_wl_tz_policy_supported_aux_hints,
219 _cb_wl_tz_policy_allowed_aux_hint,
222 struct tizen_input_device_manager_listener _wl_tz_devmgr_listener =
230 struct tizen_display_policy_listener _wl_tz_display_policy_listener =
232 _cb_wl_tz_display_policy_brightness_done,
234 #endif /* end of WAYLAND */
237 _cb_info_add(Evas_Object *win,
242 Efl_Util_Callback_Info *info;
244 info = _cb_info_find_by_win(win, idx);
247 _eflutil.cb_handler[idx].info_list
248 = eina_list_remove(_eflutil.cb_handler[idx].info_list,
253 info = (Efl_Util_Callback_Info *)calloc(1, sizeof(Efl_Util_Callback_Info));
254 if (!info) return EINA_FALSE;
260 _eflutil.cb_handler[idx].info_list
261 = eina_list_append(_eflutil.cb_handler[idx].info_list,
265 if (!_eflutil.x11.handler)
266 _eflutil.x11.handler = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE,
269 #endif /* end of X11 */
275 _cb_info_del_by_win(Evas_Object *win,
278 Efl_Util_Callback_Info *info;
280 info = _cb_info_find_by_win(win, idx);
281 if (!info) return EINA_FALSE;
283 _eflutil.cb_handler[idx].info_list
284 = eina_list_remove(_eflutil.cb_handler[idx].info_list,
289 unsigned int count = eina_list_count(_eflutil.cb_handler[idx].info_list);
290 if ((count == 0) && (_eflutil.x11.handler))
292 ecore_event_handler_del(_eflutil.x11.handler);
293 _eflutil.x11.handler = NULL;
301 _cb_info_list_get(int idx)
303 return _eflutil.cb_handler[idx].info_list;
306 static Efl_Util_Callback_Info *
307 _cb_info_find_by_win(Evas_Object *win,
311 Efl_Util_Callback_Info *info;
313 l = _cb_info_list_get(idx);
314 EINA_LIST_FOREACH(l, ll, info)
316 if (info->win == win) return info;
323 static Efl_Util_Callback_Info *
324 _cb_info_find_by_xwin(unsigned int xwin,
328 Efl_Util_Callback_Info *info;
331 l = _cb_info_list_get(idx);
332 EINA_LIST_FOREACH(l, ll, info)
334 xwin2 = elm_win_xwindow_get(info->win);
335 if (xwin == xwin2) return info;
342 _cb_x11_client_msg(void *data,
346 Ecore_X_Event_Client_Message *ev;
348 Efl_Util_Callback_Info *info;
351 if (!ev) return ECORE_CALLBACK_PASS_ON;
354 if (xwin == 0) return ECORE_CALLBACK_PASS_ON;
356 if (ev->message_type == _eflutil.cb_handler[CBH_NOTI_LEV].atom)
358 info = _cb_info_find_by_xwin(xwin, CBH_NOTI_LEV);
360 /* permission denied */
361 if ((ev->data.l[1] == 0) &&
366 EFL_UTIL_ERROR_PERMISSION_DENIED,
370 else if (ev->message_type == _eflutil.cb_handler[CBH_SCR_MODE].atom)
372 info = _cb_info_find_by_xwin(xwin, CBH_SCR_MODE);
374 /* permission denied */
375 if ((ev->data.l[1] == 0) &&
380 EFL_UTIL_ERROR_PERMISSION_DENIED,
384 return ECORE_CALLBACK_PASS_ON;
390 if (_eflutil.x11.init) return EINA_TRUE;
392 _eflutil.x11.dpy = ecore_x_display_get();
393 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.x11.dpy, EINA_FALSE);
395 _eflutil.x11.init = EINA_TRUE;
399 #endif /* end of X11 */
405 struct wl_registry *reg = NULL;
407 if (_eflutil.wl.init) return EINA_TRUE;
411 _eflutil.wl.dpy = ecore_wl_display_get();
412 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.dpy, fail);
414 _eflutil.wl.queue = wl_display_create_queue(_eflutil.wl.dpy);
415 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.queue, fail);
417 reg = wl_display_get_registry(_eflutil.wl.dpy);
418 EINA_SAFETY_ON_NULL_GOTO(reg, fail);
420 wl_proxy_set_queue((struct wl_proxy*)reg, _eflutil.wl.queue);
421 wl_registry_add_listener(reg, &_wl_reg_listener, NULL);
423 _eflutil.wl.init = EINA_TRUE;
427 if (_eflutil.wl.queue)
429 wl_event_queue_destroy(_eflutil.wl.queue);
430 _eflutil.wl.queue = NULL;
434 wl_registry_destroy(reg);
440 _cb_wl_output_geometry(void *data, struct wl_output *wl_output, int x, int y,
441 int physical_width, int physical_height, int subpixel,
442 const char *make, const char *model, int transform)
444 Efl_Util_Wl_Output_Info *output = wl_output_get_user_data(wl_output);
445 if (wl_output == output->output)
447 output->offset_x = x;
448 output->offset_y = y;
453 _cb_wl_output_mode(void *data, struct wl_output *wl_output, uint32_t flags,
454 int width, int height, int refresh)
456 Efl_Util_Wl_Output_Info *output = wl_output_get_user_data(wl_output);
457 if (wl_output == output->output && (flags & WL_OUTPUT_MODE_CURRENT))
459 output->width = width;
460 output->height = height;
465 _cb_wl_output_done(void *data, struct wl_output *wl_output)
470 _cb_wl_output_scale(void *data, struct wl_output *wl_output, int32_t factor)
474 static const struct wl_output_listener output_listener =
476 _cb_wl_output_geometry,
483 _cb_wl_screenshot_done(void *data, struct screenshooter *screenshooter)
485 Eina_Bool *shot_done = (Eina_Bool*)data;
487 *shot_done = EINA_TRUE;
490 static const struct screenshooter_listener screenshooter_listener =
492 _cb_wl_screenshot_done
496 _cb_wl_reg_global(void *data,
497 struct wl_registry *reg,
499 const char *interface,
500 unsigned int version)
502 if (!strcmp(interface, "tizen_policy"))
504 struct tizen_policy *proto;
505 proto = wl_registry_bind(reg,
507 &tizen_policy_interface,
511 tizen_policy_add_listener(proto,
512 &_wl_tz_policy_listener,
515 _eflutil.wl.policy.hash_noti_lv = eina_hash_pointer_new(free);
516 _eflutil.wl.policy.hash_scr_mode = eina_hash_pointer_new(free);
517 _eflutil.wl.policy.proto = proto;
519 else if (strcmp(interface, "wl_output") == 0)
521 Efl_Util_Wl_Output_Info *output = calloc(1, sizeof(Efl_Util_Wl_Output_Info));
522 EINA_SAFETY_ON_NULL_RETURN(output);
524 _eflutil.wl.shot.output_list = eina_list_append(_eflutil.wl.shot.output_list, output);
526 output->output = wl_registry_bind(reg, name, &wl_output_interface, version);
527 wl_output_add_listener(output->output, &output_listener, output);
529 else if (strcmp(interface, "screenshooter") == 0)
531 _eflutil.wl.shot.screenshooter = wl_registry_bind(reg, name, &screenshooter_interface, version);
532 screenshooter_add_listener(_eflutil.wl.shot.screenshooter, &screenshooter_listener, NULL);
534 else if (strcmp(interface, "tizen_input_device_manager") == 0)
536 _eflutil.wl.devmgr.devicemgr = wl_registry_bind(reg, name, &tizen_input_device_manager_interface, version);
537 tizen_input_device_manager_add_listener(_eflutil.wl.devmgr.devicemgr, &_wl_tz_devmgr_listener, NULL);
539 else if (!strcmp(interface, "tizen_display_policy"))
541 _eflutil.wl.display_policy.proto = wl_registry_bind(reg, name, &tizen_display_policy_interface, version);
542 if (!_eflutil.wl.display_policy.proto) return;
544 tizen_display_policy_add_listener(_eflutil.wl.display_policy.proto,
545 &_wl_tz_display_policy_listener,
548 _eflutil.wl.display_policy.hash_brightness = eina_hash_pointer_new(free);
554 _cb_wl_reg_global_remove(void *data,
555 struct wl_registry *reg,
558 _eflutil.wl.policy.proto = NULL;
559 eina_hash_free(_eflutil.wl.policy.hash_noti_lv);
560 eina_hash_free(_eflutil.wl.policy.hash_scr_mode);
562 _eflutil.wl.display_policy.proto = NULL;
563 eina_hash_free(_eflutil.wl.display_policy.hash_brightness);
566 static Efl_Util_Callback_Info *
567 _cb_info_find_by_wlsurf(void *wlsurf,
571 Efl_Util_Callback_Info *info;
572 Ecore_Wl_Window *wlwin2 = NULL;
573 void *wlsurf2 = NULL;
575 l = _cb_info_list_get(idx);
576 EINA_LIST_FOREACH(l, ll, info)
578 wlwin2 = elm_win_wl_window_get(info->win);
579 wlsurf2 = ecore_wl_window_surface_get(wlwin2);
580 if (wlsurf== wlsurf2) return info;
587 _cb_wl_tz_policy_conformant(void *data, struct tizen_policy *tizen_policy,
588 struct wl_surface *surface, uint32_t is_conformant)
593 _cb_wl_tz_policy_conformant_area(void *data, struct tizen_policy *tizen_policy,
594 struct wl_surface *surface, uint32_t conformant_part,
595 uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h)
600 _cb_wl_tz_policy_notification_done(void *data,
601 struct tizen_policy *tizen_policy,
602 struct wl_surface *surface,
606 Efl_Util_Wl_Surface_Lv_Info *lv_info;
607 Efl_Util_Callback_Info *cb_info;
609 lv_info = eina_hash_find(_eflutil.wl.policy.hash_noti_lv, &surface);
612 lv_info->level = level;
613 lv_info->wait_for_done = EINA_FALSE;
614 lv_info->state = state;
617 if (state != TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED) return;
619 cb_info = _cb_info_find_by_wlsurf((void *)surface, CBH_NOTI_LEV);
620 if (!cb_info) return;
621 if (!cb_info->cb) return;
623 cb_info->cb(cb_info->win,
624 EFL_UTIL_ERROR_PERMISSION_DENIED,
629 _cb_wl_tz_policy_transient_for_done(void *data, struct tizen_policy *tizen_policy, uint32_t child_id)
634 _cb_wl_tz_policy_scr_mode_done(void *data,
635 struct tizen_policy *tizen_policy,
636 struct wl_surface *surface,
641 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
642 Efl_Util_Callback_Info *cb_info;
644 scr_mode_info = eina_hash_find(_eflutil.wl.policy.hash_scr_mode, &surface);
647 scr_mode_info->mode = mode;
648 scr_mode_info->wait_for_done = EINA_FALSE;
649 scr_mode_info->state = state;
652 if (state != TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED) return;
654 cb_info = _cb_info_find_by_wlsurf((void *)surface, CBH_SCR_MODE);
655 if (!cb_info) return;
656 if (!cb_info->cb) return;
658 cb_info->cb(cb_info->win,
659 EFL_UTIL_ERROR_PERMISSION_DENIED,
663 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)
667 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)
671 static void _cb_wl_tz_policy_allowed_aux_hint(void *data, struct tizen_policy *tizen_policy, struct wl_surface *surface_resource, int id)
676 _cb_wl_tz_display_policy_brightness_done(void *data,
677 struct tizen_display_policy *tizen_display_policy,
678 struct wl_surface *surface,
682 Efl_Util_Wl_Surface_Brightness_Info *brightness_info;
684 brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
687 brightness_info->brightness = brightness;
688 brightness_info->wait_for_done = EINA_FALSE;
689 brightness_info->state = state;
694 _cb_window_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
696 Efl_Util_Wl_Surface_Lv_Info *lv_info;
699 if (EINA_UNLIKELY(!lv_info))
702 eina_hash_del(_eflutil.wl.policy.hash_noti_lv, &lv_info->surface, lv_info);
704 #endif /* end of WAYLAND */
707 efl_util_set_notification_window_level(Evas_Object *window,
708 efl_util_notification_level_e level)
712 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
713 EINA_SAFETY_ON_FALSE_RETURN_VAL((level >= EFL_UTIL_NOTIFICATION_LEVEL_NONE) &&
714 (level <= EFL_UTIL_NOTIFICATION_LEVEL_TOP),
715 EFL_UTIL_ERROR_INVALID_PARAMETER);
718 Ecore_X_Window_Type window_type;
722 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
724 xwin = elm_win_xwindow_get(window);
727 if (ecore_x_netwm_window_type_get(xwin, &window_type) == EINA_TRUE)
729 // success to get window type
730 if (window_type != ECORE_X_WINDOW_TYPE_NOTIFICATION)
732 // given EFL window's type is not notification type.
733 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
737 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
739 utilx_set_system_notification_level(_eflutil.x11.dpy,
742 return EFL_UTIL_ERROR_NONE;
745 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
746 #endif /* end of X11 */
750 Ecore_Wl_Window *wlwin;
751 struct wl_surface *surface;
752 Efl_Util_Wl_Surface_Lv_Info *lv_info;
753 Ecore_Wl_Window_Type wl_type;
756 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
758 wlwin = elm_win_wl_window_get(window);
759 EINA_SAFETY_ON_NULL_RETURN_VAL(wlwin, EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
761 type = elm_win_type_get(window);
762 if (type != ELM_WIN_NOTIFICATION)
764 wl_type = ecore_wl_window_type_get(wlwin);
765 EINA_SAFETY_ON_FALSE_RETURN_VAL((wl_type == ECORE_WL_WINDOW_TYPE_NOTIFICATION),
766 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
769 while (!_eflutil.wl.policy.proto)
770 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
772 surface = ecore_wl_window_surface_get(wlwin);
773 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
774 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
776 lv_info = eina_hash_find(_eflutil.wl.policy.hash_noti_lv, &surface);
779 lv_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Lv_Info));
780 EINA_SAFETY_ON_NULL_RETURN_VAL(lv_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
782 lv_info->surface = surface;
783 lv_info->level = (int)level;
784 lv_info->wait_for_done = EINA_TRUE;
785 lv_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
786 eina_hash_add(_eflutil.wl.policy.hash_noti_lv,
790 evas_object_event_callback_add(window, EVAS_CALLBACK_DEL,
791 _cb_window_del, lv_info);
795 lv_info->level = (int)level;
796 lv_info->wait_for_done = EINA_TRUE;
797 lv_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
801 tizen_policy_set_notification_level(_eflutil.wl.policy.proto,
802 surface, (int)level);
804 if (lv_info->wait_for_done)
807 while (lv_info->wait_for_done && (count < 3))
810 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
814 if (lv_info->wait_for_done)
816 return EFL_UTIL_ERROR_INVALID_PARAMETER;
820 if (lv_info->state == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
822 return EFL_UTIL_ERROR_PERMISSION_DENIED;
827 return EFL_UTIL_ERROR_NONE;
828 #endif /* end of WAYLAND */
832 efl_util_get_notification_window_level(Evas_Object *window,
833 efl_util_notification_level_e *level)
837 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
838 EINA_SAFETY_ON_NULL_RETURN_VAL(level, EFL_UTIL_ERROR_INVALID_PARAMETER);
841 Ecore_X_Window_Type window_type;
842 Utilx_Notification_Level utilx_level;
846 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
848 xwin = elm_win_xwindow_get(window);
851 if (ecore_x_netwm_window_type_get(xwin, &window_type) == EINA_TRUE)
853 // success to get window type
854 if (window_type != ECORE_X_WINDOW_TYPE_NOTIFICATION)
856 // given EFL window's type is not notification type.
857 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
860 utilx_level = utilx_get_system_notification_level(_eflutil.x11.dpy, xwin);
861 if (utilx_level == UTILX_NOTIFICATION_LEVEL_LOW)
862 *level = EFL_UTIL_NOTIFICATION_LEVEL_1;
863 else if(utilx_level == UTILX_NOTIFICATION_LEVEL_NORMAL)
864 *level = EFL_UTIL_NOTIFICATION_LEVEL_2;
865 else if(utilx_level == UTILX_NOTIFICATION_LEVEL_HIGH)
866 *level = EFL_UTIL_NOTIFICATION_LEVEL_3;
868 return EFL_UTIL_ERROR_INVALID_PARAMETER;
871 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
873 return EFL_UTIL_ERROR_NONE;
876 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
877 #endif /* end of X11 */
881 Ecore_Wl_Window *wlwin;
882 struct wl_surface *surface;
883 Efl_Util_Wl_Surface_Lv_Info *lv_info;
884 Ecore_Wl_Window_Type wl_type;
887 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
889 wlwin = elm_win_wl_window_get(window);
890 EINA_SAFETY_ON_NULL_RETURN_VAL(wlwin, EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
892 type = elm_win_type_get(window);
893 if (type != ELM_WIN_NOTIFICATION)
895 wl_type = ecore_wl_window_type_get(wlwin);
896 EINA_SAFETY_ON_FALSE_RETURN_VAL((wl_type == ECORE_WL_WINDOW_TYPE_NOTIFICATION),
897 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
900 while (!_eflutil.wl.policy.proto)
901 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
903 surface = ecore_wl_window_surface_get(wlwin);
904 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
905 EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE);
907 lv_info = eina_hash_find(_eflutil.wl.policy.hash_noti_lv, &surface);
910 if (lv_info->wait_for_done)
913 while ((lv_info->wait_for_done) && (count < 3))
916 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
920 if (lv_info->wait_for_done)
922 *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
923 return EFL_UTIL_ERROR_INVALID_PARAMETER;
927 switch (lv_info->level)
929 case TIZEN_POLICY_LEVEL_1: *level = EFL_UTIL_NOTIFICATION_LEVEL_1; break;
930 case TIZEN_POLICY_LEVEL_2: *level = EFL_UTIL_NOTIFICATION_LEVEL_2; break;
931 case TIZEN_POLICY_LEVEL_3: *level = EFL_UTIL_NOTIFICATION_LEVEL_3; break;
932 case TIZEN_POLICY_LEVEL_NONE: *level = EFL_UTIL_NOTIFICATION_LEVEL_NONE; break;
933 case TIZEN_POLICY_LEVEL_DEFAULT: *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT; break;
934 case TIZEN_POLICY_LEVEL_MEDIUM: *level = EFL_UTIL_NOTIFICATION_LEVEL_MEDIUM; break;
935 case TIZEN_POLICY_LEVEL_HIGH: *level = EFL_UTIL_NOTIFICATION_LEVEL_HIGH; break;
936 case TIZEN_POLICY_LEVEL_TOP: *level = EFL_UTIL_NOTIFICATION_LEVEL_TOP; break;
937 default: *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
938 return EFL_UTIL_ERROR_INVALID_PARAMETER;
940 return EFL_UTIL_ERROR_NONE;
943 *level = EFL_UTIL_NOTIFICATION_LEVEL_DEFAULT;
945 return EFL_UTIL_ERROR_NONE;
946 #endif /* end of WAYLAND */
950 efl_util_set_notification_window_level_error_cb(Evas_Object *window,
951 efl_util_notification_window_level_error_cb callback,
954 Eina_Bool ret = EINA_FALSE;
956 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
957 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EFL_UTIL_ERROR_INVALID_PARAMETER);
959 ret = _cb_info_add(window,
960 (Efl_Util_Cb)callback,
963 if (!ret) return EFL_UTIL_ERROR_OUT_OF_MEMORY;
966 if (!_eflutil.cb_handler[CBH_NOTI_LEV].atom)
967 _eflutil.cb_handler[CBH_NOTI_LEV].atom = ecore_x_atom_get("_E_NOTIFICATION_LEVEL_ACCESS_RESULT");
968 #endif /* end of X11 */
970 return EFL_UTIL_ERROR_NONE;
974 efl_util_unset_notification_window_level_error_cb(Evas_Object *window)
976 Eina_Bool ret = EINA_FALSE;
978 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
980 ret = _cb_info_del_by_win(window, CBH_NOTI_LEV);
981 if (!ret) return EFL_UTIL_ERROR_INVALID_PARAMETER;
983 return EFL_UTIL_ERROR_NONE;
987 efl_util_set_window_opaque_state(Evas_Object *window,
992 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
993 EINA_SAFETY_ON_FALSE_RETURN_VAL(((opaque >= 0) && (opaque <= 1)),
994 EFL_UTIL_ERROR_INVALID_PARAMETER);
998 Utilx_Opaque_State state;
1002 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1004 xwin = elm_win_xwindow_get(window);
1005 EINA_SAFETY_ON_FALSE_RETURN_VAL(xwin > 0, EFL_UTIL_ERROR_INVALID_PARAMETER);
1008 state = UTILX_OPAQUE_STATE_ON;
1010 state = UTILX_OPAQUE_STATE_OFF;
1012 ret = utilx_set_window_opaque_state(_eflutil.x11.dpy,
1017 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1019 return EFL_UTIL_ERROR_NONE;
1020 #endif /* end of X11 */
1023 Ecore_Wl_Window *wlwin;
1024 struct wl_surface *surface;
1026 if (!_eflutil.wl.policy.proto)
1031 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1033 while (!_eflutil.wl.policy.proto && ret != -1)
1034 ret = wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1036 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.policy.proto, EFL_UTIL_ERROR_INVALID_PARAMETER);
1039 wlwin = elm_win_wl_window_get(window);
1041 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
1043 surface = ecore_wl_window_surface_get(wlwin);
1045 return EFL_UTIL_ERROR_NOT_SUPPORTED_WINDOW_TYPE;
1047 tizen_policy_set_opaque_state(_eflutil.wl.policy.proto, surface, opaque);
1049 return EFL_UTIL_ERROR_NONE;
1050 #endif /* end of WAYLAND */
1054 efl_util_set_window_screen_mode(Evas_Object *window,
1055 efl_util_screen_mode_e mode)
1057 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1058 EINA_SAFETY_ON_FALSE_RETURN_VAL(((mode >= EFL_UTIL_SCREEN_MODE_DEFAULT) &&
1059 (mode <= EFL_UTIL_SCREEN_MODE_ALWAYS_ON)),
1060 EFL_UTIL_ERROR_INVALID_PARAMETER);
1067 e = evas_object_evas_get(window);
1068 EINA_SAFETY_ON_NULL_RETURN_VAL(e, EFL_UTIL_ERROR_INVALID_PARAMETER);
1070 ee = ecore_evas_ecore_evas_get(e);
1071 EINA_SAFETY_ON_NULL_RETURN_VAL(ee, EFL_UTIL_ERROR_INVALID_PARAMETER);
1073 id = ecore_evas_aux_hint_id_get(ee, "wm.policy.win.lcd.lock");
1074 if (mode == EFL_UTIL_SCREEN_MODE_ALWAYS_ON)
1077 ecore_evas_aux_hint_add(ee, "wm.policy.win.lcd.lock", "1");
1079 ecore_evas_aux_hint_val_set(ee, id, "1");
1081 else if (mode == EFL_UTIL_SCREEN_MODE_DEFAULT)
1084 ecore_evas_aux_hint_add(ee, "wm.policy.win.lcd.lock", "0");
1086 ecore_evas_aux_hint_val_set(ee, id, "0");
1089 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1091 return EFL_UTIL_ERROR_NONE;
1092 #endif /* end of X11 */
1095 Ecore_Wl_Window *wlwin;
1096 struct wl_surface *surface;
1097 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
1101 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1103 wlwin = elm_win_wl_window_get(window);
1106 while (!_eflutil.wl.policy.proto)
1107 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1109 surface = ecore_wl_window_surface_get(wlwin);
1110 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1111 EFL_UTIL_ERROR_INVALID_PARAMETER);
1113 scr_mode_info = eina_hash_find(_eflutil.wl.policy.hash_scr_mode, &surface);
1116 scr_mode_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Scr_Mode_Info));
1117 EINA_SAFETY_ON_NULL_RETURN_VAL(scr_mode_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
1119 scr_mode_info->surface = surface;
1120 scr_mode_info->mode = (unsigned int)mode;
1121 scr_mode_info->wait_for_done = EINA_TRUE;
1122 scr_mode_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
1124 eina_hash_add(_eflutil.wl.policy.hash_scr_mode,
1130 scr_mode_info->mode = (unsigned int)mode;
1131 scr_mode_info->wait_for_done = EINA_TRUE;
1132 scr_mode_info->state = TIZEN_POLICY_ERROR_STATE_NONE;
1135 tizen_policy_set_window_screen_mode(_eflutil.wl.policy.proto,
1136 surface, (unsigned int)mode);
1137 if (scr_mode_info->wait_for_done)
1140 while (scr_mode_info->wait_for_done && (count < 3))
1143 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1147 if (scr_mode_info->wait_for_done)
1149 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1153 if (scr_mode_info->state == TIZEN_POLICY_ERROR_STATE_PERMISSION_DENIED)
1155 return EFL_UTIL_ERROR_PERMISSION_DENIED;
1160 return EFL_UTIL_ERROR_NONE;
1163 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1164 #endif /* end of WAYLAND */
1168 efl_util_get_window_screen_mode(Evas_Object *window,
1169 efl_util_screen_mode_e *mode)
1171 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1172 EINA_SAFETY_ON_NULL_RETURN_VAL(mode, EFL_UTIL_ERROR_INVALID_PARAMETER);
1180 e = evas_object_evas_get(window);
1181 EINA_SAFETY_ON_NULL_RETURN_VAL(e, EFL_UTIL_ERROR_INVALID_PARAMETER);
1183 ee = ecore_evas_ecore_evas_get(e);
1184 EINA_SAFETY_ON_NULL_RETURN_VAL(ee, EFL_UTIL_ERROR_INVALID_PARAMETER);
1186 id = ecore_evas_aux_hint_id_get(ee, "wm.policy.win.lcd.lock");
1187 EINA_SAFETY_ON_TRUE_RETURN_VAL((id == -1), EFL_UTIL_ERROR_INVALID_PARAMETER);
1189 str = ecore_evas_aux_hint_val_get(ee, id);
1190 EINA_SAFETY_ON_NULL_RETURN_VAL(str, EFL_UTIL_ERROR_INVALID_PARAMETER);
1192 if (strncmp(str, "1", strlen("1")) == 0)
1193 *mode = EFL_UTIL_SCREEN_MODE_ALWAYS_ON;
1195 *mode = EFL_UTIL_SCREEN_MODE_DEFAULT;
1197 return EFL_UTIL_ERROR_NONE;
1198 #endif /* end of X11 */
1201 Ecore_Wl_Window *wlwin;
1202 struct wl_surface *surface;
1203 Efl_Util_Wl_Surface_Scr_Mode_Info *scr_mode_info;
1207 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1209 wlwin = elm_win_wl_window_get(window);
1212 while (!_eflutil.wl.policy.proto)
1213 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1215 surface = ecore_wl_window_surface_get(wlwin);
1216 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1217 EFL_UTIL_ERROR_INVALID_PARAMETER);
1219 scr_mode_info = eina_hash_find(_eflutil.wl.policy.hash_scr_mode, &surface);
1222 if (scr_mode_info->wait_for_done)
1224 while (scr_mode_info->wait_for_done)
1227 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1231 switch (scr_mode_info->mode)
1233 case TIZEN_POLICY_MODE_DEFAULT: *mode = EFL_UTIL_SCREEN_MODE_DEFAULT; break;
1234 case TIZEN_POLICY_MODE_ALWAYS_ON: *mode = EFL_UTIL_SCREEN_MODE_ALWAYS_ON; break;
1235 default: *mode = EFL_UTIL_SCREEN_MODE_DEFAULT;
1236 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1238 return EFL_UTIL_ERROR_NONE;
1242 *mode = EFL_UTIL_SCREEN_MODE_DEFAULT;
1243 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1247 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1248 #endif /* end of WAYLAND */
1252 efl_util_set_window_screen_mode_error_cb(Evas_Object *window,
1253 efl_util_window_screen_mode_error_cb callback,
1256 Eina_Bool ret = EINA_FALSE;
1258 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1259 EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EFL_UTIL_ERROR_INVALID_PARAMETER);
1261 ret = _cb_info_add(window,
1262 (Efl_Util_Cb)callback,
1265 if (!ret) return EFL_UTIL_ERROR_OUT_OF_MEMORY;
1268 if (!_eflutil.cb_handler[CBH_SCR_MODE].atom)
1269 _eflutil.cb_handler[CBH_SCR_MODE].atom = ecore_x_atom_get("_E_SCREEN_MODE_ACCESS_RESULT");
1270 #endif /* end of X11 */
1272 return EFL_UTIL_ERROR_NONE;
1276 efl_util_unset_window_screen_mode_error_cb(Evas_Object *window)
1278 Eina_Bool ret = EINA_FALSE;
1280 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1282 ret = _cb_info_del_by_win(window, CBH_SCR_MODE);
1283 if (!ret) return EFL_UTIL_ERROR_INVALID_PARAMETER;
1285 return EFL_UTIL_ERROR_NONE;
1289 efl_util_set_window_brightness(Evas_Object *window, int brightness)
1291 Ecore_Wl_Window *wlwin;
1292 struct wl_surface *surface;
1293 Efl_Util_Wl_Surface_Brightness_Info *brightness_info;
1296 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1297 EINA_SAFETY_ON_FALSE_RETURN_VAL(brightness <= 100, EFL_UTIL_ERROR_INVALID_PARAMETER);
1300 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1302 wlwin = elm_win_wl_window_get(window);
1305 while (!_eflutil.wl.display_policy.proto)
1306 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1308 surface = ecore_wl_window_surface_get(wlwin);
1309 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1310 EFL_UTIL_ERROR_INVALID_PARAMETER);
1312 brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
1313 if (!brightness_info)
1315 brightness_info = calloc(1, sizeof(Efl_Util_Wl_Surface_Brightness_Info));
1316 EINA_SAFETY_ON_NULL_RETURN_VAL(brightness_info, EFL_UTIL_ERROR_OUT_OF_MEMORY);
1318 brightness_info->surface = surface;
1319 brightness_info->brightness = brightness;
1320 brightness_info->wait_for_done = EINA_TRUE;
1321 brightness_info->state = TIZEN_DISPLAY_POLICY_ERROR_STATE_NONE;
1323 eina_hash_add(_eflutil.wl.display_policy.hash_brightness,
1329 brightness_info->brightness = brightness;
1330 brightness_info->wait_for_done = EINA_TRUE;
1331 brightness_info->state = TIZEN_DISPLAY_POLICY_ERROR_STATE_NONE;
1334 tizen_display_policy_set_window_brightness(_eflutil.wl.display_policy.proto,
1335 surface, brightness);
1336 if (brightness_info->wait_for_done)
1339 while (brightness_info->wait_for_done && (count < 3))
1342 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1346 if (brightness_info->wait_for_done)
1348 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1352 if (brightness_info->state == TIZEN_DISPLAY_POLICY_ERROR_STATE_PERMISSION_DENIED)
1354 return EFL_UTIL_ERROR_PERMISSION_DENIED;
1358 return EFL_UTIL_ERROR_NONE;
1361 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1365 efl_util_get_window_brightness(Evas_Object *window, int *brightness)
1367 Ecore_Wl_Window *wlwin;
1368 struct wl_surface *surface;
1369 Efl_Util_Wl_Surface_Brightness_Info *brightness_info;
1372 EINA_SAFETY_ON_NULL_RETURN_VAL(window, EFL_UTIL_ERROR_INVALID_PARAMETER);
1373 EINA_SAFETY_ON_NULL_RETURN_VAL(brightness, EFL_UTIL_ERROR_INVALID_PARAMETER);
1376 EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EFL_UTIL_ERROR_INVALID_PARAMETER);
1378 wlwin = elm_win_wl_window_get(window);
1379 if (!wlwin) return EFL_UTIL_ERROR_INVALID_PARAMETER;
1381 while (!_eflutil.wl.display_policy.proto)
1382 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1384 surface = ecore_wl_window_surface_get(wlwin);
1385 EINA_SAFETY_ON_NULL_RETURN_VAL(surface,
1386 EFL_UTIL_ERROR_INVALID_PARAMETER);
1388 brightness_info = eina_hash_find(_eflutil.wl.display_policy.hash_brightness, &surface);
1389 if (brightness_info)
1391 if (brightness_info->wait_for_done)
1393 while (brightness_info->wait_for_done)
1396 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1399 *brightness = brightness_info->brightness;
1404 return EFL_UTIL_ERROR_NONE;
1408 struct _efl_util_inputgen_h
1410 unsigned int init_type;
1415 _cb_device_add(void *data EINA_UNUSED,
1416 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1417 uint32_t serial EINA_UNUSED,
1418 const char *identifier EINA_UNUSED,
1419 struct tizen_input_device *device EINA_UNUSED,
1420 struct wl_seat *seat EINA_UNUSED)
1426 _cb_device_remove(void *data EINA_UNUSED,
1427 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1428 uint32_t serial EINA_UNUSED,
1429 const char *identifier EINA_UNUSED,
1430 struct tizen_input_device *device EINA_UNUSED,
1431 struct wl_seat *seat EINA_UNUSED)
1437 _cb_error(void *data EINA_UNUSED,
1438 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED,
1441 _eflutil.wl.devmgr.request_notified = errorcode;
1445 _cb_block_expired(void *data EINA_UNUSED,
1446 struct tizen_input_device_manager *tizen_input_device_manager EINA_UNUSED)
1450 #endif /* end of WAYLAND */
1452 static efl_util_error_e
1453 _efl_util_input_convert_input_generator_error(int ret)
1457 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE:
1458 return EFL_UTIL_ERROR_NONE;
1459 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NO_PERMISSION:
1460 return EFL_UTIL_ERROR_PERMISSION_DENIED;
1461 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_NO_SYSTEM_RESOURCES:
1462 return EFL_UTIL_ERROR_OUT_OF_MEMORY;
1463 case TIZEN_INPUT_DEVICE_MANAGER_ERROR_INVALID_PARAMETER:
1464 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1466 return EFL_UTIL_ERROR_NONE;
1470 API efl_util_inputgen_h
1471 efl_util_input_initialize_generator(efl_util_input_device_type_e dev_type)
1473 int ret = EFL_UTIL_ERROR_NONE;
1474 efl_util_inputgen_h inputgen_h = NULL;
1476 if ((dev_type <= EFL_UTIL_INPUT_DEVTYPE_NONE) ||
1477 (dev_type >= EFL_UTIL_INPUT_DEVTYPE_MAX))
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;
1493 if (ret == (int)EINA_FALSE)
1495 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1499 while (!_eflutil.wl.devmgr.devicemgr)
1500 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1502 tizen_input_device_manager_init_generator(_eflutil.wl.devmgr.devicemgr);
1504 while (_eflutil.wl.devmgr.request_notified == -1)
1505 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1507 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1508 _eflutil.wl.devmgr.request_notified = -1;
1510 set_last_result(ret);
1511 if (ret != TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE)
1527 efl_util_input_deinitialize_generator(efl_util_inputgen_h inputgen_h)
1529 int ret = EFL_UTIL_ERROR_NONE;
1530 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1536 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1538 tizen_input_device_manager_deinit_generator(_eflutil.wl.devmgr.devicemgr);
1540 while (_eflutil.wl.devmgr.request_notified == -1)
1541 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1543 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1544 _eflutil.wl.devmgr.request_notified = -1;
1551 efl_util_input_generate_key(efl_util_inputgen_h inputgen_h, const char *key_name, int pressed)
1553 int ret = EFL_UTIL_ERROR_NONE;
1555 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1556 EINA_SAFETY_ON_NULL_RETURN_VAL(key_name, EFL_UTIL_ERROR_INVALID_PARAMETER);
1557 EINA_SAFETY_ON_FALSE_RETURN_VAL(pressed == 0 || pressed == 1, EFL_UTIL_ERROR_INVALID_PARAMETER);
1558 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_KEYBOARD, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1561 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1563 tizen_input_device_manager_generate_key(_eflutil.wl.devmgr.devicemgr, key_name, pressed);
1565 while (_eflutil.wl.devmgr.request_notified == -1)
1566 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1568 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1569 _eflutil.wl.devmgr.request_notified = -1;
1576 efl_util_input_generate_touch(efl_util_inputgen_h inputgen_h, int idx,
1577 efl_util_input_touch_type_e touch_type, int x, int y)
1581 enum tizen_input_device_manager_pointer_event_type type;
1584 EINA_SAFETY_ON_NULL_RETURN_VAL(inputgen_h, EFL_UTIL_ERROR_INVALID_PARAMETER);
1585 EINA_SAFETY_ON_FALSE_RETURN_VAL(idx >= 0, EFL_UTIL_ERROR_INVALID_PARAMETER);
1586 EINA_SAFETY_ON_FALSE_RETURN_VAL((x > 0 && y > 0), EFL_UTIL_ERROR_INVALID_PARAMETER);
1587 EINA_SAFETY_ON_FALSE_RETURN_VAL(inputgen_h->init_type & EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN, EFL_UTIL_ERROR_NO_SUCH_DEVICE);
1590 EINA_SAFETY_ON_NULL_RETURN_VAL(_eflutil.wl.devmgr.devicemgr, EFL_UTIL_ERROR_INVALID_PARAMETER);
1594 case EFL_UTIL_INPUT_TOUCH_BEGIN:
1595 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_BEGIN;
1597 case EFL_UTIL_INPUT_TOUCH_UPDATE:
1598 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_UPDATE;
1600 case EFL_UTIL_INPUT_TOUCH_END:
1601 type = TIZEN_INPUT_DEVICE_MANAGER_POINTER_EVENT_TYPE_END;
1604 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1607 tizen_input_device_manager_generate_touch(_eflutil.wl.devmgr.devicemgr, type, x, y, idx);
1609 while (_eflutil.wl.devmgr.request_notified == -1)
1610 wl_display_dispatch_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1612 ret = _efl_util_input_convert_input_generator_error(_eflutil.wl.devmgr.request_notified);
1613 _eflutil.wl.devmgr.request_notified = -1;
1619 struct _efl_util_screenshot_h
1625 Ecore_X_Display *dpy;
1626 int internal_display;
1641 int eventBase, errorBase;
1642 int dri2Major, dri2Minor;
1643 char *driver_name, *device_name;
1650 Eina_Bool shot_done;
1656 /* scrrenshot handle */
1657 static efl_util_screenshot_h g_screenshot;
1660 #define FOURCC(a,b,c,d) (((unsigned)d&0xff)<<24 | ((unsigned)c&0xff)<<16 | ((unsigned)b&0xff)<<8 | ((unsigned)a&0xff))
1661 #define FOURCC_RGB32 FOURCC('R','G','B','4')
1662 #define TIMEOUT_CAPTURE 3
1664 /* x error handling */
1665 static Bool g_efl_util_x_error_caught;
1668 _efl_util_screenshot_x_error_handle(Display *dpy, XErrorEvent *ev)
1670 if (!g_screenshot || (dpy != g_screenshot->dpy))
1673 g_efl_util_x_error_caught = True;
1679 _efl_util_screenshot_get_port(Display *dpy, unsigned int id, Window win)
1681 unsigned int ver, rev, req_base, evt_base, err_base;
1682 unsigned int adaptors;
1683 XvAdaptorInfo *ai = NULL;
1684 XvImageFormatValues *fo = NULL;
1688 if (XvQueryExtension(dpy, &ver, &rev, &req_base, &evt_base, &err_base) != Success)
1690 fprintf(stderr, "[screenshot] fail: no XV extension. \n");
1694 if (XvQueryAdaptors(dpy, win, &adaptors, &ai) != Success)
1696 fprintf(stderr, "[screenshot] fail: query adaptors. \n");
1700 EINA_SAFETY_ON_NULL_RETURN_VAL(ai, -1);
1702 for (i = 0; i < adaptors; i++)
1704 int support_format = False;
1706 if (!(ai[i].type & XvInputMask) ||
1707 !(ai[i].type & XvStillMask))
1712 fo = XvListImageFormats(dpy, p, &formats);
1713 for (j = 0; j < formats; j++)
1714 if (fo[j].id == (int)id)
1715 support_format = True;
1720 if (!support_format)
1723 for (; p < ai[i].base_id + ai[i].num_ports; p++)
1725 if (XvGrabPort(dpy, p, 0) == Success)
1727 XvFreeAdaptorInfo(ai);
1733 XvFreeAdaptorInfo(ai);
1741 _efl_util_screenshot_get_best_size(Display *dpy, int port, int width, int height, unsigned int *best_width, unsigned int *best_height)
1743 XErrorHandler old_handler = NULL;
1745 Atom atom_capture = XInternAtom(dpy, "_USER_WM_PORT_ATTRIBUTE_CAPTURE", False);
1747 g_efl_util_x_error_caught = False;
1748 old_handler = XSetErrorHandler(_efl_util_screenshot_x_error_handle);
1750 XvSetPortAttribute(dpy, port, atom_capture, 1);
1753 g_efl_util_x_error_caught = False;
1754 XSetErrorHandler(old_handler);
1756 XvQueryBestSize(dpy, port, 0, 0, 0, width, height, best_width, best_height);
1757 if (best_width <= 0 || best_height <= 0)
1764 API efl_util_screenshot_h
1765 efl_util_screenshot_initialize(int width, int height)
1768 efl_util_screenshot_h screenshot = NULL;
1770 int damage_err_base = 0;
1771 unsigned int best_width = 0;
1772 unsigned int best_height = 0;
1774 EINA_SAFETY_ON_FALSE_GOTO(width > 0, fail_param);
1775 EINA_SAFETY_ON_FALSE_GOTO(height > 0, fail_param);
1777 if (g_screenshot != NULL)
1779 if (g_screenshot->width != width || g_screenshot->height != height)
1781 // TODO: recreate pixmap and update information
1782 if (!_efl_util_screenshot_get_best_size(screenshot->dpy, screenshot->port, width, height, &best_width, &best_height))
1784 set_last_result(EFL_UTIL_ERROR_SCREENSHOT_INIT_FAIL);
1788 g_screenshot->width = width;
1789 g_screenshot->height = height;
1792 return g_screenshot;
1795 screenshot = calloc(1, sizeof(struct _efl_util_screenshot_h));
1796 EINA_SAFETY_ON_NULL_GOTO(screenshot, fail_memory);
1799 screenshot->dpy = ecore_x_display_get();
1800 if (!screenshot->dpy)
1802 screenshot->dpy = XOpenDisplay(0);
1803 EINA_SAFETY_ON_NULL_GOTO(screenshot, fail_init);
1805 /* for XCloseDisplay at denitialization */
1806 screenshot->internal_display = 1;
1810 screenshot->screen = DefaultScreen(screenshot->dpy);
1812 /* set root window */
1813 screenshot->root = DefaultRootWindow(screenshot->dpy);
1815 /* initialize capture adaptor */
1816 screenshot->port = _efl_util_screenshot_get_port(screenshot->dpy, FOURCC_RGB32, screenshot->root);
1817 EINA_SAFETY_ON_FALSE_GOTO(screenshot->port > 0, fail_init);
1819 /* get the best size */
1820 _efl_util_screenshot_get_best_size(screenshot->dpy, screenshot->port, width, height, &best_width, &best_height);
1821 EINA_SAFETY_ON_FALSE_GOTO(best_width > 0, fail_init);
1822 EINA_SAFETY_ON_FALSE_GOTO(best_height > 0, fail_init);
1824 /* set the width and the height */
1825 screenshot->width = best_width;
1826 screenshot->height = best_height;
1828 /* create a pixmap */
1829 depth = DefaultDepth(screenshot->dpy, screenshot->screen);
1830 screenshot->pixmap = XCreatePixmap(screenshot->dpy, screenshot->root, screenshot->width, screenshot->height, depth);
1831 EINA_SAFETY_ON_FALSE_GOTO(screenshot->pixmap > 0, fail_init);
1833 screenshot->gc = XCreateGC(screenshot->dpy, screenshot->pixmap, 0, 0);
1834 EINA_SAFETY_ON_NULL_GOTO(screenshot->gc, fail_init);
1836 XSetForeground(screenshot->dpy, screenshot->gc, 0xFF000000);
1837 XFillRectangle(screenshot->dpy, screenshot->pixmap, screenshot->gc, 0, 0, width, height);
1839 /* initialize damage */
1840 if (!XDamageQueryExtension(screenshot->dpy, &screenshot->damage_base, &damage_err_base))
1843 screenshot->damage = XDamageCreate(screenshot->dpy, screenshot->pixmap, XDamageReportNonEmpty);
1844 EINA_SAFETY_ON_FALSE_GOTO(screenshot->damage > 0, fail_init);
1846 /* initialize dri3 and dri2 */
1847 if (!DRI2QueryExtension(screenshot->dpy, &screenshot->eventBase, &screenshot->errorBase))
1849 fprintf(stderr, "[screenshot] fail: DRI2QueryExtention\n");
1853 if (!DRI2QueryVersion(screenshot->dpy, &screenshot->dri2Major, &screenshot->dri2Minor))
1855 fprintf(stderr, "[screenshot] fail: DRI2QueryVersion\n");
1859 if (!DRI2Connect(screenshot->dpy, screenshot->root, &screenshot->driver_name, &screenshot->device_name))
1861 fprintf(stderr, "[screenshot] fail: DRI2Connect\n");
1865 screenshot->drm_fd = open(screenshot->device_name, O_RDWR);
1866 EINA_SAFETY_ON_FALSE_GOTO(screenshot->drm_fd >= 0, fail_init);
1868 if (drmGetMagic(screenshot->drm_fd, &screenshot->magic))
1870 fprintf(stderr, "[screenshot] fail: drmGetMagic\n");
1874 if (!DRI2Authenticate(screenshot->dpy, screenshot->root, screenshot->magic))
1876 fprintf(stderr, "[screenshot] fail: DRI2Authenticate\n");
1880 if (!drmAuthMagic(screenshot->drm_fd, screenshot->magic))
1882 fprintf(stderr, "[screenshot] fail: drmAuthMagic\n");
1886 DRI2CreateDrawable(screenshot->dpy, screenshot->pixmap);
1889 screenshot->bufmgr = tbm_bufmgr_init(screenshot->drm_fd);
1890 EINA_SAFETY_ON_NULL_GOTO(screenshot->bufmgr, fail_init);
1892 XFlush(screenshot->dpy);
1894 g_screenshot = screenshot;
1895 set_last_result(EFL_UTIL_ERROR_NONE);
1897 return g_screenshot;
1901 efl_util_screenshot_h screenshot = NULL;
1903 if (!_eflutil.wl.shot.screenshooter)
1907 while (!_eflutil.wl.shot.screenshooter && ret != -1)
1908 ret = wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
1909 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.screenshooter, fail_init);
1911 _eflutil.wl.shot.tbm_client = wayland_tbm_client_init(_eflutil.wl.dpy);
1912 EINA_SAFETY_ON_NULL_GOTO(_eflutil.wl.shot.tbm_client, fail_init);
1915 EINA_SAFETY_ON_FALSE_GOTO(width > 0, fail_param);
1916 EINA_SAFETY_ON_FALSE_GOTO(height > 0, fail_param);
1920 if (g_screenshot->width != width || g_screenshot->height != height)
1922 g_screenshot->width = width;
1923 g_screenshot->height = height;
1926 return g_screenshot;
1929 screenshot = calloc(1, sizeof(struct _efl_util_screenshot_h));
1930 EINA_SAFETY_ON_NULL_GOTO(screenshot, fail_memory);
1932 screenshot->width = width;
1933 screenshot->height = height;
1935 screenshot->bufmgr = wayland_tbm_client_get_bufmgr(_eflutil.wl.shot.tbm_client);
1936 EINA_SAFETY_ON_NULL_GOTO(screenshot->bufmgr, fail_init);
1938 g_screenshot = screenshot;
1939 set_last_result(EFL_UTIL_ERROR_NONE);
1941 screenshooter_set_user_data(_eflutil.wl.shot.screenshooter, &screenshot->shot_done);
1943 return g_screenshot;
1947 efl_util_screenshot_deinitialize(screenshot);
1948 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
1952 efl_util_screenshot_deinitialize(screenshot);
1953 set_last_result(EFL_UTIL_ERROR_OUT_OF_MEMORY);
1957 efl_util_screenshot_deinitialize(screenshot);
1958 set_last_result(EFL_UTIL_ERROR_SCREENSHOT_INIT_FAIL);
1963 efl_util_screenshot_deinitialize(efl_util_screenshot_h screenshot)
1967 return EFL_UTIL_ERROR_INVALID_PARAMETER;
1970 if (screenshot->bufmgr)
1971 tbm_bufmgr_deinit(screenshot->bufmgr);
1973 DRI2DestroyDrawable(screenshot->dpy, screenshot->pixmap);
1976 if (screenshot->drm_fd)
1977 close(screenshot->drm_fd);
1978 if (screenshot->driver_name)
1979 free(screenshot->driver_name);
1980 if (screenshot->device_name)
1981 free(screenshot->device_name);
1984 if (screenshot->port > 0 && screenshot->pixmap > 0)
1985 XvStopVideo(screenshot->dpy, screenshot->port, screenshot->pixmap);
1988 if (screenshot->damage)
1989 XDamageDestroy(screenshot->dpy, screenshot->damage);
1993 XFreeGC(screenshot->dpy, screenshot->gc);
1996 if (screenshot->pixmap > 0)
1997 XFreePixmap(screenshot->dpy, screenshot->pixmap);
2000 if (screenshot->port > 0)
2001 XvUngrabPort(screenshot->dpy, screenshot->port, 0);
2003 XSync(screenshot->dpy, False);
2006 if (screenshot->internal_display ==1 && screenshot->dpy)
2007 XCloseDisplay(screenshot->dpy);
2010 g_screenshot = NULL;
2012 return EFL_UTIL_ERROR_NONE;
2016 return EFL_UTIL_ERROR_INVALID_PARAMETER;
2019 g_screenshot = NULL;
2021 if (_eflutil.wl.shot.screenshooter)
2022 screenshooter_set_user_data(_eflutil.wl.shot.screenshooter, NULL);
2024 return EFL_UTIL_ERROR_NONE;
2030 efl_util_screenshot_take_tbm_surface(efl_util_screenshot_h screenshot)
2034 XErrorHandler old_handler = NULL;
2035 unsigned int attachment = DRI2BufferFrontLeft;
2037 DRI2Buffer *bufs = NULL;
2039 tbm_surface_h t_surface = NULL;
2042 tbm_surface_info_s surf_info;
2045 if (screenshot != g_screenshot)
2047 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2051 /* for flush other pending requests and pending events */
2052 XSync(screenshot->dpy, 0);
2054 g_efl_util_x_error_caught = False;
2055 old_handler = XSetErrorHandler(_efl_util_screenshot_x_error_handle);
2058 XvPutStill(screenshot->dpy, screenshot->port, screenshot->pixmap, screenshot->gc,
2059 0, 0, screenshot->width, screenshot->height,
2060 0, 0, screenshot->width, screenshot->height);
2062 XSync(screenshot->dpy, 0);
2064 if (g_efl_util_x_error_caught)
2066 g_efl_util_x_error_caught = False;
2067 XSetErrorHandler(old_handler);
2071 g_efl_util_x_error_caught = False;
2072 XSetErrorHandler(old_handler);
2074 if (XPending(screenshot->dpy))
2075 XNextEvent(screenshot->dpy, &ev);
2078 int fd = ConnectionNumber(screenshot->dpy);
2087 tv.tv_sec = TIMEOUT_CAPTURE;
2089 ret = select(fd + 1, &mask, 0, 0, &tv);
2091 fprintf(stderr, "[screenshot] fail: select.\n");
2093 fprintf(stderr, "[screenshot] fail: timeout(%d sec)!\n", TIMEOUT_CAPTURE);
2094 else if (XPending(screenshot->dpy))
2095 XNextEvent(screenshot->dpy, &ev);
2097 fprintf(stderr, "[screenshot] fail: not passed a event!\n");
2100 /* check if the capture is done by xserver and pixmap has got the captured image */
2101 if (ev.type == (screenshot->damage_base + XDamageNotify))
2103 XDamageNotifyEvent *damage_ev = (XDamageNotifyEvent *)&ev;
2104 if (damage_ev->drawable == screenshot->pixmap)
2106 /* Get DRI2 FrontLeft buffer of the pixmap */
2107 bufs = DRI2GetBuffers(screenshot->dpy, screenshot->pixmap, &buf_width, &buf_height, &attachment, 1, &nbufs);
2110 fprintf(stderr, "[screenshot] fail: DRI2GetBuffers\n");
2114 t_bo = tbm_bo_import(screenshot->bufmgr, bufs[0].name);
2117 fprintf(stderr, "[screenshot] fail: import tbm_bo!\n");
2121 surf_info.width = buf_width;
2122 surf_info.height = buf_height;
2123 surf_info.format = TBM_FORMAT_XRGB8888;
2125 surf_info.size = bufs->pitch * surf_info.height;
2126 surf_info.num_planes = 1;
2127 for (i = 0; i < surf_info.num_planes; i++)
2129 surf_info.planes[i].size = bufs->pitch * surf_info.height;
2130 surf_info.planes[i].stride = bufs->pitch;
2131 surf_info.planes[i].offset = 0;
2133 t_surface = tbm_surface_internal_create_with_bos(&surf_info, &t_bo, 1);
2136 fprintf(stderr, "[screenshot] fail: get tbm_surface!\n");
2143 XDamageSubtract(screenshot->dpy, screenshot->damage, None, None );
2145 set_last_result(EFL_UTIL_ERROR_NONE);
2150 XDamageSubtract(screenshot->dpy, screenshot->damage, None, None );
2160 set_last_result(EFL_UTIL_ERROR_SCREENSHOT_EXECUTION_FAIL);
2166 tbm_surface_h t_surface = NULL;
2167 struct wl_buffer *buffer = NULL;
2168 Efl_Util_Wl_Output_Info *output;
2171 if (screenshot != g_screenshot)
2173 set_last_result(EFL_UTIL_ERROR_INVALID_PARAMETER);
2177 output = eina_list_nth(_eflutil.wl.shot.output_list, 0);
2180 fprintf(stderr, "[screenshot] fail: no output for screenshot\n");
2184 t_surface = tbm_surface_create(screenshot->width, screenshot->height, TBM_FORMAT_XRGB8888);
2187 fprintf(stderr, "[screenshot] fail: tbm_surface_create\n");
2191 buffer = wayland_tbm_client_create_buffer(_eflutil.wl.shot.tbm_client, t_surface);
2194 fprintf(stderr, "[screenshot] fail: create wl_buffer for screenshot\n");
2198 screenshooter_shoot(_eflutil.wl.shot.screenshooter, output->output, buffer);
2200 screenshot->shot_done = EINA_FALSE;
2201 while (!screenshot->shot_done && ret != -1)
2202 ret = wl_display_roundtrip_queue(_eflutil.wl.dpy, _eflutil.wl.queue);
2206 fprintf(stderr, "[screenshot] fail: screenshooter_shoot\n");
2210 wl_buffer_destroy(buffer);
2212 /* reset shot_done for next screenshot */
2213 screenshot->shot_done = EINA_FALSE;
2219 tbm_surface_destroy(t_surface);
2221 wl_buffer_destroy(buffer);
2223 set_last_result(EFL_UTIL_ERROR_SCREENSHOT_EXECUTION_FAIL);