disable window effect
[framework/uifw/cbhm.git] / src / cbhm_main.c
1 /*
2  * SLP2
3  * Copyright (c) 2009 Samsung Electronics, Inc.
4  * All rights reserved.
5  *
6  * This software is a confidential and proprietary information
7  * of Samsung Electronics, Inc. ("Confidential Information").  You
8  * shall not disclose such Confidential Information and shall use
9  * it only in accordance with the terms of the license agreement
10  * you entered into with Samsung Electronics.
11  */
12
13 #include "common.h"
14 #include "cbhm_main.h"
15 #include "xcnphandler.h"
16 #include "clipdrawer.h"
17 #include "scrcapture.h"
18
19 // FIXME: how to remove g_main_ad? 
20 static struct appdata *g_main_ad = NULL;
21
22 static Evas_Object* create_win(void *data, const char *name);
23 static Evas_Object* load_edj(Evas_Object *parent, const char *file, const char *group);
24
25 static void win_del_cb(void *data, Evas_Object *obj, void *event)
26 {
27         struct appdata *ad = (struct appdata *) data;
28         clipdrawer_lower_view(ad);
29 //  NOTE : cbhm doesn't want to exit by home key.
30 //      elm_exit();
31 }
32
33 static void main_quit_cb(void *data, Evas_Object* obj, void* event_info)
34 {
35         elm_exit();
36 }
37
38 void* g_get_main_appdata()
39 {
40         return (void*)g_main_ad;
41 }
42
43 int init_appview(void *data)
44 {
45         struct appdata *ad = (struct appdata *) data;
46         Evas_Object *win, *ly;
47
48         win = create_win(ad, APPNAME);
49         if(win == NULL)
50                 return -1;
51         ad->evas = evas_object_evas_get(win);
52         ad->win_main = win;
53
54 //  avoid focus but it can't be used. because grap keys
55 //      Ecore_X_Window xwin = (Ecore_X_Window)ecore_evas_window_get(ecore_evas_ecore_evas_get(ad->evas));
56 //      ecore_x_icccm_hints_set(xwin, 0, 0, 0, 0, 0, 0, 0);
57
58         ly = load_edj(win, APP_EDJ_FILE, GRP_MAIN);
59         if (ly == NULL)
60                 return -1; 
61         elm_win_resize_object_add(win, ly);
62         ad->ly_main = ly;
63
64         evas_object_show(ly);
65
66         clipdrawer_create_view(ad);
67
68         evas_object_smart_callback_add(ad->win_main, "delete,request", win_del_cb, ad);
69         edje_object_signal_callback_add(elm_layout_edje_get(ly), "EXIT", "*", main_quit_cb, NULL);
70
71 // NOTE: do not show before win_main window resizing
72 //      evas_object_show(win);
73
74         return 0;
75 }
76
77 static Evas_Object* create_win(void *data, const char *name)
78 {
79         struct appdata *ad = (struct appdata *) data;
80         Evas_Object *eo;
81         int w, h;
82         Ecore_X_Display *dpy;
83         dpy = ecore_x_display_get();
84
85         eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
86         if (eo)
87     {
88                 elm_win_title_set(eo, name);
89                 elm_win_borderless_set(eo, EINA_TRUE);
90                 ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
91                 ad->root_w = w; ad->root_h = h;
92                 evas_object_resize(eo, w, h);
93                 if (dpy)
94                 {   //disable window effect
95                         utilx_set_window_effect_state(dpy, elm_win_xwindow_get(eo), 0);
96                 }
97         }
98
99         return eo;
100 }
101
102 static Evas_Object* load_edj(Evas_Object *parent, const char *file, const char *group)
103 {       
104         Evas_Object *eo;
105         int ret;
106
107         eo = elm_layout_add(parent);
108         if (eo) 
109         {
110                 ret = elm_layout_file_set(eo, file, group);
111                 if (!ret) 
112                 {
113                         evas_object_del(eo);
114                         return NULL;
115                 }
116
117                 evas_object_size_hint_weight_set(eo, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
118                 elm_win_resize_object_add(parent, eo);
119         }
120
121         return eo;
122 }
123
124 static int init(struct appdata *ad)
125 {
126         /* FIXME : add checking multiple instance */
127         xcnp_init(ad);
128         init_appview(ad);
129         init_scrcapture(ad);
130
131         return 0;
132 }
133
134 static void fini(struct appdata *ad)
135 {
136         close_scrcapture(ad);
137
138         if (ad->ly_main)
139                 evas_object_del(ad->ly_main);
140
141         if (ad->win_main)
142                 evas_object_del(ad->win_main);
143 }
144
145 static void init_ad(struct appdata *ad)
146 {
147         memset(ad, 0x0, sizeof(struct appdata));
148         g_main_ad = ad;
149 }
150
151 EAPI int elm_main(int argc, char **argv)
152 {
153         struct appdata ad;
154
155         init_ad(&ad);
156
157         if(!init(&ad))
158                 elm_run();
159
160         fini(&ad);
161
162         elm_shutdown();
163
164         return EXIT_SUCCESS;
165 }
166
167 int main( int argc, char *argv[] )
168 {
169         elm_init(argc, argv);
170
171         return elm_main(argc, argv);
172 }