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