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