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