[access][gengrid] add activate callback
[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    Evas *evas;
1951    const Eina_List *l;
1952    Evas_Object *obj;
1953
1954    EINA_LIST_FOREACH(_elm_win_list, l, obj)
1955      {
1956         elm_widget_access(obj, is_access);
1957         if (!is_access)
1958           {
1959              evas = evas_object_evas_get(obj);
1960             if (evas) _elm_access_object_hilight_disable(evas);
1961           }
1962      }
1963 }
1964
1965 void
1966 _elm_win_translate(void)
1967 {
1968    const Eina_List *l;
1969    Evas_Object *obj;
1970
1971    EINA_LIST_FOREACH(_elm_win_list, l, obj)
1972      elm_widget_translate(obj);
1973 }
1974
1975 #ifdef HAVE_ELEMENTARY_X
1976 static Eina_Bool
1977 _elm_win_client_message(void *data,
1978                         int type __UNUSED__,
1979                         void *event)
1980 {
1981    Elm_Access_Action_Info *a;
1982    Ecore_X_Atom atom_scroll, atom_back, atom_control_panel_open;
1983    Elm_Win_Smart_Data *sd = data;
1984    Ecore_X_Event_Client_Message *e = event;
1985
1986    if (e->format != 32) return ECORE_CALLBACK_PASS_ON;
1987    if (e->message_type == ECORE_X_ATOM_E_COMP_FLUSH)
1988      {
1989         if ((unsigned int)e->data.l[0] == sd->x.xwin)
1990           {
1991              Evas *evas = evas_object_evas_get(ELM_WIDGET_DATA(sd)->obj);
1992              if (evas)
1993                {
1994                   edje_file_cache_flush();
1995                   edje_collection_cache_flush();
1996                   evas_image_cache_flush(evas);
1997                   evas_font_cache_flush(evas);
1998                }
1999           }
2000      }
2001    else if (e->message_type == ECORE_X_ATOM_E_COMP_DUMP)
2002      {
2003         if ((unsigned int)e->data.l[0] == sd->x.xwin)
2004           {
2005              Evas *evas = evas_object_evas_get(ELM_WIDGET_DATA(sd)->obj);
2006              if (evas)
2007                {
2008                   edje_file_cache_flush();
2009                   edje_collection_cache_flush();
2010                   evas_image_cache_flush(evas);
2011                   evas_font_cache_flush(evas);
2012                   evas_render_dump(evas);
2013                }
2014           }
2015      }
2016    else if (e->message_type == ECORE_X_ATOM_E_ILLUME_ACCESS_CONTROL)
2017      {
2018         if ((unsigned int)e->data.l[0] == sd->x.xwin)
2019           {
2020              atom_scroll = ecore_x_atom_get("_E_MOD_SCREEN_READER_ACTION_SCROLL_");
2021              atom_back = ecore_x_atom_get("_E_MOD_SCREEN_READER_ACTION_BACK_");
2022              atom_control_panel_open = ecore_x_atom_get("_E_MOD_SCREEN_READER_ACTION_CONTROL_PANEL_OPEN_");
2023
2024              if ((unsigned int)e->data.l[1] ==
2025                  ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_NEXT)
2026                {
2027                   // XXX: call right access func
2028                }
2029              else if ((unsigned int)e->data.l[1] ==
2030                       ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_PREV)
2031                {
2032                   // XXX: call right access func
2033                }
2034              else if ((unsigned int)e->data.l[1] ==
2035                       ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_ACTIVATE)
2036                {
2037                   _elm_access_highlight_object_activate
2038                     (ELM_WIDGET_DATA(sd)->obj, ELM_ACTIVATE_DEFAULT);
2039                }
2040              else if ((unsigned int)e->data.l[1] ==
2041                       ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_READ)
2042                {
2043                   /* there would be better way to read highlight object */
2044                   Evas *evas;
2045                   evas = evas_object_evas_get(ELM_WIDGET_DATA(sd)->obj);
2046                   if (!evas) return ECORE_CALLBACK_PASS_ON;
2047
2048                   a = calloc(1, sizeof(Elm_Access_Action_Info));
2049                   a->x = e->data.l[2];
2050                   a->y = e->data.l[3];
2051                   elm_access_action(ELM_WIDGET_DATA(sd)->obj, ELM_ACCESS_ACTION_HIGHLIGHT, a);
2052                   free(a);
2053                }
2054              else if ((unsigned int)e->data.l[1] ==
2055                       ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_READ_NEXT)
2056                {
2057                   _elm_access_highlight_cycle(ELM_WIDGET_DATA(sd)->obj, ELM_FOCUS_NEXT);
2058                }
2059              else if ((unsigned int)e->data.l[1] ==
2060                       ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_READ_PREV)
2061                {
2062                   _elm_access_highlight_cycle(ELM_WIDGET_DATA(sd)->obj, ELM_FOCUS_PREVIOUS);
2063                }
2064              else if ((unsigned int)e->data.l[1] ==
2065                       ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_UP)
2066                {
2067                   _elm_access_highlight_object_activate
2068                     (ELM_WIDGET_DATA(sd)->obj, ELM_ACTIVATE_UP);
2069                }
2070              else if ((unsigned int)e->data.l[1] ==
2071                       ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_DOWN)
2072                {
2073                   _elm_access_highlight_object_activate
2074                     (ELM_WIDGET_DATA(sd)->obj, ELM_ACTIVATE_DOWN);
2075                }
2076              else if ((unsigned int)e->data.l[1] == atom_scroll)
2077                {
2078                   _elm_access_highlight_object_scroll(ELM_WIDGET_DATA(sd)->obj,
2079                     e->data.l[2], e->data.l[3], e->data.l[4]);
2080                }
2081              else if ((unsigned int)e->data.l[1] == atom_back)
2082                {
2083                   _elm_access_highlight_object_activate
2084                     (ELM_WIDGET_DATA(sd)->obj, ELM_ACTIVATE_BACK);
2085                }
2086              else if ((unsigned int)e->data.l[1] == atom_control_panel_open)
2087                {
2088                }
2089           }
2090      }
2091    return ECORE_CALLBACK_PASS_ON;
2092 }
2093
2094 static Eina_Bool
2095 _elm_win_property_change(void *data,
2096                          int type __UNUSED__,
2097                          void *event)
2098 {
2099    Elm_Win_Smart_Data *sd = data;
2100    Ecore_X_Event_Window_Property *e = event;
2101
2102    if (e->atom == ECORE_X_ATOM_E_ILLUME_INDICATOR_STATE)
2103      {
2104         if (e->win == sd->x.xwin)
2105           {
2106              sd->indmode = ecore_x_e_illume_indicator_state_get(e->win);
2107              evas_object_smart_callback_call(ELM_WIDGET_DATA(sd)->obj, SIG_INDICATOR_PROP_CHANGED, NULL);
2108           }
2109      }
2110    if (e->atom == ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_STATE)
2111      {
2112         if (e->win == sd->x.xwin)
2113           {
2114              sd->kbdmode = ecore_x_e_virtual_keyboard_state_get(e->win);
2115           }
2116      }
2117    return ECORE_CALLBACK_PASS_ON;
2118 }
2119 #endif
2120
2121 static void
2122 _elm_win_focus_highlight_hide(void *data __UNUSED__,
2123                               Evas_Object *obj,
2124                               const char *emission __UNUSED__,
2125                               const char *source __UNUSED__)
2126 {
2127    evas_object_hide(obj);
2128 }
2129
2130 static void
2131 _elm_win_focus_highlight_anim_end(void *data,
2132                                   Evas_Object *obj,
2133                                   const char *emission __UNUSED__,
2134                                   const char *source __UNUSED__)
2135 {
2136    Elm_Win_Smart_Data *sd = data;
2137
2138    _elm_win_focus_highlight_simple_setup(sd, obj);
2139 }
2140
2141 static void
2142 _elm_win_focus_highlight_init(Elm_Win_Smart_Data *sd)
2143 {
2144    evas_event_callback_add(sd->evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
2145                            _elm_win_object_focus_in, sd);
2146    evas_event_callback_add(sd->evas,
2147                            EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
2148                            _elm_win_object_focus_out, sd);
2149
2150    sd->focus_highlight.cur.target = evas_focus_get(sd->evas);
2151
2152    sd->focus_highlight.top = edje_object_add(sd->evas);
2153    sd->focus_highlight.changed_theme = EINA_TRUE;
2154    edje_object_signal_callback_add(sd->focus_highlight.top,
2155                                    "elm,action,focus,hide,end", "",
2156                                    _elm_win_focus_highlight_hide, NULL);
2157    edje_object_signal_callback_add(sd->focus_highlight.top,
2158                                    "elm,action,focus,anim,end", "",
2159                                    _elm_win_focus_highlight_anim_end, sd);
2160    _elm_win_focus_highlight_reconfigure_job_start(sd);
2161 }
2162
2163 static void
2164 _elm_win_frame_cb_move_start(void *data,
2165                              Evas_Object *obj __UNUSED__,
2166                              const char *sig __UNUSED__,
2167                              const char *source __UNUSED__)
2168 {
2169    Elm_Win_Smart_Data *sd;
2170
2171    if (!(sd = data)) return;
2172    /* FIXME: Change mouse pointer */
2173
2174    /* NB: Wayland handles moving surfaces by itself so we cannot
2175     * specify a specific x/y we want. Instead, we will pass in the
2176     * existing x/y values so they can be recorded as 'previous'
2177     * position. The new position will get updated automatically when
2178     * the move is finished */
2179
2180    ecore_evas_wayland_move(sd->ee, sd->screen.x, sd->screen.y);
2181 }
2182
2183 static void
2184 _elm_win_frame_cb_resize_show(void *data,
2185                               Evas_Object *obj __UNUSED__,
2186                               const char *sig __UNUSED__,
2187                               const char *source)
2188 {
2189    Elm_Win_Smart_Data *sd;
2190
2191    if (!(sd = data)) return;
2192    if (sd->resizing) return;
2193
2194 #ifdef HAVE_ELEMENTARY_WAYLAND
2195    if (!strcmp(source, "elm.event.resize.t"))
2196      ecore_wl_window_cursor_from_name_set(sd->wl.win, ELM_CURSOR_TOP_SIDE);
2197    else if (!strcmp(source, "elm.event.resize.b"))
2198      ecore_wl_window_cursor_from_name_set(sd->wl.win, ELM_CURSOR_BOTTOM_SIDE);
2199    else if (!strcmp(source, "elm.event.resize.l"))
2200      ecore_wl_window_cursor_from_name_set(sd->wl.win, ELM_CURSOR_LEFT_SIDE);
2201    else if (!strcmp(source, "elm.event.resize.r"))
2202      ecore_wl_window_cursor_from_name_set(sd->wl.win, ELM_CURSOR_RIGHT_SIDE);
2203    else if (!strcmp(source, "elm.event.resize.tl"))
2204      ecore_wl_window_cursor_from_name_set(sd->wl.win,
2205                                           ELM_CURSOR_TOP_LEFT_CORNER);
2206    else if (!strcmp(source, "elm.event.resize.tr"))
2207      ecore_wl_window_cursor_from_name_set(sd->wl.win,
2208                                           ELM_CURSOR_TOP_RIGHT_CORNER);
2209    else if (!strcmp(source, "elm.event.resize.bl"))
2210      ecore_wl_window_cursor_from_name_set(sd->wl.win,
2211                                           ELM_CURSOR_BOTTOM_LEFT_CORNER);
2212    else if (!strcmp(source, "elm.event.resize.br"))
2213      ecore_wl_window_cursor_from_name_set(sd->wl.win,
2214                                           ELM_CURSOR_BOTTOM_RIGHT_CORNER);
2215    else
2216      ecore_wl_window_cursor_default_restore(sd->wl.win);
2217 #else
2218    (void)source;
2219 #endif
2220 }
2221
2222 static void
2223 _elm_win_frame_cb_resize_hide(void *data,
2224                               Evas_Object *obj __UNUSED__,
2225                               const char *sig __UNUSED__,
2226                               const char *source __UNUSED__)
2227 {
2228    Elm_Win_Smart_Data *sd;
2229
2230    if (!(sd = data)) return;
2231    if (sd->resizing) return;
2232
2233 #ifdef HAVE_ELEMENTARY_WAYLAND
2234    ecore_wl_window_cursor_default_restore(sd->wl.win);
2235 #endif
2236 }
2237
2238 static void
2239 _elm_win_frame_cb_resize_start(void *data,
2240                                Evas_Object *obj __UNUSED__,
2241                                const char *sig __UNUSED__,
2242                                const char *source)
2243 {
2244    Elm_Win_Smart_Data *sd;
2245
2246    if (!(sd = data)) return;
2247    if (sd->resizing) return;
2248
2249    sd->resizing = EINA_TRUE;
2250
2251    if (!strcmp(source, "elm.event.resize.t"))
2252      sd->resize_location = 1;
2253    else if (!strcmp(source, "elm.event.resize.b"))
2254      sd->resize_location = 2;
2255    else if (!strcmp(source, "elm.event.resize.l"))
2256      sd->resize_location = 4;
2257    else if (!strcmp(source, "elm.event.resize.r"))
2258      sd->resize_location = 8;
2259    else if (!strcmp(source, "elm.event.resize.tl"))
2260      sd->resize_location = 5;
2261    else if (!strcmp(source, "elm.event.resize.tr"))
2262      sd->resize_location = 9;
2263    else if (!strcmp(source, "elm.event.resize.bl"))
2264      sd->resize_location = 6;
2265    else if (!strcmp(source, "elm.event.resize.br"))
2266      sd->resize_location = 10;
2267    else
2268      sd->resize_location = 0;
2269
2270    if (sd->resize_location > 0)
2271      ecore_evas_wayland_resize(sd->ee, sd->resize_location);
2272 }
2273
2274 static void
2275 _elm_win_frame_cb_minimize(void *data,
2276                            Evas_Object *obj __UNUSED__,
2277                            const char *sig __UNUSED__,
2278                            const char *source __UNUSED__)
2279 {
2280    Elm_Win_Smart_Data *sd;
2281
2282    if (!(sd = data)) return;
2283 // sd->iconified = EINA_TRUE;
2284    TRAP(sd, iconified_set, EINA_TRUE);
2285 }
2286
2287 static void
2288 _elm_win_frame_cb_maximize(void *data,
2289                            Evas_Object *obj __UNUSED__,
2290                            const char *sig __UNUSED__,
2291                            const char *source __UNUSED__)
2292 {
2293    Elm_Win_Smart_Data *sd;
2294
2295    if (!(sd = data)) return;
2296    if (sd->maximized) sd->maximized = EINA_FALSE;
2297    else sd->maximized = EINA_TRUE;
2298    TRAP(sd, maximized_set, sd->maximized);
2299 }
2300
2301 static void
2302 _elm_win_frame_cb_close(void *data,
2303                         Evas_Object *obj __UNUSED__,
2304                         const char *sig __UNUSED__,
2305                         const char *source __UNUSED__)
2306 {
2307    Elm_Win_Smart_Data *sd;
2308    Evas_Object *win;
2309
2310    /* FIXME: After the current freeze, this should be handled differently.
2311     *
2312     * Ideally, we would want to mimic the X11 backend and use something
2313     * like ECORE_WL_EVENT_WINDOW_DELETE and handle the delete_request
2314     * inside of ecore_evas. That would be the 'proper' way, but since we are
2315     * in a freeze right now, I cannot add a new event value, or a new
2316     * event structure to ecore_wayland.
2317     *
2318     * So yes, this is a temporary 'stop-gap' solution which will be fixed
2319     * when the freeze is over, but it does fix a trac bug for now, and in a
2320     * way which does not break API or the freeze. - dh
2321     */
2322
2323    if (!(sd = data)) return;
2324
2325    win = ELM_WIDGET_DATA(sd)->obj;
2326
2327    int autodel = sd->autodel;
2328    sd->autodel_clear = &autodel;
2329    evas_object_ref(win);
2330    evas_object_smart_callback_call(win, SIG_DELETE_REQUEST, NULL);
2331    // FIXME: if above callback deletes - then the below will be invalid
2332    if (autodel) evas_object_del(win);
2333    else sd->autodel_clear = NULL;
2334    evas_object_unref(win);
2335 }
2336
2337 static void
2338 _elm_win_frame_add(Elm_Win_Smart_Data *sd,
2339                    const char *style)
2340 {
2341    evas_output_framespace_set(sd->evas, 0, 22, 0, 26);
2342
2343    sd->frame_obj = edje_object_add(sd->evas);
2344    elm_widget_theme_object_set
2345      (ELM_WIDGET_DATA(sd)->obj, sd->frame_obj, "border", "base", style);
2346
2347    evas_object_is_frame_object_set(sd->frame_obj, EINA_TRUE);
2348    evas_object_move(sd->frame_obj, 0, 0);
2349    evas_object_resize(sd->frame_obj, 1, 1);
2350
2351    edje_object_signal_callback_add
2352      (sd->frame_obj, "elm,action,move,start", "elm",
2353      _elm_win_frame_cb_move_start, sd);
2354    edje_object_signal_callback_add
2355      (sd->frame_obj, "elm,action,resize,show", "*",
2356      _elm_win_frame_cb_resize_show, sd);
2357    edje_object_signal_callback_add
2358      (sd->frame_obj, "elm,action,resize,hide", "*",
2359      _elm_win_frame_cb_resize_hide, sd);
2360    edje_object_signal_callback_add
2361      (sd->frame_obj, "elm,action,resize,start", "*",
2362      _elm_win_frame_cb_resize_start, sd);
2363    edje_object_signal_callback_add
2364      (sd->frame_obj, "elm,action,minimize", "elm",
2365      _elm_win_frame_cb_minimize, sd);
2366    edje_object_signal_callback_add
2367      (sd->frame_obj, "elm,action,maximize", "elm",
2368      _elm_win_frame_cb_maximize, sd);
2369    edje_object_signal_callback_add
2370      (sd->frame_obj, "elm,action,close", "elm", _elm_win_frame_cb_close, sd);
2371
2372    if (sd->title)
2373      {
2374         edje_object_part_text_escaped_set
2375           (sd->frame_obj, "elm.text.title", sd->title);
2376      }
2377 }
2378
2379 static void
2380 _elm_win_frame_del(Elm_Win_Smart_Data *sd)
2381 {
2382    if (sd->frame_obj)
2383      {
2384         edje_object_signal_callback_del
2385           (sd->frame_obj, "elm,action,move,start", "elm",
2386               _elm_win_frame_cb_move_start);
2387         edje_object_signal_callback_del
2388           (sd->frame_obj, "elm,action,resize,show", "*",
2389               _elm_win_frame_cb_resize_show);
2390         edje_object_signal_callback_del
2391           (sd->frame_obj, "elm,action,resize,hide", "*",
2392               _elm_win_frame_cb_resize_hide);
2393         edje_object_signal_callback_del
2394           (sd->frame_obj, "elm,action,resize,start", "*",
2395               _elm_win_frame_cb_resize_start);
2396         edje_object_signal_callback_del
2397           (sd->frame_obj, "elm,action,minimize", "elm",
2398               _elm_win_frame_cb_minimize);
2399         edje_object_signal_callback_del
2400           (sd->frame_obj, "elm,action,maximize", "elm",
2401               _elm_win_frame_cb_maximize);
2402         edje_object_signal_callback_del
2403           (sd->frame_obj, "elm,action,close", "elm",
2404               _elm_win_frame_cb_close);
2405
2406         evas_object_del(sd->frame_obj);
2407         sd->frame_obj = NULL;
2408      }
2409
2410    evas_output_framespace_set(sd->evas, 0, 0, 0, 0);
2411 }
2412
2413 #ifdef ELM_DEBUG
2414 static void
2415 _debug_key_down(void *data __UNUSED__,
2416                 Evas *e __UNUSED__,
2417                 Evas_Object *obj,
2418                 void *event_info)
2419 {
2420    Evas_Event_Key_Down *ev = event_info;
2421
2422    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
2423      return;
2424
2425    if ((strcmp(ev->keyname, "F12")) ||
2426        (!evas_key_modifier_is_set(ev->modifiers, "Control")))
2427      return;
2428
2429    printf("Tree graph generated.\n");
2430    elm_object_tree_dot_dump(obj, "./dump.dot");
2431 }
2432
2433 #endif
2434
2435 static void
2436 _win_img_hide(void *data,
2437               Evas *e __UNUSED__,
2438               Evas_Object *obj __UNUSED__,
2439               void *event_info __UNUSED__)
2440 {
2441    Elm_Win_Smart_Data *sd = data;
2442
2443    elm_widget_focus_hide_handle(ELM_WIDGET_DATA(sd)->obj);
2444 }
2445
2446 static void
2447 _win_img_mouse_up(void *data,
2448                   Evas *e __UNUSED__,
2449                   Evas_Object *obj __UNUSED__,
2450                   void *event_info)
2451 {
2452    Elm_Win_Smart_Data *sd = data;
2453    Evas_Event_Mouse_Up *ev = event_info;
2454    if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD))
2455      elm_widget_focus_mouse_up_handle(ELM_WIDGET_DATA(sd)->obj);
2456 }
2457
2458 static void
2459 _win_img_focus_in(void *data,
2460                   Evas *e __UNUSED__,
2461                   Evas_Object *obj __UNUSED__,
2462                   void *event_info __UNUSED__)
2463 {
2464    Elm_Win_Smart_Data *sd = data;
2465    elm_widget_focus_steal(ELM_WIDGET_DATA(sd)->obj);
2466 }
2467
2468 static void
2469 _win_img_focus_out(void *data,
2470                    Evas *e __UNUSED__,
2471                    Evas_Object *obj __UNUSED__,
2472                    void *event_info __UNUSED__)
2473 {
2474    Elm_Win_Smart_Data *sd = data;
2475    elm_widget_focused_object_clear(ELM_WIDGET_DATA(sd)->obj);
2476 }
2477
2478 static void
2479 _win_inlined_image_set(Elm_Win_Smart_Data *sd)
2480 {
2481    evas_object_image_alpha_set(sd->img_obj, EINA_FALSE);
2482    evas_object_image_filled_set(sd->img_obj, EINA_TRUE);
2483
2484    evas_object_event_callback_add
2485      (sd->img_obj, EVAS_CALLBACK_DEL, _elm_win_on_img_obj_del, sd);
2486    evas_object_event_callback_add
2487      (sd->img_obj, EVAS_CALLBACK_HIDE, _win_img_hide, sd);
2488    evas_object_event_callback_add
2489      (sd->img_obj, EVAS_CALLBACK_MOUSE_UP, _win_img_mouse_up, sd);
2490    evas_object_event_callback_add
2491      (sd->img_obj, EVAS_CALLBACK_FOCUS_IN, _win_img_focus_in, sd);
2492    evas_object_event_callback_add
2493      (sd->img_obj, EVAS_CALLBACK_FOCUS_OUT, _win_img_focus_out, sd);
2494 }
2495
2496 static void
2497 _elm_win_on_icon_del(void *data,
2498                      Evas *e __UNUSED__,
2499                      Evas_Object *obj,
2500                      void *event_info __UNUSED__)
2501 {
2502    Elm_Win_Smart_Data *sd = data;
2503
2504    if (sd->icon == obj) sd->icon = NULL;
2505 }
2506
2507 static void
2508 _elm_win_smart_add(Evas_Object *obj)
2509 {
2510    EVAS_SMART_DATA_ALLOC(obj, Elm_Win_Smart_Data);
2511
2512    _elm_win_parent_sc->base.add(obj);
2513
2514    elm_widget_can_focus_set(obj, EINA_TRUE);
2515
2516    elm_widget_highlight_ignore_set(obj, EINA_TRUE);
2517 }
2518
2519 static void
2520 _elm_win_smart_set_user(Elm_Widget_Smart_Class *sc)
2521 {
2522    sc->base.add = _elm_win_smart_add;
2523    sc->base.del = _elm_win_smart_del;
2524    sc->base.show = _elm_win_smart_show;
2525    sc->base.hide = _elm_win_smart_hide;
2526    sc->base.move = _elm_win_smart_move;
2527    sc->base.resize = _elm_win_smart_resize;
2528
2529    sc->focus_next = _elm_win_smart_focus_next;
2530    sc->focus_direction = _elm_win_smart_focus_direction;
2531    sc->on_focus = _elm_win_smart_on_focus;
2532    sc->event = _elm_win_smart_event;
2533 }
2534
2535 #ifdef HAVE_ELEMENTARY_X
2536 static void
2537 _elm_x_io_err(void *data __UNUSED__)
2538 {
2539    Eina_List *l;
2540    Evas_Object *obj;
2541
2542    EINA_LIST_FOREACH(_elm_win_list, l, obj)
2543      evas_object_smart_callback_call(obj, SIG_IOERR, NULL);
2544    elm_exit();
2545 }
2546 #endif
2547
2548 static void
2549 _elm_win_cb_hide(void *data __UNUSED__,
2550                  Evas *e __UNUSED__,
2551                  Evas_Object *obj __UNUSED__,
2552                  void *event_info __UNUSED__)
2553 {
2554    _elm_win_state_eval_queue();
2555 }
2556
2557 static void
2558 _elm_win_cb_show(void *data __UNUSED__,
2559                  Evas *e __UNUSED__,
2560                  Evas_Object *obj __UNUSED__,
2561                  void *event_info __UNUSED__)
2562 {
2563    _elm_win_state_eval_queue();
2564 }
2565
2566 EAPI Evas_Object *
2567 elm_win_add(Evas_Object *parent,
2568             const char *name,
2569             Elm_Win_Type type)
2570 {
2571    Evas *e;
2572    Evas_Object *obj;
2573    const Eina_List *l;
2574    const char *fontpath, *fallback = NULL;
2575
2576    Elm_Win_Smart_Data tmp_sd;
2577
2578    /* just to store some data while trying out to create a canvas */
2579    memset(&tmp_sd, 0, sizeof(Elm_Win_Smart_Data));
2580
2581 #define FALLBACK_TRY(engine)                                      \
2582   if (!tmp_sd.ee) {                                               \
2583      CRITICAL(engine " engine creation failed. Trying default."); \
2584        tmp_sd.ee = ecore_evas_new(NULL, 0, 0, 1, 1, NULL);              \
2585        if (tmp_sd.ee)                                                   \
2586           elm_config_preferred_engine_set(ecore_evas_engine_name_get(tmp_sd.ee)); \
2587   } while (0)
2588 #define FALLBACK_STORE(engine)                               \
2589    if (tmp_sd.ee)                                            \
2590    {                                                         \
2591       CRITICAL(engine "Fallback to %s successful.", engine); \
2592       fallback = engine;                                     \
2593    }
2594
2595    switch (type)
2596      {
2597       case ELM_WIN_INLINED_IMAGE:
2598         if (!parent) break;
2599         {
2600            e = evas_object_evas_get(parent);
2601            Ecore_Evas *ee;
2602
2603            if (!e) break;
2604
2605            ee = ecore_evas_ecore_evas_get(e);
2606            if (!ee) break;
2607
2608            tmp_sd.img_obj = ecore_evas_object_image_new(ee);
2609            if (!tmp_sd.img_obj) break;
2610
2611            tmp_sd.ee = ecore_evas_object_ecore_evas_get(tmp_sd.img_obj);
2612            if (!tmp_sd.ee)
2613              {
2614                 evas_object_del(tmp_sd.img_obj);
2615                 tmp_sd.img_obj = NULL;
2616              }
2617         }
2618         break;
2619
2620       case ELM_WIN_SOCKET_IMAGE:
2621         tmp_sd.ee = ecore_evas_extn_socket_new(1, 1);
2622         break;
2623
2624       default:
2625         if (ENGINE_COMPARE(ELM_SOFTWARE_X11))
2626           {
2627              tmp_sd.ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
2628              FALLBACK_TRY("Software X11");
2629              if (!tmp_sd.ee)
2630                {
2631                   tmp_sd.ee = ecore_evas_fb_new(NULL, 0, 1, 1);
2632                   FALLBACK_STORE("Software FB");
2633                }
2634           }
2635         else if (ENGINE_COMPARE(ELM_SOFTWARE_FB))
2636           {
2637              tmp_sd.ee = ecore_evas_fb_new(NULL, 0, 1, 1);
2638              FALLBACK_TRY("Software FB");
2639              if (!tmp_sd.ee)
2640                {
2641                   tmp_sd.ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
2642                   FALLBACK_STORE("Software X11");
2643                }
2644           }
2645         else if (ENGINE_COMPARE(ELM_SOFTWARE_DIRECTFB))
2646           {
2647              tmp_sd.ee = ecore_evas_directfb_new(NULL, 1, 0, 0, 1, 1);
2648              FALLBACK_TRY("Software DirectFB");
2649              if (!tmp_sd.ee)
2650                {
2651                   tmp_sd.ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
2652                   FALLBACK_STORE("Software X11");
2653                   if (!tmp_sd.ee)
2654                     {
2655                        tmp_sd.ee = ecore_evas_fb_new(NULL, 0, 1, 1);
2656                        FALLBACK_STORE("Software FB");
2657                     }
2658                }
2659           }
2660         else if (ENGINE_COMPARE(ELM_SOFTWARE_16_X11))
2661           {
2662              tmp_sd.ee = ecore_evas_software_x11_16_new(NULL, 0, 0, 0, 1, 1);
2663              FALLBACK_TRY("Software-16");
2664              if (!tmp_sd.ee)
2665                {
2666                   tmp_sd.ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
2667                   FALLBACK_STORE("Software X11");
2668                   if (!tmp_sd.ee)
2669                     {
2670                        tmp_sd.ee = ecore_evas_fb_new(NULL, 0, 1, 1);
2671                        FALLBACK_STORE("Software FB");
2672                     }
2673                }
2674           }
2675         else if (ENGINE_COMPARE(ELM_SOFTWARE_8_X11))
2676           {
2677              tmp_sd.ee = ecore_evas_software_x11_8_new(NULL, 0, 0, 0, 1, 1);
2678              FALLBACK_TRY("Software-8");
2679              if (!tmp_sd.ee)
2680                {
2681                   tmp_sd.ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
2682                   FALLBACK_STORE("Software X11");
2683                   if (!tmp_sd.ee)
2684                     {
2685                        tmp_sd.ee = ecore_evas_fb_new(NULL, 0, 1, 1);
2686                        FALLBACK_STORE("Software FB");
2687                     }
2688                }
2689           }
2690         else if (ENGINE_COMPARE(ELM_OPENGL_X11))
2691           {
2692              int opt[10];
2693              int opt_i = 0;
2694
2695              if (_elm_config->vsync)
2696                {
2697                   opt[opt_i] = ECORE_EVAS_GL_X11_OPT_VSYNC;
2698                   opt_i++;
2699                   opt[opt_i] = 1;
2700                   opt_i++;
2701                                   opt[opt_i] = 0;
2702                }
2703              if (opt_i > 0)
2704                tmp_sd.ee = ecore_evas_gl_x11_options_new
2705                    (NULL, 0, 0, 0, 1, 1, opt);
2706              else
2707                tmp_sd.ee = ecore_evas_gl_x11_new(NULL, 0, 0, 0, 1, 1);
2708              FALLBACK_TRY("OpenGL");
2709              if (!tmp_sd.ee)
2710                {
2711                   tmp_sd.ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
2712                   FALLBACK_STORE("Software X11");
2713                   if (!tmp_sd.ee)
2714                     {
2715                        tmp_sd.ee = ecore_evas_fb_new(NULL, 0, 1, 1);
2716                        FALLBACK_STORE("Software FB");
2717                     }
2718                }
2719           }
2720         else if (ENGINE_COMPARE(ELM_SOFTWARE_WIN32))
2721           {
2722              tmp_sd.ee = ecore_evas_software_gdi_new(NULL, 0, 0, 1, 1);
2723              FALLBACK_TRY("Software Win32");
2724           }
2725         else if (ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE))
2726           {
2727              tmp_sd.ee = ecore_evas_software_wince_gdi_new(NULL, 0, 0, 1, 1);
2728              FALLBACK_TRY("Software-16-WinCE");
2729           }
2730         else if (ENGINE_COMPARE(ELM_SOFTWARE_PSL1GHT))
2731           {
2732              tmp_sd.ee = ecore_evas_psl1ght_new(NULL, 1, 1);
2733              FALLBACK_TRY("PSL1GHT");
2734           }
2735         else if (ENGINE_COMPARE(ELM_SOFTWARE_SDL))
2736           {
2737              tmp_sd.ee = ecore_evas_sdl_new(NULL, 0, 0, 0, 0, 0, 1);
2738              FALLBACK_TRY("Software SDL");
2739              if (!tmp_sd.ee)
2740                {
2741                   tmp_sd.ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
2742                   FALLBACK_STORE("Software X11");
2743                   if (!tmp_sd.ee)
2744                     {
2745                        tmp_sd.ee = ecore_evas_fb_new(NULL, 0, 1, 1);
2746                        FALLBACK_STORE("Software FB");
2747                     }
2748                }
2749           }
2750         else if (ENGINE_COMPARE(ELM_SOFTWARE_16_SDL))
2751           {
2752              tmp_sd.ee = ecore_evas_sdl16_new(NULL, 0, 0, 0, 0, 0, 1);
2753              FALLBACK_TRY("Software-16-SDL");
2754              if (!tmp_sd.ee)
2755                {
2756                   tmp_sd.ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
2757                   FALLBACK_STORE("Software X11");
2758                   if (!tmp_sd.ee)
2759                     {
2760                        tmp_sd.ee = ecore_evas_fb_new(NULL, 0, 1, 1);
2761                        FALLBACK_STORE("Software FB");
2762                     }
2763                }
2764           }
2765         else if (ENGINE_COMPARE(ELM_OPENGL_SDL))
2766           {
2767              tmp_sd.ee = ecore_evas_gl_sdl_new(NULL, 1, 1, 0, 0);
2768              FALLBACK_TRY("OpenGL SDL");
2769              if (!tmp_sd.ee)
2770                {
2771                   tmp_sd.ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
2772                   FALLBACK_STORE("Software X11");
2773                   if (!tmp_sd.ee)
2774                     {
2775                        tmp_sd.ee = ecore_evas_fb_new(NULL, 0, 1, 1);
2776                        FALLBACK_STORE("Software FB");
2777                     }
2778                }
2779           }
2780         else if (ENGINE_COMPARE(ELM_OPENGL_COCOA))
2781           {
2782              tmp_sd.ee = ecore_evas_cocoa_new(NULL, 1, 1, 0, 0);
2783              FALLBACK_TRY("OpenGL Cocoa");
2784           }
2785         else if (ENGINE_COMPARE(ELM_BUFFER))
2786           {
2787              tmp_sd.ee = ecore_evas_buffer_new(1, 1);
2788           }
2789         else if (ENGINE_COMPARE(ELM_EWS))
2790           {
2791              tmp_sd.ee = ecore_evas_ews_new(0, 0, 1, 1);
2792           }
2793         else if (ENGINE_COMPARE(ELM_WAYLAND_SHM))
2794           {
2795              tmp_sd.ee = ecore_evas_wayland_shm_new(NULL, 0, 0, 0, 1, 1, 0);
2796           }
2797         else if (ENGINE_COMPARE(ELM_WAYLAND_EGL))
2798           {
2799              tmp_sd.ee = ecore_evas_wayland_egl_new(NULL, 0, 0, 0, 1, 1, 0);
2800           }
2801         else if (!strncmp(ENGINE_GET(), "shot:", 5))
2802           {
2803              tmp_sd.ee = ecore_evas_buffer_new(1, 1);
2804              ecore_evas_manual_render_set(tmp_sd.ee, EINA_TRUE);
2805              tmp_sd.shot.info = eina_stringshare_add
2806                  (ENGINE_GET() + 5);
2807           }
2808 #undef FALLBACK_TRY
2809         break;
2810      }
2811
2812    if (!tmp_sd.ee)
2813      {
2814         ERR("Cannot create window.");
2815         return NULL;
2816      }
2817
2818    obj = evas_object_smart_add
2819        (ecore_evas_get(tmp_sd.ee), _elm_win_smart_class_new());
2820
2821    ELM_WIN_DATA_GET(obj, sd);
2822
2823    /* copying possibly altered fields back */
2824 #define SD_CPY(_field)             \
2825   do                               \
2826     {                              \
2827        sd->_field = tmp_sd._field; \
2828     } while (0)
2829
2830    SD_CPY(ee);
2831    SD_CPY(img_obj);
2832    SD_CPY(shot.info);
2833 #undef SD_CPY
2834
2835    if ((trap) && (trap->add))
2836      sd->trap_data = trap->add(obj);
2837
2838    /* complementary actions, which depend on final smart data
2839     * pointer */
2840    if (type == ELM_WIN_INLINED_IMAGE)
2841      _win_inlined_image_set(sd);
2842
2843 #ifdef HAVE_ELEMENTARY_X
2844     else if (ENGINE_COMPARE(ELM_SOFTWARE_X11) ||
2845             ENGINE_COMPARE(ELM_SOFTWARE_16_X11) ||
2846             ENGINE_COMPARE(ELM_SOFTWARE_8_X11) ||
2847             ENGINE_COMPARE(ELM_OPENGL_X11))
2848      {
2849         sd->x.client_message_handler = ecore_event_handler_add
2850             (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, sd);
2851         sd->x.property_handler = ecore_event_handler_add
2852             (ECORE_X_EVENT_WINDOW_PROPERTY, _elm_win_property_change, sd);
2853      }
2854 #endif
2855
2856    else if (!strncmp(ENGINE_GET(), "shot:", 5))
2857      _shot_init(sd);
2858
2859    sd->kbdmode = ELM_WIN_KEYBOARD_UNKNOWN;
2860    sd->indmode = ELM_WIN_INDICATOR_UNKNOWN;
2861
2862 #ifdef HAVE_ELEMENTARY_X
2863    _elm_win_xwindow_get(sd);
2864    if (sd->x.xwin)
2865      {
2866         ecore_x_io_error_handler_set(_elm_x_io_err, NULL);
2867      }
2868 #endif
2869
2870 #ifdef HAVE_ELEMENTARY_WAYLAND
2871    sd->wl.win = ecore_evas_wayland_window_get(sd->ee);
2872 #endif
2873
2874    if ((_elm_config->bgpixmap)
2875 #ifdef HAVE_ELEMENTARY_X
2876        &&
2877        (((sd->x.xwin) && (!ecore_x_screen_is_composited(0))) ||
2878            (!sd->x.xwin))
2879 #endif
2880       )
2881      TRAP(sd, avoid_damage_set, ECORE_EVAS_AVOID_DAMAGE_EXPOSE);
2882    // bg pixmap done by x - has other issues like can be redrawn by x before it
2883    // is filled/ready by app
2884    //     TRAP(sd, avoid_damage_set, ECORE_EVAS_AVOID_DAMAGE_BUILT_IN);
2885
2886    sd->type = type;
2887    sd->parent = parent;
2888
2889    if (sd->parent)
2890      evas_object_event_callback_add
2891        (sd->parent, EVAS_CALLBACK_DEL, _elm_win_on_parent_del, sd);
2892
2893    sd->evas = ecore_evas_get(sd->ee);
2894
2895    evas_object_color_set(obj, 0, 0, 0, 0);
2896    evas_object_move(obj, 0, 0);
2897    evas_object_resize(obj, 1, 1);
2898    evas_object_layer_set(obj, 50);
2899    evas_object_pass_events_set(obj, EINA_TRUE);
2900
2901    if (type == ELM_WIN_INLINED_IMAGE)
2902      elm_widget_parent2_set(obj, parent);
2903
2904    /* use own version of ecore_evas_object_associate() that does TRAP() */
2905    ecore_evas_data_set(sd->ee, "elm_win", sd);
2906
2907    evas_object_event_callback_add
2908      (obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
2909       _elm_win_obj_callback_changed_size_hints, sd);
2910
2911    evas_object_intercept_raise_callback_add
2912      (obj, _elm_win_obj_intercept_raise, sd);
2913    evas_object_intercept_lower_callback_add
2914      (obj, _elm_win_obj_intercept_lower, sd);
2915    evas_object_intercept_stack_above_callback_add
2916      (obj, _elm_win_obj_intercept_stack_above, sd);
2917    evas_object_intercept_stack_below_callback_add
2918      (obj, _elm_win_obj_intercept_stack_below, sd);
2919    evas_object_intercept_layer_set_callback_add
2920      (obj, _elm_win_obj_intercept_layer_set, sd);
2921    evas_object_intercept_show_callback_add
2922      (obj, _elm_win_obj_intercept_show, sd);
2923    evas_object_intercept_move_callback_add
2924      (obj, _ecore_evas_move_, sd);
2925
2926    TRAP(sd, name_class_set, name, _elm_appname);
2927    ecore_evas_callback_delete_request_set(sd->ee, _elm_win_delete_request);
2928    ecore_evas_callback_resize_set(sd->ee, _elm_win_resize);
2929    ecore_evas_callback_mouse_in_set(sd->ee, _elm_win_mouse_in);
2930    ecore_evas_callback_focus_in_set(sd->ee, _elm_win_focus_in);
2931    ecore_evas_callback_focus_out_set(sd->ee, _elm_win_focus_out);
2932    ecore_evas_callback_move_set(sd->ee, _elm_win_move);
2933    ecore_evas_callback_state_change_set(sd->ee, _elm_win_state_change);
2934    evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _elm_win_cb_hide, sd);
2935    evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _elm_win_cb_show, sd);
2936
2937    evas_image_cache_set(sd->evas, (_elm_config->image_cache * 1024));
2938    evas_font_cache_set(sd->evas, (_elm_config->font_cache * 1024));
2939
2940    EINA_LIST_FOREACH(_elm_config->font_dirs, l, fontpath)
2941      evas_font_path_append(sd->evas, fontpath);
2942
2943    if (!_elm_config->font_hinting)
2944      evas_font_hinting_set(sd->evas, EVAS_FONT_HINTING_NONE);
2945    else if (_elm_config->font_hinting == 1)
2946      evas_font_hinting_set(sd->evas, EVAS_FONT_HINTING_AUTO);
2947    else if (_elm_config->font_hinting == 2)
2948      evas_font_hinting_set(sd->evas, EVAS_FONT_HINTING_BYTECODE);
2949
2950 #ifdef HAVE_ELEMENTARY_X
2951    _elm_win_xwin_type_set(sd);
2952    _elm_win_xwin_update(sd);
2953 #endif
2954
2955    _elm_win_list = eina_list_append(_elm_win_list, obj);
2956    _elm_win_count++;
2957
2958    if (((fallback) && (!strcmp(fallback, "Software FB"))) ||
2959        ((!fallback) && (ENGINE_COMPARE(ELM_SOFTWARE_FB))))
2960      {
2961         TRAP(sd, fullscreen_set, 1);
2962      }
2963    else if ((type != ELM_WIN_INLINED_IMAGE) &&
2964             (ENGINE_COMPARE(ELM_WAYLAND_SHM) ||
2965              ENGINE_COMPARE(ELM_WAYLAND_EGL)))
2966      _elm_win_frame_add(sd, "default");
2967
2968    if (_elm_config->focus_highlight_enable)
2969      elm_win_focus_highlight_enabled_set(obj, EINA_TRUE);
2970
2971 #ifdef ELM_DEBUG
2972    Evas_Modifier_Mask mask = evas_key_modifier_mask_get(sd->evas, "Control");
2973    evas_object_event_callback_add
2974      (obj, EVAS_CALLBACK_KEY_DOWN, _debug_key_down, sd);
2975
2976    if (evas_object_key_grab(obj, "F12", mask, 0, EINA_TRUE))
2977      INF("Ctrl+F12 key combination exclusive for dot tree generation\n");
2978    else
2979      ERR("failed to grab F12 key to elm widgets (dot) tree generation");
2980 #endif
2981
2982    if ((_elm_config->softcursor_mode == ELM_SOFTCURSOR_MODE_ON) ||
2983        ((_elm_config->softcursor_mode == ELM_SOFTCURSOR_MODE_AUTO) &&
2984            (((fallback) && (!strcmp(fallback, "Software FB"))) ||
2985                ((!fallback) && (ENGINE_COMPARE(ELM_SOFTWARE_FB))))))
2986      {
2987         Evas_Object *o;
2988         Evas_Coord mw = 1, mh = 1, hx = 0, hy = 0;
2989
2990         sd->pointer.obj = o = edje_object_add(ecore_evas_get(tmp_sd.ee));
2991         _elm_theme_object_set(obj, o, "pointer", "base", "default");
2992         edje_object_size_min_calc(o, &mw, &mh);
2993         evas_object_resize(o, mw, mh);
2994         edje_object_part_geometry_get(o, "elm.swallow.hotspot",
2995                                       &hx, &hy, NULL, NULL);
2996         sd->pointer.hot_x = hx;
2997         sd->pointer.hot_y = hy;
2998         evas_object_show(o);
2999         ecore_evas_object_cursor_set(tmp_sd.ee, o, EVAS_LAYER_MAX, hx, hy);
3000      }
3001    else if (_elm_config->softcursor_mode == ELM_SOFTCURSOR_MODE_OFF)
3002      {
3003         // do nothing
3004      }
3005
3006    sd->wm_rot.wm_supported = ecore_evas_wm_rotation_supported_get(sd->ee);
3007    sd->wm_rot.preferred_rot = -1; // it means that elm_win doesn't use preferred rotation.
3008
3009    return obj;
3010 }
3011
3012 EAPI Evas_Object *
3013 elm_win_util_standard_add(const char *name,
3014                           const char *title)
3015 {
3016    Evas_Object *win, *bg;
3017
3018    win = elm_win_add(NULL, name, ELM_WIN_BASIC);
3019    if (!win) return NULL;
3020
3021    elm_win_title_set(win, title);
3022    bg = elm_bg_add(win);
3023    if (!bg)
3024      {
3025         evas_object_del(win);
3026         return NULL;
3027      }
3028    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3029    elm_win_resize_object_add(win, bg);
3030    evas_object_show(bg);
3031
3032    return win;
3033 }
3034
3035 EAPI void
3036 elm_win_resize_object_add(Evas_Object *obj,
3037                           Evas_Object *subobj)
3038 {
3039    Evas_Coord w, h;
3040
3041    ELM_WIN_CHECK(obj);
3042    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3043
3044    if (eina_list_data_find(sd->resize_objs, subobj)) return;
3045
3046    if (!ELM_WIDGET_DATA(sd)->api->sub_object_add(obj, subobj))
3047      ERR("could not add %p as sub object of %p", subobj, obj);
3048
3049    sd->resize_objs = eina_list_append(sd->resize_objs, subobj);
3050
3051    evas_object_event_callback_add
3052      (subobj, EVAS_CALLBACK_DEL, _elm_win_on_resize_obj_del, obj);
3053    evas_object_event_callback_add
3054      (subobj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
3055      _elm_win_on_resize_obj_changed_size_hints, obj);
3056
3057    evas_object_geometry_get(obj, NULL, NULL, &w, &h);
3058    evas_object_move(subobj, 0, 0);
3059    evas_object_resize(subobj, w, h);
3060
3061    _elm_win_resize_objects_eval(obj);
3062 }
3063
3064 EAPI void
3065 elm_win_resize_object_del(Evas_Object *obj,
3066                           Evas_Object *subobj)
3067 {
3068    ELM_WIN_CHECK(obj);
3069    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3070
3071    if (!ELM_WIDGET_DATA(sd)->api->sub_object_del(obj, subobj))
3072      ERR("could not remove sub object %p from %p", subobj, obj);
3073
3074    sd->resize_objs = eina_list_remove(sd->resize_objs, subobj);
3075
3076    evas_object_event_callback_del_full
3077      (subobj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
3078      _elm_win_on_resize_obj_changed_size_hints, obj);
3079    evas_object_event_callback_del_full
3080      (subobj, EVAS_CALLBACK_DEL, _elm_win_on_resize_obj_del, obj);
3081
3082    _elm_win_resize_objects_eval(obj);
3083 }
3084
3085 EAPI void
3086 elm_win_title_set(Evas_Object *obj,
3087                   const char *title)
3088 {
3089    ELM_WIN_CHECK(obj);
3090    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3091
3092    if (!title) return;
3093    eina_stringshare_replace(&(sd->title), title);
3094    TRAP(sd, title_set, sd->title);
3095    if (sd->frame_obj)
3096      edje_object_part_text_escaped_set
3097        (sd->frame_obj, "elm.text.title", sd->title);
3098 }
3099
3100 EAPI const char *
3101 elm_win_title_get(const Evas_Object *obj)
3102 {
3103    ELM_WIN_CHECK(obj) NULL;
3104    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, NULL);
3105
3106    return sd->title;
3107 }
3108
3109 EAPI void
3110 elm_win_icon_name_set(Evas_Object *obj,
3111                       const char *icon_name)
3112 {
3113    ELM_WIN_CHECK(obj);
3114    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3115
3116    if (!icon_name) return;
3117    eina_stringshare_replace(&(sd->icon_name), icon_name);
3118 #ifdef HAVE_ELEMENTARY_X
3119    _elm_win_xwin_update(sd);
3120 #endif
3121 }
3122
3123 EAPI const char *
3124 elm_win_icon_name_get(const Evas_Object *obj)
3125 {
3126    ELM_WIN_CHECK(obj) NULL;
3127    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, NULL);
3128
3129    return sd->icon_name;
3130 }
3131
3132 EAPI void
3133 elm_win_role_set(Evas_Object *obj, const char *role)
3134 {
3135    ELM_WIN_CHECK(obj);
3136    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3137
3138    if (!role) return;
3139    eina_stringshare_replace(&(sd->role), role);
3140 #ifdef HAVE_ELEMENTARY_X
3141    _elm_win_xwin_update(sd);
3142 #endif
3143 }
3144
3145 EAPI const char *
3146 elm_win_role_get(const Evas_Object *obj)
3147 {
3148    ELM_WIN_CHECK(obj) NULL;
3149    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, NULL);
3150
3151    return sd->role;
3152 }
3153
3154 EAPI void
3155 elm_win_icon_object_set(Evas_Object *obj,
3156                         Evas_Object *icon)
3157 {
3158    ELM_WIN_CHECK(obj);
3159    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3160
3161    if (sd->icon)
3162      evas_object_event_callback_del_full
3163        (sd->icon, EVAS_CALLBACK_DEL, _elm_win_on_icon_del, sd);
3164    sd->icon = icon;
3165    if (sd->icon)
3166      evas_object_event_callback_add
3167        (sd->icon, EVAS_CALLBACK_DEL, _elm_win_on_icon_del, sd);
3168 #ifdef HAVE_ELEMENTARY_X
3169    _elm_win_xwin_update(sd);
3170 #endif
3171 }
3172
3173 EAPI const Evas_Object *
3174 elm_win_icon_object_get(const Evas_Object *obj)
3175 {
3176    ELM_WIN_CHECK(obj) NULL;
3177    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, NULL);
3178
3179    return sd->icon;
3180 }
3181
3182 EAPI void
3183 elm_win_autodel_set(Evas_Object *obj,
3184                     Eina_Bool autodel)
3185 {
3186    ELM_WIN_CHECK(obj);
3187    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3188
3189    sd->autodel = autodel;
3190 }
3191
3192 EAPI Eina_Bool
3193 elm_win_autodel_get(const Evas_Object *obj)
3194 {
3195    ELM_WIN_CHECK(obj) EINA_FALSE;
3196    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
3197
3198    return sd->autodel;
3199 }
3200
3201 EAPI void
3202 elm_win_activate(Evas_Object *obj)
3203 {
3204    ELM_WIN_CHECK(obj);
3205    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3206
3207    TRAP(sd, activate);
3208 }
3209
3210 EAPI void
3211 elm_win_lower(Evas_Object *obj)
3212 {
3213    ELM_WIN_CHECK(obj);
3214    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3215
3216    TRAP(sd, lower);
3217 }
3218
3219 EAPI void
3220 elm_win_raise(Evas_Object *obj)
3221 {
3222    ELM_WIN_CHECK(obj);
3223    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3224
3225    TRAP(sd, raise);
3226 }
3227
3228 EAPI void
3229 elm_win_center(Evas_Object *obj,
3230                Eina_Bool h,
3231                Eina_Bool v)
3232 {
3233    int win_w, win_h, screen_w, screen_h, nx, ny;
3234
3235    ELM_WIN_CHECK(obj);
3236    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3237
3238    if ((trap) && (trap->center) && (!trap->center(sd->trap_data, obj)))
3239      return;
3240
3241    ecore_evas_screen_geometry_get(sd->ee, NULL, NULL, &screen_w, &screen_h);
3242    if ((!screen_w) || (!screen_h)) return;
3243
3244    evas_object_geometry_get(obj, NULL, NULL, &win_w, &win_h);
3245    if ((!win_w) || (!win_h)) return;
3246
3247    if (h) nx = win_w >= screen_w ? 0 : (screen_w / 2) - (win_w / 2);
3248    else nx = sd->screen.x;
3249    if (v) ny = win_h >= screen_h ? 0 : (screen_h / 2) - (win_h / 2);
3250    else ny = sd->screen.y;
3251    if (nx < 0) nx = 0;
3252    if (ny < 0) ny = 0;
3253
3254    evas_object_move(obj, nx, ny);
3255 }
3256
3257 EAPI void
3258 elm_win_borderless_set(Evas_Object *obj,
3259                        Eina_Bool borderless)
3260 {
3261    ELM_WIN_CHECK(obj);
3262    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3263
3264    TRAP(sd, borderless_set, borderless);
3265 #ifdef HAVE_ELEMENTARY_X
3266    _elm_win_xwin_update(sd);
3267 #endif
3268 }
3269
3270 EAPI Eina_Bool
3271 elm_win_borderless_get(const Evas_Object *obj)
3272 {
3273    ELM_WIN_CHECK(obj) EINA_FALSE;
3274    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
3275
3276    return ecore_evas_borderless_get(sd->ee);
3277 }
3278
3279 EAPI void
3280 elm_win_shaped_set(Evas_Object *obj,
3281                    Eina_Bool shaped)
3282 {
3283    ELM_WIN_CHECK(obj);
3284    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3285
3286    TRAP(sd, shaped_set, shaped);
3287 #ifdef HAVE_ELEMENTARY_X
3288    _elm_win_xwin_update(sd);
3289 #endif
3290 }
3291
3292 EAPI Eina_Bool
3293 elm_win_shaped_get(const Evas_Object *obj)
3294 {
3295    ELM_WIN_CHECK(obj) EINA_FALSE;
3296    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
3297
3298    return ecore_evas_shaped_get(sd->ee);
3299 }
3300
3301 EAPI void
3302 elm_win_alpha_set(Evas_Object *obj,
3303                   Eina_Bool alpha)
3304 {
3305    ELM_WIN_CHECK(obj);
3306    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3307
3308    if (sd->img_obj)
3309      {
3310         evas_object_image_alpha_set(sd->img_obj, alpha);
3311         ecore_evas_alpha_set(sd->ee, alpha);
3312      }
3313    else
3314      {
3315 #ifdef HAVE_ELEMENTARY_X
3316         if (sd->x.xwin)
3317           {
3318              if (alpha)
3319                {
3320                   if (!ecore_x_screen_is_composited(0))
3321                     elm_win_shaped_set(obj, alpha);
3322                   else
3323                     TRAP(sd, alpha_set, alpha);
3324                }
3325              else
3326                TRAP(sd, alpha_set, alpha);
3327              _elm_win_xwin_type_set(sd);
3328              _elm_win_xwin_update(sd);
3329           }
3330         else
3331 #endif
3332           TRAP(sd, alpha_set, alpha);
3333      }
3334 }
3335
3336 EAPI Eina_Bool
3337 elm_win_alpha_get(const Evas_Object *obj)
3338 {
3339    ELM_WIN_CHECK(obj) EINA_FALSE;
3340    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
3341
3342    if (sd->img_obj)
3343      {
3344         return evas_object_image_alpha_get(sd->img_obj);
3345      }
3346
3347    return ecore_evas_alpha_get(sd->ee);
3348 }
3349
3350 EAPI void
3351 elm_win_override_set(Evas_Object *obj,
3352                      Eina_Bool override)
3353 {
3354    ELM_WIN_CHECK(obj);
3355    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3356
3357    TRAP(sd, override_set, override);
3358 #ifdef HAVE_ELEMENTARY_X
3359    _elm_win_xwin_update(sd);
3360 #endif
3361 }
3362
3363 EAPI Eina_Bool
3364 elm_win_override_get(const Evas_Object *obj)
3365 {
3366    ELM_WIN_CHECK(obj) EINA_FALSE;
3367    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
3368
3369    return ecore_evas_override_get(sd->ee);
3370 }
3371
3372 EAPI void
3373 elm_win_fullscreen_set(Evas_Object *obj,
3374                        Eina_Bool fullscreen)
3375 {
3376    ELM_WIN_CHECK(obj);
3377    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3378    // YYY: handle if sd->img_obj
3379    if (ENGINE_COMPARE(ELM_SOFTWARE_FB) ||
3380        ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE))
3381      {
3382         // these engines... can ONLY be fullscreen
3383         return;
3384      }
3385    else
3386      {
3387 //        sd->fullscreen = fullscreen;
3388
3389         if (fullscreen)
3390           {
3391              if (ENGINE_COMPARE(ELM_WAYLAND_SHM) ||
3392                  ENGINE_COMPARE(ELM_WAYLAND_EGL))
3393                _elm_win_frame_del(sd);
3394           }
3395         else
3396           {
3397              if (ENGINE_COMPARE(ELM_WAYLAND_SHM) ||
3398                  ENGINE_COMPARE(ELM_WAYLAND_EGL))
3399                _elm_win_frame_add(sd, "default");
3400
3401              evas_object_show(sd->frame_obj);
3402           }
3403
3404         TRAP(sd, fullscreen_set, fullscreen);
3405 #ifdef HAVE_ELEMENTARY_X
3406         _elm_win_xwin_update(sd);
3407 #endif
3408      }
3409 }
3410
3411 EAPI Eina_Bool
3412 elm_win_fullscreen_get(const Evas_Object *obj)
3413 {
3414    ELM_WIN_CHECK(obj) EINA_FALSE;
3415    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
3416
3417    if (ENGINE_COMPARE(ELM_SOFTWARE_FB) ||
3418        ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE))
3419      {
3420         // these engines... can ONLY be fullscreen
3421         return EINA_TRUE;
3422      }
3423    else
3424      {
3425         return sd->fullscreen;
3426      }
3427 }
3428
3429 EAPI void
3430 elm_win_maximized_set(Evas_Object *obj,
3431                       Eina_Bool maximized)
3432 {
3433    ELM_WIN_CHECK(obj);
3434    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3435
3436 //   sd->maximized = maximized;
3437    // YYY: handle if sd->img_obj
3438    TRAP(sd, maximized_set, maximized);
3439 #ifdef HAVE_ELEMENTARY_X
3440    _elm_win_xwin_update(sd);
3441 #endif
3442 }
3443
3444 EAPI Eina_Bool
3445 elm_win_maximized_get(const Evas_Object *obj)
3446 {
3447    ELM_WIN_CHECK(obj) EINA_FALSE;
3448    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
3449
3450    return sd->maximized;
3451 }
3452
3453 EAPI void
3454 elm_win_iconified_set(Evas_Object *obj,
3455                       Eina_Bool iconified)
3456 {
3457    ELM_WIN_CHECK(obj);
3458    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3459
3460 //   sd->iconified = iconified;
3461    TRAP(sd, iconified_set, iconified);
3462 #ifdef HAVE_ELEMENTARY_X
3463    _elm_win_xwin_update(sd);
3464 #endif
3465 }
3466
3467 EAPI Eina_Bool
3468 elm_win_iconified_get(const Evas_Object *obj)
3469 {
3470    ELM_WIN_CHECK(obj) EINA_FALSE;
3471    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
3472
3473    return sd->iconified;
3474 }
3475
3476 EAPI void
3477 elm_win_withdrawn_set(Evas_Object *obj,
3478                       Eina_Bool withdrawn)
3479 {
3480    ELM_WIN_CHECK(obj);
3481    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3482
3483 //   sd->withdrawn = withdrawn;
3484    TRAP(sd, withdrawn_set, withdrawn);
3485 #ifdef HAVE_ELEMENTARY_X
3486    _elm_win_xwin_update(sd);
3487 #endif
3488 }
3489
3490 EAPI Eina_Bool
3491 elm_win_withdrawn_get(const Evas_Object *obj)
3492 {
3493    ELM_WIN_CHECK(obj) EINA_FALSE;
3494    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
3495
3496    return sd->withdrawn;
3497 }
3498
3499 EAPI void
3500 elm_win_profiles_set(Evas_Object  *obj,
3501                      const char  **profiles,
3502                      unsigned int  num_profiles)
3503 {
3504    char **profiles_int;
3505    const char *str;
3506    unsigned int i, num;
3507    Eina_List *l;
3508
3509    ELM_WIN_CHECK(obj);
3510    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3511
3512    if (!profiles) return;
3513
3514    if (sd->profile.timer) ecore_timer_del(sd->profile.timer);
3515    sd->profile.timer = ecore_timer_add(0.1, _elm_win_profile_change_delay, sd);
3516    EINA_LIST_FREE(sd->profile.names, str) eina_stringshare_del(str);
3517
3518    for (i = 0; i < num_profiles; i++)
3519      {
3520         if ((profiles[i]) &&
3521             _elm_config_profile_exists(profiles[i]))
3522           {
3523              str = eina_stringshare_add(profiles[i]);
3524              sd->profile.names = eina_list_append(sd->profile.names, str);
3525           }
3526      }
3527
3528    num = eina_list_count(sd->profile.names);
3529    profiles_int = alloca(num * sizeof(char *));
3530
3531    if (profiles_int)
3532      {
3533         i = 0;
3534         EINA_LIST_FOREACH(sd->profile.names, l, str)
3535           {
3536              if (str)
3537                profiles_int[i] = strdup(str);
3538              else
3539                profiles_int[i] = NULL;
3540              i++;
3541           }
3542         ecore_evas_profiles_set(sd->ee, (const char **)profiles_int, i);
3543         for (i = 0; i < num; i++)
3544           {
3545              if (profiles_int[i]) free(profiles_int[i]);
3546           }
3547      }
3548    else
3549      ecore_evas_profiles_set(sd->ee, profiles, num_profiles);
3550 }
3551
3552 EAPI const char *
3553 elm_win_profile_get(const Evas_Object *obj)
3554 {
3555    ELM_WIN_CHECK(obj) NULL;
3556    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, NULL);
3557
3558    return sd->profile.name;
3559 }
3560
3561 EAPI void
3562 elm_win_urgent_set(Evas_Object *obj,
3563                    Eina_Bool urgent)
3564 {
3565    ELM_WIN_CHECK(obj);
3566    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3567
3568    sd->urgent = urgent;
3569    TRAP(sd, urgent_set, urgent);
3570 #ifdef HAVE_ELEMENTARY_X
3571    _elm_win_xwin_update(sd);
3572 #endif
3573 }
3574
3575 EAPI Eina_Bool
3576 elm_win_urgent_get(const Evas_Object *obj)
3577 {
3578    ELM_WIN_CHECK(obj) EINA_FALSE;
3579    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
3580
3581    return sd->urgent;
3582 }
3583
3584 EAPI void
3585 elm_win_demand_attention_set(Evas_Object *obj,
3586                              Eina_Bool demand_attention)
3587 {
3588    ELM_WIN_CHECK(obj);
3589    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3590
3591    sd->demand_attention = demand_attention;
3592    TRAP(sd, demand_attention_set, demand_attention);
3593 #ifdef HAVE_ELEMENTARY_X
3594    _elm_win_xwin_update(sd);
3595 #endif
3596 }
3597
3598 EAPI Eina_Bool
3599 elm_win_demand_attention_get(const Evas_Object *obj)
3600 {
3601    ELM_WIN_CHECK(obj) EINA_FALSE;
3602    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
3603
3604    return sd->demand_attention;
3605 }
3606
3607 EAPI void
3608 elm_win_modal_set(Evas_Object *obj,
3609                   Eina_Bool modal)
3610 {
3611    ELM_WIN_CHECK(obj);
3612    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3613
3614    sd->modal = modal;
3615    TRAP(sd, modal_set, modal);
3616 #ifdef HAVE_ELEMENTARY_X
3617    _elm_win_xwin_update(sd);
3618 #endif
3619 }
3620
3621 EAPI Eina_Bool
3622 elm_win_modal_get(const Evas_Object *obj)
3623 {
3624    ELM_WIN_CHECK(obj) EINA_FALSE;
3625    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
3626
3627    return sd->modal;
3628 }
3629
3630 EAPI void
3631 elm_win_aspect_set(Evas_Object *obj,
3632                    double aspect)
3633 {
3634    ELM_WIN_CHECK(obj);
3635    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3636
3637    sd->aspect = aspect;
3638    TRAP(sd, aspect_set, aspect);
3639 #ifdef HAVE_ELEMENTARY_X
3640    _elm_win_xwin_update(sd);
3641 #endif
3642 }
3643
3644 EAPI double
3645 elm_win_aspect_get(const Evas_Object *obj)
3646 {
3647    ELM_WIN_CHECK(obj) 0.0;
3648    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, 0.0);
3649
3650    return sd->aspect;
3651 }
3652
3653 EAPI void
3654 elm_win_size_base_set(Evas_Object *obj, int w, int h)
3655 {
3656    ELM_WIN_CHECK(obj);
3657    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3658    sd->size_base_w = w;
3659    sd->size_base_h = h;
3660    TRAP(sd, size_base_set, w, h);
3661 #ifdef HAVE_ELEMENTARY_X
3662    _elm_win_xwin_update(sd);
3663 #endif
3664 }
3665
3666 EAPI void
3667 elm_win_size_base_get(Evas_Object *obj, int *w, int *h)
3668 {
3669    ELM_WIN_CHECK(obj);
3670    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3671    if (w) *w = sd->size_base_w;
3672    if (w) *h = sd->size_base_h;
3673 }
3674
3675 EAPI void
3676 elm_win_size_step_set(Evas_Object *obj, int w, int h)
3677 {
3678    ELM_WIN_CHECK(obj);
3679    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3680    sd->size_step_w = w;
3681    sd->size_step_h = h;
3682    TRAP(sd, size_step_set, w, h);
3683 #ifdef HAVE_ELEMENTARY_X
3684    _elm_win_xwin_update(sd);
3685 #endif
3686 }
3687
3688 EAPI void
3689 elm_win_size_step_get(Evas_Object *obj, int *w, int *h)
3690 {
3691    ELM_WIN_CHECK(obj);
3692    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3693    if (w) *w = sd->size_step_w;
3694    if (w) *h = sd->size_step_h;
3695 }
3696
3697 EAPI void
3698 elm_win_layer_set(Evas_Object *obj,
3699                   int layer)
3700 {
3701    ELM_WIN_CHECK(obj);
3702    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3703
3704    TRAP(sd, layer_set, layer);
3705 #ifdef HAVE_ELEMENTARY_X
3706    _elm_win_xwin_update(sd);
3707 #endif
3708 }
3709
3710 EAPI int
3711 elm_win_layer_get(const Evas_Object *obj)
3712 {
3713    ELM_WIN_CHECK(obj) - 1;
3714    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, -1);
3715
3716    return ecore_evas_layer_get(sd->ee);
3717 }
3718
3719 EAPI void
3720 elm_win_norender_push(Evas_Object *obj)
3721 {
3722    ELM_WIN_CHECK(obj);
3723    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3724
3725    sd->norender++;
3726    if (sd->norender == 1) ecore_evas_manual_render_set(sd->ee, EINA_TRUE);
3727 }
3728
3729 EAPI void
3730 elm_win_norender_pop(Evas_Object *obj)
3731 {
3732    ELM_WIN_CHECK(obj);
3733    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3734
3735    if (sd->norender <= 0) return;
3736    sd->norender--;
3737    if (sd->norender == 0) ecore_evas_manual_render_set(sd->ee, EINA_FALSE);
3738 }
3739
3740 EAPI int
3741 elm_win_norender_get(Evas_Object *obj)
3742 {
3743    ELM_WIN_CHECK(obj) - 1;
3744    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, -1);
3745    return sd->norender;
3746 }
3747
3748 EAPI void
3749 elm_win_render(Evas_Object *obj)
3750 {
3751    ELM_WIN_CHECK(obj);
3752    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3753    ecore_evas_manual_render(sd->ee);
3754 }
3755
3756 static int
3757 _win_rotation_degree_check(int rotation)
3758 {
3759    if ((rotation > 360) || (rotation < 0))
3760      {
3761         WRN("Rotation degree should be 0 ~ 360 (passed degree: %d)", rotation);
3762         rotation %= 360;
3763         if (rotation < 0) rotation += 360;
3764      }
3765    return rotation;
3766 }
3767
3768 static void
3769 _win_rotate(Evas_Object *obj, Elm_Win_Smart_Data *sd, int rotation, Eina_Bool resize)
3770 {
3771    rotation = _win_rotation_degree_check(rotation);
3772    if (sd->rot == rotation) return;
3773    sd->rot = rotation;
3774    if (resize) TRAP(sd, rotation_with_resize_set, rotation);
3775    else TRAP(sd, rotation_set, rotation);
3776    evas_object_size_hint_min_set(obj, -1, -1);
3777    evas_object_size_hint_max_set(obj, -1, -1);
3778    _elm_win_resize_objects_eval(obj);
3779 #ifdef HAVE_ELEMENTARY_X
3780    _elm_win_xwin_update(sd);
3781 #endif
3782    elm_widget_orientation_set(obj, rotation);
3783    evas_object_smart_callback_call(obj, SIG_ROTATION_CHANGED, NULL);
3784 }
3785
3786 EAPI void
3787 elm_win_rotation_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_FALSE);
3793 }
3794
3795 EAPI void
3796 elm_win_rotation_with_resize_set(Evas_Object *obj,
3797                                  int rotation)
3798 {
3799    ELM_WIN_CHECK(obj);
3800    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3801    _win_rotate(obj, sd, rotation, EINA_TRUE);
3802 }
3803
3804 EAPI int
3805 elm_win_rotation_get(const Evas_Object *obj)
3806 {
3807    ELM_WIN_CHECK(obj) - 1;
3808    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, -1);
3809
3810    return sd->rot;
3811 }
3812
3813 EAPI Eina_Bool
3814 elm_win_wm_rotation_supported_get(const Evas_Object *obj)
3815 {
3816    ELM_WIN_CHECK(obj) EINA_FALSE;
3817    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
3818    return sd->wm_rot.wm_supported;
3819 }
3820
3821 /* This will unset a preferred rotation, if given preferred rotation is '-1'.
3822  */
3823 EAPI void
3824 elm_win_wm_rotation_preferred_rotation_set(Evas_Object *obj,
3825                                            const int rotation)
3826 {
3827    int rot;
3828
3829    ELM_WIN_CHECK(obj);
3830    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3831
3832    if (!sd->wm_rot.use)
3833      sd->wm_rot.use = EINA_TRUE;
3834
3835    // '-1' means that elm_win doesn't use preferred rotation.
3836    if (rotation == -1)
3837      rot = -1;
3838    else
3839      rot = _win_rotation_degree_check(rotation);
3840
3841    if (sd->wm_rot.preferred_rot == rot) return;
3842    sd->wm_rot.preferred_rot = rot;
3843
3844    ecore_evas_wm_rotation_preferred_rotation_set(sd->ee, rot);
3845 }
3846
3847 EAPI int
3848 elm_win_wm_rotation_preferred_rotation_get(const Evas_Object *obj)
3849 {
3850    ELM_WIN_CHECK(obj) -1;
3851    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, -1);
3852    if (!sd->wm_rot.use) return -1;
3853    return sd->wm_rot.preferred_rot;
3854 }
3855
3856 EAPI void
3857 elm_win_wm_rotation_available_rotations_set(Evas_Object *obj,
3858                                             const int   *rotations,
3859                                             unsigned int count)
3860 {
3861    unsigned int i;
3862    int r;
3863
3864    ELM_WIN_CHECK(obj);
3865    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3866
3867    if (!sd->wm_rot.use)
3868      sd->wm_rot.use = EINA_TRUE;
3869
3870    if (sd->wm_rot.rots) free(sd->wm_rot.rots);
3871
3872    sd->wm_rot.rots = NULL;
3873    sd->wm_rot.count = 0;
3874
3875    if (count > 0)
3876      {
3877         sd->wm_rot.rots = calloc(count, sizeof(int));
3878         if (!sd->wm_rot.rots) return;
3879         for (i = 0; i < count; i++)
3880           {
3881              r = _win_rotation_degree_check(rotations[i]);
3882              sd->wm_rot.rots[i] = r;
3883           }
3884      }
3885
3886    sd->wm_rot.count = count;
3887
3888    ecore_evas_wm_rotation_available_rotations_set(sd->ee,
3889                                                   sd->wm_rot.rots,
3890                                                   sd->wm_rot.count);
3891 }
3892
3893 EAPI Eina_Bool
3894 elm_win_wm_rotation_available_rotations_get(const Evas_Object *obj,
3895                                             int              **rotations,
3896                                             unsigned int      *count)
3897 {
3898    ELM_WIN_CHECK(obj) EINA_FALSE;
3899    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
3900    if (!sd->wm_rot.use) return EINA_FALSE;
3901
3902    if (sd->wm_rot.count > 0)
3903      {
3904         if ((rotations) && (*rotations))
3905           {
3906              *rotations = calloc(sd->wm_rot.count, sizeof(int));
3907              if (*rotations)
3908                {
3909                   memcpy(*rotations,
3910                          sd->wm_rot.rots,
3911                          sizeof(int) * sd->wm_rot.count);
3912                }
3913           }
3914      }
3915
3916    if (count) *count = sd->wm_rot.count;
3917
3918    return EINA_TRUE;
3919 }
3920
3921 EAPI void
3922 elm_win_sticky_set(Evas_Object *obj,
3923                    Eina_Bool sticky)
3924 {
3925    ELM_WIN_CHECK(obj);
3926    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3927
3928 //   sd->sticky = sticky;
3929    TRAP(sd, sticky_set, sticky);
3930 #ifdef HAVE_ELEMENTARY_X
3931    _elm_win_xwin_update(sd);
3932 #endif
3933 }
3934
3935 EAPI Eina_Bool
3936 elm_win_sticky_get(const Evas_Object *obj)
3937 {
3938    ELM_WIN_CHECK(obj) EINA_FALSE;
3939    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
3940
3941    return sd->sticky;
3942 }
3943
3944 EAPI void
3945 elm_win_keyboard_mode_set(Evas_Object *obj,
3946                           Elm_Win_Keyboard_Mode mode)
3947 {
3948    ELM_WIN_CHECK(obj);
3949    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3950
3951    if (mode == sd->kbdmode) return;
3952 #ifdef HAVE_ELEMENTARY_X
3953    _elm_win_xwindow_get(sd);
3954 #endif
3955    sd->kbdmode = mode;
3956 #ifdef HAVE_ELEMENTARY_X
3957    if (sd->x.xwin)
3958      ecore_x_e_virtual_keyboard_state_set
3959        (sd->x.xwin, (Ecore_X_Virtual_Keyboard_State)sd->kbdmode);
3960 #endif
3961 }
3962
3963 EAPI Elm_Win_Keyboard_Mode
3964 elm_win_keyboard_mode_get(const Evas_Object *obj)
3965 {
3966    ELM_WIN_CHECK(obj) ELM_WIN_KEYBOARD_UNKNOWN;
3967    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, ELM_WIN_KEYBOARD_UNKNOWN);
3968
3969    return sd->kbdmode;
3970 }
3971
3972 EAPI void
3973 elm_win_keyboard_win_set(Evas_Object *obj,
3974                          Eina_Bool is_keyboard)
3975 {
3976    ELM_WIN_CHECK(obj);
3977    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
3978
3979 #ifdef HAVE_ELEMENTARY_X
3980    _elm_win_xwindow_get(sd);
3981    if (sd->x.xwin)
3982      ecore_x_e_virtual_keyboard_set(sd->x.xwin, is_keyboard);
3983 #else
3984    (void)is_keyboard;
3985 #endif
3986 }
3987
3988 EAPI Eina_Bool
3989 elm_win_keyboard_win_get(const Evas_Object *obj)
3990 {
3991    ELM_WIN_CHECK(obj) EINA_FALSE;
3992    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
3993
3994 #ifdef HAVE_ELEMENTARY_X
3995    _elm_win_xwindow_get(sd);
3996    if (sd->x.xwin)
3997      return ecore_x_e_virtual_keyboard_get(sd->x.xwin);
3998 #endif
3999    return EINA_FALSE;
4000 }
4001
4002 EAPI void
4003 elm_win_indicator_mode_set(Evas_Object *obj,
4004                            Elm_Win_Indicator_Mode mode)
4005 {
4006    ELM_WIN_CHECK(obj);
4007    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4008
4009    if (mode == sd->indmode) return;
4010 #ifdef HAVE_ELEMENTARY_X
4011    _elm_win_xwindow_get(sd);
4012 #endif
4013    sd->indmode = mode;
4014 #ifdef HAVE_ELEMENTARY_X
4015    if (sd->x.xwin)
4016      {
4017         if (sd->indmode == ELM_WIN_INDICATOR_SHOW)
4018           ecore_x_e_illume_indicator_state_set
4019             (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_STATE_ON);
4020         else if (sd->indmode == ELM_WIN_INDICATOR_HIDE)
4021           ecore_x_e_illume_indicator_state_set
4022             (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_STATE_OFF);
4023      }
4024 #endif
4025    evas_object_smart_callback_call(obj, SIG_INDICATOR_PROP_CHANGED, NULL);
4026 }
4027
4028 EAPI Elm_Win_Indicator_Mode
4029 elm_win_indicator_mode_get(const Evas_Object *obj)
4030 {
4031    ELM_WIN_CHECK(obj) ELM_WIN_INDICATOR_UNKNOWN;
4032    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, ELM_WIN_INDICATOR_UNKNOWN);
4033
4034    return sd->indmode;
4035 }
4036
4037 EAPI void
4038 elm_win_indicator_opacity_set(Evas_Object *obj,
4039                               Elm_Win_Indicator_Opacity_Mode mode)
4040 {
4041    ELM_WIN_CHECK(obj);
4042    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4043
4044    if (mode == sd->ind_o_mode) return;
4045    sd->ind_o_mode = mode;
4046 #ifdef HAVE_ELEMENTARY_X
4047    _elm_win_xwindow_get(sd);
4048    if (sd->x.xwin)
4049      {
4050         if (sd->ind_o_mode == ELM_WIN_INDICATOR_OPAQUE)
4051           ecore_x_e_illume_indicator_opacity_set
4052             (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_OPAQUE);
4053         else if (sd->ind_o_mode == ELM_WIN_INDICATOR_TRANSLUCENT)
4054           ecore_x_e_illume_indicator_opacity_set
4055             (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_TRANSLUCENT);
4056         else if (sd->ind_o_mode == ELM_WIN_INDICATOR_TRANSPARENT)
4057           ecore_x_e_illume_indicator_opacity_set
4058             (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_TRANSPARENT);
4059      }
4060 #endif
4061    evas_object_smart_callback_call(obj, SIG_INDICATOR_PROP_CHANGED, NULL);
4062 }
4063
4064 EAPI Elm_Win_Indicator_Opacity_Mode
4065 elm_win_indicator_opacity_get(const Evas_Object *obj)
4066 {
4067    ELM_WIN_CHECK(obj) ELM_WIN_INDICATOR_OPACITY_UNKNOWN;
4068    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, ELM_WIN_INDICATOR_OPACITY_UNKNOWN);
4069
4070    return sd->ind_o_mode;
4071 }
4072
4073 EAPI void
4074 elm_win_indicator_type_set(Evas_Object *obj,
4075                               Elm_Win_Indicator_Type_Mode mode)
4076 {
4077    ELM_WIN_CHECK(obj);
4078    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4079
4080    if (mode == sd->ind_t_mode) return;
4081    sd->ind_t_mode = mode;
4082 #ifdef HAVE_ELEMENTARY_X
4083    _elm_win_xwindow_get(sd);
4084    if (sd->x.xwin)
4085      {
4086         if (sd->ind_t_mode == ELM_WIN_INDICATOR_TYPE_1)
4087           ecore_x_e_illume_indicator_type_set
4088             (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_TYPE_1);
4089         else if (sd->ind_t_mode == ELM_WIN_INDICATOR_TYPE_2)
4090           ecore_x_e_illume_indicator_type_set
4091             (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_TYPE_2);
4092      }
4093 #endif
4094    //evas_object_smart_callback_call(obj, SIG_INDICATOR_PROP_CHANGED, NULL);
4095 }
4096
4097 EAPI Elm_Win_Indicator_Type_Mode
4098 elm_win_indicator_type_get(const Evas_Object *obj)
4099 {
4100    ELM_WIN_CHECK(obj) ELM_WIN_INDICATOR_TYPE_UNKNOWN;
4101    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, ELM_WIN_INDICATOR_TYPE_UNKNOWN);
4102
4103    return sd->ind_t_mode;
4104 }
4105 EAPI void
4106 elm_win_screen_position_get(const Evas_Object *obj,
4107                             int *x,
4108                             int *y)
4109 {
4110    ELM_WIN_CHECK(obj);
4111    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4112
4113    if (x) *x = sd->screen.x;
4114    if (y) *y = sd->screen.y;
4115 }
4116
4117 EAPI Eina_Bool
4118 elm_win_focus_get(const Evas_Object *obj)
4119 {
4120    ELM_WIN_CHECK(obj) EINA_FALSE;
4121    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
4122
4123    return ecore_evas_focus_get(sd->ee);
4124 }
4125
4126 EAPI void
4127 elm_win_screen_constrain_set(Evas_Object *obj,
4128                              Eina_Bool constrain)
4129 {
4130    ELM_WIN_CHECK(obj);
4131    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4132
4133    sd->constrain = !!constrain;
4134 }
4135
4136 EAPI Eina_Bool
4137 elm_win_screen_constrain_get(Evas_Object *obj)
4138 {
4139    ELM_WIN_CHECK(obj) EINA_FALSE;
4140    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
4141
4142    return sd->constrain;
4143 }
4144
4145 EAPI void
4146 elm_win_screen_size_get(const Evas_Object *obj,
4147                         int *x,
4148                         int *y,
4149                         int *w,
4150                         int *h)
4151 {
4152    ELM_WIN_CHECK(obj);
4153    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4154
4155    ecore_evas_screen_geometry_get(sd->ee, x, y, w, h);
4156 }
4157
4158 EAPI void
4159 elm_win_screen_dpi_get(const Evas_Object *obj,
4160                        int *xdpi,
4161                        int *ydpi)
4162 {
4163    ELM_WIN_CHECK(obj);
4164    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4165
4166    ecore_evas_screen_dpi_get(sd->ee, xdpi, ydpi);
4167 }
4168
4169 EAPI void
4170 elm_win_conformant_set(Evas_Object *obj,
4171                        Eina_Bool conformant)
4172 {
4173    ELM_WIN_CHECK(obj);
4174    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4175
4176 #ifdef HAVE_ELEMENTARY_X
4177    _elm_win_xwindow_get(sd);
4178    if (sd->x.xwin)
4179      ecore_x_e_illume_conformant_set(sd->x.xwin, conformant);
4180 #else
4181    (void)conformant;
4182 #endif
4183 }
4184
4185 EAPI Eina_Bool
4186 elm_win_conformant_get(const Evas_Object *obj)
4187 {
4188    ELM_WIN_CHECK(obj) EINA_FALSE;
4189    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
4190
4191 #ifdef HAVE_ELEMENTARY_X
4192    _elm_win_xwindow_get(sd);
4193    if (sd->x.xwin)
4194      return ecore_x_e_illume_conformant_get(sd->x.xwin);
4195 #endif
4196    return EINA_FALSE;
4197 }
4198
4199 EAPI void
4200 elm_win_quickpanel_set(Evas_Object *obj,
4201                        Eina_Bool quickpanel)
4202 {
4203    ELM_WIN_CHECK(obj);
4204    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4205 #ifdef HAVE_ELEMENTARY_X
4206    _elm_win_xwindow_get(sd);
4207    if (sd->x.xwin)
4208      {
4209         ecore_x_e_illume_quickpanel_set(sd->x.xwin, quickpanel);
4210         if (quickpanel)
4211           {
4212              Ecore_X_Window_State states[2];
4213
4214              states[0] = ECORE_X_WINDOW_STATE_SKIP_TASKBAR;
4215              states[1] = ECORE_X_WINDOW_STATE_SKIP_PAGER;
4216              ecore_x_netwm_window_state_set(sd->x.xwin, states, 2);
4217              ecore_x_icccm_hints_set(sd->x.xwin, 0, 0, 0, 0, 0, 0, 0);
4218           }
4219      }
4220 #else
4221    (void)quickpanel;
4222 #endif
4223 }
4224
4225 EAPI Eina_Bool
4226 elm_win_quickpanel_get(const Evas_Object *obj)
4227 {
4228    ELM_WIN_CHECK(obj) EINA_FALSE;
4229    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
4230
4231 #ifdef HAVE_ELEMENTARY_X
4232    _elm_win_xwindow_get(sd);
4233    if (sd->x.xwin)
4234      return ecore_x_e_illume_quickpanel_get(sd->x.xwin);
4235 #endif
4236    return EINA_FALSE;
4237 }
4238
4239 EAPI void
4240 elm_win_quickpanel_priority_major_set(Evas_Object *obj,
4241                                       int priority)
4242 {
4243    ELM_WIN_CHECK(obj);
4244    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4245
4246 #ifdef HAVE_ELEMENTARY_X
4247    _elm_win_xwindow_get(sd);
4248    if (sd->x.xwin)
4249      ecore_x_e_illume_quickpanel_priority_major_set(sd->x.xwin, priority);
4250 #else
4251    (void)priority;
4252 #endif
4253 }
4254
4255 EAPI int
4256 elm_win_quickpanel_priority_major_get(const Evas_Object *obj)
4257 {
4258    ELM_WIN_CHECK(obj) - 1;
4259    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, -1);
4260
4261 #ifdef HAVE_ELEMENTARY_X
4262    _elm_win_xwindow_get(sd);
4263    if (sd->x.xwin)
4264      return ecore_x_e_illume_quickpanel_priority_major_get(sd->x.xwin);
4265 #endif
4266    return -1;
4267 }
4268
4269 EAPI void
4270 elm_win_quickpanel_priority_minor_set(Evas_Object *obj,
4271                                       int priority)
4272 {
4273    ELM_WIN_CHECK(obj);
4274    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4275
4276 #ifdef HAVE_ELEMENTARY_X
4277    _elm_win_xwindow_get(sd);
4278    if (sd->x.xwin)
4279      ecore_x_e_illume_quickpanel_priority_minor_set(sd->x.xwin, priority);
4280 #else
4281    (void)priority;
4282 #endif
4283 }
4284
4285 EAPI int
4286 elm_win_quickpanel_priority_minor_get(const Evas_Object *obj)
4287 {
4288    ELM_WIN_CHECK(obj) - 1;
4289    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, -1);
4290
4291 #ifdef HAVE_ELEMENTARY_X
4292    _elm_win_xwindow_get(sd);
4293    if (sd->x.xwin)
4294      return ecore_x_e_illume_quickpanel_priority_minor_get(sd->x.xwin);
4295 #endif
4296    return -1;
4297 }
4298
4299 EAPI void
4300 elm_win_quickpanel_zone_set(Evas_Object *obj,
4301                             int zone)
4302 {
4303    ELM_WIN_CHECK(obj);
4304    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4305
4306 #ifdef HAVE_ELEMENTARY_X
4307    _elm_win_xwindow_get(sd);
4308    if (sd->x.xwin)
4309      ecore_x_e_illume_quickpanel_zone_set(sd->x.xwin, zone);
4310 #else
4311    (void)zone;
4312 #endif
4313 }
4314
4315 EAPI int
4316 elm_win_quickpanel_zone_get(const Evas_Object *obj)
4317 {
4318    ELM_WIN_CHECK(obj) 0;
4319    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, 0);
4320
4321 #ifdef HAVE_ELEMENTARY_X
4322    _elm_win_xwindow_get(sd);
4323    if (sd->x.xwin)
4324      return ecore_x_e_illume_quickpanel_zone_get(sd->x.xwin);
4325 #endif
4326    return 0;
4327 }
4328
4329 EAPI void
4330 elm_win_prop_focus_skip_set(Evas_Object *obj,
4331                             Eina_Bool skip)
4332 {
4333    ELM_WIN_CHECK(obj);
4334    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4335
4336    sd->skip_focus = skip;
4337    TRAP(sd, focus_skip_set, skip);
4338 }
4339
4340 EAPI void
4341 elm_win_illume_command_send(Evas_Object *obj,
4342                             Elm_Illume_Command command,
4343                             void *params __UNUSED__)
4344 {
4345    ELM_WIN_CHECK(obj);
4346    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4347
4348 #ifdef HAVE_ELEMENTARY_X
4349    _elm_win_xwindow_get(sd);
4350    if (sd->x.xwin)
4351      {
4352         switch (command)
4353           {
4354            case ELM_ILLUME_COMMAND_FOCUS_BACK:
4355              ecore_x_e_illume_focus_back_send(sd->x.xwin);
4356              break;
4357
4358            case ELM_ILLUME_COMMAND_FOCUS_FORWARD:
4359              ecore_x_e_illume_focus_forward_send(sd->x.xwin);
4360              break;
4361
4362            case ELM_ILLUME_COMMAND_FOCUS_HOME:
4363              ecore_x_e_illume_focus_home_send(sd->x.xwin);
4364              break;
4365
4366            case ELM_ILLUME_COMMAND_CLOSE:
4367              ecore_x_e_illume_close_send(sd->x.xwin);
4368              break;
4369
4370            default:
4371              break;
4372           }
4373      }
4374 #else
4375    (void)command;
4376 #endif
4377 }
4378
4379 EAPI Evas_Object *
4380 elm_win_inlined_image_object_get(Evas_Object *obj)
4381 {
4382    ELM_WIN_CHECK(obj) NULL;
4383    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, NULL);
4384
4385    return sd->img_obj;
4386 }
4387
4388 EAPI void
4389 elm_win_focus_highlight_enabled_set(Evas_Object *obj,
4390                                     Eina_Bool enabled)
4391 {
4392    ELM_WIN_CHECK(obj);
4393    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4394
4395    enabled = !!enabled;
4396    if (sd->focus_highlight.enabled == enabled)
4397      return;
4398
4399    sd->focus_highlight.enabled = enabled;
4400
4401    if (sd->focus_highlight.enabled)
4402      _elm_win_focus_highlight_init(sd);
4403    else
4404      _elm_win_focus_highlight_shutdown(sd);
4405 }
4406
4407 EAPI Eina_Bool
4408 elm_win_focus_highlight_enabled_get(const Evas_Object *obj)
4409 {
4410    ELM_WIN_CHECK(obj) EINA_FALSE;
4411    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
4412
4413    return sd->focus_highlight.enabled;
4414 }
4415
4416 EAPI void
4417 elm_win_focus_highlight_style_set(Evas_Object *obj,
4418                                   const char *style)
4419 {
4420    ELM_WIN_CHECK(obj);
4421    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4422
4423    eina_stringshare_replace(&sd->focus_highlight.style, style);
4424    sd->focus_highlight.changed_theme = EINA_TRUE;
4425    _elm_win_focus_highlight_reconfigure_job_start(sd);
4426 }
4427
4428 EAPI const char *
4429 elm_win_focus_highlight_style_get(const Evas_Object *obj)
4430 {
4431    ELM_WIN_CHECK(obj) NULL;
4432    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, NULL);
4433
4434    return sd->focus_highlight.style;
4435 }
4436
4437 EAPI Eina_Bool
4438 elm_win_socket_listen(Evas_Object *obj,
4439                       const char *svcname,
4440                       int svcnum,
4441                       Eina_Bool svcsys)
4442 {
4443    ELM_WIN_CHECK(obj) EINA_FALSE;
4444    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
4445
4446    if (!sd->ee) return EINA_FALSE;
4447
4448    if (!ecore_evas_extn_socket_listen(sd->ee, svcname, svcnum, svcsys))
4449      return EINA_FALSE;
4450
4451    return EINA_TRUE;
4452 }
4453
4454 /* windowing specific calls - shall we do this differently? */
4455
4456 EAPI Ecore_X_Window
4457 elm_win_xwindow_get(const Evas_Object *obj)
4458 {
4459    if (!obj) return 0;
4460
4461    if (!evas_object_smart_type_check_ptr(obj, WIN_SMART_NAME))
4462      {
4463         Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
4464         return _elm_ee_xwin_get(ee);
4465      }
4466
4467    ELM_WIN_CHECK(obj) 0;
4468    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, 0);
4469
4470 #ifdef HAVE_ELEMENTARY_X
4471    if (sd->x.xwin) return sd->x.xwin;
4472    if (sd->parent) return elm_win_xwindow_get(sd->parent);
4473 #endif
4474    return 0;
4475 }
4476
4477 EAPI Ecore_Wl_Window *
4478 elm_win_wl_window_get(const Evas_Object *obj)
4479 {
4480    if (!obj) return NULL;
4481
4482    if (!evas_object_smart_type_check_ptr(obj, WIN_SMART_NAME))
4483      {
4484         Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
4485         return ecore_evas_wayland_window_get(ee);
4486      }
4487
4488    ELM_WIN_CHECK(obj) NULL;
4489    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, NULL);
4490 #if HAVE_ELEMENTARY_WAYLAND
4491    if (sd->wl.win) return sd->wl.win;
4492    if (sd->parent) return elm_win_wl_window_get(sd->parent);
4493 #endif
4494    return NULL;
4495 }
4496
4497 EAPI Eina_Bool
4498 elm_win_trap_set(const Elm_Win_Trap *t)
4499 {
4500    DBG("old %p, new %p", trap, t);
4501
4502    if ((t) && (t->version != ELM_WIN_TRAP_VERSION))
4503      {
4504         CRITICAL("trying to set a trap version %lu while %lu was expected!",
4505                  t->version, ELM_WIN_TRAP_VERSION);
4506         return EINA_FALSE;
4507      }
4508
4509    trap = t;
4510    return EINA_TRUE;
4511 }
4512
4513 EAPI void
4514 elm_win_floating_mode_set(Evas_Object *obj, Eina_Bool floating)
4515 {
4516    ELM_WIN_CHECK(obj);
4517    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4518
4519    if (floating == sd->floating) return;
4520    sd->floating = floating;
4521 #ifdef HAVE_ELEMENTARY_X
4522    _elm_win_xwindow_get(sd);
4523    if (sd->x.xwin)
4524      {
4525         if (sd->floating)
4526           ecore_x_e_illume_window_state_set
4527              (sd->x.xwin, ECORE_X_ILLUME_WINDOW_STATE_FLOATING);
4528         else
4529           ecore_x_e_illume_window_state_set
4530              (sd->x.xwin, ECORE_X_ILLUME_WINDOW_STATE_NORMAL);
4531      }
4532 #endif
4533 }
4534
4535 EAPI Eina_Bool
4536 elm_win_floating_mode_get(const Evas_Object *obj)
4537 {
4538    ELM_WIN_CHECK(obj) EINA_FALSE;
4539    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
4540
4541    return sd->floating;
4542 }
4543