[focus] When an object has focus_chain manager, it should return its own next object...
[framework/uifw/elementary.git] / src / lib / elm_win.c
1 #include <Elementary.h>
2 #include <Elementary_Cursor.h>
3 #include "elm_priv.h"
4
5 static const char WIN_SMART_NAME[] = "elm_win";
6
7 static const Elm_Win_Trap *trap = NULL;
8
9 #define TRAP(sd, name, ...)                                             \
10   do                                                                    \
11     {                                                                   \
12        if ((!trap) || (!trap->name) ||                                  \
13            ((trap->name) &&                                             \
14             (trap->name(sd->trap_data, sd->base.obj, ## __VA_ARGS__)))) \
15          ecore_evas_##name(sd->ee, ##__VA_ARGS__);                      \
16     }                                                                   \
17   while (0)
18
19 #define ELM_WIN_DATA_GET(o, sd) \
20   Elm_Win_Smart_Data * sd = evas_object_smart_data_get(o)
21
22 #define ELM_WIN_DATA_GET_OR_RETURN(o, ptr)           \
23   ELM_WIN_DATA_GET(o, ptr);                          \
24   if (!ptr)                                          \
25     {                                                \
26        CRITICAL("No widget data for object %p (%s)", \
27                 o, evas_object_type_get(o));         \
28        return;                                       \
29     }
30
31 #define ELM_WIN_DATA_GET_OR_RETURN_VAL(o, ptr, val)  \
32   ELM_WIN_DATA_GET(o, ptr);                          \
33   if (!ptr)                                          \
34     {                                                \
35        CRITICAL("No widget data for object %p (%s)", \
36                 o, evas_object_type_get(o));         \
37        return val;                                   \
38     }
39
40 #define ELM_WIN_CHECK(obj)                                             \
41   if (!obj || !elm_widget_type_check((obj), WIN_SMART_NAME, __func__)) \
42     return
43
44 #define ENGINE_GET() (_elm_preferred_engine ? _elm_preferred_engine : (_elm_config->engine ? _elm_config->engine : ""))
45 #define ENGINE_COMPARE(name) (!strcmp(ENGINE_GET(), name))
46 #define EE_ENGINE_COMPARE(ee, name) (!strcmp(ecore_evas_engine_name_get(ee), name))
47
48 typedef struct _Elm_Win_Smart_Data Elm_Win_Smart_Data;
49
50 struct _Elm_Win_Smart_Data
51 {
52    Elm_Widget_Smart_Data base; /* base widget smart data as
53                                 * first member obligatory, as
54                                 * we're inheriting from it */
55
56    Ecore_Evas           *ee;
57    Evas                 *evas;
58    Evas_Object          *parent; /* parent *window* object*/
59    Evas_Object          *img_obj, *frame_obj;
60    Eina_List            *resize_objs; /* a window may have
61                                        * *multiple* resize
62                                        * objects */
63 #ifdef HAVE_ELEMENTARY_X
64    struct
65    {
66       Ecore_X_Window       xwin;
67       Ecore_Event_Handler *client_message_handler;
68       Ecore_Event_Handler *property_handler;
69    } x;
70 #endif
71 #ifdef HAVE_ELEMENTARY_WAYLAND
72    struct
73    {
74       Ecore_Wl_Window *win;
75    } wl;
76 #endif
77
78    Ecore_Job                     *deferred_resize_job;
79    Ecore_Job                     *deferred_child_eval_job;
80
81    Elm_Win_Type                   type;
82    Elm_Win_Keyboard_Mode          kbdmode;
83    Elm_Win_Indicator_Mode         indmode;
84    Elm_Win_Indicator_Opacity_Mode ind_o_mode;
85    Elm_Win_Indicator_Type_Mode ind_t_mode;
86    struct
87    {
88       const char  *info;
89       Ecore_Timer *timer;
90       int          repeat_count;
91       int          shot_counter;
92    } shot;
93    int                            resize_location;
94    int                           *autodel_clear, rot;
95    struct
96    {
97       int x, y;
98    } screen;
99    struct
100    {
101       Ecore_Evas  *ee;
102       Evas        *evas;
103       Evas_Object *obj, *hot_obj;
104       int          hot_x, hot_y;
105    } pointer;
106    struct
107    {
108       Evas_Object *top;
109
110       struct
111       {
112          Evas_Object *target;
113          Eina_Bool    visible : 1;
114          Eina_Bool    handled : 1;
115       } cur, prev;
116
117       const char  *style;
118       Ecore_Job   *reconf_job;
119
120       Eina_Bool    enabled : 1;
121       Eina_Bool    changed_theme : 1;
122       Eina_Bool    top_animate : 1;
123       Eina_Bool    geometry_changed : 1;
124    } focus_highlight;
125    struct
126    {
127       const char  *name;
128       Ecore_Timer *timer;
129       Eina_List   *names;
130    } profile;
131    struct
132    {
133       int          preferred_rot; // specified by app
134       int         *rots;          // available rotations
135       unsigned int count;         // number of elements in available rotations
136       Eina_Bool    wm_supported : 1;
137       Eina_Bool    use : 1;
138    } wm_rot;
139
140    Evas_Object *icon;
141    const char  *title;
142    const char  *icon_name;
143    const char  *role;
144
145    void *trap_data;
146
147    double       aspect;
148    int          size_base_w, size_base_h;
149    int          size_step_w, size_step_h;
150    int          norender;
151    Eina_Bool    urgent : 1;
152    Eina_Bool    modal : 1;
153    Eina_Bool    demand_attention : 1;
154    Eina_Bool    autodel : 1;
155    Eina_Bool    constrain : 1;
156    Eina_Bool    resizing : 1;
157    Eina_Bool    iconified : 1;
158    Eina_Bool    withdrawn : 1;
159    Eina_Bool    sticky : 1;
160    Eina_Bool    fullscreen : 1;
161    Eina_Bool    maximized : 1;
162    Eina_Bool    skip_focus : 1;
163    Eina_Bool    floating : 1;
164 };
165
166 static const char SIG_DELETE_REQUEST[] = "delete,request";
167 static const char SIG_FOCUS_OUT[] = "focus,out";
168 static const char SIG_FOCUS_IN[] = "focus,in";
169 static const char SIG_MOVED[] = "moved";
170 static const char SIG_WITHDRAWN[] = "withdrawn";
171 static const char SIG_ICONIFIED[] = "iconified";
172 static const char SIG_NORMAL[] = "normal";
173 static const char SIG_STICK[] = "stick";
174 static const char SIG_UNSTICK[] = "unstick";
175 static const char SIG_FULLSCREEN[] = "fullscreen";
176 static const char SIG_UNFULLSCREEN[] = "unfullscreen";
177 static const char SIG_MAXIMIZED[] = "maximized";
178 static const char SIG_UNMAXIMIZED[] = "unmaximized";
179 static const char SIG_IOERR[] = "ioerr";
180 static const char SIG_INDICATOR_PROP_CHANGED[] = "indicator,prop,changed";
181 static const char SIG_ROTATION_CHANGED[] = "rotation,changed";
182 static const char SIG_PROFILE_CHANGED[] = "profile,changed";
183 static const char SIG_WM_ROTATION_CHANGED[] = "wm,rotation,changed";
184
185 static const Evas_Smart_Cb_Description _smart_callbacks[] = {
186    {SIG_DELETE_REQUEST, ""},
187    {SIG_FOCUS_OUT, ""},
188    {SIG_FOCUS_IN, ""},
189    {SIG_MOVED, ""},
190    {SIG_WITHDRAWN, ""},
191    {SIG_ICONIFIED, ""},
192    {SIG_NORMAL, ""},
193    {SIG_STICK, ""},
194    {SIG_UNSTICK, ""},
195    {SIG_FULLSCREEN, ""},
196    {SIG_UNFULLSCREEN, ""},
197    {SIG_MAXIMIZED, ""},
198    {SIG_UNMAXIMIZED, ""},
199    {SIG_IOERR, ""},
200    {SIG_INDICATOR_PROP_CHANGED, ""},
201    {SIG_ROTATION_CHANGED, ""},
202    {SIG_PROFILE_CHANGED, ""},
203    {SIG_WM_ROTATION_CHANGED, ""},
204    {NULL, NULL}
205 };
206
207 EVAS_SMART_SUBCLASS_NEW
208   (WIN_SMART_NAME, _elm_win, Elm_Widget_Smart_Class,
209   Elm_Widget_Smart_Class, elm_widget_smart_class_get, _smart_callbacks);
210
211 Eina_List *_elm_win_list = NULL;
212 int _elm_win_deferred_free = 0;
213
214 static int _elm_win_count = 0;
215
216 static Eina_Bool _elm_win_auto_throttled = EINA_FALSE;
217
218 static Ecore_Job *_elm_win_state_eval_job = NULL;
219
220 static void _elm_win_resize_objects_eval(Evas_Object *obj);
221
222 #ifdef HAVE_ELEMENTARY_X
223 static void _elm_win_xwin_update(Elm_Win_Smart_Data *sd);
224 static void _elm_win_xwin_type_set(Elm_Win_Smart_Data *sd);
225 #endif
226
227 static void
228 _elm_win_obj_intercept_show(void *data, Evas_Object *obj)
229 {
230    Elm_Win_Smart_Data *sd = data;
231    // this is called to make sure all smart containers have calculated their
232    // sizes BEFORE we show the window to make sure it initially appears at
233    // our desired size (ie min size is known first)
234    evas_smart_objects_calculate(evas_object_evas_get(obj));
235    if (sd->frame_obj)
236      {
237         evas_object_show(sd->frame_obj);
238      }
239    else if (sd->img_obj)
240      {
241         evas_object_show(sd->img_obj);
242      }
243    if (sd->pointer.obj)
244      {
245         ecore_evas_show(sd->pointer.ee);
246         evas_object_show(sd->pointer.obj);
247         /* ecore_evas_wayland_pointer_set(win->pointer.ee, 10, 10); */
248      }
249    evas_object_show(obj);
250 }
251
252
253 static void
254 _elm_win_state_eval(void *data __UNUSED__)
255 {
256    Eina_List *l;
257    Evas_Object *obj;
258    int _elm_win_count_shown = 0;
259    int _elm_win_count_iconified = 0;
260    int _elm_win_count_withdrawn = 0;
261
262    _elm_win_state_eval_job = NULL;
263
264    if (_elm_config->auto_norender_withdrawn)
265      {
266         EINA_LIST_FOREACH(_elm_win_list, l, obj)
267           {
268              if ((elm_win_withdrawn_get(obj)) ||
269                  ((elm_win_iconified_get(obj) &&
270                    (_elm_config->auto_norender_iconified_same_as_withdrawn))))
271                {
272                   if (!evas_object_data_get(obj, "__win_auto_norender"))
273                     {
274                        Evas *evas = evas_object_evas_get(obj);
275
276                        elm_win_norender_push(obj);
277                        evas_object_data_set(obj, "__win_auto_norender", obj);
278
279                        if (_elm_config->auto_flush_withdrawn)
280                          {
281                             edje_file_cache_flush();
282                             edje_collection_cache_flush();
283                             evas_image_cache_flush(evas);
284                             evas_font_cache_flush(evas);
285                          }
286                        if (_elm_config->auto_dump_withdrawn)
287                          {
288                             evas_render_dump(evas);
289                          }
290                     }
291                }
292              else
293                {
294                   if (evas_object_data_get(obj, "__win_auto_norender"))
295                     {
296                        elm_win_norender_pop(obj);
297                        evas_object_data_del(obj, "__win_auto_norender");
298                     }
299                }
300           }
301      }
302    if (_elm_config->auto_throttle)
303      {
304         if (_elm_win_count == 0)
305           {
306              if (_elm_win_auto_throttled)
307                {
308                   ecore_throttle_adjust(-_elm_config->auto_throttle_amount);
309                   _elm_win_auto_throttled = EINA_FALSE;
310                }
311           }
312         else
313           {
314              EINA_LIST_FOREACH(_elm_win_list, l, obj)
315                {
316                   if (elm_win_withdrawn_get(obj))
317                     _elm_win_count_withdrawn++;
318                   else if (elm_win_iconified_get(obj))
319                     _elm_win_count_iconified++;
320                   else if (evas_object_visible_get(obj))
321                     _elm_win_count_shown++;
322                }
323              if (_elm_win_count_shown <= 0)
324                {
325                   if (!_elm_win_auto_throttled)
326                     {
327                        ecore_throttle_adjust(_elm_config->auto_throttle_amount);
328                        _elm_win_auto_throttled = EINA_TRUE;
329                     }
330                }
331              else
332                {
333                   if (_elm_win_auto_throttled)
334                     {
335                        ecore_throttle_adjust(-_elm_config->auto_throttle_amount);
336                        _elm_win_auto_throttled = EINA_FALSE;
337                     }
338                }
339           }
340      }
341 }
342
343 static void
344 _elm_win_state_eval_queue(void)
345 {
346    if (_elm_win_state_eval_job) ecore_job_del(_elm_win_state_eval_job);
347    _elm_win_state_eval_job = ecore_job_add(_elm_win_state_eval, NULL);
348 }
349
350 // example shot spec (wait 0.1 sec then save as my-window.png):
351 // ELM_ENGINE="shot:delay=0.1:file=my-window.png"
352
353 static double
354 _shot_delay_get(Elm_Win_Smart_Data *sd)
355 {
356    char *p, *pd;
357    char *d = strdup(sd->shot.info);
358
359    if (!d) return 0.5;
360    for (p = (char *)sd->shot.info; *p; p++)
361      {
362         if (!strncmp(p, "delay=", 6))
363           {
364              double v;
365
366              for (pd = d, p += 6; (*p) && (*p != ':'); p++, pd++)
367                {
368                   *pd = *p;
369                }
370              *pd = 0;
371              v = _elm_atof(d);
372              free(d);
373              return v;
374           }
375      }
376    free(d);
377
378    return 0.5;
379 }
380
381 static char *
382 _shot_file_get(Elm_Win_Smart_Data *sd)
383 {
384    char *p;
385    char *tmp = strdup(sd->shot.info);
386    char *repname = NULL;
387
388    if (!tmp) return NULL;
389
390    for (p = (char *)sd->shot.info; *p; p++)
391      {
392         if (!strncmp(p, "file=", 5))
393           {
394              strcpy(tmp, p + 5);
395              if (!sd->shot.repeat_count) return tmp;
396              else
397                {
398                   char *dotptr = strrchr(tmp, '.');
399                   if (dotptr)
400                     {
401                        size_t size = sizeof(char) * (strlen(tmp) + 16);
402                        repname = malloc(size);
403                        strncpy(repname, tmp, dotptr - tmp);
404                        snprintf(repname + (dotptr - tmp), size -
405                                 (dotptr - tmp), "%03i",
406                                 sd->shot.shot_counter + 1);
407                        strcat(repname, dotptr);
408                        free(tmp);
409                        return repname;
410                     }
411                }
412           }
413      }
414    free(tmp);
415    if (!sd->shot.repeat_count) return strdup("out.png");
416
417    repname = malloc(sizeof(char) * 24);
418    snprintf(repname, sizeof(char) * 24, "out%03i.png",
419             sd->shot.shot_counter + 1);
420
421    return repname;
422 }
423
424 static int
425 _shot_repeat_count_get(Elm_Win_Smart_Data *sd)
426 {
427    char *p, *pd;
428    char *d = strdup(sd->shot.info);
429
430    if (!d) return 0;
431    for (p = (char *)sd->shot.info; *p; p++)
432      {
433         if (!strncmp(p, "repeat=", 7))
434           {
435              int v;
436
437              for (pd = d, p += 7; (*p) && (*p != ':'); p++, pd++)
438                {
439                   *pd = *p;
440                }
441              *pd = 0;
442              v = atoi(d);
443              if (v < 0) v = 0;
444              if (v > 1000) v = 999;
445              free(d);
446              return v;
447           }
448      }
449    free(d);
450
451    return 0;
452 }
453
454 static char *
455 _shot_key_get(Elm_Win_Smart_Data *sd __UNUSED__)
456 {
457    return NULL;
458 }
459
460 static char *
461 _shot_flags_get(Elm_Win_Smart_Data *sd __UNUSED__)
462 {
463    return NULL;
464 }
465
466 static void
467 _shot_do(Elm_Win_Smart_Data *sd)
468 {
469    Ecore_Evas *ee;
470    Evas_Object *o;
471    unsigned int *pixels;
472    int w, h;
473    char *file, *key, *flags;
474
475    ecore_evas_manual_render(sd->ee);
476    pixels = (void *)ecore_evas_buffer_pixels_get(sd->ee);
477    if (!pixels) return;
478
479    ecore_evas_geometry_get(sd->ee, NULL, NULL, &w, &h);
480    if ((w < 1) || (h < 1)) return;
481
482    file = _shot_file_get(sd);
483    if (!file) return;
484
485    key = _shot_key_get(sd);
486    flags = _shot_flags_get(sd);
487    ee = ecore_evas_buffer_new(1, 1);
488    o = evas_object_image_add(ecore_evas_get(ee));
489    evas_object_image_alpha_set(o, ecore_evas_alpha_get(sd->ee));
490    evas_object_image_size_set(o, w, h);
491    evas_object_image_data_set(o, pixels);
492    if (!evas_object_image_save(o, file, key, flags))
493      {
494         ERR("Cannot save window to '%s' (key '%s', flags '%s')",
495             file, key, flags);
496      }
497    free(file);
498    if (key) free(key);
499    if (flags) free(flags);
500    ecore_evas_free(ee);
501    if (sd->shot.repeat_count) sd->shot.shot_counter++;
502 }
503
504 static Eina_Bool
505 _shot_delay(void *data)
506 {
507    Elm_Win_Smart_Data *sd = data;
508
509    _shot_do(sd);
510    if (sd->shot.repeat_count)
511      {
512         int remainshot = (sd->shot.repeat_count - sd->shot.shot_counter);
513         if (remainshot > 0) return EINA_TRUE;
514      }
515    sd->shot.timer = NULL;
516    elm_exit();
517
518    return EINA_FALSE;
519 }
520
521 static void
522 _shot_init(Elm_Win_Smart_Data *sd)
523 {
524    if (!sd->shot.info) return;
525
526    sd->shot.repeat_count = _shot_repeat_count_get(sd);
527    sd->shot.shot_counter = 0;
528 }
529
530 static void
531 _shot_handle(Elm_Win_Smart_Data *sd)
532 {
533    if (!sd->shot.info) return;
534
535    sd->shot.timer = ecore_timer_add(_shot_delay_get(sd), _shot_delay, sd);
536 }
537
538 /* elm-win specific associate, does the trap while ecore_evas_object_associate()
539  * does not.
540  */
541 static Elm_Win_Smart_Data *
542 _elm_win_associate_get(const Ecore_Evas *ee)
543 {
544    return ecore_evas_data_get(ee, "elm_win");
545 }
546
547 /* Interceptors Callbacks */
548 static void
549 _elm_win_obj_intercept_raise(void *data, Evas_Object *obj __UNUSED__)
550 {
551    Elm_Win_Smart_Data *sd = data;
552    TRAP(sd, raise);
553 }
554
555 static void
556 _elm_win_obj_intercept_lower(void *data, Evas_Object *obj __UNUSED__)
557 {
558    Elm_Win_Smart_Data *sd = data;
559    TRAP(sd, lower);
560 }
561
562 static void
563 _elm_win_obj_intercept_stack_above(void *data __UNUSED__, Evas_Object *obj __UNUSED__, Evas_Object *above __UNUSED__)
564 {
565    INF("TODO: %s", __FUNCTION__);
566 }
567
568 static void
569 _elm_win_obj_intercept_stack_below(void *data __UNUSED__, Evas_Object *obj __UNUSED__, Evas_Object *below __UNUSED__)
570 {
571    INF("TODO: %s", __FUNCTION__);
572 }
573
574 static void
575 _elm_win_obj_intercept_layer_set(void *data, Evas_Object *obj __UNUSED__, int l)
576 {
577    Elm_Win_Smart_Data *sd = data;
578    TRAP(sd, layer_set, l);
579 }
580
581 static void
582 _ecore_evas_move_(void *data, Evas_Object *obj __UNUSED__, int a, int b)
583 {
584    printf("[%s][%d] a=%d, b=%d\n", __FUNCTION__, __LINE__, a, b);
585    Elm_Win_Smart_Data *sd = data;
586    TRAP(sd, move, a, b);
587 }
588
589 /* Event Callbacks */
590
591 static void
592 _elm_win_obj_callback_changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
593 {
594    Elm_Win_Smart_Data *sd = data;
595    Evas_Coord w, h;
596
597    evas_object_size_hint_min_get(obj, &w, &h);
598    TRAP(sd, size_min_set, w, h);
599
600    evas_object_size_hint_max_get(obj, &w, &h);
601    if (w < 1) w = -1;
602    if (h < 1) h = -1;
603    TRAP(sd, size_max_set, w, h);
604 }
605 /* end of elm-win specific associate */
606
607
608 static void
609 _elm_win_move(Ecore_Evas *ee)
610 {
611    Elm_Win_Smart_Data *sd = _elm_win_associate_get(ee);
612    int x, y;
613
614    EINA_SAFETY_ON_NULL_RETURN(sd);
615
616    ecore_evas_geometry_get(ee, &x, &y, NULL, NULL);
617    sd->screen.x = x;
618    sd->screen.y = y;
619    evas_object_smart_callback_call(ELM_WIDGET_DATA(sd)->obj, SIG_MOVED, NULL);
620 }
621
622 static void
623 _elm_win_resize_job(void *data)
624 {
625    Elm_Win_Smart_Data *sd = data;
626    const Eina_List *l;
627    Evas_Object *obj;
628    int w, h;
629
630    sd->deferred_resize_job = NULL;
631    ecore_evas_request_geometry_get(sd->ee, NULL, NULL, &w, &h);
632    if (sd->constrain)
633      {
634         int sw, sh;
635         ecore_evas_screen_geometry_get(sd->ee, NULL, NULL, &sw, &sh);
636         w = MIN(w, sw);
637         h = MIN(h, sh);
638      }
639
640    if (sd->frame_obj)
641      {
642         int fw, fh;
643
644         evas_output_framespace_get(sd->evas, NULL, NULL, &fw, &fh);
645         evas_object_resize(sd->frame_obj, w + fw, h + fh);
646      }
647
648    /* if (sd->img_obj) */
649    /*   { */
650    /*   } */
651
652    evas_object_resize(ELM_WIDGET_DATA(sd)->obj, w, h);
653    EINA_LIST_FOREACH(sd->resize_objs, l, obj)
654      {
655         evas_object_move(obj, 0, 0);
656         evas_object_resize(obj, w, h);
657      }
658 }
659
660 static void
661 _elm_win_resize(Ecore_Evas *ee)
662 {
663    Elm_Win_Smart_Data *sd = _elm_win_associate_get(ee);
664    EINA_SAFETY_ON_NULL_RETURN(sd);
665
666    if (sd->deferred_resize_job) ecore_job_del(sd->deferred_resize_job);
667    sd->deferred_resize_job = ecore_job_add(_elm_win_resize_job, sd);
668 }
669
670 static void
671 _elm_win_mouse_in(Ecore_Evas *ee)
672 {
673    Elm_Win_Smart_Data *sd = _elm_win_associate_get(ee);
674    EINA_SAFETY_ON_NULL_RETURN(sd);
675
676    if (sd->resizing) sd->resizing = EINA_FALSE;
677 }
678
679 static void
680 _elm_win_focus_highlight_reconfigure_job_stop(Elm_Win_Smart_Data *sd)
681 {
682    if (sd->focus_highlight.reconf_job)
683      ecore_job_del(sd->focus_highlight.reconf_job);
684    sd->focus_highlight.reconf_job = NULL;
685 }
686
687 static void
688 _elm_win_focus_highlight_visible_set(Elm_Win_Smart_Data *sd,
689                                      Eina_Bool visible)
690 {
691    Evas_Object *top;
692
693    top = sd->focus_highlight.top;
694    if (visible)
695      {
696         if (top)
697           {
698              evas_object_show(top);
699              edje_object_signal_emit(top, "elm,action,focus,show", "elm");
700           }
701      }
702    else
703      {
704         if (top)
705           edje_object_signal_emit(top, "elm,action,focus,hide", "elm");
706      }
707 }
708
709 static void
710 _elm_win_focus_highlight_anim_setup(Elm_Win_Smart_Data *sd,
711                                     Evas_Object *obj)
712 {
713    Evas_Coord tx, ty, tw, th;
714    Evas_Coord w, h, px, py, pw, ph;
715    Edje_Message_Int_Set *m;
716    Evas_Object *previous = sd->focus_highlight.prev.target;
717    Evas_Object *target = sd->focus_highlight.cur.target;
718
719    evas_object_geometry_get(ELM_WIDGET_DATA(sd)->obj, NULL, NULL, &w, &h);
720    evas_object_geometry_get(target, &tx, &ty, &tw, &th);
721    evas_object_geometry_get(previous, &px, &py, &pw, &ph);
722    evas_object_move(obj, tx, ty);
723    evas_object_resize(obj, tw, th);
724    evas_object_clip_unset(obj);
725
726    m = alloca(sizeof(*m) + (sizeof(int) * 8));
727    m->count = 8;
728    m->val[0] = px - tx;
729    m->val[1] = py - ty;
730    m->val[2] = pw;
731    m->val[3] = ph;
732    m->val[4] = 0;
733    m->val[5] = 0;
734    m->val[6] = tw;
735    m->val[7] = th;
736    edje_object_message_send(obj, EDJE_MESSAGE_INT_SET, 1, m);
737 }
738
739 static void
740 _elm_win_focus_highlight_simple_setup(Elm_Win_Smart_Data *sd,
741                                       Evas_Object *obj)
742 {
743    Evas_Object *clip, *target = sd->focus_highlight.cur.target;
744    Evas_Coord x, y, w, h;
745
746    clip = evas_object_clip_get(target);
747    evas_object_geometry_get(target, &x, &y, &w, &h);
748
749    evas_object_move(obj, x, y);
750    evas_object_resize(obj, w, h);
751    evas_object_clip_set(obj, clip);
752 }
753
754 static void
755 _elm_win_focus_highlight_reconfigure(Elm_Win_Smart_Data *sd)
756 {
757    Evas_Object *target = sd->focus_highlight.cur.target;
758    Evas_Object *previous = sd->focus_highlight.prev.target;
759    Evas_Object *top = sd->focus_highlight.top;
760    Eina_Bool visible_changed;
761    Eina_Bool common_visible;
762    const char *sig = NULL;
763
764    _elm_win_focus_highlight_reconfigure_job_stop(sd);
765
766    visible_changed = (sd->focus_highlight.cur.visible !=
767                       sd->focus_highlight.prev.visible);
768
769    if ((target == previous) && (!visible_changed) &&
770        (!sd->focus_highlight.geometry_changed))
771      return;
772
773    if ((previous) && (sd->focus_highlight.prev.handled))
774      elm_widget_signal_emit
775        (previous, "elm,action,focus_highlight,hide", "elm");
776
777    if (!target)
778      common_visible = EINA_FALSE;
779    else if (sd->focus_highlight.cur.handled)
780      {
781         common_visible = EINA_FALSE;
782         if (sd->focus_highlight.cur.visible)
783           sig = "elm,action,focus_highlight,show";
784         else
785           sig = "elm,action,focus_highlight,hide";
786      }
787    else
788      common_visible = sd->focus_highlight.cur.visible;
789
790    _elm_win_focus_highlight_visible_set(sd, common_visible);
791    if (sig)
792      elm_widget_signal_emit(target, sig, "elm");
793
794    if ((!target) || (!common_visible) || (sd->focus_highlight.cur.handled))
795      goto the_end;
796
797    if (sd->focus_highlight.changed_theme)
798      {
799         const char *str;
800         if (sd->focus_highlight.style)
801           str = sd->focus_highlight.style;
802         else
803           str = "default";
804         elm_widget_theme_object_set
805           (ELM_WIDGET_DATA(sd)->obj, top, "focus_highlight", "top", str);
806         sd->focus_highlight.changed_theme = EINA_FALSE;
807
808         if (_elm_config->focus_highlight_animate)
809           {
810              str = edje_object_data_get(sd->focus_highlight.top, "animate");
811              sd->focus_highlight.top_animate = ((str) && (!strcmp(str, "on")));
812           }
813      }
814
815    if ((sd->focus_highlight.top_animate) && (previous) &&
816        (!sd->focus_highlight.prev.handled))
817      _elm_win_focus_highlight_anim_setup(sd, top);
818    else
819      _elm_win_focus_highlight_simple_setup(sd, top);
820    evas_object_raise(top);
821
822 the_end:
823    sd->focus_highlight.geometry_changed = EINA_FALSE;
824    sd->focus_highlight.prev = sd->focus_highlight.cur;
825 }
826
827 static void
828 _elm_win_focus_highlight_reconfigure_job(void *data)
829 {
830    _elm_win_focus_highlight_reconfigure((Elm_Win_Smart_Data *)data);
831 }
832
833 static void
834 _elm_win_focus_highlight_reconfigure_job_start(Elm_Win_Smart_Data *sd)
835 {
836    if (sd->focus_highlight.reconf_job)
837      ecore_job_del(sd->focus_highlight.reconf_job);
838
839    sd->focus_highlight.reconf_job = ecore_job_add(
840        _elm_win_focus_highlight_reconfigure_job, sd);
841 }
842
843 static void
844 _elm_win_focus_in(Ecore_Evas *ee)
845 {
846    Elm_Win_Smart_Data *sd = _elm_win_associate_get(ee);
847    Evas_Object *obj;
848    unsigned int order = 0;
849
850    EINA_SAFETY_ON_NULL_RETURN(sd);
851
852    obj = ELM_WIDGET_DATA(sd)->obj;
853
854    _elm_widget_top_win_focused_set(obj, EINA_TRUE);
855    if (!elm_widget_focus_order_get(obj)
856        || (obj == elm_widget_newest_focus_order_get(obj, &order, EINA_TRUE)))
857      {
858         elm_widget_focus_steal(obj);
859      }
860    else
861      elm_widget_focus_restore(obj);
862    evas_object_smart_callback_call(obj, SIG_FOCUS_IN, NULL);
863    sd->focus_highlight.cur.visible = EINA_TRUE;
864    _elm_win_focus_highlight_reconfigure_job_start(sd);
865    if (sd->frame_obj)
866      {
867         edje_object_signal_emit(sd->frame_obj, "elm,action,focus", "elm");
868      }
869
870    /* do nothing */
871    /* else if (sd->img_obj) */
872    /*   { */
873    /*   } */
874 }
875
876 static void
877 _elm_win_focus_out(Ecore_Evas *ee)
878 {
879    Elm_Win_Smart_Data *sd = _elm_win_associate_get(ee);
880    Evas_Object *obj;
881
882    EINA_SAFETY_ON_NULL_RETURN(sd);
883
884    obj = ELM_WIDGET_DATA(sd)->obj;
885
886    elm_object_focus_set(obj, EINA_FALSE);
887    _elm_widget_top_win_focused_set(obj, EINA_FALSE);
888    evas_object_smart_callback_call(obj, SIG_FOCUS_OUT, NULL);
889    sd->focus_highlight.cur.visible = EINA_FALSE;
890    _elm_win_focus_highlight_reconfigure_job_start(sd);
891    if (sd->frame_obj)
892      {
893         edje_object_signal_emit(sd->frame_obj, "elm,action,unfocus", "elm");
894      }
895
896    /* access */
897    _elm_access_object_hilight_disable(evas_object_evas_get(obj));
898
899    /* do nothing */
900    /* if (sd->img_obj) */
901    /*   { */
902    /*   } */
903 }
904
905 static void
906 _elm_win_profile_update(Ecore_Evas *ee)
907 {
908    Elm_Win_Smart_Data *sd = _elm_win_associate_get(ee);
909    Evas_Object *obj;
910
911    EINA_SAFETY_ON_NULL_RETURN(sd);
912
913    obj = ELM_WIDGET_DATA(sd)->obj;
914    if (!obj) return;
915
916    if (sd->profile.timer)
917      ecore_timer_del(sd->profile.timer);
918    sd->profile.timer = NULL;
919
920    /* It should be replaced per-window ELM profile later. */
921    _elm_config_profile_set(sd->profile.name);
922
923    evas_object_smart_callback_call(obj, SIG_PROFILE_CHANGED, NULL);
924 }
925
926 static Eina_Bool
927 _elm_win_profile_change_delay(void *data)
928 {
929    Elm_Win_Smart_Data *sd = data;
930    const char *profile;
931    Eina_Bool changed = EINA_FALSE;
932
933    profile = eina_list_nth(sd->profile.names, 0);
934    if (profile)
935      {
936         if (sd->profile.name)
937           {
938              if (strcmp(sd->profile.name, profile))
939                {
940                   eina_stringshare_replace(&(sd->profile.name), profile);
941                   changed = EINA_TRUE;
942                }
943           }
944         else
945           {
946              sd->profile.name = eina_stringshare_add(profile);
947              changed = EINA_TRUE;
948           }
949      }
950    sd->profile.timer = NULL;
951    if (changed) _elm_win_profile_update(sd->ee);
952    return EINA_FALSE;
953 }
954
955 static void
956 _elm_win_state_change(Ecore_Evas *ee)
957 {
958    Elm_Win_Smart_Data *sd = _elm_win_associate_get(ee);
959    Evas_Object *obj;
960    Eina_Bool ch_withdrawn = EINA_FALSE;
961    Eina_Bool ch_sticky = EINA_FALSE;
962    Eina_Bool ch_iconified = EINA_FALSE;
963    Eina_Bool ch_fullscreen = EINA_FALSE;
964    Eina_Bool ch_maximized = EINA_FALSE;
965    Eina_Bool ch_profile = EINA_FALSE;
966    Eina_Bool ch_wm_rotation = EINA_FALSE;
967    const char *profile;
968
969    EINA_SAFETY_ON_NULL_RETURN(sd);
970
971    obj = ELM_WIDGET_DATA(sd)->obj;
972
973    if (sd->withdrawn != ecore_evas_withdrawn_get(sd->ee))
974      {
975         sd->withdrawn = ecore_evas_withdrawn_get(sd->ee);
976         ch_withdrawn = EINA_TRUE;
977      }
978    if (sd->sticky != ecore_evas_sticky_get(sd->ee))
979      {
980         sd->sticky = ecore_evas_sticky_get(sd->ee);
981         ch_sticky = EINA_TRUE;
982      }
983    if (sd->iconified != ecore_evas_iconified_get(sd->ee))
984      {
985         sd->iconified = ecore_evas_iconified_get(sd->ee);
986         ch_iconified = EINA_TRUE;
987      }
988    if (sd->fullscreen != ecore_evas_fullscreen_get(sd->ee))
989      {
990         sd->fullscreen = ecore_evas_fullscreen_get(sd->ee);
991         ch_fullscreen = EINA_TRUE;
992      }
993    if (sd->maximized != ecore_evas_maximized_get(sd->ee))
994      {
995         sd->maximized = ecore_evas_maximized_get(sd->ee);
996         ch_maximized = EINA_TRUE;
997      }
998    profile = ecore_evas_profile_get(sd->ee);
999    if ((profile) &&
1000        _elm_config_profile_exists(profile))
1001      {
1002         if (sd->profile.name)
1003           {
1004              if (strcmp(sd->profile.name, profile))
1005                {
1006                   eina_stringshare_replace(&(sd->profile.name), profile);
1007                   ch_profile = EINA_TRUE;
1008                }
1009           }
1010         else
1011           {
1012              sd->profile.name = eina_stringshare_add(profile);
1013              ch_profile = EINA_TRUE;
1014           }
1015      }
1016    if (sd->wm_rot.use)
1017      {
1018         if (sd->rot != ecore_evas_rotation_get(sd->ee))
1019           {
1020              sd->rot = ecore_evas_rotation_get(sd->ee);
1021              ch_wm_rotation = EINA_TRUE;
1022           }
1023      }
1024
1025    _elm_win_state_eval_queue();
1026
1027    if ((ch_withdrawn) || (ch_iconified))
1028      {
1029         if (sd->withdrawn)
1030           evas_object_smart_callback_call(obj, SIG_WITHDRAWN, NULL);
1031         else if (sd->iconified)
1032           evas_object_smart_callback_call(obj, SIG_ICONIFIED, NULL);
1033         else
1034           evas_object_smart_callback_call(obj, SIG_NORMAL, NULL);
1035      }
1036    if (ch_sticky)
1037      {
1038         if (sd->sticky)
1039           evas_object_smart_callback_call(obj, SIG_STICK, NULL);
1040         else
1041           evas_object_smart_callback_call(obj, SIG_UNSTICK, NULL);
1042      }
1043    if (ch_fullscreen)
1044      {
1045         if (sd->fullscreen)
1046           evas_object_smart_callback_call(obj, SIG_FULLSCREEN, NULL);
1047         else
1048           evas_object_smart_callback_call(obj, SIG_UNFULLSCREEN, NULL);
1049      }
1050    if (ch_maximized)
1051      {
1052         if (sd->maximized)
1053           evas_object_smart_callback_call(obj, SIG_MAXIMIZED, NULL);
1054         else
1055           evas_object_smart_callback_call(obj, SIG_UNMAXIMIZED, NULL);
1056      }
1057    if (ch_profile)
1058      {
1059         _elm_win_profile_update(ee);
1060      }
1061    if (ch_wm_rotation)
1062      {
1063         evas_object_size_hint_min_set(obj, -1, -1);
1064         evas_object_size_hint_max_set(obj, -1, -1);
1065         _elm_win_resize_objects_eval(obj);
1066 #ifdef HAVE_ELEMENTARY_X
1067         _elm_win_xwin_update(sd);
1068 #endif
1069         elm_widget_orientation_set(obj, sd->rot);
1070         evas_object_smart_callback_call(obj, SIG_ROTATION_CHANGED, NULL);
1071         evas_object_smart_callback_call(obj, SIG_WM_ROTATION_CHANGED, NULL);
1072      }
1073 }
1074
1075 static Eina_Bool
1076 _elm_win_smart_focus_next(const Evas_Object *obj,
1077                           Elm_Focus_Direction dir,
1078                           Evas_Object **next)
1079 {
1080    ELM_WIN_DATA_GET(obj, sd);
1081
1082    const Eina_List *items;
1083    void *(*list_data_get)(const Eina_List *list);
1084
1085    /* Focus chain */
1086    if (ELM_WIDGET_DATA(sd)->subobjs)
1087      {
1088         if (!(items = elm_widget_focus_custom_chain_get(obj)))
1089           {
1090              items = ELM_WIDGET_DATA(sd)->subobjs;
1091              if (!items)
1092                return EINA_FALSE;
1093           }
1094         list_data_get = eina_list_data_get;
1095
1096         elm_widget_focus_list_next_get(obj, items, list_data_get, dir, next);
1097
1098         if (*next)
1099           return EINA_TRUE;
1100      }
1101    *next = (Evas_Object *)obj;
1102    return EINA_FALSE;
1103 }
1104
1105 static Eina_Bool
1106 _elm_win_smart_focus_direction(const Evas_Object *obj,
1107                                const Evas_Object *base,
1108                                double degree,
1109                                Evas_Object **direction,
1110                                double *weight)
1111 {
1112    const Eina_List *items;
1113    void *(*list_data_get)(const Eina_List *list);
1114
1115    ELM_WIN_DATA_GET(obj, sd);
1116
1117    /* Focus chain */
1118    if (ELM_WIDGET_DATA(sd)->subobjs)
1119      {
1120         if (!(items = elm_widget_focus_custom_chain_get(obj)))
1121           items = ELM_WIDGET_DATA(sd)->subobjs;
1122
1123         list_data_get = eina_list_data_get;
1124
1125         return elm_widget_focus_list_direction_get
1126                  (obj, base, items, list_data_get, degree, direction, weight);
1127      }
1128
1129    return EINA_FALSE;
1130 }
1131
1132 static Eina_Bool
1133 _elm_win_smart_on_focus(Evas_Object *obj)
1134 {
1135    ELM_WIN_DATA_GET(obj, sd);
1136
1137    if (sd->img_obj)
1138      evas_object_focus_set(sd->img_obj, elm_widget_focus_get(obj));
1139    else
1140      evas_object_focus_set(obj, elm_widget_focus_get(obj));
1141
1142    return EINA_TRUE;
1143 }
1144
1145 static Eina_Bool
1146 _elm_win_smart_event(Evas_Object *obj,
1147                      Evas_Object *src __UNUSED__,
1148                      Evas_Callback_Type type,
1149                      void *event_info)
1150 {
1151    Evas_Event_Key_Down *ev = event_info;
1152    Evas_Object *current_focused;
1153
1154    if (elm_widget_disabled_get(obj)) return EINA_FALSE;
1155
1156    if (type != EVAS_CALLBACK_KEY_DOWN)
1157      return EINA_FALSE;
1158
1159    current_focused = elm_widget_focused_object_get(obj);
1160    if ((!strcmp(ev->keyname, "Tab")) ||
1161        (!strcmp(ev->keyname, "ISO_Left_Tab")))
1162      {
1163         if (evas_key_modifier_is_set(ev->modifiers, "Shift"))
1164           elm_widget_focus_cycle(obj, ELM_FOCUS_PREVIOUS);
1165         else
1166           elm_widget_focus_cycle(obj, ELM_FOCUS_NEXT);
1167
1168         goto success;
1169      }
1170    else if ((!strcmp(ev->keyname, "Left")) ||
1171             ((!strcmp(ev->keyname, "KP_Left")) && (!ev->string)))
1172      {
1173         if (current_focused == obj)
1174           elm_widget_focus_cycle(obj, ELM_FOCUS_NEXT);
1175         else
1176           elm_widget_focus_direction_go(obj, 270.0);
1177
1178         goto success;
1179      }
1180    else if ((!strcmp(ev->keyname, "Right")) ||
1181             ((!strcmp(ev->keyname, "KP_Right")) && (!ev->string)))
1182      {
1183         if (current_focused == obj)
1184           elm_widget_focus_cycle(obj, ELM_FOCUS_NEXT);
1185         else
1186           elm_widget_focus_direction_go(obj, 90.0);
1187
1188         goto success;
1189      }
1190    else if ((!strcmp(ev->keyname, "Up")) ||
1191             ((!strcmp(ev->keyname, "KP_Up")) && (!ev->string)))
1192      {
1193         if (current_focused == obj)
1194           elm_widget_focus_cycle(obj, ELM_FOCUS_NEXT);
1195         else
1196           elm_widget_focus_direction_go(obj, 0.0);
1197
1198         goto success;
1199      }
1200    else if ((!strcmp(ev->keyname, "Down")) ||
1201             ((!strcmp(ev->keyname, "KP_Down")) && (!ev->string)))
1202      {
1203         if (current_focused == obj)
1204           elm_widget_focus_cycle(obj, ELM_FOCUS_NEXT);
1205         else
1206           elm_widget_focus_direction_go(obj, 180.0);
1207
1208         goto success;
1209      }
1210
1211    return EINA_FALSE;
1212
1213 success:
1214    ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1215    return EINA_TRUE;
1216 }
1217
1218 static void
1219 _deferred_ecore_evas_free(void *data)
1220 {
1221    ecore_evas_free(data);
1222    _elm_win_deferred_free--;
1223 }
1224
1225
1226
1227 static void
1228 _elm_win_smart_show(Evas_Object *obj)
1229 {
1230    ELM_WIN_DATA_GET(obj, sd);
1231
1232    if (!evas_object_visible_get(obj))
1233      _elm_win_state_eval_queue();
1234    _elm_win_parent_sc->base.show(obj);
1235
1236    TRAP(sd, show);
1237
1238    if (sd->shot.info) _shot_handle(sd);
1239 }
1240
1241 static void
1242 _elm_win_smart_hide(Evas_Object *obj)
1243 {
1244    ELM_WIN_DATA_GET(obj, sd);
1245
1246    if (evas_object_visible_get(obj))
1247      _elm_win_state_eval_queue();
1248    _elm_win_parent_sc->base.hide(obj);
1249
1250    TRAP(sd, hide);
1251
1252    if (sd->frame_obj)
1253      {
1254         evas_object_hide(sd->frame_obj);
1255      }
1256    if (sd->img_obj)
1257      {
1258         evas_object_hide(sd->img_obj);
1259      }
1260    if (sd->pointer.obj)
1261      {
1262         evas_object_hide(sd->pointer.obj);
1263         ecore_evas_hide(sd->pointer.ee);
1264      }
1265 }
1266
1267 static void
1268 _elm_win_on_parent_del(void *data,
1269                        Evas *e __UNUSED__,
1270                        Evas_Object *obj,
1271                        void *event_info __UNUSED__)
1272 {
1273    Elm_Win_Smart_Data *sd = data;
1274
1275    if (obj == sd->parent) sd->parent = NULL;
1276 }
1277
1278 static void
1279 _elm_win_focus_target_move(void *data,
1280                            Evas *e __UNUSED__,
1281                            Evas_Object *obj __UNUSED__,
1282                            void *event_info __UNUSED__)
1283 {
1284    Elm_Win_Smart_Data *sd = data;
1285
1286    sd->focus_highlight.geometry_changed = EINA_TRUE;
1287    _elm_win_focus_highlight_reconfigure_job_start(sd);
1288 }
1289
1290 static void
1291 _elm_win_focus_target_resize(void *data,
1292                              Evas *e __UNUSED__,
1293                              Evas_Object *obj __UNUSED__,
1294                              void *event_info __UNUSED__)
1295 {
1296    Elm_Win_Smart_Data *sd = data;
1297
1298    sd->focus_highlight.geometry_changed = EINA_TRUE;
1299    _elm_win_focus_highlight_reconfigure_job_start(sd);
1300 }
1301
1302 static void
1303 _elm_win_focus_target_del(void *data,
1304                           Evas *e __UNUSED__,
1305                           Evas_Object *obj __UNUSED__,
1306                           void *event_info __UNUSED__)
1307 {
1308    Elm_Win_Smart_Data *sd = data;
1309
1310    sd->focus_highlight.cur.target = NULL;
1311
1312    _elm_win_focus_highlight_reconfigure_job_start(sd);
1313 }
1314
1315 static Evas_Object *
1316 _elm_win_focus_target_get(Evas_Object *obj)
1317 {
1318    Evas_Object *o = obj;
1319
1320    do
1321      {
1322         if (elm_widget_is(o))
1323           {
1324              if (!elm_widget_highlight_ignore_get(o))
1325                break;
1326              o = elm_widget_parent_get(o);
1327              if (!o)
1328                o = evas_object_smart_parent_get(o);
1329           }
1330         else
1331           {
1332              o = elm_widget_parent_widget_get(o);
1333              if (!o)
1334                o = evas_object_smart_parent_get(o);
1335           }
1336      }
1337    while (o);
1338
1339    return o;
1340 }
1341
1342 static void
1343 _elm_win_focus_target_callbacks_add(Elm_Win_Smart_Data *sd)
1344 {
1345    Evas_Object *obj = sd->focus_highlight.cur.target;
1346
1347    evas_object_event_callback_add
1348      (obj, EVAS_CALLBACK_MOVE, _elm_win_focus_target_move, sd);
1349    evas_object_event_callback_add
1350      (obj, EVAS_CALLBACK_RESIZE, _elm_win_focus_target_resize, sd);
1351    evas_object_event_callback_add
1352      (obj, EVAS_CALLBACK_DEL, _elm_win_focus_target_del, sd);
1353 }
1354
1355 static void
1356 _elm_win_focus_target_callbacks_del(Elm_Win_Smart_Data *sd)
1357 {
1358    Evas_Object *obj = sd->focus_highlight.cur.target;
1359
1360    evas_object_event_callback_del_full
1361      (obj, EVAS_CALLBACK_MOVE, _elm_win_focus_target_move, sd);
1362    evas_object_event_callback_del_full
1363      (obj, EVAS_CALLBACK_RESIZE, _elm_win_focus_target_resize, sd);
1364    evas_object_event_callback_del_full
1365      (obj, EVAS_CALLBACK_DEL, _elm_win_focus_target_del, sd);
1366 }
1367
1368 static void
1369 _elm_win_object_focus_in(void *data,
1370                          Evas *e __UNUSED__,
1371                          void *event_info)
1372 {
1373    Evas_Object *obj = event_info, *target;
1374    Elm_Win_Smart_Data *sd = data;
1375
1376    if (sd->focus_highlight.cur.target == obj)
1377      return;
1378
1379    target = _elm_win_focus_target_get(obj);
1380    sd->focus_highlight.cur.target = target;
1381    if (elm_widget_highlight_in_theme_get(target))
1382      sd->focus_highlight.cur.handled = EINA_TRUE;
1383    else
1384      _elm_win_focus_target_callbacks_add(sd);
1385
1386    _elm_win_focus_highlight_reconfigure_job_start(sd);
1387 }
1388
1389 static void
1390 _elm_win_object_focus_out(void *data,
1391                           Evas *e __UNUSED__,
1392                           void *event_info __UNUSED__)
1393 {
1394    Elm_Win_Smart_Data *sd = data;
1395
1396    if (!sd->focus_highlight.cur.target)
1397      return;
1398
1399    if (!sd->focus_highlight.cur.handled)
1400      _elm_win_focus_target_callbacks_del(sd);
1401
1402    sd->focus_highlight.cur.target = NULL;
1403    sd->focus_highlight.cur.handled = EINA_FALSE;
1404
1405    _elm_win_focus_highlight_reconfigure_job_start(sd);
1406 }
1407
1408 static void
1409 _elm_win_focus_highlight_shutdown(Elm_Win_Smart_Data *sd)
1410 {
1411    _elm_win_focus_highlight_reconfigure_job_stop(sd);
1412    if (sd->focus_highlight.cur.target)
1413      {
1414         _elm_win_focus_target_callbacks_del(sd);
1415         sd->focus_highlight.cur.target = NULL;
1416      }
1417    if (sd->focus_highlight.top)
1418      {
1419         evas_object_del(sd->focus_highlight.top);
1420         sd->focus_highlight.top = NULL;
1421      }
1422
1423    evas_event_callback_del_full
1424      (sd->evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
1425      _elm_win_object_focus_in, sd);
1426    evas_event_callback_del_full
1427      (sd->evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
1428      _elm_win_object_focus_out, sd);
1429 }
1430
1431 static void
1432 _elm_win_on_img_obj_del(void *data,
1433                         Evas *e __UNUSED__,
1434                         Evas_Object *obj __UNUSED__,
1435                         void *event_info __UNUSED__)
1436 {
1437    Elm_Win_Smart_Data *sd = data;
1438    sd->img_obj = NULL;
1439 }
1440
1441 static void
1442 _elm_win_resize_objects_eval(Evas_Object *obj)
1443 {
1444    const Eina_List *l;
1445    const Evas_Object *child;
1446
1447    ELM_WIN_DATA_GET(obj, sd);
1448    Evas_Coord w, h, minw = -1, minh = -1, maxw = -1, maxh = -1;
1449    int xx = 1, xy = 1;
1450    double wx, wy;
1451
1452    EINA_LIST_FOREACH(sd->resize_objs, l, child)
1453      {
1454         evas_object_size_hint_weight_get(child, &wx, &wy);
1455         if (wx == 0.0) xx = 0;
1456         if (wy == 0.0) xy = 0;
1457
1458         evas_object_size_hint_min_get(child, &w, &h);
1459         if (w < 1) w = 1;
1460         if (h < 1) h = 1;
1461         if (w > minw) minw = w;
1462         if (h > minh) minh = h;
1463
1464         evas_object_size_hint_max_get(child, &w, &h);
1465         if (w < 1) w = -1;
1466         if (h < 1) h = -1;
1467         if (maxw == -1) maxw = w;
1468         else if ((w > 0) && (w < maxw))
1469           maxw = w;
1470         if (maxh == -1) maxh = h;
1471         else if ((h > 0) && (h < maxh))
1472           maxh = h;
1473      }
1474    if (!xx) maxw = minw;
1475    else maxw = 32767;
1476    if (!xy) maxh = minh;
1477    else maxh = 32767;
1478    evas_object_size_hint_min_set(obj, minw, minh);
1479    evas_object_size_hint_max_set(obj, maxw, maxh);
1480    evas_object_geometry_get(obj, NULL, NULL, &w, &h);
1481    if (w < minw) w = minw;
1482    if (h < minh) h = minh;
1483    if ((maxw >= 0) && (w > maxw)) w = maxw;
1484    if ((maxh >= 0) && (h > maxh)) h = maxh;
1485    evas_object_resize(obj, w, h);
1486 }
1487
1488 static void
1489 _elm_win_on_resize_obj_del(void *data,
1490                            Evas *e __UNUSED__,
1491                            Evas_Object *obj __UNUSED__,
1492                            void *event_info __UNUSED__)
1493 {
1494    ELM_WIN_DATA_GET(data, sd);
1495
1496    sd->resize_objs = eina_list_remove(sd->resize_objs, obj);
1497
1498    _elm_win_resize_objects_eval(data);
1499 }
1500
1501 static void
1502 _elm_win_on_resize_obj_changed_size_hints(void *data,
1503                                           Evas *e __UNUSED__,
1504                                           Evas_Object *obj __UNUSED__,
1505                                           void *event_info __UNUSED__)
1506 {
1507    _elm_win_resize_objects_eval(data);
1508 }
1509
1510 static void
1511 _elm_win_smart_del(Evas_Object *obj)
1512 {
1513    const char *str;
1514    const Eina_List *l;
1515    const Evas_Object *child;
1516
1517    ELM_WIN_DATA_GET(obj, sd);
1518
1519    /* NB: child deletion handled by parent's smart del */
1520
1521    if ((trap) && (trap->del))
1522      trap->del(sd->trap_data, obj);
1523
1524    if (sd->parent)
1525      {
1526         evas_object_event_callback_del_full
1527           (sd->parent, EVAS_CALLBACK_DEL, _elm_win_on_parent_del, sd);
1528         sd->parent = NULL;
1529      }
1530
1531    EINA_LIST_FOREACH(sd->resize_objs, l, child)
1532      {
1533         evas_object_event_callback_del_full
1534            (child, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1535             _elm_win_on_resize_obj_changed_size_hints, obj);
1536         evas_object_event_callback_del_full
1537            (child, EVAS_CALLBACK_DEL, _elm_win_on_resize_obj_del, obj);
1538      }
1539
1540    if (sd->autodel_clear) *(sd->autodel_clear) = -1;
1541
1542    _elm_win_list = eina_list_remove(_elm_win_list, obj);
1543    _elm_win_count--;
1544    _elm_win_state_eval_queue();
1545
1546    if (sd->ee)
1547      {
1548         ecore_evas_callback_delete_request_set(sd->ee, NULL);
1549         ecore_evas_callback_resize_set(sd->ee, NULL);
1550      }
1551    if (sd->deferred_resize_job) ecore_job_del(sd->deferred_resize_job);
1552    if (sd->deferred_child_eval_job) ecore_job_del(sd->deferred_child_eval_job);
1553    if (sd->shot.info) eina_stringshare_del(sd->shot.info);
1554    if (sd->shot.timer) ecore_timer_del(sd->shot.timer);
1555
1556 #ifdef HAVE_ELEMENTARY_X
1557    if (sd->x.client_message_handler)
1558      ecore_event_handler_del(sd->x.client_message_handler);
1559    if (sd->x.property_handler)
1560      ecore_event_handler_del(sd->x.property_handler);
1561 #endif
1562
1563    if (sd->img_obj)
1564      {
1565         evas_object_event_callback_del_full
1566            (sd->img_obj, EVAS_CALLBACK_DEL, _elm_win_on_img_obj_del, sd);
1567         sd->img_obj = NULL;
1568      }
1569    else
1570      {
1571         if (sd->ee)
1572           {
1573              ecore_job_add(_deferred_ecore_evas_free, sd->ee);
1574              _elm_win_deferred_free++;
1575           }
1576      }
1577
1578    _elm_win_focus_highlight_shutdown(sd);
1579    eina_stringshare_del(sd->focus_highlight.style);
1580
1581    if (sd->title) eina_stringshare_del(sd->title);
1582    if (sd->icon_name) eina_stringshare_del(sd->icon_name);
1583    if (sd->role) eina_stringshare_del(sd->role);
1584    if (sd->icon) evas_object_del(sd->icon);
1585
1586    EINA_LIST_FREE(sd->profile.names, str) eina_stringshare_del(str);
1587    if (sd->profile.name) eina_stringshare_del(sd->profile.name);
1588    if (sd->profile.timer) ecore_timer_del(sd->profile.timer);
1589
1590    if (sd->wm_rot.rots) free(sd->wm_rot.rots);
1591    sd->wm_rot.rots = NULL;
1592
1593    /* Don't let callback in the air that point to sd */
1594    ecore_evas_callback_delete_request_set(sd->ee, NULL);
1595    ecore_evas_callback_resize_set(sd->ee, NULL);
1596    ecore_evas_callback_mouse_in_set(sd->ee, NULL);
1597    ecore_evas_callback_focus_in_set(sd->ee, NULL);
1598    ecore_evas_callback_focus_out_set(sd->ee, NULL);
1599    ecore_evas_callback_move_set(sd->ee, NULL);
1600    ecore_evas_callback_state_change_set(sd->ee, NULL);
1601
1602    _elm_win_parent_sc->base.del(obj); /* handles freeing sd */
1603
1604    if ((!_elm_win_list) &&
1605        (elm_policy_get(ELM_POLICY_QUIT) == ELM_POLICY_QUIT_LAST_WINDOW_CLOSED))
1606      {
1607         edje_file_cache_flush();
1608         edje_collection_cache_flush();
1609         evas_image_cache_flush(evas_object_evas_get(obj));
1610         evas_font_cache_flush(evas_object_evas_get(obj));
1611         elm_exit();
1612      }
1613 }
1614
1615
1616 static void
1617 _elm_win_smart_move(Evas_Object *obj,
1618                     Evas_Coord x,
1619                     Evas_Coord y)
1620 {
1621    ELM_WIN_DATA_GET(obj, sd);
1622
1623    if (sd->img_obj)
1624      {
1625         if ((x != sd->screen.x) || (y != sd->screen.y))
1626           {
1627              sd->screen.x = x;
1628              sd->screen.y = y;
1629              evas_object_smart_callback_call(obj, SIG_MOVED, NULL);
1630           }
1631         return;
1632      }
1633    else
1634      {
1635         TRAP(sd, move, x, y);
1636         if (!ecore_evas_override_get(sd->ee))  return;
1637      }
1638
1639    _elm_win_parent_sc->base.move(obj, x, y);
1640
1641    if (ecore_evas_override_get(sd->ee))
1642      {
1643         sd->screen.x = x;
1644         sd->screen.y = y;
1645         evas_object_smart_callback_call(obj, SIG_MOVED, NULL);
1646      }
1647    if (sd->frame_obj)
1648      {
1649         /* FIXME: We should update ecore_wl_window_location here !! */
1650         sd->screen.x = x;
1651         sd->screen.y = y;
1652      }
1653    if (sd->img_obj)
1654      {
1655         sd->screen.x = x;
1656         sd->screen.y = y;
1657      }
1658 }
1659
1660 static void
1661 _elm_win_smart_resize(Evas_Object *obj,
1662                       Evas_Coord w,
1663                       Evas_Coord h)
1664 {
1665    ELM_WIN_DATA_GET(obj, sd);
1666
1667    _elm_win_parent_sc->base.resize(obj, w, h);
1668
1669    if (sd->img_obj)
1670      {
1671         if (sd->constrain)
1672           {
1673              int sw, sh;
1674
1675              ecore_evas_screen_geometry_get(sd->ee, NULL, NULL, &sw, &sh);
1676              w = MIN(w, sw);
1677              h = MIN(h, sh);
1678           }
1679         if (w < 1) w = 1;
1680         if (h < 1) h = 1;
1681
1682         evas_object_image_size_set(sd->img_obj, w, h);
1683      }
1684
1685    TRAP(sd, resize, w, h);
1686 }
1687
1688 static void
1689 _elm_win_delete_request(Ecore_Evas *ee)
1690 {
1691    Elm_Win_Smart_Data *sd = _elm_win_associate_get(ee);
1692    Evas_Object *obj;
1693
1694    EINA_SAFETY_ON_NULL_RETURN(sd);
1695
1696    obj = ELM_WIDGET_DATA(sd)->obj;
1697
1698    int autodel = sd->autodel;
1699    sd->autodel_clear = &autodel;
1700    evas_object_ref(obj);
1701    evas_object_smart_callback_call(obj, SIG_DELETE_REQUEST, NULL);
1702    // FIXME: if above callback deletes - then the below will be invalid
1703    if (autodel) evas_object_del(obj);
1704    else sd->autodel_clear = NULL;
1705    evas_object_unref(obj);
1706 }
1707
1708 Ecore_X_Window
1709 _elm_ee_xwin_get(const Ecore_Evas *ee)
1710 {
1711 #ifdef HAVE_ELEMENTARY_X
1712    Ecore_X_Window xwin = 0;
1713
1714    if (!ee) return 0;
1715    if (EE_ENGINE_COMPARE(ee, ELM_SOFTWARE_X11))
1716      {
1717         if (ee) xwin = ecore_evas_software_x11_window_get(ee);
1718      }
1719    else if (EE_ENGINE_COMPARE(ee, ELM_SOFTWARE_FB) ||
1720             EE_ENGINE_COMPARE(ee, ELM_SOFTWARE_16_WINCE) ||
1721             EE_ENGINE_COMPARE(ee, ELM_SOFTWARE_SDL) ||
1722             EE_ENGINE_COMPARE(ee, ELM_SOFTWARE_16_SDL) ||
1723             EE_ENGINE_COMPARE(ee, ELM_OPENGL_SDL) ||
1724             EE_ENGINE_COMPARE(ee, ELM_OPENGL_COCOA))
1725      {
1726      }
1727    else if (EE_ENGINE_COMPARE(ee, ELM_SOFTWARE_16_X11))
1728      {
1729         if (ee) xwin = ecore_evas_software_x11_16_window_get(ee);
1730      }
1731    else if (EE_ENGINE_COMPARE(ee, ELM_SOFTWARE_8_X11))
1732      {
1733         if (ee) xwin = ecore_evas_software_x11_8_window_get(ee);
1734      }
1735    else if (EE_ENGINE_COMPARE(ee, ELM_OPENGL_X11))
1736      {
1737         if (ee) xwin = ecore_evas_gl_x11_window_get(ee);
1738      }
1739    else if (EE_ENGINE_COMPARE(ee, ELM_SOFTWARE_WIN32))
1740      {
1741         if (ee) xwin = (long)ecore_evas_win32_window_get(ee);
1742      }
1743    return xwin;
1744
1745 #endif
1746    return 0;
1747 }
1748
1749 #ifdef HAVE_ELEMENTARY_X
1750 static void
1751 _elm_win_xwindow_get(Elm_Win_Smart_Data *sd)
1752 {
1753    sd->x.xwin = _elm_ee_xwin_get(sd->ee);
1754 }
1755
1756 #endif
1757
1758 #ifdef HAVE_ELEMENTARY_X
1759 static void
1760 _elm_win_xwin_update(Elm_Win_Smart_Data *sd)
1761 {
1762    const char *s;
1763
1764    _elm_win_xwindow_get(sd);
1765    if (sd->parent)
1766      {
1767         ELM_WIN_DATA_GET(sd->parent, sdp);
1768         if (sdp)
1769           {
1770              if (sd->x.xwin)
1771                ecore_x_icccm_transient_for_set(sd->x.xwin, sdp->x.xwin);
1772           }
1773      }
1774
1775    if (!sd->x.xwin) return;  /* nothing more to do */
1776
1777    s = sd->title;
1778    if (!s) s = _elm_appname;
1779    if (!s) s = "";
1780    if (sd->icon_name) s = sd->icon_name;
1781    ecore_x_icccm_icon_name_set(sd->x.xwin, s);
1782    ecore_x_netwm_icon_name_set(sd->x.xwin, s);
1783
1784    s = sd->role;
1785    if (s) ecore_x_icccm_window_role_set(sd->x.xwin, s);
1786
1787    // set window icon
1788    if (sd->icon)
1789      {
1790         void *data;
1791
1792         data = evas_object_image_data_get(sd->icon, EINA_FALSE);
1793         if (data)
1794           {
1795              Ecore_X_Icon ic;
1796              int w = 0, h = 0, stride, x, y;
1797              unsigned char *p;
1798              unsigned int *p2;
1799
1800              evas_object_image_size_get(sd->icon, &w, &h);
1801              stride = evas_object_image_stride_get(sd->icon);
1802              if ((w > 0) && (h > 0) &&
1803                  (stride >= (int)(w * sizeof(unsigned int))))
1804                {
1805                   ic.width = w;
1806                   ic.height = h;
1807                   ic.data = malloc(w * h * sizeof(unsigned int));
1808
1809                   if (ic.data)
1810                     {
1811                        p = (unsigned char *)data;
1812                        p2 = (unsigned int *)ic.data;
1813                        for (y = 0; y < h; y++)
1814                          {
1815                             for (x = 0; x < w; x++)
1816                               {
1817                                  *p2 = *((unsigned int *)p);
1818                                  p += sizeof(unsigned int);
1819                                  p2++;
1820                               }
1821                             p += (stride - (w * sizeof(unsigned int)));
1822                          }
1823                        ecore_x_netwm_icons_set(sd->x.xwin, &ic, 1);
1824                        free(ic.data);
1825                     }
1826                }
1827              evas_object_image_data_set(sd->icon, data);
1828           }
1829      }
1830
1831    ecore_x_e_virtual_keyboard_state_set
1832      (sd->x.xwin, (Ecore_X_Virtual_Keyboard_State)sd->kbdmode);
1833    if (sd->indmode == ELM_WIN_INDICATOR_SHOW)
1834      ecore_x_e_illume_indicator_state_set
1835        (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_STATE_ON);
1836    else if (sd->indmode == ELM_WIN_INDICATOR_HIDE)
1837      ecore_x_e_illume_indicator_state_set
1838        (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_STATE_OFF);
1839 }
1840
1841 static void
1842 _elm_win_xwin_type_set(Elm_Win_Smart_Data *sd)
1843 {
1844    _elm_win_xwindow_get(sd);
1845    if (!sd->x.xwin) return;  /* nothing more to do */
1846
1847    switch (sd->type)
1848      {
1849       case ELM_WIN_BASIC:
1850         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_NORMAL);
1851         break;
1852
1853       case ELM_WIN_DIALOG_BASIC:
1854         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_DIALOG);
1855         break;
1856
1857       case ELM_WIN_DESKTOP:
1858         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_DESKTOP);
1859         break;
1860
1861       case ELM_WIN_DOCK:
1862         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_DOCK);
1863         break;
1864
1865       case ELM_WIN_TOOLBAR:
1866         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_TOOLBAR);
1867         break;
1868
1869       case ELM_WIN_MENU:
1870         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_MENU);
1871         break;
1872
1873       case ELM_WIN_UTILITY:
1874         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_UTILITY);
1875         break;
1876
1877       case ELM_WIN_SPLASH:
1878         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_SPLASH);
1879         break;
1880
1881       case ELM_WIN_DROPDOWN_MENU:
1882         ecore_x_netwm_window_type_set
1883           (sd->x.xwin, ECORE_X_WINDOW_TYPE_DROPDOWN_MENU);
1884         break;
1885
1886       case ELM_WIN_POPUP_MENU:
1887         ecore_x_netwm_window_type_set
1888           (sd->x.xwin, ECORE_X_WINDOW_TYPE_POPUP_MENU);
1889         break;
1890
1891       case ELM_WIN_TOOLTIP:
1892         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_TOOLTIP);
1893         break;
1894
1895       case ELM_WIN_NOTIFICATION:
1896         ecore_x_netwm_window_type_set
1897           (sd->x.xwin, ECORE_X_WINDOW_TYPE_NOTIFICATION);
1898         break;
1899
1900       case ELM_WIN_COMBO:
1901         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_COMBO);
1902         break;
1903
1904       case ELM_WIN_DND:
1905         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_DND);
1906         break;
1907
1908       default:
1909         break;
1910      }
1911
1912    return;
1913 }
1914 #endif
1915
1916
1917 void
1918 _elm_win_shutdown(void)
1919 {
1920    while (_elm_win_list) evas_object_del(_elm_win_list->data);
1921    if (_elm_win_state_eval_job)
1922      {
1923         ecore_job_del(_elm_win_state_eval_job);
1924         _elm_win_state_eval_job = NULL;
1925      }
1926 }
1927
1928 void
1929 _elm_win_rescale(Elm_Theme *th,
1930                  Eina_Bool use_theme)
1931 {
1932    const Eina_List *l;
1933    Evas_Object *obj;
1934
1935    if (!use_theme)
1936      {
1937         EINA_LIST_FOREACH(_elm_win_list, l, obj)
1938           elm_widget_theme(obj);
1939      }
1940    else
1941      {
1942         EINA_LIST_FOREACH(_elm_win_list, l, obj)
1943           elm_widget_theme_specific(obj, th, EINA_FALSE);
1944      }
1945 }
1946
1947 void
1948 _elm_win_access(Eina_Bool is_access)
1949 {
1950    const Eina_List *l;
1951    Evas_Object *obj;
1952
1953    EINA_LIST_FOREACH(_elm_win_list, l, obj)
1954      elm_widget_access(obj, is_access);
1955 }
1956
1957 void
1958 _elm_win_translate(void)
1959 {
1960    const Eina_List *l;
1961    Evas_Object *obj;
1962
1963    EINA_LIST_FOREACH(_elm_win_list, l, obj)
1964      elm_widget_translate(obj);
1965 }
1966
1967 #ifdef HAVE_ELEMENTARY_X
1968 static Eina_Bool
1969 _elm_win_client_message(void *data,
1970                         int type __UNUSED__,
1971                         void *event)
1972 {
1973    Elm_Access_Action_Info *a;
1974    Ecore_X_Atom atom_scroll, atom_back, atom_control_panel_open;
1975    Elm_Win_Smart_Data *sd = data;
1976    Ecore_X_Event_Client_Message *e = event;
1977
1978    if (e->format != 32) return ECORE_CALLBACK_PASS_ON;
1979    if (e->message_type == ECORE_X_ATOM_E_COMP_FLUSH)
1980      {
1981         if ((unsigned int)e->data.l[0] == sd->x.xwin)
1982           {
1983              Evas *evas = evas_object_evas_get(ELM_WIDGET_DATA(sd)->obj);
1984              if (evas)
1985                {
1986                   edje_file_cache_flush();
1987                   edje_collection_cache_flush();
1988                   evas_image_cache_flush(evas);
1989                   evas_font_cache_flush(evas);
1990                }
1991           }
1992      }
1993    else if (e->message_type == ECORE_X_ATOM_E_COMP_DUMP)
1994      {
1995         if ((unsigned int)e->data.l[0] == sd->x.xwin)
1996           {
1997              Evas *evas = evas_object_evas_get(ELM_WIDGET_DATA(sd)->obj);
1998              if (evas)
1999                {
2000                   edje_file_cache_flush();
2001                   edje_collection_cache_flush();
2002                   evas_image_cache_flush(evas);
2003                   evas_font_cache_flush(evas);
2004                   evas_render_dump(evas);
2005                }
2006           }
2007      }
2008    else if (e->message_type == ECORE_X_ATOM_E_ILLUME_ACCESS_CONTROL)
2009      {
2010         if ((unsigned int)e->data.l[0] == sd->x.xwin)
2011           {
2012              atom_scroll = ecore_x_atom_get("_E_MOD_SCREEN_READER_ACTION_SCROLL_");
2013              atom_back = ecore_x_atom_get("_E_MOD_SCREEN_READER_ACTION_BACK_");
2014              atom_control_panel_open = ecore_x_atom_get("_E_MOD_SCREEN_READER_ACTION_CONTROL_PANEL_OPEN_");
2015
2016              if ((unsigned int)e->data.l[1] ==
2017                  ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_NEXT)
2018                {
2019                   // XXX: call right access func
2020                }
2021              else if ((unsigned int)e->data.l[1] ==
2022                       ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_PREV)
2023                {
2024                   // XXX: call right access func
2025                }
2026              else if ((unsigned int)e->data.l[1] ==
2027                       ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_ACTIVATE)
2028                {
2029                   _elm_access_highlight_object_activate
2030                     (ELM_WIDGET_DATA(sd)->obj, ELM_ACTIVATE_DEFAULT);
2031                }
2032              else if ((unsigned int)e->data.l[1] ==
2033                       ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_READ)
2034                {
2035                   /* there would be better way to read highlight object */
2036                   Evas *evas;
2037                   evas = evas_object_evas_get(ELM_WIDGET_DATA(sd)->obj);
2038                   if (!evas) return ECORE_CALLBACK_PASS_ON;
2039
2040                   a = calloc(1, sizeof(Elm_Access_Action_Info));
2041                   a->x = e->data.l[2];
2042                   a->y = e->data.l[3];
2043                   elm_access_action(ELM_WIDGET_DATA(sd)->obj, ELM_ACCESS_ACTION_HIGHLIGHT, a);
2044                   free(a);
2045                }
2046              else if ((unsigned int)e->data.l[1] ==
2047                       ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_READ_NEXT)
2048                {
2049                   _elm_access_highlight_cycle(ELM_WIDGET_DATA(sd)->obj, ELM_FOCUS_NEXT);
2050                }
2051              else if ((unsigned int)e->data.l[1] ==
2052                       ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_READ_PREV)
2053                {
2054                   _elm_access_highlight_cycle(ELM_WIDGET_DATA(sd)->obj, ELM_FOCUS_PREVIOUS);
2055                }
2056              else if ((unsigned int)e->data.l[1] ==
2057                       ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_UP)
2058                {
2059                   _elm_access_highlight_object_activate
2060                     (ELM_WIDGET_DATA(sd)->obj, ELM_ACTIVATE_UP);
2061                }
2062              else if ((unsigned int)e->data.l[1] ==
2063                       ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_DOWN)
2064                {
2065                   _elm_access_highlight_object_activate
2066                     (ELM_WIDGET_DATA(sd)->obj, ELM_ACTIVATE_DOWN);
2067                }
2068              else if ((unsigned int)e->data.l[1] == atom_scroll)
2069                {
2070                   _elm_access_highlight_object_scroll(ELM_WIDGET_DATA(sd)->obj,
2071                     e->data.l[2], e->data.l[3], e->data.l[4]);
2072                }
2073              else if ((unsigned int)e->data.l[1] == atom_back)
2074                {
2075                   _elm_access_highlight_object_activate
2076                     (ELM_WIDGET_DATA(sd)->obj, ELM_ACTIVATE_BACK);
2077                }
2078              else if ((unsigned int)e->data.l[1] == atom_control_panel_open)
2079                {
2080                }
2081           }
2082      }
2083    return ECORE_CALLBACK_PASS_ON;
2084 }
2085
2086 static Eina_Bool
2087 _elm_win_property_change(void *data,
2088                          int type __UNUSED__,
2089                          void *event)
2090 {
2091    Elm_Win_Smart_Data *sd = data;
2092    Ecore_X_Event_Window_Property *e = event;
2093
2094    if (e->atom == ECORE_X_ATOM_E_ILLUME_INDICATOR_STATE)
2095      {
2096         if (e->win == sd->x.xwin)
2097           {
2098              sd->indmode = ecore_x_e_illume_indicator_state_get(e->win);
2099              evas_object_smart_callback_call(ELM_WIDGET_DATA(sd)->obj, SIG_INDICATOR_PROP_CHANGED, NULL);
2100           }
2101      }
2102    if (e->atom == ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_STATE)
2103      {
2104         if (e->win == sd->x.xwin)
2105           {
2106              sd->kbdmode = ecore_x_e_virtual_keyboard_state_get(e->win);
2107           }
2108      }
2109    return ECORE_CALLBACK_PASS_ON;
2110 }
2111 #endif
2112
2113 static void
2114 _elm_win_focus_highlight_hide(void *data __UNUSED__,
2115                               Evas_Object *obj,
2116                               const char *emission __UNUSED__,
2117                               const char *source __UNUSED__)
2118 {
2119    evas_object_hide(obj);
2120 }
2121
2122 static void
2123 _elm_win_focus_highlight_anim_end(void *data,
2124                                   Evas_Object *obj,
2125                                   const char *emission __UNUSED__,
2126                                   const char *source __UNUSED__)
2127 {
2128    Elm_Win_Smart_Data *sd = data;
2129
2130    _elm_win_focus_highlight_simple_setup(sd, obj);
2131 }
2132
2133 static void
2134 _elm_win_focus_highlight_init(Elm_Win_Smart_Data *sd)
2135 {
2136    evas_event_callback_add(sd->evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
2137                            _elm_win_object_focus_in, sd);
2138    evas_event_callback_add(sd->evas,
2139                            EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
2140                            _elm_win_object_focus_out, sd);
2141
2142    sd->focus_highlight.cur.target = evas_focus_get(sd->evas);
2143
2144    sd->focus_highlight.top = edje_object_add(sd->evas);
2145    sd->focus_highlight.changed_theme = EINA_TRUE;
2146    edje_object_signal_callback_add(sd->focus_highlight.top,
2147                                    "elm,action,focus,hide,end", "",
2148                                    _elm_win_focus_highlight_hide, NULL);
2149    edje_object_signal_callback_add(sd->focus_highlight.top,
2150                                    "elm,action,focus,anim,end", "",
2151                                    _elm_win_focus_highlight_anim_end, sd);
2152    _elm_win_focus_highlight_reconfigure_job_start(sd);
2153 }
2154
2155 static void
2156 _elm_win_frame_cb_move_start(void *data,
2157                              Evas_Object *obj __UNUSED__,
2158                              const char *sig __UNUSED__,
2159                              const char *source __UNUSED__)
2160 {
2161    Elm_Win_Smart_Data *sd;
2162
2163    if (!(sd = data)) return;
2164    /* FIXME: Change mouse pointer */
2165
2166    /* NB: Wayland handles moving surfaces by itself so we cannot
2167     * specify a specific x/y we want. Instead, we will pass in the
2168     * existing x/y values so they can be recorded as 'previous'
2169     * position. The new position will get updated automatically when
2170     * the move is finished */
2171
2172    ecore_evas_wayland_move(sd->ee, sd->screen.x, sd->screen.y);
2173 }
2174
2175 static void
2176 _elm_win_frame_cb_resize_show(void *data,
2177                               Evas_Object *obj __UNUSED__,
2178                               const char *sig __UNUSED__,
2179                               const char *source)
2180 {
2181    Elm_Win_Smart_Data *sd;
2182
2183    if (!(sd = data)) return;
2184    if (sd->resizing) return;
2185
2186 #ifdef HAVE_ELEMENTARY_WAYLAND
2187    if (!strcmp(source, "elm.event.resize.t"))
2188      ecore_wl_window_cursor_from_name_set(sd->wl.win, ELM_CURSOR_TOP_SIDE);
2189    else if (!strcmp(source, "elm.event.resize.b"))
2190      ecore_wl_window_cursor_from_name_set(sd->wl.win, ELM_CURSOR_BOTTOM_SIDE);
2191    else if (!strcmp(source, "elm.event.resize.l"))
2192      ecore_wl_window_cursor_from_name_set(sd->wl.win, ELM_CURSOR_LEFT_SIDE);
2193    else if (!strcmp(source, "elm.event.resize.r"))
2194      ecore_wl_window_cursor_from_name_set(sd->wl.win, ELM_CURSOR_RIGHT_SIDE);
2195    else if (!strcmp(source, "elm.event.resize.tl"))
2196      ecore_wl_window_cursor_from_name_set(sd->wl.win,
2197                                           ELM_CURSOR_TOP_LEFT_CORNER);
2198    else if (!strcmp(source, "elm.event.resize.tr"))
2199      ecore_wl_window_cursor_from_name_set(sd->wl.win,
2200                                           ELM_CURSOR_TOP_RIGHT_CORNER);
2201    else if (!strcmp(source, "elm.event.resize.bl"))
2202      ecore_wl_window_cursor_from_name_set(sd->wl.win,
2203                                           ELM_CURSOR_BOTTOM_LEFT_CORNER);
2204    else if (!strcmp(source, "elm.event.resize.br"))
2205      ecore_wl_window_cursor_from_name_set(sd->wl.win,
2206                                           ELM_CURSOR_BOTTOM_RIGHT_CORNER);
2207    else
2208      ecore_wl_window_cursor_default_restore(sd->wl.win);
2209 #else
2210    (void)source;
2211 #endif
2212 }
2213
2214 static void
2215 _elm_win_frame_cb_resize_hide(void *data,
2216                               Evas_Object *obj __UNUSED__,
2217                               const char *sig __UNUSED__,
2218                               const char *source __UNUSED__)
2219 {
2220    Elm_Win_Smart_Data *sd;
2221
2222    if (!(sd = data)) return;
2223    if (sd->resizing) return;
2224
2225 #ifdef HAVE_ELEMENTARY_WAYLAND
2226    ecore_wl_window_cursor_default_restore(sd->wl.win);
2227 #endif
2228 }
2229
2230 static void
2231 _elm_win_frame_cb_resize_start(void *data,
2232                                Evas_Object *obj __UNUSED__,
2233                                const char *sig __UNUSED__,
2234                                const char *source)
2235 {
2236    Elm_Win_Smart_Data *sd;
2237
2238    if (!(sd = data)) return;
2239    if (sd->resizing) return;
2240
2241    sd->resizing = EINA_TRUE;
2242
2243    if (!strcmp(source, "elm.event.resize.t"))
2244      sd->resize_location = 1;
2245    else if (!strcmp(source, "elm.event.resize.b"))
2246      sd->resize_location = 2;
2247    else if (!strcmp(source, "elm.event.resize.l"))
2248      sd->resize_location = 4;
2249    else if (!strcmp(source, "elm.event.resize.r"))
2250      sd->resize_location = 8;
2251    else if (!strcmp(source, "elm.event.resize.tl"))
2252      sd->resize_location = 5;
2253    else if (!strcmp(source, "elm.event.resize.tr"))
2254      sd->resize_location = 9;
2255    else if (!strcmp(source, "elm.event.resize.bl"))
2256      sd->resize_location = 6;
2257    else if (!strcmp(source, "elm.event.resize.br"))
2258      sd->resize_location = 10;
2259    else
2260      sd->resize_location = 0;
2261
2262    if (sd->resize_location > 0)
2263      ecore_evas_wayland_resize(sd->ee, sd->resize_location);
2264 }
2265
2266 static void
2267 _elm_win_frame_cb_minimize(void *data,
2268                            Evas_Object *obj __UNUSED__,
2269                            const char *sig __UNUSED__,
2270                            const char *source __UNUSED__)
2271 {
2272    Elm_Win_Smart_Data *sd;
2273
2274    if (!(sd = data)) return;
2275 // sd->iconified = EINA_TRUE;
2276    TRAP(sd, iconified_set, EINA_TRUE);
2277 }
2278
2279 static void
2280 _elm_win_frame_cb_maximize(void *data,
2281                            Evas_Object *obj __UNUSED__,
2282                            const char *sig __UNUSED__,
2283                            const char *source __UNUSED__)
2284 {
2285    Elm_Win_Smart_Data *sd;
2286
2287    if (!(sd = data)) return;
2288    if (sd->maximized) sd->maximized = EINA_FALSE;
2289    else sd->maximized = EINA_TRUE;
2290    TRAP(sd, maximized_set, sd->maximized);
2291 }
2292
2293 static void
2294 _elm_win_frame_cb_close(void *data,
2295                         Evas_Object *obj __UNUSED__,
2296                         const char *sig __UNUSED__,
2297                         const char *source __UNUSED__)
2298 {
2299    Elm_Win_Smart_Data *sd;
2300    Evas_Object *win;
2301
2302    /* FIXME: After the current freeze, this should be handled differently.
2303     *
2304     * Ideally, we would want to mimic the X11 backend and use something
2305     * like ECORE_WL_EVENT_WINDOW_DELETE and handle the delete_request
2306     * inside of ecore_evas. That would be the 'proper' way, but since we are
2307     * in a freeze right now, I cannot add a new event value, or a new
2308     * event structure to ecore_wayland.
2309     *
2310     * So yes, this is a temporary 'stop-gap' solution which will be fixed
2311     * when the freeze is over, but it does fix a trac bug for now, and in a
2312     * way which does not break API or the freeze. - dh
2313     */
2314
2315    if (!(sd = data)) return;
2316
2317    win = ELM_WIDGET_DATA(sd)->obj;
2318
2319    int autodel = sd->autodel;
2320    sd->autodel_clear = &autodel;
2321    evas_object_ref(win);
2322    evas_object_smart_callback_call(win, SIG_DELETE_REQUEST, NULL);
2323    // FIXME: if above callback deletes - then the below will be invalid
2324    if (autodel) evas_object_del(win);
2325    else sd->autodel_clear = NULL;
2326    evas_object_unref(win);
2327 }
2328
2329 static void
2330 _elm_win_frame_add(Elm_Win_Smart_Data *sd,
2331                    const char *style)
2332 {
2333    evas_output_framespace_set(sd->evas, 0, 22, 0, 26);
2334
2335    sd->frame_obj = edje_object_add(sd->evas);
2336    elm_widget_theme_object_set
2337      (ELM_WIDGET_DATA(sd)->obj, sd->frame_obj, "border", "base", style);
2338
2339    evas_object_is_frame_object_set(sd->frame_obj, EINA_TRUE);
2340    evas_object_move(sd->frame_obj, 0, 0);
2341    evas_object_resize(sd->frame_obj, 1, 1);
2342
2343    edje_object_signal_callback_add
2344      (sd->frame_obj, "elm,action,move,start", "elm",
2345      _elm_win_frame_cb_move_start, sd);
2346    edje_object_signal_callback_add
2347      (sd->frame_obj, "elm,action,resize,show", "*",
2348      _elm_win_frame_cb_resize_show, sd);
2349    edje_object_signal_callback_add
2350      (sd->frame_obj, "elm,action,resize,hide", "*",
2351      _elm_win_frame_cb_resize_hide, sd);
2352    edje_object_signal_callback_add
2353      (sd->frame_obj, "elm,action,resize,start", "*",
2354      _elm_win_frame_cb_resize_start, sd);
2355    edje_object_signal_callback_add
2356      (sd->frame_obj, "elm,action,minimize", "elm",
2357      _elm_win_frame_cb_minimize, sd);
2358    edje_object_signal_callback_add
2359      (sd->frame_obj, "elm,action,maximize", "elm",
2360      _elm_win_frame_cb_maximize, sd);
2361    edje_object_signal_callback_add
2362      (sd->frame_obj, "elm,action,close", "elm", _elm_win_frame_cb_close, sd);
2363
2364    if (sd->title)
2365      {
2366         edje_object_part_text_escaped_set
2367           (sd->frame_obj, "elm.text.title", sd->title);
2368      }
2369 }
2370
2371 static void
2372 _elm_win_frame_del(Elm_Win_Smart_Data *sd)
2373 {
2374    if (sd->frame_obj)
2375      {
2376         edje_object_signal_callback_del
2377           (sd->frame_obj, "elm,action,move,start", "elm",
2378               _elm_win_frame_cb_move_start);
2379         edje_object_signal_callback_del
2380           (sd->frame_obj, "elm,action,resize,show", "*",
2381               _elm_win_frame_cb_resize_show);
2382         edje_object_signal_callback_del
2383           (sd->frame_obj, "elm,action,resize,hide", "*",
2384               _elm_win_frame_cb_resize_hide);
2385         edje_object_signal_callback_del
2386           (sd->frame_obj, "elm,action,resize,start", "*",
2387               _elm_win_frame_cb_resize_start);
2388         edje_object_signal_callback_del
2389           (sd->frame_obj, "elm,action,minimize", "elm",
2390               _elm_win_frame_cb_minimize);
2391         edje_object_signal_callback_del
2392           (sd->frame_obj, "elm,action,maximize", "elm",
2393               _elm_win_frame_cb_maximize);
2394         edje_object_signal_callback_del
2395           (sd->frame_obj, "elm,action,close", "elm",
2396               _elm_win_frame_cb_close);
2397
2398         evas_object_del(sd->frame_obj);
2399         sd->frame_obj = NULL;
2400      }
2401
2402    evas_output_framespace_set(sd->evas, 0, 0, 0, 0);
2403 }
2404
2405 #ifdef ELM_DEBUG
2406 static void
2407 _debug_key_down(void *data __UNUSED__,
2408                 Evas *e __UNUSED__,
2409                 Evas_Object *obj,
2410                 void *event_info)
2411 {
2412    Evas_Event_Key_Down *ev = event_info;
2413
2414    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
2415      return;
2416
2417    if ((strcmp(ev->keyname, "F12")) ||
2418        (!evas_key_modifier_is_set(ev->modifiers, "Control")))
2419      return;
2420
2421    printf("Tree graph generated.\n");
2422    elm_object_tree_dot_dump(obj, "./dump.dot");
2423 }
2424
2425 #endif
2426
2427 static void
2428 _win_img_hide(void *data,
2429               Evas *e __UNUSED__,
2430               Evas_Object *obj __UNUSED__,
2431               void *event_info __UNUSED__)
2432 {
2433    Elm_Win_Smart_Data *sd = data;
2434
2435    elm_widget_focus_hide_handle(ELM_WIDGET_DATA(sd)->obj);
2436 }
2437
2438 static void
2439 _win_img_mouse_up(void *data,
2440                   Evas *e __UNUSED__,
2441                   Evas_Object *obj __UNUSED__,
2442                   void *event_info)
2443 {
2444    Elm_Win_Smart_Data *sd = data;
2445    Evas_Event_Mouse_Up *ev = event_info;
2446    if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD))
2447      elm_widget_focus_mouse_up_handle(ELM_WIDGET_DATA(sd)->obj);
2448 }
2449
2450 static void
2451 _win_img_focus_in(void *data,
2452                   Evas *e __UNUSED__,
2453                   Evas_Object *obj __UNUSED__,
2454                   void *event_info __UNUSED__)
2455 {
2456    Elm_Win_Smart_Data *sd = data;
2457    elm_widget_focus_steal(ELM_WIDGET_DATA(sd)->obj);
2458 }
2459
2460 static void
2461 _win_img_focus_out(void *data,
2462                    Evas *e __UNUSED__,
2463                    Evas_Object *obj __UNUSED__,
2464                    void *event_info __UNUSED__)
2465 {
2466    Elm_Win_Smart_Data *sd = data;
2467    elm_widget_focused_object_clear(ELM_WIDGET_DATA(sd)->obj);
2468 }
2469
2470 static void
2471 _win_inlined_image_set(Elm_Win_Smart_Data *sd)
2472 {
2473    evas_object_image_alpha_set(sd->img_obj, EINA_FALSE);
2474    evas_object_image_filled_set(sd->img_obj, EINA_TRUE);
2475
2476    evas_object_event_callback_add
2477      (sd->img_obj, EVAS_CALLBACK_DEL, _elm_win_on_img_obj_del, sd);
2478    evas_object_event_callback_add
2479      (sd->img_obj, EVAS_CALLBACK_HIDE, _win_img_hide, sd);
2480    evas_object_event_callback_add
2481      (sd->img_obj, EVAS_CALLBACK_MOUSE_UP, _win_img_mouse_up, sd);
2482    evas_object_event_callback_add
2483      (sd->img_obj, EVAS_CALLBACK_FOCUS_IN, _win_img_focus_in, sd);
2484    evas_object_event_callback_add
2485      (sd->img_obj, EVAS_CALLBACK_FOCUS_OUT, _win_img_focus_out, sd);
2486 }
2487
2488 static void
2489 _elm_win_on_icon_del(void *data,
2490                      Evas *e __UNUSED__,
2491                      Evas_Object *obj,
2492                      void *event_info __UNUSED__)
2493 {
2494    Elm_Win_Smart_Data *sd = data;
2495
2496    if (sd->icon == obj) sd->icon = NULL;
2497 }
2498
2499 static void
2500 _elm_win_smart_add(Evas_Object *obj)
2501 {
2502    EVAS_SMART_DATA_ALLOC(obj, Elm_Win_Smart_Data);
2503
2504    _elm_win_parent_sc->base.add(obj);
2505
2506    elm_widget_can_focus_set(obj, EINA_TRUE);
2507
2508    elm_widget_highlight_ignore_set(obj, EINA_TRUE);
2509 }
2510
2511 static void
2512 _elm_win_smart_set_user(Elm_Widget_Smart_Class *sc)
2513 {
2514    sc->base.add = _elm_win_smart_add;
2515    sc->base.del = _elm_win_smart_del;
2516    sc->base.show = _elm_win_smart_show;
2517    sc->base.hide = _elm_win_smart_hide;
2518    sc->base.move = _elm_win_smart_move;
2519    sc->base.resize = _elm_win_smart_resize;
2520
2521    sc->focus_next = _elm_win_smart_focus_next;
2522    sc->focus_direction = _elm_win_smart_focus_direction;
2523    sc->on_focus = _elm_win_smart_on_focus;
2524    sc->event = _elm_win_smart_event;
2525 }
2526
2527 #ifdef HAVE_ELEMENTARY_X
2528 static void
2529 _elm_x_io_err(void *data __UNUSED__)
2530 {
2531    Eina_List *l;
2532    Evas_Object *obj;
2533
2534    EINA_LIST_FOREACH(_elm_win_list, l, obj)
2535      evas_object_smart_callback_call(obj, SIG_IOERR, NULL);
2536    elm_exit();
2537 }
2538 #endif
2539
2540 static void
2541 _elm_win_cb_hide(void *data __UNUSED__,
2542                  Evas *e __UNUSED__,
2543                  Evas_Object *obj __UNUSED__,
2544                  void *event_info __UNUSED__)
2545 {
2546    _elm_win_state_eval_queue();
2547 }
2548
2549 static void
2550 _elm_win_cb_show(void *data __UNUSED__,
2551                  Evas *e __UNUSED__,
2552                  Evas_Object *obj __UNUSED__,
2553                  void *event_info __UNUSED__)
2554 {
2555    _elm_win_state_eval_queue();
2556 }
2557
2558 EAPI Evas_Object *
2559 elm_win_add(Evas_Object *parent,
2560             const char *name,
2561             Elm_Win_Type type)
2562 {
2563    Evas *e;
2564    Evas_Object *obj;
2565    const Eina_List *l;
2566    const char *fontpath, *fallback = NULL;
2567
2568    Elm_Win_Smart_Data tmp_sd;
2569
2570    /* just to store some data while trying out to create a canvas */
2571    memset(&tmp_sd, 0, sizeof(Elm_Win_Smart_Data));
2572
2573 #define FALLBACK_TRY(engine)                                      \
2574   if (!tmp_sd.ee) {                                               \
2575      CRITICAL(engine " engine creation failed. Trying default."); \
2576        tmp_sd.ee = ecore_evas_new(NULL, 0, 0, 1, 1, NULL);              \
2577        if (tmp_sd.ee)                                                   \
2578           elm_config_preferred_engine_set(ecore_evas_engine_name_get(tmp_sd.ee)); \
2579   } while (0)
2580 #define FALLBACK_STORE(engine)                               \
2581    if (tmp_sd.ee)                                            \
2582    {                                                         \
2583       CRITICAL(engine "Fallback to %s successful.", engine); \
2584       fallback = engine;                                     \
2585    }
2586
2587    switch (type)
2588      {
2589       case ELM_WIN_INLINED_IMAGE:
2590         if (!parent) break;
2591         {
2592            e = evas_object_evas_get(parent);
2593            Ecore_Evas *ee;
2594
2595            if (!e) break;
2596
2597            ee = ecore_evas_ecore_evas_get(e);
2598            if (!ee) break;
2599
2600            tmp_sd.img_obj = ecore_evas_object_image_new(ee);
2601            if (!tmp_sd.img_obj) break;
2602
2603            tmp_sd.ee = ecore_evas_object_ecore_evas_get(tmp_sd.img_obj);
2604            if (!tmp_sd.ee)
2605              {
2606                 evas_object_del(tmp_sd.img_obj);
2607                 tmp_sd.img_obj = NULL;
2608              }
2609         }
2610         break;
2611
2612       case ELM_WIN_SOCKET_IMAGE:
2613         tmp_sd.ee = ecore_evas_extn_socket_new(1, 1);
2614         break;
2615
2616       default:
2617         if (ENGINE_COMPARE(ELM_SOFTWARE_X11))
2618           {
2619              tmp_sd.ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
2620              FALLBACK_TRY("Software X11");
2621              if (!tmp_sd.ee)
2622                {
2623                   tmp_sd.ee = ecore_evas_fb_new(NULL, 0, 1, 1);
2624                   FALLBACK_STORE("Software FB");
2625                }
2626           }
2627         else if (ENGINE_COMPARE(ELM_SOFTWARE_FB))
2628           {
2629              tmp_sd.ee = ecore_evas_fb_new(NULL, 0, 1, 1);
2630              FALLBACK_TRY("Software FB");
2631              if (!tmp_sd.ee)
2632                {
2633                   tmp_sd.ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
2634                   FALLBACK_STORE("Software X11");
2635                }
2636           }
2637         else if (ENGINE_COMPARE(ELM_SOFTWARE_DIRECTFB))
2638           {
2639              tmp_sd.ee = ecore_evas_directfb_new(NULL, 1, 0, 0, 1, 1);
2640              FALLBACK_TRY("Software DirectFB");
2641              if (!tmp_sd.ee)
2642                {
2643                   tmp_sd.ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
2644                   FALLBACK_STORE("Software X11");
2645                   if (!tmp_sd.ee)
2646                     {
2647                        tmp_sd.ee = ecore_evas_fb_new(NULL, 0, 1, 1);
2648                        FALLBACK_STORE("Software FB");
2649                     }
2650                }
2651           }
2652         else if (ENGINE_COMPARE(ELM_SOFTWARE_16_X11))
2653           {
2654              tmp_sd.ee = ecore_evas_software_x11_16_new(NULL, 0, 0, 0, 1, 1);
2655              FALLBACK_TRY("Software-16");
2656              if (!tmp_sd.ee)
2657                {
2658                   tmp_sd.ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
2659                   FALLBACK_STORE("Software X11");
2660                   if (!tmp_sd.ee)
2661                     {
2662                        tmp_sd.ee = ecore_evas_fb_new(NULL, 0, 1, 1);
2663                        FALLBACK_STORE("Software FB");
2664                     }
2665                }
2666           }
2667         else if (ENGINE_COMPARE(ELM_SOFTWARE_8_X11))
2668           {
2669              tmp_sd.ee = ecore_evas_software_x11_8_new(NULL, 0, 0, 0, 1, 1);
2670              FALLBACK_TRY("Software-8");
2671              if (!tmp_sd.ee)
2672                {
2673                   tmp_sd.ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
2674                   FALLBACK_STORE("Software X11");
2675                   if (!tmp_sd.ee)
2676                     {
2677                        tmp_sd.ee = ecore_evas_fb_new(NULL, 0, 1, 1);
2678                        FALLBACK_STORE("Software FB");
2679                     }
2680                }
2681           }
2682         else if (ENGINE_COMPARE(ELM_OPENGL_X11))
2683           {
2684              int opt[10];
2685              int opt_i = 0;
2686
2687              if (_elm_config->vsync)
2688                {
2689                   opt[opt_i] = ECORE_EVAS_GL_X11_OPT_VSYNC;
2690                   opt_i++;
2691                   opt[opt_i] = 1;
2692                   opt_i++;
2693                                   opt[opt_i] = 0;
2694                }
2695              if (opt_i > 0)
2696                tmp_sd.ee = ecore_evas_gl_x11_options_new
2697                    (NULL, 0, 0, 0, 1, 1, opt);
2698              else
2699                tmp_sd.ee = ecore_evas_gl_x11_new(NULL, 0, 0, 0, 1, 1);
2700              FALLBACK_TRY("OpenGL");
2701              if (!tmp_sd.ee)
2702                {
2703                   tmp_sd.ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
2704                   FALLBACK_STORE("Software X11");
2705                   if (!tmp_sd.ee)
2706                     {
2707                        tmp_sd.ee = ecore_evas_fb_new(NULL, 0, 1, 1);
2708                        FALLBACK_STORE("Software FB");
2709                     }
2710                }
2711           }
2712         else if (ENGINE_COMPARE(ELM_SOFTWARE_WIN32))
2713           {
2714              tmp_sd.ee = ecore_evas_software_gdi_new(NULL, 0, 0, 1, 1);
2715              FALLBACK_TRY("Software Win32");
2716           }
2717         else if (ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE))
2718           {
2719              tmp_sd.ee = ecore_evas_software_wince_gdi_new(NULL, 0, 0, 1, 1);
2720              FALLBACK_TRY("Software-16-WinCE");
2721           }
2722         else if (ENGINE_COMPARE(ELM_SOFTWARE_PSL1GHT))
2723           {
2724              tmp_sd.ee = ecore_evas_psl1ght_new(NULL, 1, 1);
2725              FALLBACK_TRY("PSL1GHT");
2726           }
2727         else if (ENGINE_COMPARE(ELM_SOFTWARE_SDL))
2728           {
2729              tmp_sd.ee = ecore_evas_sdl_new(NULL, 0, 0, 0, 0, 0, 1);
2730              FALLBACK_TRY("Software SDL");
2731              if (!tmp_sd.ee)
2732                {
2733                   tmp_sd.ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
2734                   FALLBACK_STORE("Software X11");
2735                   if (!tmp_sd.ee)
2736                     {
2737                        tmp_sd.ee = ecore_evas_fb_new(NULL, 0, 1, 1);
2738                        FALLBACK_STORE("Software FB");
2739                     }
2740                }
2741           }
2742         else if (ENGINE_COMPARE(ELM_SOFTWARE_16_SDL))
2743           {
2744              tmp_sd.ee = ecore_evas_sdl16_new(NULL, 0, 0, 0, 0, 0, 1);
2745              FALLBACK_TRY("Software-16-SDL");
2746              if (!tmp_sd.ee)
2747                {
2748                   tmp_sd.ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
2749                   FALLBACK_STORE("Software X11");
2750                   if (!tmp_sd.ee)
2751                     {
2752                        tmp_sd.ee = ecore_evas_fb_new(NULL, 0, 1, 1);
2753                        FALLBACK_STORE("Software FB");
2754                     }
2755                }
2756           }
2757         else if (ENGINE_COMPARE(ELM_OPENGL_SDL))
2758           {
2759              tmp_sd.ee = ecore_evas_gl_sdl_new(NULL, 1, 1, 0, 0);
2760              FALLBACK_TRY("OpenGL SDL");
2761              if (!tmp_sd.ee)
2762                {
2763                   tmp_sd.ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
2764                   FALLBACK_STORE("Software X11");
2765                   if (!tmp_sd.ee)
2766                     {
2767                        tmp_sd.ee = ecore_evas_fb_new(NULL, 0, 1, 1);
2768                        FALLBACK_STORE("Software FB");
2769                     }
2770                }
2771           }
2772         else if (ENGINE_COMPARE(ELM_OPENGL_COCOA))
2773           {
2774              tmp_sd.ee = ecore_evas_cocoa_new(NULL, 1, 1, 0, 0);
2775              FALLBACK_TRY("OpenGL Cocoa");
2776           }
2777         else if (ENGINE_COMPARE(ELM_BUFFER))
2778           {
2779              tmp_sd.ee = ecore_evas_buffer_new(1, 1);
2780           }
2781         else if (ENGINE_COMPARE(ELM_EWS))
2782           {
2783              tmp_sd.ee = ecore_evas_ews_new(0, 0, 1, 1);
2784           }
2785         else if (ENGINE_COMPARE(ELM_WAYLAND_SHM))
2786           {
2787              tmp_sd.ee = ecore_evas_wayland_shm_new(NULL, 0, 0, 0, 1, 1, 0);
2788           }
2789         else if (ENGINE_COMPARE(ELM_WAYLAND_EGL))
2790           {
2791              tmp_sd.ee = ecore_evas_wayland_egl_new(NULL, 0, 0, 0, 1, 1, 0);
2792           }
2793         else if (!strncmp(ENGINE_GET(), "shot:", 5))
2794           {
2795              tmp_sd.ee = ecore_evas_buffer_new(1, 1);
2796              ecore_evas_manual_render_set(tmp_sd.ee, EINA_TRUE);
2797              tmp_sd.shot.info = eina_stringshare_add
2798                  (ENGINE_GET() + 5);
2799           }
2800 #undef FALLBACK_TRY
2801         break;
2802      }
2803
2804    if (!tmp_sd.ee)
2805      {
2806         ERR("Cannot create window.");
2807         return NULL;
2808      }
2809
2810    obj = evas_object_smart_add
2811        (ecore_evas_get(tmp_sd.ee), _elm_win_smart_class_new());
2812
2813    ELM_WIN_DATA_GET(obj, sd);
2814
2815    /* copying possibly altered fields back */
2816 #define SD_CPY(_field)             \
2817   do                               \
2818     {                              \
2819        sd->_field = tmp_sd._field; \
2820     } while (0)
2821
2822    SD_CPY(ee);
2823    SD_CPY(img_obj);
2824    SD_CPY(shot.info);
2825 #undef SD_CPY
2826
2827    if ((trap) && (trap->add))
2828      sd->trap_data = trap->add(obj);
2829
2830    /* complementary actions, which depend on final smart data
2831     * pointer */
2832    if (type == ELM_WIN_INLINED_IMAGE)
2833      _win_inlined_image_set(sd);
2834
2835 #ifdef HAVE_ELEMENTARY_X
2836     else if (ENGINE_COMPARE(ELM_SOFTWARE_X11) ||
2837             ENGINE_COMPARE(ELM_SOFTWARE_16_X11) ||
2838             ENGINE_COMPARE(ELM_SOFTWARE_8_X11) ||
2839             ENGINE_COMPARE(ELM_OPENGL_X11))
2840      {
2841         sd->x.client_message_handler = ecore_event_handler_add
2842             (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, sd);
2843         sd->x.property_handler = ecore_event_handler_add
2844             (ECORE_X_EVENT_WINDOW_PROPERTY, _elm_win_property_change, sd);
2845      }
2846 #endif
2847
2848    else if (!strncmp(ENGINE_GET(), "shot:", 5))
2849      _shot_init(sd);
2850
2851    sd->kbdmode = ELM_WIN_KEYBOARD_UNKNOWN;
2852    sd->indmode = ELM_WIN_INDICATOR_UNKNOWN;
2853
2854 #ifdef HAVE_ELEMENTARY_X
2855    _elm_win_xwindow_get(sd);
2856    if (sd->x.xwin)
2857      {
2858         ecore_x_io_error_handler_set(_elm_x_io_err, NULL);
2859      }
2860 #endif
2861
2862 #ifdef HAVE_ELEMENTARY_WAYLAND
2863    sd->wl.win = ecore_evas_wayland_window_get(sd->ee);
2864 #endif
2865
2866    if ((_elm_config->bgpixmap)
2867 #ifdef HAVE_ELEMENTARY_X
2868        &&
2869        (((sd->x.xwin) && (!ecore_x_screen_is_composited(0))) ||
2870            (!sd->x.xwin))
2871 #endif
2872       )
2873      TRAP(sd, avoid_damage_set, ECORE_EVAS_AVOID_DAMAGE_EXPOSE);
2874    // bg pixmap done by x - has other issues like can be redrawn by x before it
2875    // is filled/ready by app
2876    //     TRAP(sd, avoid_damage_set, ECORE_EVAS_AVOID_DAMAGE_BUILT_IN);
2877
2878    sd->type = type;
2879    sd->parent = parent;
2880
2881    if (sd->parent)
2882      evas_object_event_callback_add
2883        (sd->parent, EVAS_CALLBACK_DEL, _elm_win_on_parent_del, sd);
2884
2885    sd->evas = ecore_evas_get(sd->ee);
2886
2887    evas_object_color_set(obj, 0, 0, 0, 0);
2888    evas_object_move(obj, 0, 0);
2889    evas_object_resize(obj, 1, 1);
2890    evas_object_layer_set(obj, 50);
2891    evas_object_pass_events_set(obj, EINA_TRUE);
2892
2893    if (type == ELM_WIN_INLINED_IMAGE)
2894      elm_widget_parent2_set(obj, parent);
2895
2896    /* use own version of ecore_evas_object_associate() that does TRAP() */
2897    ecore_evas_data_set(sd->ee, "elm_win", sd);
2898
2899    evas_object_event_callback_add
2900      (obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
2901       _elm_win_obj_callback_changed_size_hints, sd);
2902
2903    evas_object_intercept_raise_callback_add
2904      (obj, _elm_win_obj_intercept_raise, sd);
2905    evas_object_intercept_lower_callback_add
2906      (obj, _elm_win_obj_intercept_lower, sd);
2907    evas_object_intercept_stack_above_callback_add
2908      (obj, _elm_win_obj_intercept_stack_above, sd);
2909    evas_object_intercept_stack_below_callback_add
2910      (obj, _elm_win_obj_intercept_stack_below, sd);
2911    evas_object_intercept_layer_set_callback_add
2912      (obj, _elm_win_obj_intercept_layer_set, sd);
2913    evas_object_intercept_show_callback_add
2914      (obj, _elm_win_obj_intercept_show, sd);
2915    evas_object_intercept_move_callback_add
2916      (obj, _ecore_evas_move_, sd);
2917
2918    TRAP(sd, name_class_set, name, _elm_appname);
2919    ecore_evas_callback_delete_request_set(sd->ee, _elm_win_delete_request);
2920    ecore_evas_callback_resize_set(sd->ee, _elm_win_resize);
2921    ecore_evas_callback_mouse_in_set(sd->ee, _elm_win_mouse_in);
2922    ecore_evas_callback_focus_in_set(sd->ee, _elm_win_focus_in);
2923    ecore_evas_callback_focus_out_set(sd->ee, _elm_win_focus_out);
2924    ecore_evas_callback_move_set(sd->ee, _elm_win_move);
2925    ecore_evas_callback_state_change_set(sd->ee, _elm_win_state_change);
2926    evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _elm_win_cb_hide, sd);
2927    evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _elm_win_cb_show, sd);
2928
2929    evas_image_cache_set(sd->evas, (_elm_config->image_cache * 1024));
2930    evas_font_cache_set(sd->evas, (_elm_config->font_cache * 1024));
2931
2932    EINA_LIST_FOREACH(_elm_config->font_dirs, l, fontpath)
2933      evas_font_path_append(sd->evas, fontpath);
2934
2935    if (!_elm_config->font_hinting)
2936      evas_font_hinting_set(sd->evas, EVAS_FONT_HINTING_NONE);
2937    else if (_elm_config->font_hinting == 1)
2938      evas_font_hinting_set(sd->evas, EVAS_FONT_HINTING_AUTO);
2939    else if (_elm_config->font_hinting == 2)
2940      evas_font_hinting_set(sd->evas, EVAS_FONT_HINTING_BYTECODE);
2941
2942 #ifdef HAVE_ELEMENTARY_X
2943    _elm_win_xwin_type_set(sd);
2944    _elm_win_xwin_update(sd);
2945 #endif
2946
2947    _elm_win_list = eina_list_append(_elm_win_list, obj);
2948    _elm_win_count++;
2949
2950    if (((fallback) && (!strcmp(fallback, "Software FB"))) ||
2951        ((!fallback) && (ENGINE_COMPARE(ELM_SOFTWARE_FB))))
2952      {
2953         TRAP(sd, fullscreen_set, 1);
2954      }
2955    else if ((type != ELM_WIN_INLINED_IMAGE) &&
2956             (ENGINE_COMPARE(ELM_WAYLAND_SHM) ||
2957              ENGINE_COMPARE(ELM_WAYLAND_EGL)))
2958      _elm_win_frame_add(sd, "default");
2959
2960    if (_elm_config->focus_highlight_enable)
2961      elm_win_focus_highlight_enabled_set(obj, EINA_TRUE);
2962
2963 #ifdef ELM_DEBUG
2964    Evas_Modifier_Mask mask = evas_key_modifier_mask_get(sd->evas, "Control");
2965    evas_object_event_callback_add
2966      (obj, EVAS_CALLBACK_KEY_DOWN, _debug_key_down, sd);
2967
2968    if (evas_object_key_grab(obj, "F12", mask, 0, EINA_TRUE))
2969      INF("Ctrl+F12 key combination exclusive for dot tree generation\n");
2970    else
2971      ERR("failed to grab F12 key to elm widgets (dot) tree generation");
2972 #endif
2973
2974    if ((_elm_config->softcursor_mode == ELM_SOFTCURSOR_MODE_ON) ||
2975        ((_elm_config->softcursor_mode == ELM_SOFTCURSOR_MODE_AUTO) &&
2976            (((fallback) && (!strcmp(fallback, "Software FB"))) ||
2977                ((!fallback) && (ENGINE_COMPARE(ELM_SOFTWARE_FB))))))
2978      {
2979         Evas_Object *o;
2980         Evas_Coord mw = 1, mh = 1, hx = 0, hy = 0;
2981
2982         sd->pointer.obj = o = edje_object_add(ecore_evas_get(tmp_sd.ee));
2983         _elm_theme_object_set(obj, o, "pointer", "base", "default");
2984         edje_object_size_min_calc(o, &mw, &mh);
2985         evas_object_resize(o, mw, mh);
2986         edje_object_part_geometry_get(o, "elm.swallow.hotspot",
2987                                       &hx, &hy, NULL, NULL);
2988         sd->pointer.hot_x = hx;
2989         sd->pointer.hot_y = hy;
2990         evas_object_show(o);
2991         ecore_evas_object_cursor_set(tmp_sd.ee, o, EVAS_LAYER_MAX, hx, hy);
2992      }
2993    else if (_elm_config->softcursor_mode == ELM_SOFTCURSOR_MODE_OFF)
2994      {
2995         // do nothing
2996      }
2997
2998    sd->wm_rot.wm_supported = ecore_evas_wm_rotation_supported_get(sd->ee);
2999    sd->wm_rot.preferred_rot = -1; // it means that elm_win doesn't use preferred rotation.
3000
3001    return obj;
3002 }
3003
3004 EAPI Evas_Object *
3005 elm_win_util_standard_add(const char *name,
3006                           const char *title)
3007 {
3008    Evas_Object *win, *bg;
3009
3010    win = elm_win_add(NULL, name, ELM_WIN_BASIC);
3011    if (!win) return NULL;
3012
3013    elm_win_title_set(win, title);
3014    bg = elm_bg_add(win);
3015    if (!bg)
3016      {
3017         evas_object_del(win);
3018         return NULL;
3019      }
3020    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3021    elm_win_resize_object_add(win, bg);
3022    evas_object_show(bg);
3023
3024    return win;
3025 }
3026
3027 EAPI void
3028 elm_win_resize_object_add(Evas_Object *obj,
3029                           Evas_Object *subobj)
3030 {
3031    Evas_Coord w, h;
3032
3033    ELM_WIN_CHECK(obj);
3034    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3035
3036    if (eina_list_data_find(sd->resize_objs, subobj)) return;
3037
3038    if (!ELM_WIDGET_DATA(sd)->api->sub_object_add(obj, subobj))
3039      ERR("could not add %p as sub object of %p", subobj, obj);
3040
3041    sd->resize_objs = eina_list_append(sd->resize_objs, subobj);
3042
3043    evas_object_event_callback_add
3044      (subobj, EVAS_CALLBACK_DEL, _elm_win_on_resize_obj_del, obj);
3045    evas_object_event_callback_add
3046      (subobj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
3047      _elm_win_on_resize_obj_changed_size_hints, obj);
3048
3049    evas_object_geometry_get(obj, NULL, NULL, &w, &h);
3050    evas_object_move(subobj, 0, 0);
3051    evas_object_resize(subobj, w, h);
3052
3053    _elm_win_resize_objects_eval(obj);
3054 }
3055
3056 EAPI void
3057 elm_win_resize_object_del(Evas_Object *obj,
3058                           Evas_Object *subobj)
3059 {
3060    ELM_WIN_CHECK(obj);
3061    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3062
3063    if (!ELM_WIDGET_DATA(sd)->api->sub_object_del(obj, subobj))
3064      ERR("could not remove sub object %p from %p", subobj, obj);
3065
3066    sd->resize_objs = eina_list_remove(sd->resize_objs, subobj);
3067
3068    evas_object_event_callback_del_full
3069      (subobj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
3070      _elm_win_on_resize_obj_changed_size_hints, obj);
3071    evas_object_event_callback_del_full
3072      (subobj, EVAS_CALLBACK_DEL, _elm_win_on_resize_obj_del, obj);
3073
3074    _elm_win_resize_objects_eval(obj);
3075 }
3076
3077 EAPI void
3078 elm_win_title_set(Evas_Object *obj,
3079                   const char *title)
3080 {
3081    ELM_WIN_CHECK(obj);
3082    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3083
3084    if (!title) return;
3085    eina_stringshare_replace(&(sd->title), title);
3086    TRAP(sd, title_set, sd->title);
3087    if (sd->frame_obj)
3088      edje_object_part_text_escaped_set
3089        (sd->frame_obj, "elm.text.title", sd->title);
3090 }
3091
3092 EAPI const char *
3093 elm_win_title_get(const Evas_Object *obj)
3094 {
3095    ELM_WIN_CHECK(obj) NULL;
3096    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, NULL);
3097
3098    return sd->title;
3099 }
3100
3101 EAPI void
3102 elm_win_icon_name_set(Evas_Object *obj,
3103                       const char *icon_name)
3104 {
3105    ELM_WIN_CHECK(obj);
3106    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3107
3108    if (!icon_name) return;
3109    eina_stringshare_replace(&(sd->icon_name), icon_name);
3110 #ifdef HAVE_ELEMENTARY_X
3111    _elm_win_xwin_update(sd);
3112 #endif
3113 }
3114
3115 EAPI const char *
3116 elm_win_icon_name_get(const Evas_Object *obj)
3117 {
3118    ELM_WIN_CHECK(obj) NULL;
3119    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, NULL);
3120
3121    return sd->icon_name;
3122 }
3123
3124 EAPI void
3125 elm_win_role_set(Evas_Object *obj, const char *role)
3126 {
3127    ELM_WIN_CHECK(obj);
3128    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3129
3130    if (!role) return;
3131    eina_stringshare_replace(&(sd->role), role);
3132 #ifdef HAVE_ELEMENTARY_X
3133    _elm_win_xwin_update(sd);
3134 #endif
3135 }
3136
3137 EAPI const char *
3138 elm_win_role_get(const Evas_Object *obj)
3139 {
3140    ELM_WIN_CHECK(obj) NULL;
3141    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, NULL);
3142
3143    return sd->role;
3144 }
3145
3146 EAPI void
3147 elm_win_icon_object_set(Evas_Object *obj,
3148                         Evas_Object *icon)
3149 {
3150    ELM_WIN_CHECK(obj);
3151    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3152
3153    if (sd->icon)
3154      evas_object_event_callback_del_full
3155        (sd->icon, EVAS_CALLBACK_DEL, _elm_win_on_icon_del, sd);
3156    sd->icon = icon;
3157    if (sd->icon)
3158      evas_object_event_callback_add
3159        (sd->icon, EVAS_CALLBACK_DEL, _elm_win_on_icon_del, sd);
3160 #ifdef HAVE_ELEMENTARY_X
3161    _elm_win_xwin_update(sd);
3162 #endif
3163 }
3164
3165 EAPI const Evas_Object *
3166 elm_win_icon_object_get(const Evas_Object *obj)
3167 {
3168    ELM_WIN_CHECK(obj) NULL;
3169    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, NULL);
3170
3171    return sd->icon;
3172 }
3173
3174 EAPI void
3175 elm_win_autodel_set(Evas_Object *obj,
3176                     Eina_Bool autodel)
3177 {
3178    ELM_WIN_CHECK(obj);
3179    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3180
3181    sd->autodel = autodel;
3182 }
3183
3184 EAPI Eina_Bool
3185 elm_win_autodel_get(const Evas_Object *obj)
3186 {
3187    ELM_WIN_CHECK(obj) EINA_FALSE;
3188    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
3189
3190    return sd->autodel;
3191 }
3192
3193 EAPI void
3194 elm_win_activate(Evas_Object *obj)
3195 {
3196    ELM_WIN_CHECK(obj);
3197    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3198
3199    TRAP(sd, activate);
3200 }
3201
3202 EAPI void
3203 elm_win_lower(Evas_Object *obj)
3204 {
3205    ELM_WIN_CHECK(obj);
3206    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3207
3208    TRAP(sd, lower);
3209 }
3210
3211 EAPI void
3212 elm_win_raise(Evas_Object *obj)
3213 {
3214    ELM_WIN_CHECK(obj);
3215    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3216
3217    TRAP(sd, raise);
3218 }
3219
3220 EAPI void
3221 elm_win_center(Evas_Object *obj,
3222                Eina_Bool h,
3223                Eina_Bool v)
3224 {
3225    int win_w, win_h, screen_w, screen_h, nx, ny;
3226
3227    ELM_WIN_CHECK(obj);
3228    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3229
3230    if ((trap) && (trap->center) && (!trap->center(sd->trap_data, obj)))
3231      return;
3232
3233    ecore_evas_screen_geometry_get(sd->ee, NULL, NULL, &screen_w, &screen_h);
3234    if ((!screen_w) || (!screen_h)) return;
3235
3236    evas_object_geometry_get(obj, NULL, NULL, &win_w, &win_h);
3237    if ((!win_w) || (!win_h)) return;
3238
3239    if (h) nx = win_w >= screen_w ? 0 : (screen_w / 2) - (win_w / 2);
3240    else nx = sd->screen.x;
3241    if (v) ny = win_h >= screen_h ? 0 : (screen_h / 2) - (win_h / 2);
3242    else ny = sd->screen.y;
3243    if (nx < 0) nx = 0;
3244    if (ny < 0) ny = 0;
3245
3246    evas_object_move(obj, nx, ny);
3247 }
3248
3249 EAPI void
3250 elm_win_borderless_set(Evas_Object *obj,
3251                        Eina_Bool borderless)
3252 {
3253    ELM_WIN_CHECK(obj);
3254    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3255
3256    TRAP(sd, borderless_set, borderless);
3257 #ifdef HAVE_ELEMENTARY_X
3258    _elm_win_xwin_update(sd);
3259 #endif
3260 }
3261
3262 EAPI Eina_Bool
3263 elm_win_borderless_get(const Evas_Object *obj)
3264 {
3265    ELM_WIN_CHECK(obj) EINA_FALSE;
3266    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
3267
3268    return ecore_evas_borderless_get(sd->ee);
3269 }
3270
3271 EAPI void
3272 elm_win_shaped_set(Evas_Object *obj,
3273                    Eina_Bool shaped)
3274 {
3275    ELM_WIN_CHECK(obj);
3276    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3277
3278    TRAP(sd, shaped_set, shaped);
3279 #ifdef HAVE_ELEMENTARY_X
3280    _elm_win_xwin_update(sd);
3281 #endif
3282 }
3283
3284 EAPI Eina_Bool
3285 elm_win_shaped_get(const Evas_Object *obj)
3286 {
3287    ELM_WIN_CHECK(obj) EINA_FALSE;
3288    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
3289
3290    return ecore_evas_shaped_get(sd->ee);
3291 }
3292
3293 EAPI void
3294 elm_win_alpha_set(Evas_Object *obj,
3295                   Eina_Bool alpha)
3296 {
3297    ELM_WIN_CHECK(obj);
3298    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3299
3300    if (sd->img_obj)
3301      {
3302         evas_object_image_alpha_set(sd->img_obj, alpha);
3303         ecore_evas_alpha_set(sd->ee, alpha);
3304      }
3305    else
3306      {
3307 #ifdef HAVE_ELEMENTARY_X
3308         if (sd->x.xwin)
3309           {
3310              if (alpha)
3311                {
3312                   if (!ecore_x_screen_is_composited(0))
3313                     elm_win_shaped_set(obj, alpha);
3314                   else
3315                     TRAP(sd, alpha_set, alpha);
3316                }
3317              else
3318                TRAP(sd, alpha_set, alpha);
3319              _elm_win_xwin_update(sd);
3320           }
3321         else
3322 #endif
3323           TRAP(sd, alpha_set, alpha);
3324      }
3325 }
3326
3327 EAPI Eina_Bool
3328 elm_win_alpha_get(const Evas_Object *obj)
3329 {
3330    ELM_WIN_CHECK(obj) EINA_FALSE;
3331    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
3332
3333    if (sd->img_obj)
3334      {
3335         return evas_object_image_alpha_get(sd->img_obj);
3336      }
3337
3338    return ecore_evas_alpha_get(sd->ee);
3339 }
3340
3341 EAPI void
3342 elm_win_override_set(Evas_Object *obj,
3343                      Eina_Bool override)
3344 {
3345    ELM_WIN_CHECK(obj);
3346    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3347
3348    TRAP(sd, override_set, override);
3349 #ifdef HAVE_ELEMENTARY_X
3350    _elm_win_xwin_update(sd);
3351 #endif
3352 }
3353
3354 EAPI Eina_Bool
3355 elm_win_override_get(const Evas_Object *obj)
3356 {
3357    ELM_WIN_CHECK(obj) EINA_FALSE;
3358    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
3359
3360    return ecore_evas_override_get(sd->ee);
3361 }
3362
3363 EAPI void
3364 elm_win_fullscreen_set(Evas_Object *obj,
3365                        Eina_Bool fullscreen)
3366 {
3367    ELM_WIN_CHECK(obj);
3368    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3369    // YYY: handle if sd->img_obj
3370    if (ENGINE_COMPARE(ELM_SOFTWARE_FB) ||
3371        ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE))
3372      {
3373         // these engines... can ONLY be fullscreen
3374         return;
3375      }
3376    else
3377      {
3378 //        sd->fullscreen = fullscreen;
3379
3380         if (fullscreen)
3381           {
3382              if (ENGINE_COMPARE(ELM_WAYLAND_SHM) ||
3383                  ENGINE_COMPARE(ELM_WAYLAND_EGL))
3384                _elm_win_frame_del(sd);
3385           }
3386         else
3387           {
3388              if (ENGINE_COMPARE(ELM_WAYLAND_SHM) ||
3389                  ENGINE_COMPARE(ELM_WAYLAND_EGL))
3390                _elm_win_frame_add(sd, "default");
3391
3392              evas_object_show(sd->frame_obj);
3393           }
3394
3395         TRAP(sd, fullscreen_set, fullscreen);
3396 #ifdef HAVE_ELEMENTARY_X
3397         _elm_win_xwin_update(sd);
3398 #endif
3399      }
3400 }
3401
3402 EAPI Eina_Bool
3403 elm_win_fullscreen_get(const Evas_Object *obj)
3404 {
3405    ELM_WIN_CHECK(obj) EINA_FALSE;
3406    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
3407
3408    if (ENGINE_COMPARE(ELM_SOFTWARE_FB) ||
3409        ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE))
3410      {
3411         // these engines... can ONLY be fullscreen
3412         return EINA_TRUE;
3413      }
3414    else
3415      {
3416         return sd->fullscreen;
3417      }
3418 }
3419
3420 EAPI void
3421 elm_win_maximized_set(Evas_Object *obj,
3422                       Eina_Bool maximized)
3423 {
3424    ELM_WIN_CHECK(obj);
3425    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3426
3427 //   sd->maximized = maximized;
3428    // YYY: handle if sd->img_obj
3429    TRAP(sd, maximized_set, maximized);
3430 #ifdef HAVE_ELEMENTARY_X
3431    _elm_win_xwin_update(sd);
3432 #endif
3433 }
3434
3435 EAPI Eina_Bool
3436 elm_win_maximized_get(const Evas_Object *obj)
3437 {
3438    ELM_WIN_CHECK(obj) EINA_FALSE;
3439    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
3440
3441    return sd->maximized;
3442 }
3443
3444 EAPI void
3445 elm_win_iconified_set(Evas_Object *obj,
3446                       Eina_Bool iconified)
3447 {
3448    ELM_WIN_CHECK(obj);
3449    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3450
3451 //   sd->iconified = iconified;
3452    TRAP(sd, iconified_set, iconified);
3453 #ifdef HAVE_ELEMENTARY_X
3454    _elm_win_xwin_update(sd);
3455 #endif
3456 }
3457
3458 EAPI Eina_Bool
3459 elm_win_iconified_get(const Evas_Object *obj)
3460 {
3461    ELM_WIN_CHECK(obj) EINA_FALSE;
3462    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
3463
3464    return sd->iconified;
3465 }
3466
3467 EAPI void
3468 elm_win_withdrawn_set(Evas_Object *obj,
3469                       Eina_Bool withdrawn)
3470 {
3471    ELM_WIN_CHECK(obj);
3472    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3473
3474 //   sd->withdrawn = withdrawn;
3475    TRAP(sd, withdrawn_set, withdrawn);
3476 #ifdef HAVE_ELEMENTARY_X
3477    _elm_win_xwin_update(sd);
3478 #endif
3479 }
3480
3481 EAPI Eina_Bool
3482 elm_win_withdrawn_get(const Evas_Object *obj)
3483 {
3484    ELM_WIN_CHECK(obj) EINA_FALSE;
3485    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
3486
3487    return sd->withdrawn;
3488 }
3489
3490 EAPI void
3491 elm_win_profiles_set(Evas_Object  *obj,
3492                      const char  **profiles,
3493                      unsigned int  num_profiles)
3494 {
3495    char **profiles_int;
3496    const char *str;
3497    unsigned int i, num;
3498    Eina_List *l;
3499
3500    ELM_WIN_CHECK(obj);
3501    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3502
3503    if (!profiles) return;
3504
3505    if (sd->profile.timer) ecore_timer_del(sd->profile.timer);
3506    sd->profile.timer = ecore_timer_add(0.1, _elm_win_profile_change_delay, sd);
3507    EINA_LIST_FREE(sd->profile.names, str) eina_stringshare_del(str);
3508
3509    for (i = 0; i < num_profiles; i++)
3510      {
3511         if ((profiles[i]) &&
3512             _elm_config_profile_exists(profiles[i]))
3513           {
3514              str = eina_stringshare_add(profiles[i]);
3515              sd->profile.names = eina_list_append(sd->profile.names, str);
3516           }
3517      }
3518
3519    num = eina_list_count(sd->profile.names);
3520    profiles_int = alloca(num * sizeof(char *));
3521
3522    if (profiles_int)
3523      {
3524         i = 0;
3525         EINA_LIST_FOREACH(sd->profile.names, l, str)
3526           {
3527              if (str)
3528                profiles_int[i] = strdup(str);
3529              else
3530                profiles_int[i] = NULL;
3531              i++;
3532           }
3533         ecore_evas_profiles_set(sd->ee, (const char **)profiles_int, i);
3534         for (i = 0; i < num; i++)
3535           {
3536              if (profiles_int[i]) free(profiles_int[i]);
3537           }
3538      }
3539    else
3540      ecore_evas_profiles_set(sd->ee, profiles, num_profiles);
3541 }
3542
3543 EAPI const char *
3544 elm_win_profile_get(const Evas_Object *obj)
3545 {
3546    ELM_WIN_CHECK(obj) NULL;
3547    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, NULL);
3548
3549    return sd->profile.name;
3550 }
3551
3552 EAPI void
3553 elm_win_urgent_set(Evas_Object *obj,
3554                    Eina_Bool urgent)
3555 {
3556    ELM_WIN_CHECK(obj);
3557    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3558
3559    sd->urgent = urgent;
3560    TRAP(sd, urgent_set, urgent);
3561 #ifdef HAVE_ELEMENTARY_X
3562    _elm_win_xwin_update(sd);
3563 #endif
3564 }
3565
3566 EAPI Eina_Bool
3567 elm_win_urgent_get(const Evas_Object *obj)
3568 {
3569    ELM_WIN_CHECK(obj) EINA_FALSE;
3570    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
3571
3572    return sd->urgent;
3573 }
3574
3575 EAPI void
3576 elm_win_demand_attention_set(Evas_Object *obj,
3577                              Eina_Bool demand_attention)
3578 {
3579    ELM_WIN_CHECK(obj);
3580    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3581
3582    sd->demand_attention = demand_attention;
3583    TRAP(sd, demand_attention_set, demand_attention);
3584 #ifdef HAVE_ELEMENTARY_X
3585    _elm_win_xwin_update(sd);
3586 #endif
3587 }
3588
3589 EAPI Eina_Bool
3590 elm_win_demand_attention_get(const Evas_Object *obj)
3591 {
3592    ELM_WIN_CHECK(obj) EINA_FALSE;
3593    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
3594
3595    return sd->demand_attention;
3596 }
3597
3598 EAPI void
3599 elm_win_modal_set(Evas_Object *obj,
3600                   Eina_Bool modal)
3601 {
3602    ELM_WIN_CHECK(obj);
3603    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3604
3605    sd->modal = modal;
3606    TRAP(sd, modal_set, modal);
3607 #ifdef HAVE_ELEMENTARY_X
3608    _elm_win_xwin_update(sd);
3609 #endif
3610 }
3611
3612 EAPI Eina_Bool
3613 elm_win_modal_get(const Evas_Object *obj)
3614 {
3615    ELM_WIN_CHECK(obj) EINA_FALSE;
3616    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
3617
3618    return sd->modal;
3619 }
3620
3621 EAPI void
3622 elm_win_aspect_set(Evas_Object *obj,
3623                    double aspect)
3624 {
3625    ELM_WIN_CHECK(obj);
3626    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3627
3628    sd->aspect = aspect;
3629    TRAP(sd, aspect_set, aspect);
3630 #ifdef HAVE_ELEMENTARY_X
3631    _elm_win_xwin_update(sd);
3632 #endif
3633 }
3634
3635 EAPI double
3636 elm_win_aspect_get(const Evas_Object *obj)
3637 {
3638    ELM_WIN_CHECK(obj) 0.0;
3639    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, 0.0);
3640
3641    return sd->aspect;
3642 }
3643
3644 EAPI void
3645 elm_win_size_base_set(Evas_Object *obj, int w, int h)
3646 {
3647    ELM_WIN_CHECK(obj);
3648    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3649    sd->size_base_w = w;
3650    sd->size_base_h = h;
3651    TRAP(sd, size_base_set, w, h);
3652 #ifdef HAVE_ELEMENTARY_X
3653    _elm_win_xwin_update(sd);
3654 #endif
3655 }
3656
3657 EAPI void
3658 elm_win_size_base_get(Evas_Object *obj, int *w, int *h)
3659 {
3660    ELM_WIN_CHECK(obj);
3661    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3662    if (w) *w = sd->size_base_w;
3663    if (w) *h = sd->size_base_h;
3664 }
3665
3666 EAPI void
3667 elm_win_size_step_set(Evas_Object *obj, int w, int h)
3668 {
3669    ELM_WIN_CHECK(obj);
3670    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3671    sd->size_step_w = w;
3672    sd->size_step_h = h;
3673    TRAP(sd, size_step_set, w, h);
3674 #ifdef HAVE_ELEMENTARY_X
3675    _elm_win_xwin_update(sd);
3676 #endif
3677 }
3678
3679 EAPI void
3680 elm_win_size_step_get(Evas_Object *obj, int *w, int *h)
3681 {
3682    ELM_WIN_CHECK(obj);
3683    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3684    if (w) *w = sd->size_step_w;
3685    if (w) *h = sd->size_step_h;
3686 }
3687
3688 EAPI void
3689 elm_win_layer_set(Evas_Object *obj,
3690                   int layer)
3691 {
3692    ELM_WIN_CHECK(obj);
3693    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3694
3695    TRAP(sd, layer_set, layer);
3696 #ifdef HAVE_ELEMENTARY_X
3697    _elm_win_xwin_update(sd);
3698 #endif
3699 }
3700
3701 EAPI int
3702 elm_win_layer_get(const Evas_Object *obj)
3703 {
3704    ELM_WIN_CHECK(obj) - 1;
3705    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, -1);
3706
3707    return ecore_evas_layer_get(sd->ee);
3708 }
3709
3710 EAPI void
3711 elm_win_norender_push(Evas_Object *obj)
3712 {
3713    ELM_WIN_CHECK(obj);
3714    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3715
3716    sd->norender++;
3717    if (sd->norender == 1) ecore_evas_manual_render_set(sd->ee, EINA_TRUE);
3718 }
3719
3720 EAPI void
3721 elm_win_norender_pop(Evas_Object *obj)
3722 {
3723    ELM_WIN_CHECK(obj);
3724    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3725
3726    if (sd->norender <= 0) return;
3727    sd->norender--;
3728    if (sd->norender == 0) ecore_evas_manual_render_set(sd->ee, EINA_FALSE);
3729 }
3730
3731 EAPI int
3732 elm_win_norender_get(Evas_Object *obj)
3733 {
3734    ELM_WIN_CHECK(obj) - 1;
3735    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, -1);
3736    return sd->norender;
3737 }
3738
3739 EAPI void
3740 elm_win_render(Evas_Object *obj)
3741 {
3742    ELM_WIN_CHECK(obj);
3743    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3744    ecore_evas_manual_render(sd->ee);
3745 }
3746
3747 static int
3748 _win_rotation_degree_check(int rotation)
3749 {
3750    if ((rotation > 360) || (rotation < 0))
3751      {
3752         WRN("Rotation degree should be 0 ~ 360 (passed degree: %d)", rotation);
3753         rotation %= 360;
3754         if (rotation < 0) rotation += 360;
3755      }
3756    return rotation;
3757 }
3758
3759 static void
3760 _win_rotate(Evas_Object *obj, Elm_Win_Smart_Data *sd, int rotation, Eina_Bool resize)
3761 {
3762    rotation = _win_rotation_degree_check(rotation);
3763    if (sd->rot == rotation) return;
3764    sd->rot = rotation;
3765    if (resize) TRAP(sd, rotation_with_resize_set, rotation);
3766    else TRAP(sd, rotation_set, rotation);
3767    evas_object_size_hint_min_set(obj, -1, -1);
3768    evas_object_size_hint_max_set(obj, -1, -1);
3769    _elm_win_resize_objects_eval(obj);
3770 #ifdef HAVE_ELEMENTARY_X
3771    _elm_win_xwin_update(sd);
3772 #endif
3773    elm_widget_orientation_set(obj, rotation);
3774    evas_object_smart_callback_call(obj, SIG_ROTATION_CHANGED, NULL);
3775 }
3776
3777 EAPI void
3778 elm_win_rotation_set(Evas_Object *obj,
3779                      int rotation)
3780 {
3781    ELM_WIN_CHECK(obj);
3782    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3783    _win_rotate(obj, sd, rotation, EINA_FALSE);
3784 }
3785
3786 EAPI void
3787 elm_win_rotation_with_resize_set(Evas_Object *obj,
3788                                  int rotation)
3789 {
3790    ELM_WIN_CHECK(obj);
3791    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3792    _win_rotate(obj, sd, rotation, EINA_TRUE);
3793 }
3794
3795 EAPI int
3796 elm_win_rotation_get(const Evas_Object *obj)
3797 {
3798    ELM_WIN_CHECK(obj) - 1;
3799    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, -1);
3800
3801    return sd->rot;
3802 }
3803
3804 EAPI Eina_Bool
3805 elm_win_wm_rotation_supported_get(const Evas_Object *obj)
3806 {
3807    ELM_WIN_CHECK(obj) EINA_FALSE;
3808    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
3809    return sd->wm_rot.wm_supported;
3810 }
3811
3812 /* This will unset a preferred rotation, if given preferred rotation is '-1'.
3813  */
3814 EAPI void
3815 elm_win_wm_rotation_preferred_rotation_set(Evas_Object *obj,
3816                                            const int rotation)
3817 {
3818    int rot;
3819
3820    ELM_WIN_CHECK(obj);
3821    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3822
3823    if (!sd->wm_rot.use)
3824      sd->wm_rot.use = EINA_TRUE;
3825
3826    // '-1' means that elm_win doesn't use preferred rotation.
3827    if (rotation == -1)
3828      rot = -1;
3829    else
3830      rot = _win_rotation_degree_check(rotation);
3831
3832    if (sd->wm_rot.preferred_rot == rot) return;
3833    sd->wm_rot.preferred_rot = rot;
3834
3835    ecore_evas_wm_rotation_preferred_rotation_set(sd->ee, rot);
3836 }
3837
3838 EAPI int
3839 elm_win_wm_rotation_preferred_rotation_get(const Evas_Object *obj)
3840 {
3841    ELM_WIN_CHECK(obj) -1;
3842    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, -1);
3843    if (!sd->wm_rot.use) return -1;
3844    return sd->wm_rot.preferred_rot;
3845 }
3846
3847 EAPI void
3848 elm_win_wm_rotation_available_rotations_set(Evas_Object *obj,
3849                                             const int   *rotations,
3850                                             unsigned int count)
3851 {
3852    unsigned int i;
3853    int r;
3854
3855    ELM_WIN_CHECK(obj);
3856    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3857
3858    if (!sd->wm_rot.use)
3859      sd->wm_rot.use = EINA_TRUE;
3860
3861    if (sd->wm_rot.rots) free(sd->wm_rot.rots);
3862
3863    sd->wm_rot.rots = NULL;
3864    sd->wm_rot.count = 0;
3865
3866    if (count > 0)
3867      {
3868         sd->wm_rot.rots = calloc(count, sizeof(int));
3869         if (!sd->wm_rot.rots) return;
3870         for (i = 0; i < count; i++)
3871           {
3872              r = _win_rotation_degree_check(rotations[i]);
3873              sd->wm_rot.rots[i] = r;
3874           }
3875      }
3876
3877    sd->wm_rot.count = count;
3878
3879    ecore_evas_wm_rotation_available_rotations_set(sd->ee,
3880                                                   sd->wm_rot.rots,
3881                                                   sd->wm_rot.count);
3882 }
3883
3884 EAPI Eina_Bool
3885 elm_win_wm_rotation_available_rotations_get(const Evas_Object *obj,
3886                                             int              **rotations,
3887                                             unsigned int      *count)
3888 {
3889    ELM_WIN_CHECK(obj) EINA_FALSE;
3890    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
3891    if (!sd->wm_rot.use) return EINA_FALSE;
3892
3893    if (sd->wm_rot.count > 0)
3894      {
3895         if ((rotations) && (*rotations))
3896           {
3897              *rotations = calloc(sd->wm_rot.count, sizeof(int));
3898              if (*rotations)
3899                {
3900                   memcpy(*rotations,
3901                          sd->wm_rot.rots,
3902                          sizeof(int) * sd->wm_rot.count);
3903                }
3904           }
3905      }
3906
3907    if (count) *count = sd->wm_rot.count;
3908
3909    return EINA_TRUE;
3910 }
3911
3912 EAPI void
3913 elm_win_sticky_set(Evas_Object *obj,
3914                    Eina_Bool sticky)
3915 {
3916    ELM_WIN_CHECK(obj);
3917    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3918
3919 //   sd->sticky = sticky;
3920    TRAP(sd, sticky_set, sticky);
3921 #ifdef HAVE_ELEMENTARY_X
3922    _elm_win_xwin_update(sd);
3923 #endif
3924 }
3925
3926 EAPI Eina_Bool
3927 elm_win_sticky_get(const Evas_Object *obj)
3928 {
3929    ELM_WIN_CHECK(obj) EINA_FALSE;
3930    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
3931
3932    return sd->sticky;
3933 }
3934
3935 EAPI void
3936 elm_win_keyboard_mode_set(Evas_Object *obj,
3937                           Elm_Win_Keyboard_Mode mode)
3938 {
3939    ELM_WIN_CHECK(obj);
3940    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3941
3942    if (mode == sd->kbdmode) return;
3943 #ifdef HAVE_ELEMENTARY_X
3944    _elm_win_xwindow_get(sd);
3945 #endif
3946    sd->kbdmode = mode;
3947 #ifdef HAVE_ELEMENTARY_X
3948    if (sd->x.xwin)
3949      ecore_x_e_virtual_keyboard_state_set
3950        (sd->x.xwin, (Ecore_X_Virtual_Keyboard_State)sd->kbdmode);
3951 #endif
3952 }
3953
3954 EAPI Elm_Win_Keyboard_Mode
3955 elm_win_keyboard_mode_get(const Evas_Object *obj)
3956 {
3957    ELM_WIN_CHECK(obj) ELM_WIN_KEYBOARD_UNKNOWN;
3958    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, ELM_WIN_KEYBOARD_UNKNOWN);
3959
3960    return sd->kbdmode;
3961 }
3962
3963 EAPI void
3964 elm_win_keyboard_win_set(Evas_Object *obj,
3965                          Eina_Bool is_keyboard)
3966 {
3967    ELM_WIN_CHECK(obj);
3968    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3969
3970 #ifdef HAVE_ELEMENTARY_X
3971    _elm_win_xwindow_get(sd);
3972    if (sd->x.xwin)
3973      ecore_x_e_virtual_keyboard_set(sd->x.xwin, is_keyboard);
3974 #else
3975    (void)is_keyboard;
3976 #endif
3977 }
3978
3979 EAPI Eina_Bool
3980 elm_win_keyboard_win_get(const Evas_Object *obj)
3981 {
3982    ELM_WIN_CHECK(obj) EINA_FALSE;
3983    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
3984
3985 #ifdef HAVE_ELEMENTARY_X
3986    _elm_win_xwindow_get(sd);
3987    if (sd->x.xwin)
3988      return ecore_x_e_virtual_keyboard_get(sd->x.xwin);
3989 #endif
3990    return EINA_FALSE;
3991 }
3992
3993 EAPI void
3994 elm_win_indicator_mode_set(Evas_Object *obj,
3995                            Elm_Win_Indicator_Mode mode)
3996 {
3997    ELM_WIN_CHECK(obj);
3998    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3999
4000    if (mode == sd->indmode) return;
4001 #ifdef HAVE_ELEMENTARY_X
4002    _elm_win_xwindow_get(sd);
4003 #endif
4004    sd->indmode = mode;
4005 #ifdef HAVE_ELEMENTARY_X
4006    if (sd->x.xwin)
4007      {
4008         if (sd->indmode == ELM_WIN_INDICATOR_SHOW)
4009           ecore_x_e_illume_indicator_state_set
4010             (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_STATE_ON);
4011         else if (sd->indmode == ELM_WIN_INDICATOR_HIDE)
4012           ecore_x_e_illume_indicator_state_set
4013             (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_STATE_OFF);
4014      }
4015 #endif
4016    evas_object_smart_callback_call(obj, SIG_INDICATOR_PROP_CHANGED, NULL);
4017 }
4018
4019 EAPI Elm_Win_Indicator_Mode
4020 elm_win_indicator_mode_get(const Evas_Object *obj)
4021 {
4022    ELM_WIN_CHECK(obj) ELM_WIN_INDICATOR_UNKNOWN;
4023    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, ELM_WIN_INDICATOR_UNKNOWN);
4024
4025    return sd->indmode;
4026 }
4027
4028 EAPI void
4029 elm_win_indicator_opacity_set(Evas_Object *obj,
4030                               Elm_Win_Indicator_Opacity_Mode mode)
4031 {
4032    ELM_WIN_CHECK(obj);
4033    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4034
4035    if (mode == sd->ind_o_mode) return;
4036    sd->ind_o_mode = mode;
4037 #ifdef HAVE_ELEMENTARY_X
4038    _elm_win_xwindow_get(sd);
4039    if (sd->x.xwin)
4040      {
4041         if (sd->ind_o_mode == ELM_WIN_INDICATOR_OPAQUE)
4042           ecore_x_e_illume_indicator_opacity_set
4043             (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_OPAQUE);
4044         else if (sd->ind_o_mode == ELM_WIN_INDICATOR_TRANSLUCENT)
4045           ecore_x_e_illume_indicator_opacity_set
4046             (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_TRANSLUCENT);
4047         else if (sd->ind_o_mode == ELM_WIN_INDICATOR_TRANSPARENT)
4048           ecore_x_e_illume_indicator_opacity_set
4049             (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_TRANSPARENT);
4050      }
4051 #endif
4052    evas_object_smart_callback_call(obj, SIG_INDICATOR_PROP_CHANGED, NULL);
4053 }
4054
4055 EAPI Elm_Win_Indicator_Opacity_Mode
4056 elm_win_indicator_opacity_get(const Evas_Object *obj)
4057 {
4058    ELM_WIN_CHECK(obj) ELM_WIN_INDICATOR_OPACITY_UNKNOWN;
4059    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, ELM_WIN_INDICATOR_OPACITY_UNKNOWN);
4060
4061    return sd->ind_o_mode;
4062 }
4063
4064 EAPI void
4065 elm_win_indicator_type_set(Evas_Object *obj,
4066                               Elm_Win_Indicator_Type_Mode mode)
4067 {
4068    ELM_WIN_CHECK(obj);
4069    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4070
4071    if (mode == sd->ind_t_mode) return;
4072    sd->ind_t_mode = mode;
4073 #ifdef HAVE_ELEMENTARY_X
4074    _elm_win_xwindow_get(sd);
4075    if (sd->x.xwin)
4076      {
4077         if (sd->ind_t_mode == ELM_WIN_INDICATOR_TYPE_1)
4078           ecore_x_e_illume_indicator_type_set
4079             (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_TYPE_1);
4080         else if (sd->ind_t_mode == ELM_WIN_INDICATOR_TYPE_2)
4081           ecore_x_e_illume_indicator_type_set
4082             (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_TYPE_2);
4083      }
4084 #endif
4085    //evas_object_smart_callback_call(obj, SIG_INDICATOR_PROP_CHANGED, NULL);
4086 }
4087
4088 EAPI Elm_Win_Indicator_Type_Mode
4089 elm_win_indicator_type_get(const Evas_Object *obj)
4090 {
4091    ELM_WIN_CHECK(obj) ELM_WIN_INDICATOR_TYPE_UNKNOWN;
4092    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, ELM_WIN_INDICATOR_TYPE_UNKNOWN);
4093
4094    return sd->ind_t_mode;
4095 }
4096 EAPI void
4097 elm_win_screen_position_get(const Evas_Object *obj,
4098                             int *x,
4099                             int *y)
4100 {
4101    ELM_WIN_CHECK(obj);
4102    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4103
4104    if (x) *x = sd->screen.x;
4105    if (y) *y = sd->screen.y;
4106 }
4107
4108 EAPI Eina_Bool
4109 elm_win_focus_get(const Evas_Object *obj)
4110 {
4111    ELM_WIN_CHECK(obj) EINA_FALSE;
4112    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
4113
4114    return ecore_evas_focus_get(sd->ee);
4115 }
4116
4117 EAPI void
4118 elm_win_screen_constrain_set(Evas_Object *obj,
4119                              Eina_Bool constrain)
4120 {
4121    ELM_WIN_CHECK(obj);
4122    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4123
4124    sd->constrain = !!constrain;
4125 }
4126
4127 EAPI Eina_Bool
4128 elm_win_screen_constrain_get(Evas_Object *obj)
4129 {
4130    ELM_WIN_CHECK(obj) EINA_FALSE;
4131    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
4132
4133    return sd->constrain;
4134 }
4135
4136 EAPI void
4137 elm_win_screen_size_get(const Evas_Object *obj,
4138                         int *x,
4139                         int *y,
4140                         int *w,
4141                         int *h)
4142 {
4143    ELM_WIN_CHECK(obj);
4144    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4145
4146    ecore_evas_screen_geometry_get(sd->ee, x, y, w, h);
4147 }
4148
4149 EAPI void
4150 elm_win_screen_dpi_get(const Evas_Object *obj,
4151                        int *xdpi,
4152                        int *ydpi)
4153 {
4154    ELM_WIN_CHECK(obj);
4155    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4156
4157    ecore_evas_screen_dpi_get(sd->ee, xdpi, ydpi);
4158 }
4159
4160 EAPI void
4161 elm_win_conformant_set(Evas_Object *obj,
4162                        Eina_Bool conformant)
4163 {
4164    ELM_WIN_CHECK(obj);
4165    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4166
4167 #ifdef HAVE_ELEMENTARY_X
4168    _elm_win_xwindow_get(sd);
4169    if (sd->x.xwin)
4170      ecore_x_e_illume_conformant_set(sd->x.xwin, conformant);
4171 #else
4172    (void)conformant;
4173 #endif
4174 }
4175
4176 EAPI Eina_Bool
4177 elm_win_conformant_get(const Evas_Object *obj)
4178 {
4179    ELM_WIN_CHECK(obj) EINA_FALSE;
4180    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
4181
4182 #ifdef HAVE_ELEMENTARY_X
4183    _elm_win_xwindow_get(sd);
4184    if (sd->x.xwin)
4185      return ecore_x_e_illume_conformant_get(sd->x.xwin);
4186 #endif
4187    return EINA_FALSE;
4188 }
4189
4190 EAPI void
4191 elm_win_quickpanel_set(Evas_Object *obj,
4192                        Eina_Bool quickpanel)
4193 {
4194    ELM_WIN_CHECK(obj);
4195    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4196 #ifdef HAVE_ELEMENTARY_X
4197    _elm_win_xwindow_get(sd);
4198    if (sd->x.xwin)
4199      {
4200         ecore_x_e_illume_quickpanel_set(sd->x.xwin, quickpanel);
4201         if (quickpanel)
4202           {
4203              Ecore_X_Window_State states[2];
4204
4205              states[0] = ECORE_X_WINDOW_STATE_SKIP_TASKBAR;
4206              states[1] = ECORE_X_WINDOW_STATE_SKIP_PAGER;
4207              ecore_x_netwm_window_state_set(sd->x.xwin, states, 2);
4208              ecore_x_icccm_hints_set(sd->x.xwin, 0, 0, 0, 0, 0, 0, 0);
4209           }
4210      }
4211 #else
4212    (void)quickpanel;
4213 #endif
4214 }
4215
4216 EAPI Eina_Bool
4217 elm_win_quickpanel_get(const Evas_Object *obj)
4218 {
4219    ELM_WIN_CHECK(obj) EINA_FALSE;
4220    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
4221
4222 #ifdef HAVE_ELEMENTARY_X
4223    _elm_win_xwindow_get(sd);
4224    if (sd->x.xwin)
4225      return ecore_x_e_illume_quickpanel_get(sd->x.xwin);
4226 #endif
4227    return EINA_FALSE;
4228 }
4229
4230 EAPI void
4231 elm_win_quickpanel_priority_major_set(Evas_Object *obj,
4232                                       int priority)
4233 {
4234    ELM_WIN_CHECK(obj);
4235    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4236
4237 #ifdef HAVE_ELEMENTARY_X
4238    _elm_win_xwindow_get(sd);
4239    if (sd->x.xwin)
4240      ecore_x_e_illume_quickpanel_priority_major_set(sd->x.xwin, priority);
4241 #else
4242    (void)priority;
4243 #endif
4244 }
4245
4246 EAPI int
4247 elm_win_quickpanel_priority_major_get(const Evas_Object *obj)
4248 {
4249    ELM_WIN_CHECK(obj) - 1;
4250    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, -1);
4251
4252 #ifdef HAVE_ELEMENTARY_X
4253    _elm_win_xwindow_get(sd);
4254    if (sd->x.xwin)
4255      return ecore_x_e_illume_quickpanel_priority_major_get(sd->x.xwin);
4256 #endif
4257    return -1;
4258 }
4259
4260 EAPI void
4261 elm_win_quickpanel_priority_minor_set(Evas_Object *obj,
4262                                       int priority)
4263 {
4264    ELM_WIN_CHECK(obj);
4265    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4266
4267 #ifdef HAVE_ELEMENTARY_X
4268    _elm_win_xwindow_get(sd);
4269    if (sd->x.xwin)
4270      ecore_x_e_illume_quickpanel_priority_minor_set(sd->x.xwin, priority);
4271 #else
4272    (void)priority;
4273 #endif
4274 }
4275
4276 EAPI int
4277 elm_win_quickpanel_priority_minor_get(const Evas_Object *obj)
4278 {
4279    ELM_WIN_CHECK(obj) - 1;
4280    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, -1);
4281
4282 #ifdef HAVE_ELEMENTARY_X
4283    _elm_win_xwindow_get(sd);
4284    if (sd->x.xwin)
4285      return ecore_x_e_illume_quickpanel_priority_minor_get(sd->x.xwin);
4286 #endif
4287    return -1;
4288 }
4289
4290 EAPI void
4291 elm_win_quickpanel_zone_set(Evas_Object *obj,
4292                             int zone)
4293 {
4294    ELM_WIN_CHECK(obj);
4295    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4296
4297 #ifdef HAVE_ELEMENTARY_X
4298    _elm_win_xwindow_get(sd);
4299    if (sd->x.xwin)
4300      ecore_x_e_illume_quickpanel_zone_set(sd->x.xwin, zone);
4301 #else
4302    (void)zone;
4303 #endif
4304 }
4305
4306 EAPI int
4307 elm_win_quickpanel_zone_get(const Evas_Object *obj)
4308 {
4309    ELM_WIN_CHECK(obj) 0;
4310    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, 0);
4311
4312 #ifdef HAVE_ELEMENTARY_X
4313    _elm_win_xwindow_get(sd);
4314    if (sd->x.xwin)
4315      return ecore_x_e_illume_quickpanel_zone_get(sd->x.xwin);
4316 #endif
4317    return 0;
4318 }
4319
4320 EAPI void
4321 elm_win_prop_focus_skip_set(Evas_Object *obj,
4322                             Eina_Bool skip)
4323 {
4324    ELM_WIN_CHECK(obj);
4325    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4326
4327    sd->skip_focus = skip;
4328    TRAP(sd, focus_skip_set, skip);
4329 }
4330
4331 EAPI void
4332 elm_win_illume_command_send(Evas_Object *obj,
4333                             Elm_Illume_Command command,
4334                             void *params __UNUSED__)
4335 {
4336    ELM_WIN_CHECK(obj);
4337    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4338
4339 #ifdef HAVE_ELEMENTARY_X
4340    _elm_win_xwindow_get(sd);
4341    if (sd->x.xwin)
4342      {
4343         switch (command)
4344           {
4345            case ELM_ILLUME_COMMAND_FOCUS_BACK:
4346              ecore_x_e_illume_focus_back_send(sd->x.xwin);
4347              break;
4348
4349            case ELM_ILLUME_COMMAND_FOCUS_FORWARD:
4350              ecore_x_e_illume_focus_forward_send(sd->x.xwin);
4351              break;
4352
4353            case ELM_ILLUME_COMMAND_FOCUS_HOME:
4354              ecore_x_e_illume_focus_home_send(sd->x.xwin);
4355              break;
4356
4357            case ELM_ILLUME_COMMAND_CLOSE:
4358              ecore_x_e_illume_close_send(sd->x.xwin);
4359              break;
4360
4361            default:
4362              break;
4363           }
4364      }
4365 #else
4366    (void)command;
4367 #endif
4368 }
4369
4370 EAPI Evas_Object *
4371 elm_win_inlined_image_object_get(Evas_Object *obj)
4372 {
4373    ELM_WIN_CHECK(obj) NULL;
4374    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, NULL);
4375
4376    return sd->img_obj;
4377 }
4378
4379 EAPI void
4380 elm_win_focus_highlight_enabled_set(Evas_Object *obj,
4381                                     Eina_Bool enabled)
4382 {
4383    ELM_WIN_CHECK(obj);
4384    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4385
4386    enabled = !!enabled;
4387    if (sd->focus_highlight.enabled == enabled)
4388      return;
4389
4390    sd->focus_highlight.enabled = enabled;
4391
4392    if (sd->focus_highlight.enabled)
4393      _elm_win_focus_highlight_init(sd);
4394    else
4395      _elm_win_focus_highlight_shutdown(sd);
4396 }
4397
4398 EAPI Eina_Bool
4399 elm_win_focus_highlight_enabled_get(const Evas_Object *obj)
4400 {
4401    ELM_WIN_CHECK(obj) EINA_FALSE;
4402    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
4403
4404    return sd->focus_highlight.enabled;
4405 }
4406
4407 EAPI void
4408 elm_win_focus_highlight_style_set(Evas_Object *obj,
4409                                   const char *style)
4410 {
4411    ELM_WIN_CHECK(obj);
4412    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4413
4414    eina_stringshare_replace(&sd->focus_highlight.style, style);
4415    sd->focus_highlight.changed_theme = EINA_TRUE;
4416    _elm_win_focus_highlight_reconfigure_job_start(sd);
4417 }
4418
4419 EAPI const char *
4420 elm_win_focus_highlight_style_get(const Evas_Object *obj)
4421 {
4422    ELM_WIN_CHECK(obj) NULL;
4423    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, NULL);
4424
4425    return sd->focus_highlight.style;
4426 }
4427
4428 EAPI Eina_Bool
4429 elm_win_socket_listen(Evas_Object *obj,
4430                       const char *svcname,
4431                       int svcnum,
4432                       Eina_Bool svcsys)
4433 {
4434    ELM_WIN_CHECK(obj) EINA_FALSE;
4435    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
4436
4437    if (!sd->ee) return EINA_FALSE;
4438
4439    if (!ecore_evas_extn_socket_listen(sd->ee, svcname, svcnum, svcsys))
4440      return EINA_FALSE;
4441
4442    return EINA_TRUE;
4443 }
4444
4445 /* windowing specific calls - shall we do this differently? */
4446
4447 EAPI Ecore_X_Window
4448 elm_win_xwindow_get(const Evas_Object *obj)
4449 {
4450    if (!obj) return 0;
4451
4452    if (!evas_object_smart_type_check_ptr(obj, WIN_SMART_NAME))
4453      {
4454         Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
4455         return _elm_ee_xwin_get(ee);
4456      }
4457
4458    ELM_WIN_CHECK(obj) 0;
4459    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, 0);
4460
4461 #ifdef HAVE_ELEMENTARY_X
4462    if (sd->x.xwin) return sd->x.xwin;
4463    if (sd->parent) return elm_win_xwindow_get(sd->parent);
4464 #endif
4465    return 0;
4466 }
4467
4468 EAPI Ecore_Wl_Window *
4469 elm_win_wl_window_get(const Evas_Object *obj)
4470 {
4471    if (!obj) return NULL;
4472
4473    if (!evas_object_smart_type_check_ptr(obj, WIN_SMART_NAME))
4474      {
4475         Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
4476         return ecore_evas_wayland_window_get(ee);
4477      }
4478
4479    ELM_WIN_CHECK(obj) NULL;
4480    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, NULL);
4481 #if HAVE_ELEMENTARY_WAYLAND
4482    if (sd->wl.win) return sd->wl.win;
4483    if (sd->parent) return elm_win_wl_window_get(sd->parent);
4484 #endif
4485    return NULL;
4486 }
4487
4488 EAPI Eina_Bool
4489 elm_win_trap_set(const Elm_Win_Trap *t)
4490 {
4491    DBG("old %p, new %p", trap, t);
4492
4493    if ((t) && (t->version != ELM_WIN_TRAP_VERSION))
4494      {
4495         CRITICAL("trying to set a trap version %lu while %lu was expected!",
4496                  t->version, ELM_WIN_TRAP_VERSION);
4497         return EINA_FALSE;
4498      }
4499
4500    trap = t;
4501    return EINA_TRUE;
4502 }
4503
4504 EAPI void
4505 elm_win_floating_mode_set(Evas_Object *obj, Eina_Bool floating)
4506 {
4507    ELM_WIN_CHECK(obj);
4508    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4509
4510    if (floating == sd->floating) return;
4511    sd->floating = floating;
4512 #ifdef HAVE_ELEMENTARY_X
4513    _elm_win_xwindow_get(sd);
4514    if (sd->x.xwin)
4515      {
4516         if (sd->floating)
4517           ecore_x_e_illume_window_state_set
4518              (sd->x.xwin, ECORE_X_ILLUME_WINDOW_STATE_FLOATING);
4519         else
4520           ecore_x_e_illume_window_state_set
4521              (sd->x.xwin, ECORE_X_ILLUME_WINDOW_STATE_NORMAL);
4522      }
4523 #endif
4524 }
4525
4526 EAPI Eina_Bool
4527 elm_win_floating_mode_get(const Evas_Object *obj)
4528 {
4529    ELM_WIN_CHECK(obj) EINA_FALSE;
4530    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
4531
4532    return sd->floating;
4533 }
4534