2 * Copyright (c) 2000 - 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.
17 #include <sys/types.h>
18 #include <sys/socket.h>
28 #include <Ecore_Wayland.h>
30 #include <X11/Xatom.h>
36 #include <Ecore_Evas.h>
37 #include <Ecore_Input_Evas.h>
38 #include <Elementary.h>
39 #include <glib-object.h>
47 #include "appcore-internal.h"
48 #include "appcore-efl.h"
51 static bool resource_reclaiming = TRUE;
52 static int tmp_val = 0;
58 Ecore_Event_Handler *hshow;
59 Ecore_Event_Handler *hhide;
60 Ecore_Event_Handler *hvchange;
62 Ecore_Event_Handler *hlower;
64 Ecore_Event_Handler *hcmsg; /* WM_ROTATE */
66 Ecore_Timer *mftimer; /* Ecore Timer for memory flushing */
68 #ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
69 struct appcore *app_core;
70 void (*prepare_to_suspend) (void *data);
71 void (*exit_from_suspend) (void *data);
73 struct appcore_ops *ops;
74 void (*mfcb) (void); /* Memory Flushing Callback */
79 int (*rot_cb) (void *event_info, enum appcore_rm, void *);
81 enum appcore_rm rot_mode;
85 static struct ui_priv priv;
87 static const char *_ae_name[AE_MAX] = {
88 [AE_UNKNOWN] = "UNKNOWN",
89 [AE_CREATE] = "CREATE",
90 [AE_TERMINATE] = "TERMINATE",
92 [AE_RESUME] = "RESUME",
94 [AE_LOWMEM_POST] = "LOWMEM_POST",
95 [AE_MEM_FLUSH] = "MEM_FLUSH",
98 static const char *_as_name[] = {
100 [AS_CREATED] = "CREATED",
101 [AS_RUNNING] = "RUNNING",
102 [AS_PAUSED] = "PAUSED",
103 [AS_DYING] = "DYING",
106 static bool b_active = FALSE;
107 static bool first_launch = TRUE;
118 static struct ui_wm_rotate wm_rotate;
120 static Eina_Bool __visibility_cb(void *data, int type, void *event);
121 static GSList *g_winnode_list;
123 #ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
124 static void __appcore_efl_prepare_to_suspend(void *data)
126 struct ui_priv *ui = (struct ui_priv *)data;
127 struct sys_op *op = NULL;
128 int suspend = APPCORE_SUSPENDED_STATE_WILL_ENTER_SUSPEND;
130 if (ui->app_core && !ui->app_core->allowed_bg && !ui->app_core->suspended_state) {
131 op = &ui->app_core->sops[SE_SUSPENDED_STATE];
133 op->func((void *)&suspend, op->data); /* calls c-api handler */
135 ui->app_core->suspended_state = true;
137 _DBG("[__SUSPEND__]");
140 static void __appcore_efl_exit_from_suspend(void *data)
142 struct ui_priv *ui = (struct ui_priv *)data;
143 struct sys_op *op = NULL;
144 int suspend = APPCORE_SUSPENDED_STATE_DID_EXIT_FROM_SUSPEND;
146 if (ui->app_core && !ui->app_core->allowed_bg && ui->app_core->suspended_state) {
147 op = &ui->app_core->sops[SE_SUSPENDED_STATE];
149 op->func((void *)&suspend, op->data); /* calls c-api handler */
151 ui->app_core->suspended_state = false;
153 _DBG("[__SUSPEND__]");
157 #if defined(MEMORY_FLUSH_ACTIVATE)
158 static Eina_Bool __appcore_memory_flush_cb(void *data)
160 struct ui_priv *ui = (struct ui_priv *)data;
162 appcore_flush_memory();
166 #ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
167 if (ui && ui->prepare_to_suspend) {
168 _DBG("[__SUSPEND__] flush case");
169 ui->prepare_to_suspend(ui);
173 return ECORE_CALLBACK_CANCEL;
176 static int __appcore_low_memory_post_cb(struct ui_priv *ui)
178 if (ui->state == AS_PAUSED)
179 appcore_flush_memory();
186 static void __appcore_timer_add(struct ui_priv *ui)
188 ui->mftimer = ecore_timer_add(5, __appcore_memory_flush_cb, ui);
191 static void __appcore_timer_del(struct ui_priv *ui)
194 ecore_timer_del(ui->mftimer);
201 static int __appcore_low_memory_post_cb(ui_priv *ui)
206 #define __appcore_timer_add(ui) 0
207 #define __appcore_timer_del(ui) 0
211 static void __appcore_efl_memory_flush_cb(void)
213 _DBG("[APP %d] __appcore_efl_memory_flush_cb()", _pid);
214 elm_cache_all_flush();
217 static void wl_raise_win(void)
219 Ecore_Wl_Window *win;
220 unsigned int win_id = appcore_get_main_window();
222 _DBG("Raise window: %d", win_id);
223 win = ecore_wl_window_find(win_id);
224 ecore_wl_window_activate(win);
227 static void wl_pause_win(void)
229 Ecore_Wl_Window *win;
230 GSList *wlist = g_winnode_list;
231 struct win_node *entry = NULL;
233 _DBG("Pause window");
238 _DBG("Pause window: %d", entry->win);
239 win = ecore_wl_window_find(entry->win);
240 ecore_wl_window_iconified_set(win, EINA_TRUE);
248 static void __do_app(enum app_event event, void *data, bundle * b)
251 struct ui_priv *ui = data;
253 _DBG("[APP %d] Event: %d", _pid, event);
254 _ret_if(ui == NULL || event >= AE_MAX);
255 _DBG("[APP %d] Event: %s State: %s", _pid, _ae_name[event],
256 _as_name[ui->state]);
258 if (event == AE_MEM_FLUSH) {
263 if (event == AE_LOWMEM_POST) {
264 if (__appcore_low_memory_post_cb(ui) == 0)
268 if (!(ui->state == AS_PAUSED && event == AE_PAUSE))
269 __appcore_timer_del(ui);
271 if (ui->state == AS_DYING) {
272 _ERR("Skip the event in dying state");
276 if (event == AE_TERMINATE) {
277 _DBG("[APP %d] TERMINATE", _pid);
279 aul_status_update(STATUS_DYING);
283 if (event == AE_RAISE) {
285 x_raise_win(getpid());
286 #elif defined(WAYLAND)
292 if (event == AE_LOWER) {
294 x_pause_win(getpid());
295 #elif defined(WAYLAND)
301 _ret_if(ui->ops == NULL);
305 _DBG("[APP %d] RESET", _pid);
306 ui->pending_data = bundle_dup(b);
307 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:reset:start]", ui->name);
309 #ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
310 if (ui->exit_from_suspend) {
311 _DBG("[__SUSPEND__] reset case");
312 ui->exit_from_suspend(ui);
316 if (ui->ops->reset) {
317 traceBegin(TTRACE_TAG_APPLICATION_MANAGER,
319 r = ui->ops->reset(b, ui->ops->data);
320 traceEnd(TTRACE_TAG_APPLICATION_MANAGER);
322 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:reset:done]", ui->name);
325 first_launch = FALSE;
327 _INFO("[APP %d] App already running, raise the window", _pid);
329 x_raise_win(getpid());
334 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:reset:done]",
338 if (ui->state == AS_RUNNING) {
339 _DBG("[APP %d] PAUSE", _pid);
340 if (ui->ops->pause) {
341 traceBegin(TTRACE_TAG_APPLICATION_MANAGER,
343 r = ui->ops->pause(ui->ops->data);
344 traceEnd(TTRACE_TAG_APPLICATION_MANAGER);
346 ui->state = AS_PAUSED;
347 if (r >= 0 && resource_reclaiming == TRUE)
348 __appcore_timer_add(ui);
349 #ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
350 else if (r >= 0 && resource_reclaiming == FALSE
351 && ui->prepare_to_suspend) {
352 _DBG("[__SUSPEND__] pause case");
353 ui->prepare_to_suspend(ui);
357 /* TODO : rotation stop */
358 /* r = appcore_pause_rotation_cb(); */
359 aul_status_update(STATUS_BG);
362 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:resume:start]",
364 #ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
365 if (ui->exit_from_suspend) {
366 _DBG("[__SUSPEND__] resume case");
367 ui->exit_from_suspend(ui);
371 if (ui->state == AS_PAUSED || ui->state == AS_CREATED) {
372 _DBG("[APP %d] RESUME", _pid);
374 if (ui->state == AS_CREATED) {
375 bundle_free(ui->pending_data);
376 ui->pending_data = NULL;
379 if (ui->ops->resume) {
380 traceBegin(TTRACE_TAG_APPLICATION_MANAGER,
382 ui->ops->resume(ui->ops->data);
383 traceEnd(TTRACE_TAG_APPLICATION_MANAGER);
385 ui->state = AS_RUNNING;
387 /*TODO : rotation start*/
388 /* r = appcore_resume_rotation_cb(); */
389 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:resume:done]",
391 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:Launching:done]",
393 aul_status_update(STATUS_VISIBLE);
395 case AE_TERMINATE_BGAPP:
396 if (ui->state == AS_PAUSED) {
397 _DBG("[APP %d] is paused. TERMINATE", _pid);
398 ui->state = AS_DYING;
399 aul_status_update(STATUS_DYING);
401 } else if (ui->state == AS_RUNNING) {
402 _DBG("[APP %d] is running.", _pid);
404 _DBG("[APP %d] is another state", _pid);
413 static struct ui_ops efl_ops = {
418 static bool __check_visible(void)
421 struct win_node *entry = NULL;
423 _DBG("[EVENT_TEST][EVENT] __check_visible\n");
425 for (iter = g_winnode_list; iter != NULL; iter = g_slist_next(iter)) {
427 _DBG("win : %x obscured : %d\n", entry->win, entry->bfobscured);
428 if (entry->bfobscured == FALSE)
435 static GSList *__find_win(unsigned int win)
440 for (iter = g_winnode_list; iter; iter = g_slist_next(iter)) {
442 if (t && t->win == win)
450 static bool __add_win(unsigned int win)
455 _DBG("[EVENT_TEST][EVENT] __add_win WIN:%x\n", win);
460 _DBG("[EVENT_TEST][EVENT] ERROR There is already window : %x \n", win);
464 t = calloc(1, sizeof(struct win_node));
469 t->bfobscured = FALSE;
471 g_winnode_list = g_slist_append(g_winnode_list, t);
475 #elif defined(WAYLAND)
476 static bool __add_win(unsigned int win, unsigned int surf)
481 _DBG("[EVENT_TEST][EVENT] __add_win WIN:%x\n", win);
486 _DBG("[EVENT_TEST][EVENT] ERROR There is already window : %x \n", win);
490 t = calloc(1, sizeof(struct win_node));
496 t->bfobscured = FALSE;
498 g_winnode_list = g_slist_append(g_winnode_list, t);
504 static bool __delete_win(unsigned int win)
511 _DBG("[EVENT_TEST][EVENT] ERROR There is no window : %x \n",
517 g_winnode_list = g_slist_delete_link(g_winnode_list, f);
523 static bool __update_win(unsigned int win, bool bfobscured)
528 _DBG("[EVENT_TEST][EVENT] __update_win WIN:%x fully_obscured %d\n", win,
534 _DBG("[EVENT_TEST][EVENT] ERROR There is no window : %x \n", win);
538 g_winnode_list = g_slist_remove_link(g_winnode_list, f);
540 t = (struct win_node *)f->data;
542 t->bfobscured = bfobscured;
544 g_winnode_list = g_slist_concat(g_winnode_list, f);
548 #elif defined(WAYLAND)
549 static bool __update_win(unsigned int win, unsigned int surf, bool bfobscured)
554 _DBG("[EVENT_TEST][EVENT] __update_win WIN:%x fully_obscured %d\n", win,
560 _DBG("[EVENT_TEST][EVENT] ERROR There is no window : %x \n", win);
564 g_winnode_list = g_slist_remove_link(g_winnode_list, f);
566 t = (struct win_node *)f->data;
570 t->bfobscured = bfobscured;
572 g_winnode_list = g_slist_concat(g_winnode_list, f);
580 static Ecore_X_Atom _WM_WINDOW_ROTATION_SUPPORTED = 0;
581 static Ecore_X_Atom _WM_WINDOW_ROTATION_CHANGE_REQUEST = 0;
583 static int __check_wm_rotation_support(void)
585 _DBG("Disable window manager rotation");
588 Ecore_X_Window root, win, win2;
591 if (!_WM_WINDOW_ROTATION_SUPPORTED) {
592 _WM_WINDOW_ROTATION_SUPPORTED =
593 ecore_x_atom_get("_E_WINDOW_ROTATION_SUPPORTED");
596 if (!_WM_WINDOW_ROTATION_CHANGE_REQUEST) {
597 _WM_WINDOW_ROTATION_CHANGE_REQUEST =
598 ecore_x_atom_get("_E_WINDOW_ROTATION_CHANGE_REQUEST");
601 root = ecore_x_window_root_first_get();
602 ret = ecore_x_window_prop_xid_get(root,
603 _WM_WINDOW_ROTATION_SUPPORTED,
606 if ((ret == 1) && (win)) {
607 ret = ecore_x_window_prop_xid_get(win,
608 _WM_WINDOW_ROTATION_SUPPORTED,
611 if ((ret == 1) && (win2 == win))
618 static void __set_wm_rotation_support(unsigned int win, unsigned int set)
621 struct win_node *entry = NULL;
624 for (iter = g_winnode_list; iter != NULL; iter = g_slist_next(iter)) {
627 ecore_x_window_prop_card32_set(entry->win,
628 _WM_WINDOW_ROTATION_SUPPORTED,
633 ecore_x_window_prop_card32_set(win,
634 _WM_WINDOW_ROTATION_SUPPORTED,
640 static Eina_Bool __show_cb(void *data, int type, void *event)
643 Ecore_Wl_Event_Window_Show *ev;
646 if (ev->parent_win != 0) {
647 /* This is child window. Skip!!! */
648 return ECORE_CALLBACK_PASS_ON;
651 _DBG("[EVENT_TEST][EVENT] GET SHOW EVENT!!!. WIN:%x, %d\n", ev->win, ev->data[0]);
653 if (!__find_win((unsigned int)ev->win))
654 __add_win((unsigned int)ev->win, (unsigned int)ev->data[0]);
656 __update_win((unsigned int)ev->win, (unsigned int)ev->data[0], FALSE);
659 Ecore_X_Event_Window_Show *ev;
663 _DBG("[EVENT_TEST][EVENT] GET SHOW EVENT!!!. WIN:%x\n", ev->win);
665 if (!__find_win((unsigned int)ev->win)) {
667 if ((priv.wm_rot_supported) && (1 == priv.rot_started))
668 __set_wm_rotation_support(ev->win, 1);
669 __add_win((unsigned int)ev->win);
671 __update_win((unsigned int)ev->win, FALSE);
675 appcore_group_attach();
676 return ECORE_CALLBACK_RENEW;
679 static Eina_Bool __hide_cb(void *data, int type, void *event)
682 Ecore_Wl_Event_Window_Hide *ev;
684 Ecore_X_Event_Window_Hide *ev;
690 _DBG("[EVENT_TEST][EVENT] GET HIDE EVENT!!!. WIN:%x\n", ev->win);
692 if (__find_win((unsigned int)ev->win)) {
693 __delete_win((unsigned int)ev->win);
694 bvisibility = __check_visible();
695 if (!bvisibility && b_active == TRUE) {
696 _DBG(" Go to Pasue state \n");
698 __do_app(AE_PAUSE, data, NULL);
702 return ECORE_CALLBACK_RENEW;
706 static Eina_Bool __lower_cb(void *data, int type, void *event)
708 Ecore_Wl_Event_Window_Lower *ev;
710 if (!ev) return ECORE_CALLBACK_RENEW;
711 _DBG("ECORE_WL_EVENT_WINDOW_LOWER window id:%u\n", ev->win);
712 appcore_group_lower();
713 return ECORE_CALLBACK_RENEW;
717 static Eina_Bool __visibility_cb(void *data, int type, void *event)
720 Ecore_Wl_Event_Window_Visibility_Change *ev;
723 __update_win((unsigned int)ev->win, 0, ev->fully_obscured);
725 Ecore_X_Event_Window_Visibility_Change *ev;
730 __update_win((unsigned int)ev->win, ev->fully_obscured);
732 bvisibility = __check_visible();
734 _DBG("bvisibility %d, b_active %d", bvisibility, b_active);
736 if (bvisibility && b_active == FALSE) {
737 _DBG(" Go to Resume state\n");
739 __do_app(AE_RESUME, data, NULL);
741 } else if (!bvisibility && b_active == TRUE) {
742 _DBG(" Go to Pasue state \n");
744 __do_app(AE_PAUSE, data, NULL);
746 _DBG(" No change state \n");
748 return ECORE_CALLBACK_RENEW;
754 static Eina_Bool __cmsg_cb(void *data, int type, void *event)
756 struct ui_priv *ui = (struct ui_priv *)data;
757 Ecore_X_Event_Client_Message *e = event;
760 return ECORE_CALLBACK_PASS_ON;
763 return ECORE_CALLBACK_PASS_ON;
765 if (e->message_type == _WM_WINDOW_ROTATION_CHANGE_REQUEST) {
766 if ((ui->wm_rot_supported == 0)
767 || (ui->rot_started == 0)
768 || (ui->rot_cb == NULL)) {
769 return ECORE_CALLBACK_PASS_ON;
773 switch (e->data.l[1]) {
775 rm = APPCORE_RM_PORTRAIT_NORMAL;
778 rm = APPCORE_RM_LANDSCAPE_REVERSE;
781 rm = APPCORE_RM_PORTRAIT_REVERSE;
784 rm = APPCORE_RM_LANDSCAPE_NORMAL;
787 rm = APPCORE_RM_UNKNOWN;
793 if (APPCORE_RM_UNKNOWN != rm)
794 ui->rot_cb((void *)&rm, rm, ui->rot_cb_data);
797 return ECORE_CALLBACK_PASS_ON;
801 static void __add_climsg_cb(struct ui_priv *ui)
806 ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_SHOW, __show_cb, ui);
808 ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_HIDE, __hide_cb, ui);
810 ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_VISIBILITY_CHANGE,
811 __visibility_cb, ui);
813 ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_LOWER,
817 ecore_event_handler_add(ECORE_X_EVENT_WINDOW_SHOW, __show_cb, ui);
819 ecore_event_handler_add(ECORE_X_EVENT_WINDOW_HIDE, __hide_cb, ui);
821 ecore_event_handler_add(ECORE_X_EVENT_WINDOW_VISIBILITY_CHANGE,
822 __visibility_cb, ui);
824 /* Add client message callback for WM_ROTATE */
825 if (!__check_wm_rotation_support()) {
826 ui->hcmsg = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE,
828 ui->wm_rot_supported = 1;
829 appcore_set_wm_rotation(&wm_rotate);
834 static int __before_loop(struct ui_priv *ui, int *argc, char ***argv)
839 if (argc == NULL || argv == NULL) {
840 _ERR("argc/argv is NULL");
845 #if !(GLIB_CHECK_VERSION(2, 36, 0))
848 elm_init(*argc, *argv);
850 hwacc = getenv("HWACC");
852 _DBG("elm_config_accel_preference_set is not called");
853 } else if (strcmp(hwacc, "USE") == 0) {
854 elm_config_accel_preference_set("hw");
855 _DBG("elm_config_accel_preference_set : hw");
856 } else if (strcmp(hwacc, "NOT_USE") == 0) {
857 elm_config_accel_preference_set("none");
858 _DBG("elm_config_accel_preference_set : none");
860 _DBG("elm_config_accel_preference_set is not called");
863 r = appcore_init(ui->name, &efl_ops, *argc, *argv);
864 _retv_if(r == -1, -1);
866 #if _APPFW_FEATURE_BACKGROUND_MANAGEMENT
867 appcore_get_app_core(&ac);
869 SECURE_LOGD("[__SUSPEND__] appcore initialized, appcore addr: 0x%x", ac);
872 LOG(LOG_DEBUG, "LAUNCH", "[%s:Platform:appcore_init:done]", ui->name);
873 if (ui->ops && ui->ops->create) {
874 traceBegin(TTRACE_TAG_APPLICATION_MANAGER, "APPCORE:CREATE");
875 r = ui->ops->create(ui->ops->data);
876 traceEnd(TTRACE_TAG_APPLICATION_MANAGER);
878 _ERR("create() return error");
880 if (ui->ops && ui->ops->terminate) {
881 traceBegin(TTRACE_TAG_APPLICATION_MANAGER,
882 "APPCORE:TERMINATE");
883 ui->ops->terminate(ui->ops->data);
884 traceEnd(TTRACE_TAG_APPLICATION_MANAGER);
889 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:create:done]",
892 ui->state = AS_CREATED;
899 static void __after_loop(struct ui_priv *ui)
901 appcore_unset_rotation_cb();
904 if (ui->state == AS_RUNNING) {
905 _DBG("[APP %d] PAUSE before termination", _pid);
906 if (ui->ops && ui->ops->pause) {
907 traceBegin(TTRACE_TAG_APPLICATION_MANAGER,
909 ui->ops->pause(ui->ops->data);
910 traceEnd(TTRACE_TAG_APPLICATION_MANAGER);
914 if (ui->ops && ui->ops->terminate) {
915 traceBegin(TTRACE_TAG_APPLICATION_MANAGER, "APPCORE:TERMINATE");
916 ui->ops->terminate(ui->ops->data);
917 traceEnd(TTRACE_TAG_APPLICATION_MANAGER);
920 ui->state = AS_DYING;
923 ecore_event_handler_del(ui->hshow);
925 ecore_event_handler_del(ui->hhide);
927 ecore_event_handler_del(ui->hvchange);
930 ecore_event_handler_del(ui->hlower);
933 __appcore_timer_del(ui);
938 static int __set_data(struct ui_priv *ui, const char *name,
939 struct appcore_ops *ops)
942 _ERR("Mainloop already started");
947 if (name == NULL || name[0] == '\0') {
948 _ERR("Invalid name");
959 ui->name = strdup(name);
960 _retv_if(ui->name == NULL, -1);
963 ui->mfcb = __appcore_efl_memory_flush_cb;
967 ui->wm_rot_supported = 0;
970 ui->rot_cb_data = NULL;
971 ui->rot_mode = APPCORE_RM_UNKNOWN;
973 #ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
975 ui->prepare_to_suspend = __appcore_efl_prepare_to_suspend;
976 ui->exit_from_suspend = __appcore_efl_exit_from_suspend;
982 static void __unset_data(struct ui_priv *ui)
985 free((void *)ui->name);
987 memset(ui, 0, sizeof(struct ui_priv));
992 static int __wm_set_rotation_cb(int (*cb) (void *event_info, enum appcore_rm, void *), void *data)
999 if ((priv.wm_rot_supported) && (0 == priv.rot_started))
1000 __set_wm_rotation_support(0, 1);
1003 priv.rot_cb_data = data;
1004 priv.rot_started = 1;
1009 static int __wm_unset_rotation_cb(void)
1011 if ((priv.wm_rot_supported) && (1 == priv.rot_started))
1012 __set_wm_rotation_support(0, 0);
1015 priv.rot_cb_data = NULL;
1016 priv.rot_started = 0;
1021 static int __wm_get_rotation_state(enum appcore_rm *curr)
1028 *curr = priv.rot_mode;
1033 static int __wm_pause_rotation_cb(void)
1035 if ((priv.rot_started == 1) && (priv.wm_rot_supported))
1036 __set_wm_rotation_support(0, 0);
1038 priv.rot_started = 0;
1043 static int __wm_resume_rotation_cb(void)
1045 if ((priv.rot_started == 0) && (priv.wm_rot_supported))
1046 __set_wm_rotation_support(0, 1);
1048 priv.rot_started = 1;
1053 static struct ui_wm_rotate wm_rotate = {
1054 __wm_set_rotation_cb,
1055 __wm_unset_rotation_cb,
1056 __wm_get_rotation_state,
1057 __wm_pause_rotation_cb,
1058 __wm_resume_rotation_cb
1062 EXPORT_API int appcore_efl_init(const char *name, int *argc, char ***argv,
1063 struct appcore_ops *ops)
1067 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:main:done]", name);
1069 r = __set_data(&priv, name, ops);
1070 _retv_if(r == -1, -1);
1072 r = __before_loop(&priv, argc, argv);
1074 aul_status_update(STATUS_DYING);
1075 __unset_data(&priv);
1082 EXPORT_API void appcore_efl_fini(void)
1084 aul_status_update(STATUS_DYING);
1086 __after_loop(&priv);
1088 __unset_data(&priv);
1091 EXPORT_API int appcore_efl_main(const char *name, int *argc, char ***argv,
1092 struct appcore_ops *ops)
1096 r = appcore_efl_init(name, argc, argv, ops);
1097 _retv_if(r == -1, -1);
1106 EXPORT_API int appcore_set_system_resource_reclaiming(bool enable)
1108 resource_reclaiming = enable;
1113 EXPORT_API int appcore_set_app_state(int state)
1122 EXPORT_API int appcore_set_preinit_window_name(const char *win_name)
1125 void *preinit_window = NULL;
1126 const Evas *e = NULL;
1129 _ERR("invalid parameter");
1133 preinit_window = aul_get_preinit_window(win_name);
1134 if (!preinit_window) {
1135 _ERR("Failed to get preinit window");
1139 e = evas_object_evas_get((const Evas_Object *)preinit_window);
1141 Ecore_Evas *ee = ecore_evas_ecore_evas_get(e);
1143 ecore_evas_name_class_set(ee, win_name, win_name);
1151 EXPORT_API unsigned int appcore_get_main_window(void)
1153 struct win_node *entry = NULL;
1155 if (g_winnode_list != NULL) {
1156 entry = g_winnode_list->data;
1157 return (unsigned int) entry->win;
1163 #if defined(WAYLAND)
1164 EXPORT_API unsigned int appcore_get_main_surface(void)
1166 struct win_node *entry = NULL;
1168 if (g_winnode_list != NULL) {
1169 entry = g_winnode_list->data;
1170 return (unsigned int) entry->surf;