2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (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://floralicense.org/license/
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.
23 #include <sys/types.h>
30 #include <Elementary.h>
32 #include <Ecore_X_Atoms.h>
34 #include <boot-animation.h>
35 #include <animation.h>
37 static struct animation {
38 Ecore_X_Window focus_win;
39 Ecore_X_Window root_win;
53 static void win_del(void *data, Evas_Object * obj, void *event_info)
55 fprintf(stderr, "Window delete event received\n");
59 static void _edje_cb(void *d, Evas_Object * obj, const char *e, const char *s)
61 fprintf(stderr, "edje calback is invoked\n");
63 if (vconf_set_int("memory/boot-animation/finished", 1) != 0) {
64 fprintf(stderr, "Failed to set finished set\n");
67 if (s_animation.state == TYPE_OFF || s_animation.state == TYPE_ON) {
69 } else if (s_animation.state == TYPE_OFF_WITH_MSG) {
70 if (s_animation.txt) {
74 evas_object_size_hint_weight_set(s_animation.txt,
77 evas_object_size_hint_fill_set(s_animation.txt,
80 evas_object_resize(s_animation.txt, s_animation.w,
82 evas_object_color_set(s_animation.txt, 255, 255, 255,
84 evas_object_text_font_set(s_animation.txt,
85 "SLP:style=medium", 30);
86 evas_object_geometry_get(s_animation.txt, NULL, NULL,
88 evas_object_move(s_animation.txt,
89 (s_animation.w - w) >> 1,
90 (s_animation.h - h) >> 1);
91 evas_object_show(s_animation.txt);
97 int init_layout(const char *msg)
99 s_animation.layout = elm_layout_add(s_animation.win);
100 if (!s_animation.layout) {
101 fprintf(stderr, "Failed to create layout\n");
105 if (s_animation.state == TYPE_ON) {
106 elm_layout_file_set(s_animation.layout, EDJ_ON, GRP_ON);
108 elm_layout_file_set(s_animation.layout, EDJ_OFF, GRP_OFF);
111 evas_object_size_hint_weight_set(s_animation.layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
112 printf("[Boot-ani] Start animation: %d mode\n", s_animation.state);
113 elm_win_resize_object_add(s_animation.win, s_animation.layout);
114 edje_object_signal_callback_add(elm_layout_edje_get(s_animation.layout),
115 "end", "animation", _edje_cb, NULL);
116 evas_object_show(s_animation.layout);
119 xwin = elm_win_xwindow_get(s_animation.win);
120 ecore_x_icccm_hints_set(xwin, 0, 0, 0, 0, 0, 0, 0);
124 if (!s_animation.txt) {
126 evas_object_text_add(s_animation.evas);
127 if (!s_animation.txt) {
128 fprintf(stderr, "Failed to add text\n");
129 evas_object_del(s_animation.layout);
134 evas_object_text_text_set(s_animation.txt, msg);
135 evas_object_hide(s_animation.txt);
138 if (vconf_set_int("memory/boot-animation/finished", 0) != 0) {
139 fprintf(stderr, "Failed to set finished value to 0\n");
146 void fini_layout(void)
148 if (s_animation.layout) {
149 evas_object_del(s_animation.layout);
152 if (s_animation.txt) {
153 evas_object_del(s_animation.txt);
154 s_animation.txt = NULL;
158 void restart_animation(int state, const char *msg)
162 s_animation.state = state;
166 evas_object_show(s_animation.win);
170 int create_window(void)
172 s_animation.win = elm_win_add(NULL, "", ELM_WIN_BASIC);
173 if (!s_animation.win) {
174 fprintf(stderr, "Failed to create a new window\n");
177 evas_object_smart_callback_add(s_animation.win, "delete-request",
179 evas_object_resize(s_animation.win, s_animation.w, s_animation.h);
181 s_animation.evas = evas_object_evas_get(s_animation.win);
182 if (!s_animation.evas) {
183 evas_object_del(s_animation.win);
184 fprintf(stderr, "Failed to get the evas object\n");
187 elm_win_borderless_set(s_animation.win, 1);
188 evas_object_move(s_animation.win, 0, 0);
190 if (s_animation.w > s_animation.h) {
192 elm_win_rotation_with_resize_set(s_animation.win, 90);
194 s_animation.w = s_animation.h;
197 evas_object_show(s_animation.win);
199 s_animation.ee = ecore_evas_ecore_evas_get(s_animation.evas);
200 if (!s_animation.ee) {
201 evas_object_del(s_animation.win);
202 fprintf(stderr, "Failed to get the ecore evas object\n");
206 s_animation.xwin = ecore_evas_window_get(s_animation.ee);
207 ecore_x_netwm_window_type_set(s_animation.xwin,
208 ECORE_X_WINDOW_TYPE_NOTIFICATION);
209 utilx_set_system_notification_level(ecore_x_display_get(),
211 UTILX_NOTIFICATION_LEVEL_HIGH);
216 int init_animation(int state, const char *msg)
218 s_animation.focus_win = ecore_x_window_focus_get();
219 s_animation.root_win = ecore_x_window_root_get(s_animation.focus_win);
220 s_animation.state = state;
221 ecore_x_window_size_get(s_animation.root_win, &s_animation.w,
224 if (create_window() == EXIT_FAILURE) {
225 fprintf(stderr, "Failed to create a new window\n");
229 if (init_layout(msg) == EXIT_FAILURE) {
230 fprintf(stderr, "Failed to init the layout object\n");
232 evas_object_del(s_animation.txt);
233 evas_object_del(s_animation.win);
240 int fini_animation(void)
243 evas_object_del(s_animation.win);