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