3 * Copyright (c) 2009 Samsung Electronics, Inc.
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.
14 #include "cbhm_main.h"
15 #include "xcnphandler.h"
16 #include "clipdrawer.h"
17 #include "scrcapture.h"
19 // FIXME: how to remove g_main_ad?
20 static struct appdata *g_main_ad = NULL;
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);
25 static void win_del_cb(void *data, Evas_Object *obj, void *event)
27 struct appdata *ad = (struct appdata *) data;
28 clipdrawer_lower_view(ad);
29 // NOTE : cbhm doesn't want to exit by home key.
33 static void main_quit_cb(void *data, Evas_Object* obj, void* event_info)
38 void* g_get_main_appdata()
40 return (void*)g_main_ad;
43 int init_appview(void *data)
45 struct appdata *ad = (struct appdata *) data;
46 Evas_Object *win, *ly;
48 win = create_win(ad, APPNAME);
51 ad->evas = evas_object_evas_get(win);
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);
58 ly = load_edj(win, APP_EDJ_FILE, GRP_MAIN);
61 elm_win_resize_object_add(win, ly);
66 clipdrawer_create_view(ad);
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);
71 // NOTE: do not show before win_main window resizing
72 // evas_object_show(win);
77 void disable_focus_for_app_window (Evas_Object *win)
79 Eina_Bool accepts_focus;
80 Ecore_X_Window_State_Hint initial_state;
81 Ecore_X_Pixmap icon_pixmap;
82 Ecore_X_Pixmap icon_mask;
83 Ecore_X_Window icon_window;
84 Ecore_X_Window window_group;
87 ecore_x_icccm_hints_get (elm_win_xwindow_get (win),
88 &accepts_focus, &initial_state, &icon_pixmap, &icon_mask, &icon_window, &window_group, &is_urgent);
89 ecore_x_icccm_hints_set (elm_win_xwindow_get (win),
90 0, initial_state, icon_pixmap, icon_mask, icon_window, window_group, is_urgent);
93 static Evas_Object* create_win(void *data, const char *name)
95 struct appdata *ad = (struct appdata *) data;
99 dpy = ecore_x_display_get();
101 eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
104 elm_win_title_set(eo, name);
105 elm_win_borderless_set(eo, EINA_TRUE);
106 ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
107 ad->root_w = w; ad->root_h = h;
108 evas_object_resize(eo, w, h);
110 { //disable window effect
111 utilx_set_window_effect_state(dpy, elm_win_xwindow_get(eo), 0);
112 ecore_x_icccm_name_class_set(elm_win_xwindow_get(eo), "NORMAL_WINDOW", "NORMAL_WINDOW");
113 // elm_win_keyboard_win_set (eo, EINA_TRUE);
114 // ecore_x_icccm_name_class_set(elm_win_xwindow_get(eo), "Virtual Keyboard", "ISF");
115 // disable_focus_for_app_window(eo);
122 static Evas_Object* load_edj(Evas_Object *parent, const char *file, const char *group)
127 eo = elm_layout_add(parent);
130 ret = elm_layout_file_set(eo, file, group);
137 evas_object_size_hint_weight_set(eo, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
138 elm_win_resize_object_add(parent, eo);
144 static int init(struct appdata *ad)
146 /* FIXME : add checking multiple instance */
154 static void fini(struct appdata *ad)
156 close_scrcapture(ad);
159 evas_object_del(ad->ly_main);
162 evas_object_del(ad->win_main);
165 static void init_ad(struct appdata *ad)
167 memset(ad, 0x0, sizeof(struct appdata));
171 EAPI int elm_main(int argc, char **argv)
187 int main( int argc, char *argv[] )
189 elm_init(argc, argv);
191 return elm_main(argc, argv);