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