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