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