4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 #include <sys/types.h>
23 #include <sys/socket.h>
33 #include <Ecore_Wayland.h>
35 #include <X11/Xatom.h>
41 #include <Ecore_Evas.h>
42 #include <Ecore_Input_Evas.h>
43 #include <Elementary.h>
44 #include <glib-object.h>
47 #include <dbus/dbus.h>
48 #include <dbus/dbus-glib-lowlevel.h>
52 #include "appcore-internal.h"
53 #include "appcore-efl.h"
56 static bool resource_reclaiming = TRUE;
57 static int tmp_val = 0;
59 /* cgroup command type */
60 enum proc_status_type {
63 PROC_STATUS_TERMINATE,
72 Ecore_Event_Handler *hshow;
73 Ecore_Event_Handler *hhide;
74 Ecore_Event_Handler *hvchange;
76 Ecore_Event_Handler *hlower;
78 Ecore_Event_Handler *hcmsg; /* WM_ROTATE */
80 Ecore_Timer *mftimer; /* Ecore Timer for memory flushing */
82 #ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
83 struct appcore *app_core;
84 void (*prepare_to_suspend) (void *data);
85 void (*exit_from_suspend) (void *data);
87 struct appcore_ops *ops;
88 void (*mfcb) (void); /* Memory Flushing Callback */
93 int (*rot_cb) (void *event_info, enum appcore_rm, void *);
95 enum appcore_rm rot_mode;
99 static struct ui_priv priv;
101 static const char *_ae_name[AE_MAX] = {
102 [AE_UNKNOWN] = "UNKNOWN",
103 [AE_CREATE] = "CREATE",
104 [AE_TERMINATE] = "TERMINATE",
105 [AE_PAUSE] = "PAUSE",
106 [AE_RESUME] = "RESUME",
107 [AE_RESET] = "RESET",
108 [AE_LOWMEM_POST] = "LOWMEM_POST",
109 [AE_MEM_FLUSH] = "MEM_FLUSH",
112 static const char *_as_name[] = {
114 [AS_CREATED] = "CREATED",
115 [AS_RUNNING] = "RUNNING",
116 [AS_PAUSED] = "PAUSED",
117 [AS_DYING] = "DYING",
120 static bool b_active = FALSE;
121 static bool first_launch = TRUE;
131 static struct ui_wm_rotate wm_rotate;
132 static Eina_Bool __visibility_cb(void *data, int type, void *event);
134 static void _send_to_resourced(enum proc_status_type type)
136 DBusConnection *conn;
138 DBusError dbus_error;
140 dbus_error_init(&dbus_error);
142 conn = dbus_bus_get(DBUS_BUS_SYSTEM, &dbus_error);
144 _ERR("dbus_bus_get failed : [%s]", dbus_error.message);
145 dbus_error_free(&dbus_error);
149 msg = dbus_message_new_signal("/Org/Tizen/ResourceD/Process",
150 "org.tizen.resourced.process",
153 _ERR("dbus_message_new_signal is failed");
157 if (!dbus_message_append_args(msg,
158 DBUS_TYPE_INT32, &type,
159 DBUS_TYPE_INT32, &_pid,
160 DBUS_TYPE_INVALID)) {
161 _ERR("dbus_message_append_args is failed. type = %d, pid = %d",
163 dbus_message_unref(msg);
167 if (!dbus_connection_send(conn, msg, NULL))
168 _ERR("dbus_connection_send is failed");
170 dbus_message_unref(msg);
173 static GSList *g_winnode_list;
175 #ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
176 static void __appcore_efl_prepare_to_suspend(void *data)
178 struct ui_priv *ui = (struct ui_priv *)data;
179 struct sys_op *op = NULL;
180 int suspend = APPCORE_SUSPENDED_STATE_WILL_ENTER_SUSPEND;
182 if (ui->app_core && !ui->app_core->allowed_bg && !ui->app_core->suspended_state) {
183 op = &ui->app_core->sops[SE_SUSPENDED_STATE];
185 op->func((void *)&suspend, op->data); /* calls c-api handler */
187 ui->app_core->suspended_state = true;
189 _DBG("[__SUSPEND__]");
192 static void __appcore_efl_exit_from_suspend(void *data)
194 struct ui_priv *ui = (struct ui_priv *)data;
195 struct sys_op *op = NULL;
196 int suspend = APPCORE_SUSPENDED_STATE_DID_EXIT_FROM_SUSPEND;
198 if (ui->app_core && !ui->app_core->allowed_bg && ui->app_core->suspended_state) {
199 op = &ui->app_core->sops[SE_SUSPENDED_STATE];
201 op->func((void *)&suspend, op->data); /* calls c-api handler */
203 ui->app_core->suspended_state = false;
205 _DBG("[__SUSPEND__]");
209 #if defined(MEMORY_FLUSH_ACTIVATE)
210 static Eina_Bool __appcore_memory_flush_cb(void *data)
212 struct ui_priv *ui = (struct ui_priv *)data;
214 appcore_flush_memory();
218 #ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
219 if (ui && ui->prepare_to_suspend) {
220 _DBG("[__SUSPEND__] flush case");
221 ui->prepare_to_suspend(ui);
225 return ECORE_CALLBACK_CANCEL;
228 static int __appcore_low_memory_post_cb(struct ui_priv *ui)
230 if (ui->state == AS_PAUSED)
231 appcore_flush_memory();
238 static void __appcore_timer_add(struct ui_priv *ui)
240 ui->mftimer = ecore_timer_add(5, __appcore_memory_flush_cb, ui);
243 static void __appcore_timer_del(struct ui_priv *ui)
246 ecore_timer_del(ui->mftimer);
253 static int __appcore_low_memory_post_cb(ui_priv *ui)
258 #define __appcore_timer_add(ui) 0
259 #define __appcore_timer_del(ui) 0
263 static void __appcore_efl_memory_flush_cb(void)
265 _DBG("[APP %d] __appcore_efl_memory_flush_cb()", _pid);
266 elm_cache_all_flush();
269 static void wl_raise_win(void)
271 Ecore_Wl_Window *win;
272 unsigned int win_id = appcore_get_main_window();
274 _DBG("Raise window: %d", win_id);
275 win = ecore_wl_window_find(win_id);
276 ecore_wl_window_activate(win);
279 static void wl_pause_win(void)
281 Ecore_Wl_Window *win;
282 GSList *wlist = g_winnode_list;
283 struct win_node *entry = NULL;
285 _DBG("Pause window");
290 _DBG("Pause window: %d", entry->win);
291 win = ecore_wl_window_find(entry->win);
292 ecore_wl_window_iconified_set(win, EINA_TRUE);
300 static void __do_app(enum app_event event, void *data, bundle * b)
303 struct ui_priv *ui = data;
305 _DBG("[APP %d] Event: %d", _pid, event);
306 _ret_if(ui == NULL || event >= AE_MAX);
307 _DBG("[APP %d] Event: %s State: %s", _pid, _ae_name[event],
308 _as_name[ui->state]);
310 if (event == AE_MEM_FLUSH) {
315 if (event == AE_LOWMEM_POST) {
316 if (__appcore_low_memory_post_cb(ui) == 0)
320 if (!(ui->state == AS_PAUSED && event == AE_PAUSE))
321 __appcore_timer_del(ui);
323 if (ui->state == AS_DYING) {
324 _ERR("Skip the event in dying state");
328 if (event == AE_TERMINATE) {
329 _DBG("[APP %d] TERMINATE", _pid);
331 aul_status_update(STATUS_DYING);
335 if (event == AE_RAISE) {
337 x_raise_win(getpid());
338 #elif defined(WAYLAND)
344 if (event == AE_LOWER) {
346 x_pause_win(getpid());
347 #elif defined(WAYLAND)
353 _ret_if(ui->ops == NULL);
357 _DBG("[APP %d] RESET", _pid);
358 ui->pending_data = bundle_dup(b);
359 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:reset:start]", ui->name);
361 #ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
362 if (ui->exit_from_suspend) {
363 _DBG("[__SUSPEND__] reset case");
364 ui->exit_from_suspend(ui);
369 r = ui->ops->reset(b, ui->ops->data);
370 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:reset:done]", ui->name);
373 first_launch = FALSE;
375 _INFO("[APP %d] App already running, raise the window", _pid);
377 x_raise_win(getpid());
382 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:reset:done]",
386 if (ui->state == AS_RUNNING) {
387 _DBG("[APP %d] PAUSE", _pid);
389 r = ui->ops->pause(ui->ops->data);
390 ui->state = AS_PAUSED;
391 if (r >= 0 && resource_reclaiming == TRUE)
392 __appcore_timer_add(ui);
393 #ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
394 else if (r >= 0 && resource_reclaiming == FALSE
395 && ui->prepare_to_suspend) {
396 _DBG("[__SUSPEND__] pause case");
397 ui->prepare_to_suspend(ui);
401 /* TODO : rotation stop */
402 /* r = appcore_pause_rotation_cb(); */
403 aul_status_update(STATUS_BG);
404 _send_to_resourced(PROC_STATUS_BACKGRD);
407 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:resume:start]",
409 #ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
410 if (ui->exit_from_suspend) {
411 _DBG("[__SUSPEND__] resume case");
412 ui->exit_from_suspend(ui);
416 if (ui->state == AS_PAUSED || ui->state == AS_CREATED) {
417 _DBG("[APP %d] RESUME", _pid);
419 if (ui->state == AS_CREATED) {
420 bundle_free(ui->pending_data);
421 ui->pending_data = NULL;
425 ui->ops->resume(ui->ops->data);
426 ui->state = AS_RUNNING;
428 /*TODO : rotation start*/
429 /* r = appcore_resume_rotation_cb(); */
430 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:resume:done]",
432 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:Launching:done]",
434 aul_status_update(STATUS_VISIBLE);
435 _send_to_resourced(PROC_STATUS_FOREGRD);
437 case AE_TERMINATE_BGAPP:
438 if (ui->state == AS_PAUSED) {
439 _DBG("[APP %d] is paused. TERMINATE", _pid);
440 ui->state = AS_DYING;
441 aul_status_update(STATUS_DYING);
443 } else if (ui->state == AS_RUNNING) {
444 _DBG("[APP %d] is running.", _pid);
446 _DBG("[APP %d] is another state", _pid);
455 static struct ui_ops efl_ops = {
460 static bool __check_visible(void)
463 struct win_node *entry = NULL;
465 _DBG("[EVENT_TEST][EVENT] __check_visible\n");
467 for (iter = g_winnode_list; iter != NULL; iter = g_slist_next(iter)) {
469 _DBG("win : %x obscured : %d\n", entry->win, entry->bfobscured);
470 if (entry->bfobscured == FALSE)
477 static GSList *__find_win(unsigned int win)
482 for (iter = g_winnode_list; iter; iter = g_slist_next(iter)) {
484 if (t && t->win == win)
492 static bool __add_win(unsigned int win)
497 _DBG("[EVENT_TEST][EVENT] __add_win WIN:%x\n", win);
502 _DBG("[EVENT_TEST][EVENT] ERROR There is already window : %x \n", win);
506 t = calloc(1, sizeof(struct win_node));
511 t->bfobscured = FALSE;
513 g_winnode_list = g_slist_append(g_winnode_list, t);
517 #elif defined(WAYLAND)
518 static bool __add_win(unsigned int win, unsigned int surf)
523 _DBG("[EVENT_TEST][EVENT] __add_win WIN:%x\n", win);
528 _DBG("[EVENT_TEST][EVENT] ERROR There is already window : %x \n", win);
532 t = calloc(1, sizeof(struct win_node));
538 t->bfobscured = FALSE;
540 g_winnode_list = g_slist_append(g_winnode_list, t);
546 static bool __delete_win(unsigned int win)
553 _DBG("[EVENT_TEST][EVENT] ERROR There is no window : %x \n",
559 g_winnode_list = g_slist_delete_link(g_winnode_list, f);
565 static bool __update_win(unsigned int win, bool bfobscured)
570 _DBG("[EVENT_TEST][EVENT] __update_win WIN:%x fully_obscured %d\n", win,
576 _DBG("[EVENT_TEST][EVENT] ERROR There is no window : %x \n", win);
580 g_winnode_list = g_slist_remove_link(g_winnode_list, f);
582 t = (struct win_node *)f->data;
584 t->bfobscured = bfobscured;
586 g_winnode_list = g_slist_concat(g_winnode_list, f);
590 #elif defined(WAYLAND)
591 static bool __update_win(unsigned int win, unsigned int surf, bool bfobscured)
596 _DBG("[EVENT_TEST][EVENT] __update_win WIN:%x fully_obscured %d\n", win,
602 _DBG("[EVENT_TEST][EVENT] ERROR There is no window : %x \n", win);
606 g_winnode_list = g_slist_remove_link(g_winnode_list, f);
608 t = (struct win_node *)f->data;
612 t->bfobscured = bfobscured;
614 g_winnode_list = g_slist_concat(g_winnode_list, f);
622 static Ecore_X_Atom _WM_WINDOW_ROTATION_SUPPORTED = 0;
623 static Ecore_X_Atom _WM_WINDOW_ROTATION_CHANGE_REQUEST = 0;
625 static int __check_wm_rotation_support(void)
627 _DBG("Disable window manager rotation");
630 Ecore_X_Window root, win, win2;
633 if (!_WM_WINDOW_ROTATION_SUPPORTED) {
634 _WM_WINDOW_ROTATION_SUPPORTED =
635 ecore_x_atom_get("_E_WINDOW_ROTATION_SUPPORTED");
638 if (!_WM_WINDOW_ROTATION_CHANGE_REQUEST) {
639 _WM_WINDOW_ROTATION_CHANGE_REQUEST =
640 ecore_x_atom_get("_E_WINDOW_ROTATION_CHANGE_REQUEST");
643 root = ecore_x_window_root_first_get();
644 ret = ecore_x_window_prop_xid_get(root,
645 _WM_WINDOW_ROTATION_SUPPORTED,
648 if ((ret == 1) && (win)) {
649 ret = ecore_x_window_prop_xid_get(win,
650 _WM_WINDOW_ROTATION_SUPPORTED,
653 if ((ret == 1) && (win2 == win))
660 static void __set_wm_rotation_support(unsigned int win, unsigned int set)
663 struct win_node *entry = NULL;
666 for (iter = g_winnode_list; iter != NULL; iter = g_slist_next(iter)) {
669 ecore_x_window_prop_card32_set(entry->win,
670 _WM_WINDOW_ROTATION_SUPPORTED,
675 ecore_x_window_prop_card32_set(win,
676 _WM_WINDOW_ROTATION_SUPPORTED,
682 static Eina_Bool __show_cb(void *data, int type, void *event)
685 Ecore_Wl_Event_Window_Show *ev;
688 if (ev->parent_win != 0) {
689 /* This is child window. Skip!!! */
690 return ECORE_CALLBACK_PASS_ON;
693 _DBG("[EVENT_TEST][EVENT] GET SHOW EVENT!!!. WIN:%x, %d\n", ev->win, ev->data[0]);
695 if (!__find_win((unsigned int)ev->win))
696 __add_win((unsigned int)ev->win, (unsigned int)ev->data[0]);
698 __update_win((unsigned int)ev->win, (unsigned int)ev->data[0], FALSE);
701 Ecore_X_Event_Window_Show *ev;
703 Ecore_X_Window parent;
707 _DBG("[EVENT_TEST][EVENT] GET SHOW EVENT!!!. WIN:%x\n", ev->win);
709 if (!__find_win((unsigned int)ev->win)) {
711 if ((priv.wm_rot_supported) && (1 == priv.rot_started))
712 __set_wm_rotation_support(ev->win, 1);
713 __add_win((unsigned int)ev->win);
715 __update_win((unsigned int)ev->win, FALSE);
719 appcore_group_attach();
720 return ECORE_CALLBACK_RENEW;
723 static Eina_Bool __hide_cb(void *data, int type, void *event)
726 Ecore_Wl_Event_Window_Hide *ev;
728 Ecore_X_Event_Window_Hide *ev;
734 _DBG("[EVENT_TEST][EVENT] GET HIDE EVENT!!!. WIN:%x\n", ev->win);
736 if (__find_win((unsigned int)ev->win)) {
737 __delete_win((unsigned int)ev->win);
738 bvisibility = __check_visible();
739 if (!bvisibility && b_active == TRUE) {
740 _DBG(" Go to Pasue state \n");
742 __do_app(AE_PAUSE, data, NULL);
746 return ECORE_CALLBACK_RENEW;
750 static Eina_Bool __lower_cb(void *data, int type, void *event)
752 Ecore_Wl_Event_Window_Lower *ev;
754 if (!ev) return ECORE_CALLBACK_RENEW;
755 _DBG("ECORE_WL_EVENT_WINDOW_LOWER window id:%u\n", ev->win);
756 appcore_group_lower();
757 return ECORE_CALLBACK_RENEW;
761 static Eina_Bool __visibility_cb(void *data, int type, void *event)
764 Ecore_Wl_Event_Window_Visibility_Change *ev;
767 __update_win((unsigned int)ev->win, 0, ev->fully_obscured);
769 Ecore_X_Event_Window_Visibility_Change *ev;
774 __update_win((unsigned int)ev->win, ev->fully_obscured);
776 bvisibility = __check_visible();
778 _DBG("bvisibility %d, b_active %d", bvisibility, b_active);
780 if (bvisibility && b_active == FALSE) {
781 _DBG(" Go to Resume state\n");
783 __do_app(AE_RESUME, data, NULL);
785 } else if (!bvisibility && b_active == TRUE) {
786 _DBG(" Go to Pasue state \n");
788 __do_app(AE_PAUSE, data, NULL);
790 _DBG(" No change state \n");
792 return ECORE_CALLBACK_RENEW;
798 static Eina_Bool __cmsg_cb(void *data, int type, void *event)
800 struct ui_priv *ui = (struct ui_priv *)data;
801 Ecore_X_Event_Client_Message *e = event;
804 return ECORE_CALLBACK_PASS_ON;
807 return ECORE_CALLBACK_PASS_ON;
809 if (e->message_type == _WM_WINDOW_ROTATION_CHANGE_REQUEST) {
810 if ((ui->wm_rot_supported == 0)
811 || (ui->rot_started == 0)
812 || (ui->rot_cb == NULL)) {
813 return ECORE_CALLBACK_PASS_ON;
817 switch (e->data.l[1]) {
819 rm = APPCORE_RM_PORTRAIT_NORMAL;
822 rm = APPCORE_RM_LANDSCAPE_REVERSE;
825 rm = APPCORE_RM_PORTRAIT_REVERSE;
828 rm = APPCORE_RM_LANDSCAPE_NORMAL;
831 rm = APPCORE_RM_UNKNOWN;
837 if (APPCORE_RM_UNKNOWN != rm)
838 ui->rot_cb((void *)&rm, rm, ui->rot_cb_data);
841 return ECORE_CALLBACK_PASS_ON;
845 static void __add_climsg_cb(struct ui_priv *ui)
850 ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_SHOW, __show_cb, ui);
852 ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_HIDE, __hide_cb, ui);
854 ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_VISIBILITY_CHANGE,
855 __visibility_cb, ui);
857 ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_LOWER,
861 ecore_event_handler_add(ECORE_X_EVENT_WINDOW_SHOW, __show_cb, ui);
863 ecore_event_handler_add(ECORE_X_EVENT_WINDOW_HIDE, __hide_cb, ui);
865 ecore_event_handler_add(ECORE_X_EVENT_WINDOW_VISIBILITY_CHANGE,
866 __visibility_cb, ui);
868 /* Add client message callback for WM_ROTATE */
869 if (!__check_wm_rotation_support()) {
870 ui->hcmsg = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE,
872 ui->wm_rot_supported = 1;
873 appcore_set_wm_rotation(&wm_rotate);
878 static int __before_loop(struct ui_priv *ui, int *argc, char ***argv)
883 if (argc == NULL || argv == NULL) {
884 _ERR("argc/argv is NULL");
889 #if !(GLIB_CHECK_VERSION(2, 36, 0))
892 elm_init(*argc, *argv);
894 hwacc = getenv("HWACC");
896 _DBG("elm_config_accel_preference_set is not called");
897 } else if (strcmp(hwacc, "USE") == 0) {
898 elm_config_accel_preference_set("hw");
899 _DBG("elm_config_accel_preference_set : hw");
900 } else if (strcmp(hwacc, "NOT_USE") == 0) {
901 elm_config_accel_preference_set("none");
902 _DBG("elm_config_accel_preference_set : none");
904 _DBG("elm_config_accel_preference_set is not called");
907 r = appcore_init(ui->name, &efl_ops, *argc, *argv);
908 _retv_if(r == -1, -1);
910 #if _APPFW_FEATURE_BACKGROUND_MANAGEMENT
911 appcore_get_app_core(&ac);
913 SECURE_LOGD("[__SUSPEND__] appcore initialized, appcore addr: 0x%x", ac);
916 LOG(LOG_DEBUG, "LAUNCH", "[%s:Platform:appcore_init:done]", ui->name);
917 if (ui->ops && ui->ops->create) {
918 r = ui->ops->create(ui->ops->data);
920 _ERR("create() return error");
922 if (ui->ops && ui->ops->terminate)
923 ui->ops->terminate(ui->ops->data);
927 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:create:done]",
930 ui->state = AS_CREATED;
937 static void __after_loop(struct ui_priv *ui)
939 appcore_unset_rotation_cb();
942 if (ui->state == AS_RUNNING) {
943 _DBG("[APP %d] PAUSE before termination", _pid);
944 if (ui->ops && ui->ops->pause)
945 ui->ops->pause(ui->ops->data);
948 if (ui->ops && ui->ops->terminate)
949 ui->ops->terminate(ui->ops->data);
951 ui->state = AS_DYING;
954 ecore_event_handler_del(ui->hshow);
956 ecore_event_handler_del(ui->hhide);
958 ecore_event_handler_del(ui->hvchange);
961 ecore_event_handler_del(ui->hlower);
964 __appcore_timer_del(ui);
969 static int __set_data(struct ui_priv *ui, const char *name,
970 struct appcore_ops *ops)
973 _ERR("Mainloop already started");
978 if (name == NULL || name[0] == '\0') {
979 _ERR("Invalid name");
990 ui->name = strdup(name);
991 _retv_if(ui->name == NULL, -1);
994 ui->mfcb = __appcore_efl_memory_flush_cb;
998 ui->wm_rot_supported = 0;
1001 ui->rot_cb_data = NULL;
1002 ui->rot_mode = APPCORE_RM_UNKNOWN;
1004 #ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
1005 ui->app_core = NULL;
1006 ui->prepare_to_suspend = __appcore_efl_prepare_to_suspend;
1007 ui->exit_from_suspend = __appcore_efl_exit_from_suspend;
1013 static void __unset_data(struct ui_priv *ui)
1016 free((void *)ui->name);
1018 memset(ui, 0, sizeof(struct ui_priv));
1022 static int __wm_set_rotation_cb(int (*cb) (void *event_info, enum appcore_rm, void *), void *data)
1029 if ((priv.wm_rot_supported) && (0 == priv.rot_started))
1030 __set_wm_rotation_support(0, 1);
1033 priv.rot_cb_data = data;
1034 priv.rot_started = 1;
1039 static int __wm_unset_rotation_cb(void)
1041 if ((priv.wm_rot_supported) && (1 == priv.rot_started))
1042 __set_wm_rotation_support(0, 0);
1045 priv.rot_cb_data = NULL;
1046 priv.rot_started = 0;
1051 static int __wm_get_rotation_state(enum appcore_rm *curr)
1058 *curr = priv.rot_mode;
1063 static int __wm_pause_rotation_cb(void)
1065 if ((priv.rot_started == 1) && (priv.wm_rot_supported))
1066 __set_wm_rotation_support(0, 0);
1068 priv.rot_started = 0;
1073 static int __wm_resume_rotation_cb(void)
1075 if ((priv.rot_started == 0) && (priv.wm_rot_supported))
1076 __set_wm_rotation_support(0, 1);
1078 priv.rot_started = 1;
1083 static struct ui_wm_rotate wm_rotate = {
1084 __wm_set_rotation_cb,
1085 __wm_unset_rotation_cb,
1086 __wm_get_rotation_state,
1087 __wm_pause_rotation_cb,
1088 __wm_resume_rotation_cb
1091 EXPORT_API int appcore_efl_init(const char *name, int *argc, char ***argv,
1092 struct appcore_ops *ops)
1096 LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:main:done]", name);
1098 r = __set_data(&priv, name, ops);
1099 _retv_if(r == -1, -1);
1101 r = __before_loop(&priv, argc, argv);
1103 aul_status_update(STATUS_DYING);
1104 __unset_data(&priv);
1111 EXPORT_API void appcore_efl_fini(void)
1113 aul_status_update(STATUS_DYING);
1115 __after_loop(&priv);
1117 __unset_data(&priv);
1120 EXPORT_API int appcore_efl_main(const char *name, int *argc, char ***argv,
1121 struct appcore_ops *ops)
1125 r = appcore_efl_init(name, argc, argv, ops);
1126 _retv_if(r == -1, -1);
1135 EXPORT_API int appcore_set_system_resource_reclaiming(bool enable)
1137 resource_reclaiming = enable;
1142 EXPORT_API int appcore_set_app_state(int state)
1151 EXPORT_API int appcore_set_preinit_window_name(const char *win_name)
1154 void *preinit_window = NULL;
1155 const Evas *e = NULL;
1158 _ERR("invalid parameter");
1162 preinit_window = aul_get_preinit_window(win_name);
1163 if (!preinit_window) {
1164 _ERR("Failed to get preinit window");
1168 e = evas_object_evas_get((const Evas_Object *)preinit_window);
1170 Ecore_Evas *ee = ecore_evas_ecore_evas_get(e);
1172 ecore_evas_name_class_set(ee, win_name, win_name);
1180 EXPORT_API unsigned int appcore_get_main_window(void)
1182 struct win_node *entry = NULL;
1184 if (g_winnode_list != NULL) {
1185 entry = g_winnode_list->data;
1186 return (unsigned int) entry->win;
1192 #if defined(WAYLAND)
1193 EXPORT_API unsigned int appcore_get_main_surface(void)
1195 struct win_node *entry = NULL;
1197 if (g_winnode_list != NULL) {
1198 entry = g_winnode_list->data;
1199 return (unsigned int) entry->surf;