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