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