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>
46 #include <bundle_internal.h>
49 #include "appcore-internal.h"
50 #include "appcore-efl.h"
53 static bool resource_reclaiming = TRUE;
54 static int tmp_val = 0;
60 Ecore_Event_Handler *hshow;
61 Ecore_Event_Handler *hhide;
62 Ecore_Event_Handler *hvchange;
64 Ecore_Event_Handler *hlower;
66 Ecore_Event_Handler *hcmsg; /* WM_ROTATE */
68 Ecore_Timer *mftimer; /* Ecore Timer for memory flushing */
70 #ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
71 struct appcore *app_core;
72 void (*prepare_to_suspend) (void *data);
73 void (*exit_from_suspend) (void *data);
75 struct appcore_ops *ops;
76 void (*mfcb) (void); /* Memory Flushing Callback */
81 int (*rot_cb) (void *event_info, enum appcore_rm, void *);
83 enum appcore_rm rot_mode;
88 static struct ui_priv priv;
90 static const char *_ae_name[AE_MAX] = {
91 [AE_UNKNOWN] = "UNKNOWN",
92 [AE_CREATE] = "CREATE",
93 [AE_TERMINATE] = "TERMINATE",
95 [AE_RESUME] = "RESUME",
97 [AE_LOWMEM_POST] = "LOWMEM_POST",
98 [AE_MEM_FLUSH] = "MEM_FLUSH",
101 static const char *_as_name[] = {
103 [AS_CREATED] = "CREATED",
104 [AS_RUNNING] = "RUNNING",
105 [AS_PAUSED] = "PAUSED",
106 [AS_DYING] = "DYING",
109 static bool b_active = FALSE;
110 static bool first_launch = TRUE;
121 static struct ui_wm_rotate wm_rotate;
123 static Eina_Bool __visibility_cb(void *data, int type, void *event);
124 static GSList *g_winnode_list;
126 #ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
127 static void __appcore_efl_prepare_to_suspend(void *data)
129 struct ui_priv *ui = (struct ui_priv *)data;
130 struct sys_op *op = NULL;
131 int suspend = APPCORE_SUSPENDED_STATE_WILL_ENTER_SUSPEND;
133 if (ui->app_core && !ui->app_core->allowed_bg && !ui->app_core->suspended_state) {
134 op = &ui->app_core->sops[SE_SUSPENDED_STATE];
136 op->func((void *)&suspend, op->data); /* calls c-api handler */
138 ui->app_core->suspended_state = true;
140 _DBG("[__SUSPEND__]");
143 static void __appcore_efl_exit_from_suspend(void *data)
145 struct ui_priv *ui = (struct ui_priv *)data;
146 struct sys_op *op = NULL;
147 int suspend = APPCORE_SUSPENDED_STATE_DID_EXIT_FROM_SUSPEND;
149 if (ui->app_core && !ui->app_core->allowed_bg && ui->app_core->suspended_state) {
150 op = &ui->app_core->sops[SE_SUSPENDED_STATE];
152 op->func((void *)&suspend, op->data); /* calls c-api handler */
154 ui->app_core->suspended_state = false;
156 _DBG("[__SUSPEND__]");
160 #if defined(MEMORY_FLUSH_ACTIVATE)
161 static Eina_Bool __appcore_memory_flush_cb(void *data)
163 struct ui_priv *ui = (struct ui_priv *)data;
165 appcore_flush_memory();
169 #ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
170 if (ui && ui->prepare_to_suspend) {
171 _DBG("[__SUSPEND__] flush case");
172 ui->prepare_to_suspend(ui);
176 return ECORE_CALLBACK_CANCEL;
179 static int __appcore_low_memory_post_cb(struct ui_priv *ui)
181 if (ui->state == AS_PAUSED)
182 appcore_flush_memory();
189 static void __appcore_timer_add(struct ui_priv *ui)
191 ui->mftimer = ecore_timer_add(5, __appcore_memory_flush_cb, ui);
194 static void __appcore_timer_del(struct ui_priv *ui)
197 ecore_timer_del(ui->mftimer);
204 static int __appcore_low_memory_post_cb(ui_priv *ui)
209 #define __appcore_timer_add(ui) 0
210 #define __appcore_timer_del(ui) 0
214 static void __appcore_efl_memory_flush_cb(void)
216 _DBG("[APP %d] __appcore_efl_memory_flush_cb()", _pid);
217 elm_cache_all_flush();
220 static void wl_raise_win(void)
222 Ecore_Wl_Window *win;
223 unsigned int win_id = appcore_get_main_window();
225 _DBG("Raise window: %d", win_id);
226 win = ecore_wl_window_find(win_id);
227 ecore_wl_window_activate(win);
230 static void wl_pause_win(void)
232 Ecore_Wl_Window *win;
233 GSList *wlist = g_winnode_list;
234 struct win_node *entry = NULL;
236 _DBG("Pause window");
241 _DBG("Pause window: %d", entry->win);
242 win = ecore_wl_window_find(entry->win);
243 ecore_wl_window_iconified_set(win, EINA_TRUE);
251 static void __do_app(enum app_event event, void *data, bundle * b)
254 struct ui_priv *ui = data;
255 const char *below_app;
257 _DBG("[APP %d] Event: %d", _pid, event);
258 _ret_if(ui == NULL || event >= AE_MAX);
259 _DBG("[APP %d] Event: %s State: %s", _pid, _ae_name[event],
260 _as_name[ui->state]);
262 if (event == AE_MEM_FLUSH) {
267 if (event == AE_LOWMEM_POST) {
268 if (__appcore_low_memory_post_cb(ui) == 0)
272 if (!(ui->state == AS_PAUSED && event == AE_PAUSE))
273 __appcore_timer_del(ui);
275 if (ui->state == AS_DYING) {
276 _ERR("Skip the event in dying state");
280 if (event == AE_TERMINATE) {
281 _DBG("[APP %d] TERMINATE", _pid);
283 aul_status_update(STATUS_DYING);
287 if (event == AE_RAISE) {
289 x_raise_win(getpid());
290 #elif defined(WAYLAND)
296 if (event == AE_LOWER) {
298 x_pause_win(getpid());
299 #elif defined(WAYLAND)
305 _ret_if(ui->ops == NULL);
309 _DBG("[APP %d] RESET", _pid);
310 ui->pending_data = bundle_dup(b);
311 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:reset:start]", ui->name);
315 ui->below_app = NULL;
318 below_app = bundle_get_val(b, AUL_SVC_K_RELOCATE_BELOW);
320 ui->below_app = strdup(below_app);
321 #ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
322 if (ui->exit_from_suspend) {
323 _DBG("[__SUSPEND__] reset case");
324 ui->exit_from_suspend(ui);
328 if (ui->ops->reset) {
329 traceBegin(TTRACE_TAG_APPLICATION_MANAGER,
331 r = ui->ops->reset(b, ui->ops->data);
332 traceEnd(TTRACE_TAG_APPLICATION_MANAGER);
334 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:reset:done]", ui->name);
337 first_launch = FALSE;
339 _INFO("[APP %d] App already running, raise the window", _pid);
341 x_raise_win(getpid());
346 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:reset:done]",
350 if (ui->state == AS_RUNNING) {
351 _DBG("[APP %d] PAUSE", _pid);
352 if (ui->ops->pause) {
353 traceBegin(TTRACE_TAG_APPLICATION_MANAGER,
355 r = ui->ops->pause(ui->ops->data);
356 traceEnd(TTRACE_TAG_APPLICATION_MANAGER);
358 ui->state = AS_PAUSED;
359 if (r >= 0 && resource_reclaiming == TRUE)
360 __appcore_timer_add(ui);
361 #ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
362 else if (r >= 0 && resource_reclaiming == FALSE
363 && ui->prepare_to_suspend) {
364 _DBG("[__SUSPEND__] pause case");
365 ui->prepare_to_suspend(ui);
369 /* TODO : rotation stop */
370 /* r = appcore_pause_rotation_cb(); */
371 aul_status_update(STATUS_BG);
374 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:resume:start]",
376 #ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
377 if (ui->exit_from_suspend) {
378 _DBG("[__SUSPEND__] resume case");
379 ui->exit_from_suspend(ui);
383 if (ui->state == AS_PAUSED || ui->state == AS_CREATED) {
384 _DBG("[APP %d] RESUME", _pid);
386 if (ui->state == AS_CREATED) {
387 bundle_free(ui->pending_data);
388 ui->pending_data = NULL;
391 if (ui->ops->resume) {
392 traceBegin(TTRACE_TAG_APPLICATION_MANAGER,
394 ui->ops->resume(ui->ops->data);
395 traceEnd(TTRACE_TAG_APPLICATION_MANAGER);
397 ui->state = AS_RUNNING;
400 aul_app_group_activate_below(ui->below_app);
402 ui->below_app = NULL;
405 /*TODO : rotation start*/
406 /* r = appcore_resume_rotation_cb(); */
407 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:resume:done]",
409 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:Launching:done]",
411 aul_status_update(STATUS_VISIBLE);
413 case AE_TERMINATE_BGAPP:
414 if (ui->state == AS_PAUSED) {
415 _DBG("[APP %d] is paused. TERMINATE", _pid);
416 ui->state = AS_DYING;
417 aul_status_update(STATUS_DYING);
419 } else if (ui->state == AS_RUNNING) {
420 _DBG("[APP %d] is running.", _pid);
422 _DBG("[APP %d] is another state", _pid);
431 static struct ui_ops efl_ops = {
436 static bool __check_visible(void)
439 struct win_node *entry = NULL;
441 _DBG("[EVENT_TEST][EVENT] __check_visible\n");
443 for (iter = g_winnode_list; iter != NULL; iter = g_slist_next(iter)) {
445 _DBG("win : %x obscured : %d\n", entry->win, entry->bfobscured);
446 if (entry->bfobscured == FALSE)
453 static GSList *__find_win(unsigned int win)
458 for (iter = g_winnode_list; iter; iter = g_slist_next(iter)) {
460 if (t && t->win == win)
468 static bool __add_win(unsigned int win)
473 _DBG("[EVENT_TEST][EVENT] __add_win WIN:%x\n", win);
478 _DBG("[EVENT_TEST][EVENT] ERROR There is already window : %x \n", win);
482 t = calloc(1, sizeof(struct win_node));
487 t->bfobscured = FALSE;
489 g_winnode_list = g_slist_append(g_winnode_list, t);
493 #elif defined(WAYLAND)
494 static bool __add_win(unsigned int win, unsigned int surf)
499 _DBG("[EVENT_TEST][EVENT] __add_win WIN:%x\n", win);
504 _DBG("[EVENT_TEST][EVENT] ERROR There is already window : %x \n", win);
508 t = calloc(1, sizeof(struct win_node));
514 t->bfobscured = FALSE;
516 g_winnode_list = g_slist_append(g_winnode_list, t);
522 static bool __delete_win(unsigned int win)
529 _DBG("[EVENT_TEST][EVENT] ERROR There is no window : %x \n",
535 g_winnode_list = g_slist_delete_link(g_winnode_list, f);
541 static bool __update_win(unsigned int win, bool bfobscured)
546 _DBG("[EVENT_TEST][EVENT] __update_win WIN:%x fully_obscured %d\n", win,
552 _DBG("[EVENT_TEST][EVENT] ERROR There is no window : %x \n", win);
556 g_winnode_list = g_slist_remove_link(g_winnode_list, f);
558 t = (struct win_node *)f->data;
560 t->bfobscured = bfobscured;
562 g_winnode_list = g_slist_concat(g_winnode_list, f);
566 #elif defined(WAYLAND)
567 static bool __update_win(unsigned int win, unsigned int surf, bool bfobscured)
572 _DBG("[EVENT_TEST][EVENT] __update_win WIN:%x fully_obscured %d\n", win,
578 _DBG("[EVENT_TEST][EVENT] ERROR There is no window : %x \n", win);
582 g_winnode_list = g_slist_remove_link(g_winnode_list, f);
584 t = (struct win_node *)f->data;
588 t->bfobscured = bfobscured;
590 g_winnode_list = g_slist_concat(g_winnode_list, f);
598 static Ecore_X_Atom _WM_WINDOW_ROTATION_SUPPORTED = 0;
599 static Ecore_X_Atom _WM_WINDOW_ROTATION_CHANGE_REQUEST = 0;
601 static int __check_wm_rotation_support(void)
603 _DBG("Disable window manager rotation");
606 Ecore_X_Window root, win, win2;
609 if (!_WM_WINDOW_ROTATION_SUPPORTED) {
610 _WM_WINDOW_ROTATION_SUPPORTED =
611 ecore_x_atom_get("_E_WINDOW_ROTATION_SUPPORTED");
614 if (!_WM_WINDOW_ROTATION_CHANGE_REQUEST) {
615 _WM_WINDOW_ROTATION_CHANGE_REQUEST =
616 ecore_x_atom_get("_E_WINDOW_ROTATION_CHANGE_REQUEST");
619 root = ecore_x_window_root_first_get();
620 ret = ecore_x_window_prop_xid_get(root,
621 _WM_WINDOW_ROTATION_SUPPORTED,
624 if ((ret == 1) && (win)) {
625 ret = ecore_x_window_prop_xid_get(win,
626 _WM_WINDOW_ROTATION_SUPPORTED,
629 if ((ret == 1) && (win2 == win))
636 static void __set_wm_rotation_support(unsigned int win, unsigned int set)
639 struct win_node *entry = NULL;
642 for (iter = g_winnode_list; iter != NULL; iter = g_slist_next(iter)) {
645 ecore_x_window_prop_card32_set(entry->win,
646 _WM_WINDOW_ROTATION_SUPPORTED,
651 ecore_x_window_prop_card32_set(win,
652 _WM_WINDOW_ROTATION_SUPPORTED,
658 static Eina_Bool __show_cb(void *data, int type, void *event)
661 Ecore_Wl_Event_Window_Show *ev;
664 if (ev->parent_win != 0) {
665 /* This is child window. Skip!!! */
666 return ECORE_CALLBACK_PASS_ON;
669 _DBG("[EVENT_TEST][EVENT] GET SHOW EVENT!!!. WIN:%x, %d\n", ev->win, ev->data[0]);
671 if (!__find_win((unsigned int)ev->win))
672 __add_win((unsigned int)ev->win, (unsigned int)ev->data[0]);
674 __update_win((unsigned int)ev->win, (unsigned int)ev->data[0], FALSE);
677 Ecore_X_Event_Window_Show *ev;
681 _DBG("[EVENT_TEST][EVENT] GET SHOW EVENT!!!. WIN:%x\n", ev->win);
683 if (!__find_win((unsigned int)ev->win)) {
685 if ((priv.wm_rot_supported) && (1 == priv.rot_started))
686 __set_wm_rotation_support(ev->win, 1);
687 __add_win((unsigned int)ev->win);
689 __update_win((unsigned int)ev->win, FALSE);
693 appcore_group_attach();
694 return ECORE_CALLBACK_RENEW;
697 static Eina_Bool __hide_cb(void *data, int type, void *event)
700 Ecore_Wl_Event_Window_Hide *ev;
702 Ecore_X_Event_Window_Hide *ev;
708 _DBG("[EVENT_TEST][EVENT] GET HIDE EVENT!!!. WIN:%x\n", ev->win);
710 if (__find_win((unsigned int)ev->win)) {
711 __delete_win((unsigned int)ev->win);
712 bvisibility = __check_visible();
713 if (!bvisibility && b_active == TRUE) {
714 _DBG(" Go to Pasue state \n");
716 __do_app(AE_PAUSE, data, NULL);
720 return ECORE_CALLBACK_RENEW;
724 static Eina_Bool __lower_cb(void *data, int type, void *event)
726 Ecore_Wl_Event_Window_Lower *ev;
728 if (!ev) return ECORE_CALLBACK_RENEW;
729 _DBG("ECORE_WL_EVENT_WINDOW_LOWER window id:%u\n", ev->win);
730 appcore_group_lower();
731 return ECORE_CALLBACK_RENEW;
735 static Eina_Bool __visibility_cb(void *data, int type, void *event)
738 Ecore_Wl_Event_Window_Visibility_Change *ev;
741 __update_win((unsigned int)ev->win, 0, ev->fully_obscured);
743 Ecore_X_Event_Window_Visibility_Change *ev;
748 __update_win((unsigned int)ev->win, ev->fully_obscured);
750 bvisibility = __check_visible();
752 _DBG("bvisibility %d, b_active %d", bvisibility, b_active);
754 if (bvisibility && b_active == FALSE) {
755 _DBG(" Go to Resume state\n");
757 __do_app(AE_RESUME, data, NULL);
759 } else if (!bvisibility && b_active == TRUE) {
760 _DBG(" Go to Pasue state \n");
762 __do_app(AE_PAUSE, data, NULL);
764 _DBG(" No change state \n");
766 return ECORE_CALLBACK_RENEW;
772 static Eina_Bool __cmsg_cb(void *data, int type, void *event)
774 struct ui_priv *ui = (struct ui_priv *)data;
775 Ecore_X_Event_Client_Message *e = event;
778 return ECORE_CALLBACK_PASS_ON;
781 return ECORE_CALLBACK_PASS_ON;
783 if (e->message_type == _WM_WINDOW_ROTATION_CHANGE_REQUEST) {
784 if ((ui->wm_rot_supported == 0)
785 || (ui->rot_started == 0)
786 || (ui->rot_cb == NULL)) {
787 return ECORE_CALLBACK_PASS_ON;
791 switch (e->data.l[1]) {
793 rm = APPCORE_RM_PORTRAIT_NORMAL;
796 rm = APPCORE_RM_LANDSCAPE_REVERSE;
799 rm = APPCORE_RM_PORTRAIT_REVERSE;
802 rm = APPCORE_RM_LANDSCAPE_NORMAL;
805 rm = APPCORE_RM_UNKNOWN;
811 if (APPCORE_RM_UNKNOWN != rm)
812 ui->rot_cb((void *)&rm, rm, ui->rot_cb_data);
815 return ECORE_CALLBACK_PASS_ON;
819 static void __add_climsg_cb(struct ui_priv *ui)
824 ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_SHOW, __show_cb, ui);
826 ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_HIDE, __hide_cb, ui);
828 ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_VISIBILITY_CHANGE,
829 __visibility_cb, ui);
831 ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_LOWER,
835 ecore_event_handler_add(ECORE_X_EVENT_WINDOW_SHOW, __show_cb, ui);
837 ecore_event_handler_add(ECORE_X_EVENT_WINDOW_HIDE, __hide_cb, ui);
839 ecore_event_handler_add(ECORE_X_EVENT_WINDOW_VISIBILITY_CHANGE,
840 __visibility_cb, ui);
842 /* Add client message callback for WM_ROTATE */
843 if (!__check_wm_rotation_support()) {
844 ui->hcmsg = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE,
846 ui->wm_rot_supported = 1;
847 appcore_set_wm_rotation(&wm_rotate);
852 static int __before_loop(struct ui_priv *ui, int *argc, char ***argv)
857 if (argc == NULL || argv == NULL) {
858 _ERR("argc/argv is NULL");
863 #if !(GLIB_CHECK_VERSION(2, 36, 0))
866 elm_init(*argc, *argv);
868 hwacc = getenv("HWACC");
870 _DBG("elm_config_accel_preference_set is not called");
871 } else if (strcmp(hwacc, "USE") == 0) {
872 elm_config_accel_preference_set("hw");
873 _DBG("elm_config_accel_preference_set : hw");
874 } else if (strcmp(hwacc, "NOT_USE") == 0) {
875 elm_config_accel_preference_set("none");
876 _DBG("elm_config_accel_preference_set : none");
878 _DBG("elm_config_accel_preference_set is not called");
881 r = appcore_init(ui->name, &efl_ops, *argc, *argv);
882 _retv_if(r == -1, -1);
884 #if _APPFW_FEATURE_BACKGROUND_MANAGEMENT
885 appcore_get_app_core(&ac);
887 SECURE_LOGD("[__SUSPEND__] appcore initialized, appcore addr: 0x%x", ac);
890 LOG(LOG_DEBUG, "LAUNCH", "[%s:Platform:appcore_init:done]", ui->name);
891 if (ui->ops && ui->ops->create) {
892 traceBegin(TTRACE_TAG_APPLICATION_MANAGER, "APPCORE:CREATE");
893 r = ui->ops->create(ui->ops->data);
894 traceEnd(TTRACE_TAG_APPLICATION_MANAGER);
896 _ERR("create() return error");
898 if (ui->ops && ui->ops->terminate) {
899 traceBegin(TTRACE_TAG_APPLICATION_MANAGER,
900 "APPCORE:TERMINATE");
901 ui->ops->terminate(ui->ops->data);
902 traceEnd(TTRACE_TAG_APPLICATION_MANAGER);
907 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:create:done]",
910 ui->state = AS_CREATED;
917 static void __after_loop(struct ui_priv *ui)
919 appcore_unset_rotation_cb();
922 if (ui->state == AS_RUNNING) {
923 _DBG("[APP %d] PAUSE before termination", _pid);
924 if (ui->ops && ui->ops->pause) {
925 traceBegin(TTRACE_TAG_APPLICATION_MANAGER,
927 ui->ops->pause(ui->ops->data);
928 traceEnd(TTRACE_TAG_APPLICATION_MANAGER);
932 if (ui->ops && ui->ops->terminate) {
933 traceBegin(TTRACE_TAG_APPLICATION_MANAGER, "APPCORE:TERMINATE");
934 ui->ops->terminate(ui->ops->data);
935 traceEnd(TTRACE_TAG_APPLICATION_MANAGER);
938 ui->state = AS_DYING;
941 ecore_event_handler_del(ui->hshow);
943 ecore_event_handler_del(ui->hhide);
945 ecore_event_handler_del(ui->hvchange);
948 ecore_event_handler_del(ui->hlower);
951 __appcore_timer_del(ui);
956 static int __set_data(struct ui_priv *ui, const char *name,
957 struct appcore_ops *ops)
960 _ERR("Mainloop already started");
965 if (name == NULL || name[0] == '\0') {
966 _ERR("Invalid name");
977 ui->name = strdup(name);
978 _retv_if(ui->name == NULL, -1);
981 ui->mfcb = __appcore_efl_memory_flush_cb;
985 ui->wm_rot_supported = 0;
988 ui->rot_cb_data = NULL;
989 ui->rot_mode = APPCORE_RM_UNKNOWN;
991 #ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
993 ui->prepare_to_suspend = __appcore_efl_prepare_to_suspend;
994 ui->exit_from_suspend = __appcore_efl_exit_from_suspend;
1000 static void __unset_data(struct ui_priv *ui)
1003 free((void *)ui->name);
1005 memset(ui, 0, sizeof(struct ui_priv));
1010 static int __wm_set_rotation_cb(int (*cb) (void *event_info, enum appcore_rm, void *), void *data)
1017 if ((priv.wm_rot_supported) && (0 == priv.rot_started))
1018 __set_wm_rotation_support(0, 1);
1021 priv.rot_cb_data = data;
1022 priv.rot_started = 1;
1027 static int __wm_unset_rotation_cb(void)
1029 if ((priv.wm_rot_supported) && (1 == priv.rot_started))
1030 __set_wm_rotation_support(0, 0);
1033 priv.rot_cb_data = NULL;
1034 priv.rot_started = 0;
1039 static int __wm_get_rotation_state(enum appcore_rm *curr)
1046 *curr = priv.rot_mode;
1051 static int __wm_pause_rotation_cb(void)
1053 if ((priv.rot_started == 1) && (priv.wm_rot_supported))
1054 __set_wm_rotation_support(0, 0);
1056 priv.rot_started = 0;
1061 static int __wm_resume_rotation_cb(void)
1063 if ((priv.rot_started == 0) && (priv.wm_rot_supported))
1064 __set_wm_rotation_support(0, 1);
1066 priv.rot_started = 1;
1071 static struct ui_wm_rotate wm_rotate = {
1072 __wm_set_rotation_cb,
1073 __wm_unset_rotation_cb,
1074 __wm_get_rotation_state,
1075 __wm_pause_rotation_cb,
1076 __wm_resume_rotation_cb
1080 EXPORT_API int appcore_efl_init(const char *name, int *argc, char ***argv,
1081 struct appcore_ops *ops)
1085 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:main:done]", name);
1087 r = __set_data(&priv, name, ops);
1088 _retv_if(r == -1, -1);
1090 r = __before_loop(&priv, argc, argv);
1092 aul_status_update(STATUS_DYING);
1093 __unset_data(&priv);
1100 EXPORT_API void appcore_efl_fini(void)
1102 aul_status_update(STATUS_DYING);
1104 __after_loop(&priv);
1106 __unset_data(&priv);
1109 EXPORT_API int appcore_efl_main(const char *name, int *argc, char ***argv,
1110 struct appcore_ops *ops)
1114 r = appcore_efl_init(name, argc, argv, ops);
1115 _retv_if(r == -1, -1);
1124 EXPORT_API int appcore_set_system_resource_reclaiming(bool enable)
1126 resource_reclaiming = enable;
1131 EXPORT_API int appcore_set_app_state(int state)
1140 EXPORT_API int appcore_set_preinit_window_name(const char *win_name)
1143 void *preinit_window = NULL;
1144 const Evas *e = NULL;
1147 _ERR("invalid parameter");
1151 preinit_window = elm_win_precreated_object_get();
1152 if (!preinit_window) {
1153 _ERR("Failed to get preinit window");
1157 e = evas_object_evas_get((const Evas_Object *)preinit_window);
1159 Ecore_Evas *ee = ecore_evas_ecore_evas_get(e);
1161 ecore_evas_name_class_set(ee, win_name, win_name);
1169 EXPORT_API unsigned int appcore_get_main_window(void)
1171 struct win_node *entry = NULL;
1173 if (g_winnode_list != NULL) {
1174 entry = g_winnode_list->data;
1175 return (unsigned int) entry->win;
1181 #if defined(WAYLAND)
1182 EXPORT_API unsigned int appcore_get_main_surface(void)
1184 struct win_node *entry = NULL;
1186 if (g_winnode_list != NULL) {
1187 entry = g_winnode_list->data;
1188 return (unsigned int) entry->surf;