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