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