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