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