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