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 <aul_rpc_port.h>
43 #include <bundle_internal.h>
46 #include "appcore_base.h"
47 #include "appcore_ui_base.h"
48 #include "appcore_ui_base_private.h"
49 #include "appcore_ui_plugin.h"
65 enum visibility_type {
71 typedef struct _appcore_ui_base_context {
72 appcore_ui_base_ops ops;
80 bool resource_reclaiming;
83 Ecore_Event_Handler *hshow;
84 Ecore_Event_Handler *hhide;
85 Ecore_Event_Handler *hvchange;
86 Ecore_Event_Handler *hlower;
87 Ecore_Event_Handler *hpvchange;
88 Ecore_Event_Handler *hauxmsg;
89 } appcore_ui_base_context;
92 static int w_status = WS_NONE;
93 static bool first_launch = true;
101 static GSList *g_winnode_list;
102 static appcore_ui_base_context __context;
103 static struct wl_display *dsp;
104 static struct wl_registry *reg;
105 static struct tizen_policy *tz_policy;
107 static void _wl_cb_conformant(void *data,
108 struct tizen_policy *tizen_policy,
109 struct wl_surface *surface_resource,
110 uint32_t is_conformant)
115 static void _wl_cb_conformant_area(void *data,
116 struct tizen_policy *tizen_policy,
117 struct wl_surface *surface_resource,
118 uint32_t conformant_part,
120 int32_t x, int32_t y, int32_t w, int32_t h)
125 static void _wl_cb_notification_done(void *data,
126 struct tizen_policy *tizen_policy,
127 struct wl_surface *surface,
134 static void _wl_cb_transient_for_done(void *data,
135 struct tizen_policy *tizen_policy,
141 static void _wl_cb_scr_mode_done(void *data,
142 struct tizen_policy *tizen_policy,
143 struct wl_surface *surface,
150 static void _wl_cb_iconify_state_changed(void *data,
151 struct tizen_policy *tizen_policy,
152 struct wl_surface *surface_resource,
159 static void _wl_cb_supported_aux_hints(void *data,
160 struct tizen_policy *tizen_policy,
161 struct wl_surface *surface_resource,
162 struct wl_array *hints,
168 static void _wl_cb_allowed_aux_hint(void *data,
169 struct tizen_policy *tizen_policy,
170 struct wl_surface *surface_resource,
176 static void _wl_cb_aux_message(void *data,
177 struct tizen_policy *tizen_policy,
178 struct wl_surface *surface_resource,
181 struct wl_array *options)
186 static void _wl_cb_conformant_region(void *data,
187 struct tizen_policy *tizen_policy,
188 struct wl_surface *surface,
189 uint32_t conformant_part,
191 int32_t x, int32_t y, int32_t w, int32_t h,
197 static const struct tizen_policy_listener _tizen_policy_listener = {
199 _wl_cb_conformant_area,
200 _wl_cb_notification_done,
201 _wl_cb_transient_for_done,
202 _wl_cb_scr_mode_done,
203 _wl_cb_iconify_state_changed,
204 _wl_cb_supported_aux_hints,
205 _wl_cb_allowed_aux_hint,
207 _wl_cb_conformant_region,
210 static void __wl_listener_cb(void *data, struct wl_registry *reg,
211 uint32_t id, const char *interface, uint32_t ver)
213 if (interface && !strcmp(interface, "tizen_policy")) {
215 tz_policy = wl_registry_bind(reg, id,
216 &tizen_policy_interface, 7);
218 tizen_policy_add_listener(tz_policy, &_tizen_policy_listener, dsp);
223 static void __wl_listener_remove_cb(void *data, struct wl_registry *reg,
229 static const struct wl_registry_listener reg_listener = {
231 __wl_listener_remove_cb
234 static Eina_Bool __stub_show_cb(void *data, int type, void *event)
236 if (__context.ops.window.show)
237 __context.ops.window.show(type, event, __context.data);
239 return ECORE_CALLBACK_RENEW;
242 static Eina_Bool __stub_hide_cb(void *data, int type, void *event)
244 if (__context.ops.window.hide)
245 __context.ops.window.hide(type, event, __context.data);
247 return ECORE_CALLBACK_RENEW;
250 static Eina_Bool __stub_visibility_cb(void *data, int type, void *event)
252 if (__context.ops.window.visibility)
253 __context.ops.window.visibility(type, event, __context.data);
255 return ECORE_CALLBACK_RENEW;
258 static Eina_Bool __stub_lower_cb(void *data, int type, void *event)
260 if (__context.ops.window.lower)
261 __context.ops.window.lower(type, event, __context.data);
263 return ECORE_CALLBACK_RENEW;
266 static Eina_Bool __stub_pre_visibility_cb(void *data, int type, void *event)
268 if (__context.ops.window.pre_visibility)
269 __context.ops.window.pre_visibility(type, event, __context.data);
271 return ECORE_CALLBACK_RENEW;
274 static Eina_Bool __stub_aux_message_cb(void *data, int type, void *event)
276 if (__context.ops.window.aux_message)
277 __context.ops.window.aux_message(type, event, __context.data);
279 return ECORE_CALLBACK_RENEW;
282 static void __prepare_to_suspend(void)
284 int suspend = APPCORE_BASE_SUSPENDED_STATE_WILL_ENTER_SUSPEND;
286 if (appcore_base_is_bg_allowed() && !appcore_base_is_suspended()) {
287 appcore_base_raise_event((void *)&suspend, APPCORE_BASE_EVENT_SUSPENDED_STATE_CHANGE);
288 appcore_base_toggle_suspended_state();
292 static void __exit_from_suspend(void)
294 int suspend = APPCORE_BASE_SUSPENDED_STATE_DID_EXIT_FROM_SUSPEND;
296 if (appcore_base_is_suspended()) {
297 appcore_base_raise_event((void *)&suspend, APPCORE_BASE_EVENT_SUSPENDED_STATE_CHANGE);
298 appcore_base_toggle_suspended_state();
302 static void __do_pause(void)
306 if (__context.state == AS_RUNNING) {
307 if (__context.ops.pause) {
308 traceBegin(TTRACE_TAG_APPLICATION_MANAGER, "APPCORE:PAUSE");
309 _DBG("Call pause callback");
310 r = __context.ops.pause(__context.data);
311 traceEnd(TTRACE_TAG_APPLICATION_MANAGER);
314 if (r >= 0 && __context.resource_reclaiming)
315 appcore_base_add_suspend_timer();
317 __context.state = AS_PAUSED;
318 __prepare_to_suspend();
320 aul_status_update(STATUS_BG);
323 static void __do_resume(void)
325 if (__context.state == AS_PAUSED || __context.state == AS_CREATED) {
326 __exit_from_suspend();
327 if (__context.ops.resume) {
328 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:resume:start]", __context.appid);
329 traceBegin(TTRACE_TAG_APPLICATION_MANAGER, "APPCORE:RESUME");
330 _DBG("Call resume callback");
331 appcore_base_remove_suspend_timer();
332 __context.ops.resume(__context.data);
333 traceEnd(TTRACE_TAG_APPLICATION_MANAGER);
334 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:resume:done]", __context.appid);
336 __context.state = AS_RUNNING;
339 aul_status_update(STATUS_VISIBLE);
342 static GSList *__find_win(unsigned int win)
347 for (iter = g_winnode_list; iter; iter = g_slist_next(iter)) {
349 if (t && t->win == win)
356 static int __get_main_window(void)
358 struct win_node *entry = NULL;
360 if (g_winnode_list != NULL) {
361 entry = g_winnode_list->data;
362 return (unsigned int) entry->win;
368 static int __get_main_surface(void)
370 struct win_node *entry = NULL;
372 if (g_winnode_list != NULL) {
373 entry = g_winnode_list->data;
374 return (unsigned int) entry->surf;
380 static bool __add_win(unsigned int win, unsigned int surf)
385 _DBG("[EVENT_TEST][EVENT] __add_win WIN:%x\n", win);
390 _DBG("[EVENT_TEST][EVENT] ERROR There is already window : %x \n", win);
394 t = calloc(1, sizeof(struct win_node));
402 g_winnode_list = g_slist_append(g_winnode_list, t);
407 static bool __delete_win(unsigned int win)
414 _DBG("[EVENT_TEST][EVENT] ERROR There is no window : %x \n",
420 g_winnode_list = g_slist_delete_link(g_winnode_list, f);
425 static bool __update_win(unsigned int win, unsigned int surf, int vis)
430 _DBG("[EVENT_TEST][EVENT] __update_win WIN:%x visibility %d\n",
436 _DBG("[EVENT_TEST][EVENT] ERROR There is no window : %x \n", win);
440 t = (struct win_node *)f->data;
450 static void __raise_win(void)
452 Ecore_Wl2_Window *win;
455 if (!(__context.hint & APPCORE_UI_BASE_HINT_WINDOW_STACK_CONTROL))
458 win_id = __get_main_window();
460 _INFO("Raise window: %d", win_id);
461 win = ecore_wl2_display_window_find(ecore_wl2_connected_display_get(NULL), win_id);
462 ecore_wl2_window_activate(win);
465 static void __pause_win(void)
467 Ecore_Wl2_Window *win;
468 GSList *wlist = g_winnode_list;
469 struct win_node *entry = NULL;
471 if (!(__context.hint & APPCORE_UI_BASE_HINT_WINDOW_STACK_CONTROL))
474 _DBG("Pause window");
479 _DBG("Pause window: %d", entry->win);
480 win = ecore_wl2_display_window_find(ecore_wl2_connected_display_get(NULL), entry->win);
481 ecore_wl2_window_iconified_set(win, EINA_TRUE);
487 static int __init_wl(void)
489 _DBG("initialize wayland");
490 dsp = wl_display_connect(NULL);
492 _ERR("Failed to connect wl display");
496 reg = wl_display_get_registry(dsp);
498 _ERR("Failed to get registry");
499 wl_display_disconnect(dsp);
503 wl_registry_add_listener(reg, ®_listener, NULL);
504 wl_display_roundtrip(dsp);
507 _ERR("Failed to get tizen policy interface");
508 wl_registry_destroy(reg);
509 wl_display_disconnect(dsp);
516 static void __finish_wl(void)
519 tizen_policy_destroy(tz_policy);
524 wl_registry_destroy(reg);
529 wl_display_disconnect(dsp);
534 static void __set_bg_state(void)
536 if (!tz_policy && __init_wl() < 0)
539 tizen_policy_set_background_state(tz_policy, getpid());
540 wl_display_roundtrip(dsp);
541 __context.bg_state = true;
542 _DBG("bg state: %d", __context.bg_state);
545 static void __unset_bg_state(void)
550 tizen_policy_unset_background_state(tz_policy, getpid());
551 wl_display_roundtrip(dsp);
552 __context.bg_state = false;
553 _DBG("bg state: %d", __context.bg_state);
556 static void __set_app_id(void)
558 if (!tz_policy && __init_wl() < 0)
561 tizen_policy_set_appid(tz_policy, getpid(), __context.appid);
562 wl_display_roundtrip(dsp);
563 _DBG("set appid: %s", __context.appid);
566 static void __do_start(bundle *b)
568 const char *bg_launch;
569 const char *below_app;
570 const char *rpc_port;
572 if (__context.hint & APPCORE_UI_BASE_HINT_WINDOW_STACK_CONTROL) {
573 if (__context.below_app) {
574 free(__context.below_app);
575 __context.below_app = NULL;
578 below_app = bundle_get_val(b, AUL_SVC_K_RELOCATE_BELOW);
580 __context.below_app = strdup(below_app);
584 first_launch = FALSE;
588 if (__context.hint & APPCORE_UI_BASE_HINT_BG_LAUNCH_CONTROL) {
589 bg_launch = bundle_get_val(b, AUL_SVC_K_BG_LAUNCH);
590 if (bg_launch && strcmp(bg_launch, "enable") == 0) {
591 if (!__context.bg_state &&
592 __context.state != AS_RUNNING)
595 if (__context.bg_state)
600 if (__context.hint & APPCORE_UI_BASE_HINT_WINDOW_AUTO_CONTROL) {
601 if (!__context.bg_state) {
602 rpc_port = bundle_get_val(b, AUL_K_RPC_PORT);
609 static int __is_legacy_lifecycle(void)
611 static int is_legacy = -1;
612 const char *api_version;
617 api_version = getenv("TIZEN_API_VERSION");
619 if (strverscmp("2.4", api_version) > 0 &&
620 strverscmp("2.2.1", api_version) < 0)
631 EXPORT_API int appcore_ui_base_on_receive(aul_type type, bundle *b)
633 if (__context.state == AS_DYING) {
634 _ERR("Skip the event in dying state");
638 if ((type == AUL_TERMINATE_BGAPP || type == AUL_TERMINATE_BG_INST) &&
639 __context.state != AS_PAUSED)
642 if (type == AUL_START)
643 __exit_from_suspend();
645 appcore_base_on_receive(type, b);
650 if (__context.hint & APPCORE_UI_BASE_HINT_LEGACY_CONTROL) {
651 if (!__context.bg_state && __is_legacy_lifecycle()) {
652 _DBG("Legacy lifecycle");
658 if (__context.bg_state)
663 __context.state = AS_DYING;
665 case AUL_TERMINATE_BG_INST:
666 case AUL_TERMINATE_INST:
667 case AUL_TERMINATE_BGAPP:
668 _DBG("[APP %d] TERMINATE", getpid());
669 __context.state = AS_DYING;
670 aul_status_update(STATUS_DYING);
671 if (__context.ops.base.exit)
672 __context.ops.base.exit(__context.data);
684 static void __add_ecore_events(void)
686 __context.hshow = ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_SHOW,
687 __stub_show_cb, NULL);
688 if (!__context.hshow)
689 _ERR("Failed to add ECORE_WL_EVENT_WINDOW_SHOW event");
691 __context.hhide = ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_HIDE,
692 __stub_hide_cb, NULL);
693 if (!__context.hhide)
694 _ERR("Failed to add ECORE_WL_EVENT_WINDOW_HIDE event");
696 __context.hvchange = ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_VISIBILITY_CHANGE,
697 __stub_visibility_cb, NULL);
698 if (!__context.hvchange)
699 _ERR("Failed to add ECORE_WL_EVENT_WINDOW_VISIBILITY_CHANGE event");
701 __context.hlower = ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_LOWER,
702 __stub_lower_cb, NULL);
703 if (!__context.hlower)
704 _ERR("Failed to add ECORE_WL_EVENT_WINDOW_LOWER event");
706 __context.hpvchange = ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_PRE_VISIBILITY_CHANGE,
707 __stub_pre_visibility_cb, NULL);
708 if (!__context.hpvchange)
709 _ERR("Failed to add ECORE_WL_EVENT_WINDOW_PRE_VISIBILITY_CHANGE event");
711 __context.hauxmsg = ecore_event_handler_add(ECORE_WL2_EVENT_AUX_MESSAGE,
712 __stub_aux_message_cb, NULL);
713 if (!__context.hauxmsg)
714 _ERR("Failed to add ECORE_WL2_EVENT_AUX_MESSAGE event");
717 static void __del_ecore_events(void)
719 if (__context.hshow) {
720 ecore_event_handler_del(__context.hshow);
721 __context.hshow = NULL;
724 if (__context.hhide) {
725 ecore_event_handler_del(__context.hhide);
726 __context.hhide = NULL;
729 if (__context.hvchange) {
730 ecore_event_handler_del(__context.hvchange);
731 __context.hvchange = NULL;
734 if (__context.hlower) {
735 ecore_event_handler_del(__context.hlower);
736 __context.hlower = NULL;
739 if (__context.hpvchange) {
740 ecore_event_handler_del(__context.hpvchange);
741 __context.hpvchange = NULL;
744 if (__context.hauxmsg) {
745 ecore_event_handler_del(__context.hauxmsg);
746 __context.hauxmsg = NULL;
750 EXPORT_API int appcore_ui_base_on_create(void)
752 __add_ecore_events();
753 appcore_base_on_create();
754 __context.state = AS_CREATED;
755 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:create:done]", __context.appid);
760 EXPORT_API int appcore_ui_base_on_terminate(void)
762 if (__context.state == AS_RUNNING) {
763 if (__context.ops.pause) {
764 _DBG("Call pause callback");
765 __context.ops.pause(__context.data);
769 __context.state = AS_DYING;
771 appcore_base_on_terminate();
776 EXPORT_API int appcore_ui_base_on_pause(void)
781 EXPORT_API int appcore_ui_base_on_resume(void)
786 EXPORT_API int appcore_ui_base_on_control(bundle *b)
788 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:reset:start]", __context.appid);
789 appcore_base_on_control(b);
790 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:reset:done]", __context.appid);
795 EXPORT_API int appcore_ui_base_on_trim_memory(void)
797 return appcore_base_on_trim_memory();
800 static void __group_attach()
802 if (!(__context.hint & APPCORE_UI_BASE_HINT_WINDOW_GROUP_CONTROL))
805 appcore_ui_base_group_add();
808 static void __group_lower()
810 if (!(__context.hint & APPCORE_UI_BASE_HINT_WINDOW_GROUP_CONTROL))
812 appcore_ui_base_group_remove();
815 EXPORT_API int appcore_ui_base_group_add()
817 static bool attached = false;
820 _DBG("__group_attach");
824 int wid = __get_main_surface();
826 _ERR("window wasn't ready");
830 ret = aul_app_group_set_window(wid);
832 _ERR("Failed to set app group window. error(%d)", ret);
840 EXPORT_API void appcore_ui_base_group_remove()
844 _DBG("__group_lower");
845 aul_app_group_lower(&exit);
847 _DBG("__group_lower : sub-app!");
848 if (__context.ops.base.exit)
849 __context.ops.base.exit(__context.data);
853 EXPORT_API void appcore_ui_base_window_on_show(int type, void *event)
855 Ecore_Wl2_Event_Window_Show *ev;
858 if (ev->parent_win != 0) {
859 /* This is child window. Skip!!! */
863 _DBG("[EVENT_TEST][EVENT] GET SHOW EVENT!!!. WIN:%x, %d\n",
864 ev->win, ev->data[0]);
866 if (!__find_win((unsigned int)ev->win)) {
867 __add_win((unsigned int)ev->win, (unsigned int)ev->data[0]);
869 __update_win((unsigned int)ev->win, (unsigned int)ev->data[0],
873 if (ev->data[0] != 0)
877 static bool __check_visible(void)
880 struct win_node *entry = NULL;
882 _DBG("[EVENT_TEST][EVENT] __check_visible\n");
884 for (iter = g_winnode_list; iter != NULL; iter = g_slist_next(iter)) {
886 _DBG("win : %x visibility : %d\n", entry->win, entry->vis);
887 if (entry->vis == VT_UNOBSCURED)
894 EXPORT_API void appcore_ui_base_window_on_hide(int type, void *event)
896 Ecore_Wl2_Event_Window_Hide *ev;
900 _DBG("[EVENT_TEST][EVENT] GET HIDE EVENT!!!. WIN:%x\n", ev->win);
902 if (__find_win((unsigned int)ev->win)) {
903 __delete_win((unsigned int)ev->win);
904 bvisibility = __check_visible();
905 if (!bvisibility && w_status != WS_PAUSE) {
906 _DBG(" Go to Pasue state \n");
913 EXPORT_API void appcore_ui_base_window_on_lower(int type, void *event)
915 Ecore_Wl2_Event_Window_Lower *ev;
920 _DBG("ECORE_WL2_EVENT_WINDOW_LOWER window id:%u\n", ev->win);
924 EXPORT_API void appcore_ui_base_window_on_visibility(int type, void *event)
926 Ecore_Wl2_Event_Window_Visibility_Change *ev;
930 __update_win((unsigned int)ev->win, 0,
931 ev->fully_obscured ? VT_FULLY_OBSCURED : VT_UNOBSCURED);
932 bvisibility = __check_visible();
934 _DBG("bvisibility %d, w_status %d", bvisibility, w_status);
936 if (bvisibility && (__context.hint & APPCORE_UI_BASE_HINT_WINDOW_STACK_CONTROL) &&
937 __context.below_app) {
938 aul_app_group_activate_below(__context.below_app);
939 free(__context.below_app);
940 __context.below_app = NULL;
943 if (bvisibility && w_status != WS_RESUME) {
944 _DBG(" Go to Resume state\n");
945 w_status = WS_RESUME;
947 } else if (!bvisibility && w_status != WS_PAUSE) {
948 _DBG(" Go to Pasue state \n");
952 _DBG(" No change state \n");
957 EXPORT_API void appcore_ui_base_window_on_pre_visibility(int type, void *event)
959 Ecore_Wl2_Event_Window_Pre_Visibility_Change *ev = event;
962 if (ev && ev->type == ECORE_WL2_WINDOW_VISIBILITY_TYPE_PRE_UNOBSCURED) {
963 __update_win((unsigned int)ev->win, 0, VT_UNOBSCURED);
964 bvisibility = __check_visible();
966 _DBG("bvisibility %d, w_status %d", bvisibility, w_status);
967 if (bvisibility && w_status != WS_RESUME) {
968 _DBG(" Go to Resume state\n");
969 w_status = WS_RESUME;
975 EXPORT_API void appcore_ui_base_window_on_aux_message(int type, void *event)
977 Ecore_Wl2_Event_Aux_Message *ev = event;
979 if (ev->key && !strcmp(ev->key, "dpms_wm")) {
980 if (ev->val && !strcmp(ev->val, "on")) {
981 _DBG("Display state: on");
982 appcore_base_set_display_state(
983 APPCORE_BASE_DISPLAY_STATE_ON);
984 } else if (ev->val && !strcmp(ev->val, "off")) {
985 _DBG("Display state: off");
986 appcore_base_set_display_state(
987 APPCORE_BASE_DISPLAY_STATE_OFF);
989 _ERR("Unknown state: %s", ev->val);
994 EXPORT_API int appcore_ui_base_init(appcore_ui_base_ops ops, int argc, char **argv,
995 void *data, unsigned int hint)
997 const char *bg_launch;
999 char appid[PATH_MAX] = {0, };
1002 if (!ecore_wl2_init()) {
1003 _ERR("could not wl2 init");
1007 ecore_wl2_display_connect(NULL);
1008 appcore_ui_plugin_init(&ops, argc, argv, &hint);
1009 ret = aul_app_get_appid_bypid(getpid(), appid, sizeof(appid));
1011 _ERR("Fail to get appid (%d)", getpid());
1013 __context.ops = ops;
1014 __context.data = data;
1015 __context.argc = argc;
1016 __context.argv = argv;
1017 __context.hint = hint;
1018 __context.state = AS_NONE;
1019 __context.appid = strdup(appid);
1020 __context.resource_reclaiming = true;
1022 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:main:done]", appid);
1023 if (__context.hint & APPCORE_UI_BASE_HINT_BG_LAUNCH_CONTROL) {
1024 b = bundle_import_from_argv(argc, argv);
1026 bg_launch = bundle_get_val(b, AUL_SVC_K_BG_LAUNCH);
1027 if (bg_launch && strcmp(bg_launch, "enable") == 0)
1034 if (__context.hint & APPCORE_UI_BASE_HINT_WINDOW_ID_CONTROL)
1037 return appcore_base_init(ops.base, argc, argv, data);
1040 EXPORT_API void appcore_ui_base_fini(void)
1042 __del_ecore_events();
1045 free(__context.appid);
1046 __context.appid = NULL;
1048 appcore_base_fini();
1049 appcore_ui_plugin_fini();
1050 _ERR("disconnect wl2_display");
1051 ecore_wl2_display_disconnect(ecore_wl2_connected_display_get(NULL));
1052 ecore_wl2_shutdown();
1055 EXPORT_API void appcore_ui_base_pause(void)
1060 EXPORT_API void appcore_ui_base_resume(void)
1065 EXPORT_API bool appcore_ui_base_is_resumed(void)
1067 return __context.state == AS_RUNNING;
1070 EXPORT_API void appcore_ui_base_exit(void)
1072 if (__context.ops.base.exit)
1073 __context.ops.base.exit(__context.data);
1076 EXPORT_API unsigned int appcore_ui_base_get_main_window(void)
1078 return __get_main_window();
1081 EXPORT_API unsigned int appcore_ui_base_get_main_surface(void)
1083 return __get_main_surface();
1086 EXPORT_API int appcore_ui_base_get_hint(void)
1088 return __context.hint;
1091 EXPORT_API bool appcore_ui_base_get_bg_state(void)
1093 return __context.bg_state;
1096 EXPORT_API void appcore_ui_base_set_bg_state(bool bg_state)
1098 __context.bg_state = bg_state;
1101 EXPORT_API void appcore_ui_base_set_system_resource_reclaiming(bool enable)
1103 __context.resource_reclaiming = enable;
1106 static int __on_receive(aul_type type, bundle *b, void *data)
1108 return appcore_ui_base_on_receive(type, b);
1111 static int __on_create(void *data)
1113 return appcore_ui_base_on_create();
1116 static int __on_terminate(void *data)
1118 return appcore_ui_base_on_terminate();
1121 static int __on_pause(void *data)
1123 return appcore_ui_base_on_pause();
1126 static int __on_resume(void *data)
1128 return appcore_ui_base_on_resume();
1131 static void __window_on_show(int type, void *event, void *data)
1133 appcore_ui_base_window_on_show(type, event);
1136 static void __window_on_hide(int type, void *event, void *data)
1138 appcore_ui_base_window_on_hide(type, event);
1141 static void __window_on_lower(int type, void *event, void *data)
1143 appcore_ui_base_window_on_lower(type, event);
1146 static void __window_on_visibility(int type, void *event, void *data)
1148 appcore_ui_base_window_on_visibility(type, event);
1151 static void __window_on_pre_visibility(int type, void *event, void *data)
1153 appcore_ui_base_window_on_pre_visibility(type, event);
1156 static void __window_on_aux_message(int type, void *event, void *data)
1158 appcore_ui_base_window_on_aux_message(type, event);
1161 EXPORT_API appcore_ui_base_ops appcore_ui_base_get_default_ops(void)
1163 appcore_ui_base_ops ops;
1165 ops.base = appcore_base_get_default_ops();
1167 /* override methods */
1168 ops.base.create = __on_create;
1169 ops.base.terminate = __on_terminate;
1170 ops.base.receive = __on_receive;
1171 ops.base.init = NULL;
1172 ops.base.finish = NULL;
1173 ops.base.run = NULL;
1174 ops.base.exit = NULL;
1176 ops.pause = __on_pause;
1177 ops.resume = __on_resume;
1178 ops.window.show = __window_on_show;
1179 ops.window.hide = __window_on_hide;
1180 ops.window.lower = __window_on_lower;
1181 ops.window.visibility = __window_on_visibility;
1182 ops.window.pre_visibility = __window_on_pre_visibility;
1183 ops.window.aux_message = __window_on_aux_message;