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