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