2 * Copyright (c) 2016 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.
18 #include <sys/types.h>
19 #include <sys/socket.h>
27 #include <linux/limits.h>
29 #include <Ecore_Wl2.h>
30 #include <wayland-client.h>
31 #include <wayland-tbm-client.h>
32 #include <tizen-extension-client-protocol.h>
35 #include <glib-object.h>
42 #include <bundle_internal.h>
45 #include "appcore_base.h"
46 #include "appcore_ui_base.h"
47 #include "appcore_ui_base_private.h"
48 #include "appcore_ui_plugin.h"
64 enum visibility_type {
70 typedef struct _appcore_ui_base_context {
71 appcore_ui_base_ops ops;
79 bool resource_reclaiming;
82 Ecore_Event_Handler *hshow;
83 Ecore_Event_Handler *hhide;
84 Ecore_Event_Handler *hvchange;
85 Ecore_Event_Handler *hlower;
86 Ecore_Event_Handler *hpvchange;
87 Ecore_Event_Handler *hauxmsg;
88 } appcore_ui_base_context;
91 static int w_status = WS_NONE;
92 static bool first_launch = true;
100 static GSList *g_winnode_list;
101 static appcore_ui_base_context __context;
102 static struct wl_display *dsp;
103 static struct wl_registry *reg;
104 static struct tizen_policy *tz_policy;
106 static void _wl_cb_conformant(void *data,
107 struct tizen_policy *tizen_policy,
108 struct wl_surface *surface_resource,
109 uint32_t is_conformant)
114 static void _wl_cb_conformant_area(void *data,
115 struct tizen_policy *tizen_policy,
116 struct wl_surface *surface_resource,
117 uint32_t conformant_part,
119 int32_t x, int32_t y, int32_t w, int32_t h)
124 static void _wl_cb_notification_done(void *data,
125 struct tizen_policy *tizen_policy,
126 struct wl_surface *surface,
133 static void _wl_cb_transient_for_done(void *data,
134 struct tizen_policy *tizen_policy,
140 static void _wl_cb_scr_mode_done(void *data,
141 struct tizen_policy *tizen_policy,
142 struct wl_surface *surface,
149 static void _wl_cb_iconify_state_changed(void *data,
150 struct tizen_policy *tizen_policy,
151 struct wl_surface *surface_resource,
158 static void _wl_cb_supported_aux_hints(void *data,
159 struct tizen_policy *tizen_policy,
160 struct wl_surface *surface_resource,
161 struct wl_array *hints,
167 static void _wl_cb_allowed_aux_hint(void *data,
168 struct tizen_policy *tizen_policy,
169 struct wl_surface *surface_resource,
175 static void _wl_cb_aux_message(void *data,
176 struct tizen_policy *tizen_policy,
177 struct wl_surface *surface_resource,
180 struct wl_array *options)
185 static void _wl_cb_conformant_region(void *data,
186 struct tizen_policy *tizen_policy,
187 struct wl_surface *surface,
188 uint32_t conformant_part,
190 int32_t x, int32_t y, int32_t w, int32_t h,
196 static const struct tizen_policy_listener _tizen_policy_listener = {
198 _wl_cb_conformant_area,
199 _wl_cb_notification_done,
200 _wl_cb_transient_for_done,
201 _wl_cb_scr_mode_done,
202 _wl_cb_iconify_state_changed,
203 _wl_cb_supported_aux_hints,
204 _wl_cb_allowed_aux_hint,
206 _wl_cb_conformant_region,
209 static void __wl_listener_cb(void *data, struct wl_registry *reg,
210 uint32_t id, const char *interface, uint32_t ver)
212 if (interface && !strcmp(interface, "tizen_policy")) {
214 tz_policy = wl_registry_bind(reg, id,
215 &tizen_policy_interface, 7);
217 tizen_policy_add_listener(tz_policy, &_tizen_policy_listener, dsp);
222 static void __wl_listener_remove_cb(void *data, struct wl_registry *reg,
228 static const struct wl_registry_listener reg_listener = {
230 __wl_listener_remove_cb
233 static Eina_Bool __stub_show_cb(void *data, int type, void *event)
235 if (__context.ops.window.show)
236 __context.ops.window.show(type, event, __context.data);
238 return ECORE_CALLBACK_RENEW;
241 static Eina_Bool __stub_hide_cb(void *data, int type, void *event)
243 if (__context.ops.window.hide)
244 __context.ops.window.hide(type, event, __context.data);
246 return ECORE_CALLBACK_RENEW;
249 static Eina_Bool __stub_visibility_cb(void *data, int type, void *event)
251 if (__context.ops.window.visibility)
252 __context.ops.window.visibility(type, event, __context.data);
254 return ECORE_CALLBACK_RENEW;
257 static Eina_Bool __stub_lower_cb(void *data, int type, void *event)
259 if (__context.ops.window.lower)
260 __context.ops.window.lower(type, event, __context.data);
262 return ECORE_CALLBACK_RENEW;
265 static Eina_Bool __stub_pre_visibility_cb(void *data, int type, void *event)
267 if (__context.ops.window.pre_visibility)
268 __context.ops.window.pre_visibility(type, event, __context.data);
270 return ECORE_CALLBACK_RENEW;
273 static Eina_Bool __stub_aux_message_cb(void *data, int type, void *event)
275 if (__context.ops.window.aux_message)
276 __context.ops.window.aux_message(type, event, __context.data);
278 return ECORE_CALLBACK_RENEW;
281 static void __prepare_to_suspend(void)
283 int suspend = APPCORE_BASE_SUSPENDED_STATE_WILL_ENTER_SUSPEND;
285 if (appcore_base_is_bg_allowed() && !appcore_base_is_suspended()) {
286 appcore_base_raise_event((void *)&suspend, APPCORE_BASE_EVENT_SUSPENDED_STATE_CHANGE);
287 appcore_base_toggle_suspended_state();
291 static void __exit_from_suspend(void)
293 int suspend = APPCORE_BASE_SUSPENDED_STATE_DID_EXIT_FROM_SUSPEND;
295 if (appcore_base_is_suspended()) {
296 appcore_base_raise_event((void *)&suspend, APPCORE_BASE_EVENT_SUSPENDED_STATE_CHANGE);
297 appcore_base_toggle_suspended_state();
301 static void __do_pause(void)
305 if (__context.state == AS_RUNNING) {
306 if (__context.ops.pause) {
307 traceBegin(TTRACE_TAG_APPLICATION_MANAGER, "APPCORE:PAUSE");
308 _DBG("Call pause callback");
309 r = __context.ops.pause(__context.data);
310 traceEnd(TTRACE_TAG_APPLICATION_MANAGER);
313 if (r >= 0 && __context.resource_reclaiming)
314 appcore_base_add_suspend_timer();
316 __context.state = AS_PAUSED;
317 __prepare_to_suspend();
319 aul_status_update(STATUS_BG);
322 static void __do_resume(void)
324 if (__context.state == AS_PAUSED || __context.state == AS_CREATED) {
325 __exit_from_suspend();
326 if (__context.ops.resume) {
327 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:resume:start]", __context.appid);
328 traceBegin(TTRACE_TAG_APPLICATION_MANAGER, "APPCORE:RESUME");
329 _DBG("Call resume callback");
330 __context.ops.resume(__context.data);
331 traceEnd(TTRACE_TAG_APPLICATION_MANAGER);
332 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:resume:done]", __context.appid);
334 __context.state = AS_RUNNING;
337 aul_status_update(STATUS_VISIBLE);
340 static GSList *__find_win(unsigned int win)
345 for (iter = g_winnode_list; iter; iter = g_slist_next(iter)) {
347 if (t && t->win == win)
354 static int __get_main_window(void)
356 struct win_node *entry = NULL;
358 if (g_winnode_list != NULL) {
359 entry = g_winnode_list->data;
360 return (unsigned int) entry->win;
366 static int __get_main_surface(void)
368 struct win_node *entry = NULL;
370 if (g_winnode_list != NULL) {
371 entry = g_winnode_list->data;
372 return (unsigned int) entry->surf;
378 static bool __add_win(unsigned int win, unsigned int surf)
383 _DBG("[EVENT_TEST][EVENT] __add_win WIN:%x\n", win);
388 _DBG("[EVENT_TEST][EVENT] ERROR There is already window : %x \n", win);
392 t = calloc(1, sizeof(struct win_node));
400 g_winnode_list = g_slist_append(g_winnode_list, t);
405 static bool __delete_win(unsigned int win)
412 _DBG("[EVENT_TEST][EVENT] ERROR There is no window : %x \n",
418 g_winnode_list = g_slist_delete_link(g_winnode_list, f);
423 static bool __update_win(unsigned int win, unsigned int surf, int vis)
428 _DBG("[EVENT_TEST][EVENT] __update_win WIN:%x visibility %d\n",
434 _DBG("[EVENT_TEST][EVENT] ERROR There is no window : %x \n", win);
438 t = (struct win_node *)f->data;
448 static void __raise_win(void)
450 Ecore_Wl2_Window *win;
453 if (!(__context.hint & APPCORE_UI_BASE_HINT_WINDOW_STACK_CONTROL))
456 win_id = __get_main_window();
458 _DBG("Raise window: %d", win_id);
459 win = ecore_wl2_display_window_find(ecore_wl2_connected_display_get(NULL), win_id);
460 ecore_wl2_window_activate(win);
463 static void __pause_win(void)
465 Ecore_Wl2_Window *win;
466 GSList *wlist = g_winnode_list;
467 struct win_node *entry = NULL;
469 if (!(__context.hint & APPCORE_UI_BASE_HINT_WINDOW_STACK_CONTROL))
472 _DBG("Pause window");
477 _DBG("Pause window: %d", entry->win);
478 win = ecore_wl2_display_window_find(ecore_wl2_connected_display_get(NULL), entry->win);
479 ecore_wl2_window_iconified_set(win, EINA_TRUE);
485 static int __init_wl(void)
487 _DBG("initialize wayland");
488 dsp = wl_display_connect(NULL);
490 _ERR("Failed to connect wl display");
494 reg = wl_display_get_registry(dsp);
496 _ERR("Failed to get registry");
497 wl_display_disconnect(dsp);
501 wl_registry_add_listener(reg, ®_listener, NULL);
502 wl_display_roundtrip(dsp);
505 _ERR("Failed to get tizen policy interface");
506 wl_registry_destroy(reg);
507 wl_display_disconnect(dsp);
514 static void __finish_wl(void)
517 tizen_policy_destroy(tz_policy);
522 wl_registry_destroy(reg);
527 wl_display_disconnect(dsp);
532 static void __set_bg_state(void)
534 if (!tz_policy && __init_wl() < 0)
537 tizen_policy_set_background_state(tz_policy, getpid());
538 wl_display_roundtrip(dsp);
539 __context.bg_state = true;
540 _DBG("bg state: %d", __context.bg_state);
543 static void __unset_bg_state(void)
548 tizen_policy_unset_background_state(tz_policy, getpid());
549 wl_display_roundtrip(dsp);
550 __context.bg_state = false;
551 _DBG("bg state: %d", __context.bg_state);
554 static void __do_start(bundle *b)
556 const char *bg_launch;
557 const char *below_app;
559 if (__context.hint & APPCORE_UI_BASE_HINT_WINDOW_STACK_CONTROL) {
560 if (__context.below_app) {
561 free(__context.below_app);
562 __context.below_app = NULL;
565 below_app = bundle_get_val(b, AUL_SVC_K_RELOCATE_BELOW);
567 __context.below_app = strdup(below_app);
571 first_launch = FALSE;
575 if (__context.hint & APPCORE_UI_BASE_HINT_BG_LAUNCH_CONTROL) {
576 bg_launch = bundle_get_val(b, AUL_SVC_K_BG_LAUNCH);
577 if (bg_launch && strcmp(bg_launch, "enable") == 0) {
578 if (!__context.bg_state &&
579 __context.state != AS_RUNNING)
582 if (__context.bg_state)
587 if (__context.hint & APPCORE_UI_BASE_HINT_WINDOW_AUTO_CONTROL) {
588 if (!__context.bg_state)
593 static int __is_legacy_lifecycle(void)
595 static int is_legacy = -1;
596 const char *api_version;
601 api_version = getenv("TIZEN_API_VERSION");
603 if (strverscmp("2.4", api_version) > 0 &&
604 strverscmp("2.2.1", api_version) < 0)
615 EXPORT_API int appcore_ui_base_on_receive(aul_type type, bundle *b)
617 if (__context.state == AS_DYING) {
618 _ERR("Skip the event in dying state");
622 if (type == AUL_TERMINATE_BGAPP && __context.state != AS_PAUSED)
625 if (type == AUL_START)
626 __exit_from_suspend();
628 appcore_base_on_receive(type, b);
633 if (__context.hint & APPCORE_UI_BASE_HINT_LEGACY_CONTROL) {
634 if (!__context.bg_state && __is_legacy_lifecycle()) {
635 _DBG("Legacy lifecycle");
641 if (__context.bg_state)
647 case AUL_TERMINATE_BGAPP:
648 _DBG("[APP %d] is paused. TERMINATE", getpid());
649 __context.state = AS_DYING;
650 aul_status_update(STATUS_DYING);
651 if (__context.ops.base.exit)
652 __context.ops.base.exit(__context.data);
664 static void __add_ecore_events(void)
666 __context.hshow = ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_SHOW,
667 __stub_show_cb, NULL);
668 if (!__context.hshow)
669 _ERR("Failed to add ECORE_WL_EVENT_WINDOW_SHOW event");
671 __context.hhide = ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_HIDE,
672 __stub_hide_cb, NULL);
673 if (!__context.hhide)
674 _ERR("Failed to add ECORE_WL_EVENT_WINDOW_HIDE event");
676 __context.hvchange = ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_VISIBILITY_CHANGE,
677 __stub_visibility_cb, NULL);
678 if (!__context.hvchange)
679 _ERR("Failed to add ECORE_WL_EVENT_WINDOW_VISIBILITY_CHANGE event");
681 __context.hlower = ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_LOWER,
682 __stub_lower_cb, NULL);
683 if (!__context.hlower)
684 _ERR("Failed to add ECORE_WL_EVENT_WINDOW_LOWER event");
686 __context.hpvchange = ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_PRE_VISIBILITY_CHANGE,
687 __stub_pre_visibility_cb, NULL);
688 if (!__context.hpvchange)
689 _ERR("Failed to add ECORE_WL_EVENT_WINDOW_PRE_VISIBILITY_CHANGE event");
691 __context.hauxmsg = ecore_event_handler_add(ECORE_WL2_EVENT_AUX_MESSAGE,
692 __stub_aux_message_cb, NULL);
693 if (!__context.hauxmsg)
694 _ERR("Failed to add ECORE_WL2_EVENT_AUX_MESSAGE event");
697 static void __del_ecore_events(void)
699 if (__context.hshow) {
700 ecore_event_handler_del(__context.hshow);
701 __context.hshow = NULL;
704 if (__context.hhide) {
705 ecore_event_handler_del(__context.hhide);
706 __context.hhide = NULL;
709 if (__context.hvchange) {
710 ecore_event_handler_del(__context.hvchange);
711 __context.hvchange = NULL;
714 if (__context.hlower) {
715 ecore_event_handler_del(__context.hlower);
716 __context.hlower = NULL;
719 if (__context.hpvchange) {
720 ecore_event_handler_del(__context.hpvchange);
721 __context.hpvchange = NULL;
724 if (__context.hauxmsg) {
725 ecore_event_handler_del(__context.hauxmsg);
726 __context.hauxmsg = NULL;
730 EXPORT_API int appcore_ui_base_on_create(void)
732 __add_ecore_events();
733 appcore_base_on_create();
734 __context.state = AS_CREATED;
735 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:create:done]", __context.appid);
740 EXPORT_API int appcore_ui_base_on_terminate(void)
742 if (__context.state == AS_RUNNING) {
743 if (__context.ops.pause) {
744 _DBG("Call pause callback");
745 __context.ops.pause(__context.data);
749 __context.state = AS_DYING;
751 appcore_base_on_terminate();
756 EXPORT_API int appcore_ui_base_on_pause(void)
761 EXPORT_API int appcore_ui_base_on_resume(void)
766 EXPORT_API int appcore_ui_base_on_control(bundle *b)
768 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:reset:start]", __context.appid);
769 appcore_base_on_control(b);
770 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:reset:done]", __context.appid);
775 EXPORT_API int appcore_ui_base_on_trim_memory(void)
777 return appcore_base_on_trim_memory();
780 static void __group_attach()
782 if (!(__context.hint & APPCORE_UI_BASE_HINT_WINDOW_GROUP_CONTROL))
785 appcore_ui_base_group_add();
788 static void __group_lower()
790 if (!(__context.hint & APPCORE_UI_BASE_HINT_WINDOW_GROUP_CONTROL))
792 appcore_ui_base_group_remove();
795 EXPORT_API void appcore_ui_base_group_add()
797 static bool attached = false;
799 _DBG("__group_attach");
803 int wid = __get_main_surface();
805 _ERR("window wasn't ready");
809 aul_app_group_set_window(wid);
813 EXPORT_API void appcore_ui_base_group_remove()
817 _DBG("__group_lower");
818 aul_app_group_lower(&exit);
820 _DBG("__group_lower : sub-app!");
821 if (__context.ops.base.exit)
822 __context.ops.base.exit(__context.data);
826 EXPORT_API void appcore_ui_base_window_on_show(int type, void *event)
828 Ecore_Wl2_Event_Window_Show *ev;
831 if (ev->parent_win != 0) {
832 /* This is child window. Skip!!! */
836 _DBG("[EVENT_TEST][EVENT] GET SHOW EVENT!!!. WIN:%x, %d\n",
837 ev->win, ev->data[0]);
839 if (!__find_win((unsigned int)ev->win)) {
840 __add_win((unsigned int)ev->win, (unsigned int)ev->data[0]);
842 __update_win((unsigned int)ev->win, (unsigned int)ev->data[0],
846 if (ev->data[0] != 0)
850 static bool __check_visible(void)
853 struct win_node *entry = NULL;
855 _DBG("[EVENT_TEST][EVENT] __check_visible\n");
857 for (iter = g_winnode_list; iter != NULL; iter = g_slist_next(iter)) {
859 _DBG("win : %x visibility : %d\n", entry->win, entry->vis);
860 if (entry->vis == VT_UNOBSCURED)
867 EXPORT_API void appcore_ui_base_window_on_hide(int type, void *event)
869 Ecore_Wl2_Event_Window_Hide *ev;
873 _DBG("[EVENT_TEST][EVENT] GET HIDE EVENT!!!. WIN:%x\n", ev->win);
875 if (__find_win((unsigned int)ev->win)) {
876 __delete_win((unsigned int)ev->win);
877 bvisibility = __check_visible();
878 if (!bvisibility && w_status != WS_PAUSE) {
879 _DBG(" Go to Pasue state \n");
886 EXPORT_API void appcore_ui_base_window_on_lower(int type, void *event)
888 Ecore_Wl2_Event_Window_Lower *ev;
893 _DBG("ECORE_WL2_EVENT_WINDOW_LOWER window id:%u\n", ev->win);
897 EXPORT_API void appcore_ui_base_window_on_visibility(int type, void *event)
899 Ecore_Wl2_Event_Window_Visibility_Change *ev;
903 __update_win((unsigned int)ev->win, 0,
904 ev->fully_obscured ? VT_FULLY_OBSCURED : VT_UNOBSCURED);
905 bvisibility = __check_visible();
907 _DBG("bvisibility %d, w_status %d", bvisibility, w_status);
909 if (bvisibility && (__context.hint & APPCORE_UI_BASE_HINT_WINDOW_STACK_CONTROL) &&
910 __context.below_app) {
911 aul_app_group_activate_below(__context.below_app);
912 free(__context.below_app);
913 __context.below_app = NULL;
916 if (bvisibility && w_status != WS_RESUME) {
917 _DBG(" Go to Resume state\n");
918 w_status = WS_RESUME;
920 } else if (!bvisibility && w_status != WS_PAUSE) {
921 _DBG(" Go to Pasue state \n");
925 _DBG(" No change state \n");
930 EXPORT_API void appcore_ui_base_window_on_pre_visibility(int type, void *event)
932 Ecore_Wl2_Event_Window_Pre_Visibility_Change *ev = event;
935 if (ev && ev->type == ECORE_WL2_WINDOW_VISIBILITY_TYPE_PRE_UNOBSCURED) {
936 __update_win((unsigned int)ev->win, 0, VT_UNOBSCURED);
937 bvisibility = __check_visible();
939 _DBG("bvisibility %d, w_status %d", bvisibility, w_status);
940 if (bvisibility && w_status != WS_RESUME) {
941 _DBG(" Go to Resume state\n");
942 w_status = WS_RESUME;
948 EXPORT_API void appcore_ui_base_window_on_aux_message(int type, void *event)
950 Ecore_Wl2_Event_Aux_Message *ev = event;
952 if (ev->key && !strcmp(ev->key, "dpms_wm")) {
953 if (ev->val && !strcmp(ev->val, "on")) {
954 _DBG("Display state: on");
955 appcore_base_set_display_state(
956 APPCORE_BASE_DISPLAY_STATE_ON);
957 } else if (ev->val && !strcmp(ev->val, "off")) {
958 _DBG("Display state: off");
959 appcore_base_set_display_state(
960 APPCORE_BASE_DISPLAY_STATE_OFF);
962 _ERR("Unknown state: %s", ev->val);
967 EXPORT_API int appcore_ui_base_init(appcore_ui_base_ops ops, int argc, char **argv,
968 void *data, unsigned int hint)
970 const char *bg_launch;
972 char appid[PATH_MAX] = {0, };
975 if (!ecore_wl2_init()) {
976 _ERR("could not wl2 init");
980 ecore_wl2_display_connect(NULL);
981 appcore_ui_plugin_init(&ops, argc, argv, &hint);
982 ret = aul_app_get_appid_bypid(getpid(), appid, sizeof(appid));
984 _ERR("Fail to get appid (%d)", getpid());
987 __context.data = data;
988 __context.argc = argc;
989 __context.argv = argv;
990 __context.hint = hint;
991 __context.state = AS_NONE;
992 __context.appid = strdup(appid);
993 __context.resource_reclaiming = true;
995 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:main:done]", appid);
996 if (__context.hint & APPCORE_UI_BASE_HINT_BG_LAUNCH_CONTROL) {
997 b = bundle_import_from_argv(argc, argv);
999 bg_launch = bundle_get_val(b, AUL_SVC_K_BG_LAUNCH);
1000 if (bg_launch && strcmp(bg_launch, "enable") == 0)
1007 return appcore_base_init(ops.base, argc, argv, data);
1010 EXPORT_API void appcore_ui_base_fini(void)
1012 __del_ecore_events();
1015 free(__context.appid);
1016 __context.appid = NULL;
1018 appcore_base_fini();
1019 appcore_ui_plugin_fini();
1020 _ERR("disconnect wl2_display");
1021 ecore_wl2_display_disconnect(ecore_wl2_connected_display_get(NULL));
1022 ecore_wl2_shutdown();
1025 EXPORT_API void appcore_ui_base_pause(void)
1030 EXPORT_API void appcore_ui_base_resume(void)
1035 EXPORT_API bool appcore_ui_base_is_resumed(void)
1037 return __context.state == AS_RUNNING;
1040 EXPORT_API void appcore_ui_base_exit(void)
1042 if (__context.ops.base.exit)
1043 __context.ops.base.exit(__context.data);
1046 EXPORT_API unsigned int appcore_ui_base_get_main_window(void)
1048 return __get_main_window();
1051 EXPORT_API unsigned int appcore_ui_base_get_main_surface(void)
1053 return __get_main_surface();
1056 EXPORT_API int appcore_ui_base_get_hint(void)
1058 return __context.hint;
1061 EXPORT_API bool appcore_ui_base_get_bg_state(void)
1063 return __context.bg_state;
1066 EXPORT_API void appcore_ui_base_set_bg_state(bool bg_state)
1068 __context.bg_state = bg_state;
1071 EXPORT_API void appcore_ui_base_set_system_resource_reclaiming(bool enable)
1073 __context.resource_reclaiming = enable;
1076 static int __on_receive(aul_type type, bundle *b, void *data)
1078 return appcore_ui_base_on_receive(type, b);
1081 static int __on_create(void *data)
1083 return appcore_ui_base_on_create();
1086 static int __on_terminate(void *data)
1088 return appcore_ui_base_on_terminate();
1091 static int __on_pause(void *data)
1093 return appcore_ui_base_on_pause();
1096 static int __on_resume(void *data)
1098 return appcore_ui_base_on_resume();
1101 static void __window_on_show(int type, void *event, void *data)
1103 appcore_ui_base_window_on_show(type, event);
1106 static void __window_on_hide(int type, void *event, void *data)
1108 appcore_ui_base_window_on_hide(type, event);
1111 static void __window_on_lower(int type, void *event, void *data)
1113 appcore_ui_base_window_on_lower(type, event);
1116 static void __window_on_visibility(int type, void *event, void *data)
1118 appcore_ui_base_window_on_visibility(type, event);
1121 static void __window_on_pre_visibility(int type, void *event, void *data)
1123 appcore_ui_base_window_on_pre_visibility(type, event);
1126 static void __window_on_aux_message(int type, void *event, void *data)
1128 appcore_ui_base_window_on_aux_message(type, event);
1131 EXPORT_API appcore_ui_base_ops appcore_ui_base_get_default_ops(void)
1133 appcore_ui_base_ops ops;
1135 ops.base = appcore_base_get_default_ops();
1137 /* override methods */
1138 ops.base.create = __on_create;
1139 ops.base.terminate = __on_terminate;
1140 ops.base.receive = __on_receive;
1141 ops.base.init = NULL;
1142 ops.base.finish = NULL;
1143 ops.base.run = NULL;
1144 ops.base.exit = NULL;
1146 ops.pause = __on_pause;
1147 ops.resume = __on_resume;
1148 ops.window.show = __window_on_show;
1149 ops.window.hide = __window_on_hide;
1150 ops.window.lower = __window_on_lower;
1151 ops.window.visibility = __window_on_visibility;
1152 ops.window.pre_visibility = __window_on_pre_visibility;
1153 ops.window.aux_message = __window_on_aux_message;