Elementary: Removed trailing whitespaces.
[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  * Signals that you can add callbacks for are:
11  *
12  * "delete,request" - the user requested to delete the window
13  * "focus,in" - window got focus
14  * "focus,out" - window lost focus
15  * "moved" - window that holds the canvas was moved
16  */
17
18 typedef struct _Elm_Win Elm_Win;
19
20 struct _Elm_Win
21 {
22    Ecore_Evas *ee;
23    Evas *evas;
24    Evas_Object *parent, *win_obj, *img_obj, *frame_obj;
25    Eina_List *subobjs;
26 #ifdef HAVE_ELEMENTARY_X
27    Ecore_X_Window xwin;
28    Ecore_Event_Handler *client_message_handler;
29 #endif
30    Ecore_Job *deferred_resize_job;
31    Ecore_Job *deferred_child_eval_job;
32
33    Elm_Win_Type type;
34    Elm_Win_Keyboard_Mode kbdmode;
35    struct {
36       const char *info;
37       Ecore_Timer *timer;
38    } shot;
39    Eina_Bool autodel : 1;
40    int *autodel_clear, rot;
41    struct {
42       int x, y;
43    } screen;
44
45    struct {
46       Evas_Object *top;
47
48       struct {
49          Evas_Object *target;
50          Eina_Bool visible : 1;
51          Eina_Bool handled : 1;
52       } cur, prev;
53
54       const char *style;
55       Ecore_Job *reconf_job;
56
57       Eina_Bool enabled : 1;
58       Eina_Bool changed_theme : 1;
59       Eina_Bool top_animate : 1;
60       Eina_Bool geometry_changed : 1;
61    } focus_highlight;
62 };
63
64 static const char *widtype = NULL;
65 static void _elm_win_obj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
66 static void _elm_win_obj_callback_img_obj_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
67 static void _elm_win_obj_callback_parent_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
68 static void _elm_win_obj_intercept_move(void *data, Evas_Object *obj, Evas_Coord x, Evas_Coord y);
69 static void _elm_win_obj_intercept_show(void *data, Evas_Object *obj);
70 static void _elm_win_move(Ecore_Evas *ee);
71 static void _elm_win_resize(Ecore_Evas *ee);
72 static void _elm_win_delete_request(Ecore_Evas *ee);
73 static void _elm_win_resize_job(void *data);
74 #ifdef HAVE_ELEMENTARY_X
75 static void _elm_win_xwin_update(Elm_Win *win);
76 #endif
77 static void _elm_win_eval_subobjs(Evas_Object *obj);
78 static void _elm_win_subobj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
79 static void _elm_win_subobj_callback_changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
80 static void _elm_win_focus_highlight_init(Elm_Win *win);
81 static void _elm_win_focus_highlight_shutdown(Elm_Win *win);
82 static void _elm_win_focus_highlight_visible_set(Elm_Win *win, Eina_Bool visible);
83 static void _elm_win_focus_highlight_reconfigure_job_start(Elm_Win *win);
84 static void _elm_win_focus_highlight_reconfigure_job_stop(Elm_Win *win);
85 static void _elm_win_focus_highlight_anim_end(void *data, Evas_Object *obj, const char *emission, const char *source);
86 static void _elm_win_focus_highlight_reconfigure(Elm_Win *win);
87
88 static const char SIG_DELETE_REQUEST[] = "delete,request";
89 static const char SIG_FOCUS_OUT[] = "focus,in";
90 static const char SIG_FOCUS_IN[] = "focus,out";
91 static const char SIG_MOVED[] = "moved";
92
93 static const Evas_Smart_Cb_Description _signals[] = {
94    {SIG_DELETE_REQUEST, ""},
95    {SIG_FOCUS_OUT, ""},
96    {SIG_FOCUS_IN, ""},
97    {SIG_MOVED, ""},
98    {NULL, NULL}
99 };
100
101
102
103 Eina_List *_elm_win_list = NULL;
104 int _elm_win_deferred_free = 0;
105
106 // exmaple shot spec (wait 0.1 sec then save as my-window.png):
107 // ELM_ENGINE="shot:delay=0.1:file=my-window.png"
108
109 static double
110 _shot_delay_get(Elm_Win *win)
111 {
112    char *p, *pd;
113    char *d = strdup(win->shot.info);
114
115    if (!d) return 0.5;
116    for (p = (char *)win->shot.info; *p; p++)
117      {
118         if (!strncmp(p, "delay=", 6))
119           {
120              double v;
121
122              for (pd = d, p += 6; (*p) && (*p != ':'); p++, pd++)
123                {
124                   *pd = *p;
125                }
126              *pd = 0;
127              v = atof(d);
128              free(d);
129              return v;
130           }
131      }
132    free(d);
133    return 0.5;
134 }
135
136 static char *
137 _shot_file_get(Elm_Win *win)
138 {
139    char *p;
140    char *tmp = strdup(win->shot.info);
141
142    if (!tmp) return NULL;
143    for (p = (char *)win->shot.info; *p; p++)
144      {
145         if (!strncmp(p, "file=", 5))
146           {
147              strcpy(tmp, p + 5);
148              return tmp;
149           }
150      }
151    free(tmp);
152    return strdup("out.png");
153 }
154
155 static char *
156 _shot_key_get(Elm_Win *win __UNUSED__)
157 {
158    return NULL;
159 }
160
161 static char *
162 _shot_flags_get(Elm_Win *win __UNUSED__)
163 {
164    return NULL;
165 }
166
167 static void
168 _shot_do(Elm_Win *win)
169 {
170    Ecore_Evas *ee;
171    Evas_Object *o;
172    unsigned int *pixels;
173    int w, h;
174    char *file, *key, *flags;
175
176    ecore_evas_manual_render(win->ee);
177    pixels = (void *)ecore_evas_buffer_pixels_get(win->ee);
178    if (!pixels) return;
179    ecore_evas_geometry_get(win->ee, NULL, NULL, &w, &h);
180    if ((w < 1) || (h < 1)) return;
181    file = _shot_file_get(win);
182    if (!file) return;
183    key = _shot_key_get(win);
184    flags = _shot_flags_get(win);
185    ee = ecore_evas_buffer_new(1, 1);
186    o = evas_object_image_add(ecore_evas_get(ee));
187    evas_object_image_alpha_set(o, ecore_evas_alpha_get(win->ee));
188    evas_object_image_size_set(o, w, h);
189    evas_object_image_data_set(o, pixels);
190    if (!evas_object_image_save(o, file, key, flags))
191      {
192         ERR("Cannot save window to '%s' (key '%s', flags '%s')",
193             file, key, flags);
194      }
195    free(file);
196    if (key) free(key);
197    if (flags) free(flags);
198    ecore_evas_free(ee);
199 }
200
201 static Eina_Bool
202 _shot_delay(void *data)
203 {
204    Elm_Win *win = data;
205    _shot_do(win);
206    win->shot.timer = NULL;
207    elm_exit();
208    return EINA_FALSE;
209 }
210
211 static void
212 _shot_handle(Elm_Win *win)
213 {
214    if (!win->shot.info) return;
215    win->shot.timer = ecore_timer_add(_shot_delay_get(win), _shot_delay, win);
216 }
217
218 static void
219 _elm_win_move(Ecore_Evas *ee)
220 {
221    Evas_Object *obj = ecore_evas_object_associate_get(ee);
222    Elm_Win *win;
223    int x, y;
224
225    if (!obj) return;
226    win = elm_widget_data_get(obj);
227    if (!win) return;
228    ecore_evas_geometry_get(ee, &x, &y, NULL, NULL);
229    win->screen.x = x;
230    win->screen.y = y;
231    evas_object_smart_callback_call(win->win_obj, SIG_MOVED, NULL);
232 }
233
234 static void
235 _elm_win_resize(Ecore_Evas *ee)
236 {
237    Evas_Object *obj = ecore_evas_object_associate_get(ee);
238    Elm_Win *win;
239
240    if (!obj) return;
241    win = elm_widget_data_get(obj);
242    if (!win) return;
243    if (win->deferred_resize_job) ecore_job_del(win->deferred_resize_job);
244    win->deferred_resize_job = ecore_job_add(_elm_win_resize_job, win);
245 }
246
247 static void
248 _elm_win_focus_in(Ecore_Evas *ee)
249 {
250    Evas_Object *obj = ecore_evas_object_associate_get(ee);
251    Elm_Win *win;
252
253    if (!obj) return;
254    win = elm_widget_data_get(obj);
255    if (!win) return;
256    /*NB: Why two different "focus signals" here ??? */
257    evas_object_smart_callback_call(win->win_obj, SIG_FOCUS_IN, NULL); // FIXME: remove me
258    evas_object_smart_callback_call(win->win_obj, SIG_FOCUS_IN, NULL);
259    win->focus_highlight.cur.visible = EINA_TRUE;
260    _elm_win_focus_highlight_reconfigure_job_start(win);
261    if (win->frame_obj)
262      {
263      }
264    else if (win->img_obj)
265      {
266         /* do nothing */
267      }
268 }
269
270 static void
271 _elm_win_focus_out(Ecore_Evas *ee)
272 {
273    Evas_Object *obj = ecore_evas_object_associate_get(ee);
274    Elm_Win *win;
275
276    if (!obj) return;
277    win = elm_widget_data_get(obj);
278    if (!win) return;
279    evas_object_smart_callback_call(win->win_obj, SIG_FOCUS_OUT, NULL); // FIXME: remove me
280    evas_object_smart_callback_call(win->win_obj, SIG_FOCUS_OUT, NULL);
281    win->focus_highlight.cur.visible = EINA_FALSE;
282    _elm_win_focus_highlight_reconfigure_job_start(win);
283    if (win->frame_obj)
284      {
285      }
286    else if (win->img_obj)
287      {
288         /* do nothing */
289      }
290 }
291
292 static Eina_Bool
293 _elm_win_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
294 {
295    Elm_Win *wd = elm_widget_data_get(obj);
296    const Eina_List *items;
297    void *(*list_data_get) (const Eina_List *list);
298
299    if (!wd)
300      return EINA_FALSE;
301
302    /* Focus chain */
303    if (wd->subobjs)
304      {
305         if (!(items = elm_widget_focus_custom_chain_get(obj)))
306           {
307              items = wd->subobjs;
308              if (!items)
309                return EINA_FALSE;
310           }
311         list_data_get = eina_list_data_get;
312
313         elm_widget_focus_list_next_get(obj, items, list_data_get, dir, next);
314
315         if (*next)
316           return EINA_TRUE;
317      }
318
319    *next = (Evas_Object *)obj;
320    return EINA_FALSE;
321 }
322
323 static void
324 _elm_win_on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
325 {
326    Elm_Win *win = elm_widget_data_get(obj);
327    if (!win) return;
328
329    if (win->img_obj)
330       evas_object_focus_set(win->img_obj, elm_widget_focus_get(obj));
331    else
332       evas_object_focus_set(obj, elm_widget_focus_get(obj));
333 }
334
335 static Eina_Bool
336 _elm_win_event_cb(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
337 {
338    if (type == EVAS_CALLBACK_KEY_DOWN)
339      {
340         Evas_Event_Key_Down *ev = event_info;
341         if (!strcmp(ev->keyname, "Tab"))
342           {
343              if (evas_key_modifier_is_set(ev->modifiers, "Shift"))
344                elm_widget_focus_cycle(obj, ELM_FOCUS_PREVIOUS);
345              else
346                elm_widget_focus_cycle(obj, ELM_FOCUS_NEXT);
347              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
348              return EINA_TRUE;
349           }
350      }
351
352    return EINA_FALSE;
353 }
354
355 static void
356 _deferred_ecore_evas_free(void *data)
357 {
358    ecore_evas_free(data);
359    _elm_win_deferred_free--;
360 }
361
362 static void
363 _elm_win_obj_callback_show(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
364 {
365    Elm_Win *win = data;
366
367    elm_object_focus(obj);
368    if (win->shot.info) _shot_handle(win);
369 }
370
371 static void
372 _elm_win_obj_callback_hide(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
373 {
374    Elm_Win *win = data;
375
376    if (win->frame_obj)
377      {
378      }
379    else if (win->img_obj)
380      {
381         evas_object_hide(win->img_obj);
382      }
383 }
384
385 static void
386 _elm_win_obj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info __UNUSED__)
387 {
388    Elm_Win *win = data;
389    Evas_Object *child;
390
391    if (win->parent)
392      {
393         evas_object_event_callback_del_full(win->parent, EVAS_CALLBACK_DEL,
394                                             _elm_win_obj_callback_parent_del, win);
395         win->parent = NULL;
396      }
397    if (win->autodel_clear) *(win->autodel_clear) = -1;
398    _elm_win_list = eina_list_remove(_elm_win_list, win->win_obj);
399    while (win->subobjs) elm_win_resize_object_del(obj, win->subobjs->data);
400    if (win->ee)
401      {
402         ecore_evas_callback_delete_request_set(win->ee, NULL);
403         ecore_evas_callback_resize_set(win->ee, NULL);
404      }
405    if (win->deferred_resize_job) ecore_job_del(win->deferred_resize_job);
406    if (win->deferred_child_eval_job) ecore_job_del(win->deferred_child_eval_job);
407    if (win->shot.info) eina_stringshare_del(win->shot.info);
408    if (win->shot.timer) ecore_timer_del(win->shot.timer);
409    while (((child = evas_object_bottom_get(win->evas))) &&
410           (child != obj))
411      {
412         evas_object_del(child);
413      }
414    while (((child = evas_object_top_get(win->evas))) &&
415           (child != obj))
416      {
417         evas_object_del(child);
418      }
419 #ifdef HAVE_ELEMENTARY_X
420    if (win->client_message_handler)
421      ecore_event_handler_del(win->client_message_handler);
422 #endif
423    // FIXME: Why are we flushing edje on every window destroy ??
424    //   edje_file_cache_flush();
425    //   edje_collection_cache_flush();
426    //   evas_image_cache_flush(win->evas);
427    //   evas_font_cache_flush(win->evas);
428    // FIXME: we are in the del handler for the object and delete the canvas
429    // that lives under it from the handler... nasty. deferring doesn't help either
430
431    if (win->img_obj)
432      {
433         win->img_obj = NULL;
434      }
435    else
436      {
437         if (win->ee)
438           {
439              ecore_job_add(_deferred_ecore_evas_free, win->ee);
440              _elm_win_deferred_free++;
441           }
442      }
443
444    _elm_win_focus_highlight_shutdown(win);
445    eina_stringshare_del(win->focus_highlight.style);
446
447    free(win);
448
449    if ((!_elm_win_list) &&
450        (elm_policy_get(ELM_POLICY_QUIT) == ELM_POLICY_QUIT_LAST_WINDOW_CLOSED))
451      {
452         edje_file_cache_flush();
453         edje_collection_cache_flush();
454         evas_image_cache_flush(e);
455         evas_font_cache_flush(e);
456         elm_exit();
457      }
458 }
459
460 static void
461 _elm_win_obj_callback_img_obj_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
462 {
463    Elm_Win *win = data;
464    if (!win->img_obj) return;
465    evas_object_event_callback_del_full
466       (win->img_obj, EVAS_CALLBACK_DEL, _elm_win_obj_callback_img_obj_del, win);
467    evas_object_del(win->img_obj);
468 }
469
470 static void
471 _elm_win_obj_callback_parent_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
472 {
473    Elm_Win *win = data;
474    if (obj == win->parent) win->parent = NULL;
475 }
476
477 static void
478 _elm_win_obj_intercept_move(void *data, Evas_Object *obj, Evas_Coord x, Evas_Coord y)
479 {
480    Elm_Win *win = data;
481
482    if (win->img_obj)
483      {
484         if ((x != win->screen.x) || (y != win->screen.y))
485           {
486              win->screen.x = x;
487              win->screen.y = y;
488              evas_object_smart_callback_call(win->win_obj, SIG_MOVED, NULL);
489           }
490      }
491    else
492      {
493         evas_object_move(obj, x, y);
494      }
495 }
496
497 static void
498 _elm_win_obj_intercept_show(void *data, Evas_Object *obj)
499 {
500    Elm_Win *win = data;
501    // this is called to make sure all smart containers have calculated their
502    // sizes BEFORE we show the window to make sure it initially appears at
503    // our desired size (ie min size is known first)
504    evas_smart_objects_calculate(evas_object_evas_get(obj));
505    evas_object_show(obj);
506    if (win->frame_obj)
507      {
508      }
509    else if (win->img_obj)
510      {
511         evas_object_show(win->img_obj);
512      }
513 }
514
515 static void
516 _elm_win_obj_callback_move(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
517 {
518    Elm_Win *win = data;
519
520    if (ecore_evas_override_get(win->ee))
521      {
522         Evas_Coord x, y;
523
524         evas_object_geometry_get(obj, &x, &y, NULL, NULL);
525         win->screen.x = x;
526         win->screen.y = y;
527         evas_object_smart_callback_call(win->win_obj, SIG_MOVED, NULL);
528      }
529    if (win->frame_obj)
530      {
531      }
532    else if (win->img_obj)
533      {
534         Evas_Coord x, y;
535
536         evas_object_geometry_get(obj, &x, &y, NULL, NULL);
537         win->screen.x = x;
538         win->screen.y = y;
539 //        evas_object_move(win->img_obj, x, y);
540      }
541 }
542
543 static void
544 _elm_win_obj_callback_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
545 {
546    Elm_Win *win = data;
547
548    if (win->frame_obj)
549      {
550      }
551    else if (win->img_obj)
552      {
553         Evas_Coord w = 1, h = 1;
554
555         evas_object_geometry_get(obj, NULL, NULL, &w, &h);
556         if (w < 1) w = 1;
557         if (h < 1) h = 1;
558         evas_object_image_size_set(win->img_obj, w, h);
559      }
560 }
561
562 static void
563 _elm_win_delete_request(Ecore_Evas *ee)
564 {
565    Evas_Object *obj = ecore_evas_object_associate_get(ee);
566    Elm_Win *win;
567    if (strcmp(elm_widget_type_get(obj), "win")) return;
568
569    win = elm_widget_data_get(obj);
570    if (!win) return;
571    int autodel = win->autodel;
572    win->autodel_clear = &autodel;
573    evas_object_smart_callback_call(win->win_obj, SIG_DELETE_REQUEST, NULL); // FIXME: remove me.
574    evas_object_smart_callback_call(win->win_obj, SIG_DELETE_REQUEST, NULL);
575    // FIXME: if above callback deletes - then the below will be invalid
576    if (autodel) evas_object_del(win->win_obj);
577    else win->autodel_clear = NULL;
578 }
579
580 static void
581 _elm_win_resize_job(void *data)
582 {
583    Elm_Win *win = data;
584    const Eina_List *l;
585    Evas_Object *obj;
586    int w, h;
587
588    win->deferred_resize_job = NULL;
589    ecore_evas_geometry_get(win->ee, NULL, NULL, &w, &h);
590    evas_object_resize(win->win_obj, w, h);
591    if (win->frame_obj)
592      {
593      }
594    else if (win->img_obj)
595      {
596      }
597    EINA_LIST_FOREACH(win->subobjs, l, obj)
598      {
599         evas_object_move(obj, 0, 0);
600         evas_object_resize(obj, w, h);
601      }
602 }
603
604 #ifdef HAVE_ELEMENTARY_X
605 static void
606 _elm_win_xwindow_get(Elm_Win *win)
607 {
608    win->xwin = 0;
609
610 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
611    if (ENGINE_COMPARE(ELM_SOFTWARE_X11))
612      {
613        if (win->ee) win->xwin = ecore_evas_software_x11_window_get(win->ee);
614      }
615    else if (ENGINE_COMPARE(ELM_SOFTWARE_X11) ||
616             ENGINE_COMPARE(ELM_SOFTWARE_FB) ||
617             ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE) ||
618             ENGINE_COMPARE(ELM_SOFTWARE_SDL) ||
619             ENGINE_COMPARE(ELM_SOFTWARE_16_SDL) ||
620             ENGINE_COMPARE(ELM_OPENGL_SDL))
621      {
622      }
623    else if (ENGINE_COMPARE(ELM_SOFTWARE_16_X11))
624      {
625         if (win->ee) win->xwin = ecore_evas_software_x11_16_window_get(win->ee);
626      }
627    else if (ENGINE_COMPARE(ELM_SOFTWARE_8_X11))
628      {
629         if (win->ee) win->xwin = ecore_evas_software_x11_8_window_get(win->ee);
630      }
631 /* killed
632    else if (ENGINE_COMPARE(ELM_XRENDER_X11))
633      {
634         if (win->ee) win->xwin = ecore_evas_xrender_x11_window_get(win->ee);
635      }
636  */
637    else if (ENGINE_COMPARE(ELM_OPENGL_X11))
638      {
639         if (win->ee) win->xwin = ecore_evas_gl_x11_window_get(win->ee);
640      }
641    else if (ENGINE_COMPARE(ELM_SOFTWARE_WIN32))
642      {
643         if (win->ee) win->xwin = (long)ecore_evas_win32_window_get(win->ee);
644      }
645 #undef ENGINE_COMPARE
646 }
647 #endif
648
649 #ifdef HAVE_ELEMENTARY_X
650 static void
651 _elm_win_xwin_update(Elm_Win *win)
652 {
653    _elm_win_xwindow_get(win);
654    if (win->parent)
655      {
656         Elm_Win *win2;
657
658         win2 = elm_widget_data_get(win->parent);
659         if (win2)
660           {
661              if (win->xwin)
662                ecore_x_icccm_transient_for_set(win->xwin, win2->xwin);
663           }
664      }
665
666    if (!win->xwin) return; /* nothing more to do */
667
668    switch (win->type)
669      {
670       case ELM_WIN_BASIC:
671          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_NORMAL);
672          break;
673       case ELM_WIN_DIALOG_BASIC:
674          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DIALOG);
675          break;
676       case ELM_WIN_DESKTOP:
677          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DESKTOP);
678          break;
679       case ELM_WIN_DOCK:
680          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DOCK);
681          break;
682       case ELM_WIN_TOOLBAR:
683          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_TOOLBAR);
684          break;
685       case ELM_WIN_MENU:
686          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_MENU);
687          break;
688       case ELM_WIN_UTILITY:
689          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_UTILITY);
690          break;
691       case ELM_WIN_SPLASH:
692          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_SPLASH);
693          break;
694       case ELM_WIN_DROPDOWN_MENU:
695          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DROPDOWN_MENU);
696          break;
697       case ELM_WIN_POPUP_MENU:
698          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_POPUP_MENU);
699          break;
700       case ELM_WIN_TOOLTIP:
701          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_TOOLTIP);
702          break;
703       case ELM_WIN_NOTIFICATION:
704          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_NOTIFICATION);
705          break;
706       case ELM_WIN_COMBO:
707          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_COMBO);
708          break;
709       case ELM_WIN_DND:
710          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DND);
711          break;
712       default:
713          break;
714      }
715    ecore_x_e_virtual_keyboard_state_set
716       (win->xwin, (Ecore_X_Virtual_Keyboard_State)win->kbdmode);
717 }
718 #endif
719
720 static void
721 _elm_win_eval_subobjs(Evas_Object *obj)
722 {
723    const Eina_List *l;
724    const Evas_Object *child;
725
726    Elm_Win *win = elm_widget_data_get(obj);
727    Evas_Coord w, h, minw = -1, minh = -1, maxw = -1, maxh = -1;
728    int xx = 1, xy = 1;
729    double wx, wy;
730
731    EINA_LIST_FOREACH(win->subobjs, l, child)
732      {
733         evas_object_size_hint_weight_get(child, &wx, &wy);
734         if (wx == 0.0) xx = 0;
735         if (wy == 0.0) xy = 0;
736
737         evas_object_size_hint_min_get(child, &w, &h);
738         if (w < 1) w = -1;
739         if (h < 1) h = -1;
740         if (w > minw) minw = w;
741         if (h > minh) minh = h;
742
743         evas_object_size_hint_max_get(child, &w, &h);
744         if (w < 1) w = -1;
745         if (h < 1) h = -1;
746         if (maxw == -1) maxw = w;
747         else if ((w > 0) && (w < maxw)) maxw = w;
748         if (maxh == -1) maxh = h;
749         else if ((h > 0) && (h < maxh)) maxh = h;
750      }
751    if (!xx) maxw = minw;
752    else maxw = 32767;
753    if (!xy) maxh = minh;
754    else maxh = 32767;
755    evas_object_size_hint_min_set(obj, minw, minh);
756    evas_object_size_hint_max_set(obj, maxw, maxh);
757    evas_object_geometry_get(obj, NULL, NULL, &w, &h);
758    if (w < minw) w = minw;
759    if (h < minh) h = minh;
760    if ((maxw >= 0) && (w > maxw)) w = maxw;
761    if ((maxh >= 0) && (h > maxh)) h = maxh;
762    evas_object_resize(obj, w, h);
763 }
764
765 static void
766 _elm_win_subobj_callback_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
767 {
768    Elm_Win *win = elm_widget_data_get(data);
769    win->subobjs = eina_list_remove(win->subobjs, obj);
770    _elm_win_eval_subobjs(win->win_obj);
771 }
772
773 static void
774 _elm_win_subobj_callback_changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
775 {
776    _elm_win_eval_subobjs(data);
777 }
778
779 void
780 _elm_win_shutdown(void)
781 {
782    while (_elm_win_list)
783      evas_object_del(_elm_win_list->data);
784 }
785
786 void
787 _elm_win_rescale(Elm_Theme *th, Eina_Bool use_theme)
788 {
789    const Eina_List *l;
790    Evas_Object *obj;
791
792    if (!use_theme)
793      {
794         EINA_LIST_FOREACH(_elm_win_list, l, obj)
795           elm_widget_theme(obj);
796      }
797    else
798      {
799         EINA_LIST_FOREACH(_elm_win_list, l, obj)
800           elm_widget_theme_specific(obj, th, EINA_FALSE);
801      }
802 }
803
804 #ifdef HAVE_ELEMENTARY_X
805 static Eina_Bool
806 _elm_win_client_message(void *data, int type __UNUSED__, void *event)
807 {
808    Elm_Win *win = data;
809    Ecore_X_Event_Client_Message *e = event;
810
811    if (e->format != 32) return ECORE_CALLBACK_PASS_ON;
812    if (e->message_type == ECORE_X_ATOM_E_COMP_FLUSH)
813      {
814         if ((unsigned)e->data.l[0] == win->xwin)
815           {
816              Evas *evas = evas_object_evas_get(win->win_obj);
817              if (evas)
818                {
819                   edje_file_cache_flush();
820                   edje_collection_cache_flush();
821                   evas_image_cache_flush(evas);
822                   evas_font_cache_flush(evas);
823                }
824           }
825      }
826    else if (e->message_type == ECORE_X_ATOM_E_COMP_DUMP)
827      {
828         if ((unsigned)e->data.l[0] == win->xwin)
829           {
830              Evas *evas = evas_object_evas_get(win->win_obj);
831              if (evas)
832                {
833                   edje_file_cache_flush();
834                   edje_collection_cache_flush();
835                   evas_image_cache_flush(evas);
836                   evas_font_cache_flush(evas);
837                   evas_render_dump(evas);
838                }
839           }
840      }
841    return ECORE_CALLBACK_PASS_ON;
842 }
843 #endif
844
845 static void
846 _elm_win_focus_target_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
847 {
848    Elm_Win *win = data;
849
850    win->focus_highlight.geometry_changed = EINA_TRUE;
851    _elm_win_focus_highlight_reconfigure_job_start(win);
852 }
853
854 static void
855 _elm_win_focus_target_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
856 {
857    Elm_Win *win = data;
858
859    win->focus_highlight.geometry_changed = EINA_TRUE;
860    _elm_win_focus_highlight_reconfigure_job_start(win);
861 }
862
863 static void
864 _elm_win_focus_target_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
865 {
866    Elm_Win *win = data;
867
868    win->focus_highlight.cur.target = NULL;
869
870    _elm_win_focus_highlight_reconfigure_job_start(win);
871 }
872
873 static void
874 _elm_win_focus_target_callbacks_add(Elm_Win *win)
875 {
876    Evas_Object *obj = win->focus_highlight.cur.target;
877
878    evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE,
879                                   _elm_win_focus_target_move, win);
880    evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE,
881                                   _elm_win_focus_target_resize, win);
882    evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
883                                   _elm_win_focus_target_del, win);
884 }
885
886 static void
887 _elm_win_focus_target_callbacks_del(Elm_Win *win)
888 {
889    Evas_Object *obj = win->focus_highlight.cur.target;
890
891    evas_object_event_callback_del_full(obj, EVAS_CALLBACK_MOVE,
892                                        _elm_win_focus_target_move, win);
893    evas_object_event_callback_del_full(obj, EVAS_CALLBACK_RESIZE,
894                                        _elm_win_focus_target_resize, win);
895    evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL,
896                                        _elm_win_focus_target_del, win);
897 }
898
899 static Evas_Object *
900 _elm_win_focus_target_get(Evas_Object *obj)
901 {
902    Evas_Object *o = obj;
903
904    do
905      {
906         if (elm_widget_is(o))
907           {
908              if (!elm_widget_highlight_ignore_get(o))
909                break;
910              o = elm_widget_parent_get(o);
911              if (!o)
912                o = evas_object_smart_parent_get(o);
913           }
914         else
915           {
916              o = elm_widget_parent_widget_get(o);
917              if (!o)
918                o = evas_object_smart_parent_get(o);
919           }
920      }
921    while (o);
922
923    return o;
924 }
925
926 static void
927 _elm_win_object_focus_in(void *data, Evas *e __UNUSED__, void *event_info)
928 {
929    Evas_Object *obj = event_info, *target;
930    Elm_Win *win = data;
931
932    if (win->focus_highlight.cur.target == obj)
933      return;
934
935    target = _elm_win_focus_target_get(obj);
936    win->focus_highlight.cur.target = target;
937    if (elm_widget_highlight_in_theme_get(target))
938      win->focus_highlight.cur.handled = EINA_TRUE;
939    else
940      _elm_win_focus_target_callbacks_add(win);
941
942    _elm_win_focus_highlight_reconfigure_job_start(win);
943 }
944
945 static void
946 _elm_win_object_focus_out(void *data, Evas *e __UNUSED__, void *event_info __UNUSED__)
947 {
948    Elm_Win *win = data;
949
950    if (!win->focus_highlight.cur.target)
951      return;
952
953    if (!win->focus_highlight.cur.handled)
954      _elm_win_focus_target_callbacks_del(win);
955    win->focus_highlight.cur.target = NULL;
956    win->focus_highlight.cur.handled = EINA_FALSE;
957
958    _elm_win_focus_highlight_reconfigure_job_start(win);
959 }
960
961 static void
962 _elm_win_focus_highlight_hide(void *data __UNUSED__, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
963 {
964    evas_object_hide(obj);
965 }
966
967 static void
968 _elm_win_focus_highlight_init(Elm_Win *win)
969 {
970    evas_event_callback_add(win->evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
971                            _elm_win_object_focus_in, win);
972    evas_event_callback_add(win->evas,
973                            EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
974                            _elm_win_object_focus_out, win);
975
976    win->focus_highlight.cur.target = evas_focus_get(win->evas);
977
978    win->focus_highlight.top = edje_object_add(win->evas);
979    win->focus_highlight.changed_theme = EINA_TRUE;
980    edje_object_signal_callback_add(win->focus_highlight.top,
981                                    "elm,action,focus,hide,end", "",
982                                    _elm_win_focus_highlight_hide, NULL);
983    edje_object_signal_callback_add(win->focus_highlight.top,
984                                    "elm,action,focus,anim,end", "",
985                                    _elm_win_focus_highlight_anim_end, win);
986    _elm_win_focus_highlight_reconfigure_job_start(win);
987 }
988
989 static void
990 _elm_win_focus_highlight_shutdown(Elm_Win *win)
991 {
992    _elm_win_focus_highlight_reconfigure_job_stop(win);
993    if (win->focus_highlight.cur.target)
994      {
995         _elm_win_focus_target_callbacks_del(win);
996         win->focus_highlight.cur.target = NULL;
997      }
998    if (win->focus_highlight.top)
999      {
1000         evas_object_del(win->focus_highlight.top);
1001         win->focus_highlight.top = NULL;
1002      }
1003
1004    evas_event_callback_del_full(win->evas,
1005                                 EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
1006                                 _elm_win_object_focus_in, win);
1007    evas_event_callback_del_full(win->evas,
1008                                 EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
1009                                 _elm_win_object_focus_out, win);
1010 }
1011
1012 static void
1013 _elm_win_focus_highlight_visible_set(Elm_Win *win, Eina_Bool visible)
1014 {
1015    Evas_Object *top;
1016
1017    top = win->focus_highlight.top;
1018    if (visible)
1019      {
1020         if (top)
1021           {
1022              evas_object_show(top);
1023              edje_object_signal_emit(top, "elm,action,focus,show", "elm");
1024           }
1025      }
1026    else
1027      {
1028         if (top)
1029           edje_object_signal_emit(top, "elm,action,focus,hide", "elm");
1030      }
1031 }
1032
1033 static void
1034 _elm_win_focus_highlight_reconfigure_job(void *data)
1035 {
1036    _elm_win_focus_highlight_reconfigure((Elm_Win *)data);
1037 }
1038
1039 static void
1040 _elm_win_focus_highlight_reconfigure_job_start(Elm_Win *win)
1041 {
1042    if (win->focus_highlight.reconf_job)
1043      ecore_job_del(win->focus_highlight.reconf_job);
1044    win->focus_highlight.reconf_job = ecore_job_add(
1045       _elm_win_focus_highlight_reconfigure_job, win);
1046 }
1047
1048 static void
1049 _elm_win_focus_highlight_reconfigure_job_stop(Elm_Win *win)
1050 {
1051    if (win->focus_highlight.reconf_job)
1052      ecore_job_del(win->focus_highlight.reconf_job);
1053    win->focus_highlight.reconf_job = NULL;
1054 }
1055
1056 static void
1057 _elm_win_focus_highlight_simple_setup(Elm_Win *win, Evas_Object *obj)
1058 {
1059    Evas_Object *clip, *target = win->focus_highlight.cur.target;
1060    Evas_Coord x, y, w, h;
1061
1062    clip = evas_object_clip_get(target);
1063    evas_object_geometry_get(target, &x, &y, &w, &h);
1064
1065    evas_object_move(obj, x, y);
1066    evas_object_resize(obj, w, h);
1067    evas_object_clip_set(obj, clip);
1068 }
1069
1070 static void
1071 _elm_win_focus_highlight_anim_setup(Elm_Win *win, Evas_Object *obj)
1072 {
1073    Evas_Coord tx, ty, tw, th;
1074    Evas_Coord w, h, px, py, pw, ph;
1075    Edje_Message_Int_Set *m;
1076    Evas_Object *previous = win->focus_highlight.prev.target;
1077    Evas_Object *target = win->focus_highlight.cur.target;
1078
1079    evas_object_geometry_get(win->win_obj, NULL, NULL, &w, &h);
1080    evas_object_geometry_get(target, &tx, &ty, &tw, &th);
1081    evas_object_geometry_get(previous, &px, &py, &pw, &ph);
1082    evas_object_move(obj, 0, 0);
1083    evas_object_resize(obj, tw, th);
1084    evas_object_clip_unset(obj);
1085
1086    m = alloca(sizeof(*m) + (sizeof(int) * 8));
1087    m->count = 8;
1088    m->val[0] = px;
1089    m->val[1] = py;
1090    m->val[2] = pw;
1091    m->val[3] = ph;
1092    m->val[4] = tx;
1093    m->val[5] = ty;
1094    m->val[6] = tw;
1095    m->val[7] = th;
1096    edje_object_message_send(obj, EDJE_MESSAGE_INT_SET, 1, m);
1097 }
1098
1099 static void
1100 _elm_win_focus_highlight_anim_end(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
1101 {
1102    Elm_Win *win = data;
1103    _elm_win_focus_highlight_simple_setup(win, obj);
1104 }
1105
1106 static void
1107 _elm_win_focus_highlight_reconfigure(Elm_Win *win)
1108 {
1109    Evas_Object *target = win->focus_highlight.cur.target;
1110    Evas_Object *previous = win->focus_highlight.prev.target;
1111    Evas_Object *top = win->focus_highlight.top;
1112    Eina_Bool visible_changed;
1113    Eina_Bool common_visible;
1114    const char *sig = NULL;
1115
1116    _elm_win_focus_highlight_reconfigure_job_stop(win);
1117
1118    visible_changed = (win->focus_highlight.cur.visible !=
1119                       win->focus_highlight.prev.visible);
1120
1121    if ((target == previous) && (!visible_changed) &&
1122        (!win->focus_highlight.geometry_changed))
1123      return;
1124
1125    if ((previous) && (win->focus_highlight.prev.handled))
1126      elm_widget_signal_emit(previous, "elm,action,focus_highlight,hide", "elm");
1127
1128    if (!target)
1129      common_visible = EINA_FALSE;
1130    else if (win->focus_highlight.cur.handled)
1131      {
1132         common_visible = EINA_FALSE;
1133         if (win->focus_highlight.cur.visible)
1134           sig = "elm,action,focus_highlight,show";
1135         else
1136           sig = "elm,action,focus_highlight,hide";
1137      }
1138    else
1139      common_visible = win->focus_highlight.cur.visible;
1140
1141    _elm_win_focus_highlight_visible_set(win, common_visible);
1142    if (sig)
1143      elm_widget_signal_emit(target, sig, "elm");
1144
1145    if ((!target) || (!common_visible) || (win->focus_highlight.cur.handled))
1146      goto the_end;
1147
1148    if (win->focus_highlight.changed_theme)
1149      {
1150         const char *str;
1151         if (win->focus_highlight.style)
1152           str = win->focus_highlight.style;
1153         else
1154           str = "default";
1155         _elm_theme_object_set(win->win_obj, top, "focus_highlight", "top",
1156                               str);
1157         win->focus_highlight.changed_theme = EINA_FALSE;
1158
1159         if (_elm_config->focus_highlight_animate)
1160           {
1161              str = edje_object_data_get(win->focus_highlight.top, "animate");
1162              win->focus_highlight.top_animate = ((str) && (!strcmp(str, "on")));
1163           }
1164      }
1165
1166    if ((win->focus_highlight.top_animate) && (previous) &&
1167        (!win->focus_highlight.prev.handled))
1168      _elm_win_focus_highlight_anim_setup(win, top);
1169    else
1170      _elm_win_focus_highlight_simple_setup(win, top);
1171    evas_object_raise(top);
1172
1173 the_end:
1174    win->focus_highlight.geometry_changed = EINA_FALSE;
1175    win->focus_highlight.prev = win->focus_highlight.cur;
1176 }
1177
1178 #ifdef ELM_DEBUG
1179 static void
1180 _debug_key_down(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
1181 {
1182    Evas_Event_Key_Down *ev = event_info;
1183
1184    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1185      return;
1186
1187
1188    if ((strcmp(ev->keyname, "F12")) ||
1189        (!evas_key_modifier_is_set(ev->modifiers, "Control")))
1190      return;
1191
1192    printf("Tree graph generated.\n");
1193    elm_object_tree_dot_dump(obj, "./dump.dot");
1194 }
1195 #endif
1196
1197 static void
1198 _win_img_hide(void        *data,
1199               Evas        *e __UNUSED__,
1200               Evas_Object *obj __UNUSED__,
1201               void        *event_info __UNUSED__)
1202 {
1203    Elm_Win *win = data;
1204
1205    elm_widget_focus_hide_handle(win->win_obj);
1206 }
1207
1208 static void
1209 _win_img_mouse_down(void        *data,
1210                     Evas        *e __UNUSED__,
1211                     Evas_Object *obj __UNUSED__,
1212                     void        *event_info __UNUSED__)
1213 {
1214    Elm_Win *win = data;
1215    elm_widget_focus_mouse_down_handle(win->win_obj);
1216 }
1217
1218 static void
1219 _win_img_focus_in(void        *data,
1220                   Evas        *e __UNUSED__,
1221                   Evas_Object *obj __UNUSED__,
1222                   void        *event_info __UNUSED__)
1223 {
1224    Elm_Win *win = data;
1225    elm_widget_focus_steal(win->win_obj);
1226 }
1227
1228 static void
1229 _win_img_focus_out(void        *data,
1230                    Evas        *e __UNUSED__,
1231                    Evas_Object *obj __UNUSED__,
1232                    void        *event_info __UNUSED__)
1233 {
1234    Elm_Win *win = data;
1235    elm_widget_focused_object_clear(win->win_obj);
1236 }
1237
1238 static void
1239 _win_inlined_image_set(Elm_Win *win)
1240 {
1241    evas_object_image_alpha_set(win->img_obj, EINA_FALSE);
1242    evas_object_image_filled_set(win->img_obj, EINA_TRUE);
1243    evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_DEL,
1244                                   _elm_win_obj_callback_img_obj_del, win);
1245
1246    evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_HIDE,
1247                                   _win_img_hide, win);
1248    evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_MOUSE_DOWN,
1249                                   _win_img_mouse_down, win);
1250    evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_FOCUS_IN,
1251                                   _win_img_focus_in, win);
1252    evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_FOCUS_OUT,
1253                                   _win_img_focus_out, win);
1254 }
1255
1256 /**
1257  * Adds a window object. If this is the first window created, pass NULL as
1258  * @p parent.
1259  *
1260  * @param parent Parent object to add the window to, or NULL
1261  * @param name The name of the window
1262  * @param type The window type, one of the following:
1263  * ELM_WIN_BASIC
1264  * ELM_WIN_DIALOG_BASIC
1265  * ELM_WIN_DESKTOP
1266  * ELM_WIN_DOCK
1267  * ELM_WIN_TOOLBAR
1268  * ELM_WIN_MENU
1269  * ELM_WIN_UTILITY
1270  * ELM_WIN_SPLASH
1271  *
1272  * @return The created object, or NULL on failure
1273  *
1274  * @ingroup Win
1275  */
1276 EAPI Evas_Object *
1277 elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type)
1278 {
1279    Elm_Win *win;
1280    const Eina_List *l;
1281    const char *fontpath;
1282
1283    win = ELM_NEW(Elm_Win);
1284
1285 #define FALLBACK_TRY(engine)                                            \
1286    if (!win->ee)                                                        \
1287    do {                                                               \
1288         CRITICAL(engine " engine creation failed. Trying software X11."); \
1289         win->ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);      \
1290    } while (0)
1291 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
1292
1293    switch (type)
1294      {
1295       case ELM_WIN_INLINED_IMAGE:
1296           {
1297              if (parent)
1298                {
1299                   Evas *e = evas_object_evas_get(parent);
1300                   if (e)
1301                     {
1302                        Ecore_Evas *ee = ecore_evas_ecore_evas_get(e);
1303                        if (ee)
1304                          {
1305                             win->img_obj = ecore_evas_object_image_new(ee);
1306                             if (win->img_obj)
1307                               {
1308                                  win->ee = ecore_evas_object_ecore_evas_get(win->img_obj);
1309                                  if (win->ee)
1310                                    {
1311                                       _win_inlined_image_set(win);
1312                                    }
1313                                  else
1314                                    {
1315                                       evas_object_del(win->img_obj);
1316                                       win->img_obj = NULL;
1317                                    }
1318                               }
1319                          }
1320                     }
1321                }
1322           }
1323         break;
1324       default:
1325         if (ENGINE_COMPARE(ELM_SOFTWARE_X11))
1326           {
1327              win->ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
1328 #ifdef HAVE_ELEMENTARY_X
1329              win->client_message_handler = ecore_event_handler_add
1330                 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1331 #endif
1332           }
1333         else if (ENGINE_COMPARE(ELM_SOFTWARE_FB))
1334           {
1335              win->ee = ecore_evas_fb_new(NULL, 0, 1, 1);
1336              FALLBACK_TRY("Sofware FB");
1337           }
1338         else if (ENGINE_COMPARE(ELM_SOFTWARE_DIRECTFB))
1339           {
1340              win->ee = ecore_evas_directfb_new(NULL, 1, 0, 0, 1, 1);
1341              FALLBACK_TRY("Sofware DirectFB");
1342           }
1343         else if (ENGINE_COMPARE(ELM_SOFTWARE_16_X11))
1344           {
1345              win->ee = ecore_evas_software_x11_16_new(NULL, 0, 0, 0, 1, 1);
1346              FALLBACK_TRY("Sofware-16");
1347 #ifdef HAVE_ELEMENTARY_X
1348              win->client_message_handler = ecore_event_handler_add
1349                 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1350 #endif
1351      }
1352         else if (ENGINE_COMPARE(ELM_SOFTWARE_8_X11))
1353           {
1354              win->ee = ecore_evas_software_x11_8_new(NULL, 0, 0, 0, 1, 1);
1355              FALLBACK_TRY("Sofware-8");
1356 #ifdef HAVE_ELEMENTARY_X
1357              win->client_message_handler = ecore_event_handler_add
1358                 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1359 #endif
1360           }
1361 /* killed
1362         else if (ENGINE_COMPARE(ELM_XRENDER_X11))
1363           {
1364              win->ee = ecore_evas_xrender_x11_new(NULL, 0, 0, 0, 1, 1);
1365              FALLBACK_TRY("XRender");
1366 #ifdef HAVE_ELEMENTARY_X
1367              win->client_message_handler = ecore_event_handler_add
1368                 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1369 #endif
1370           }
1371  */
1372         else if (ENGINE_COMPARE(ELM_OPENGL_X11))
1373           {
1374              win->ee = ecore_evas_gl_x11_new(NULL, 0, 0, 0, 1, 1);
1375              FALLBACK_TRY("OpenGL");
1376 #ifdef HAVE_ELEMENTARY_X
1377              win->client_message_handler = ecore_event_handler_add
1378                 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1379 #endif
1380           }
1381         else if (ENGINE_COMPARE(ELM_SOFTWARE_WIN32))
1382           {
1383              win->ee = ecore_evas_software_gdi_new(NULL, 0, 0, 1, 1);
1384              FALLBACK_TRY("Sofware Win32");
1385           }
1386         else if (ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE))
1387           {
1388              win->ee = ecore_evas_software_wince_gdi_new(NULL, 0, 0, 1, 1);
1389              FALLBACK_TRY("Sofware-16-WinCE");
1390           }
1391         else if (ENGINE_COMPARE(ELM_SOFTWARE_SDL))
1392           {
1393              win->ee = ecore_evas_sdl_new(NULL, 0, 0, 0, 0, 0, 1);
1394              FALLBACK_TRY("Sofware SDL");
1395           }
1396         else if (ENGINE_COMPARE(ELM_SOFTWARE_16_SDL))
1397           {
1398              win->ee = ecore_evas_sdl16_new(NULL, 0, 0, 0, 0, 0, 1);
1399              FALLBACK_TRY("Sofware-16-SDL");
1400           }
1401         else if (ENGINE_COMPARE(ELM_OPENGL_SDL))
1402           {
1403              win->ee = ecore_evas_gl_sdl_new(NULL, 1, 1, 0, 0);
1404              FALLBACK_TRY("OpenGL SDL");
1405           }
1406         else if (!strncmp(_elm_config->engine, "shot:", 5))
1407           {
1408              win->ee = ecore_evas_buffer_new(1, 1);
1409              ecore_evas_manual_render_set(win->ee, EINA_TRUE);
1410              win->shot.info = eina_stringshare_add(_elm_config->engine + 5);
1411           }
1412 #undef FALLBACK_TRY
1413         break;
1414      }
1415
1416    if (!win->ee)
1417      {
1418         ERR("Cannot create window.");
1419         free(win);
1420         return NULL;
1421      }
1422 #ifdef HAVE_ELEMENTARY_X
1423    _elm_win_xwindow_get(win);
1424 #endif
1425    if ((_elm_config->bgpixmap) && (!_elm_config->compositing))
1426      ecore_evas_avoid_damage_set(win->ee, ECORE_EVAS_AVOID_DAMAGE_EXPOSE);
1427    // bg pixmap done by x - has other issues like can be redrawn by x before it
1428    // is filled/ready by app
1429    //     ecore_evas_avoid_damage_set(win->ee, ECORE_EVAS_AVOID_DAMAGE_BUILT_IN);
1430
1431    win->type = type;
1432    win->parent = parent;
1433    if (win->parent)
1434      evas_object_event_callback_add(win->parent, EVAS_CALLBACK_DEL,
1435                                     _elm_win_obj_callback_parent_del, win);
1436
1437    win->evas = ecore_evas_get(win->ee);
1438    win->win_obj = elm_widget_add(win->evas);
1439    elm_widget_type_set(win->win_obj, "win");
1440    ELM_SET_WIDTYPE(widtype, "win");
1441    elm_widget_data_set(win->win_obj, win);
1442    elm_widget_event_hook_set(win->win_obj, _elm_win_event_cb);
1443    elm_widget_on_focus_hook_set(win->win_obj, _elm_win_on_focus_hook, NULL);
1444    elm_widget_can_focus_set(win->win_obj, EINA_TRUE);
1445    elm_widget_highlight_ignore_set(win->win_obj, EINA_TRUE);
1446    elm_widget_focus_next_hook_set(win->win_obj, _elm_win_focus_next_hook);
1447    evas_object_color_set(win->win_obj, 0, 0, 0, 0);
1448    evas_object_move(win->win_obj, 0, 0);
1449    evas_object_resize(win->win_obj, 1, 1);
1450    evas_object_layer_set(win->win_obj, 50);
1451    evas_object_pass_events_set(win->win_obj, EINA_TRUE);
1452
1453    ecore_evas_object_associate(win->ee, win->win_obj,
1454                                ECORE_EVAS_OBJECT_ASSOCIATE_BASE |
1455                                ECORE_EVAS_OBJECT_ASSOCIATE_STACK |
1456                                ECORE_EVAS_OBJECT_ASSOCIATE_LAYER);
1457    evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_SHOW,
1458                                   _elm_win_obj_callback_show, win);
1459    evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_HIDE,
1460                                   _elm_win_obj_callback_hide, win);
1461    evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_DEL,
1462                                   _elm_win_obj_callback_del, win);
1463    evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_MOVE,
1464                                   _elm_win_obj_callback_move, win);
1465    evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_RESIZE,
1466                                   _elm_win_obj_callback_resize, win);
1467    if (win->img_obj)
1468       evas_object_intercept_move_callback_add(win->win_obj,
1469                                               _elm_win_obj_intercept_move, win);
1470    evas_object_intercept_show_callback_add(win->win_obj,
1471                                            _elm_win_obj_intercept_show, win);
1472
1473    ecore_evas_name_class_set(win->ee, name, _elm_appname);
1474    ecore_evas_callback_delete_request_set(win->ee, _elm_win_delete_request);
1475    ecore_evas_callback_resize_set(win->ee, _elm_win_resize);
1476    ecore_evas_callback_focus_in_set(win->ee, _elm_win_focus_in);
1477    ecore_evas_callback_focus_out_set(win->ee, _elm_win_focus_out);
1478    ecore_evas_callback_move_set(win->ee, _elm_win_move);
1479    evas_image_cache_set(win->evas, (_elm_config->image_cache * 1024));
1480    evas_font_cache_set(win->evas, (_elm_config->font_cache * 1024));
1481    EINA_LIST_FOREACH(_elm_config->font_dirs, l, fontpath)
1482       evas_font_path_append(win->evas, fontpath);
1483    if (!_elm_config->font_hinting)
1484      evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_NONE);
1485    else if (_elm_config->font_hinting == 1)
1486      evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_AUTO);
1487    else if (_elm_config->font_hinting == 2)
1488      evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_BYTECODE);
1489
1490 #ifdef HAVE_ELEMENTARY_X
1491    _elm_win_xwin_update(win);
1492 #endif
1493
1494    _elm_win_list = eina_list_append(_elm_win_list, win->win_obj);
1495
1496    if (ENGINE_COMPARE(ELM_SOFTWARE_FB))
1497      {
1498         ecore_evas_fullscreen_set(win->ee, 1);
1499      }
1500 #undef ENGINE_COMPARE
1501
1502    if (_elm_config->focus_highlight_enable)
1503      elm_win_focus_highlight_enabled_set(win->win_obj, EINA_TRUE);
1504
1505 #ifdef ELM_DEBUG
1506    Evas_Modifier_Mask mask = evas_key_modifier_mask_get(win->evas, "Control");
1507    evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_KEY_DOWN,
1508                                   _debug_key_down, win);
1509
1510    Eina_Bool ret = evas_object_key_grab(win->win_obj, "F12", mask, 0,
1511                                         EINA_TRUE);
1512    printf("Key F12 exclusive for dot tree generation. (%d)\n", ret);
1513 #endif
1514
1515    evas_object_smart_callbacks_descriptions_set(win->win_obj, _signals);
1516
1517    return win->win_obj;
1518 }
1519
1520 /**
1521  * Add @p subobj as a resize object of window @p obj.
1522  *
1523  * @param obj The window object
1524  * @param subobj The resize object to add
1525  *
1526  * @ingroup Win
1527  */
1528 EAPI void
1529 elm_win_resize_object_add(Evas_Object *obj, Evas_Object *subobj)
1530 {
1531    Evas_Coord w, h;
1532    Elm_Win *win;
1533    ELM_CHECK_WIDTYPE(obj, widtype);
1534    win = elm_widget_data_get(obj);
1535    if (!win) return;
1536    win->subobjs = eina_list_append(win->subobjs, subobj);
1537    elm_widget_sub_object_add(obj, subobj);
1538    evas_object_event_callback_add(subobj, EVAS_CALLBACK_DEL,
1539                                   _elm_win_subobj_callback_del, obj);
1540    evas_object_event_callback_add(subobj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1541                                   _elm_win_subobj_callback_changed_size_hints,
1542                                   obj);
1543    ecore_evas_geometry_get(win->ee, NULL, NULL, &w, &h);
1544    evas_object_move(subobj, 0, 0);
1545    evas_object_resize(subobj, w, h);
1546    _elm_win_eval_subobjs(obj);
1547 }
1548
1549 /**
1550  * Delete @p subobj as a resize object of window @p obj.
1551  *
1552  * @param obj The window object
1553  * @param subobj The resize object to add
1554  *
1555  * @ingroup Win
1556  */
1557 EAPI void
1558 elm_win_resize_object_del(Evas_Object *obj, Evas_Object *subobj)
1559 {
1560    Elm_Win *win;
1561    ELM_CHECK_WIDTYPE(obj, widtype);
1562    win = elm_widget_data_get(obj);
1563    if (!win) return;
1564    evas_object_event_callback_del_full(subobj,
1565                                        EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1566                                        _elm_win_subobj_callback_changed_size_hints,
1567                                        obj);
1568    evas_object_event_callback_del_full(subobj, EVAS_CALLBACK_DEL,
1569                                        _elm_win_subobj_callback_del, obj);
1570    win->subobjs = eina_list_remove(win->subobjs, subobj);
1571    elm_widget_sub_object_del(obj, subobj);
1572    _elm_win_eval_subobjs(obj);
1573 }
1574
1575 /**
1576  * Set the title of the window
1577  *
1578  * @param obj The window object
1579  * @param title The title to set
1580  *
1581  * @ingroup Win
1582  */
1583 EAPI void
1584 elm_win_title_set(Evas_Object *obj, const char *title)
1585 {
1586    Elm_Win *win;
1587    ELM_CHECK_WIDTYPE(obj, widtype);
1588    win = elm_widget_data_get(obj);
1589    if (!win) return;
1590    ecore_evas_title_set(win->ee, title);
1591 }
1592
1593 /**
1594  * Get the title of the window
1595  *
1596  * @param obj The window object
1597  * @return The title
1598  *
1599  * @ingroup Win
1600  */
1601 EAPI const char *
1602 elm_win_title_get(const Evas_Object *obj)
1603 {
1604    Elm_Win *win;
1605    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1606    win = elm_widget_data_get(obj);
1607    if (!win) return NULL;
1608    return ecore_evas_title_get(win->ee);
1609 }
1610
1611 /**
1612  * Set the window's autodel state.
1613  *
1614  * @param obj The window object
1615  * @param autodel If true, the window will automatically delete itself when closed
1616  *
1617  * @ingroup Win
1618  */
1619 EAPI void
1620 elm_win_autodel_set(Evas_Object *obj, Eina_Bool autodel)
1621 {
1622    Elm_Win *win;
1623    ELM_CHECK_WIDTYPE(obj, widtype);
1624    win = elm_widget_data_get(obj);
1625    if (!win) return;
1626    win->autodel = autodel;
1627 }
1628
1629 /**
1630  * Get the window's autodel state.
1631  *
1632  * @param obj The window object
1633  * @return If the window will automatically delete itself when closed
1634  *
1635  * @ingroup Win
1636  */
1637 EAPI Eina_Bool
1638 elm_win_autodel_get(const Evas_Object *obj)
1639 {
1640    Elm_Win *win;
1641    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1642    win = elm_widget_data_get(obj);
1643    if (!win) return EINA_FALSE;
1644    return win->autodel;
1645 }
1646
1647 /**
1648  * Activate a window object.
1649  *
1650  * @param obj The window object
1651  *
1652  * @ingroup Win
1653  */
1654 EAPI void
1655 elm_win_activate(Evas_Object *obj)
1656 {
1657    Elm_Win *win;
1658    ELM_CHECK_WIDTYPE(obj, widtype);
1659    win = elm_widget_data_get(obj);
1660    if (!win) return;
1661    ecore_evas_activate(win->ee);
1662 }
1663
1664 /**
1665  * Lower a window object.
1666  *
1667  * @param obj The window object
1668  *
1669  * @ingroup Win
1670  */
1671 EAPI void
1672 elm_win_lower(Evas_Object *obj)
1673 {
1674    Elm_Win *win;
1675    ELM_CHECK_WIDTYPE(obj, widtype);
1676    win = elm_widget_data_get(obj);
1677    if (!win) return;
1678    ecore_evas_lower(win->ee);
1679 }
1680
1681 /**
1682  * Raise a window object.
1683  *
1684  * @param obj The window object
1685  *
1686  * @ingroup Win
1687  */
1688 EAPI void
1689 elm_win_raise(Evas_Object *obj)
1690 {
1691    Elm_Win *win;
1692    ELM_CHECK_WIDTYPE(obj, widtype);
1693    win = elm_widget_data_get(obj);
1694    if (!win) return;
1695    ecore_evas_raise(win->ee);
1696 }
1697
1698 /**
1699  * Set the borderless state of a window.
1700  *
1701  * @param obj The window object
1702  * @param borderless If true, the window is borderless
1703  *
1704  * @ingroup Win
1705  */
1706 EAPI void
1707 elm_win_borderless_set(Evas_Object *obj, Eina_Bool borderless)
1708 {
1709    Elm_Win *win;
1710    ELM_CHECK_WIDTYPE(obj, widtype);
1711    win = elm_widget_data_get(obj);
1712    if (!win) return;
1713    ecore_evas_borderless_set(win->ee, borderless);
1714 #ifdef HAVE_ELEMENTARY_X
1715    _elm_win_xwin_update(win);
1716 #endif
1717 }
1718
1719 /**
1720  * Get the borderless state of a window.
1721  *
1722  * @param obj The window object
1723  * @return If true, the window is borderless
1724  *
1725  * @ingroup Win
1726  */
1727 EAPI Eina_Bool
1728 elm_win_borderless_get(const Evas_Object *obj)
1729 {
1730    Elm_Win *win;
1731    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1732    win = elm_widget_data_get(obj);
1733    if (!win) return EINA_FALSE;
1734    return ecore_evas_borderless_get(win->ee);
1735 }
1736
1737 /**
1738  * Set the shaped state of a window.
1739  *
1740  * @param obj The window object
1741  * @param shaped If true, the window is shaped
1742  *
1743  * @ingroup Win
1744  */
1745 EAPI void
1746 elm_win_shaped_set(Evas_Object *obj, Eina_Bool shaped)
1747 {
1748    Elm_Win *win;
1749    ELM_CHECK_WIDTYPE(obj, widtype);
1750    win = elm_widget_data_get(obj);
1751    if (!win) return;
1752    ecore_evas_shaped_set(win->ee, shaped);
1753 #ifdef HAVE_ELEMENTARY_X
1754    _elm_win_xwin_update(win);
1755 #endif
1756 }
1757
1758 /**
1759  * Get the shaped state of a window.
1760  *
1761  * @param obj The window object
1762  * @return If true, the window is shaped
1763  *
1764  * @ingroup Win
1765  */
1766 EAPI Eina_Bool
1767 elm_win_shaped_get(const Evas_Object *obj)
1768 {
1769    Elm_Win *win;
1770    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1771    win = elm_widget_data_get(obj);
1772    if (!win) return EINA_FALSE;
1773    return ecore_evas_shaped_get(win->ee);
1774 }
1775
1776 /**
1777  * Set the alpha channel state of a window.
1778  *
1779  * @param obj The window object
1780  * @param alpha If true, the window has an alpha channel
1781  *
1782  * @ingroup Win
1783  */
1784 EAPI void
1785 elm_win_alpha_set(Evas_Object *obj, Eina_Bool alpha)
1786 {
1787    Elm_Win *win;
1788    ELM_CHECK_WIDTYPE(obj, widtype);
1789    win = elm_widget_data_get(obj);
1790    if (!win) return;
1791    if (win->frame_obj)
1792      {
1793      }
1794    else if (win->img_obj)
1795      {
1796         evas_object_image_alpha_set(win->img_obj, alpha);
1797      }
1798    else
1799      {
1800 #ifdef HAVE_ELEMENTARY_X
1801         if (win->xwin)
1802           {
1803              if (alpha)
1804                {
1805                   if (!_elm_config->compositing)
1806                      elm_win_shaped_set(obj, alpha);
1807                   else
1808                      ecore_evas_alpha_set(win->ee, alpha);
1809                }
1810              else
1811                 ecore_evas_alpha_set(win->ee, alpha);
1812              _elm_win_xwin_update(win);
1813           }
1814         else
1815 #endif
1816            ecore_evas_alpha_set(win->ee, alpha);
1817      }
1818 }
1819
1820 /**
1821  * Get the alpha channel state of a window.
1822  *
1823  * @param obj The window object
1824  * @return If true, the window has an alpha channel
1825  *
1826  * @ingroup Win
1827  */
1828 EAPI Eina_Bool
1829 elm_win_alpha_get(const Evas_Object *obj)
1830 {
1831    Elm_Win *win;
1832    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1833    win = elm_widget_data_get(obj);
1834    if (!win) return EINA_FALSE;
1835    return ecore_evas_alpha_get(win->ee);
1836 }
1837
1838 /**
1839  * Set the transparency state of a window.
1840  *
1841  * @param obj The window object
1842  * @param transparent If true, the window is transparent
1843  *
1844  * @ingroup Win
1845  */
1846 EAPI void
1847 elm_win_transparent_set(Evas_Object *obj, Eina_Bool transparent)
1848 {
1849    Elm_Win *win;
1850    ELM_CHECK_WIDTYPE(obj, widtype);
1851    win = elm_widget_data_get(obj);
1852    if (!win) return;
1853
1854    if (win->frame_obj)
1855      {
1856      }
1857    else if (win->img_obj)
1858      {
1859         evas_object_image_alpha_set(win->img_obj, transparent);
1860      }
1861    else
1862      {
1863 #ifdef HAVE_ELEMENTARY_X
1864         if (win->xwin)
1865           {
1866              ecore_evas_transparent_set(win->ee, transparent);
1867              _elm_win_xwin_update(win);
1868           }
1869         else
1870 #endif
1871            ecore_evas_transparent_set(win->ee, transparent);
1872      }
1873 }
1874
1875 /**
1876  * Get the transparency state of a window.
1877  *
1878  * @param obj The window object
1879  * @return If true, the window is transparent
1880  *
1881  * @ingroup Win
1882  */
1883 EAPI Eina_Bool
1884 elm_win_transparent_get(const Evas_Object *obj)
1885 {
1886    Elm_Win *win;
1887    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1888    win = elm_widget_data_get(obj);
1889    if (!win) return EINA_FALSE;
1890
1891    return ecore_evas_transparent_get(win->ee);
1892 }
1893
1894 /**
1895  * Set the override state of a window.
1896  *
1897  * @param obj The window object
1898  * @param override If true, the window is overridden
1899  *
1900  * @ingroup Win
1901  */
1902 EAPI void
1903 elm_win_override_set(Evas_Object *obj, Eina_Bool override)
1904 {
1905    Elm_Win *win;
1906    ELM_CHECK_WIDTYPE(obj, widtype);
1907    win = elm_widget_data_get(obj);
1908    if (!win) return;
1909    ecore_evas_override_set(win->ee, override);
1910 #ifdef HAVE_ELEMENTARY_X
1911    _elm_win_xwin_update(win);
1912 #endif
1913 }
1914
1915 /**
1916  * Get the override state of a window.
1917  *
1918  * @param obj The window object
1919  * @return If true, the window is overridden
1920  *
1921  * @ingroup Win
1922  */
1923 EAPI Eina_Bool
1924 elm_win_override_get(const Evas_Object *obj)
1925 {
1926    Elm_Win *win;
1927    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1928    win = elm_widget_data_get(obj);
1929    if (!win) return EINA_FALSE;
1930    return ecore_evas_override_get(win->ee);
1931 }
1932
1933 /**
1934  * Set the fullscreen state of a window.
1935  *
1936  * @param obj The window object
1937  * @param fullscreen If true, the window is fullscreen
1938  *
1939  * @ingroup Win
1940  */
1941 EAPI void
1942 elm_win_fullscreen_set(Evas_Object *obj, Eina_Bool fullscreen)
1943 {
1944    Elm_Win *win;
1945    ELM_CHECK_WIDTYPE(obj, widtype);
1946    win = elm_widget_data_get(obj);
1947    if (!win) return;
1948
1949    // YYY: handle if win->img_obj
1950 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
1951    if (ENGINE_COMPARE(ELM_SOFTWARE_FB) ||
1952        ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE))
1953      {
1954         // these engines... can ONLY be fullscreen
1955         return;
1956      }
1957    else
1958      {
1959         ecore_evas_fullscreen_set(win->ee, fullscreen);
1960 #ifdef HAVE_ELEMENTARY_X
1961         _elm_win_xwin_update(win);
1962 #endif
1963      }
1964 #undef ENGINE_COMPARE
1965 }
1966
1967 /**
1968  * Get the fullscreen state of a window.
1969  *
1970  * @param obj The window object
1971  * @return If true, the window is fullscreen
1972  *
1973  * @ingroup Win
1974  */
1975 EAPI Eina_Bool
1976 elm_win_fullscreen_get(const Evas_Object *obj)
1977 {
1978    Elm_Win *win;
1979    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1980    win = elm_widget_data_get(obj);
1981    if (!win) return EINA_FALSE;
1982
1983 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
1984    if (ENGINE_COMPARE(ELM_SOFTWARE_FB) ||
1985        ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE))
1986      {
1987         // these engines... can ONLY be fullscreen
1988         return EINA_TRUE;
1989      }
1990    else
1991      {
1992         return ecore_evas_fullscreen_get(win->ee);
1993      }
1994 #undef ENGINE_COMPARE
1995 }
1996
1997 /**
1998  * Set the maximized state of a window.
1999  *
2000  * @param obj The window object
2001  * @param maximized If true, the window is maximized
2002  *
2003  * @ingroup Win
2004  */
2005 EAPI void
2006 elm_win_maximized_set(Evas_Object *obj, Eina_Bool maximized)
2007 {
2008    Elm_Win *win;
2009    ELM_CHECK_WIDTYPE(obj, widtype);
2010    win = elm_widget_data_get(obj);
2011    if (!win) return;
2012    // YYY: handle if win->img_obj
2013    ecore_evas_maximized_set(win->ee, maximized);
2014 #ifdef HAVE_ELEMENTARY_X
2015    _elm_win_xwin_update(win);
2016 #endif
2017 }
2018
2019 /**
2020  * Get the maximized state of a window.
2021  *
2022  * @param obj The window object
2023  * @return If true, the window is maximized
2024  *
2025  * @ingroup Win
2026  */
2027 EAPI Eina_Bool
2028 elm_win_maximized_get(const Evas_Object *obj)
2029 {
2030    Elm_Win *win;
2031    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2032    win = elm_widget_data_get(obj);
2033    if (!win) return EINA_FALSE;
2034    return ecore_evas_maximized_get(win->ee);
2035 }
2036
2037 /**
2038  * Set the iconified state of a window.
2039  *
2040  * @param obj The window object
2041  * @param iconified If true, the window is iconified
2042  *
2043  * @ingroup Win
2044  */
2045 EAPI void
2046 elm_win_iconified_set(Evas_Object *obj, Eina_Bool iconified)
2047 {
2048    Elm_Win *win;
2049    ELM_CHECK_WIDTYPE(obj, widtype);
2050    win = elm_widget_data_get(obj);
2051    if (!win) return;
2052    ecore_evas_iconified_set(win->ee, iconified);
2053 #ifdef HAVE_ELEMENTARY_X
2054    _elm_win_xwin_update(win);
2055 #endif
2056 }
2057
2058 /**
2059  * Get the iconified state of a window.
2060  *
2061  * @param obj The window object
2062  * @return If true, the window is iconified
2063  *
2064  * @ingroup Win
2065  */
2066 EAPI Eina_Bool
2067 elm_win_iconified_get(const Evas_Object *obj)
2068 {
2069    Elm_Win *win;
2070    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2071    win = elm_widget_data_get(obj);
2072    if (!win) return EINA_FALSE;
2073    return ecore_evas_iconified_get(win->ee);
2074 }
2075
2076 /**
2077  * Set the layer of the window.
2078  *
2079  * @param obj The window object
2080  * @param layer The layer of the window
2081  *
2082  * @ingroup Win
2083  */
2084 EAPI void
2085 elm_win_layer_set(Evas_Object *obj, int layer)
2086 {
2087    Elm_Win *win;
2088    ELM_CHECK_WIDTYPE(obj, widtype);
2089    win = elm_widget_data_get(obj);
2090    if (!win) return;
2091    ecore_evas_layer_set(win->ee, layer);
2092 #ifdef HAVE_ELEMENTARY_X
2093    _elm_win_xwin_update(win);
2094 #endif
2095 }
2096
2097 /**
2098  * Get the layer of the window.
2099  *
2100  * @param obj The window object
2101  * @return The layer of the window
2102  *
2103  * @ingroup Win
2104  */
2105 EAPI int
2106 elm_win_layer_get(const Evas_Object *obj)
2107 {
2108    Elm_Win *win;
2109    ELM_CHECK_WIDTYPE(obj, widtype) -1;
2110    win = elm_widget_data_get(obj);
2111    if (!win) return -1;
2112    return ecore_evas_layer_get(win->ee);
2113 }
2114
2115 /**
2116  * Set the rotation of the window.
2117  *
2118  * @param obj The window object
2119  * @param rotation The rotation of the window, in degrees (0-360)
2120  *
2121  * @ingroup Win
2122  */
2123 EAPI void
2124 elm_win_rotation_set(Evas_Object *obj, int rotation)
2125 {
2126    Elm_Win *win;
2127    ELM_CHECK_WIDTYPE(obj, widtype);
2128    win = elm_widget_data_get(obj);
2129    if (!win) return;
2130    if (win->rot == rotation) return;
2131    win->rot = rotation;
2132    ecore_evas_rotation_set(win->ee, rotation);
2133    evas_object_size_hint_min_set(obj, -1, -1);
2134    evas_object_size_hint_max_set(obj, -1, -1);
2135    _elm_win_eval_subobjs(obj);
2136 #ifdef HAVE_ELEMENTARY_X
2137    _elm_win_xwin_update(win);
2138 #endif
2139 }
2140
2141 /**
2142  * Rotates the window and resizes it
2143  *
2144  * @param obj The window object
2145  * @param layer The rotation of the window in degrees (0-360)
2146  *
2147  * @ingroup Win
2148  */
2149 EAPI void
2150 elm_win_rotation_with_resize_set(Evas_Object *obj, int rotation)
2151 {
2152    Elm_Win *win;
2153    ELM_CHECK_WIDTYPE(obj, widtype);
2154    win = elm_widget_data_get(obj);
2155    if (!win) return;
2156    if (win->rot == rotation) return;
2157    win->rot = rotation;
2158    ecore_evas_rotation_with_resize_set(win->ee, rotation);
2159    evas_object_size_hint_min_set(obj, -1, -1);
2160    evas_object_size_hint_max_set(obj, -1, -1);
2161    _elm_win_eval_subobjs(obj);
2162 #ifdef HAVE_ELEMENTARY_X
2163    _elm_win_xwin_update(win);
2164 #endif
2165 }
2166
2167 /**
2168  * Get the rotation of the window.
2169  *
2170  * @param obj The window object
2171  * @return The rotation of the window in degrees (0-360)
2172  *
2173  * @ingroup Win
2174  */
2175 EAPI int
2176 elm_win_rotation_get(const Evas_Object *obj)
2177 {
2178    Elm_Win *win;
2179    ELM_CHECK_WIDTYPE(obj, widtype) -1;
2180    win = elm_widget_data_get(obj);
2181    if (!win) return -1;
2182    return win->rot;
2183 }
2184
2185 /**
2186  * Set the sticky state of the window.
2187  *
2188  * @param obj The window object
2189  * @param sticky If true, the window's sticky state is enabled
2190  *
2191  * @ingroup Win
2192  */
2193 EAPI void
2194 elm_win_sticky_set(Evas_Object *obj, Eina_Bool sticky)
2195 {
2196    Elm_Win *win;
2197    ELM_CHECK_WIDTYPE(obj, widtype);
2198    win = elm_widget_data_get(obj);
2199    if (!win) return;
2200    ecore_evas_sticky_set(win->ee, sticky);
2201 #ifdef HAVE_ELEMENTARY_X
2202    _elm_win_xwin_update(win);
2203 #endif
2204 }
2205
2206 /**
2207  * Get the sticky state of the window.
2208  *
2209  * @param obj The window object
2210  * @return If true, the window's sticky state is enabled
2211  *
2212  * @ingroup Win
2213  */
2214 EAPI Eina_Bool
2215 elm_win_sticky_get(const Evas_Object *obj)
2216 {
2217    Elm_Win *win;
2218    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2219    win = elm_widget_data_get(obj);
2220    if (!win) return EINA_FALSE;
2221    return ecore_evas_sticky_get(win->ee);
2222 }
2223
2224 /**
2225  * Sets the keyboard mode of the window.
2226  *
2227  * @param obj The window object
2228  * @param mode The mode to set; one of:
2229  * ELM_WIN_KEYBOARD_UNKNOWN
2230  * ELM_WIN_KEYBOARD_OFF
2231  * ELM_WIN_KEYBOARD_ON
2232  * ELM_WIN_KEYBOARD_ALPHA
2233  * ELM_WIN_KEYBOARD_NUMERIC
2234  * ELM_WIN_KEYBOARD_PIN
2235  * ELM_WIN_KEYBOARD_PHONE_NUMBER
2236  * ELM_WIN_KEYBOARD_HEX
2237  * ELM_WIN_KEYBOARD_TERMINAL
2238  * ELM_WIN_KEYBOARD_PASSWORD
2239  * ELM_WIN_KEYBOARD_IP
2240  * ELM_WIN_KEYBOARD_HOST
2241  * ELM_WIN_KEYBOARD_FILE
2242  * ELM_WIN_KEYBOARD_URL
2243  * ELM_WIN_KEYBOARD_KEYPAD
2244  * ELM_WIN_KEYBOARD_J2ME
2245  *
2246  * @ingroup Win
2247  */
2248 EAPI void
2249 elm_win_keyboard_mode_set(Evas_Object *obj, Elm_Win_Keyboard_Mode mode)
2250 {
2251    Elm_Win *win;
2252    ELM_CHECK_WIDTYPE(obj, widtype);
2253    win = elm_widget_data_get(obj);
2254    if (!win) return;
2255    if (mode == win->kbdmode) return;
2256 #ifdef HAVE_ELEMENTARY_X
2257    _elm_win_xwindow_get(win);
2258 #endif
2259    win->kbdmode = mode;
2260 #ifdef HAVE_ELEMENTARY_X
2261    if (win->xwin)
2262      ecore_x_e_virtual_keyboard_state_set
2263         (win->xwin, (Ecore_X_Virtual_Keyboard_State)win->kbdmode);
2264 #endif
2265 }
2266
2267 /**
2268  * Gets the keyboard mode of the window.
2269  *
2270  * @param obj The window object
2271  * @return The mode; one of:
2272  * ELM_WIN_KEYBOARD_UNKNOWN
2273  * ELM_WIN_KEYBOARD_OFF
2274  * ELM_WIN_KEYBOARD_ON
2275  * ELM_WIN_KEYBOARD_ALPHA
2276  * ELM_WIN_KEYBOARD_NUMERIC
2277  * ELM_WIN_KEYBOARD_PIN
2278  * ELM_WIN_KEYBOARD_PHONE_NUMBER
2279  * ELM_WIN_KEYBOARD_HEX
2280  * ELM_WIN_KEYBOARD_TERMINAL
2281  * ELM_WIN_KEYBOARD_PASSWORD
2282  * ELM_WIN_KEYBOARD_IP
2283  * ELM_WIN_KEYBOARD_HOST
2284  * ELM_WIN_KEYBOARD_FILE
2285  * ELM_WIN_KEYBOARD_URL
2286  * ELM_WIN_KEYBOARD_KEYPAD
2287  * ELM_WIN_KEYBOARD_J2ME
2288  *
2289  * @ingroup Win
2290  */
2291 EAPI Elm_Win_Keyboard_Mode
2292 elm_win_keyboard_mode_get(const Evas_Object *obj)
2293 {
2294    Elm_Win *win;
2295    ELM_CHECK_WIDTYPE(obj, widtype) ELM_WIN_KEYBOARD_UNKNOWN;
2296    win = elm_widget_data_get(obj);
2297    if (!win) return ELM_WIN_KEYBOARD_UNKNOWN;
2298    return win->kbdmode;
2299 }
2300
2301 /**
2302  * Sets whether the window is a keyboard.
2303  *
2304  * @param obj The window object
2305  * @param is_keyboard If true, the window is a virtual keyboard
2306  *
2307  * @ingroup Win
2308  */
2309 EAPI void
2310 elm_win_keyboard_win_set(Evas_Object *obj, Eina_Bool is_keyboard)
2311 {
2312    Elm_Win *win;
2313    ELM_CHECK_WIDTYPE(obj, widtype);
2314    win = elm_widget_data_get(obj);
2315    if (!win) return;
2316 #ifdef HAVE_ELEMENTARY_X
2317    _elm_win_xwindow_get(win);
2318    if (win->xwin)
2319      ecore_x_e_virtual_keyboard_set(win->xwin, is_keyboard);
2320 #endif
2321 }
2322
2323 /**
2324  * Gets whether the window is a keyboard.
2325  *
2326  * @param obj The window object
2327  * @return If the window is a virtual keyboard
2328  *
2329  * @ingroup Win
2330  */
2331 EAPI Eina_Bool
2332 elm_win_keyboard_win_get(const Evas_Object *obj)
2333 {
2334    Elm_Win *win;
2335    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2336    win = elm_widget_data_get(obj);
2337    if (!win) return EINA_FALSE;
2338 #ifdef HAVE_ELEMENTARY_X
2339    _elm_win_xwindow_get(win);
2340    if (win->xwin)
2341      return ecore_x_e_virtual_keyboard_get(win->xwin);
2342 #endif
2343    return EINA_FALSE;
2344 }
2345
2346 /**
2347  * Get the screen position of a window.
2348  *
2349  * @param obj The window object
2350  * @param x The int to store the x coordinate to
2351  * @param y The int to store the y coordinate to
2352  *
2353  * @ingroup Win
2354  */
2355 EAPI void
2356 elm_win_screen_position_get(const Evas_Object *obj, int *x, int *y)
2357 {
2358    Elm_Win *win;
2359    ELM_CHECK_WIDTYPE(obj, widtype);
2360    win = elm_widget_data_get(obj);
2361    if (!win) return;
2362    if (x) *x = win->screen.x;
2363    if (y) *y = win->screen.y;
2364 }
2365
2366 /**
2367  * Set if this window is an illume conformant window
2368  *
2369  * @param obj The window object
2370  * @param conformant The conformant flag (1 = conformant, 0 = non-conformant)
2371  *
2372  * @ingroup Win
2373  */
2374 EAPI void
2375 elm_win_conformant_set(Evas_Object *obj, Eina_Bool conformant)
2376 {
2377    Elm_Win *win;
2378    ELM_CHECK_WIDTYPE(obj, widtype);
2379    win = elm_widget_data_get(obj);
2380    if (!win) return;
2381 #ifdef HAVE_ELEMENTARY_X
2382    _elm_win_xwindow_get(win);
2383    if (win->xwin)
2384      ecore_x_e_illume_conformant_set(win->xwin, conformant);
2385 #endif
2386 }
2387
2388 /**
2389  * Get if this window is an illume conformant window
2390  *
2391  * @param obj The window object
2392  * @return A boolean if this window is illume conformant or not
2393  *
2394  * @ingroup Win
2395  */
2396 EAPI Eina_Bool
2397 elm_win_conformant_get(const Evas_Object *obj)
2398 {
2399    Elm_Win *win;
2400    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2401    win = elm_widget_data_get(obj);
2402    if (!win) return EINA_FALSE;
2403 #ifdef HAVE_ELEMENTARY_X
2404    _elm_win_xwindow_get(win);
2405    if (win->xwin)
2406      return ecore_x_e_illume_conformant_get(win->xwin);
2407 #endif
2408    return EINA_FALSE;
2409 }
2410
2411 /**
2412  * Set a window to be an illume quickpanel window
2413  *
2414  * By default window objects are not quickpanel windows.
2415  *
2416  * @param obj The window object
2417  * @param quickpanel The quickpanel flag (1 = quickpanel, 0 = normal window)
2418  *
2419  * @ingroup Win
2420  */
2421 EAPI void
2422 elm_win_quickpanel_set(Evas_Object *obj, Eina_Bool quickpanel)
2423 {
2424    Elm_Win *win;
2425    ELM_CHECK_WIDTYPE(obj, widtype);
2426    win = elm_widget_data_get(obj);
2427    if (!win) return;
2428 #ifdef HAVE_ELEMENTARY_X
2429    _elm_win_xwindow_get(win);
2430    if (win->xwin)
2431      {
2432         ecore_x_e_illume_quickpanel_set(win->xwin, quickpanel);
2433         if (quickpanel)
2434           {
2435              Ecore_X_Window_State states[2];
2436
2437              states[0] = ECORE_X_WINDOW_STATE_SKIP_TASKBAR;
2438              states[1] = ECORE_X_WINDOW_STATE_SKIP_PAGER;
2439              ecore_x_netwm_window_state_set(win->xwin, states, 2);
2440              ecore_x_icccm_hints_set(win->xwin, 0, 0, 0, 0, 0, 0, 0);
2441           }
2442      }
2443 #endif
2444 }
2445
2446 /**
2447  * Get if this window is a quickpanel or not
2448  *
2449  * @param obj The window object
2450  * @return A boolean if this window is a quickpanel or not
2451  *
2452  * @ingroup Win
2453  */
2454 EAPI Eina_Bool
2455 elm_win_quickpanel_get(const Evas_Object *obj)
2456 {
2457    Elm_Win *win;
2458    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2459    win = elm_widget_data_get(obj);
2460    if (!win) return EINA_FALSE;
2461 #ifdef HAVE_ELEMENTARY_X
2462    _elm_win_xwindow_get(win);
2463    if (win->xwin)
2464      return ecore_x_e_illume_quickpanel_get(win->xwin);
2465 #endif
2466    return EINA_FALSE;
2467 }
2468
2469 /**
2470  * Set the major priority of a quickpanel window
2471  *
2472  * @param obj The window object
2473  * @param priority The major priority for this quickpanel
2474  *
2475  * @ingroup Win
2476  */
2477 EAPI void
2478 elm_win_quickpanel_priority_major_set(Evas_Object *obj, int priority)
2479 {
2480    Elm_Win *win;
2481    ELM_CHECK_WIDTYPE(obj, widtype);
2482    win = elm_widget_data_get(obj);
2483    if (!win) return;
2484 #ifdef HAVE_ELEMENTARY_X
2485    _elm_win_xwindow_get(win);
2486    if (win->xwin)
2487      ecore_x_e_illume_quickpanel_priority_major_set(win->xwin, priority);
2488 #endif
2489 }
2490
2491 /**
2492  * Get the major priority of a quickpanel window
2493  *
2494  * @param obj The window object
2495  * @return The major priority of this quickpanel
2496  *
2497  * @ingroup Win
2498  */
2499 EAPI int
2500 elm_win_quickpanel_priority_major_get(const Evas_Object *obj)
2501 {
2502    Elm_Win *win;
2503    ELM_CHECK_WIDTYPE(obj, widtype) -1;
2504    win = elm_widget_data_get(obj);
2505    if (!win) return -1;
2506 #ifdef HAVE_ELEMENTARY_X
2507    _elm_win_xwindow_get(win);
2508    if (win->xwin)
2509      return ecore_x_e_illume_quickpanel_priority_major_get(win->xwin);
2510 #endif
2511    return -1;
2512 }
2513
2514 /**
2515  * Set the minor priority of a quickpanel window
2516  *
2517  * @param obj The window object
2518  * @param priority The minor priority for this quickpanel
2519  *
2520  * @ingroup Win
2521  */
2522 EAPI void
2523 elm_win_quickpanel_priority_minor_set(Evas_Object *obj, int priority)
2524 {
2525    Elm_Win *win;
2526    ELM_CHECK_WIDTYPE(obj, widtype);
2527    win = elm_widget_data_get(obj);
2528    if (!win) return;
2529 #ifdef HAVE_ELEMENTARY_X
2530    _elm_win_xwindow_get(win);
2531    if (win->xwin)
2532      ecore_x_e_illume_quickpanel_priority_minor_set(win->xwin, priority);
2533 #endif
2534 }
2535
2536 /**
2537  * Get the minor priority of a quickpanel window
2538  *
2539  * @param obj The window object
2540  * @return The minor priority of this quickpanel
2541  *
2542  * @ingroup Win
2543  */
2544 EAPI int
2545 elm_win_quickpanel_priority_minor_get(const Evas_Object *obj)
2546 {
2547    Elm_Win *win;
2548    ELM_CHECK_WIDTYPE(obj, widtype) -1;
2549    win = elm_widget_data_get(obj);
2550    if (!win) return -1;
2551 #ifdef HAVE_ELEMENTARY_X
2552    _elm_win_xwindow_get(win);
2553    if (win->xwin)
2554      return ecore_x_e_illume_quickpanel_priority_minor_get(win->xwin);
2555 #endif
2556    return -1;
2557 }
2558
2559 /**
2560  * Set which zone this quickpanel should appear in
2561  *
2562  * @param obj The window object
2563  * @param zone The requested zone for this quickpanel
2564  *
2565  * @ingroup Win
2566  */
2567 EAPI void
2568 elm_win_quickpanel_zone_set(Evas_Object *obj, int zone)
2569 {
2570    Elm_Win *win;
2571    ELM_CHECK_WIDTYPE(obj, widtype);
2572    win = elm_widget_data_get(obj);
2573    if (!win) return;
2574 #ifdef HAVE_ELEMENTARY_X
2575    _elm_win_xwindow_get(win);
2576    if (win->xwin)
2577      ecore_x_e_illume_quickpanel_zone_set(win->xwin, zone);
2578 #endif
2579 }
2580
2581 /**
2582  * Get which zone this quickpanel should appear in
2583  *
2584  * @param obj The window object
2585  * @return The requested zone for this quickpanel
2586  *
2587  * @ingroup Win
2588  */
2589 EAPI int
2590 elm_win_quickpanel_zone_get(const Evas_Object *obj)
2591 {
2592    Elm_Win *win;
2593    ELM_CHECK_WIDTYPE(obj, widtype) 0;
2594    win = elm_widget_data_get(obj);
2595    if (!win) return 0;
2596 #ifdef HAVE_ELEMENTARY_X
2597    _elm_win_xwindow_get(win);
2598    if (win->xwin)
2599      return ecore_x_e_illume_quickpanel_zone_get(win->xwin);
2600 #endif
2601    return 0;
2602 }
2603
2604 /**
2605  * Set the window to be skipped by keyboard focus
2606  *
2607  * This sets the window to be skipped by normal keyboard input. This means
2608  * a window manager will be asked to not focus this window as well as omit
2609  * it from things like the taskbar, pager, "alt-tab" list etc. etc.
2610  *
2611  * Call this and enable it on a window BEFORE you show it for the first time,
2612  * otherwise it may have no effect.
2613  *
2614  * Use this for windows that have only output information or might only be
2615  * interacted with by the mouse or fingers, and never for typing input.
2616  * Be careful that this may have side-effects like making the window
2617  * non-accessible in some cases unless the window is specially handled. Use
2618  * this with care.
2619  *
2620  * @param obj The window object
2621  * @param skip The skip flag state (EINA_TRUE if it is to be skipped)
2622  *
2623  * @ingroup Win
2624  */
2625 EAPI void
2626 elm_win_prop_focus_skip_set(Evas_Object *obj, Eina_Bool skip)
2627 {
2628    Elm_Win *win;
2629    ELM_CHECK_WIDTYPE(obj, widtype);
2630    win = elm_widget_data_get(obj);
2631    if (!win) return;
2632 #ifdef HAVE_ELEMENTARY_X
2633    _elm_win_xwindow_get(win);
2634    if (skip)
2635      {
2636         if (win->xwin)
2637           {
2638              Ecore_X_Window_State states[2];
2639
2640              ecore_x_icccm_hints_set(win->xwin, 0, 0, 0, 0, 0, 0, 0);
2641              states[0] = ECORE_X_WINDOW_STATE_SKIP_TASKBAR;
2642              states[1] = ECORE_X_WINDOW_STATE_SKIP_PAGER;
2643              ecore_x_netwm_window_state_set(win->xwin, states, 2);
2644           }
2645      }
2646 #endif
2647 }
2648
2649 /**
2650  * Send a command to the windowing environment
2651  *
2652  * This is intended to work in touchscreen or small screen device environments
2653  * where there is a more simplistic window management policy in place. This
2654  * uses the window object indicated to select which part of the environment
2655  * to control (the part that this window lives in), and provides a command
2656  * and an optional parameter structure (use NULL for this if not needed).
2657  *
2658  * @param obj The window object that lives in the environment to control
2659  * @param command The command to send
2660  * @param params Optional parameters for the command
2661  *
2662  * @ingroup Win
2663  */
2664 EAPI void
2665 elm_win_illume_command_send(Evas_Object *obj, Elm_Illume_Command command, void *params __UNUSED__)
2666 {
2667    Elm_Win *win;
2668    ELM_CHECK_WIDTYPE(obj, widtype);
2669    win = elm_widget_data_get(obj);
2670    if (!win) return;
2671 #ifdef HAVE_ELEMENTARY_X
2672    _elm_win_xwindow_get(win);
2673    if (win->xwin)
2674      {
2675         switch (command)
2676           {
2677            case ELM_ILLUME_COMMAND_FOCUS_BACK:
2678               ecore_x_e_illume_focus_back_send(win->xwin);
2679               break;
2680            case ELM_ILLUME_COMMAND_FOCUS_FORWARD:
2681               ecore_x_e_illume_focus_forward_send(win->xwin);
2682               break;
2683            case ELM_ILLUME_COMMAND_FOCUS_HOME:
2684               ecore_x_e_illume_focus_home_send(win->xwin);
2685               break;
2686            case ELM_ILLUME_COMMAND_CLOSE:
2687               ecore_x_e_illume_close_send(win->xwin);
2688               break;
2689            default:
2690               break;
2691           }
2692      }
2693 #endif
2694 }
2695
2696 /**
2697  * Get the inlined image object handle
2698  *
2699  * When you create a window with elm_win_add() of type ELM_WIN_INLINED_IMAGE,
2700  * then the window is in fact an evas image object inlined in the parent
2701  * canvas. You can get this object (be careful to not manipulate it as it
2702  * is under control of elementary), and use it to do things like get pixel
2703  * data, save the image to a file, etc.
2704  *
2705  * @param obj The window object to get the inlined image from
2706  * @return The inlined image object, or NULL if none exists
2707  *
2708  * @ingroup Win
2709  */
2710 EAPI Evas_Object *
2711 elm_win_inlined_image_object_get(Evas_Object *obj)
2712 {
2713    Elm_Win *win;
2714    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2715    win = elm_widget_data_get(obj);
2716    if (!win) return NULL;
2717    return win->img_obj;
2718 }
2719
2720 /**
2721  * Set the enabled status for the focus highlight in a window
2722  *
2723  * This function will enable or disable the focus highlight only for the
2724  * given window, regardless of the global setting for it
2725  *
2726  * @param obj The window where to enable the highlight
2727  * @param enabled The enabled value for the highlight
2728  *
2729  * @ingroup Win
2730  */
2731 EAPI void
2732 elm_win_focus_highlight_enabled_set(Evas_Object *obj, Eina_Bool enabled)
2733 {
2734    Elm_Win *win;
2735
2736    ELM_CHECK_WIDTYPE(obj, widtype);
2737
2738    win = elm_widget_data_get(obj);
2739    enabled = !!enabled;
2740    if (win->focus_highlight.enabled == enabled)
2741      return;
2742
2743    win->focus_highlight.enabled = enabled;
2744
2745    if (win->focus_highlight.enabled)
2746      _elm_win_focus_highlight_init(win);
2747    else
2748      _elm_win_focus_highlight_shutdown(win);
2749 }
2750
2751 /**
2752  * Get the enabled value of the focus highlight for this window
2753  *
2754  * @param obj The window in which to check if the focus highlight is enabled
2755  *
2756  * @return EINA_TRUE if enabled, EINA_FALSE otherwise
2757  *
2758  * @ingroup Win
2759  */
2760 EAPI Eina_Bool
2761 elm_win_focus_highlight_enabled_get(const Evas_Object *obj)
2762 {
2763    Elm_Win *win;
2764
2765    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2766
2767    win = elm_widget_data_get(obj);
2768    return win->focus_highlight.enabled;
2769 }
2770
2771 /**
2772  * Set the style for the focus highlight on this window
2773  *
2774  * Sets the style to use for theming the highlight of focused objects on
2775  * the given window. If @p style is NULL, the default will be used.
2776  *
2777  * @param obj The window where to set the style
2778  * @param style The style to set
2779  *
2780  * @ingroup Win
2781  */
2782 EAPI void
2783 elm_win_focus_highlight_style_set(Evas_Object *obj, const char *style)
2784 {
2785    Elm_Win *win;
2786
2787    ELM_CHECK_WIDTYPE(obj, widtype);
2788
2789    win = elm_widget_data_get(obj);
2790    eina_stringshare_replace(&win->focus_highlight.style, style);
2791    win->focus_highlight.changed_theme = EINA_TRUE;
2792    _elm_win_focus_highlight_reconfigure_job_start(win);
2793 }
2794
2795 /**
2796  * Get the style set for the focus highlight object
2797  *
2798  * Gets the style set for this windows highilght object, or NULL if none
2799  * is set.
2800  *
2801  * @param obj The window to retrieve the highlights style from
2802  *
2803  * @return The style set or NULL if none was. Default is used in that case.
2804  *
2805  * @ingroup Win
2806  */
2807 EAPI const char *
2808 elm_win_focus_highlight_style_get(const Evas_Object *obj)
2809 {
2810    Elm_Win *win;
2811
2812    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2813
2814    win = elm_widget_data_get(obj);
2815    return win->focus_highlight.style;
2816 }
2817
2818 typedef struct _Widget_Data Widget_Data;
2819
2820 struct _Widget_Data
2821 {
2822    Evas_Object *frm;
2823    Evas_Object *content;
2824 };
2825
2826 static void _del_hook(Evas_Object *obj);
2827 static void _theme_hook(Evas_Object *obj);
2828 static void _sizing_eval(Evas_Object *obj);
2829 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
2830 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
2831
2832 static const char *widtype2 = NULL;
2833
2834 static void
2835 _del_hook(Evas_Object *obj)
2836 {
2837    Widget_Data *wd = elm_widget_data_get(obj);
2838    if (!wd) return;
2839    free(wd);
2840 }
2841
2842 static void
2843 _theme_hook(Evas_Object *obj)
2844 {
2845    Widget_Data *wd = elm_widget_data_get(obj);
2846    _elm_theme_object_set(obj, wd->frm, "win", "inwin", elm_widget_style_get(obj));
2847    if (wd->content)
2848      edje_object_part_swallow(wd->frm, "elm.swallow.content", wd->content);
2849    _sizing_eval(obj);
2850 }
2851
2852 static Eina_Bool
2853 _elm_inwin_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
2854 {
2855    Widget_Data *wd = elm_widget_data_get(obj);
2856
2857    if (!wd)
2858      return EINA_FALSE;
2859
2860    /* Try Focus cycle in subitem */
2861    if (wd->content)
2862      {
2863         elm_widget_focus_next_get(wd->content, dir, next);
2864         if (*next)
2865           return EINA_TRUE;
2866      }
2867
2868    *next = (Evas_Object *)obj;
2869    return EINA_FALSE;
2870 }
2871
2872 static void
2873 _sizing_eval(Evas_Object *obj)
2874 {
2875    Widget_Data *wd = elm_widget_data_get(obj);
2876    Evas_Coord minw = -1, minh = -1;
2877
2878    evas_object_size_hint_min_get(wd->content, &minw, &minh);
2879    edje_object_size_min_calc(wd->frm, &minw, &minh);
2880    evas_object_size_hint_min_set(obj, minw, minh);
2881    evas_object_size_hint_max_set(obj, -1, -1);
2882 }
2883
2884 static void
2885 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2886 {
2887    _sizing_eval(data);
2888 }
2889
2890 static void
2891 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
2892 {
2893    Widget_Data *wd = elm_widget_data_get(obj);
2894    Evas_Object *sub = event_info;
2895    if (sub == wd->content)
2896      {
2897         evas_object_event_callback_del_full
2898            (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
2899         wd->content = NULL;
2900         _sizing_eval(obj);
2901      }
2902 }
2903
2904 /**
2905  * @defgroup Inwin Inwin
2906  *
2907  * An inwin is a window inside a window that is useful for a quick popup.  It does not hover.
2908  */
2909 EAPI Evas_Object *
2910 elm_win_inwin_add(Evas_Object *obj)
2911 {
2912    Evas_Object *obj2;
2913    Widget_Data *wd;
2914    Elm_Win *win;
2915
2916    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2917    win = elm_widget_data_get(obj);
2918    if (!win) return NULL;
2919    wd = ELM_NEW(Widget_Data);
2920    obj2 = elm_widget_add(win->evas);
2921    elm_widget_type_set(obj2, "inwin");
2922    ELM_SET_WIDTYPE(widtype2, "inwin");
2923    elm_widget_sub_object_add(obj, obj2);
2924    evas_object_size_hint_weight_set(obj2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2925    evas_object_size_hint_align_set(obj2, EVAS_HINT_FILL, EVAS_HINT_FILL);
2926    elm_win_resize_object_add(obj, obj2);
2927
2928    elm_widget_data_set(obj2, wd);
2929    elm_widget_del_hook_set(obj2, _del_hook);
2930    elm_widget_theme_hook_set(obj2, _theme_hook);
2931    elm_widget_focus_next_hook_set(obj2, _elm_inwin_focus_next_hook);
2932    elm_widget_can_focus_set(obj2, EINA_TRUE);
2933    elm_widget_highlight_ignore_set(obj2, EINA_TRUE);
2934
2935    wd->frm = edje_object_add(win->evas);
2936    _elm_theme_object_set(obj, wd->frm, "win", "inwin", "default");
2937    elm_widget_resize_object_set(obj2, wd->frm);
2938
2939    evas_object_smart_callback_add(obj2, "sub-object-del", _sub_del, obj2);
2940
2941    _sizing_eval(obj2);
2942    return obj2;
2943 }
2944
2945 /**
2946  * Activates an inwin object
2947  *
2948  * @param obj The inwin to activate
2949  *
2950  * @ingroup Inwin
2951  */
2952 EAPI void
2953 elm_win_inwin_activate(Evas_Object *obj)
2954 {
2955    ELM_CHECK_WIDTYPE(obj, widtype2);
2956    Widget_Data *wd = elm_widget_data_get(obj);
2957    if (!wd) return;
2958    evas_object_raise(obj);
2959    evas_object_show(obj);
2960    edje_object_signal_emit(wd->frm, "elm,action,show", "elm");
2961    elm_object_focus(obj);
2962 }
2963
2964 /**
2965  * Set the content of an inwin object.
2966  *
2967  * Once the content object is set, a previously set one will be deleted.
2968  * If you want to keep that old content object, use the
2969  * elm_win_inwin_content_unset() function.
2970  *
2971  * @param obj The inwin object
2972  * @param content The object to set as content
2973  *
2974  * @ingroup Inwin
2975  */
2976 EAPI void
2977 elm_win_inwin_content_set(Evas_Object *obj, Evas_Object *content)
2978 {
2979    ELM_CHECK_WIDTYPE(obj, widtype2);
2980    Widget_Data *wd = elm_widget_data_get(obj);
2981    if (!wd) return;
2982    if (wd->content == content) return;
2983    if (wd->content) evas_object_del(wd->content);
2984    wd->content = content;
2985    if (content)
2986      {
2987         elm_widget_sub_object_add(obj, content);
2988         evas_object_event_callback_add(content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
2989                                        _changed_size_hints, obj);
2990         edje_object_part_swallow(wd->frm, "elm.swallow.content", content);
2991      }
2992    _sizing_eval(obj);
2993 }
2994
2995 /**
2996  * Get the content of an inwin object.
2997  *
2998  * Return the content object which is set for this widget.
2999  *
3000  * @param obj The inwin object
3001  * @return The content that is being used
3002  *
3003  * @ingroup Inwin
3004  */
3005 EAPI Evas_Object *
3006 elm_win_inwin_content_get(const Evas_Object *obj)
3007 {
3008    ELM_CHECK_WIDTYPE(obj, widtype2) NULL;
3009    Widget_Data *wd = elm_widget_data_get(obj);
3010    if (!wd) return NULL;
3011    return wd->content;
3012 }
3013
3014 /**
3015  * Unset the content of an inwin object.
3016  *
3017  * Unparent and return the content object which was set for this widget.
3018  *
3019  * @param obj The inwin object
3020  * @return The content that was being used
3021  *
3022  * @ingroup Inwin
3023  */
3024 EAPI Evas_Object *
3025 elm_win_inwin_content_unset(Evas_Object *obj)
3026 {
3027    ELM_CHECK_WIDTYPE(obj, widtype2) NULL;
3028    Widget_Data *wd = elm_widget_data_get(obj);
3029    if (!wd) return NULL;
3030    if (!wd->content) return NULL;
3031    Evas_Object *content = wd->content;
3032    elm_widget_sub_object_del(obj, wd->content);
3033    edje_object_part_unswallow(wd->frm, wd->content);
3034    wd->content = NULL;
3035    return content;
3036 }
3037
3038 /* windowing spcific calls - shall we do this differently? */
3039
3040 static Ecore_X_Window
3041 _elm_ee_win_get(const Evas_Object *obj)
3042 {
3043    if (!obj) return 0;
3044 #ifdef HAVE_ELEMENTARY_X
3045    Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
3046    if (ee) return (Ecore_X_Window)ecore_evas_window_get(ee);
3047 #endif
3048    return 0;
3049 }
3050
3051 /**
3052  * Get the Ecore_X_Window of an Evas_Object
3053  *
3054  * @param obj The object
3055  *
3056  * @return The Ecore_X_Window of @p obj
3057  *
3058  * @ingroup Win
3059  */
3060 EAPI Ecore_X_Window
3061 elm_win_xwindow_get(const Evas_Object *obj)
3062 {
3063    Ecore_X_Window xwin = 0;
3064    Elm_Win *win;
3065    const char *type;
3066
3067    if (!obj) return 0;
3068    type = elm_widget_type_get(obj);
3069    if (!type) return 0;
3070    if (type != widtype) return _elm_ee_win_get(obj);
3071 #ifdef HAVE_ELEMENTARY_X
3072    win = elm_widget_data_get(obj);
3073    if (!win) return xwin;
3074    if (win->xwin) return win->xwin;
3075    if (win->parent) return elm_win_xwindow_get(win->parent);
3076 #endif
3077    return xwin;
3078    win = NULL;
3079 }