Elementary migration revision 69832
[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    Elm_Win_Indicator_Mode indmode;
22    Elm_Win_Indicator_Opacity_Mode ind_o_mode;
23    struct
24      {
25         const char *info;
26         Ecore_Timer *timer;
27         int repeat_count;
28         int shot_counter;
29      } shot;
30    int resize_location;
31    int *autodel_clear, rot;
32    int show_count;
33    struct
34      {
35         int x, y;
36      } screen;
37    struct
38      {
39         Ecore_Evas *ee;
40         Evas *evas;
41         Evas_Object *obj, *hot_obj;
42         int hot_x, hot_y;
43      } pointer;
44    struct
45      {
46         Evas_Object *top;
47
48         struct
49           {
50              Evas_Object *target;
51              Eina_Bool visible : 1;
52              Eina_Bool handled : 1;
53           } cur, prev;
54
55         const char *style;
56         Ecore_Job *reconf_job;
57
58         Eina_Bool enabled : 1;
59         Eina_Bool changed_theme : 1;
60         Eina_Bool top_animate : 1;
61         Eina_Bool geometry_changed : 1;
62      } focus_highlight;
63
64    Evas_Object *icon;
65    const char *title;
66    const char *icon_name;
67    const char *role;
68
69    double aspect;
70    Eina_Bool urgent : 1;
71    Eina_Bool modal : 1;
72    Eina_Bool demand_attention : 1;
73    Eina_Bool autodel : 1;
74    Eina_Bool constrain : 1;
75    Eina_Bool resizing : 1;
76    Eina_Bool iconified : 1;
77    Eina_Bool withdrawn : 1;
78    Eina_Bool sticky : 1;
79    Eina_Bool fullscreen : 1;
80    Eina_Bool maximized : 1;
81    Eina_Bool skip_focus : 1;
82 };
83
84 static const char *widtype = NULL;
85 static void _elm_win_obj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
86 static void _elm_win_obj_callback_img_obj_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
87 static void _elm_win_obj_callback_parent_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
88 static void _elm_win_obj_intercept_move(void *data, Evas_Object *obj, Evas_Coord x, Evas_Coord y);
89 static void _elm_win_obj_intercept_show(void *data, Evas_Object *obj);
90 static void _elm_win_move(Ecore_Evas *ee);
91 static void _elm_win_resize(Ecore_Evas *ee);
92 static void _elm_win_delete_request(Ecore_Evas *ee);
93 static void _elm_win_resize_job(void *data);
94 #ifdef HAVE_ELEMENTARY_X
95 static void _elm_win_xwin_update(Elm_Win *win);
96 #endif
97 static void _elm_win_eval_subobjs(Evas_Object *obj);
98 static void _elm_win_subobj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
99 static void _elm_win_subobj_callback_changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
100 static void _elm_win_focus_highlight_init(Elm_Win *win);
101 static void _elm_win_focus_highlight_shutdown(Elm_Win *win);
102 static void _elm_win_focus_highlight_visible_set(Elm_Win *win, Eina_Bool visible);
103 static void _elm_win_focus_highlight_reconfigure_job_start(Elm_Win *win);
104 static void _elm_win_focus_highlight_reconfigure_job_stop(Elm_Win *win);
105 static void _elm_win_focus_highlight_anim_end(void *data, Evas_Object *obj, const char *emission, const char *source);
106 static void _elm_win_focus_highlight_reconfigure(Elm_Win *win);
107
108 static void _elm_win_frame_add(Elm_Win *win, const char *style);
109 static void _elm_win_frame_cb_move_start(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__);
110 static void _elm_win_frame_cb_resize_start(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source);
111 static void _elm_win_frame_cb_minimize(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__);
112 static void _elm_win_frame_cb_maximize(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__);
113 static void _elm_win_frame_cb_close(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__);
114
115 //static void _elm_win_pointer_add(Elm_Win *win, const char *style);
116
117 static const char SIG_DELETE_REQUEST[] = "delete,request";
118 static const char SIG_FOCUS_OUT[] = "focus,out";
119 static const char SIG_FOCUS_IN[] = "focus,in";
120 static const char SIG_MOVED[] = "moved";
121 static const char SIG_THEME_CHANGED[] = "theme,changed";
122 static const char SIG_WITHDRAWN[] = "withdrawn";
123 static const char SIG_ICONIFIED[] = "iconified";
124 static const char SIG_NORMAL[] = "normal";
125 static const char SIG_STICK[] = "stick";
126 static const char SIG_UNSTICK[] = "unstick";
127 static const char SIG_FULLSCREEN[] = "fullscreen";
128 static const char SIG_UNFULLSCREEN[] = "unfullscreen";
129 static const char SIG_MAXIMIZED[] = "maximized";
130 static const char SIG_UNMAXIMIZED[] = "unmaximized";
131
132 static const Evas_Smart_Cb_Description _signals[] = {
133    {SIG_DELETE_REQUEST, ""},
134    {SIG_FOCUS_OUT, ""},
135    {SIG_FOCUS_IN, ""},
136    {SIG_MOVED, ""},
137    {SIG_WITHDRAWN, ""},
138    {SIG_ICONIFIED, ""},
139    {SIG_NORMAL, ""},
140    {SIG_STICK, ""},
141    {SIG_UNSTICK, ""},
142    {SIG_FULLSCREEN, ""},
143    {SIG_UNFULLSCREEN, ""},
144    {SIG_MAXIMIZED, ""},
145    {SIG_UNMAXIMIZED, ""},
146    {NULL, NULL}
147 };
148
149
150
151 Eina_List *_elm_win_list = NULL;
152 int _elm_win_deferred_free = 0;
153
154 // exmaple shot spec (wait 0.1 sec then save as my-window.png):
155 // ELM_ENGINE="shot:delay=0.1:file=my-window.png"
156
157 static double
158 _shot_delay_get(Elm_Win *win)
159 {
160    char *p, *pd;
161    char *d = strdup(win->shot.info);
162
163    if (!d) return 0.5;
164    for (p = (char *)win->shot.info; *p; p++)
165      {
166         if (!strncmp(p, "delay=", 6))
167           {
168              double v;
169
170              for (pd = d, p += 6; (*p) && (*p != ':'); p++, pd++)
171                {
172                   *pd = *p;
173                }
174              *pd = 0;
175              v = atof(d);
176              free(d);
177              return v;
178           }
179      }
180    free(d);
181    return 0.5;
182 }
183
184 static char *
185 _shot_file_get(Elm_Win *win)
186 {
187    char *p;
188    char *tmp = strdup(win->shot.info);
189    char *repname = NULL;
190
191    if (!tmp) return NULL;
192
193    for (p = (char *)win->shot.info; *p; p++)
194      {
195         if (!strncmp(p, "file=", 5))
196           {
197              strcpy(tmp, p + 5);
198              if (!win->shot.repeat_count) return tmp;
199              else
200                {
201                   char *dotptr = strrchr(tmp, '.');
202                   if (dotptr)
203                     {
204                        size_t size = sizeof(char)*(strlen(tmp) + 16);
205                        repname = malloc(size);
206                        strncpy(repname, tmp, dotptr - tmp);
207                        snprintf(repname + (dotptr - tmp), size - (dotptr - tmp), "%03i",
208                                win->shot.shot_counter + 1);
209                        strcat(repname, dotptr);
210                        free(tmp);
211                        return repname;
212                     }
213                }
214           }
215      }
216    free(tmp);
217    if (!win->shot.repeat_count) return strdup("out.png");
218
219    repname = malloc(sizeof(char) * 24);
220    snprintf(repname, sizeof(char) * 24, "out%03i.png", win->shot.shot_counter + 1);
221    return repname;
222 }
223
224 static int
225 _shot_repeat_count_get(Elm_Win *win)
226 {
227    char *p, *pd;
228    char *d = strdup(win->shot.info);
229
230    if (!d) return 0;
231    for (p = (char *)win->shot.info; *p; p++)
232      {
233         if (!strncmp(p, "repeat=", 7))
234           {
235              int v;
236
237              for (pd = d, p += 7; (*p) && (*p != ':'); p++, pd++)
238                {
239                   *pd = *p;
240                }
241              *pd = 0;
242              v = atoi(d);
243              if (v < 0) v = 0;
244              if (v > 1000) v = 999;
245              free(d);
246              return v;
247           }
248      }
249    free(d);
250    return 0;
251 }
252
253 static char *
254 _shot_key_get(Elm_Win *win __UNUSED__)
255 {
256    return NULL;
257 }
258
259 static char *
260 _shot_flags_get(Elm_Win *win __UNUSED__)
261 {
262    return NULL;
263 }
264
265 static void
266 _shot_do(Elm_Win *win)
267 {
268    Ecore_Evas *ee;
269    Evas_Object *o;
270    unsigned int *pixels;
271    int w, h;
272    char *file, *key, *flags;
273
274    ecore_evas_manual_render(win->ee);
275    pixels = (void *)ecore_evas_buffer_pixels_get(win->ee);
276    if (!pixels) return;
277    ecore_evas_geometry_get(win->ee, NULL, NULL, &w, &h);
278    if ((w < 1) || (h < 1)) return;
279    file = _shot_file_get(win);
280    if (!file) return;
281    key = _shot_key_get(win);
282    flags = _shot_flags_get(win);
283    ee = ecore_evas_buffer_new(1, 1);
284    o = evas_object_image_add(ecore_evas_get(ee));
285    evas_object_image_alpha_set(o, ecore_evas_alpha_get(win->ee));
286    evas_object_image_size_set(o, w, h);
287    evas_object_image_data_set(o, pixels);
288    if (!evas_object_image_save(o, file, key, flags))
289      {
290         ERR("Cannot save window to '%s' (key '%s', flags '%s')",
291             file, key, flags);
292      }
293    free(file);
294    if (key) free(key);
295    if (flags) free(flags);
296    ecore_evas_free(ee);
297    if (win->shot.repeat_count) win->shot.shot_counter++;
298 }
299
300 static Eina_Bool
301 _shot_delay(void *data)
302 {
303    Elm_Win *win = data;
304    _shot_do(win);
305    if (win->shot.repeat_count)
306      {
307         int remainshot = (win->shot.repeat_count - win->shot.shot_counter);
308         if (remainshot > 0) return EINA_TRUE;
309      }
310    win->shot.timer = NULL;
311    elm_exit();
312    return EINA_FALSE;
313 }
314
315 static void
316 _shot_init(Elm_Win *win)
317 {
318    if (!win->shot.info) return;
319    win->shot.repeat_count = _shot_repeat_count_get(win);
320    win->shot.shot_counter = 0;
321 }
322
323 static void
324 _shot_handle(Elm_Win *win)
325 {
326    if (!win->shot.info) return;
327    win->shot.timer = ecore_timer_add(_shot_delay_get(win), _shot_delay, win);
328 }
329
330 static void
331 _elm_win_move(Ecore_Evas *ee)
332 {
333    Evas_Object *obj = ecore_evas_object_associate_get(ee);
334    Elm_Win *win;
335    int x, y;
336
337    if (!obj) return;
338    win = elm_widget_data_get(obj);
339    if (!win) return;
340    ecore_evas_geometry_get(ee, &x, &y, NULL, NULL);
341    win->screen.x = x;
342    win->screen.y = y;
343    evas_object_smart_callback_call(win->win_obj, SIG_MOVED, NULL);
344 }
345
346 static void
347 _elm_win_resize(Ecore_Evas *ee)
348 {
349    Evas_Object *obj = ecore_evas_object_associate_get(ee);
350    Elm_Win *win;
351
352    if (!obj) return;
353    win = elm_widget_data_get(obj);
354    if (!win) return;
355    if (win->deferred_resize_job) ecore_job_del(win->deferred_resize_job);
356    win->deferred_resize_job = ecore_job_add(_elm_win_resize_job, win);
357 }
358
359 static void
360 _elm_win_mouse_in(Ecore_Evas *ee)
361 {
362    Evas_Object *obj;
363    Elm_Win *win;
364
365    if (!(obj = ecore_evas_object_associate_get(ee))) return;
366    if (!(win = elm_widget_data_get(obj))) return;
367    if (win->resizing) win->resizing = EINA_FALSE;
368 }
369
370 static void
371 _elm_win_focus_in(Ecore_Evas *ee)
372 {
373    Evas_Object *obj = ecore_evas_object_associate_get(ee);
374    Elm_Win *win;
375
376    if (!obj) return;
377    win = elm_widget_data_get(obj);
378    if (!win) return;
379    _elm_widget_top_win_focused_set(win->win_obj, EINA_TRUE);
380    if (!elm_widget_focus_order_get(obj))
381      {
382         elm_widget_focus_steal(win->win_obj);
383         win->show_count++;
384      }
385    else
386      elm_widget_focus_restore(win->win_obj);
387    evas_object_smart_callback_call(win->win_obj, SIG_FOCUS_IN, NULL);
388    win->focus_highlight.cur.visible = EINA_TRUE;
389    _elm_win_focus_highlight_reconfigure_job_start(win);
390    if (win->frame_obj)
391      {
392         edje_object_signal_emit(win->frame_obj, "elm,action,focus", "elm");
393      }
394    else if (win->img_obj)
395      {
396         /* do nothing */
397      }
398 }
399
400 static void
401 _elm_win_focus_out(Ecore_Evas *ee)
402 {
403    Evas_Object *obj = ecore_evas_object_associate_get(ee);
404    Elm_Win *win;
405
406    if (!obj) return;
407    win = elm_widget_data_get(obj);
408    if (!win) return;
409    elm_object_focus_set(win->win_obj, EINA_FALSE);
410    _elm_widget_top_win_focused_set(win->win_obj, EINA_FALSE);
411    evas_object_smart_callback_call(win->win_obj, SIG_FOCUS_OUT, NULL);
412    win->focus_highlight.cur.visible = EINA_FALSE;
413    _elm_win_focus_highlight_reconfigure_job_start(win);
414    if (win->frame_obj)
415      {
416         edje_object_signal_emit(win->frame_obj, "elm,action,unfocus", "elm");
417      }
418    else if (win->img_obj)
419      {
420         /* do nothing */
421      }
422 }
423
424 static void
425 _elm_win_state_change(Ecore_Evas *ee)
426 {
427    Evas_Object *obj;
428    Elm_Win *win;
429    Eina_Bool ch_withdrawn = EINA_FALSE;
430    Eina_Bool ch_sticky = EINA_FALSE;
431    Eina_Bool ch_iconified = EINA_FALSE;
432    Eina_Bool ch_fullscreen = EINA_FALSE;
433    Eina_Bool ch_maximized = EINA_FALSE;
434
435    if (!(obj = ecore_evas_object_associate_get(ee))) return;
436
437    if (!(win = elm_widget_data_get(obj))) return;
438
439    if (win->withdrawn != ecore_evas_withdrawn_get(win->ee))
440      {
441         win->withdrawn = ecore_evas_withdrawn_get(win->ee);
442         ch_withdrawn = EINA_TRUE;
443      }
444    if (win->sticky != ecore_evas_sticky_get(win->ee))
445      {
446         win->sticky = ecore_evas_sticky_get(win->ee);
447         ch_sticky = EINA_TRUE;
448      }
449    if (win->iconified != ecore_evas_iconified_get(win->ee))
450      {
451         win->iconified = ecore_evas_iconified_get(win->ee);
452         ch_iconified = EINA_TRUE;
453      }
454    if (win->fullscreen != ecore_evas_fullscreen_get(win->ee))
455      {
456         win->fullscreen = ecore_evas_fullscreen_get(win->ee);
457         ch_fullscreen = EINA_TRUE;
458      }
459    if (win->maximized != ecore_evas_maximized_get(win->ee))
460      {
461         win->maximized = ecore_evas_maximized_get(win->ee);
462         ch_maximized = EINA_TRUE;
463      }
464    if ((ch_withdrawn) || (ch_iconified))
465      {
466         if (win->withdrawn)
467           evas_object_smart_callback_call(win->win_obj, SIG_WITHDRAWN, NULL);
468         else if (win->iconified)
469           evas_object_smart_callback_call(win->win_obj, SIG_ICONIFIED, NULL);
470         else
471           evas_object_smart_callback_call(win->win_obj, SIG_NORMAL, NULL);
472      }
473    if (ch_sticky)
474      {
475         if (win->sticky)
476           evas_object_smart_callback_call(win->win_obj, SIG_STICK, NULL);
477         else
478           evas_object_smart_callback_call(win->win_obj, SIG_UNSTICK, NULL);
479      }
480    if (ch_fullscreen)
481      {
482         if (win->fullscreen)
483           evas_object_smart_callback_call(win->win_obj, SIG_FULLSCREEN, NULL);
484         else
485           evas_object_smart_callback_call(win->win_obj, SIG_UNFULLSCREEN, NULL);
486      }
487    if (ch_maximized)
488      {
489         if (win->maximized)
490           evas_object_smart_callback_call(win->win_obj, SIG_MAXIMIZED, NULL);
491         else
492           evas_object_smart_callback_call(win->win_obj, SIG_UNMAXIMIZED, NULL);
493      }
494 }
495
496 static Eina_Bool
497 _elm_win_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
498 {
499    Elm_Win *wd = elm_widget_data_get(obj);
500    const Eina_List *items;
501    void *(*list_data_get) (const Eina_List *list);
502
503    if (!wd)
504      return EINA_FALSE;
505
506    /* Focus chain */
507    if (wd->subobjs)
508      {
509         if (!(items = elm_widget_focus_custom_chain_get(obj)))
510           {
511              items = wd->subobjs;
512              if (!items)
513                return EINA_FALSE;
514           }
515         list_data_get = eina_list_data_get;
516
517         elm_widget_focus_list_next_get(obj, items, list_data_get, dir, next);
518
519         if (*next)
520           return EINA_TRUE;
521      }
522
523    *next = (Evas_Object *)obj;
524    return EINA_FALSE;
525 }
526
527 static void
528 _elm_win_on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
529 {
530    Elm_Win *win = elm_widget_data_get(obj);
531    if (!win) return;
532
533    if (win->img_obj)
534       evas_object_focus_set(win->img_obj, elm_widget_focus_get(obj));
535    else
536       evas_object_focus_set(obj, elm_widget_focus_get(obj));
537 }
538
539 static Eina_Bool
540 _elm_win_event_cb(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
541 {
542    if (type == EVAS_CALLBACK_KEY_DOWN)
543      {
544         Evas_Event_Key_Down *ev = event_info;
545         if (!strcmp(ev->keyname, "Tab"))
546           {
547              if (evas_key_modifier_is_set(ev->modifiers, "Shift"))
548                elm_widget_focus_cycle(obj, ELM_FOCUS_PREVIOUS);
549              else
550                elm_widget_focus_cycle(obj, ELM_FOCUS_NEXT);
551              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
552              return EINA_TRUE;
553           }
554         else if ((!strcmp(ev->keyname, "Left")) ||
555                  (!strcmp(ev->keyname, "KP_Left")))
556           {
557              //TODO : woohyun jung
558           }
559         else if ((!strcmp(ev->keyname, "Right")) ||
560                  (!strcmp(ev->keyname, "KP_Right")))
561           {
562              //TODO : woohyun jung
563           }
564         else if ((!strcmp(ev->keyname, "Up")) ||
565                  (!strcmp(ev->keyname, "KP_Up")))
566           {
567              //TODO : woohyun jung
568           }
569         else if ((!strcmp(ev->keyname, "Down")) ||
570                  (!strcmp(ev->keyname, "KP_Down")))
571           {
572              //TODO : woohyun jung
573           }
574      }
575
576    return EINA_FALSE;
577 }
578
579 static void
580 _deferred_ecore_evas_free(void *data)
581 {
582    ecore_evas_free(data);
583    _elm_win_deferred_free--;
584 }
585
586 static void
587 _elm_win_obj_callback_show(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
588 {
589    Elm_Win *win = data;
590
591    if (!win->show_count) win->show_count++;
592    if (win->shot.info) _shot_handle(win);
593 }
594
595 static void
596 _elm_win_obj_callback_hide(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
597 {
598    Elm_Win *win = data;
599
600    if (win->frame_obj)
601      {
602         evas_object_hide(win->frame_obj);
603      }
604    else if (win->img_obj)
605      {
606         evas_object_hide(win->img_obj);
607      }
608    if (win->pointer.obj)
609      {
610         evas_object_hide(win->pointer.obj);
611         ecore_evas_hide(win->pointer.ee);
612      }
613 }
614
615 static void
616 _elm_win_obj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info __UNUSED__)
617 {
618    Elm_Win *win = data;
619    Evas_Object *child, *child2 = NULL;
620
621    if (win->parent)
622      {
623         evas_object_event_callback_del_full(win->parent, EVAS_CALLBACK_DEL,
624                                             _elm_win_obj_callback_parent_del, win);
625         win->parent = NULL;
626      }
627    if (win->autodel_clear) *(win->autodel_clear) = -1;
628    _elm_win_list = eina_list_remove(_elm_win_list, win->win_obj);
629    while (win->subobjs) elm_win_resize_object_del(obj, win->subobjs->data);
630    if (win->ee)
631      {
632         ecore_evas_callback_delete_request_set(win->ee, NULL);
633         ecore_evas_callback_resize_set(win->ee, NULL);
634      }
635    if (win->deferred_resize_job) ecore_job_del(win->deferred_resize_job);
636    if (win->deferred_child_eval_job) ecore_job_del(win->deferred_child_eval_job);
637    if (win->shot.info) eina_stringshare_del(win->shot.info);
638    if (win->shot.timer) ecore_timer_del(win->shot.timer);
639    evas_object_event_callback_del_full(win->win_obj, EVAS_CALLBACK_DEL,
640                                        _elm_win_obj_callback_del, win);
641    child = evas_object_bottom_get(win->evas);
642    while (child)
643      {
644         /* if the object we see *IS* the window object (because we are
645          * faking a parent object inside the canvas), then skip it and
646          * go to the next one */
647         if (child == obj)
648           {
649              child = evas_object_above_get(child);
650              if (!child) break;
651           }
652         /* if we are using the next object above from the previous loop */
653         if (child == child2)
654           {
655              /* this object has refcounts from the previous loop */
656              child2 = evas_object_above_get(child);
657              if (child2) evas_object_ref(child2);
658              evas_object_del(child);
659              /* so unref from previous loop */
660              evas_object_unref(child);
661              child = child2;
662           }
663         else
664           {
665              /* just delete as normal (probably only first object */
666              child2 = evas_object_above_get(child);
667              if (child2) evas_object_ref(child2);
668              evas_object_del(child);
669              child = child2;
670           }
671      }
672 #ifdef HAVE_ELEMENTARY_X
673    if (win->client_message_handler)
674      ecore_event_handler_del(win->client_message_handler);
675 #endif
676    // FIXME: Why are we flushing edje on every window destroy ??
677    //   edje_file_cache_flush();
678    //   edje_collection_cache_flush();
679    //   evas_image_cache_flush(win->evas);
680    //   evas_font_cache_flush(win->evas);
681    // FIXME: we are in the del handler for the object and delete the canvas
682    // that lives under it from the handler... nasty. deferring doesn't help either
683
684    if (win->img_obj)
685      {
686         win->img_obj = NULL;
687      }
688    else
689      {
690         if (win->ee)
691           {
692              ecore_job_add(_deferred_ecore_evas_free, win->ee);
693              _elm_win_deferred_free++;
694           }
695      }
696
697    _elm_win_focus_highlight_shutdown(win);
698    eina_stringshare_del(win->focus_highlight.style);
699
700    if (win->title) eina_stringshare_del(win->title);
701    if (win->icon_name) eina_stringshare_del(win->icon_name);
702    if (win->role) eina_stringshare_del(win->role);
703    if (win->icon) evas_object_del(win->icon);
704
705    free(win);
706
707    if ((!_elm_win_list) &&
708        (elm_policy_get(ELM_POLICY_QUIT) == ELM_POLICY_QUIT_LAST_WINDOW_CLOSED))
709      {
710         edje_file_cache_flush();
711         edje_collection_cache_flush();
712         evas_image_cache_flush(e);
713         evas_font_cache_flush(e);
714         elm_exit();
715      }
716 }
717
718 static void
719 _elm_win_obj_callback_img_obj_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
720 {
721    Elm_Win *win = data;
722    if (!win->img_obj) return;
723    evas_object_event_callback_del_full
724       (win->img_obj, EVAS_CALLBACK_DEL, _elm_win_obj_callback_img_obj_del, win);
725    evas_object_del(win->img_obj);
726 }
727
728 static void
729 _elm_win_obj_callback_parent_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
730 {
731    Elm_Win *win = data;
732    if (obj == win->parent) win->parent = NULL;
733 }
734
735 static void
736 _elm_win_obj_intercept_move(void *data, Evas_Object *obj, Evas_Coord x, Evas_Coord y)
737 {
738    Elm_Win *win = data;
739
740    if (win->img_obj)
741      {
742         if ((x != win->screen.x) || (y != win->screen.y))
743           {
744              win->screen.x = x;
745              win->screen.y = y;
746              evas_object_smart_callback_call(win->win_obj, SIG_MOVED, NULL);
747           }
748      }
749    else
750      {
751         evas_object_move(obj, x, y);
752      }
753 }
754
755 static void
756 _elm_win_obj_intercept_show(void *data, Evas_Object *obj)
757 {
758    Elm_Win *win = data;
759    // this is called to make sure all smart containers have calculated their
760    // sizes BEFORE we show the window to make sure it initially appears at
761    // our desired size (ie min size is known first)
762    evas_smart_objects_calculate(evas_object_evas_get(obj));
763    if (win->frame_obj)
764      {
765         evas_object_show(win->frame_obj);
766      }
767    else if (win->img_obj)
768      {
769         evas_object_show(win->img_obj);
770      }
771    if (win->pointer.obj)
772      {
773         ecore_evas_show(win->pointer.ee);
774         evas_object_show(win->pointer.obj);
775         /* ecore_evas_wayland_pointer_set(win->pointer.ee, 10, 10); */
776      }
777    evas_object_show(obj);
778 }
779
780 static void
781 _elm_win_obj_callback_move(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
782 {
783    Elm_Win *win = data;
784
785    if (ecore_evas_override_get(win->ee))
786      {
787         Evas_Coord x, y;
788
789         evas_object_geometry_get(obj, &x, &y, NULL, NULL);
790         win->screen.x = x;
791         win->screen.y = y;
792         evas_object_smart_callback_call(win->win_obj, SIG_MOVED, NULL);
793      }
794    if (win->frame_obj)
795      {
796         Evas_Coord x, y;
797
798         evas_object_geometry_get(obj, &x, &y, NULL, NULL);
799         win->screen.x = x;
800         win->screen.y = y;
801      }
802    else if (win->img_obj)
803      {
804         Evas_Coord x, y;
805
806         evas_object_geometry_get(obj, &x, &y, NULL, NULL);
807         win->screen.x = x;
808         win->screen.y = y;
809 //        evas_object_move(win->img_obj, x, y);
810      }
811 }
812
813 static void
814 _elm_win_obj_callback_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
815 {
816    Elm_Win *win = data;
817
818    if (win->frame_obj)
819      {
820      }
821    else if (win->img_obj)
822      {
823         Evas_Coord w = 1, h = 1;
824
825         evas_object_geometry_get(obj, NULL, NULL, &w, &h);
826         if (win->constrain)
827           {
828              int sw, sh;
829              ecore_evas_screen_geometry_get(win->ee, NULL, NULL, &sw, &sh);
830              w = MIN(w, sw);
831              h = MIN(h, sh);
832           }
833         if (w < 1) w = 1;
834         if (h < 1) h = 1;
835         evas_object_image_size_set(win->img_obj, w, h);
836      }
837 }
838
839 static void
840 _elm_win_delete_request(Ecore_Evas *ee)
841 {
842    Evas_Object *obj = ecore_evas_object_associate_get(ee);
843    Elm_Win *win;
844    if (strcmp(elm_widget_type_get(obj), "win")) return;
845
846    win = elm_widget_data_get(obj);
847    if (!win) return;
848    int autodel = win->autodel;
849    win->autodel_clear = &autodel;
850    evas_object_ref(win->win_obj);
851    evas_object_smart_callback_call(win->win_obj, SIG_DELETE_REQUEST, NULL);
852    // FIXME: if above callback deletes - then the below will be invalid
853    if (autodel) evas_object_del(win->win_obj);
854    else win->autodel_clear = NULL;
855    evas_object_unref(win->win_obj);
856 }
857
858 static void
859 _elm_win_resize_job(void *data)
860 {
861    Elm_Win *win = data;
862    const Eina_List *l;
863    Evas_Object *obj;
864    int w, h;
865
866    win->deferred_resize_job = NULL;
867    ecore_evas_request_geometry_get(win->ee, NULL, NULL, &w, &h);
868    if (win->constrain)
869      {
870         int sw, sh;
871         ecore_evas_screen_geometry_get(win->ee, NULL, NULL, &sw, &sh);
872         w = MIN(w, sw);
873         h = MIN(h, sh);
874      }
875    if (win->frame_obj)
876      {
877         evas_object_resize(win->frame_obj, w, h);
878      }
879    else if (win->img_obj)
880      {
881      }
882    evas_object_resize(win->win_obj, w, h);
883    EINA_LIST_FOREACH(win->subobjs, l, obj)
884      {
885         evas_object_move(obj, 0, 0);
886         evas_object_resize(obj, w, h);
887      }
888 }
889
890 #ifdef HAVE_ELEMENTARY_X
891 static void
892 _elm_win_xwindow_get(Elm_Win *win)
893 {
894    win->xwin = 0;
895
896 #define ENGINE_COMPARE(name) (!strcmp(_elm_preferred_engine, name))
897    if (ENGINE_COMPARE(ELM_SOFTWARE_X11))
898      {
899        if (win->ee) win->xwin = ecore_evas_software_x11_window_get(win->ee);
900      }
901    else if (ENGINE_COMPARE(ELM_SOFTWARE_X11) ||
902             ENGINE_COMPARE(ELM_SOFTWARE_FB) ||
903             ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE) ||
904             ENGINE_COMPARE(ELM_SOFTWARE_SDL) ||
905             ENGINE_COMPARE(ELM_SOFTWARE_16_SDL) ||
906             ENGINE_COMPARE(ELM_OPENGL_SDL) ||
907             ENGINE_COMPARE(ELM_OPENGL_COCOA))
908      {
909      }
910    else if (ENGINE_COMPARE(ELM_SOFTWARE_16_X11))
911      {
912         if (win->ee) win->xwin = ecore_evas_software_x11_16_window_get(win->ee);
913      }
914    else if (ENGINE_COMPARE(ELM_SOFTWARE_8_X11))
915      {
916         if (win->ee) win->xwin = ecore_evas_software_x11_8_window_get(win->ee);
917      }
918 /* killed
919    else if (ENGINE_COMPARE(ELM_XRENDER_X11))
920      {
921         if (win->ee) win->xwin = ecore_evas_xrender_x11_window_get(win->ee);
922      }
923  */
924    else if (ENGINE_COMPARE(ELM_OPENGL_X11))
925      {
926         if (win->ee) win->xwin = ecore_evas_gl_x11_window_get(win->ee);
927      }
928    else if (ENGINE_COMPARE(ELM_SOFTWARE_WIN32))
929      {
930         if (win->ee) win->xwin = (long)ecore_evas_win32_window_get(win->ee);
931      }
932 #undef ENGINE_COMPARE
933 }
934 #endif
935
936 #ifdef HAVE_ELEMENTARY_X
937 static void
938 _elm_win_xwin_update(Elm_Win *win)
939 {
940    const char *s;
941
942    _elm_win_xwindow_get(win);
943    if (win->parent)
944      {
945         Elm_Win *win2;
946
947         win2 = elm_widget_data_get(win->parent);
948         if (win2)
949           {
950              if (win->xwin)
951                ecore_x_icccm_transient_for_set(win->xwin, win2->xwin);
952           }
953      }
954
955    if (!win->xwin) return; /* nothing more to do */
956
957    s = win->title;
958    if (!s) s = _elm_appname;
959    if (!s) s = "";
960    if (win->icon_name) s = win->icon_name;
961    ecore_x_icccm_icon_name_set(win->xwin, s);
962    ecore_x_netwm_icon_name_set(win->xwin, s);
963
964    s = win->role;
965    if (s) ecore_x_icccm_window_role_set(win->xwin, s);
966
967    // set window icon
968    if (win->icon)
969      {
970         void *data;
971
972         data = evas_object_image_data_get(win->icon, EINA_FALSE);
973         if (data)
974           {
975              Ecore_X_Icon ic;
976              int w = 0, h = 0, stride, x, y;
977              unsigned char *p;
978              unsigned int *p2;
979
980              evas_object_image_size_get(win->icon, &w, &h);
981              stride = evas_object_image_stride_get(win->icon);
982              if ((w > 0) && (h > 0) &&
983                  (stride >= (int)(w * sizeof(unsigned int))))
984                {
985                   ic.width = w;
986                   ic.height = h;
987                   ic.data = malloc(w * h * sizeof(unsigned int));
988
989                   if (ic.data)
990                     {
991                        p = (unsigned char *)data;
992                        p2 = (unsigned int *)ic.data;
993                        for (y = 0; y < h; y++)
994                          {
995                             for (x = 0; x < w; x++)
996                               {
997                                  *p2 = *((unsigned int *)p);
998                                  p += sizeof(unsigned int);
999                                  p2++;
1000                               }
1001                             p += (stride - (w * sizeof(unsigned int)));
1002                          }
1003                        ecore_x_netwm_icons_set(win->xwin, &ic, 1);
1004                        free(ic.data);
1005                     }
1006                }
1007              evas_object_image_data_set(win->icon, data);
1008           }
1009      }
1010
1011    switch (win->type)
1012      {
1013       case ELM_WIN_BASIC:
1014          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_NORMAL);
1015          break;
1016       case ELM_WIN_DIALOG_BASIC:
1017          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DIALOG);
1018          break;
1019       case ELM_WIN_DESKTOP:
1020          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DESKTOP);
1021          break;
1022       case ELM_WIN_DOCK:
1023          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DOCK);
1024          break;
1025       case ELM_WIN_TOOLBAR:
1026          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_TOOLBAR);
1027          break;
1028       case ELM_WIN_MENU:
1029          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_MENU);
1030          break;
1031       case ELM_WIN_UTILITY:
1032          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_UTILITY);
1033          break;
1034       case ELM_WIN_SPLASH:
1035          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_SPLASH);
1036          break;
1037       case ELM_WIN_DROPDOWN_MENU:
1038          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DROPDOWN_MENU);
1039          break;
1040       case ELM_WIN_POPUP_MENU:
1041          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_POPUP_MENU);
1042          break;
1043       case ELM_WIN_TOOLTIP:
1044          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_TOOLTIP);
1045          break;
1046       case ELM_WIN_NOTIFICATION:
1047          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_NOTIFICATION);
1048          break;
1049       case ELM_WIN_COMBO:
1050          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_COMBO);
1051          break;
1052       case ELM_WIN_DND:
1053          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DND);
1054          break;
1055       default:
1056          break;
1057      }
1058    ecore_x_e_virtual_keyboard_state_set
1059       (win->xwin, (Ecore_X_Virtual_Keyboard_State)win->kbdmode);
1060    if (win->indmode == ELM_WIN_INDICATOR_SHOW)
1061      ecore_x_e_illume_indicator_state_set
1062      (win->xwin, ECORE_X_ILLUME_INDICATOR_STATE_ON);
1063    else if (win->indmode == ELM_WIN_INDICATOR_HIDE)
1064      ecore_x_e_illume_indicator_state_set
1065      (win->xwin, ECORE_X_ILLUME_INDICATOR_STATE_OFF);
1066 }
1067 #endif
1068
1069 static void
1070 _elm_win_eval_subobjs(Evas_Object *obj)
1071 {
1072    const Eina_List *l;
1073    const Evas_Object *child;
1074
1075    Elm_Win *win = elm_widget_data_get(obj);
1076    Evas_Coord w, h, minw = -1, minh = -1, maxw = -1, maxh = -1;
1077    int xx = 1, xy = 1;
1078    double wx, wy;
1079
1080    EINA_LIST_FOREACH(win->subobjs, l, child)
1081      {
1082         evas_object_size_hint_weight_get(child, &wx, &wy);
1083         if (wx == 0.0) xx = 0;
1084         if (wy == 0.0) xy = 0;
1085
1086         evas_object_size_hint_min_get(child, &w, &h);
1087         if (w < 1) w = 1;
1088         if (h < 1) h = 1;
1089         if (w > minw) minw = w;
1090         if (h > minh) minh = h;
1091
1092         evas_object_size_hint_max_get(child, &w, &h);
1093         if (w < 1) w = -1;
1094         if (h < 1) h = -1;
1095         if (maxw == -1) maxw = w;
1096         else if ((w > 0) && (w < maxw)) maxw = w;
1097         if (maxh == -1) maxh = h;
1098         else if ((h > 0) && (h < maxh)) maxh = h;
1099      }
1100    if (!xx) maxw = minw;
1101    else maxw = 32767;
1102    if (!xy) maxh = minh;
1103    else maxh = 32767;
1104    evas_object_size_hint_min_set(obj, minw, minh);
1105    evas_object_size_hint_max_set(obj, maxw, maxh);
1106    evas_object_geometry_get(obj, NULL, NULL, &w, &h);
1107    if (w < minw) w = minw;
1108    if (h < minh) h = minh;
1109    if ((maxw >= 0) && (w > maxw)) w = maxw;
1110    if ((maxh >= 0) && (h > maxh)) h = maxh;
1111    evas_object_resize(obj, w, h);
1112 }
1113
1114 static void
1115 _elm_win_subobj_callback_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1116 {
1117    Elm_Win *win = elm_widget_data_get(data);
1118    win->subobjs = eina_list_remove(win->subobjs, obj);
1119    _elm_win_eval_subobjs(win->win_obj);
1120 }
1121
1122 static void
1123 _elm_win_subobj_callback_changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1124 {
1125    _elm_win_eval_subobjs(data);
1126 }
1127
1128 void
1129 _elm_win_shutdown(void)
1130 {
1131    while (_elm_win_list)
1132      evas_object_del(_elm_win_list->data);
1133 }
1134
1135 void
1136 _elm_win_rescale(Elm_Theme *th, Eina_Bool use_theme)
1137 {
1138    const Eina_List *l;
1139    Evas_Object *obj;
1140
1141    if (!use_theme)
1142      {
1143         EINA_LIST_FOREACH(_elm_win_list, l, obj)
1144           elm_widget_theme(obj);
1145      }
1146    else
1147      {
1148         EINA_LIST_FOREACH(_elm_win_list, l, obj)
1149           elm_widget_theme_specific(obj, th, EINA_FALSE);
1150      }
1151 }
1152
1153 void
1154 _elm_win_translate(void)
1155 {
1156    const Eina_List *l;
1157    Evas_Object *obj;
1158
1159    EINA_LIST_FOREACH(_elm_win_list, l, obj)
1160       elm_widget_translate(obj);
1161 }
1162
1163 #ifdef HAVE_ELEMENTARY_X
1164 static Eina_Bool
1165 _elm_win_client_message(void *data, int type __UNUSED__, void *event)
1166 {
1167    Elm_Win *win = data;
1168    Ecore_X_Event_Client_Message *e = event;
1169
1170    if (e->format != 32) return ECORE_CALLBACK_PASS_ON;
1171    if (e->message_type == ECORE_X_ATOM_E_COMP_FLUSH)
1172      {
1173         if ((unsigned)e->data.l[0] == win->xwin)
1174           {
1175              Evas *evas = evas_object_evas_get(win->win_obj);
1176              if (evas)
1177                {
1178                   edje_file_cache_flush();
1179                   edje_collection_cache_flush();
1180                   evas_image_cache_flush(evas);
1181                   evas_font_cache_flush(evas);
1182                }
1183           }
1184      }
1185    else if (e->message_type == ECORE_X_ATOM_E_COMP_DUMP)
1186      {
1187         if ((unsigned)e->data.l[0] == win->xwin)
1188           {
1189              Evas *evas = evas_object_evas_get(win->win_obj);
1190              if (evas)
1191                {
1192                   edje_file_cache_flush();
1193                   edje_collection_cache_flush();
1194                   evas_image_cache_flush(evas);
1195                   evas_font_cache_flush(evas);
1196                   evas_render_dump(evas);
1197                }
1198           }
1199      }
1200    return ECORE_CALLBACK_PASS_ON;
1201 }
1202 #endif
1203
1204 static void
1205 _elm_win_focus_target_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1206 {
1207    Elm_Win *win = data;
1208
1209    win->focus_highlight.geometry_changed = EINA_TRUE;
1210    _elm_win_focus_highlight_reconfigure_job_start(win);
1211 }
1212
1213 static void
1214 _elm_win_focus_target_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1215 {
1216    Elm_Win *win = data;
1217
1218    win->focus_highlight.geometry_changed = EINA_TRUE;
1219    _elm_win_focus_highlight_reconfigure_job_start(win);
1220 }
1221
1222 static void
1223 _elm_win_focus_target_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1224 {
1225    Elm_Win *win = data;
1226
1227    win->focus_highlight.cur.target = NULL;
1228
1229    _elm_win_focus_highlight_reconfigure_job_start(win);
1230 }
1231
1232 static void
1233 _elm_win_focus_target_callbacks_add(Elm_Win *win)
1234 {
1235    Evas_Object *obj = win->focus_highlight.cur.target;
1236
1237    evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE,
1238                                   _elm_win_focus_target_move, win);
1239    evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE,
1240                                   _elm_win_focus_target_resize, win);
1241    evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
1242                                   _elm_win_focus_target_del, win);
1243 }
1244
1245 static void
1246 _elm_win_focus_target_callbacks_del(Elm_Win *win)
1247 {
1248    Evas_Object *obj = win->focus_highlight.cur.target;
1249
1250    evas_object_event_callback_del_full(obj, EVAS_CALLBACK_MOVE,
1251                                        _elm_win_focus_target_move, win);
1252    evas_object_event_callback_del_full(obj, EVAS_CALLBACK_RESIZE,
1253                                        _elm_win_focus_target_resize, win);
1254    evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL,
1255                                        _elm_win_focus_target_del, win);
1256 }
1257
1258 static Evas_Object *
1259 _elm_win_focus_target_get(Evas_Object *obj)
1260 {
1261    Evas_Object *o = obj;
1262
1263    do
1264      {
1265         if (elm_widget_is(o))
1266           {
1267              if (!elm_widget_highlight_ignore_get(o))
1268                break;
1269              o = elm_widget_parent_get(o);
1270              if (!o)
1271                o = evas_object_smart_parent_get(o);
1272           }
1273         else
1274           {
1275              o = elm_widget_parent_widget_get(o);
1276              if (!o)
1277                o = evas_object_smart_parent_get(o);
1278           }
1279      }
1280    while (o);
1281
1282    return o;
1283 }
1284
1285 static void
1286 _elm_win_object_focus_in(void *data, Evas *e __UNUSED__, void *event_info)
1287 {
1288    Evas_Object *obj = event_info, *target;
1289    Elm_Win *win = data;
1290
1291    if (win->focus_highlight.cur.target == obj)
1292      return;
1293
1294    target = _elm_win_focus_target_get(obj);
1295    win->focus_highlight.cur.target = target;
1296    if (elm_widget_highlight_in_theme_get(target))
1297      win->focus_highlight.cur.handled = EINA_TRUE;
1298    else
1299      _elm_win_focus_target_callbacks_add(win);
1300
1301    _elm_win_focus_highlight_reconfigure_job_start(win);
1302 }
1303
1304 static void
1305 _elm_win_object_focus_out(void *data, Evas *e __UNUSED__, void *event_info __UNUSED__)
1306 {
1307    Elm_Win *win = data;
1308
1309    if (!win->focus_highlight.cur.target)
1310      return;
1311
1312    if (!win->focus_highlight.cur.handled)
1313      _elm_win_focus_target_callbacks_del(win);
1314    win->focus_highlight.cur.target = NULL;
1315    win->focus_highlight.cur.handled = EINA_FALSE;
1316
1317    _elm_win_focus_highlight_reconfigure_job_start(win);
1318 }
1319
1320 static void
1321 _elm_win_focus_highlight_hide(void *data __UNUSED__, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
1322 {
1323    evas_object_hide(obj);
1324 }
1325
1326 static void
1327 _elm_win_focus_highlight_init(Elm_Win *win)
1328 {
1329    evas_event_callback_add(win->evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
1330                            _elm_win_object_focus_in, win);
1331    evas_event_callback_add(win->evas,
1332                            EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
1333                            _elm_win_object_focus_out, win);
1334
1335    win->focus_highlight.cur.target = evas_focus_get(win->evas);
1336
1337    win->focus_highlight.top = edje_object_add(win->evas);
1338    win->focus_highlight.changed_theme = EINA_TRUE;
1339    edje_object_signal_callback_add(win->focus_highlight.top,
1340                                    "elm,action,focus,hide,end", "",
1341                                    _elm_win_focus_highlight_hide, NULL);
1342    edje_object_signal_callback_add(win->focus_highlight.top,
1343                                    "elm,action,focus,anim,end", "",
1344                                    _elm_win_focus_highlight_anim_end, win);
1345    _elm_win_focus_highlight_reconfigure_job_start(win);
1346 }
1347
1348 static void
1349 _elm_win_focus_highlight_shutdown(Elm_Win *win)
1350 {
1351    _elm_win_focus_highlight_reconfigure_job_stop(win);
1352    if (win->focus_highlight.cur.target)
1353      {
1354         _elm_win_focus_target_callbacks_del(win);
1355         win->focus_highlight.cur.target = NULL;
1356      }
1357    if (win->focus_highlight.top)
1358      {
1359         evas_object_del(win->focus_highlight.top);
1360         win->focus_highlight.top = NULL;
1361      }
1362
1363    evas_event_callback_del_full(win->evas,
1364                                 EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
1365                                 _elm_win_object_focus_in, win);
1366    evas_event_callback_del_full(win->evas,
1367                                 EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
1368                                 _elm_win_object_focus_out, win);
1369 }
1370
1371 static void
1372 _elm_win_focus_highlight_visible_set(Elm_Win *win, Eina_Bool visible)
1373 {
1374    Evas_Object *top;
1375
1376    top = win->focus_highlight.top;
1377    if (visible)
1378      {
1379         if (top)
1380           {
1381              evas_object_show(top);
1382              edje_object_signal_emit(top, "elm,action,focus,show", "elm");
1383           }
1384      }
1385    else
1386      {
1387         if (top)
1388           edje_object_signal_emit(top, "elm,action,focus,hide", "elm");
1389      }
1390 }
1391
1392 static void
1393 _elm_win_focus_highlight_reconfigure_job(void *data)
1394 {
1395    _elm_win_focus_highlight_reconfigure((Elm_Win *)data);
1396 }
1397
1398 static void
1399 _elm_win_focus_highlight_reconfigure_job_start(Elm_Win *win)
1400 {
1401    if (win->focus_highlight.reconf_job)
1402      ecore_job_del(win->focus_highlight.reconf_job);
1403    win->focus_highlight.reconf_job = ecore_job_add(
1404       _elm_win_focus_highlight_reconfigure_job, win);
1405 }
1406
1407 static void
1408 _elm_win_focus_highlight_reconfigure_job_stop(Elm_Win *win)
1409 {
1410    if (win->focus_highlight.reconf_job)
1411      ecore_job_del(win->focus_highlight.reconf_job);
1412    win->focus_highlight.reconf_job = NULL;
1413 }
1414
1415 static void
1416 _elm_win_focus_highlight_simple_setup(Elm_Win *win, Evas_Object *obj)
1417 {
1418    Evas_Object *clip, *target = win->focus_highlight.cur.target;
1419    Evas_Coord x, y, w, h;
1420
1421    clip = evas_object_clip_get(target);
1422    evas_object_geometry_get(target, &x, &y, &w, &h);
1423
1424    evas_object_move(obj, x, y);
1425    evas_object_resize(obj, w, h);
1426    evas_object_clip_set(obj, clip);
1427 }
1428
1429 static void
1430 _elm_win_focus_highlight_anim_setup(Elm_Win *win, Evas_Object *obj)
1431 {
1432    Evas_Coord tx, ty, tw, th;
1433    Evas_Coord w, h, px, py, pw, ph;
1434    Edje_Message_Int_Set *m;
1435    Evas_Object *previous = win->focus_highlight.prev.target;
1436    Evas_Object *target = win->focus_highlight.cur.target;
1437
1438    evas_object_geometry_get(win->win_obj, NULL, NULL, &w, &h);
1439    evas_object_geometry_get(target, &tx, &ty, &tw, &th);
1440    evas_object_geometry_get(previous, &px, &py, &pw, &ph);
1441    evas_object_move(obj, 0, 0);
1442    evas_object_resize(obj, tw, th);
1443    evas_object_clip_unset(obj);
1444
1445    m = alloca(sizeof(*m) + (sizeof(int) * 8));
1446    m->count = 8;
1447    m->val[0] = px;
1448    m->val[1] = py;
1449    m->val[2] = pw;
1450    m->val[3] = ph;
1451    m->val[4] = tx;
1452    m->val[5] = ty;
1453    m->val[6] = tw;
1454    m->val[7] = th;
1455    edje_object_message_send(obj, EDJE_MESSAGE_INT_SET, 1, m);
1456 }
1457
1458 static void
1459 _elm_win_focus_highlight_anim_end(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
1460 {
1461    Elm_Win *win = data;
1462    _elm_win_focus_highlight_simple_setup(win, obj);
1463 }
1464
1465 static void
1466 _elm_win_focus_highlight_reconfigure(Elm_Win *win)
1467 {
1468    Evas_Object *target = win->focus_highlight.cur.target;
1469    Evas_Object *previous = win->focus_highlight.prev.target;
1470    Evas_Object *top = win->focus_highlight.top;
1471    Eina_Bool visible_changed;
1472    Eina_Bool common_visible;
1473    const char *sig = NULL;
1474
1475    _elm_win_focus_highlight_reconfigure_job_stop(win);
1476
1477    visible_changed = (win->focus_highlight.cur.visible !=
1478                       win->focus_highlight.prev.visible);
1479
1480    if ((target == previous) && (!visible_changed) &&
1481        (!win->focus_highlight.geometry_changed))
1482      return;
1483
1484    if ((previous) && (win->focus_highlight.prev.handled))
1485      elm_widget_signal_emit(previous, "elm,action,focus_highlight,hide", "elm");
1486
1487    if (!target)
1488      common_visible = EINA_FALSE;
1489    else if (win->focus_highlight.cur.handled)
1490      {
1491         common_visible = EINA_FALSE;
1492         if (win->focus_highlight.cur.visible)
1493           sig = "elm,action,focus_highlight,show";
1494         else
1495           sig = "elm,action,focus_highlight,hide";
1496      }
1497    else
1498      common_visible = win->focus_highlight.cur.visible;
1499
1500    _elm_win_focus_highlight_visible_set(win, common_visible);
1501    if (sig)
1502      elm_widget_signal_emit(target, sig, "elm");
1503
1504    if ((!target) || (!common_visible) || (win->focus_highlight.cur.handled))
1505      goto the_end;
1506
1507    if (win->focus_highlight.changed_theme)
1508      {
1509         const char *str;
1510         if (win->focus_highlight.style)
1511           str = win->focus_highlight.style;
1512         else
1513           str = "default";
1514         _elm_theme_object_set(win->win_obj, top, "focus_highlight", "top",
1515                               str);
1516         win->focus_highlight.changed_theme = EINA_FALSE;
1517
1518         if (_elm_config->focus_highlight_animate)
1519           {
1520              str = edje_object_data_get(win->focus_highlight.top, "animate");
1521              win->focus_highlight.top_animate = ((str) && (!strcmp(str, "on")));
1522           }
1523      }
1524
1525    if ((win->focus_highlight.top_animate) && (previous) &&
1526        (!win->focus_highlight.prev.handled))
1527      _elm_win_focus_highlight_anim_setup(win, top);
1528    else
1529      _elm_win_focus_highlight_simple_setup(win, top);
1530    evas_object_raise(top);
1531
1532 the_end:
1533    win->focus_highlight.geometry_changed = EINA_FALSE;
1534    win->focus_highlight.prev = win->focus_highlight.cur;
1535 }
1536
1537 static void
1538 _elm_win_frame_add(Elm_Win *win, const char *style)
1539 {
1540    evas_output_framespace_set(win->evas, 0, 22, 0, 26);
1541
1542    win->frame_obj = edje_object_add(win->evas);
1543    _elm_theme_set(NULL, win->frame_obj, "border", "base", style);
1544    evas_object_is_frame_object_set(win->frame_obj, EINA_TRUE);
1545    evas_object_move(win->frame_obj, 0, 0);
1546    evas_object_resize(win->frame_obj, 1, 1);
1547
1548    edje_object_signal_callback_add(win->frame_obj, "elm,action,move,start",
1549                                    "elm", _elm_win_frame_cb_move_start, win);
1550    edje_object_signal_callback_add(win->frame_obj, "elm,action,resize,start",
1551                                    "*", _elm_win_frame_cb_resize_start, win);
1552    edje_object_signal_callback_add(win->frame_obj, "elm,action,minimize",
1553                                    "elm", _elm_win_frame_cb_minimize, win);
1554    edje_object_signal_callback_add(win->frame_obj, "elm,action,maximize",
1555                                    "elm", _elm_win_frame_cb_maximize, win);
1556    edje_object_signal_callback_add(win->frame_obj, "elm,action,close",
1557                                    "elm", _elm_win_frame_cb_close, win);
1558 }
1559
1560 static void
1561 _elm_win_frame_cb_move_start(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__)
1562 {
1563    Elm_Win *win;
1564
1565    if (!(win = data)) return;
1566    /* FIXME: Change mouse pointer */
1567
1568    /* NB: 0,0 are dummy values. Wayland handles the move by itself */
1569    ecore_evas_move(win->ee, 0, 0);
1570 }
1571
1572 static void
1573 _elm_win_frame_cb_resize_start(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source)
1574 {
1575    Elm_Win *win;
1576
1577    if (!(win = data)) return;
1578    if (win->resizing) return;
1579    win->resizing = EINA_TRUE;
1580
1581    /* FIXME: Change mouse pointer */
1582
1583    if (!strcmp(source, "elm.event.resize.t"))
1584      win->resize_location = 1;
1585    else if (!strcmp(source, "elm.event.resize.b"))
1586      win->resize_location = 2;
1587    else if (!strcmp(source, "elm.event.resize.l"))
1588      win->resize_location = 4;
1589    else if (!strcmp(source, "elm.event.resize.r"))
1590      win->resize_location = 8;
1591    else if (!strcmp(source, "elm.event.resize.tl"))
1592      win->resize_location = 5;
1593    else if (!strcmp(source, "elm.event.resize.tr"))
1594      win->resize_location = 9;
1595    else if (!strcmp(source, "elm.event.resize.bl"))
1596      win->resize_location = 6;
1597    else if (!strcmp(source, "elm.event.resize.br"))
1598      win->resize_location = 10;
1599    else
1600      win->resize_location = 0;
1601
1602    if (win->resize_location > 0)
1603      ecore_evas_wayland_resize(win->ee, win->resize_location);
1604 }
1605
1606 static void
1607 _elm_win_frame_cb_minimize(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__)
1608 {
1609    Elm_Win *win;
1610
1611    if (!(win = data)) return;
1612    win->iconified = EINA_TRUE;
1613    ecore_evas_iconified_set(win->ee, EINA_TRUE);
1614 }
1615
1616 static void
1617 _elm_win_frame_cb_maximize(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__)
1618 {
1619    Elm_Win *win;
1620
1621    if (!(win = data)) return;
1622    if (win->maximized) win->maximized = EINA_FALSE;
1623    else win->maximized = EINA_TRUE;
1624    ecore_evas_maximized_set(win->ee, win->maximized);
1625 }
1626
1627 static void
1628 _elm_win_frame_cb_close(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__)
1629 {
1630    Elm_Win *win;
1631
1632    if (!(win = data)) return;
1633    evas_object_del(win->win_obj);
1634 }
1635
1636 /*
1637 static void
1638 _elm_win_pointer_add(Elm_Win *win, const char *style)
1639 {
1640    int mw, mh;
1641
1642    return;
1643
1644    win->pointer.ee = ecore_evas_wayland_shm_new(NULL, 0, 0, 0, 32, 32, 0);
1645    ecore_evas_resize(win->pointer.ee, 32, 32);
1646
1647    win->pointer.evas = ecore_evas_get(win->ee);
1648
1649    win->pointer.obj = edje_object_add(win->pointer.evas);
1650    _elm_theme_set(NULL, win->pointer.obj, "pointer", "base", style);
1651    edje_object_size_min_calc(win->pointer.obj, &mw, &mh);
1652    evas_object_move(win->pointer.obj, 0, 0);
1653    evas_object_resize(win->pointer.obj, 32, 32);
1654    evas_object_show(win->pointer.obj);
1655 }
1656 */
1657
1658 #ifdef ELM_DEBUG
1659 static void
1660 _debug_key_down(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
1661 {
1662    Evas_Event_Key_Down *ev = event_info;
1663
1664    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1665      return;
1666
1667    if ((strcmp(ev->keyname, "F12")) ||
1668        (!evas_key_modifier_is_set(ev->modifiers, "Control")))
1669      return;
1670
1671    printf("Tree graph generated.\n");
1672    elm_object_tree_dot_dump(obj, "./dump.dot");
1673 }
1674 #endif
1675
1676 static void
1677 _win_img_hide(void        *data,
1678               Evas        *e __UNUSED__,
1679               Evas_Object *obj __UNUSED__,
1680               void        *event_info __UNUSED__)
1681 {
1682    Elm_Win *win = data;
1683
1684    elm_widget_focus_hide_handle(win->win_obj);
1685 }
1686
1687 static void
1688 _win_img_mouse_up(void        *data,
1689                   Evas        *e __UNUSED__,
1690                   Evas_Object *obj __UNUSED__,
1691                   void        *event_info)
1692 {
1693    Elm_Win *win = data;
1694    Evas_Event_Mouse_Up *ev = event_info;
1695    if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD))
1696       elm_widget_focus_mouse_up_handle(win->win_obj);
1697 }
1698
1699 static void
1700 _win_img_focus_in(void        *data,
1701                   Evas        *e __UNUSED__,
1702                   Evas_Object *obj __UNUSED__,
1703                   void        *event_info __UNUSED__)
1704 {
1705    Elm_Win *win = data;
1706    elm_widget_focus_steal(win->win_obj);
1707 }
1708
1709 static void
1710 _win_img_focus_out(void        *data,
1711                    Evas        *e __UNUSED__,
1712                    Evas_Object *obj __UNUSED__,
1713                    void        *event_info __UNUSED__)
1714 {
1715    Elm_Win *win = data;
1716    elm_widget_focused_object_clear(win->win_obj);
1717 }
1718
1719 static void
1720 _win_inlined_image_set(Elm_Win *win)
1721 {
1722    evas_object_image_alpha_set(win->img_obj, EINA_FALSE);
1723    evas_object_image_filled_set(win->img_obj, EINA_TRUE);
1724    evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_DEL,
1725                                   _elm_win_obj_callback_img_obj_del, win);
1726
1727    evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_HIDE,
1728                                   _win_img_hide, win);
1729    evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_MOUSE_UP,
1730                                   _win_img_mouse_up, win);
1731    evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_FOCUS_IN,
1732                                   _win_img_focus_in, win);
1733    evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_FOCUS_OUT,
1734                                   _win_img_focus_out, win);
1735 }
1736
1737 static void
1738 _subobj_del(Elm_Win *win, Evas_Object *obj, Evas_Object *subobj)
1739 {
1740    evas_object_event_callback_del_full(subobj,
1741                                        EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1742                                        _elm_win_subobj_callback_changed_size_hints,
1743                                        obj);
1744    evas_object_event_callback_del_full(subobj, EVAS_CALLBACK_DEL,
1745                                        _elm_win_subobj_callback_del, obj);
1746    win->subobjs = eina_list_remove(win->subobjs, subobj);
1747    _elm_win_eval_subobjs(obj);
1748 }
1749
1750 static void
1751 _elm_win_obj_icon_callback_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1752 {
1753    Elm_Win *win = data;
1754    if (win->icon == obj) win->icon = NULL;
1755 }
1756
1757 EAPI Evas_Object *
1758 elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type)
1759 {
1760    Elm_Win *win;
1761    const Eina_List *l;
1762    const char *fontpath;
1763
1764    win = ELM_NEW(Elm_Win);
1765
1766 #define FALLBACK_TRY(engine)                                            \
1767    if (!win->ee)                                                        \
1768       do {                                                              \
1769          CRITICAL(engine " engine creation failed. Trying default.");   \
1770          win->ee = ecore_evas_new(NULL, 0, 0, 1, 1, NULL);              \
1771          if (win->ee)                                                   \
1772             elm_config_preferred_engine_set(ecore_evas_engine_name_get(win->ee)); \
1773    } while (0)
1774 #define ENGINE_COMPARE(name) (_elm_preferred_engine && !strcmp(_elm_preferred_engine, name))
1775
1776    win->kbdmode = ELM_WIN_KEYBOARD_UNKNOWN;
1777    win->indmode = ELM_WIN_INDICATOR_UNKNOWN;
1778
1779    switch (type)
1780      {
1781       case ELM_WIN_INLINED_IMAGE:
1782         if (!parent) break;
1783         {
1784            Evas *e = evas_object_evas_get(parent);
1785            Ecore_Evas *ee;
1786            if (!e) break;
1787            ee = ecore_evas_ecore_evas_get(e);
1788            if (!ee) break;
1789            win->img_obj = ecore_evas_object_image_new(ee);
1790            if (!win->img_obj) break;
1791            win->ee = ecore_evas_object_ecore_evas_get(win->img_obj);
1792            if (win->ee)
1793              {
1794                 _win_inlined_image_set(win);
1795                 break;
1796              }
1797            evas_object_del(win->img_obj);
1798            win->img_obj = NULL;
1799         }
1800         break;
1801
1802       case ELM_WIN_SOCKET_IMAGE:
1803         win->ee = ecore_evas_extn_socket_new(1, 1);
1804         break;
1805
1806       default:
1807         if (ENGINE_COMPARE(ELM_SOFTWARE_X11))
1808           {
1809              win->ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
1810 #ifdef HAVE_ELEMENTARY_X
1811              win->client_message_handler = ecore_event_handler_add
1812                 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1813 #endif
1814              FALLBACK_TRY("Sofware X11");
1815           }
1816         else if (ENGINE_COMPARE(ELM_SOFTWARE_FB))
1817           {
1818              win->ee = ecore_evas_fb_new(NULL, 0, 1, 1);
1819              FALLBACK_TRY("Sofware FB");
1820           }
1821         else if (ENGINE_COMPARE(ELM_SOFTWARE_DIRECTFB))
1822           {
1823              win->ee = ecore_evas_directfb_new(NULL, 1, 0, 0, 1, 1);
1824              FALLBACK_TRY("Sofware DirectFB");
1825           }
1826         else if (ENGINE_COMPARE(ELM_SOFTWARE_16_X11))
1827           {
1828              win->ee = ecore_evas_software_x11_16_new(NULL, 0, 0, 0, 1, 1);
1829              FALLBACK_TRY("Sofware-16");
1830 #ifdef HAVE_ELEMENTARY_X
1831              win->client_message_handler = ecore_event_handler_add
1832                 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1833 #endif
1834      }
1835         else if (ENGINE_COMPARE(ELM_SOFTWARE_8_X11))
1836           {
1837              win->ee = ecore_evas_software_x11_8_new(NULL, 0, 0, 0, 1, 1);
1838              FALLBACK_TRY("Sofware-8");
1839 #ifdef HAVE_ELEMENTARY_X
1840              win->client_message_handler = ecore_event_handler_add
1841                 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1842 #endif
1843           }
1844 /* killed
1845         else if (ENGINE_COMPARE(ELM_XRENDER_X11))
1846           {
1847              win->ee = ecore_evas_xrender_x11_new(NULL, 0, 0, 0, 1, 1);
1848              FALLBACK_TRY("XRender");
1849 #ifdef HAVE_ELEMENTARY_X
1850              win->client_message_handler = ecore_event_handler_add
1851                 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1852 #endif
1853           }
1854  */
1855         else if (ENGINE_COMPARE(ELM_OPENGL_X11))
1856           {
1857              int opt[10];
1858              int opt_i = 0;
1859
1860              if (_elm_config->vsync)
1861                {
1862                   opt[opt_i] = ECORE_EVAS_GL_X11_OPT_VSYNC;
1863                   opt_i++;
1864                   opt[opt_i] = 1;
1865                   opt_i++;
1866                }
1867              if (opt_i > 0)
1868                 win->ee = ecore_evas_gl_x11_options_new(NULL, 0, 0, 0, 1, 1, opt);
1869              else
1870                 win->ee = ecore_evas_gl_x11_new(NULL, 0, 0, 0, 1, 1);
1871              FALLBACK_TRY("OpenGL");
1872 #ifdef HAVE_ELEMENTARY_X
1873              win->client_message_handler = ecore_event_handler_add
1874                 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1875 #endif
1876           }
1877         else if (ENGINE_COMPARE(ELM_SOFTWARE_WIN32))
1878           {
1879              win->ee = ecore_evas_software_gdi_new(NULL, 0, 0, 1, 1);
1880              FALLBACK_TRY("Sofware Win32");
1881           }
1882         else if (ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE))
1883           {
1884              win->ee = ecore_evas_software_wince_gdi_new(NULL, 0, 0, 1, 1);
1885              FALLBACK_TRY("Sofware-16-WinCE");
1886           }
1887         else if (ENGINE_COMPARE(ELM_SOFTWARE_PSL1GHT))
1888           {
1889              win->ee = ecore_evas_psl1ght_new(NULL, 1, 1);
1890              FALLBACK_TRY("PSL1GHT");
1891           }
1892         else if (ENGINE_COMPARE(ELM_SOFTWARE_SDL))
1893           {
1894              win->ee = ecore_evas_sdl_new(NULL, 0, 0, 0, 0, 0, 1);
1895              FALLBACK_TRY("Sofware SDL");
1896           }
1897         else if (ENGINE_COMPARE(ELM_SOFTWARE_16_SDL))
1898           {
1899              win->ee = ecore_evas_sdl16_new(NULL, 0, 0, 0, 0, 0, 1);
1900              FALLBACK_TRY("Sofware-16-SDL");
1901           }
1902         else if (ENGINE_COMPARE(ELM_OPENGL_SDL))
1903           {
1904              win->ee = ecore_evas_gl_sdl_new(NULL, 1, 1, 0, 0);
1905              FALLBACK_TRY("OpenGL SDL");
1906           }
1907         else if (ENGINE_COMPARE(ELM_OPENGL_COCOA))
1908           {
1909              win->ee = ecore_evas_cocoa_new(NULL, 1, 1, 0, 0);
1910              FALLBACK_TRY("OpenGL Cocoa");
1911           }
1912         else if (ENGINE_COMPARE(ELM_BUFFER))
1913           {
1914              win->ee = ecore_evas_buffer_new(1, 1);
1915           }
1916         else if (ENGINE_COMPARE(ELM_EWS))
1917           {
1918              win->ee = ecore_evas_ews_new(0, 0, 1, 1);
1919           }
1920         else if (ENGINE_COMPARE(ELM_WAYLAND_SHM))
1921           {
1922              win->ee = ecore_evas_wayland_shm_new(NULL, 0, 0, 0, 1, 1, 0);
1923              win->evas = ecore_evas_get(win->ee);
1924
1925              _elm_win_frame_add(win, "default");
1926 //             _elm_win_pointer_add(win, "default");
1927           }
1928         else if (ENGINE_COMPARE(ELM_WAYLAND_EGL))
1929           {
1930              win->ee = ecore_evas_wayland_egl_new(NULL, 0, 0, 0, 1, 1, 0);
1931              win->evas = ecore_evas_get(win->ee);
1932
1933              _elm_win_frame_add(win, "default");
1934 //             _elm_win_pointer_add(win, "default");
1935           }
1936         else if (!strncmp(_elm_preferred_engine, "shot:", 5))
1937           {
1938              win->ee = ecore_evas_buffer_new(1, 1);
1939              ecore_evas_manual_render_set(win->ee, EINA_TRUE);
1940              win->shot.info = eina_stringshare_add(_elm_preferred_engine + 5);
1941              _shot_init(win);
1942           }
1943 #undef FALLBACK_TRY
1944         break;
1945      }
1946
1947    if (!win->ee)
1948      {
1949         ERR("Cannot create window.");
1950         free(win);
1951         return NULL;
1952      }
1953 #ifdef HAVE_ELEMENTARY_X
1954    _elm_win_xwindow_get(win);
1955 #endif
1956    if ((_elm_config->bgpixmap) && (!_elm_config->compositing))
1957      ecore_evas_avoid_damage_set(win->ee, ECORE_EVAS_AVOID_DAMAGE_EXPOSE);
1958    // bg pixmap done by x - has other issues like can be redrawn by x before it
1959    // is filled/ready by app
1960    //     ecore_evas_avoid_damage_set(win->ee, ECORE_EVAS_AVOID_DAMAGE_BUILT_IN);
1961
1962    win->type = type;
1963    win->parent = parent;
1964    if (win->parent)
1965      evas_object_event_callback_add(win->parent, EVAS_CALLBACK_DEL,
1966                                     _elm_win_obj_callback_parent_del, win);
1967
1968    win->evas = ecore_evas_get(win->ee);
1969    win->win_obj = elm_widget_add(win->evas);
1970    elm_widget_type_set(win->win_obj, "win");
1971    ELM_SET_WIDTYPE(widtype, "win");
1972    elm_widget_data_set(win->win_obj, win);
1973    elm_widget_event_hook_set(win->win_obj, _elm_win_event_cb);
1974    elm_widget_on_focus_hook_set(win->win_obj, _elm_win_on_focus_hook, NULL);
1975    elm_widget_can_focus_set(win->win_obj, EINA_TRUE);
1976    elm_widget_highlight_ignore_set(win->win_obj, EINA_TRUE);
1977    elm_widget_focus_next_hook_set(win->win_obj, _elm_win_focus_next_hook);
1978    evas_object_color_set(win->win_obj, 0, 0, 0, 0);
1979    evas_object_move(win->win_obj, 0, 0);
1980    evas_object_resize(win->win_obj, 1, 1);
1981    evas_object_layer_set(win->win_obj, 50);
1982    evas_object_pass_events_set(win->win_obj, EINA_TRUE);
1983
1984    if (win->frame_obj)
1985      {
1986         evas_object_clip_set(win->win_obj, win->frame_obj);
1987         evas_object_stack_below(win->frame_obj, win->win_obj);
1988      }
1989
1990    if (type == ELM_WIN_INLINED_IMAGE)
1991      elm_widget_parent2_set(win->win_obj, parent);
1992    ecore_evas_object_associate(win->ee, win->win_obj,
1993                                ECORE_EVAS_OBJECT_ASSOCIATE_BASE |
1994                                ECORE_EVAS_OBJECT_ASSOCIATE_STACK |
1995                                ECORE_EVAS_OBJECT_ASSOCIATE_LAYER);
1996    evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_SHOW,
1997                                   _elm_win_obj_callback_show, win);
1998    evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_HIDE,
1999                                   _elm_win_obj_callback_hide, win);
2000    evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_DEL,
2001                                   _elm_win_obj_callback_del, win);
2002    evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_MOVE,
2003                                   _elm_win_obj_callback_move, win);
2004    evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_RESIZE,
2005                                   _elm_win_obj_callback_resize, win);
2006    if (win->img_obj)
2007      evas_object_intercept_move_callback_add(win->win_obj,
2008                                              _elm_win_obj_intercept_move, win);
2009    evas_object_intercept_show_callback_add(win->win_obj,
2010                                            _elm_win_obj_intercept_show, win);
2011
2012    evas_object_smart_callback_add(win->win_obj, "sub-object-del", (Evas_Smart_Cb)_subobj_del, win);
2013    ecore_evas_name_class_set(win->ee, name, _elm_appname);
2014    ecore_evas_callback_delete_request_set(win->ee, _elm_win_delete_request);
2015    ecore_evas_callback_resize_set(win->ee, _elm_win_resize);
2016    ecore_evas_callback_mouse_in_set(win->ee, _elm_win_mouse_in);
2017    ecore_evas_callback_focus_in_set(win->ee, _elm_win_focus_in);
2018    ecore_evas_callback_focus_out_set(win->ee, _elm_win_focus_out);
2019    ecore_evas_callback_move_set(win->ee, _elm_win_move);
2020    ecore_evas_callback_state_change_set(win->ee, _elm_win_state_change);
2021    evas_image_cache_set(win->evas, (_elm_config->image_cache * 1024));
2022    evas_font_cache_set(win->evas, (_elm_config->font_cache * 1024));
2023    EINA_LIST_FOREACH(_elm_config->font_dirs, l, fontpath)
2024      evas_font_path_append(win->evas, fontpath);
2025    if (!_elm_config->font_hinting)
2026      evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_NONE);
2027    else if (_elm_config->font_hinting == 1)
2028      evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_AUTO);
2029    else if (_elm_config->font_hinting == 2)
2030      evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_BYTECODE);
2031
2032 #ifdef HAVE_ELEMENTARY_X
2033    _elm_win_xwin_update(win);
2034 #endif
2035
2036    _elm_win_list = eina_list_append(_elm_win_list, win->win_obj);
2037
2038    if (ENGINE_COMPARE(ELM_SOFTWARE_FB))
2039      {
2040         ecore_evas_fullscreen_set(win->ee, 1);
2041      }
2042 #undef ENGINE_COMPARE
2043
2044    if (_elm_config->focus_highlight_enable)
2045      elm_win_focus_highlight_enabled_set(win->win_obj, EINA_TRUE);
2046
2047 #ifdef ELM_DEBUG
2048    Evas_Modifier_Mask mask = evas_key_modifier_mask_get(win->evas, "Control");
2049    evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_KEY_DOWN,
2050                                   _debug_key_down, win);
2051
2052    Eina_Bool ret = evas_object_key_grab(win->win_obj, "F12", mask, 0,
2053                                         EINA_TRUE);
2054    printf("Ctrl+F12 key combination exclusive for dot tree generation\n");
2055 #endif
2056
2057    evas_object_smart_callbacks_descriptions_set(win->win_obj, _signals);
2058
2059    return win->win_obj;
2060 }
2061
2062 EAPI Evas_Object *
2063 elm_win_util_standard_add(const char *name, const char *title)
2064 {
2065    Evas_Object *win, *bg;
2066
2067    win = elm_win_add(NULL, name, ELM_WIN_BASIC);
2068    if (!win) return NULL;
2069    elm_win_title_set(win, title);
2070    bg = elm_bg_add(win);
2071    if (!bg)
2072      {
2073         evas_object_del(win);
2074         return NULL;
2075      }
2076    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2077    elm_win_resize_object_add(win, bg);
2078    evas_object_show(bg);
2079    return win;
2080 }
2081
2082 EAPI void
2083 elm_win_resize_object_add(Evas_Object *obj, Evas_Object *subobj)
2084 {
2085    Evas_Coord w, h;
2086    Elm_Win *win;
2087    ELM_CHECK_WIDTYPE(obj, widtype);
2088    win = elm_widget_data_get(obj);
2089    if (!win) return;
2090    if (eina_list_data_find(win->subobjs, subobj)) return;
2091    win->subobjs = eina_list_append(win->subobjs, subobj);
2092    elm_widget_sub_object_add(obj, subobj);
2093    evas_object_event_callback_add(subobj, EVAS_CALLBACK_DEL,
2094                                   _elm_win_subobj_callback_del, obj);
2095    evas_object_event_callback_add(subobj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
2096                                   _elm_win_subobj_callback_changed_size_hints,
2097                                   obj);
2098    evas_object_geometry_get(obj, NULL, NULL, &w, &h);
2099    evas_object_move(subobj, 0, 0);
2100    evas_object_resize(subobj, w, h);
2101    _elm_win_eval_subobjs(obj);
2102 }
2103
2104 EAPI void
2105 elm_win_resize_object_del(Evas_Object *obj, Evas_Object *subobj)
2106 {
2107    Elm_Win *win;
2108    ELM_CHECK_WIDTYPE(obj, widtype);
2109    win = elm_widget_data_get(obj);
2110    if (!win) return;
2111    evas_object_event_callback_del_full(subobj,
2112                                        EVAS_CALLBACK_CHANGED_SIZE_HINTS,
2113                                        _elm_win_subobj_callback_changed_size_hints,
2114                                        obj);
2115    evas_object_event_callback_del_full(subobj, EVAS_CALLBACK_DEL,
2116                                        _elm_win_subobj_callback_del, obj);
2117    win->subobjs = eina_list_remove(win->subobjs, subobj);
2118    elm_widget_sub_object_del(obj, subobj);
2119    _elm_win_eval_subobjs(obj);
2120 }
2121
2122 EAPI void
2123 elm_win_title_set(Evas_Object *obj, const char *title)
2124 {
2125    Elm_Win *win;
2126    ELM_CHECK_WIDTYPE(obj, widtype);
2127    win = elm_widget_data_get(obj);
2128    if (!win || !title) return;
2129    eina_stringshare_replace(&(win->title), title);
2130    ecore_evas_title_set(win->ee, win->title);
2131    if (win->frame_obj)
2132      edje_object_part_text_set(win->frame_obj, "elm.text.title", win->title);
2133 }
2134
2135 EAPI const char *
2136 elm_win_title_get(const Evas_Object *obj)
2137 {
2138    Elm_Win *win;
2139    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2140    win = elm_widget_data_get(obj);
2141    if (!win) return NULL;
2142    return win->title;
2143 }
2144
2145 EAPI void
2146 elm_win_icon_name_set(Evas_Object *obj, const char *icon_name)
2147 {
2148    Elm_Win *win;
2149    ELM_CHECK_WIDTYPE(obj, widtype);
2150    win = elm_widget_data_get(obj);
2151    if (!win || !icon_name) return;
2152    eina_stringshare_replace(&(win->icon_name), icon_name);
2153 #ifdef HAVE_ELEMENTARY_X
2154    _elm_win_xwin_update(win);
2155 #endif
2156 }
2157
2158 EAPI const char *
2159 elm_win_icon_name_get(const Evas_Object *obj)
2160 {
2161    Elm_Win *win;
2162    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2163    win = elm_widget_data_get(obj);
2164    if (!win) return NULL;
2165    return win->icon_name;
2166 }
2167
2168 EAPI void
2169 elm_win_role_set(Evas_Object *obj, const char *role)
2170 {
2171    Elm_Win *win;
2172    ELM_CHECK_WIDTYPE(obj, widtype);
2173    win = elm_widget_data_get(obj);
2174    if (!win || !role) return;
2175    eina_stringshare_replace(&(win->role), role);
2176 #ifdef HAVE_ELEMENTARY_X
2177    _elm_win_xwin_update(win);
2178 #endif
2179 }
2180
2181 EAPI const char *
2182 elm_win_role_get(const Evas_Object *obj)
2183 {
2184    Elm_Win *win;
2185    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2186    win = elm_widget_data_get(obj);
2187    if (!win) return NULL;
2188    return win->role;
2189 }
2190
2191 EAPI void
2192 elm_win_icon_object_set(Evas_Object *obj, Evas_Object *icon)
2193 {
2194    Elm_Win *win;
2195    ELM_CHECK_WIDTYPE(obj, widtype);
2196    win = elm_widget_data_get(obj);
2197    if (!win) return;
2198    if (win->icon)
2199      evas_object_event_callback_del_full(win->icon, EVAS_CALLBACK_DEL,
2200                                          _elm_win_obj_icon_callback_del, win);
2201    win->icon = icon;
2202    if (win->icon)
2203      evas_object_event_callback_add(win->icon, EVAS_CALLBACK_DEL,
2204                                     _elm_win_obj_icon_callback_del, win);
2205 #ifdef HAVE_ELEMENTARY_X
2206    _elm_win_xwin_update(win);
2207 #endif
2208 }
2209
2210 EAPI const Evas_Object *
2211 elm_win_icon_object_get(const Evas_Object *obj)
2212 {
2213    Elm_Win *win;
2214    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2215    win = elm_widget_data_get(obj);
2216    if (!win) return NULL;
2217    return win->icon;
2218 }
2219
2220 EAPI void
2221 elm_win_autodel_set(Evas_Object *obj, Eina_Bool autodel)
2222 {
2223    Elm_Win *win;
2224    ELM_CHECK_WIDTYPE(obj, widtype);
2225    win = elm_widget_data_get(obj);
2226    if (!win) return;
2227    win->autodel = autodel;
2228 }
2229
2230 EAPI Eina_Bool
2231 elm_win_autodel_get(const Evas_Object *obj)
2232 {
2233    Elm_Win *win;
2234    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2235    win = elm_widget_data_get(obj);
2236    if (!win) return EINA_FALSE;
2237    return win->autodel;
2238 }
2239
2240 EAPI void
2241 elm_win_activate(Evas_Object *obj)
2242 {
2243    Elm_Win *win;
2244    ELM_CHECK_WIDTYPE(obj, widtype);
2245    win = elm_widget_data_get(obj);
2246    if (!win) return;
2247    ecore_evas_activate(win->ee);
2248 }
2249
2250 EAPI void
2251 elm_win_lower(Evas_Object *obj)
2252 {
2253    Elm_Win *win;
2254    ELM_CHECK_WIDTYPE(obj, widtype);
2255    win = elm_widget_data_get(obj);
2256    if (!win) return;
2257    ecore_evas_lower(win->ee);
2258 }
2259
2260 EAPI void
2261 elm_win_raise(Evas_Object *obj)
2262 {
2263    Elm_Win *win;
2264    ELM_CHECK_WIDTYPE(obj, widtype);
2265    win = elm_widget_data_get(obj);
2266    if (!win) return;
2267    ecore_evas_raise(win->ee);
2268 }
2269
2270 EAPI void
2271 elm_win_center(Evas_Object *obj, Eina_Bool h, Eina_Bool v)
2272 {
2273    Elm_Win *win;
2274    int win_w, win_h, screen_w, screen_h, nx, ny;
2275    ELM_CHECK_WIDTYPE(obj, widtype);
2276    win = elm_widget_data_get(obj);
2277    if (!win) return;
2278    ecore_evas_screen_geometry_get(win->ee, NULL, NULL, &screen_w, &screen_h);
2279    if ((!screen_w) || (!screen_h)) return;
2280    evas_object_geometry_get(obj, NULL, NULL, &win_w, &win_h);
2281    if ((!win_w) || (!win_h)) return;
2282    if (h) nx = win_w >= screen_w ? 0 : (screen_w / 2) - (win_w / 2);
2283    else nx = win->screen.x;
2284    if (v) ny = win_h >= screen_h ? 0 : (screen_h / 2) - (win_h / 2);
2285    else ny = win->screen.y;
2286    if (nx < 0) nx = 0;
2287    if (ny < 0) ny = 0;
2288    evas_object_move(obj, nx, ny);
2289 }
2290
2291 EAPI void
2292 elm_win_borderless_set(Evas_Object *obj, Eina_Bool borderless)
2293 {
2294    Elm_Win *win;
2295    ELM_CHECK_WIDTYPE(obj, widtype);
2296    win = elm_widget_data_get(obj);
2297    if (!win) return;
2298    ecore_evas_borderless_set(win->ee, borderless);
2299 #ifdef HAVE_ELEMENTARY_X
2300    _elm_win_xwin_update(win);
2301 #endif
2302 }
2303
2304 EAPI Eina_Bool
2305 elm_win_borderless_get(const Evas_Object *obj)
2306 {
2307    Elm_Win *win;
2308    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2309    win = elm_widget_data_get(obj);
2310    if (!win) return EINA_FALSE;
2311    return ecore_evas_borderless_get(win->ee);
2312 }
2313
2314 EAPI void
2315 elm_win_shaped_set(Evas_Object *obj, Eina_Bool shaped)
2316 {
2317    Elm_Win *win;
2318    ELM_CHECK_WIDTYPE(obj, widtype);
2319    win = elm_widget_data_get(obj);
2320    if (!win) return;
2321    ecore_evas_shaped_set(win->ee, shaped);
2322 #ifdef HAVE_ELEMENTARY_X
2323    _elm_win_xwin_update(win);
2324 #endif
2325 }
2326
2327 EAPI Eina_Bool
2328 elm_win_shaped_get(const Evas_Object *obj)
2329 {
2330    Elm_Win *win;
2331    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2332    win = elm_widget_data_get(obj);
2333    if (!win) return EINA_FALSE;
2334    return ecore_evas_shaped_get(win->ee);
2335 }
2336
2337 EAPI void
2338 elm_win_alpha_set(Evas_Object *obj, Eina_Bool alpha)
2339 {
2340    Elm_Win *win;
2341    ELM_CHECK_WIDTYPE(obj, widtype);
2342    win = elm_widget_data_get(obj);
2343    if (!win) return;
2344    if (win->frame_obj)
2345      {
2346      }
2347    else if (win->img_obj)
2348      {
2349         evas_object_image_alpha_set(win->img_obj, alpha);
2350         ecore_evas_alpha_set(win->ee, alpha);
2351      }
2352    else
2353      {
2354 #ifdef HAVE_ELEMENTARY_X
2355         if (win->xwin)
2356           {
2357              if (alpha)
2358                {
2359                   if (!_elm_config->compositing)
2360                      elm_win_shaped_set(obj, alpha);
2361                   else
2362                      ecore_evas_alpha_set(win->ee, alpha);
2363                }
2364              else
2365                 ecore_evas_alpha_set(win->ee, alpha);
2366              _elm_win_xwin_update(win);
2367           }
2368         else
2369 #endif
2370            ecore_evas_alpha_set(win->ee, alpha);
2371      }
2372 }
2373
2374 EAPI Eina_Bool
2375 elm_win_alpha_get(const Evas_Object *obj)
2376 {
2377    Elm_Win *win;
2378    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2379    win = elm_widget_data_get(obj);
2380    if (!win) return EINA_FALSE;
2381    if (win->frame_obj)
2382      {
2383      }
2384    else if (win->img_obj)
2385      {
2386         return evas_object_image_alpha_get(win->img_obj);
2387      }
2388    return ecore_evas_alpha_get(win->ee);
2389 }
2390
2391 EAPI void
2392 elm_win_override_set(Evas_Object *obj, Eina_Bool override)
2393 {
2394    Elm_Win *win;
2395    ELM_CHECK_WIDTYPE(obj, widtype);
2396    win = elm_widget_data_get(obj);
2397    if (!win) return;
2398    ecore_evas_override_set(win->ee, override);
2399 #ifdef HAVE_ELEMENTARY_X
2400    _elm_win_xwin_update(win);
2401 #endif
2402 }
2403
2404 EAPI Eina_Bool
2405 elm_win_override_get(const Evas_Object *obj)
2406 {
2407    Elm_Win *win;
2408    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2409    win = elm_widget_data_get(obj);
2410    if (!win) return EINA_FALSE;
2411    return ecore_evas_override_get(win->ee);
2412 }
2413
2414 EAPI void
2415 elm_win_fullscreen_set(Evas_Object *obj, Eina_Bool fullscreen)
2416 {
2417    Elm_Win *win;
2418    ELM_CHECK_WIDTYPE(obj, widtype);
2419    win = elm_widget_data_get(obj);
2420    if (!win) return;
2421    // YYY: handle if win->img_obj
2422 #define ENGINE_COMPARE(name) (!strcmp(_elm_preferred_engine, name))
2423    if (ENGINE_COMPARE(ELM_SOFTWARE_FB) ||
2424        ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE))
2425      {
2426         // these engines... can ONLY be fullscreen
2427         return;
2428      }
2429    else
2430      {
2431         win->fullscreen = fullscreen;
2432         ecore_evas_fullscreen_set(win->ee, fullscreen);
2433 #ifdef HAVE_ELEMENTARY_X
2434         _elm_win_xwin_update(win);
2435 #endif
2436      }
2437 #undef ENGINE_COMPARE
2438 }
2439
2440 EAPI Eina_Bool
2441 elm_win_fullscreen_get(const Evas_Object *obj)
2442 {
2443    Elm_Win *win;
2444    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2445    win = elm_widget_data_get(obj);
2446    if (!win) return EINA_FALSE;
2447 #define ENGINE_COMPARE(name) (!strcmp(_elm_preferred_engine, name))
2448    if (ENGINE_COMPARE(ELM_SOFTWARE_FB) ||
2449        ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE))
2450      {
2451         // these engines... can ONLY be fullscreen
2452         return EINA_TRUE;
2453      }
2454    else
2455      {
2456         return win->fullscreen;
2457      }
2458 #undef ENGINE_COMPARE
2459 }
2460
2461 EAPI void
2462 elm_win_maximized_set(Evas_Object *obj, Eina_Bool maximized)
2463 {
2464    Elm_Win *win;
2465    ELM_CHECK_WIDTYPE(obj, widtype);
2466    win = elm_widget_data_get(obj);
2467    if (!win) return;
2468    win->maximized = maximized;
2469    // YYY: handle if win->img_obj
2470    ecore_evas_maximized_set(win->ee, maximized);
2471 #ifdef HAVE_ELEMENTARY_X
2472    _elm_win_xwin_update(win);
2473 #endif
2474 }
2475
2476 EAPI Eina_Bool
2477 elm_win_maximized_get(const Evas_Object *obj)
2478 {
2479    Elm_Win *win;
2480    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2481    win = elm_widget_data_get(obj);
2482    if (!win) return EINA_FALSE;
2483    return win->maximized;
2484 }
2485
2486 EAPI void
2487 elm_win_iconified_set(Evas_Object *obj, Eina_Bool iconified)
2488 {
2489    Elm_Win *win;
2490    ELM_CHECK_WIDTYPE(obj, widtype);
2491    win = elm_widget_data_get(obj);
2492    if (!win) return;
2493    win->iconified = iconified;
2494    ecore_evas_iconified_set(win->ee, iconified);
2495 #ifdef HAVE_ELEMENTARY_X
2496    _elm_win_xwin_update(win);
2497 #endif
2498 }
2499
2500 EAPI Eina_Bool
2501 elm_win_iconified_get(const Evas_Object *obj)
2502 {
2503    Elm_Win *win;
2504    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2505    win = elm_widget_data_get(obj);
2506    if (!win) return EINA_FALSE;
2507    return win->iconified;
2508 }
2509
2510 EAPI void
2511 elm_win_withdrawn_set(Evas_Object *obj, Eina_Bool withdrawn)
2512 {
2513    Elm_Win *win;
2514    ELM_CHECK_WIDTYPE(obj, widtype);
2515    win = elm_widget_data_get(obj);
2516    if (!win) return;
2517    win->withdrawn = withdrawn;
2518    ecore_evas_withdrawn_set(win->ee, withdrawn);
2519 #ifdef HAVE_ELEMENTARY_X
2520    _elm_win_xwin_update(win);
2521 #endif
2522 }
2523
2524 EAPI Eina_Bool
2525 elm_win_withdrawn_get(const Evas_Object *obj)
2526 {
2527    Elm_Win *win;
2528    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2529    win = elm_widget_data_get(obj);
2530    if (!win) return EINA_FALSE;
2531    return win->withdrawn;
2532 }
2533
2534 EAPI void
2535 elm_win_urgent_set(Evas_Object *obj, Eina_Bool urgent)
2536 {
2537    Elm_Win *win;
2538    ELM_CHECK_WIDTYPE(obj, widtype);
2539    win = elm_widget_data_get(obj);
2540    if (!win) return;
2541    win->urgent = urgent;
2542    ecore_evas_urgent_set(win->ee, urgent);
2543 #ifdef HAVE_ELEMENTARY_X
2544    _elm_win_xwin_update(win);
2545 #endif
2546 }
2547
2548 EAPI Eina_Bool
2549 elm_win_urgent_get(const Evas_Object *obj)
2550 {
2551    Elm_Win *win;
2552    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2553    win = elm_widget_data_get(obj);
2554    if (!win) return EINA_FALSE;
2555    return win->urgent;
2556 }
2557
2558 EAPI void
2559 elm_win_demand_attention_set(Evas_Object *obj, Eina_Bool demand_attention)
2560 {
2561    Elm_Win *win;
2562    ELM_CHECK_WIDTYPE(obj, widtype);
2563    win = elm_widget_data_get(obj);
2564    if (!win) return;
2565    win->demand_attention = demand_attention;
2566    ecore_evas_demand_attention_set(win->ee, demand_attention);
2567 #ifdef HAVE_ELEMENTARY_X
2568    _elm_win_xwin_update(win);
2569 #endif
2570 }
2571
2572 EAPI Eina_Bool
2573 elm_win_demand_attention_get(const Evas_Object *obj)
2574 {
2575    Elm_Win *win;
2576    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2577    win = elm_widget_data_get(obj);
2578    if (!win) return EINA_FALSE;
2579    return win->demand_attention;
2580 }
2581
2582 EAPI void
2583 elm_win_modal_set(Evas_Object *obj, Eina_Bool modal)
2584 {
2585    Elm_Win *win;
2586    ELM_CHECK_WIDTYPE(obj, widtype);
2587    win = elm_widget_data_get(obj);
2588    if (!win) return;
2589    win->modal = modal;
2590    ecore_evas_modal_set(win->ee, modal);
2591 #ifdef HAVE_ELEMENTARY_X
2592    _elm_win_xwin_update(win);
2593 #endif
2594 }
2595
2596 EAPI Eina_Bool
2597 elm_win_modal_get(const Evas_Object *obj)
2598 {
2599    Elm_Win *win;
2600    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2601    win = elm_widget_data_get(obj);
2602    if (!win) return EINA_FALSE;
2603    return win->modal;
2604 }
2605
2606 EAPI void
2607 elm_win_aspect_set(Evas_Object *obj, double aspect)
2608 {
2609    Elm_Win *win;
2610    ELM_CHECK_WIDTYPE(obj, widtype);
2611    win = elm_widget_data_get(obj);
2612    if (!win) return;
2613    win->aspect = aspect;
2614    ecore_evas_aspect_set(win->ee, aspect);
2615 #ifdef HAVE_ELEMENTARY_X
2616    _elm_win_xwin_update(win);
2617 #endif
2618 }
2619
2620 EAPI double
2621 elm_win_aspect_get(const Evas_Object *obj)
2622 {
2623    Elm_Win *win;
2624    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2625    win = elm_widget_data_get(obj);
2626    if (!win) return EINA_FALSE;
2627    return win->aspect;
2628 }
2629
2630 EAPI void
2631 elm_win_layer_set(Evas_Object *obj, int layer)
2632 {
2633    Elm_Win *win;
2634    ELM_CHECK_WIDTYPE(obj, widtype);
2635    win = elm_widget_data_get(obj);
2636    if (!win) return;
2637    ecore_evas_layer_set(win->ee, layer);
2638 #ifdef HAVE_ELEMENTARY_X
2639    _elm_win_xwin_update(win);
2640 #endif
2641 }
2642
2643 EAPI int
2644 elm_win_layer_get(const Evas_Object *obj)
2645 {
2646    Elm_Win *win;
2647    ELM_CHECK_WIDTYPE(obj, widtype) -1;
2648    win = elm_widget_data_get(obj);
2649    if (!win) return -1;
2650    return ecore_evas_layer_get(win->ee);
2651 }
2652
2653 EAPI void
2654 elm_win_rotation_set(Evas_Object *obj, int rotation)
2655 {
2656    Elm_Win *win;
2657    ELM_CHECK_WIDTYPE(obj, widtype);
2658    win = elm_widget_data_get(obj);
2659    if (!win) return;
2660    if (win->rot == rotation) return;
2661    win->rot = rotation;
2662    ecore_evas_rotation_set(win->ee, rotation);
2663    evas_object_size_hint_min_set(obj, -1, -1);
2664    evas_object_size_hint_max_set(obj, -1, -1);
2665    _elm_win_eval_subobjs(obj);
2666 #ifdef HAVE_ELEMENTARY_X
2667    _elm_win_xwin_update(win);
2668 #endif
2669 }
2670
2671 EAPI void
2672 elm_win_rotation_with_resize_set(Evas_Object *obj, int rotation)
2673 {
2674    Elm_Win *win;
2675    ELM_CHECK_WIDTYPE(obj, widtype);
2676    win = elm_widget_data_get(obj);
2677    if (!win) return;
2678    if (win->rot == rotation) return;
2679    win->rot = rotation;
2680    ecore_evas_rotation_with_resize_set(win->ee, rotation);
2681    evas_object_size_hint_min_set(obj, -1, -1);
2682    evas_object_size_hint_max_set(obj, -1, -1);
2683    _elm_win_eval_subobjs(obj);
2684 #ifdef HAVE_ELEMENTARY_X
2685    _elm_win_xwin_update(win);
2686 #endif
2687 }
2688
2689 EAPI int
2690 elm_win_rotation_get(const Evas_Object *obj)
2691 {
2692    Elm_Win *win;
2693    ELM_CHECK_WIDTYPE(obj, widtype) -1;
2694    win = elm_widget_data_get(obj);
2695    if (!win) return -1;
2696    return win->rot;
2697 }
2698
2699 EAPI void
2700 elm_win_sticky_set(Evas_Object *obj, Eina_Bool sticky)
2701 {
2702    Elm_Win *win;
2703    ELM_CHECK_WIDTYPE(obj, widtype);
2704    win = elm_widget_data_get(obj);
2705    if (!win) return;
2706    win->sticky = sticky;
2707    ecore_evas_sticky_set(win->ee, sticky);
2708 #ifdef HAVE_ELEMENTARY_X
2709    _elm_win_xwin_update(win);
2710 #endif
2711 }
2712
2713 EAPI Eina_Bool
2714 elm_win_sticky_get(const Evas_Object *obj)
2715 {
2716    Elm_Win *win;
2717    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2718    win = elm_widget_data_get(obj);
2719    if (!win) return EINA_FALSE;
2720    return win->sticky;
2721 }
2722
2723 EAPI void
2724 elm_win_keyboard_mode_set(Evas_Object *obj, Elm_Win_Keyboard_Mode mode)
2725 {
2726    Elm_Win *win;
2727    ELM_CHECK_WIDTYPE(obj, widtype);
2728    win = elm_widget_data_get(obj);
2729    if (!win) return;
2730    if (mode == win->kbdmode) return;
2731 #ifdef HAVE_ELEMENTARY_X
2732    _elm_win_xwindow_get(win);
2733 #endif
2734    win->kbdmode = mode;
2735 #ifdef HAVE_ELEMENTARY_X
2736    if (win->xwin)
2737      ecore_x_e_virtual_keyboard_state_set
2738         (win->xwin, (Ecore_X_Virtual_Keyboard_State)win->kbdmode);
2739 #endif
2740 }
2741
2742 EAPI Elm_Win_Keyboard_Mode
2743 elm_win_keyboard_mode_get(const Evas_Object *obj)
2744 {
2745    Elm_Win *win;
2746    ELM_CHECK_WIDTYPE(obj, widtype) ELM_WIN_KEYBOARD_UNKNOWN;
2747    win = elm_widget_data_get(obj);
2748    if (!win) return ELM_WIN_KEYBOARD_UNKNOWN;
2749    return win->kbdmode;
2750 }
2751
2752 EAPI void
2753 elm_win_keyboard_win_set(Evas_Object *obj, Eina_Bool is_keyboard)
2754 {
2755    Elm_Win *win;
2756    ELM_CHECK_WIDTYPE(obj, widtype);
2757    win = elm_widget_data_get(obj);
2758    if (!win) return;
2759 #ifdef HAVE_ELEMENTARY_X
2760    _elm_win_xwindow_get(win);
2761    if (win->xwin)
2762      ecore_x_e_virtual_keyboard_set(win->xwin, is_keyboard);
2763 #else
2764    (void) is_keyboard;
2765 #endif
2766 }
2767
2768 EAPI Eina_Bool
2769 elm_win_keyboard_win_get(const Evas_Object *obj)
2770 {
2771    Elm_Win *win;
2772    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2773    win = elm_widget_data_get(obj);
2774    if (!win) return EINA_FALSE;
2775 #ifdef HAVE_ELEMENTARY_X
2776    _elm_win_xwindow_get(win);
2777    if (win->xwin)
2778      return ecore_x_e_virtual_keyboard_get(win->xwin);
2779 #endif
2780    return EINA_FALSE;
2781 }
2782
2783 // WRAPPER: Temperary added.
2784 EAPI void
2785 elm_win_indicator_state_set(Evas_Object *obj, Elm_Win_Indicator_Mode mode)
2786 {
2787    elm_win_indicator_mode_set(obj, mode);
2788 }
2789
2790 EAPI void
2791 elm_win_indicator_mode_set(Evas_Object *obj, Elm_Win_Indicator_Mode mode)
2792 {
2793    Elm_Win *win;
2794    ELM_CHECK_WIDTYPE(obj, widtype);
2795    win = elm_widget_data_get(obj);
2796    if (!win) return;
2797    if (mode == win->indmode) return;
2798 #ifdef HAVE_ELEMENTARY_X
2799    _elm_win_xwindow_get(win);
2800 #endif
2801    win->indmode = mode;
2802 #ifdef HAVE_ELEMENTARY_X
2803    if (win->xwin)
2804      {
2805         if (win->indmode == ELM_WIN_INDICATOR_SHOW)
2806           ecore_x_e_illume_indicator_state_set
2807           (win->xwin, ECORE_X_ILLUME_INDICATOR_STATE_ON);
2808         else if (win->indmode == ELM_WIN_INDICATOR_HIDE)
2809           ecore_x_e_illume_indicator_state_set
2810           (win->xwin, ECORE_X_ILLUME_INDICATOR_STATE_OFF);
2811      }
2812 #endif
2813 }
2814
2815 // WRAPPER: Temperary added.
2816 EAPI Elm_Win_Indicator_Mode
2817 elm_win_indicator_state_get(const Evas_Object *obj)
2818 {
2819    return elm_win_indicator_mode_get(obj);
2820 }
2821
2822 EAPI Elm_Win_Indicator_Mode
2823 elm_win_indicator_mode_get(const Evas_Object *obj)
2824 {
2825    Elm_Win *win;
2826    ELM_CHECK_WIDTYPE(obj, widtype) ELM_WIN_INDICATOR_UNKNOWN;
2827    win = elm_widget_data_get(obj);
2828    if (!win) return ELM_WIN_INDICATOR_UNKNOWN;
2829    return win->indmode;
2830 }
2831
2832 EAPI void
2833 elm_win_indicator_opacity_set(Evas_Object *obj, Elm_Win_Indicator_Opacity_Mode mode)
2834 {
2835    Elm_Win *win;
2836    ELM_CHECK_WIDTYPE(obj, widtype);
2837    win = elm_widget_data_get(obj);
2838    if (!win) return;
2839    if (mode == win->ind_o_mode) return;
2840    win->ind_o_mode = mode;
2841 #ifdef HAVE_ELEMENTARY_X
2842    _elm_win_xwindow_get(win);
2843    if (win->xwin)
2844      {
2845         if (win->ind_o_mode == ELM_WIN_INDICATOR_OPAQUE)
2846           ecore_x_e_illume_indicator_opacity_set
2847           (win->xwin, ECORE_X_ILLUME_INDICATOR_OPAQUE);
2848         else if (win->ind_o_mode == ELM_WIN_INDICATOR_TRANSLUCENT)
2849           ecore_x_e_illume_indicator_opacity_set
2850           (win->xwin, ECORE_X_ILLUME_INDICATOR_TRANSLUCENT);
2851         else if (win->ind_o_mode == ELM_WIN_INDICATOR_TRANSPARENT)
2852           ecore_x_e_illume_indicator_opacity_set
2853           (win->xwin, ECORE_X_ILLUME_INDICATOR_TRANSPARENT);
2854
2855      }
2856 #endif
2857 }
2858
2859 EAPI Elm_Win_Indicator_Opacity_Mode
2860 elm_win_indicator_opacity_get(const Evas_Object *obj)
2861 {
2862    Elm_Win *win;
2863    ELM_CHECK_WIDTYPE(obj, widtype) ELM_WIN_INDICATOR_OPACITY_UNKNOWN;
2864    win = elm_widget_data_get(obj);
2865    if (!win) return ELM_WIN_INDICATOR_OPACITY_UNKNOWN;
2866    return win->ind_o_mode;
2867 }
2868
2869 EAPI void
2870 elm_win_screen_position_get(const Evas_Object *obj, int *x, int *y)
2871 {
2872    Elm_Win *win;
2873    ELM_CHECK_WIDTYPE(obj, widtype);
2874    win = elm_widget_data_get(obj);
2875    if (!win) return;
2876    if (x) *x = win->screen.x;
2877    if (y) *y = win->screen.y;
2878 }
2879
2880 EAPI Eina_Bool
2881 elm_win_focus_get(const Evas_Object *obj)
2882 {
2883    Elm_Win *win;
2884    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2885    win = elm_widget_data_get(obj);
2886    if (!win) return EINA_FALSE;
2887    return ecore_evas_focus_get(win->ee);
2888 }
2889
2890 EAPI void
2891 elm_win_screen_constrain_set(Evas_Object *obj, Eina_Bool constrain)
2892 {
2893    Elm_Win *win;
2894    ELM_CHECK_WIDTYPE(obj, widtype);
2895    win = elm_widget_data_get(obj);
2896    if (!win) return;
2897    win->constrain = !!constrain;
2898 }
2899
2900 EAPI Eina_Bool
2901 elm_win_screen_constrain_get(Evas_Object *obj)
2902 {
2903    Elm_Win *win;
2904    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2905    win = elm_widget_data_get(obj);
2906    if (!win) return EINA_FALSE;
2907    return win->constrain;
2908 }
2909
2910 EAPI void
2911 elm_win_screen_size_get(const Evas_Object *obj, int *x, int *y, int *w, int *h)
2912 {
2913    Elm_Win *win;
2914    ELM_CHECK_WIDTYPE(obj, widtype);
2915    win = elm_widget_data_get(obj);
2916    if (!win) return;
2917    ecore_evas_screen_geometry_get(win->ee, x, y, w, h);
2918 }
2919
2920 EAPI void
2921 elm_win_conformant_set(Evas_Object *obj, Eina_Bool conformant)
2922 {
2923    Elm_Win *win;
2924    ELM_CHECK_WIDTYPE(obj, widtype);
2925    win = elm_widget_data_get(obj);
2926    if (!win) return;
2927 #ifdef HAVE_ELEMENTARY_X
2928    _elm_win_xwindow_get(win);
2929    if (win->xwin)
2930      ecore_x_e_illume_conformant_set(win->xwin, conformant);
2931 #else
2932    (void) conformant;
2933 #endif
2934 }
2935
2936 EAPI Eina_Bool
2937 elm_win_conformant_get(const Evas_Object *obj)
2938 {
2939    Elm_Win *win;
2940    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2941    win = elm_widget_data_get(obj);
2942    if (!win) return EINA_FALSE;
2943 #ifdef HAVE_ELEMENTARY_X
2944    _elm_win_xwindow_get(win);
2945    if (win->xwin)
2946      return ecore_x_e_illume_conformant_get(win->xwin);
2947 #endif
2948    return EINA_FALSE;
2949 }
2950
2951 EAPI void
2952 elm_win_quickpanel_set(Evas_Object *obj, Eina_Bool quickpanel)
2953 {
2954    Elm_Win *win;
2955    ELM_CHECK_WIDTYPE(obj, widtype);
2956    win = elm_widget_data_get(obj);
2957    if (!win) return;
2958 #ifdef HAVE_ELEMENTARY_X
2959    _elm_win_xwindow_get(win);
2960    if (win->xwin)
2961      {
2962         ecore_x_e_illume_quickpanel_set(win->xwin, quickpanel);
2963         if (quickpanel)
2964           {
2965              Ecore_X_Window_State states[2];
2966
2967              states[0] = ECORE_X_WINDOW_STATE_SKIP_TASKBAR;
2968              states[1] = ECORE_X_WINDOW_STATE_SKIP_PAGER;
2969              ecore_x_netwm_window_state_set(win->xwin, states, 2);
2970              ecore_x_icccm_hints_set(win->xwin, 0, 0, 0, 0, 0, 0, 0);
2971           }
2972      }
2973 #else
2974    (void) quickpanel;
2975 #endif
2976 }
2977
2978 EAPI Eina_Bool
2979 elm_win_quickpanel_get(const Evas_Object *obj)
2980 {
2981    Elm_Win *win;
2982    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2983    win = elm_widget_data_get(obj);
2984    if (!win) return EINA_FALSE;
2985 #ifdef HAVE_ELEMENTARY_X
2986    _elm_win_xwindow_get(win);
2987    if (win->xwin)
2988      return ecore_x_e_illume_quickpanel_get(win->xwin);
2989 #endif
2990    return EINA_FALSE;
2991 }
2992
2993 EAPI void
2994 elm_win_quickpanel_priority_major_set(Evas_Object *obj, int priority)
2995 {
2996    Elm_Win *win;
2997    ELM_CHECK_WIDTYPE(obj, widtype);
2998    win = elm_widget_data_get(obj);
2999    if (!win) return;
3000 #ifdef HAVE_ELEMENTARY_X
3001    _elm_win_xwindow_get(win);
3002    if (win->xwin)
3003      ecore_x_e_illume_quickpanel_priority_major_set(win->xwin, priority);
3004 #else
3005    (void) priority;
3006 #endif
3007 }
3008
3009 EAPI int
3010 elm_win_quickpanel_priority_major_get(const Evas_Object *obj)
3011 {
3012    Elm_Win *win;
3013    ELM_CHECK_WIDTYPE(obj, widtype) -1;
3014    win = elm_widget_data_get(obj);
3015    if (!win) return -1;
3016 #ifdef HAVE_ELEMENTARY_X
3017    _elm_win_xwindow_get(win);
3018    if (win->xwin)
3019      return ecore_x_e_illume_quickpanel_priority_major_get(win->xwin);
3020 #endif
3021    return -1;
3022 }
3023
3024 EAPI void
3025 elm_win_quickpanel_priority_minor_set(Evas_Object *obj, int priority)
3026 {
3027    Elm_Win *win;
3028    ELM_CHECK_WIDTYPE(obj, widtype);
3029    win = elm_widget_data_get(obj);
3030    if (!win) return;
3031 #ifdef HAVE_ELEMENTARY_X
3032    _elm_win_xwindow_get(win);
3033    if (win->xwin)
3034      ecore_x_e_illume_quickpanel_priority_minor_set(win->xwin, priority);
3035 #else
3036    (void) priority;
3037 #endif
3038 }
3039
3040 EAPI int
3041 elm_win_quickpanel_priority_minor_get(const Evas_Object *obj)
3042 {
3043    Elm_Win *win;
3044    ELM_CHECK_WIDTYPE(obj, widtype) -1;
3045    win = elm_widget_data_get(obj);
3046    if (!win) return -1;
3047 #ifdef HAVE_ELEMENTARY_X
3048    _elm_win_xwindow_get(win);
3049    if (win->xwin)
3050      return ecore_x_e_illume_quickpanel_priority_minor_get(win->xwin);
3051 #endif
3052    return -1;
3053 }
3054
3055 EAPI void
3056 elm_win_quickpanel_zone_set(Evas_Object *obj, int zone)
3057 {
3058    Elm_Win *win;
3059    ELM_CHECK_WIDTYPE(obj, widtype);
3060    win = elm_widget_data_get(obj);
3061    if (!win) return;
3062 #ifdef HAVE_ELEMENTARY_X
3063    _elm_win_xwindow_get(win);
3064    if (win->xwin)
3065      ecore_x_e_illume_quickpanel_zone_set(win->xwin, zone);
3066 #else
3067    (void) zone;
3068 #endif
3069 }
3070
3071 EAPI int
3072 elm_win_quickpanel_zone_get(const Evas_Object *obj)
3073 {
3074    Elm_Win *win;
3075    ELM_CHECK_WIDTYPE(obj, widtype) 0;
3076    win = elm_widget_data_get(obj);
3077    if (!win) return 0;
3078 #ifdef HAVE_ELEMENTARY_X
3079    _elm_win_xwindow_get(win);
3080    if (win->xwin)
3081      return ecore_x_e_illume_quickpanel_zone_get(win->xwin);
3082 #endif
3083    return 0;
3084 }
3085
3086 EAPI void
3087 elm_win_prop_focus_skip_set(Evas_Object *obj, Eina_Bool skip)
3088 {
3089    Elm_Win *win;
3090    ELM_CHECK_WIDTYPE(obj, widtype);
3091    win = elm_widget_data_get(obj);
3092    if (!win) return;
3093    win->skip_focus = skip;
3094    ecore_evas_focus_skip_set(win->ee, skip);
3095 }
3096
3097 EAPI void
3098 elm_win_illume_command_send(Evas_Object *obj, Elm_Illume_Command command, void *params __UNUSED__)
3099 {
3100    Elm_Win *win;
3101    ELM_CHECK_WIDTYPE(obj, widtype);
3102    win = elm_widget_data_get(obj);
3103    if (!win) return;
3104 #ifdef HAVE_ELEMENTARY_X
3105    _elm_win_xwindow_get(win);
3106    if (win->xwin)
3107      {
3108         switch (command)
3109           {
3110            case ELM_ILLUME_COMMAND_FOCUS_BACK:
3111               ecore_x_e_illume_focus_back_send(win->xwin);
3112               break;
3113            case ELM_ILLUME_COMMAND_FOCUS_FORWARD:
3114               ecore_x_e_illume_focus_forward_send(win->xwin);
3115               break;
3116            case ELM_ILLUME_COMMAND_FOCUS_HOME:
3117               ecore_x_e_illume_focus_home_send(win->xwin);
3118               break;
3119            case ELM_ILLUME_COMMAND_CLOSE:
3120               ecore_x_e_illume_close_send(win->xwin);
3121               break;
3122            default:
3123               break;
3124           }
3125      }
3126 #else
3127    (void) command;
3128 #endif
3129 }
3130
3131 EAPI Evas_Object *
3132 elm_win_inlined_image_object_get(Evas_Object *obj)
3133 {
3134    Elm_Win *win;
3135    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3136    win = elm_widget_data_get(obj);
3137    if (!win) return NULL;
3138    return win->img_obj;
3139 }
3140
3141 EAPI void
3142 elm_win_focus_highlight_enabled_set(Evas_Object *obj, Eina_Bool enabled)
3143 {
3144    Elm_Win *win;
3145
3146    ELM_CHECK_WIDTYPE(obj, widtype);
3147
3148    win = elm_widget_data_get(obj);
3149    enabled = !!enabled;
3150    if (win->focus_highlight.enabled == enabled)
3151      return;
3152
3153    win->focus_highlight.enabled = enabled;
3154
3155    if (win->focus_highlight.enabled)
3156      _elm_win_focus_highlight_init(win);
3157    else
3158      _elm_win_focus_highlight_shutdown(win);
3159 }
3160
3161 EAPI Eina_Bool
3162 elm_win_focus_highlight_enabled_get(const Evas_Object *obj)
3163 {
3164    Elm_Win *win;
3165
3166    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3167
3168    win = elm_widget_data_get(obj);
3169    return win->focus_highlight.enabled;
3170 }
3171
3172 EAPI void
3173 elm_win_focus_highlight_style_set(Evas_Object *obj, const char *style)
3174 {
3175    Elm_Win *win;
3176
3177    ELM_CHECK_WIDTYPE(obj, widtype);
3178
3179    win = elm_widget_data_get(obj);
3180    eina_stringshare_replace(&win->focus_highlight.style, style);
3181    win->focus_highlight.changed_theme = EINA_TRUE;
3182    _elm_win_focus_highlight_reconfigure_job_start(win);
3183 }
3184
3185 EAPI const char *
3186 elm_win_focus_highlight_style_get(const Evas_Object *obj)
3187 {
3188    Elm_Win *win;
3189
3190    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3191
3192    win = elm_widget_data_get(obj);
3193    return win->focus_highlight.style;
3194 }
3195
3196 typedef struct _Widget_Data Widget_Data;
3197
3198 struct _Widget_Data
3199 {
3200    Evas_Object *frm;
3201    Evas_Object *content;
3202 };
3203
3204 static void _del_hook(Evas_Object *obj);
3205 static void _theme_hook(Evas_Object *obj);
3206 static void _sizing_eval(Evas_Object *obj);
3207 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
3208 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
3209
3210 static const char *widtype2 = NULL;
3211
3212 static void
3213 _del_hook(Evas_Object *obj)
3214 {
3215    Widget_Data *wd = elm_widget_data_get(obj);
3216    if (!wd) return;
3217    free(wd);
3218 }
3219
3220 static void
3221 _theme_hook(Evas_Object *obj)
3222 {
3223    Widget_Data *wd = elm_widget_data_get(obj);
3224    _elm_theme_object_set(obj, wd->frm, "win", "inwin", elm_widget_style_get(obj));
3225    if (wd->content)
3226      edje_object_part_swallow(wd->frm, "elm.swallow.content", wd->content);
3227    _sizing_eval(obj);
3228
3229    evas_object_smart_callback_call(obj, SIG_THEME_CHANGED, NULL);
3230 }
3231
3232 static Eina_Bool
3233 _elm_inwin_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
3234 {
3235    Widget_Data *wd = elm_widget_data_get(obj);
3236
3237    if (!wd)
3238      return EINA_FALSE;
3239
3240    /* Try Focus cycle in subitem */
3241    if (wd->content)
3242      {
3243         elm_widget_focus_next_get(wd->content, dir, next);
3244         if (*next)
3245           return EINA_TRUE;
3246      }
3247
3248    *next = (Evas_Object *)obj;
3249    return EINA_FALSE;
3250 }
3251
3252 static void
3253 _elm_inwin_text_set_hook(Evas_Object *obj, const char *item, const char *text)
3254 {
3255    Widget_Data *wd = elm_widget_data_get(obj);
3256
3257    if (!wd || !item) return;
3258    edje_object_part_text_set(wd->frm, item, text);
3259    _sizing_eval(obj);
3260 }
3261
3262 static const char *
3263 _elm_inwin_text_get_hook(const Evas_Object *obj, const char *item)
3264 {
3265    Widget_Data *wd = elm_widget_data_get(obj);
3266
3267    if (!item || !wd || !wd->frm) return NULL;
3268    return edje_object_part_text_get(wd->frm, item);
3269 }
3270
3271 static void
3272 _sizing_eval(Evas_Object *obj)
3273 {
3274    Widget_Data *wd = elm_widget_data_get(obj);
3275    Evas_Coord minw = -1, minh = -1;
3276
3277    evas_object_size_hint_min_get(wd->content, &minw, &minh);
3278    edje_object_size_min_calc(wd->frm, &minw, &minh);
3279    evas_object_size_hint_min_set(obj, minw, minh);
3280    evas_object_size_hint_max_set(obj, -1, -1);
3281 }
3282
3283 static void
3284 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
3285 {
3286    _sizing_eval(data);
3287 }
3288
3289 static void
3290 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
3291 {
3292    Widget_Data *wd = elm_widget_data_get(obj);
3293    Evas_Object *sub = event_info;
3294    if (sub == wd->content)
3295      {
3296         evas_object_event_callback_del_full
3297            (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
3298         wd->content = NULL;
3299         _sizing_eval(obj);
3300      }
3301 }
3302
3303 EAPI Evas_Object *
3304 elm_win_inwin_add(Evas_Object *obj)
3305 {
3306    Evas_Object *obj2;
3307    Widget_Data *wd;
3308    Elm_Win *win;
3309
3310    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3311    win = elm_widget_data_get(obj);
3312    if (!win) return NULL;
3313    wd = ELM_NEW(Widget_Data);
3314    obj2 = elm_widget_add(win->evas);
3315    elm_widget_type_set(obj2, "inwin");
3316    ELM_SET_WIDTYPE(widtype2, "inwin");
3317    elm_widget_sub_object_add(obj, obj2);
3318    evas_object_size_hint_weight_set(obj2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3319    evas_object_size_hint_align_set(obj2, EVAS_HINT_FILL, EVAS_HINT_FILL);
3320    elm_win_resize_object_add(obj, obj2);
3321
3322    elm_widget_data_set(obj2, wd);
3323    elm_widget_del_hook_set(obj2, _del_hook);
3324    elm_widget_theme_hook_set(obj2, _theme_hook);
3325    elm_widget_focus_next_hook_set(obj2, _elm_inwin_focus_next_hook);
3326    elm_widget_text_set_hook_set(obj2, _elm_inwin_text_set_hook);
3327    elm_widget_text_get_hook_set(obj2, _elm_inwin_text_get_hook);
3328    elm_widget_can_focus_set(obj2, EINA_TRUE);
3329    elm_widget_highlight_ignore_set(obj2, EINA_TRUE);
3330
3331    wd->frm = edje_object_add(win->evas);
3332    _elm_theme_object_set(obj, wd->frm, "win", "inwin", "default");
3333    elm_widget_resize_object_set(obj2, wd->frm);
3334
3335    evas_object_smart_callback_add(obj2, "sub-object-del", _sub_del, obj2);
3336
3337    _sizing_eval(obj2);
3338    return obj2;
3339 }
3340
3341 EAPI void
3342 elm_win_inwin_activate(Evas_Object *obj)
3343 {
3344    ELM_CHECK_WIDTYPE(obj, widtype2);
3345    Widget_Data *wd = elm_widget_data_get(obj);
3346    if (!wd) return;
3347    evas_object_raise(obj);
3348    evas_object_show(obj);
3349    edje_object_signal_emit(wd->frm, "elm,action,show", "elm");
3350    elm_object_focus_set(obj, EINA_TRUE);
3351 }
3352
3353 EAPI void
3354 elm_win_inwin_content_set(Evas_Object *obj, Evas_Object *content)
3355 {
3356    ELM_CHECK_WIDTYPE(obj, widtype2);
3357    Widget_Data *wd = elm_widget_data_get(obj);
3358    if (!wd) return;
3359    if (wd->content == content) return;
3360    if (wd->content) evas_object_del(wd->content);
3361    wd->content = content;
3362    if (content)
3363      {
3364         elm_widget_sub_object_add(obj, content);
3365         evas_object_event_callback_add(content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
3366                                        _changed_size_hints, obj);
3367         edje_object_part_swallow(wd->frm, "elm.swallow.content", content);
3368      }
3369    _sizing_eval(obj);
3370 }
3371
3372 EAPI Evas_Object *
3373 elm_win_inwin_content_get(const Evas_Object *obj)
3374 {
3375    ELM_CHECK_WIDTYPE(obj, widtype2) NULL;
3376    Widget_Data *wd = elm_widget_data_get(obj);
3377    if (!wd) return NULL;
3378    return wd->content;
3379 }
3380
3381 EAPI Evas_Object *
3382 elm_win_inwin_content_unset(Evas_Object *obj)
3383 {
3384    ELM_CHECK_WIDTYPE(obj, widtype2) NULL;
3385    Widget_Data *wd = elm_widget_data_get(obj);
3386    if (!wd) return NULL;
3387    if (!wd->content) return NULL;
3388    Evas_Object *content = wd->content;
3389    elm_widget_sub_object_del(obj, wd->content);
3390    evas_object_event_callback_del_full(wd->content,
3391                                        EVAS_CALLBACK_CHANGED_SIZE_HINTS,
3392                                        _changed_size_hints, obj);
3393    edje_object_part_unswallow(wd->frm, wd->content);
3394    wd->content = NULL;
3395    return content;
3396 }
3397
3398 EAPI Eina_Bool
3399 elm_win_socket_listen(Evas_Object *obj, const char *svcname, int svcnum, Eina_Bool svcsys)
3400 {
3401
3402    Elm_Win *win;
3403
3404    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3405    win = elm_widget_data_get(obj);
3406    if (!win) return EINA_FALSE;
3407    if (!win->ee) return EINA_FALSE;
3408
3409    if (!ecore_evas_extn_socket_listen(win->ee, svcname, svcnum, svcsys))
3410      return EINA_FALSE;
3411
3412    return EINA_TRUE;
3413 }
3414
3415 /* windowing specific calls - shall we do this differently? */
3416
3417 static Ecore_X_Window
3418 _elm_ee_win_get(const Evas_Object *obj)
3419 {
3420    if (!obj) return 0;
3421 #ifdef HAVE_ELEMENTARY_X
3422    Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
3423    if (ee) return (Ecore_X_Window)ecore_evas_window_get(ee);
3424 #endif
3425    return 0;
3426 }
3427
3428 EAPI Ecore_X_Window
3429 elm_win_xwindow_get(const Evas_Object *obj)
3430 {
3431    Elm_Win *win;
3432    const char *type;
3433
3434    if (!obj) return 0;
3435    type = elm_widget_type_get(obj);
3436    if ((!type) || (type != widtype)) return _elm_ee_win_get(obj);
3437    win = elm_widget_data_get(obj);
3438    if (!win) return 0;
3439 #ifdef HAVE_ELEMENTARY_X
3440    if (win->xwin) return win->xwin;
3441    if (win->parent) return elm_win_xwindow_get(win->parent);
3442 #endif
3443    return 0;
3444 }