72472c72eb612557c77ab51e08d39d4d488acb13
[framework/uifw/elementary.git] / src / lib / elm_win.c
1 #include <Elementary.h>
2 #include "elm_priv.h"
3
4 /**
5  * @defgroup Win Win
6  *
7  * The window class of Elementary.  Contains functions to manipulate
8  * windows.
9  */
10
11 typedef struct _Elm_Win Elm_Win;
12
13 struct _Elm_Win
14 {
15    Ecore_Evas *ee;
16    Evas *evas;
17    Evas_Object *parent, *win_obj;
18    Eina_List *subobjs;
19 #ifdef HAVE_ELEMENTARY_X
20    Ecore_X_Window xwin;
21    Ecore_Event_Handler *client_message_handler;
22 #endif   
23    Ecore_Job *deferred_resize_job;
24    Ecore_Job *deferred_child_eval_job;
25
26    Elm_Win_Type type;
27    Elm_Win_Keyboard_Mode kbdmode;
28    Eina_Bool autodel : 1;
29    int *autodel_clear, rot;
30    struct {
31       int x, y;
32    } screen;
33 };
34
35 static const char *widtype = NULL;
36 static void _elm_win_obj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
37 static void _elm_win_obj_callback_parent_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
38 static void _elm_win_obj_intercept_show(void *data, Evas_Object *obj);
39 static void _elm_win_move(Ecore_Evas *ee);
40 static void _elm_win_resize(Ecore_Evas *ee);
41 static void _elm_win_delete_request(Ecore_Evas *ee);
42 static void _elm_win_resize_job(void *data);
43 #ifdef HAVE_ELEMENTARY_X
44 static void _elm_win_xwin_update(Elm_Win *win);
45 #endif
46 static void _elm_win_eval_subobjs(Evas_Object *obj);
47 static void _elm_win_subobj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
48 static void _elm_win_subobj_callback_changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
49
50 Eina_List *_elm_win_list = NULL;
51
52 static void
53 _elm_win_move(Ecore_Evas *ee)
54 {
55    Evas_Object *obj = ecore_evas_object_associate_get(ee);
56    Elm_Win *win;
57    int x, y;
58    
59    if (!obj) return;
60    win = elm_widget_data_get(obj);
61    if (!win) return;
62    ecore_evas_geometry_get(ee, &x, &y, NULL, NULL);
63    win->screen.x = x;
64    win->screen.y = y;
65    evas_object_smart_callback_call(win->win_obj, "moved", NULL);
66 }
67
68 static void
69 _elm_win_resize(Ecore_Evas *ee)
70 {
71    Evas_Object *obj = ecore_evas_object_associate_get(ee);
72    Elm_Win *win;
73    
74    if (!obj) return;
75    win = elm_widget_data_get(obj);
76    if (!win) return;
77    if (win->deferred_resize_job) ecore_job_del(win->deferred_resize_job);
78    win->deferred_resize_job = ecore_job_add(_elm_win_resize_job, win);
79 }
80
81 static void
82 _elm_win_focus_in(Ecore_Evas *ee)
83 {
84    Evas_Object *obj = ecore_evas_object_associate_get(ee);
85    Elm_Win *win;
86    
87    if (!obj) return;
88    win = elm_widget_data_get(obj);
89    if (!win) return;
90    /*NB: Why two different "focus signals" here ??? */
91    evas_object_smart_callback_call(win->win_obj, "focus-in", NULL); // FIXME: remove me
92    evas_object_smart_callback_call(win->win_obj, "focus,in", NULL);
93 }
94
95 static void
96 _elm_win_focus_out(Ecore_Evas *ee)
97 {
98    Evas_Object *obj = ecore_evas_object_associate_get(ee);
99    Elm_Win *win;
100    
101    if (!obj) return;
102    win = elm_widget_data_get(obj);
103    if (!win) return;
104    evas_object_smart_callback_call(win->win_obj, "focus-out", NULL); // FIXME: remove me
105    evas_object_smart_callback_call(win->win_obj, "focus,out", NULL);
106 }
107
108 static void
109 _deferred_ecore_evas_free(void *data)
110 {
111    ecore_evas_free(data);
112 }
113
114 static void
115 _elm_win_obj_callback_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
116 {
117    Elm_Win *win = data;
118    Evas_Object *child;
119
120    if (win->parent)
121      {
122         evas_object_event_callback_del_full(win->parent, EVAS_CALLBACK_DEL,
123                                             _elm_win_obj_callback_parent_del, win);
124         win->parent = NULL;
125      }
126    if (win->autodel_clear) *(win->autodel_clear) = -1;
127    _elm_win_list = eina_list_remove(_elm_win_list, win->win_obj);
128    while (win->subobjs) elm_win_resize_object_del(obj, win->subobjs->data);
129    ecore_evas_callback_delete_request_set(win->ee, NULL);
130    ecore_evas_callback_resize_set(win->ee, NULL);
131    if (win->deferred_resize_job) ecore_job_del(win->deferred_resize_job);
132    if (win->deferred_child_eval_job) ecore_job_del(win->deferred_child_eval_job);
133    while (((child = evas_object_bottom_get(win->evas)) != NULL) &&
134           (child != obj))
135      {
136         evas_object_del(child);
137      }
138    while (((child = evas_object_top_get(win->evas)) != NULL) &&
139           (child != obj))
140      {
141         evas_object_del(child);
142      }
143 #ifdef HAVE_ELEMENTARY_X
144    if (win->client_message_handler)
145      ecore_event_handler_del(win->client_message_handler);
146 #endif   
147 // FIXME: Why are we flushing edje on every window destroy ??
148 //   evas_image_cache_flush(win->evas);
149 //   evas_font_cache_flush(win->evas);
150 //   edje_file_cache_flush();
151 //   edje_collection_cache_flush();
152 // FIXME: we are in the del handler for the object and delete the canvas
153 // that lives under it from the handler... nasty. deferring doesnt help either
154    ecore_job_add(_deferred_ecore_evas_free, win->ee);
155 //   ecore_evas_free(win->ee);
156    free(win);
157
158    if ((!_elm_win_list) &&
159        (elm_policy_get(ELM_POLICY_QUIT) == ELM_POLICY_QUIT_LAST_WINDOW_CLOSED))
160      {
161         evas_image_cache_flush(e);
162         evas_font_cache_flush(e);
163         edje_file_cache_flush();
164         edje_collection_cache_flush();
165         elm_exit();
166      }
167 }
168
169 static void
170 _elm_win_obj_callback_parent_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
171 {
172    Elm_Win *win = data;
173    if (obj == win->parent) win->parent = NULL;
174 }
175
176 static void
177 _elm_win_obj_intercept_show(void *data __UNUSED__, Evas_Object *obj)
178 {
179    // this is called to make sure all smart containers have calculated their
180    // sizes BEFORE we show the window to make sure it initially appears at
181    // our desired size (ie min size is known first)
182    evas_smart_objects_calculate(evas_object_evas_get(obj));
183    evas_object_show(obj);
184 }
185
186 static void
187 _elm_win_delete_request(Ecore_Evas *ee)
188 {
189    Evas_Object *obj = ecore_evas_object_associate_get(ee);
190    Elm_Win *win;
191    if (strcmp(elm_widget_type_get(obj), "win")) return;
192    
193    win = elm_widget_data_get(obj);
194    if (!win) return;
195    int autodel = win->autodel;
196    win->autodel_clear = &autodel;
197    evas_object_smart_callback_call(win->win_obj, "delete-request", NULL); // FIXME: remove me
198    evas_object_smart_callback_call(win->win_obj, "delete,request", NULL);
199    // FIXME: if above callback deletes - then the below will be invalid
200    if (autodel) evas_object_del(win->win_obj);
201    else win->autodel_clear = NULL;
202 }
203
204 static void
205 _elm_win_resize_job(void *data)
206 {
207    Elm_Win *win = data;
208    const Eina_List *l;
209    Evas_Object *obj;
210    int w, h;
211
212    win->deferred_resize_job = NULL;
213    ecore_evas_geometry_get(win->ee, NULL, NULL, &w, &h);
214    evas_object_resize(win->win_obj, w, h);
215    EINA_LIST_FOREACH(win->subobjs, l, obj)
216      {
217         evas_object_move(obj, 0, 0);
218         evas_object_resize(obj, w, h);
219      }
220 }
221
222 #ifdef HAVE_ELEMENTARY_X
223 static void
224 _elm_win_xwindow_get(Elm_Win *win)
225 {
226    win->xwin = 0;
227    switch (_elm_config->engine)
228      {
229       case ELM_SOFTWARE_X11:
230         if (win->ee) win->xwin = ecore_evas_software_x11_window_get(win->ee);
231         break;
232       case ELM_SOFTWARE_FB:
233       case ELM_SOFTWARE_DIRECTFB:
234       case ELM_SOFTWARE_16_WINCE:
235       case ELM_SOFTWARE_SDL:
236       case ELM_SOFTWARE_16_SDL:
237       case ELM_OPENGL_SDL:
238         break;
239       case ELM_SOFTWARE_16_X11:
240         if (win->ee) win->xwin = ecore_evas_software_x11_16_window_get(win->ee);
241         break;
242       case ELM_XRENDER_X11:
243         if (win->ee) win->xwin = ecore_evas_xrender_x11_window_get(win->ee);
244         break;
245       case ELM_OPENGL_X11:
246         if (win->ee) win->xwin = ecore_evas_gl_x11_window_get(win->ee);
247         break;
248       case ELM_SOFTWARE_WIN32:
249         if (win->ee) win->xwin = (long)ecore_evas_win32_window_get(win->ee);
250         break;
251       default:
252         break;
253      }
254 }
255 #endif
256
257 #ifdef HAVE_ELEMENTARY_X
258 static void
259 _elm_win_xwin_update(Elm_Win *win)
260 {
261    _elm_win_xwindow_get(win);
262    if (win->parent)
263      {
264         Elm_Win *win2;
265
266         win2 = elm_widget_data_get(win->parent);
267         if (win2)
268           {
269              if (win->xwin)
270                ecore_x_icccm_transient_for_set(win->xwin, win2->xwin);
271           }
272      }
273
274    if (!win->xwin) return; /* nothing more to do */
275
276    switch (win->type)
277      {
278       case ELM_WIN_BASIC:
279          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_NORMAL);
280          break;
281       case ELM_WIN_DIALOG_BASIC:
282          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DIALOG);
283          break;
284       case ELM_WIN_DESKTOP:
285          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DESKTOP);
286          break;
287       case ELM_WIN_DOCK:
288          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DOCK);
289          break;
290       case ELM_WIN_TOOLBAR:
291          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_TOOLBAR);
292          break;
293       case ELM_WIN_MENU:
294          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_MENU);
295          break;
296       case ELM_WIN_UTILITY:
297          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_UTILITY);
298          break;
299       case ELM_WIN_SPLASH:
300          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_SPLASH);
301          break;
302       default:
303          break;
304      }
305    ecore_x_e_virtual_keyboard_state_set
306      (win->xwin, (Ecore_X_Virtual_Keyboard_State)win->kbdmode);
307 }
308 #endif
309
310 static void
311 _elm_win_eval_subobjs(Evas_Object *obj)
312 {
313    const Eina_List *l;
314    const Evas_Object *child;
315    
316    Elm_Win *win = elm_widget_data_get(obj);
317    Evas_Coord w, h, minw = -1, minh = -1, maxw = -1, maxh = -1;
318    int xx = 1, xy = 1;
319    double wx, wy;
320
321    EINA_LIST_FOREACH(win->subobjs, l, child)
322      {
323         evas_object_size_hint_weight_get(child, &wx, &wy);
324         if (wx == 0.0) xx = 0;
325         if (wy == 0.0) xy = 0;
326
327         evas_object_size_hint_min_get(child, &w, &h);
328         if (w < 1) w = -1;
329         if (h < 1) h = -1;
330         if (w > minw) minw = w;
331         if (h > minh) minh = h;
332
333         evas_object_size_hint_max_get(child, &w, &h);
334         if (w < 1) w = -1;
335         if (h < 1) h = -1;
336         if (maxw == -1) maxw = w;
337         else if ((w > 0) && (w < maxw)) maxw = w;
338         if (maxh == -1) maxh = h;
339         else if ((h > 0) && (h < maxh)) maxh = h;
340      }
341    if ((maxw >= 0) && (maxw < minw)) maxw = minw;
342    if ((maxh >= 0) && (maxh < minh)) maxh = minh;
343    if (!xx) maxw = minw;
344    else maxw = 32767;
345    if (!xy) maxh = minh;
346    else maxh = 32767;
347    evas_object_size_hint_min_set(obj, minw, minh);
348    evas_object_size_hint_max_set(obj, maxw, maxh);
349    evas_object_geometry_get(obj, NULL, NULL, &w, &h);
350    if (w < minw) w = minw;
351    if (h < minh) h = minh;
352    if ((maxw >= 0) && (w > maxw)) w = maxw;
353    if ((maxh >= 0) && (h > maxh)) h = maxh;
354    evas_object_resize(obj, w, h);
355 }
356
357 static void
358 _elm_win_subobj_callback_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
359 {
360    elm_win_resize_object_del(data, obj);
361 }
362
363 static void
364 _elm_win_subobj_callback_changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
365 {
366    _elm_win_eval_subobjs(data);
367 }
368
369 void
370 _elm_win_shutdown(void)
371 {
372    while (_elm_win_list)
373      evas_object_del(_elm_win_list->data);
374 }
375
376 void
377 _elm_win_rescale(void)
378 {
379    const Eina_List *l;
380    Evas_Object *obj;
381
382    EINA_LIST_FOREACH(_elm_win_list, l, obj)
383      elm_widget_theme(obj);
384 }
385
386 #ifdef HAVE_ELEMENTARY_X
387 static int
388 _elm_win_client_message(void *data, int type __UNUSED__, void *event)
389 {
390    Elm_Win *win = data;
391    Ecore_X_Event_Client_Message *e = event;
392
393    if (e->format != 32) return 1;
394    if (e->message_type == ECORE_X_ATOM_E_COMP_FLUSH)
395      {
396         if (e->data.l[0] == win->xwin)
397           {
398              Evas *evas = evas_object_evas_get(win->win_obj);
399              if (evas)
400                {
401                   edje_file_cache_flush();
402                   edje_collection_cache_flush();
403                   evas_image_cache_flush(evas);
404                   evas_font_cache_flush(evas);
405                }
406           }
407      }
408    else if (e->message_type == ECORE_X_ATOM_E_COMP_DUMP)
409      {
410         if (e->data.l[0] == win->xwin)
411           {
412              Evas *evas = evas_object_evas_get(win->win_obj);
413              if (evas)
414                {
415                   edje_file_cache_flush();
416                   edje_collection_cache_flush();
417                   evas_image_cache_flush(evas);
418                   evas_font_cache_flush(evas);
419                   evas_render_dump(evas);
420                }
421           }
422      }
423    return 1;
424 }
425 #endif
426
427 /**
428  * Adds a window object. If this is the first window created, pass NULL as
429  * @p parent.
430  *
431  * @param parent Parent object to add the window to, or NULL
432  * @param name The name of the window
433  * @param type The window type, one of the following:
434  * ELM_WIN_BASIC
435  * ELM_WIN_DIALOG_BASIC
436  * ELM_WIN_DESKTOP
437  * ELM_WIN_DOCK
438  * ELM_WIN_TOOLBAR
439  * ELM_WIN_MENU
440  * ELM_WIN_UTILITY
441  * ELM_WIN_SPLASH
442  *
443  * @return The created object, or NULL on failure
444  *
445  * @ingroup Win
446  */
447 EAPI Evas_Object *
448 elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type)
449 {
450    Elm_Win *win;
451    const Eina_List *l;
452    const char *fontpath;
453
454    win = ELM_NEW(Elm_Win);
455    switch (_elm_config->engine)
456      {
457       case ELM_SOFTWARE_X11:
458         win->ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
459 #ifdef HAVE_ELEMENTARY_X
460         win->client_message_handler = ecore_event_handler_add
461           (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
462 #endif        
463         break;
464       case ELM_SOFTWARE_FB:
465         win->ee = ecore_evas_fb_new(NULL, 0, 1, 1);
466         break;
467       case ELM_SOFTWARE_DIRECTFB:
468         win->ee = ecore_evas_directfb_new(NULL, 1, 0, 0, 1, 1);
469         break;
470       case ELM_SOFTWARE_16_X11:
471         win->ee = ecore_evas_software_x11_16_new(NULL, 0, 0, 0, 1, 1);
472         if (!win->ee)
473           {
474              CRITICAL("Software-16 engine create failed. Try software.");
475              win->ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
476           }
477 #ifdef HAVE_ELEMENTARY_X
478         win->client_message_handler = ecore_event_handler_add
479           (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
480 #endif        
481         break;
482       case ELM_XRENDER_X11:
483         win->ee = ecore_evas_xrender_x11_new(NULL, 0, 0, 0, 1, 1);
484         if (!win->ee)
485           {
486              CRITICAL("XRender engine create failed. Try software.");
487              win->ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
488           }
489 #ifdef HAVE_ELEMENTARY_X
490         win->client_message_handler = ecore_event_handler_add
491           (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
492 #endif        
493         break;
494       case ELM_OPENGL_X11:
495         win->ee = ecore_evas_gl_x11_new(NULL, 0, 0, 0, 1, 1);
496         if (!win->ee)
497           {
498              CRITICAL("OpenGL engine create failed. Try software.");
499              win->ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
500           }
501 #ifdef HAVE_ELEMENTARY_X
502         win->client_message_handler = ecore_event_handler_add
503           (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
504 #endif        
505         break;
506       case ELM_SOFTWARE_WIN32:
507         win->ee = ecore_evas_software_gdi_new(NULL, 0, 0, 1, 1);
508         break;
509       case ELM_SOFTWARE_16_WINCE:
510         win->ee = ecore_evas_software_wince_gdi_new(NULL, 0, 0, 1, 1);
511         break;
512       case ELM_SOFTWARE_SDL:
513         win->ee = ecore_evas_sdl_new(NULL, 0, 0, 0, 0, 0, 1);
514         if (!win->ee)
515           {
516              CRITICAL("Software SDL engine create failed. Try software.");
517              win->ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
518           }
519         break;
520       case ELM_SOFTWARE_16_SDL:
521         win->ee = ecore_evas_sdl16_new(NULL, 0, 0, 0, 0, 0, 1);
522         if (!win->ee)
523           {
524              CRITICAL("Sofware-16-SDL engine create failed. Try software.");
525              win->ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
526           }
527         break;
528       case ELM_OPENGL_SDL:
529         win->ee = ecore_evas_gl_sdl_new(NULL, 1, 1, 0, 0);
530         if (!win->ee)
531           {
532              CRITICAL("OpenGL SDL engine create failed. Try software.");
533              win->ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
534           }
535         break;
536       default:
537         break;
538      }
539    if (!win->ee)
540      {
541         ERR("Cannot create window.");
542         free(win);
543         return NULL;
544      }
545 #ifdef HAVE_ELEMENTARY_X
546    _elm_win_xwindow_get(win);
547 #endif   
548    if ((_elm_config->bgpixmap) && (!_elm_config->compositing))
549      ecore_evas_avoid_damage_set(win->ee, ECORE_EVAS_AVOID_DAMAGE_EXPOSE);
550 // bg pixmap done by x - has other issues like can be redrawn by x before it
551 // is filled/ready by app
552 //     ecore_evas_avoid_damage_set(win->ee, ECORE_EVAS_AVOID_DAMAGE_BUILT_IN);
553
554    win->type = type;
555    win->parent = parent;
556    if (win->parent)
557      evas_object_event_callback_add(win->parent, EVAS_CALLBACK_DEL,
558                                     _elm_win_obj_callback_parent_del, win);
559
560    win->evas = ecore_evas_get(win->ee);
561    win->win_obj = elm_widget_add(win->evas);
562    elm_widget_type_set(win->win_obj, "win");
563    ELM_SET_WIDTYPE(widtype, "win");
564    elm_widget_data_set(win->win_obj, win);
565    evas_object_color_set(win->win_obj, 0, 0, 0, 0);
566    evas_object_move(win->win_obj, 0, 0);
567    evas_object_resize(win->win_obj, 1, 1);
568    evas_object_layer_set(win->win_obj, 50);
569    evas_object_pass_events_set(win->win_obj, 1);
570
571    evas_object_intercept_show_callback_add(win->win_obj,
572                                            _elm_win_obj_intercept_show, win);
573    ecore_evas_object_associate(win->ee, win->win_obj,
574                                ECORE_EVAS_OBJECT_ASSOCIATE_BASE |
575                                ECORE_EVAS_OBJECT_ASSOCIATE_STACK |
576                                ECORE_EVAS_OBJECT_ASSOCIATE_LAYER);
577    evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_DEL,
578                                   _elm_win_obj_callback_del, win);
579
580    ecore_evas_name_class_set(win->ee, name, _elm_appname);
581    ecore_evas_callback_delete_request_set(win->ee, _elm_win_delete_request);
582    ecore_evas_callback_resize_set(win->ee, _elm_win_resize);
583    ecore_evas_callback_focus_in_set(win->ee, _elm_win_focus_in);
584    ecore_evas_callback_focus_out_set(win->ee, _elm_win_focus_out);
585    ecore_evas_callback_move_set(win->ee, _elm_win_move);
586    evas_image_cache_set(win->evas, (_elm_config->image_cache * 1024));
587    evas_font_cache_set(win->evas, (_elm_config->font_cache * 1024));
588    EINA_LIST_FOREACH(_elm_config->font_dirs, l, fontpath)
589      evas_font_path_append(win->evas, fontpath);
590    if (_elm_config->font_hinting == 0)
591      evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_NONE);
592    else if (_elm_config->font_hinting == 1)
593      evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_AUTO);
594    else if (_elm_config->font_hinting == 2)
595      evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_BYTECODE);
596
597 #ifdef HAVE_ELEMENTARY_X
598    _elm_win_xwin_update(win);
599 #endif
600    
601    _elm_win_list = eina_list_append(_elm_win_list, win->win_obj);
602
603    switch (_elm_config->engine)
604      {
605       case ELM_SOFTWARE_16_WINCE:
606       case ELM_SOFTWARE_FB:
607         ecore_evas_fullscreen_set(win->ee, 1);
608         break;
609       case ELM_SOFTWARE_X11:
610       case ELM_SOFTWARE_16_X11:
611       case ELM_XRENDER_X11:
612       case ELM_OPENGL_X11:
613       case ELM_SOFTWARE_WIN32:
614       case ELM_SOFTWARE_SDL:
615       case ELM_SOFTWARE_16_SDL:
616       case ELM_OPENGL_SDL:
617       default:
618         break;
619      }
620    
621    return win->win_obj;
622 }
623
624 /**
625  * Add @p subobj as a resize object of window @p obj.
626  *
627  * @param obj The window object
628  * @param subobj The resize object to add
629  *
630  * @ingroup Win
631  */
632 EAPI void
633 elm_win_resize_object_add(Evas_Object *obj, Evas_Object *subobj)
634 {
635    Evas_Coord w, h;
636    Elm_Win *win;
637    ELM_CHECK_WIDTYPE(obj, widtype);
638    win = elm_widget_data_get(obj);
639    if (!win) return;
640    win->subobjs = eina_list_append(win->subobjs, subobj);
641    elm_widget_sub_object_add(obj, subobj);
642    evas_object_event_callback_add(subobj, EVAS_CALLBACK_DEL,
643                                   _elm_win_subobj_callback_del, obj);
644    evas_object_event_callback_add(subobj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
645                                   _elm_win_subobj_callback_changed_size_hints,
646                                   obj);
647    ecore_evas_geometry_get(win->ee, NULL, NULL, &w, &h);
648    evas_object_move(subobj, 0, 0);
649    evas_object_resize(subobj, w, h);
650    _elm_win_eval_subobjs(obj);
651 }
652
653 /**
654  * Delete @p subobj as a resize object of window @p obj.
655  *
656  * @param obj The window object
657  * @param subobj The resize object to add
658  *
659  * @ingroup Win
660  */
661 EAPI void
662 elm_win_resize_object_del(Evas_Object *obj, Evas_Object *subobj)
663 {
664    Elm_Win *win;
665    ELM_CHECK_WIDTYPE(obj, widtype);
666    win = elm_widget_data_get(obj);
667    if (!win) return;
668    evas_object_event_callback_del_full(subobj,
669                                        EVAS_CALLBACK_CHANGED_SIZE_HINTS,
670                                        _elm_win_subobj_callback_changed_size_hints,
671                                        obj);
672    evas_object_event_callback_del_full(subobj, EVAS_CALLBACK_DEL,
673                                        _elm_win_subobj_callback_del, obj);
674    win->subobjs = eina_list_remove(win->subobjs, subobj);
675    elm_widget_sub_object_del(obj, subobj);
676    _elm_win_eval_subobjs(obj);
677 }
678
679 /**
680  * Set the title of the window
681  *
682  * @param obj The window object
683  * @param title The title to set
684  *
685  * @ingroup Win
686  */
687 EAPI void
688 elm_win_title_set(Evas_Object *obj, const char *title)
689 {
690    Elm_Win *win;
691    ELM_CHECK_WIDTYPE(obj, widtype);
692    win = elm_widget_data_get(obj);
693    if (!win) return;
694    ecore_evas_title_set(win->ee, title);
695 }
696
697 /**
698  * Set the window's autodel state.
699  *
700  * @param obj The window object
701  * @param autodel If true, the window will automatically delete itself when closed
702  *
703  * @ingroup Win
704  */
705 EAPI void
706 elm_win_autodel_set(Evas_Object *obj, Eina_Bool autodel)
707 {
708    Elm_Win *win;
709    ELM_CHECK_WIDTYPE(obj, widtype);
710    win = elm_widget_data_get(obj);
711    if (!win) return;
712    win->autodel = autodel;
713 }
714
715 /**
716  * Activate a window object.
717  *
718  * @param obj The window object
719  *
720  * @ingroup Win
721  */
722 EAPI void
723 elm_win_activate(Evas_Object *obj)
724 {
725    Elm_Win *win;
726    ELM_CHECK_WIDTYPE(obj, widtype);
727    win = elm_widget_data_get(obj);
728    if (!win) return;
729    ecore_evas_activate(win->ee);
730 }
731
732 /**
733  * Lower a window object.
734  *
735  * @param obj The window object
736  *
737  * @ingroup Win
738  */
739 EAPI void
740 elm_win_lower(Evas_Object *obj)
741 {
742    Elm_Win *win;
743    ELM_CHECK_WIDTYPE(obj, widtype);
744    win = elm_widget_data_get(obj);
745    if (!win) return;
746    ecore_evas_lower(win->ee);
747 }
748
749 /**
750  * Raise a window object.
751  *
752  * @param obj The window object
753  *
754  * @ingroup Win
755  */
756 EAPI void
757 elm_win_raise(Evas_Object *obj)
758 {
759    Elm_Win *win;
760    ELM_CHECK_WIDTYPE(obj, widtype);
761    win = elm_widget_data_get(obj);
762    if (!win) return;
763    ecore_evas_raise(win->ee);
764 }
765
766 /**
767  * Set the borderless state of a window.
768  *
769  * @param obj The window object
770  * @param borderless If true, the window is borderless
771  *
772  * @ingroup Win
773  */
774 EAPI void
775 elm_win_borderless_set(Evas_Object *obj, Eina_Bool borderless)
776 {
777    Elm_Win *win;
778    ELM_CHECK_WIDTYPE(obj, widtype);
779    win = elm_widget_data_get(obj);
780    if (!win) return;
781    ecore_evas_borderless_set(win->ee, borderless);
782 #ifdef HAVE_ELEMENTARY_X
783    _elm_win_xwin_update(win);
784 #endif
785 }
786
787 /**
788  * Get the borderless state of a window.
789  *
790  * @param obj The window object
791  * @return If true, the window is borderless
792  *
793  * @ingroup Win
794  */
795 EAPI Eina_Bool
796 elm_win_borderless_get(const Evas_Object *obj)
797 {
798    Elm_Win *win;
799    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
800    win = elm_widget_data_get(obj);
801    if (!win) return EINA_FALSE;
802    return ecore_evas_borderless_get(win->ee);
803 }
804
805 /**
806  * Set the shaped state of a window.
807  *
808  * @param obj The window object
809  * @param shaped If true, the window is shaped
810  *
811  * @ingroup Win
812  */
813 EAPI void
814 elm_win_shaped_set(Evas_Object *obj, Eina_Bool shaped)
815 {
816    Elm_Win *win;
817    ELM_CHECK_WIDTYPE(obj, widtype);
818    win = elm_widget_data_get(obj);
819    if (!win) return;
820    ecore_evas_shaped_set(win->ee, shaped);
821 #ifdef HAVE_ELEMENTARY_X
822    _elm_win_xwin_update(win);
823 #endif
824 }
825
826 /**
827  * Get the shaped state of a window.
828  *
829  * @param obj The window object
830  * @return If true, the window is shaped
831  *
832  * @ingroup Win
833  */
834 EAPI Eina_Bool
835 elm_win_shaped_get(const Evas_Object *obj)
836 {
837    Elm_Win *win;
838    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
839    win = elm_widget_data_get(obj);
840    if (!win) return EINA_FALSE;
841    return ecore_evas_shaped_get(win->ee);
842 }
843
844 /**
845  * Set the alpha channel state of a window.
846  *
847  * @param obj The window object
848  * @param alpha If true, the window has an alpha channel
849  *
850  * @ingroup Win
851  */
852 EAPI void
853 elm_win_alpha_set(Evas_Object *obj, Eina_Bool alpha)
854 {
855    Elm_Win *win;
856    ELM_CHECK_WIDTYPE(obj, widtype);
857    win = elm_widget_data_get(obj);
858    if (!win) return;
859 #ifdef HAVE_ELEMENTARY_X
860    if (win->xwin)
861      {
862         if (alpha)
863           {
864              if (!_elm_config->compositing)
865                elm_win_shaped_set(obj, alpha);
866              else
867                ecore_evas_alpha_set(win->ee, alpha);
868           }
869         else
870           ecore_evas_alpha_set(win->ee, alpha);
871         _elm_win_xwin_update(win);
872      }
873    else
874 #endif
875      ecore_evas_alpha_set(win->ee, alpha);
876 }
877
878 /**
879  * Get the alpha channel state of a window.
880  *
881  * @param obj The window object
882  * @return If true, the window has an alpha channel
883  *
884  * @ingroup Win
885  */
886 EAPI Eina_Bool
887 elm_win_alpha_get(const Evas_Object *obj)
888 {
889    Elm_Win *win;
890    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
891    win = elm_widget_data_get(obj);
892    if (!win) return EINA_FALSE;
893    return ecore_evas_alpha_get(win->ee);
894 }
895
896 /**
897  * Set the transparency state of a window.
898  *
899  * @param obj The window object
900  * @param transparent If true, the window is transparent
901  *
902  * @ingroup Win
903  */
904 EAPI void
905 elm_win_transparent_set(Evas_Object *obj, Eina_Bool transparent)
906 {
907    Elm_Win *win;
908    ELM_CHECK_WIDTYPE(obj, widtype);
909    win = elm_widget_data_get(obj);
910    if (!win) return;
911    
912 #ifdef HAVE_ELEMENTARY_X
913    if (win->xwin)
914      {
915        ecore_evas_transparent_set(win->ee, transparent);          
916         _elm_win_xwin_update(win);
917      }
918    else
919 #endif
920      ecore_evas_transparent_set(win->ee, transparent);
921 }
922
923 /**
924  * Get the transparency state of a window.
925  *
926  * @param obj The window object
927  * @return If true, the window is transparent
928  *
929  * @ingroup Win
930  */
931 EAPI Eina_Bool
932 elm_win_transparent_get(const Evas_Object *obj)
933 {
934    Elm_Win *win;
935    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
936    win = elm_widget_data_get(obj);
937    if (!win) return EINA_FALSE;
938
939    return ecore_evas_transparent_get(win->ee);
940 }
941
942 /**
943  * Set the override state of a window.
944  *
945  * @param obj The window object
946  * @param override If true, the window is overridden
947  *
948  * @ingroup Win
949  */
950 EAPI void
951 elm_win_override_set(Evas_Object *obj, Eina_Bool override)
952 {
953    Elm_Win *win;
954    ELM_CHECK_WIDTYPE(obj, widtype);
955    win = elm_widget_data_get(obj);
956    if (!win) return;
957    ecore_evas_override_set(win->ee, override);
958 #ifdef HAVE_ELEMENTARY_X
959    _elm_win_xwin_update(win);
960 #endif
961 }
962
963 /**
964  * Get the override state of a window.
965  *
966  * @param obj The window object
967  * @return If true, the window is overridden
968  *
969  * @ingroup Win
970  */
971 EAPI Eina_Bool
972 elm_win_override_get(const Evas_Object *obj)
973 {
974    Elm_Win *win;
975    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
976    win = elm_widget_data_get(obj);
977    if (!win) return EINA_FALSE;
978    return ecore_evas_override_get(win->ee);
979 }
980
981 /**
982  * Set the fullscreen state of a window.
983  *
984  * @param obj The window object
985  * @param fullscreen If true, the window is fullscreen
986  *
987  * @ingroup Win
988  */
989 EAPI void
990 elm_win_fullscreen_set(Evas_Object *obj, Eina_Bool fullscreen)
991 {
992    Elm_Win *win;
993    ELM_CHECK_WIDTYPE(obj, widtype);
994    win = elm_widget_data_get(obj);
995    if (!win) return;
996    switch (_elm_config->engine)
997      {
998      case ELM_SOFTWARE_16_WINCE:
999      case ELM_SOFTWARE_FB:
1000         // these engines... can ONLY be fullscreen
1001         break;
1002      default:
1003         ecore_evas_fullscreen_set(win->ee, fullscreen);
1004 #ifdef HAVE_ELEMENTARY_X
1005         _elm_win_xwin_update(win);
1006 #endif
1007         break;
1008      }
1009 }
1010
1011 /**
1012  * Get the fullscreen state of a window.
1013  *
1014  * @param obj The window object
1015  * @return If true, the window is fullscreen
1016  *
1017  * @ingroup Win
1018  */
1019 EAPI Eina_Bool
1020 elm_win_fullscreen_get(const Evas_Object *obj)
1021 {
1022    Elm_Win *win;
1023    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1024    win = elm_widget_data_get(obj);
1025    if (!win) return EINA_FALSE;
1026    switch (_elm_config->engine)
1027      {
1028      case ELM_SOFTWARE_16_WINCE:
1029      case ELM_SOFTWARE_FB:
1030         // these engines... can ONLY be fullscreen
1031         return EINA_TRUE;
1032         break;
1033      default:
1034         return ecore_evas_fullscreen_get(win->ee);
1035         break;
1036      }
1037    return EINA_FALSE;
1038 }
1039
1040 /**
1041  * Set the maximized state of a window.
1042  *
1043  * @param obj The window object
1044  * @param maximized If true, the window is maximized
1045  *
1046  * @ingroup Win
1047  */
1048 EAPI void
1049 elm_win_maximized_set(Evas_Object *obj, Eina_Bool maximized)
1050 {
1051    Elm_Win *win;
1052    ELM_CHECK_WIDTYPE(obj, widtype);
1053    win = elm_widget_data_get(obj);
1054    if (!win) return;
1055    ecore_evas_maximized_set(win->ee, maximized);
1056 #ifdef HAVE_ELEMENTARY_X
1057    _elm_win_xwin_update(win);
1058 #endif
1059 }
1060
1061 /**
1062  * Get the maximized state of a window.
1063  *
1064  * @param obj The window object
1065  * @return If true, the window is maximized
1066  *
1067  * @ingroup Win
1068  */
1069 EAPI Eina_Bool
1070 elm_win_maximized_get(const Evas_Object *obj)
1071 {
1072    Elm_Win *win;
1073    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1074    win = elm_widget_data_get(obj);
1075    if (!win) return EINA_FALSE;
1076    return ecore_evas_maximized_get(win->ee);
1077 }
1078
1079 /**
1080  * Set the iconified state of a window.
1081  *
1082  * @param obj The window object
1083  * @param iconified If true, the window is iconified
1084  *
1085  * @ingroup Win
1086  */
1087 EAPI void
1088 elm_win_iconified_set(Evas_Object *obj, Eina_Bool iconified)
1089 {
1090    Elm_Win *win;
1091    ELM_CHECK_WIDTYPE(obj, widtype);
1092    win = elm_widget_data_get(obj);
1093    if (!win) return;
1094    ecore_evas_iconified_set(win->ee, iconified);
1095 #ifdef HAVE_ELEMENTARY_X
1096    _elm_win_xwin_update(win);
1097 #endif
1098 }
1099
1100 /**
1101  * Get the iconified state of a window.
1102  *
1103  * @param obj The window object
1104  * @return If true, the window is iconified
1105  *
1106  * @ingroup Win
1107  */
1108 EAPI Eina_Bool
1109 elm_win_iconified_get(const Evas_Object *obj)
1110 {
1111    Elm_Win *win;
1112    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1113    win = elm_widget_data_get(obj);
1114    if (!win) return EINA_FALSE;
1115    return ecore_evas_iconified_get(win->ee);
1116 }
1117
1118 /**
1119  * Set the layer of the window.
1120  *
1121  * @param obj The window object
1122  * @param layer The layer of the window
1123  *
1124  * @ingroup Win
1125  */
1126 EAPI void
1127 elm_win_layer_set(Evas_Object *obj, int layer)
1128 {
1129    Elm_Win *win;
1130    ELM_CHECK_WIDTYPE(obj, widtype);
1131    win = elm_widget_data_get(obj);
1132    if (!win) return;
1133    ecore_evas_layer_set(win->ee, layer); 
1134 #ifdef HAVE_ELEMENTARY_X
1135    _elm_win_xwin_update(win);
1136 #endif
1137 }
1138
1139 /**
1140  * Get the layer of the window.
1141  *
1142  * @param obj The window object
1143  * @return The layer of the window
1144  *
1145  * @ingroup Win
1146  */
1147 EAPI int
1148 elm_win_layer_get(const Evas_Object *obj)
1149 {
1150    Elm_Win *win;
1151    ELM_CHECK_WIDTYPE(obj, widtype) -1;
1152    win = elm_widget_data_get(obj);
1153    if (!win) return -1;
1154    return ecore_evas_layer_get(win->ee);
1155 }
1156
1157 /**
1158  * Set the rotation of the window.
1159  *
1160  * @param obj The window object
1161  * @param rotation The rotation of the window, in degrees (0-360)
1162  *
1163  * @ingroup Win
1164  */
1165 EAPI void
1166 elm_win_rotation_set(Evas_Object *obj, int rotation)
1167 {
1168    Elm_Win *win;
1169    ELM_CHECK_WIDTYPE(obj, widtype);
1170    win = elm_widget_data_get(obj);
1171    if (!win) return;
1172    if (win->rot == rotation) return;
1173    win->rot = rotation;
1174    ecore_evas_rotation_set(win->ee, rotation);
1175    evas_object_size_hint_min_set(obj, -1, -1);
1176    evas_object_size_hint_max_set(obj, -1, -1);
1177    _elm_win_eval_subobjs(obj);
1178 #ifdef HAVE_ELEMENTARY_X
1179    _elm_win_xwin_update(win);
1180 #endif
1181 }
1182
1183 /**
1184  * Rotates the window and resizes it
1185  *
1186  * @param obj The window object
1187  * @param layer The rotation of the window in degrees (0-360)
1188  *
1189  * @ingroup Win
1190  */
1191 EAPI void
1192 elm_win_rotation_with_resize_set(Evas_Object *obj, int rotation)
1193 {
1194    Elm_Win *win;
1195    ELM_CHECK_WIDTYPE(obj, widtype);
1196    win = elm_widget_data_get(obj);
1197    if (!win) return;
1198    if (win->rot == rotation) return;
1199    win->rot = rotation;
1200    ecore_evas_rotation_with_resize_set(win->ee, rotation);
1201    evas_object_size_hint_min_set(obj, -1, -1);
1202    evas_object_size_hint_max_set(obj, -1, -1);
1203    _elm_win_eval_subobjs(obj);
1204 #ifdef HAVE_ELEMENTARY_X
1205    _elm_win_xwin_update(win);
1206 #endif
1207 }
1208
1209 /**
1210  * Get the rotation of the window.
1211  *
1212  * @param obj The window object
1213  * @return The rotation of the window in degrees (0-360)
1214  *
1215  * @ingroup Win
1216  */
1217 EAPI int
1218 elm_win_rotation_get(const Evas_Object *obj)
1219 {
1220    Elm_Win *win;
1221    ELM_CHECK_WIDTYPE(obj, widtype) -1;
1222    win = elm_widget_data_get(obj);
1223    if (!win) return -1;
1224    return win->rot;
1225 }
1226
1227 /**
1228  * Set the sticky state of the window.
1229  *
1230  * @param obj The window object
1231  * @param sticky If true, the window's sticky state is enabled
1232  *
1233  * @ingroup Win
1234  */
1235 EAPI void
1236 elm_win_sticky_set(Evas_Object *obj, Eina_Bool sticky)
1237 {
1238    Elm_Win *win;
1239    ELM_CHECK_WIDTYPE(obj, widtype);
1240    win = elm_widget_data_get(obj);
1241    if (!win) return;
1242    ecore_evas_sticky_set(win->ee, sticky);
1243 #ifdef HAVE_ELEMENTARY_X
1244    _elm_win_xwin_update(win);
1245 #endif
1246 }
1247
1248 /**
1249  * Get the sticky state of the window.
1250  *
1251  * @param obj The window object
1252  * @return If true, the window's sticky state is enabled
1253  *
1254  * @ingroup Win
1255  */
1256 EAPI Eina_Bool
1257 elm_win_sticky_get(const Evas_Object *obj)
1258 {
1259    Elm_Win *win;
1260    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1261    win = elm_widget_data_get(obj);
1262    if (!win) return EINA_FALSE;
1263    return ecore_evas_sticky_get(win->ee);
1264 }
1265
1266 /**
1267  * Sets the keyboard mode of the window.
1268  *
1269  * @param obj The window object
1270  * @param mode The mode to set; one of:
1271  * ELM_WIN_KEYBOARD_UNKNOWN
1272  * ELM_WIN_KEYBOARD_OFF
1273  * ELM_WIN_KEYBOARD_ON
1274  * ELM_WIN_KEYBOARD_ALPHA
1275  * ELM_WIN_KEYBOARD_NUMERIC
1276  * ELM_WIN_KEYBOARD_PIN
1277  * ELM_WIN_KEYBOARD_PHONE_NUMBER
1278  * ELM_WIN_KEYBOARD_HEX
1279  * ELM_WIN_KEYBOARD_TERMINAL
1280  * ELM_WIN_KEYBOARD_PASSWORD
1281  * ELM_WIN_KEYBOARD_IP
1282  * ELM_WIN_KEYBOARD_HOST
1283  * ELM_WIN_KEYBOARD_FILE
1284  * ELM_WIN_KEYBOARD_URL
1285  * ELM_WIN_KEYBOARD_KEYPAD
1286  * ELM_WIN_KEYBOARD_J2ME
1287  *
1288  * @ingroup Win
1289  */
1290 EAPI void
1291 elm_win_keyboard_mode_set(Evas_Object *obj, Elm_Win_Keyboard_Mode mode)
1292 {
1293    Elm_Win *win;
1294    ELM_CHECK_WIDTYPE(obj, widtype);
1295    win = elm_widget_data_get(obj);
1296    if (!win) return;
1297    if (mode == win->kbdmode) return;
1298 #ifdef HAVE_ELEMENTARY_X
1299    _elm_win_xwindow_get(win);
1300 #endif
1301    win->kbdmode = mode;
1302 #ifdef HAVE_ELEMENTARY_X
1303    if (win->xwin)
1304      ecore_x_e_virtual_keyboard_state_set
1305      (win->xwin, (Ecore_X_Virtual_Keyboard_State)win->kbdmode);
1306 #endif
1307 }
1308
1309 /**
1310  * Sets whether the window is a keyboard.
1311  *
1312  * @param obj The window object
1313  * @param is_keyboard If true, the window is a virtual keyboard
1314  *
1315  * @ingroup Win
1316  */
1317 EAPI void
1318 elm_win_keyboard_win_set(Evas_Object *obj, Eina_Bool is_keyboard)
1319 {
1320    Elm_Win *win;
1321    ELM_CHECK_WIDTYPE(obj, widtype);
1322    win = elm_widget_data_get(obj);
1323    if (!win) return;
1324 #ifdef HAVE_ELEMENTARY_X
1325    _elm_win_xwindow_get(win);
1326    if (win->xwin)
1327      ecore_x_e_virtual_keyboard_set(win->xwin, is_keyboard);
1328 #endif
1329 }
1330
1331 /**
1332  * Get the screen position of a window.
1333  *
1334  * @param obj The window object
1335  * @param x The int to store the x coordinate to
1336  * @param y The int to store the y coordinate to
1337  *
1338  * @ingroup Win
1339  */
1340 EAPI void
1341 elm_win_screen_position_get(const Evas_Object *obj, int *x, int *y)
1342 {
1343    Elm_Win *win;
1344    ELM_CHECK_WIDTYPE(obj, widtype);
1345    win = elm_widget_data_get(obj);
1346    if (!win) return;
1347    if (x) *x = win->screen.x;
1348    if (y) *y = win->screen.y;
1349 }
1350
1351 /**
1352  * Set if this window is an illume conformant window
1353  *
1354  * @param obj The window object
1355  * @param conformant The conformant flag (1 = conformant, 0 = non-conformant)
1356  *
1357  * @ingroup Win
1358  */
1359 EAPI void
1360 elm_win_conformant_set(Evas_Object *obj, Eina_Bool conformant)
1361 {
1362    Elm_Win *win;
1363    ELM_CHECK_WIDTYPE(obj, widtype);
1364    win = elm_widget_data_get(obj);
1365    if (!win) return;
1366 #ifdef HAVE_ELEMENTARY_X
1367    _elm_win_xwindow_get(win);
1368    if (win->xwin)
1369      ecore_x_e_illume_conformant_set(win->xwin, conformant);
1370 #endif
1371 }
1372
1373 /**
1374  * Get if this window is an illume conformant window
1375  *
1376  * @param obj The window object
1377  * @return A boolean if this window is illume conformant or not
1378  *
1379  * @ingroup Win
1380  */
1381 EAPI Eina_Bool
1382 elm_win_conformant_get(const Evas_Object *obj)
1383 {
1384    Elm_Win *win;
1385    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1386    win = elm_widget_data_get(obj);
1387    if (!win) return EINA_FALSE;
1388 #ifdef HAVE_ELEMENTARY_X
1389    _elm_win_xwindow_get(win);
1390    if (win->xwin)
1391      return ecore_x_e_illume_conformant_get(win->xwin);
1392 #endif
1393    return EINA_FALSE;
1394 }
1395
1396 /**
1397  * Set a window to be an illume quickpanel window
1398  *
1399  * By default window objects are not quickpanel windows.
1400  *
1401  * @param obj The window object
1402  * @param quickpanel The quickpanel flag (1 = quickpanel, 0 = normal window)
1403  *
1404  * @ingroup Win
1405  */
1406 EAPI void
1407 elm_win_quickpanel_set(Evas_Object *obj, Eina_Bool quickpanel)
1408 {
1409    Elm_Win *win;
1410    ELM_CHECK_WIDTYPE(obj, widtype);
1411    win = elm_widget_data_get(obj);
1412    if (!win) return;
1413 #ifdef HAVE_ELEMENTARY_X
1414    _elm_win_xwindow_get(win);
1415    if (win->xwin)
1416      {
1417         ecore_x_e_illume_quickpanel_set(win->xwin, quickpanel);
1418         if (quickpanel)
1419           {
1420              Ecore_X_Window_State states[2];
1421
1422              states[0] = ECORE_X_WINDOW_STATE_SKIP_TASKBAR;
1423              states[1] = ECORE_X_WINDOW_STATE_SKIP_PAGER;
1424              ecore_x_netwm_window_state_set(win->xwin, states, 2);
1425              ecore_x_icccm_hints_set(win->xwin, 0, 0, 0, 0, 0, 0, 0);
1426           }
1427      }
1428 #endif
1429 }
1430
1431 /**
1432  * Get if this window is a quickpanel or not
1433  *
1434  * @param obj The window object
1435  * @return A boolean if this window is a quickpanel or not
1436  *
1437  * @ingroup Win
1438  */
1439 EAPI Eina_Bool
1440 elm_win_quickpanel_get(const Evas_Object *obj)
1441 {
1442    Elm_Win *win;
1443    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1444    win = elm_widget_data_get(obj);
1445    if (!win) return EINA_FALSE;
1446 #ifdef HAVE_ELEMENTARY_X
1447    _elm_win_xwindow_get(win);
1448    if (win->xwin)
1449      return ecore_x_e_illume_quickpanel_get(win->xwin);
1450 #endif
1451    return EINA_FALSE;
1452 }
1453
1454 /**
1455  * Set the major priority of a quickpanel window
1456  *
1457  * @param obj The window object
1458  * @param priority The major priority for this quickpanel
1459  *
1460  * @ingroup Win
1461  */
1462 EAPI void
1463 elm_win_quickpanel_priority_major_set(Evas_Object *obj, int priority)
1464 {
1465    Elm_Win *win;
1466    ELM_CHECK_WIDTYPE(obj, widtype);
1467    win = elm_widget_data_get(obj);
1468    if (!win) return;
1469 #ifdef HAVE_ELEMENTARY_X
1470    _elm_win_xwindow_get(win);
1471    if (win->xwin)
1472      ecore_x_e_illume_quickpanel_priority_major_set(win->xwin, priority);
1473 #endif
1474 }
1475
1476 /**
1477  * Get the major priority of a quickpanel window
1478  *
1479  * @param obj The window object
1480  * @return The major priority of this quickpanel
1481  *
1482  * @ingroup Win
1483  */
1484 EAPI int
1485 elm_win_quickpanel_priority_major_get(const Evas_Object *obj)
1486 {
1487    Elm_Win *win;
1488    ELM_CHECK_WIDTYPE(obj, widtype) -1;
1489    win = elm_widget_data_get(obj);
1490    if (!win) return -1;
1491 #ifdef HAVE_ELEMENTARY_X
1492    _elm_win_xwindow_get(win);
1493    if (win->xwin)
1494      return ecore_x_e_illume_quickpanel_priority_major_get(win->xwin);
1495 #endif
1496    return -1;
1497 }
1498
1499 /**
1500  * Set the minor priority of a quickpanel window
1501  *
1502  * @param obj The window object
1503  * @param priority The minor priority for this quickpanel
1504  *
1505  * @ingroup Win
1506  */
1507 EAPI void
1508 elm_win_quickpanel_priority_minor_set(Evas_Object *obj, int priority)
1509 {
1510    Elm_Win *win;
1511    ELM_CHECK_WIDTYPE(obj, widtype);
1512    win = elm_widget_data_get(obj);
1513    if (!win) return;
1514 #ifdef HAVE_ELEMENTARY_X
1515    _elm_win_xwindow_get(win);
1516    if (win->xwin)
1517      ecore_x_e_illume_quickpanel_priority_minor_set(win->xwin, priority);
1518 #endif
1519 }
1520
1521 /**
1522  * Get the minor priority of a quickpanel window
1523  *
1524  * @param obj The window object
1525  * @return The minor priority of this quickpanel
1526  *
1527  * @ingroup Win
1528  */
1529 EAPI int
1530 elm_win_quickpanel_priority_minor_get(const Evas_Object *obj)
1531 {
1532    Elm_Win *win;
1533    ELM_CHECK_WIDTYPE(obj, widtype) -1;
1534    win = elm_widget_data_get(obj);
1535    if (!win) return -1;
1536 #ifdef HAVE_ELEMENTARY_X
1537    _elm_win_xwindow_get(win);
1538    if (win->xwin)
1539      return ecore_x_e_illume_quickpanel_priority_minor_get(win->xwin);
1540 #endif
1541    return -1;
1542 }
1543
1544 /**
1545  * Set which zone this quickpanel should appear in
1546  *
1547  * @param obj The window object
1548  * @param zone The requested zone for this quickpanel
1549  *
1550  * @ingroup Win
1551  */
1552 EAPI void
1553 elm_win_quickpanel_zone_set(Evas_Object *obj, int zone)
1554 {
1555    Elm_Win *win;
1556    ELM_CHECK_WIDTYPE(obj, widtype);
1557    win = elm_widget_data_get(obj);
1558    if (!win) return;
1559 #ifdef HAVE_ELEMENTARY_X
1560    _elm_win_xwindow_get(win);
1561    if (win->xwin)
1562      ecore_x_e_illume_quickpanel_zone_set(win->xwin, zone);
1563 #endif
1564 }
1565
1566 typedef struct _Widget_Data Widget_Data;
1567
1568 struct _Widget_Data
1569 {
1570    Evas_Object *frm;
1571    Evas_Object *content;
1572 };
1573
1574 static void _del_hook(Evas_Object *obj);
1575 static void _theme_hook(Evas_Object *obj);
1576 static void _sizing_eval(Evas_Object *obj);
1577 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
1578 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
1579
1580 static const char *widtype2 = NULL;
1581
1582 static void
1583 _del_hook(Evas_Object *obj)
1584 {
1585    Widget_Data *wd = elm_widget_data_get(obj);
1586    free(wd);
1587 }
1588
1589 static void
1590 _theme_hook(Evas_Object *obj)
1591 {
1592    Widget_Data *wd = elm_widget_data_get(obj);
1593    _elm_theme_object_set(obj, wd->frm, "win", "inwin", elm_widget_style_get(obj));
1594    if (wd->content)
1595      edje_object_part_swallow(wd->frm, "elm.swallow.content", wd->content);
1596    _sizing_eval(obj);
1597 }
1598
1599 static void
1600 _sizing_eval(Evas_Object *obj)
1601 {
1602    Widget_Data *wd = elm_widget_data_get(obj);
1603    Evas_Coord minw = -1, minh = -1;
1604
1605    evas_object_size_hint_min_get(wd->content, &minw, &minh);
1606    edje_object_size_min_calc(wd->frm, &minw, &minh);
1607    evas_object_size_hint_min_set(obj, minw, minh);
1608    evas_object_size_hint_max_set(obj, -1, -1);
1609 }
1610
1611 static void
1612 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1613 {
1614    _sizing_eval(data);
1615 }
1616
1617 static void
1618 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
1619 {
1620    Widget_Data *wd = elm_widget_data_get(obj);
1621    Evas_Object *sub = event_info;
1622    if (sub == wd->content)
1623      {
1624         evas_object_event_callback_del_full
1625           (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
1626         wd->content = NULL;
1627         _sizing_eval(obj);
1628      }
1629 }
1630
1631 /**
1632  * @defgroup Inwin Inwin
1633  *
1634  * An inwin is a window inside a window that is useful for a quick popup.  It does not hover.
1635  */
1636 EAPI Evas_Object *
1637 elm_win_inwin_add(Evas_Object *obj)
1638 {
1639    Evas_Object *obj2;
1640    Widget_Data *wd;
1641    Elm_Win *win;
1642
1643    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1644    win = elm_widget_data_get(obj);
1645    if (!win) return NULL;
1646    wd = ELM_NEW(Widget_Data);
1647    obj2 = elm_widget_add(win->evas);
1648    elm_widget_type_set(obj2, "inwin");
1649    ELM_SET_WIDTYPE(widtype2, "inwin");
1650    elm_widget_sub_object_add(obj, obj2);
1651    evas_object_size_hint_weight_set(obj2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1652    evas_object_size_hint_align_set(obj2, EVAS_HINT_FILL, EVAS_HINT_FILL);
1653    elm_win_resize_object_add(obj, obj2);
1654
1655    elm_widget_data_set(obj2, wd);
1656    elm_widget_del_hook_set(obj2, _del_hook);
1657    elm_widget_theme_hook_set(obj2, _theme_hook);
1658
1659    wd->frm = edje_object_add(win->evas);
1660    _elm_theme_object_set(obj, wd->frm, "win", "inwin", "default");
1661    elm_widget_resize_object_set(obj2, wd->frm);
1662
1663    evas_object_smart_callback_add(obj2, "sub-object-del", _sub_del, obj2);
1664
1665    _sizing_eval(obj2);
1666    return obj2;
1667 }
1668
1669 /**
1670  * Activates an inwin object
1671  *
1672  * @param obj The inwin to activate
1673  *
1674  * @ingroup Inwin
1675  */
1676 EAPI void
1677 elm_win_inwin_activate(Evas_Object *obj)
1678 {
1679    ELM_CHECK_WIDTYPE(obj, widtype2);
1680    Widget_Data *wd = elm_widget_data_get(obj);
1681    if (!wd) return;
1682    evas_object_raise(obj);
1683    evas_object_show(obj);
1684    edje_object_signal_emit(wd->frm, "elm,action,show", "elm");
1685    elm_widget_focused_object_clear(elm_widget_parent_get(obj));
1686 }
1687
1688 /**
1689  * Set the content of an inwin object.
1690  *
1691  * @param obj The inwin object
1692  * @param content The object to set as content
1693  *
1694  * @ingroup Inwin
1695  */
1696 EAPI void
1697 elm_win_inwin_content_set(Evas_Object *obj, Evas_Object *content)
1698 {
1699    ELM_CHECK_WIDTYPE(obj, widtype2);
1700    Widget_Data *wd = elm_widget_data_get(obj);
1701    if (!wd) return;
1702    if ((wd->content) && (wd->content != content))
1703      elm_widget_sub_object_del(obj, wd->content);
1704    wd->content = content;
1705    if (content)
1706      {
1707         elm_widget_sub_object_add(obj, content);
1708         evas_object_event_callback_add(content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1709                                        _changed_size_hints, obj);
1710         edje_object_part_swallow(wd->frm, "elm.swallow.content", content);
1711         _sizing_eval(obj);
1712      }
1713 }
1714
1715 /* windowing spcific calls - shall we do this differently? */
1716 /**
1717  * Get the Ecore_X_Window of an Evas_Object
1718  *
1719  * @param obj The object
1720  *
1721  * @return The Ecore_X_Window of @p obj
1722  *
1723  * @ingroup Win
1724  */
1725 EAPI Ecore_X_Window
1726 elm_win_xwindow_get(const Evas_Object *obj)
1727 {
1728    Ecore_X_Window xwin = 0;
1729    Ecore_Evas *ee = NULL;
1730    if (!obj) return 0;
1731 #ifdef HAVE_ELEMENTARY_X
1732    ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
1733    if (ee) xwin = (Ecore_X_Window)ecore_evas_window_get(ee);
1734    return xwin;
1735 #else
1736    return 0;
1737 #endif
1738 }