Eolian: Integration of Elm Widget
[platform/upstream/elementary.git] / src / lib / elm_win.c
1 #ifdef HAVE_CONFIG_H
2 # include "elementary_config.h"
3 #endif
4
5 #include <Elementary.h>
6 #include <Elementary_Cursor.h>
7
8 #include "elm_priv.h"
9 #include "elm_widget_menu.h"
10
11 EAPI Eo_Op ELM_OBJ_WIN_BASE_ID = EO_NOOP;
12
13 #define MY_CLASS ELM_OBJ_WIN_CLASS
14
15 #define MY_CLASS_NAME "Elm_Win"
16 #define MY_CLASS_NAME_LEGACY "elm_win"
17
18 static const Elm_Win_Trap *trap = NULL;
19
20 #define TRAP(sd, name, ...)                                             \
21   do                                                                    \
22     {                                                                   \
23        if ((!trap) || (!trap->name) ||                                  \
24            ((trap->name) &&                                             \
25             (trap->name(sd->trap_data, sd->obj, ## __VA_ARGS__)))) \
26          ecore_evas_##name(sd->ee, ##__VA_ARGS__);                      \
27     }                                                                   \
28   while (0)
29
30 #define ELM_WIN_DATA_GET(o, sd) \
31   Elm_Win_Smart_Data * sd = eo_data_scope_get(o, MY_CLASS)
32
33 #define ELM_WIN_DATA_GET_OR_RETURN(o, ptr)           \
34   ELM_WIN_DATA_GET(o, ptr);                          \
35   if (!ptr)                                          \
36     {                                                \
37        CRI("No widget data for object %p (%s)", \
38                 o, evas_object_type_get(o));         \
39        return;                                       \
40     }
41
42 #define ELM_WIN_DATA_GET_OR_RETURN_VAL(o, ptr, val)  \
43   ELM_WIN_DATA_GET(o, ptr);                          \
44   if (!ptr)                                          \
45     {                                                \
46        CRI("No widget data for object %p (%s)", \
47                 o, evas_object_type_get(o));         \
48        return val;                                   \
49     }
50
51 #define ELM_WIN_CHECK(obj)                                             \
52   if (!obj || !eo_isa(obj, MY_CLASS)) \
53     return
54
55 #define ENGINE_GET() (_elm_preferred_engine ? _elm_preferred_engine : (_elm_config->engine ? _elm_config->engine : ""))
56 #define ENGINE_COMPARE(name) (!strcmp(ENGINE_GET(), name))
57
58 typedef struct _Elm_Win_Smart_Data Elm_Win_Smart_Data;
59
60 struct _Elm_Win_Smart_Data
61 {
62    Ecore_Evas           *ee;
63    Evas                 *evas;
64    Evas_Object          *parent; /* parent *window* object*/
65    Evas_Object          *img_obj, *frame_obj;
66    Evas_Object          *client_obj; /* rect representing the client */
67    Evas_Object          *spacer_obj;
68    Eo                   *layout;
69    Eo                   *box;
70    Evas_Object          *obj; /* The object itself */
71 #ifdef HAVE_ELEMENTARY_X
72    struct
73    {
74       Ecore_X_Window       xwin;
75       Ecore_Event_Handler *client_message_handler;
76       Ecore_Event_Handler *property_handler;
77    } x;
78 #endif
79 #ifdef HAVE_ELEMENTARY_WAYLAND
80    struct
81    {
82       Ecore_Wl_Window *win;
83    } wl;
84 #endif
85
86    Ecore_Job                     *deferred_resize_job;
87    Ecore_Job                     *deferred_child_eval_job;
88
89    Elm_Win_Type                   type;
90    Elm_Win_Keyboard_Mode          kbdmode;
91    Elm_Win_Indicator_Mode         indmode;
92    Elm_Win_Indicator_Opacity_Mode ind_o_mode;
93    struct
94    {
95       const char  *info;
96       Ecore_Timer *timer;
97       int          repeat_count;
98       int          shot_counter;
99    } shot;
100    int                            resize_location;
101    int                           *autodel_clear, rot;
102    struct
103    {
104       int x, y;
105    } screen;
106    struct
107    {
108       Ecore_Evas  *ee;
109       Evas        *evas;
110       Evas_Object *obj, *hot_obj;
111       int          hot_x, hot_y;
112    } pointer;
113    struct
114    {
115       Evas_Object *fobj; /* focus highlight edje object */
116
117       struct
118       {
119          Evas_Object *target;
120          Eina_Bool    visible : 1;
121          Eina_Bool    in_theme: 1; /**< focus highlight is handled by theme.
122                                      this is set true if edc data item "focus_highlight" is set to "on" during focus in callback. */
123       } cur, prev;
124
125       const char  *style;
126       Ecore_Job   *reconf_job;
127
128       Eina_Bool    enabled : 1;
129       Eina_Bool    theme_changed : 1; /* set true when the focus theme is changed */
130       Eina_Bool    animate : 1; /* set true when the focus highlight animate is enabled */
131       Eina_Bool    animate_supported : 1; /* set true when the focus highlight animate is supported by theme */
132       Eina_Bool    geometry_changed : 1;
133    } focus_highlight;
134
135    Evas_Object *icon;
136    const char  *title;
137    const char  *icon_name;
138    const char  *role;
139
140    Evas_Object *main_menu;
141
142    struct
143    {
144       const char  *name;
145       const char **available_list;
146       unsigned int count;
147    } profile;
148    struct
149    {
150       int          preferred_rot; /* indicates preferred rotation value, -1 means invalid. */
151       int         *rots; /* indicates available rotations */
152       unsigned int count; /* number of elements in available rotations */
153       Eina_Bool    wm_supported : 1; /* set true when the window manager support window rotation */
154       Eina_Bool    use : 1; /* set ture when application use window manager rotation. */
155    } wm_rot;
156
157    void *trap_data;
158
159    double       aspect;
160    int          size_base_w, size_base_h;
161    int          size_step_w, size_step_h;
162    int          norender;
163    Eina_Bool    urgent : 1;
164    Eina_Bool    modal : 1;
165    Eina_Bool    demand_attention : 1;
166    Eina_Bool    autodel : 1;
167    Eina_Bool    constrain : 1;
168    Eina_Bool    resizing : 1;
169    Eina_Bool    iconified : 1;
170    Eina_Bool    withdrawn : 1;
171    Eina_Bool    sticky : 1;
172    Eina_Bool    fullscreen : 1;
173    Eina_Bool    maximized : 1;
174    Eina_Bool    skip_focus : 1;
175    Eina_Bool    floating : 1;
176 };
177
178 static const char SIG_DELETE_REQUEST[] = "delete,request";
179 static const char SIG_FOCUS_OUT[] = "focus,out"; // deprecated. use "focused" instead.
180 static const char SIG_FOCUS_IN[] = "focus,in"; // deprecated. use "unfocused" instead.
181 static const char SIG_MOVED[] = "moved";
182 static const char SIG_WITHDRAWN[] = "withdrawn";
183 static const char SIG_ICONIFIED[] = "iconified";
184 static const char SIG_NORMAL[] = "normal";
185 static const char SIG_STICK[] = "stick";
186 static const char SIG_UNSTICK[] = "unstick";
187 static const char SIG_FULLSCREEN[] = "fullscreen";
188 static const char SIG_UNFULLSCREEN[] = "unfullscreen";
189 static const char SIG_MAXIMIZED[] = "maximized";
190 static const char SIG_UNMAXIMIZED[] = "unmaximized";
191 static const char SIG_IOERR[] = "ioerr";
192 static const char SIG_INDICATOR_PROP_CHANGED[] = "indicator,prop,changed";
193 static const char SIG_ROTATION_CHANGED[] = "rotation,changed";
194 static const char SIG_PROFILE_CHANGED[] = "profile,changed";
195 static const char SIG_FOCUSED[] = "focused";
196 static const char SIG_UNFOCUSED[] = "unfocused";
197 static const char SIG_WM_ROTATION_CHANGED[] = "wm,rotation,changed";
198
199 static const Evas_Smart_Cb_Description _smart_callbacks[] = {
200    {SIG_DELETE_REQUEST, ""},
201    {SIG_FOCUS_OUT, ""},
202    {SIG_FOCUS_IN, ""},
203    {SIG_MOVED, ""},
204    {SIG_WITHDRAWN, ""},
205    {SIG_ICONIFIED, ""},
206    {SIG_NORMAL, ""},
207    {SIG_STICK, ""},
208    {SIG_UNSTICK, ""},
209    {SIG_FULLSCREEN, ""},
210    {SIG_UNFULLSCREEN, ""},
211    {SIG_MAXIMIZED, ""},
212    {SIG_UNMAXIMIZED, ""},
213    {SIG_IOERR, ""},
214    {SIG_INDICATOR_PROP_CHANGED, ""},
215    {SIG_ROTATION_CHANGED, ""},
216    {SIG_PROFILE_CHANGED, ""},
217    {SIG_FOCUSED, ""},
218    {SIG_UNFOCUSED, ""},
219    {SIG_WM_ROTATION_CHANGED, ""},
220    {NULL, NULL}
221 };
222
223 Eina_List *_elm_win_list = NULL;
224 int _elm_win_deferred_free = 0;
225
226 static int _elm_win_count = 0;
227
228 static Eina_Bool _elm_win_auto_throttled = EINA_FALSE;
229
230 static Ecore_Job *_elm_win_state_eval_job = NULL;
231
232 static void
233 _elm_win_on_resize_obj_changed_size_hints(void *data,
234                                           Evas *e,
235                                           Evas_Object *obj,
236                                           void *event_info);
237 static void
238 _elm_win_img_callbacks_del(Evas_Object *obj, Evas_Object *imgobj);
239
240 #ifdef HAVE_ELEMENTARY_X
241 static void _elm_win_xwin_update(Elm_Win_Smart_Data *sd);
242 #endif
243
244 EAPI double _elm_startup_time = 0;
245
246 static void
247 _elm_win_first_frame_do(void *data, Evas *e EINA_UNUSED, void *event_info EINA_UNUSED)
248 {
249    double end = ecore_time_unix_get();
250    char *first = data;
251
252    switch (*first)
253      {
254       case 'A': abort();
255       case 'E':
256       case 'D': exit(-1);
257       case 'T': fprintf(stderr, "Startup time: '%f' - '%f' = '%f' sec\n", end, _elm_startup_time, end - _elm_startup_time);
258                 break;
259      }
260
261    evas_event_callback_del_full(e, EVAS_CALLBACK_RENDER_POST, _elm_win_first_frame_do, data);
262 }
263
264 static void
265 _elm_win_state_eval(void *data EINA_UNUSED)
266 {
267    Eina_List *l;
268    Evas_Object *obj;
269    int _elm_win_count_shown = 0;
270    int _elm_win_count_iconified = 0;
271    int _elm_win_count_withdrawn = 0;
272
273    _elm_win_state_eval_job = NULL;
274
275    if (_elm_config->auto_norender_withdrawn)
276      {
277         EINA_LIST_FOREACH(_elm_win_list, l, obj)
278           {
279              if ((elm_win_withdrawn_get(obj)) ||
280                  ((elm_win_iconified_get(obj) &&
281                    (_elm_config->auto_norender_iconified_same_as_withdrawn))))
282                {
283                   if (!evas_object_data_get(obj, "__win_auto_norender"))
284                     {
285                        Evas *evas = evas_object_evas_get(obj);
286
287                        elm_win_norender_push(obj);
288                        evas_object_data_set(obj, "__win_auto_norender", obj);
289
290                        if (_elm_config->auto_flush_withdrawn)
291                          {
292                             edje_file_cache_flush();
293                             edje_collection_cache_flush();
294                             evas_image_cache_flush(evas);
295                             evas_font_cache_flush(evas);
296                          }
297                        if (_elm_config->auto_dump_withdrawn)
298                          {
299                             evas_render_dump(evas);
300                          }
301                     }
302                }
303              else
304                {
305                   if (evas_object_data_get(obj, "__win_auto_norender"))
306                     {
307                        elm_win_norender_pop(obj);
308                        evas_object_data_del(obj, "__win_auto_norender");
309                     }
310                }
311           }
312      }
313    if (((_elm_config->auto_throttle) &&
314         (elm_policy_get(ELM_POLICY_THROTTLE) != ELM_POLICY_THROTTLE_NEVER)) ||
315         (elm_policy_get(ELM_POLICY_THROTTLE) == ELM_POLICY_THROTTLE_HIDDEN_ALWAYS))
316      {
317         if (_elm_win_count == 0)
318           {
319              if (_elm_win_auto_throttled)
320                {
321                   ecore_throttle_adjust(-_elm_config->auto_throttle_amount);
322                   _elm_win_auto_throttled = EINA_FALSE;
323                }
324           }
325         else
326           {
327              EINA_LIST_FOREACH(_elm_win_list, l, obj)
328                {
329                   if (elm_win_withdrawn_get(obj))
330                     _elm_win_count_withdrawn++;
331                   else if (elm_win_iconified_get(obj))
332                     _elm_win_count_iconified++;
333                   else if (evas_object_visible_get(obj))
334                     _elm_win_count_shown++;
335                }
336              if (_elm_win_count_shown <= 0)
337                {
338                   if (!_elm_win_auto_throttled)
339                     {
340                        ecore_throttle_adjust(_elm_config->auto_throttle_amount);
341                        _elm_win_auto_throttled = EINA_TRUE;
342                     }
343                }
344              else
345                {
346                   if (_elm_win_auto_throttled)
347                     {
348                        ecore_throttle_adjust(-_elm_config->auto_throttle_amount);
349                        _elm_win_auto_throttled = EINA_FALSE;
350                     }
351                }
352           }
353      }
354 }
355
356 static void
357 _elm_win_state_eval_queue(void)
358 {
359    ecore_job_del(_elm_win_state_eval_job);
360    _elm_win_state_eval_job = ecore_job_add(_elm_win_state_eval, NULL);
361 }
362
363 // example shot spec (wait 0.1 sec then save as my-window.png):
364 // ELM_ENGINE="shot:delay=0.1:file=my-window.png"
365
366 static double
367 _shot_delay_get(Elm_Win_Smart_Data *sd)
368 {
369    char *p, *pd;
370    char *d = strdup(sd->shot.info);
371
372    if (!d) return 0.5;
373    for (p = (char *)sd->shot.info; *p; p++)
374      {
375         if (!strncmp(p, "delay=", 6))
376           {
377              double v;
378
379              for (pd = d, p += 6; (*p) && (*p != ':'); p++, pd++)
380                {
381                   *pd = *p;
382                }
383              *pd = 0;
384              v = _elm_atof(d);
385              free(d);
386              return v;
387           }
388      }
389    free(d);
390
391    return 0.5;
392 }
393
394 static char *
395 _shot_file_get(Elm_Win_Smart_Data *sd)
396 {
397    char *p;
398    char *tmp = strdup(sd->shot.info);
399    char *repname = NULL;
400
401    if (!tmp) return NULL;
402
403    for (p = (char *)sd->shot.info; *p; p++)
404      {
405         if (!strncmp(p, "file=", 5))
406           {
407              strcpy(tmp, p + 5);
408              if (!sd->shot.repeat_count) return tmp;
409              else
410                {
411                   char *dotptr = strrchr(tmp, '.');
412                   if (dotptr)
413                     {
414                        size_t size = sizeof(char) * (strlen(tmp) + 16);
415                        repname = malloc(size);
416                        strncpy(repname, tmp, dotptr - tmp);
417                        snprintf(repname + (dotptr - tmp), size -
418                                 (dotptr - tmp), "%03i",
419                                 sd->shot.shot_counter + 1);
420                        strcat(repname, dotptr);
421                        free(tmp);
422                        return repname;
423                     }
424                }
425           }
426      }
427    free(tmp);
428    if (!sd->shot.repeat_count) return strdup("out.png");
429
430    repname = malloc(sizeof(char) * 24);
431    snprintf(repname, sizeof(char) * 24, "out%03i.png",
432             sd->shot.shot_counter + 1);
433
434    return repname;
435 }
436
437 static int
438 _shot_repeat_count_get(Elm_Win_Smart_Data *sd)
439 {
440    char *p, *pd;
441    char *d = strdup(sd->shot.info);
442
443    if (!d) return 0;
444    for (p = (char *)sd->shot.info; *p; p++)
445      {
446         if (!strncmp(p, "repeat=", 7))
447           {
448              int v;
449
450              for (pd = d, p += 7; (*p) && (*p != ':'); p++, pd++)
451                {
452                   *pd = *p;
453                }
454              *pd = 0;
455              v = atoi(d);
456              if (v < 0) v = 0;
457              if (v > 1000) v = 999;
458              free(d);
459              return v;
460           }
461      }
462    free(d);
463
464    return 0;
465 }
466
467 static char *
468 _shot_key_get(Elm_Win_Smart_Data *sd EINA_UNUSED)
469 {
470    return NULL;
471 }
472
473 static char *
474 _shot_flags_get(Elm_Win_Smart_Data *sd EINA_UNUSED)
475 {
476    return NULL;
477 }
478
479 static void
480 _shot_do(Elm_Win_Smart_Data *sd)
481 {
482    Ecore_Evas *ee;
483    Evas_Object *o;
484    unsigned int *pixels;
485    int w, h;
486    char *file, *key, *flags;
487
488    ecore_evas_manual_render(sd->ee);
489    pixels = (void *)ecore_evas_buffer_pixels_get(sd->ee);
490    if (!pixels) return;
491
492    ecore_evas_geometry_get(sd->ee, NULL, NULL, &w, &h);
493    if ((w < 1) || (h < 1)) return;
494
495    file = _shot_file_get(sd);
496    if (!file) return;
497
498    key = _shot_key_get(sd);
499    flags = _shot_flags_get(sd);
500    ee = ecore_evas_buffer_new(1, 1);
501    o = evas_object_image_add(ecore_evas_get(ee));
502    evas_object_image_alpha_set(o, ecore_evas_alpha_get(sd->ee));
503    evas_object_image_size_set(o, w, h);
504    evas_object_image_data_set(o, pixels);
505    if (!evas_object_image_save(o, file, key, flags))
506      {
507         ERR("Cannot save window to '%s' (key '%s', flags '%s')",
508             file, key, flags);
509      }
510    free(file);
511    free(key);
512    free(flags);
513    ecore_evas_free(ee);
514    if (sd->shot.repeat_count) sd->shot.shot_counter++;
515 }
516
517 static Eina_Bool
518 _shot_delay(void *data)
519 {
520    ELM_WIN_DATA_GET(data, sd);
521
522    _shot_do(sd);
523    if (sd->shot.repeat_count)
524      {
525         int remainshot = (sd->shot.repeat_count - sd->shot.shot_counter);
526         if (remainshot > 0) return EINA_TRUE;
527      }
528    sd->shot.timer = NULL;
529    elm_exit();
530
531    return EINA_FALSE;
532 }
533
534 static void
535 _shot_init(Elm_Win_Smart_Data *sd)
536 {
537    if (!sd->shot.info) return;
538
539    sd->shot.repeat_count = _shot_repeat_count_get(sd);
540    sd->shot.shot_counter = 0;
541 }
542
543 static void
544 _shot_handle(Elm_Win_Smart_Data *sd)
545 {
546    if (!sd->shot.info) return;
547
548    if (!sd->shot.timer)
549      sd->shot.timer = ecore_timer_add(_shot_delay_get(sd), _shot_delay,
550                                       sd->obj);
551 }
552
553 /* elm-win specific associate, does the trap while ecore_evas_object_associate()
554  * does not.
555  */
556 static Elm_Win_Smart_Data *
557 _elm_win_associate_get(const Ecore_Evas *ee)
558 {
559    Evas_Object *obj = ecore_evas_data_get(ee, "elm_win");
560    if (!obj) return NULL;
561    ELM_WIN_DATA_GET(obj, sd);
562    return sd;
563 }
564
565 /* Interceptors Callbacks */
566 static void
567 _elm_win_obj_intercept_raise(void *data, Evas_Object *obj EINA_UNUSED)
568 {
569    ELM_WIN_DATA_GET(data, sd);
570    TRAP(sd, raise);
571 }
572
573 static void
574 _elm_win_obj_intercept_lower(void *data, Evas_Object *obj EINA_UNUSED)
575 {
576    ELM_WIN_DATA_GET(data, sd);
577    TRAP(sd, lower);
578 }
579
580 static void
581 _elm_win_obj_intercept_stack_above(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, Evas_Object *above EINA_UNUSED)
582 {
583    INF("TODO: %s", __FUNCTION__);
584 }
585
586 static void
587 _elm_win_obj_intercept_stack_below(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, Evas_Object *below EINA_UNUSED)
588 {
589    INF("TODO: %s", __FUNCTION__);
590 }
591
592 static void
593 _elm_win_obj_intercept_layer_set(void *data, Evas_Object *obj EINA_UNUSED, int l)
594 {
595    ELM_WIN_DATA_GET(data, sd);
596    TRAP(sd, layer_set, l);
597 }
598
599 /* Event Callbacks */
600
601 static void
602 _elm_win_obj_callback_changed_size_hints(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
603 {
604    ELM_WIN_DATA_GET(data, sd);
605    Evas_Coord w, h;
606
607    evas_object_size_hint_min_get(obj, &w, &h);
608    TRAP(sd, size_min_set, w, h);
609
610    evas_object_size_hint_max_get(obj, &w, &h);
611    if (w < 1) w = -1;
612    if (h < 1) h = -1;
613    TRAP(sd, size_max_set, w, h);
614 }
615 /* end of elm-win specific associate */
616
617 static void
618 _elm_win_move(Ecore_Evas *ee)
619 {
620    Elm_Win_Smart_Data *sd = _elm_win_associate_get(ee);
621    int x, y;
622
623    if (!sd) return;
624
625    ecore_evas_geometry_get(ee, &x, &y, NULL, NULL);
626    sd->screen.x = x;
627    sd->screen.y = y;
628    evas_object_smart_callback_call(sd->obj, SIG_MOVED, NULL);
629 }
630
631 static void
632 _elm_win_resize_job(void *data)
633 {
634    ELM_WIN_DATA_GET(data, sd);
635    int w, h;
636
637    sd->deferred_resize_job = NULL;
638    ecore_evas_request_geometry_get(sd->ee, NULL, NULL, &w, &h);
639    if (sd->constrain)
640      {
641         int sw, sh;
642         ecore_evas_screen_geometry_get(sd->ee, NULL, NULL, &sw, &sh);
643         w = MIN(w, sw);
644         h = MIN(h, sh);
645      }
646
647    if (sd->frame_obj)
648      {
649         int fx, fy, fw, fh;
650
651         evas_output_framespace_get(sd->evas, &fx, &fy, &fw, &fh);
652         evas_object_move(sd->frame_obj, -fx, -fy);
653         evas_object_resize(sd->frame_obj, w + fw, h + fh);
654      }
655
656    evas_object_resize(sd->obj, w, h);
657    evas_object_resize(sd->layout, w, h);
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    if (!sd) return;
665
666    ecore_job_del(sd->deferred_resize_job);
667    sd->deferred_resize_job = ecore_job_add(_elm_win_resize_job, sd->obj);
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    if (!sd) return;
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    ELM_SAFE_FREE(sd->focus_highlight.reconf_job, ecore_job_del);
683 }
684
685 static void
686 _elm_win_focus_highlight_visible_set(Elm_Win_Smart_Data *sd,
687                                      Eina_Bool visible)
688 {
689    Evas_Object *fobj = sd->focus_highlight.fobj;
690    if (!fobj) return;
691
692    if (visible)
693      {
694         evas_object_show(fobj);
695         edje_object_signal_emit(fobj, "elm,action,focus,show", "elm");
696      }
697    else
698      {
699         edje_object_signal_emit(fobj, "elm,action,focus,hide", "elm");
700      }
701 }
702
703 static void
704 _elm_win_focus_highlight_anim_setup(Elm_Win_Smart_Data *sd,
705                                     Evas_Object *obj)
706 {
707    Evas_Coord tx, ty, tw, th;
708    Evas_Coord w, h, px, py, pw, ph;
709    Edje_Message_Int_Set *m;
710    Evas_Object *previous = sd->focus_highlight.prev.target;
711    Evas_Object *target = sd->focus_highlight.cur.target;
712
713    evas_object_geometry_get(sd->obj, NULL, NULL, &w, &h);
714    elm_widget_focus_highlight_geometry_get(target, &tx, &ty, &tw, &th, EINA_TRUE);
715    elm_widget_focus_highlight_geometry_get(previous, &px, &py, &pw, &ph, EINA_FALSE);
716    evas_object_move(obj, tx, ty);
717    evas_object_resize(obj, tw, th);
718
719    if (!_elm_config->focus_highlight_clip_disable)
720      evas_object_clip_unset(obj);
721
722    m = alloca(sizeof(*m) + (sizeof(int) * 8));
723    m->count = 8;
724    m->val[0] = px - tx;
725    m->val[1] = py - ty;
726    m->val[2] = pw;
727    m->val[3] = ph;
728    m->val[4] = 0;
729    m->val[5] = 0;
730    m->val[6] = tw;
731    m->val[7] = th;
732    edje_object_message_send(obj, EDJE_MESSAGE_INT_SET, 1, m);
733 }
734
735 static void
736 _elm_win_focus_highlight_simple_setup(Elm_Win_Smart_Data *sd,
737                                       Evas_Object *obj)
738 {
739    Evas_Object *clip, *target = sd->focus_highlight.cur.target;
740    Evas_Coord x, y, w, h;
741
742    elm_widget_focus_highlight_geometry_get(target, &x, &y, &w, &h, EINA_TRUE);
743
744    evas_object_move(obj, x, y);
745    evas_object_resize(obj, w, h);
746
747    if (!_elm_config->focus_highlight_clip_disable)
748      {
749         clip = evas_object_clip_get(target);
750         if (clip) evas_object_clip_set(obj, clip);
751      }
752 }
753
754 static void
755 _elm_win_focus_highlight_reconfigure_job(void *data)
756 {
757    ELM_WIN_DATA_GET(data, sd);
758    Evas_Object *target = sd->focus_highlight.cur.target;
759    Evas_Object *previous = sd->focus_highlight.prev.target;
760    Evas_Object *fobj = sd->focus_highlight.fobj;
761    Eina_Bool visible_changed;
762    Eina_Bool common_visible;
763    const char *sig = NULL;
764    const char *focus_style_target = NULL;
765    const char *focus_style_previous = NULL;
766
767    _elm_win_focus_highlight_reconfigure_job_stop(sd);
768
769    visible_changed = (sd->focus_highlight.cur.visible !=
770                       sd->focus_highlight.prev.visible);
771
772    if ((target == previous) && (!visible_changed) &&
773        (!sd->focus_highlight.geometry_changed) &&
774        (!sd->focus_highlight.theme_changed))
775      return;
776
777    if ((previous) && (sd->focus_highlight.prev.in_theme))
778      elm_widget_signal_emit
779        (previous, "elm,action,focus_highlight,hide", "elm");
780
781    if (!target)
782      common_visible = EINA_FALSE;
783    else if (sd->focus_highlight.cur.in_theme)
784      {
785         common_visible = EINA_FALSE;
786         if (sd->focus_highlight.cur.visible)
787           sig = "elm,action,focus_highlight,show";
788         else
789           sig = "elm,action,focus_highlight,hide";
790      }
791    else
792      common_visible = sd->focus_highlight.cur.visible;
793
794    if (sig)
795      elm_widget_signal_emit(target, sig, "elm");
796
797    if ((!target) || (!common_visible) || (sd->focus_highlight.cur.in_theme))
798      goto the_end;
799
800    if (previous)
801      focus_style_previous = elm_widget_focus_highlight_style_get(previous);
802    focus_style_target = elm_widget_focus_highlight_style_get(target);
803
804    if (sd->focus_highlight.theme_changed ||
805        (focus_style_target != focus_style_previous))
806      {
807         const char *str;
808
809         if (focus_style_target)
810           str = focus_style_target;
811         else if (sd->focus_highlight.style)
812           str = sd->focus_highlight.style;
813         else
814           str = "default";
815
816         elm_widget_theme_object_set
817           (sd->obj, fobj, "focus_highlight", "top", str);
818         sd->focus_highlight.theme_changed = EINA_FALSE;
819
820         if (sd->focus_highlight.animate)
821           {
822              str = edje_object_data_get(sd->focus_highlight.fobj, "animate");
823              sd->focus_highlight.animate_supported = ((str) && (!strcmp(str, "on")));
824           }
825         else
826           sd->focus_highlight.animate_supported = EINA_FALSE;
827      }
828
829    if ((sd->focus_highlight.animate_supported) && (previous) &&
830        (!sd->focus_highlight.prev.in_theme))
831      _elm_win_focus_highlight_anim_setup(sd, fobj);
832    else
833      _elm_win_focus_highlight_simple_setup(sd, fobj);
834    evas_object_raise(fobj);
835
836 the_end:
837    _elm_win_focus_highlight_visible_set(sd, common_visible);
838    sd->focus_highlight.geometry_changed = EINA_FALSE;
839    sd->focus_highlight.prev = sd->focus_highlight.cur;
840 }
841
842 static void
843 _elm_win_focus_highlight_reconfigure_job_start(Elm_Win_Smart_Data *sd)
844 {
845    ecore_job_del(sd->focus_highlight.reconf_job);
846
847    sd->focus_highlight.reconf_job = ecore_job_add(
848        _elm_win_focus_highlight_reconfigure_job, sd->obj);
849 }
850
851 static void
852 _elm_win_focus_in(Ecore_Evas *ee)
853 {
854    Elm_Win_Smart_Data *sd = _elm_win_associate_get(ee);
855    Evas_Object *obj;
856    unsigned int order = 0;
857
858    if (!sd) return;
859
860    obj = sd->obj;
861
862    _elm_widget_top_win_focused_set(obj, EINA_TRUE);
863    if (!elm_widget_focus_order_get(obj)
864        || (obj == elm_widget_newest_focus_order_get(obj, &order, EINA_TRUE)))
865      {
866         elm_widget_focus_steal(obj);
867      }
868    else
869      elm_widget_focus_restore(obj);
870    evas_object_smart_callback_call(obj, SIG_FOCUS_IN, NULL);
871    evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
872    sd->focus_highlight.cur.visible = EINA_TRUE;
873    _elm_win_focus_highlight_reconfigure_job_start(sd);
874    if (sd->frame_obj)
875      {
876         edje_object_signal_emit(sd->frame_obj, "elm,action,focus", "elm");
877      }
878
879    /* do nothing */
880    /* else if (sd->img_obj) */
881    /*   { */
882    /*   } */
883 }
884
885 static void
886 _elm_win_focus_out(Ecore_Evas *ee)
887 {
888    Elm_Win_Smart_Data *sd = _elm_win_associate_get(ee);
889    Evas_Object *obj;
890
891    if (!sd) return;
892
893    obj = sd->obj;
894
895    elm_object_focus_set(obj, EINA_FALSE);
896    _elm_widget_top_win_focused_set(obj, EINA_FALSE);
897    evas_object_smart_callback_call(obj, SIG_FOCUS_OUT, NULL);
898    evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
899    sd->focus_highlight.cur.visible = EINA_FALSE;
900    _elm_win_focus_highlight_reconfigure_job_start(sd);
901    if (sd->frame_obj)
902      {
903         edje_object_signal_emit(sd->frame_obj, "elm,action,unfocus", "elm");
904      }
905
906    /* access */
907    _elm_access_object_highlight_disable(evas_object_evas_get(obj));
908
909    /* do nothing */
910    /* if (sd->img_obj) */
911    /*   { */
912    /*   } */
913 }
914
915 static void
916 _elm_win_available_profiles_del(Elm_Win_Smart_Data *sd)
917 {
918    if (!sd->profile.available_list) return;
919
920    unsigned int i;
921    for (i = 0; i < sd->profile.count; i++)
922      ELM_SAFE_FREE(sd->profile.available_list[i], eina_stringshare_del);
923    sd->profile.count = 0;
924    ELM_SAFE_FREE(sd->profile.available_list, free);
925 }
926
927 static void
928 _elm_win_profile_del(Elm_Win_Smart_Data *sd)
929 {
930    ELM_SAFE_FREE(sd->profile.name, eina_stringshare_del);
931 }
932
933 static Eina_Bool
934 _elm_win_profile_set(Elm_Win_Smart_Data *sd, const char *profile)
935 {
936    Eina_Bool changed = EINA_FALSE;
937    if (profile)
938      {
939         if (sd->profile.name)
940           {
941              if (strcmp(sd->profile.name, profile) != 0)
942                {
943                   eina_stringshare_replace(&(sd->profile.name), profile);
944                   changed = EINA_TRUE;
945                }
946           }
947         else
948           {
949              sd->profile.name = eina_stringshare_add(profile);
950              changed = EINA_TRUE;
951           }
952      }
953    else
954      _elm_win_profile_del(sd);
955
956    return changed;
957 }
958
959 static void
960 _elm_win_profile_update(Elm_Win_Smart_Data *sd)
961 {
962    if (sd->profile.available_list)
963      {
964         Eina_Bool found = EINA_FALSE;
965         if (sd->profile.name)
966           {
967              unsigned int i;
968              for (i = 0; i < sd->profile.count; i++)
969                {
970                   if (!strcmp(sd->profile.name,
971                               sd->profile.available_list[i]))
972                     {
973                        found = EINA_TRUE;
974                        break;
975                     }
976                }
977           }
978
979         /* If current profile is not present in an available profiles,
980          * change current profile to the 1st element of an array.
981          */
982         if (!found)
983           _elm_win_profile_set(sd, sd->profile.available_list[0]);
984      }
985
986    _elm_config_profile_set(sd->profile.name);
987
988    /* update sub ee */
989    Ecore_Evas *ee2;
990    Eina_List *sub, *l = NULL;
991
992    sub = ecore_evas_sub_ecore_evas_list_get(sd->ee);
993    EINA_LIST_FOREACH(sub, l, ee2)
994      ecore_evas_window_profile_set(ee2, sd->profile.name);
995
996    evas_object_smart_callback_call(sd->obj, SIG_PROFILE_CHANGED, NULL);
997 }
998
999 static void
1000 _elm_win_state_change(Ecore_Evas *ee)
1001 {
1002    Elm_Win_Smart_Data *sd = _elm_win_associate_get(ee);
1003    Evas_Object *obj;
1004    Eina_Bool ch_withdrawn = EINA_FALSE;
1005    Eina_Bool ch_sticky = EINA_FALSE;
1006    Eina_Bool ch_iconified = EINA_FALSE;
1007    Eina_Bool ch_fullscreen = EINA_FALSE;
1008    Eina_Bool ch_maximized = EINA_FALSE;
1009    Eina_Bool ch_profile = EINA_FALSE;
1010    Eina_Bool ch_wm_rotation = EINA_FALSE;
1011    const char *profile;
1012
1013    if (!sd) return;
1014
1015    obj = sd->obj;
1016
1017    if (sd->withdrawn != ecore_evas_withdrawn_get(sd->ee))
1018      {
1019         sd->withdrawn = ecore_evas_withdrawn_get(sd->ee);
1020         ch_withdrawn = EINA_TRUE;
1021      }
1022    if (sd->sticky != ecore_evas_sticky_get(sd->ee))
1023      {
1024         sd->sticky = ecore_evas_sticky_get(sd->ee);
1025         ch_sticky = EINA_TRUE;
1026      }
1027    if (sd->iconified != ecore_evas_iconified_get(sd->ee))
1028      {
1029         sd->iconified = ecore_evas_iconified_get(sd->ee);
1030         ch_iconified = EINA_TRUE;
1031      }
1032    if (sd->fullscreen != ecore_evas_fullscreen_get(sd->ee))
1033      {
1034         sd->fullscreen = ecore_evas_fullscreen_get(sd->ee);
1035         ch_fullscreen = EINA_TRUE;
1036      }
1037    if (sd->maximized != ecore_evas_maximized_get(sd->ee))
1038      {
1039         sd->maximized = ecore_evas_maximized_get(sd->ee);
1040         ch_maximized = EINA_TRUE;
1041      }
1042
1043    profile = ecore_evas_window_profile_get(sd->ee);
1044    ch_profile = _elm_win_profile_set(sd, profile);
1045
1046    if (sd->wm_rot.use)
1047      {
1048         if (sd->rot != ecore_evas_rotation_get(sd->ee))
1049           {
1050              sd->rot = ecore_evas_rotation_get(sd->ee);
1051              ch_wm_rotation = EINA_TRUE;
1052           }
1053      }
1054
1055    _elm_win_state_eval_queue();
1056
1057    if ((ch_withdrawn) || (ch_iconified))
1058      {
1059         if (sd->withdrawn)
1060           evas_object_smart_callback_call(obj, SIG_WITHDRAWN, NULL);
1061         else if (sd->iconified)
1062           evas_object_smart_callback_call(obj, SIG_ICONIFIED, NULL);
1063         else
1064           evas_object_smart_callback_call(obj, SIG_NORMAL, NULL);
1065      }
1066    if (ch_sticky)
1067      {
1068         if (sd->sticky)
1069           evas_object_smart_callback_call(obj, SIG_STICK, NULL);
1070         else
1071           evas_object_smart_callback_call(obj, SIG_UNSTICK, NULL);
1072      }
1073    if (ch_fullscreen)
1074      {
1075         if (sd->fullscreen)
1076           evas_object_smart_callback_call(obj, SIG_FULLSCREEN, NULL);
1077         else
1078           evas_object_smart_callback_call(obj, SIG_UNFULLSCREEN, NULL);
1079      }
1080    if (ch_maximized)
1081      {
1082         if (sd->maximized)
1083           evas_object_smart_callback_call(obj, SIG_MAXIMIZED, NULL);
1084         else
1085           evas_object_smart_callback_call(obj, SIG_UNMAXIMIZED, NULL);
1086      }
1087    if (ch_profile)
1088      {
1089         _elm_win_profile_update(sd);
1090      }
1091    if (ch_wm_rotation)
1092      {
1093         evas_object_size_hint_min_set(obj, -1, -1);
1094         evas_object_size_hint_max_set(obj, -1, -1);
1095 #ifdef HAVE_ELEMENTARY_X
1096         _elm_win_xwin_update(sd);
1097 #endif
1098         elm_widget_orientation_set(obj, sd->rot);
1099         evas_object_smart_callback_call(obj, SIG_ROTATION_CHANGED, NULL);
1100         evas_object_smart_callback_call(obj, SIG_WM_ROTATION_CHANGED, NULL);
1101      }
1102 }
1103
1104 static void
1105 _elm_win_smart_focus_next_manager_is(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list)
1106 {
1107    Eina_Bool *ret = va_arg(*list, Eina_Bool *);
1108    *ret = EINA_TRUE;
1109 }
1110
1111 static void
1112 _elm_win_smart_focus_next(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
1113 {
1114    Elm_Focus_Direction dir = va_arg(*list, Elm_Focus_Direction);
1115    Evas_Object **next = va_arg(*list, Evas_Object **);
1116    Eina_Bool *ret = va_arg(*list, Eina_Bool *);
1117    if (ret) *ret = EINA_FALSE;
1118
1119    ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
1120
1121    const Eina_List *items;
1122    void *(*list_data_get)(const Eina_List *list);
1123
1124    /* Focus chain */
1125    if (wd->subobjs)
1126      {
1127         if (!(items = elm_widget_focus_custom_chain_get(obj)))
1128           {
1129              items = wd->subobjs;
1130              if (!items)
1131                return;
1132           }
1133         list_data_get = eina_list_data_get;
1134
1135         elm_widget_focus_list_next_get(obj, items, list_data_get, dir, next);
1136
1137         if (*next)
1138           {
1139              if (ret) *ret = EINA_TRUE;
1140              return;
1141           }
1142      }
1143    *next = (Evas_Object *)obj;
1144    return;
1145 }
1146
1147 static void
1148 _elm_win_smart_focus_direction_manager_is(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, va_list *list)
1149 {
1150    Eina_Bool *ret = va_arg(*list, Eina_Bool *);
1151    *ret = EINA_TRUE;
1152 }
1153
1154 static void
1155 _elm_win_smart_focus_direction(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
1156 {
1157    const Evas_Object *base = va_arg(*list, Evas_Object *);
1158    double degree = va_arg(*list, double);
1159    Evas_Object **direction = va_arg(*list, Evas_Object **);
1160    double *weight = va_arg(*list, double *);
1161    Eina_Bool *ret = va_arg(*list, Eina_Bool *);
1162    if (ret) *ret = EINA_FALSE;
1163    Eina_Bool int_ret = EINA_FALSE;
1164
1165    const Eina_List *items;
1166    void *(*list_data_get)(const Eina_List *list);
1167
1168    ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd);
1169
1170    /* Focus chain */
1171    if (wd->subobjs)
1172      {
1173         if (!(items = elm_widget_focus_custom_chain_get(obj)))
1174           items = wd->subobjs;
1175
1176         list_data_get = eina_list_data_get;
1177
1178         int_ret = elm_widget_focus_list_direction_get
1179                  (obj, base, items, list_data_get, degree, direction, weight);
1180         if (ret) *ret = int_ret;
1181      }
1182 }
1183
1184 static void
1185 _elm_win_smart_on_focus(Eo *obj, void *_pd, va_list *list)
1186 {
1187    Eina_Bool *ret = va_arg(*list, Eina_Bool *);
1188    if (ret) *ret = EINA_TRUE;
1189    Elm_Win_Smart_Data *sd = _pd;
1190    Eina_Bool int_ret = EINA_FALSE;
1191
1192    eo_do_super(obj, MY_CLASS, elm_obj_widget_on_focus(&int_ret));
1193    if (!int_ret) return;
1194
1195    if (sd->img_obj)
1196      evas_object_focus_set(sd->img_obj, elm_widget_focus_get(obj));
1197    else
1198      evas_object_focus_set(obj, elm_widget_focus_get(obj));
1199 }
1200
1201 static void
1202 _elm_win_smart_event(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
1203 {
1204    Evas_Object *src = va_arg(*list, Evas_Object *);
1205    Evas_Callback_Type type = va_arg(*list, Evas_Callback_Type);
1206    Evas_Event_Key_Down *ev = va_arg(*list, void *);
1207    Eina_Bool *ret = va_arg(*list, Eina_Bool *);
1208
1209    if (ret) *ret = EINA_FALSE;
1210    (void) src;
1211
1212    if (elm_widget_disabled_get(obj)) return;
1213    if (type != EVAS_CALLBACK_KEY_DOWN) return;
1214
1215    if ((!strcmp(ev->key, "Tab")) ||
1216        (!strcmp(ev->key, "ISO_Left_Tab")))
1217      {
1218         if (evas_key_modifier_is_set(ev->modifiers, "Control") ||
1219             evas_key_modifier_is_set(ev->modifiers, "Alt"))
1220           return;
1221         if (evas_key_modifier_is_set(ev->modifiers, "Shift"))
1222           elm_widget_focus_cycle(obj, ELM_FOCUS_PREVIOUS);
1223         else
1224           elm_widget_focus_cycle(obj, ELM_FOCUS_NEXT);
1225
1226         goto success;
1227      }
1228    else if ((!strcmp(ev->key, "Left")) ||
1229             ((!strcmp(ev->key, "KP_Left")) && (!ev->string)))
1230      {
1231         elm_widget_focus_cycle(obj, ELM_FOCUS_LEFT);
1232
1233         goto success;
1234      }
1235    else if ((!strcmp(ev->key, "Right")) ||
1236             ((!strcmp(ev->key, "KP_Right")) && (!ev->string)))
1237      {
1238         elm_widget_focus_cycle(obj, ELM_FOCUS_RIGHT);
1239
1240         goto success;
1241      }
1242    else if ((!strcmp(ev->key, "Up")) ||
1243             ((!strcmp(ev->key, "KP_Up")) && (!ev->string)))
1244      {
1245         elm_widget_focus_cycle(obj, ELM_FOCUS_UP);
1246
1247         goto success;
1248      }
1249    else if ((!strcmp(ev->key, "Down")) ||
1250             ((!strcmp(ev->key, "KP_Down")) && (!ev->string)))
1251      {
1252         elm_widget_focus_cycle(obj, ELM_FOCUS_DOWN);
1253
1254         goto success;
1255      }
1256
1257    return;
1258
1259 success:
1260    ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1261    if (ret) *ret = EINA_TRUE;
1262 }
1263
1264 static void
1265 _deferred_ecore_evas_free(void *data)
1266 {
1267    ecore_evas_free(data);
1268    _elm_win_deferred_free--;
1269 }
1270
1271 static void
1272 _elm_win_smart_show(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
1273 {
1274    Elm_Win_Smart_Data *sd = _pd;
1275
1276    if (!evas_object_visible_get(obj))
1277      _elm_win_state_eval_queue();
1278    eo_do_super(obj, MY_CLASS, evas_obj_smart_show());
1279
1280    TRAP(sd, show);
1281
1282    if (sd->shot.info) _shot_handle(sd);
1283 }
1284
1285 static void
1286 _elm_win_smart_hide(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
1287 {
1288    Elm_Win_Smart_Data *sd = _pd;
1289
1290    if (evas_object_visible_get(obj))
1291      _elm_win_state_eval_queue();
1292    eo_do_super(obj, MY_CLASS, evas_obj_smart_hide());
1293
1294    TRAP(sd, hide);
1295
1296    if (sd->frame_obj)
1297      {
1298         evas_object_hide(sd->frame_obj);
1299      }
1300    if (sd->img_obj)
1301      {
1302         evas_object_hide(sd->img_obj);
1303      }
1304    if (sd->pointer.obj)
1305      {
1306         evas_object_hide(sd->pointer.obj);
1307         ecore_evas_hide(sd->pointer.ee);
1308      }
1309 }
1310
1311 static void
1312 _elm_win_on_parent_del(void *data,
1313                        Evas *e EINA_UNUSED,
1314                        Evas_Object *obj,
1315                        void *event_info EINA_UNUSED)
1316 {
1317    ELM_WIN_DATA_GET(data, sd);
1318
1319    if (obj == sd->parent) sd->parent = NULL;
1320 }
1321
1322 static void
1323 _elm_win_focus_target_move(void *data,
1324                            Evas *e EINA_UNUSED,
1325                            Evas_Object *obj EINA_UNUSED,
1326                            void *event_info EINA_UNUSED)
1327 {
1328    ELM_WIN_DATA_GET(data, sd);
1329
1330    sd->focus_highlight.geometry_changed = EINA_TRUE;
1331    _elm_win_focus_highlight_reconfigure_job_start(sd);
1332 }
1333
1334 static void
1335 _elm_win_focus_target_resize(void *data,
1336                              Evas *e EINA_UNUSED,
1337                              Evas_Object *obj EINA_UNUSED,
1338                              void *event_info EINA_UNUSED)
1339 {
1340    ELM_WIN_DATA_GET(data, sd);
1341
1342    sd->focus_highlight.geometry_changed = EINA_TRUE;
1343    _elm_win_focus_highlight_reconfigure_job_start(sd);
1344 }
1345
1346 static void
1347 _elm_win_focus_target_del(void *data,
1348                           Evas *e EINA_UNUSED,
1349                           Evas_Object *obj EINA_UNUSED,
1350                           void *event_info EINA_UNUSED)
1351 {
1352    ELM_WIN_DATA_GET(data, sd);
1353
1354    sd->focus_highlight.cur.target = NULL;
1355
1356    _elm_win_focus_highlight_reconfigure_job_start(sd);
1357 }
1358
1359 static Evas_Object *
1360 _elm_win_focus_target_get(Evas_Object *obj)
1361 {
1362    Evas_Object *o = obj;
1363
1364    do
1365      {
1366         if (elm_widget_is(o))
1367           {
1368              if (!elm_widget_highlight_ignore_get(o))
1369                break;
1370              o = elm_widget_parent_get(o);
1371              if (!o)
1372                o = evas_object_smart_parent_get(o);
1373           }
1374         else
1375           {
1376              o = elm_widget_parent_widget_get(o);
1377              if (!o)
1378                o = evas_object_smart_parent_get(o);
1379           }
1380      }
1381    while (o);
1382
1383    return o;
1384 }
1385
1386 static void
1387 _elm_win_focus_target_callbacks_add(Elm_Win_Smart_Data *sd)
1388 {
1389    Evas_Object *obj = sd->focus_highlight.cur.target;
1390    if (!obj) return;
1391
1392    evas_object_event_callback_add
1393      (obj, EVAS_CALLBACK_MOVE, _elm_win_focus_target_move, sd->obj);
1394    evas_object_event_callback_add
1395      (obj, EVAS_CALLBACK_RESIZE, _elm_win_focus_target_resize, sd->obj);
1396    evas_object_event_callback_add
1397      (obj, EVAS_CALLBACK_DEL, _elm_win_focus_target_del, sd->obj);
1398 }
1399
1400 static void
1401 _elm_win_focus_target_callbacks_del(Elm_Win_Smart_Data *sd)
1402 {
1403    Evas_Object *obj = sd->focus_highlight.cur.target;
1404
1405    evas_object_event_callback_del_full
1406      (obj, EVAS_CALLBACK_MOVE, _elm_win_focus_target_move, sd->obj);
1407    evas_object_event_callback_del_full
1408      (obj, EVAS_CALLBACK_RESIZE, _elm_win_focus_target_resize, sd->obj);
1409    evas_object_event_callback_del_full
1410      (obj, EVAS_CALLBACK_DEL, _elm_win_focus_target_del, sd->obj);
1411 }
1412
1413 static void
1414 _elm_win_object_focus_in(void *data,
1415                          Evas *e EINA_UNUSED,
1416                          void *event_info)
1417 {
1418    Evas_Object *obj = event_info, *target;
1419    ELM_WIN_DATA_GET(data, sd);
1420
1421    if (sd->focus_highlight.cur.target == obj)
1422      return;
1423
1424    target = _elm_win_focus_target_get(obj);
1425    sd->focus_highlight.cur.target = target;
1426    if (target && elm_widget_highlight_in_theme_get(target))
1427      sd->focus_highlight.cur.in_theme = EINA_TRUE;
1428    else
1429      _elm_win_focus_target_callbacks_add(sd);
1430
1431    _elm_win_focus_highlight_reconfigure_job_start(sd);
1432 }
1433
1434 static void
1435 _elm_win_object_focus_out(void *data,
1436                           Evas *e EINA_UNUSED,
1437                           void *event_info EINA_UNUSED)
1438 {
1439    ELM_WIN_DATA_GET(data, sd);
1440
1441    if (!sd->focus_highlight.cur.target)
1442      return;
1443
1444    if (!sd->focus_highlight.cur.in_theme)
1445      _elm_win_focus_target_callbacks_del(sd);
1446
1447    sd->focus_highlight.cur.target = NULL;
1448    sd->focus_highlight.cur.in_theme = EINA_FALSE;
1449
1450    _elm_win_focus_highlight_reconfigure_job_start(sd);
1451 }
1452
1453 static void
1454 _elm_win_focus_highlight_shutdown(Elm_Win_Smart_Data *sd)
1455 {
1456    _elm_win_focus_highlight_reconfigure_job_stop(sd);
1457    if (sd->focus_highlight.cur.target)
1458      {
1459         elm_widget_signal_emit(sd->focus_highlight.cur.target,
1460                                "elm,action,focus_highlight,hide", "elm");
1461         _elm_win_focus_target_callbacks_del(sd);
1462         sd->focus_highlight.cur.target = NULL;
1463      }
1464    ELM_SAFE_FREE(sd->focus_highlight.fobj, evas_object_del);
1465
1466    evas_event_callback_del_full
1467      (sd->evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
1468      _elm_win_object_focus_in, sd->obj);
1469    evas_event_callback_del_full
1470      (sd->evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
1471      _elm_win_object_focus_out, sd->obj);
1472 }
1473
1474 static void
1475 _win_img_hide(void *data,
1476               Evas *e EINA_UNUSED,
1477               Evas_Object *obj EINA_UNUSED,
1478               void *event_info EINA_UNUSED)
1479 {
1480    elm_widget_focus_hide_handle(data);
1481 }
1482
1483 static void
1484 _win_img_mouse_up(void *data,
1485                   Evas *e EINA_UNUSED,
1486                   Evas_Object *obj EINA_UNUSED,
1487                   void *event_info)
1488 {
1489    Evas_Event_Mouse_Up *ev = event_info;
1490    if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD))
1491      elm_widget_focus_mouse_up_handle(data);
1492 }
1493
1494 static void
1495 _win_img_focus_in(void *data,
1496                   Evas *e EINA_UNUSED,
1497                   Evas_Object *obj EINA_UNUSED,
1498                   void *event_info EINA_UNUSED)
1499 {
1500    elm_widget_focus_steal(data);
1501 }
1502
1503 static void
1504 _win_img_focus_out(void *data,
1505                    Evas *e EINA_UNUSED,
1506                    Evas_Object *obj EINA_UNUSED,
1507                    void *event_info EINA_UNUSED)
1508 {
1509    elm_widget_focused_object_clear(data);
1510 }
1511
1512 static void
1513 _elm_win_on_img_obj_del(void *data,
1514                         Evas *e EINA_UNUSED,
1515                         Evas_Object *obj EINA_UNUSED,
1516                         void *event_info EINA_UNUSED)
1517 {
1518    ELM_WIN_DATA_GET(data, sd);
1519    _elm_win_img_callbacks_del(sd->obj, sd->img_obj);
1520    sd->img_obj = NULL;
1521 }
1522
1523 static void
1524 _elm_win_img_callbacks_del(Evas_Object *obj, Evas_Object *imgobj)
1525 {
1526    evas_object_event_callback_del_full
1527      (imgobj, EVAS_CALLBACK_DEL, _elm_win_on_img_obj_del, obj);
1528    evas_object_event_callback_del_full
1529      (imgobj, EVAS_CALLBACK_HIDE, _win_img_hide, obj);
1530    evas_object_event_callback_del_full
1531      (imgobj, EVAS_CALLBACK_MOUSE_UP, _win_img_mouse_up, obj);
1532    evas_object_event_callback_del_full
1533      (imgobj, EVAS_CALLBACK_FOCUS_IN, _win_img_focus_in, obj);
1534    evas_object_event_callback_del_full
1535      (imgobj, EVAS_CALLBACK_FOCUS_OUT, _win_img_focus_out, obj);
1536 }
1537
1538 static void
1539 _elm_win_smart_del(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
1540 {
1541    Elm_Win_Smart_Data *sd = _pd;
1542
1543    evas_object_event_callback_del_full(sd->layout,
1544                                        EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1545                                        _elm_win_on_resize_obj_changed_size_hints,
1546                                        obj);
1547    evas_object_del(sd->box);
1548    evas_object_del(sd->layout);
1549
1550    /* NB: child deletion handled by parent's smart del */
1551
1552    if ((trap) && (trap->del))
1553      trap->del(sd->trap_data, obj);
1554
1555    if (sd->parent)
1556      {
1557         evas_object_event_callback_del_full
1558           (sd->parent, EVAS_CALLBACK_DEL, _elm_win_on_parent_del, obj);
1559         sd->parent = NULL;
1560      }
1561
1562    if (sd->autodel_clear) *(sd->autodel_clear) = -1;
1563
1564    _elm_win_list = eina_list_remove(_elm_win_list, obj);
1565    _elm_win_count--;
1566    _elm_win_state_eval_queue();
1567
1568    if (sd->ee)
1569      {
1570         ecore_evas_callback_delete_request_set(sd->ee, NULL);
1571         ecore_evas_callback_resize_set(sd->ee, NULL);
1572      }
1573
1574    ecore_job_del(sd->deferred_resize_job);
1575    ecore_job_del(sd->deferred_child_eval_job);
1576    eina_stringshare_del(sd->shot.info);
1577    ecore_timer_del(sd->shot.timer);
1578
1579 #ifdef HAVE_ELEMENTARY_X
1580    ecore_event_handler_del(sd->x.client_message_handler);
1581    ecore_event_handler_del(sd->x.property_handler);
1582 #endif
1583
1584    if (sd->img_obj)
1585      {
1586         _elm_win_img_callbacks_del(obj, sd->img_obj);
1587         sd->img_obj = NULL;
1588      }
1589    else
1590      {
1591         if (sd->ee)
1592           {
1593              ecore_job_add(_deferred_ecore_evas_free, sd->ee);
1594              _elm_win_deferred_free++;
1595           }
1596      }
1597
1598    _elm_win_focus_highlight_shutdown(sd);
1599    eina_stringshare_del(sd->focus_highlight.style);
1600
1601    eina_stringshare_del(sd->title);
1602    eina_stringshare_del(sd->icon_name);
1603    eina_stringshare_del(sd->role);
1604    evas_object_del(sd->icon);
1605    evas_object_del(sd->main_menu);
1606
1607    _elm_win_profile_del(sd);
1608    _elm_win_available_profiles_del(sd);
1609
1610    /* Don't let callback in the air that point to sd */
1611    ecore_evas_callback_delete_request_set(sd->ee, NULL);
1612    ecore_evas_callback_resize_set(sd->ee, NULL);
1613    ecore_evas_callback_mouse_in_set(sd->ee, NULL);
1614    ecore_evas_callback_focus_in_set(sd->ee, NULL);
1615    ecore_evas_callback_focus_out_set(sd->ee, NULL);
1616    ecore_evas_callback_move_set(sd->ee, NULL);
1617    ecore_evas_callback_state_change_set(sd->ee, NULL);
1618
1619    eo_do_super(obj, MY_CLASS, evas_obj_smart_del());
1620
1621    if ((!_elm_win_list) &&
1622        (elm_policy_get(ELM_POLICY_QUIT) == ELM_POLICY_QUIT_LAST_WINDOW_CLOSED))
1623      {
1624         edje_file_cache_flush();
1625         edje_collection_cache_flush();
1626         evas_image_cache_flush(evas_object_evas_get(obj));
1627         evas_font_cache_flush(evas_object_evas_get(obj));
1628         elm_exit();
1629      }
1630 }
1631
1632 static void
1633 _elm_win_obj_intercept_show(void *data,
1634                             Evas_Object *obj)
1635 {
1636    ELM_WIN_DATA_GET(data, sd);
1637
1638    // this is called to make sure all smart containers have calculated their
1639    // sizes BEFORE we show the window to make sure it initially appears at
1640    // our desired size (ie min size is known first)
1641    evas_smart_objects_calculate(evas_object_evas_get(obj));
1642    if (sd->frame_obj)
1643      {
1644         evas_object_show(sd->frame_obj);
1645      }
1646    if (sd->img_obj)
1647      {
1648         evas_object_show(sd->img_obj);
1649      }
1650    if (sd->pointer.obj)
1651      {
1652         ecore_evas_show(sd->pointer.ee);
1653         evas_object_show(sd->pointer.obj);
1654      }
1655    evas_object_show(obj);
1656 }
1657
1658 static void
1659 _elm_win_smart_move(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
1660 {
1661    Evas_Coord x = va_arg(*list, Evas_Coord);
1662    Evas_Coord y = va_arg(*list, Evas_Coord);
1663    Elm_Win_Smart_Data *sd = _pd;
1664
1665    if (sd->img_obj)
1666      {
1667         if ((x != sd->screen.x) || (y != sd->screen.y))
1668           {
1669              sd->screen.x = x;
1670              sd->screen.y = y;
1671              evas_object_smart_callback_call(obj, SIG_MOVED, NULL);
1672           }
1673         return;
1674      }
1675    else
1676      {
1677         TRAP(sd, move, x, y);
1678         if (!ecore_evas_override_get(sd->ee))  return;
1679      }
1680
1681    eo_do_super(obj, MY_CLASS, evas_obj_smart_move(x, y));
1682
1683    if (ecore_evas_override_get(sd->ee))
1684      {
1685         sd->screen.x = x;
1686         sd->screen.y = y;
1687         evas_object_smart_callback_call(obj, SIG_MOVED, NULL);
1688      }
1689    if (sd->frame_obj)
1690      {
1691         /* FIXME: We should update ecore_wl_window_location here !! */
1692         sd->screen.x = x;
1693         sd->screen.y = y;
1694      }
1695    if (sd->img_obj)
1696      {
1697         sd->screen.x = x;
1698         sd->screen.y = y;
1699      }
1700 }
1701
1702 static void
1703 _elm_win_smart_resize(Eo *obj, void *_pd, va_list *list)
1704 {
1705    Evas_Coord w = va_arg(*list, Evas_Coord);
1706    Evas_Coord h = va_arg(*list, Evas_Coord);
1707
1708    Elm_Win_Smart_Data *sd = _pd;
1709
1710    eo_do_super(obj, MY_CLASS, evas_obj_smart_resize(w, h));
1711
1712    if (sd->img_obj)
1713      {
1714         if (sd->constrain)
1715           {
1716              int sw, sh;
1717
1718              ecore_evas_screen_geometry_get(sd->ee, NULL, NULL, &sw, &sh);
1719              w = MIN(w, sw);
1720              h = MIN(h, sh);
1721           }
1722         if (w < 1) w = 1;
1723         if (h < 1) h = 1;
1724
1725         evas_object_image_size_set(sd->img_obj, w, h);
1726      }
1727
1728    TRAP(sd, resize, w, h);
1729 }
1730
1731 static void
1732 _elm_win_delete_request(Ecore_Evas *ee)
1733 {
1734    Elm_Win_Smart_Data *sd = _elm_win_associate_get(ee);
1735    Evas_Object *obj;
1736
1737    if (!sd) return;
1738
1739    obj = sd->obj;
1740
1741    int autodel = sd->autodel;
1742    sd->autodel_clear = &autodel;
1743    evas_object_ref(obj);
1744    evas_object_smart_callback_call(obj, SIG_DELETE_REQUEST, NULL);
1745    // FIXME: if above callback deletes - then the below will be invalid
1746    if (autodel) evas_object_del(obj);
1747    else sd->autodel_clear = NULL;
1748    evas_object_unref(obj);
1749 }
1750
1751 Ecore_X_Window
1752 _elm_ee_xwin_get(const Ecore_Evas *ee)
1753 {
1754 #ifdef HAVE_ELEMENTARY_X
1755    const char *engine_name;
1756    if (!ee) return 0;
1757
1758    engine_name = ecore_evas_engine_name_get(ee);
1759    if (EINA_UNLIKELY(!engine_name)) return 0;
1760
1761    if (!strcmp(engine_name, ELM_SOFTWARE_X11))
1762      {
1763         return ecore_evas_software_x11_window_get(ee);
1764      }
1765    else if (!strcmp(engine_name, ELM_OPENGL_X11))
1766      {
1767         return ecore_evas_gl_x11_window_get(ee);
1768      }
1769 #else
1770    (void)ee;
1771 #endif
1772    return 0;
1773 }
1774
1775 #ifdef HAVE_ELEMENTARY_X
1776 static void
1777 _elm_win_xwindow_get(Elm_Win_Smart_Data *sd)
1778 {
1779    sd->x.xwin = _elm_ee_xwin_get(sd->ee);
1780 }
1781 #endif
1782
1783 Ecore_Wl_Window *
1784 _elm_ee_wlwin_get(const Ecore_Evas *ee)
1785 {
1786 #ifdef HAVE_ELEMENTARY_WAYLAND
1787    const char *engine_name;
1788
1789    if (!ee) return NULL;
1790
1791    engine_name = ecore_evas_engine_name_get(ee);
1792    if (EINA_UNLIKELY(!engine_name)) return NULL;
1793
1794    if ((!strcmp(engine_name, ELM_WAYLAND_SHM)) ||
1795        (!strcmp(engine_name, ELM_WAYLAND_EGL)))
1796      {
1797         return ecore_evas_wayland_window_get(ee);
1798      }
1799 #else
1800    (void)ee;
1801 #endif
1802    return NULL;
1803 }
1804
1805 #ifdef HAVE_ELEMENTARY_WAYLAND
1806 static void
1807 _elm_win_wlwindow_get(Elm_Win_Smart_Data *sd)
1808 {
1809    sd->wl.win = _elm_ee_wlwin_get(sd->ee);
1810 }
1811 #endif
1812
1813 #ifdef HAVE_ELEMENTARY_X
1814 static void
1815 _elm_win_xwin_update(Elm_Win_Smart_Data *sd)
1816 {
1817    const char *s;
1818
1819    _elm_win_xwindow_get(sd);
1820    if (sd->parent)
1821      {
1822         ELM_WIN_DATA_GET(sd->parent, sdp);
1823         if (sdp)
1824           {
1825              if (sd->x.xwin)
1826                ecore_x_icccm_transient_for_set(sd->x.xwin, sdp->x.xwin);
1827           }
1828      }
1829
1830    if (!sd->x.xwin) return;  /* nothing more to do */
1831
1832    s = sd->title;
1833    if (!s) s = _elm_appname;
1834    if (!s) s = "";
1835    if (sd->icon_name) s = sd->icon_name;
1836    ecore_x_icccm_icon_name_set(sd->x.xwin, s);
1837    ecore_x_netwm_icon_name_set(sd->x.xwin, s);
1838
1839    s = sd->role;
1840    if (s) ecore_x_icccm_window_role_set(sd->x.xwin, s);
1841
1842    // set window icon
1843    if (sd->icon)
1844      {
1845         void *data;
1846
1847         data = evas_object_image_data_get(sd->icon, EINA_FALSE);
1848         if (data)
1849           {
1850              Ecore_X_Icon ic;
1851              int w = 0, h = 0, stride, x, y;
1852              unsigned char *p;
1853              unsigned int *p2;
1854
1855              evas_object_image_size_get(sd->icon, &w, &h);
1856              stride = evas_object_image_stride_get(sd->icon);
1857              if ((w > 0) && (h > 0) &&
1858                  (stride >= (int)(w * sizeof(unsigned int))))
1859                {
1860                   ic.width = w;
1861                   ic.height = h;
1862                   ic.data = malloc(w * h * sizeof(unsigned int));
1863
1864                   if (ic.data)
1865                     {
1866                        p = (unsigned char *)data;
1867                        p2 = (unsigned int *)ic.data;
1868                        for (y = 0; y < h; y++)
1869                          {
1870                             for (x = 0; x < w; x++)
1871                               {
1872                                  *p2 = *((unsigned int *)p);
1873                                  p += sizeof(unsigned int);
1874                                  p2++;
1875                               }
1876                             p += (stride - (w * sizeof(unsigned int)));
1877                          }
1878                        ecore_x_netwm_icons_set(sd->x.xwin, &ic, 1);
1879                        free(ic.data);
1880                     }
1881                }
1882              evas_object_image_data_set(sd->icon, data);
1883           }
1884      }
1885
1886    switch (sd->type)
1887      {
1888       case ELM_WIN_BASIC:
1889         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_NORMAL);
1890         break;
1891
1892       case ELM_WIN_DIALOG_BASIC:
1893         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_DIALOG);
1894         break;
1895
1896       case ELM_WIN_DESKTOP:
1897         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_DESKTOP);
1898         break;
1899
1900       case ELM_WIN_DOCK:
1901         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_DOCK);
1902         break;
1903
1904       case ELM_WIN_TOOLBAR:
1905         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_TOOLBAR);
1906         break;
1907
1908       case ELM_WIN_MENU:
1909         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_MENU);
1910         break;
1911
1912       case ELM_WIN_UTILITY:
1913         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_UTILITY);
1914         break;
1915
1916       case ELM_WIN_SPLASH:
1917         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_SPLASH);
1918         break;
1919
1920       case ELM_WIN_DROPDOWN_MENU:
1921         ecore_x_netwm_window_type_set
1922           (sd->x.xwin, ECORE_X_WINDOW_TYPE_DROPDOWN_MENU);
1923         break;
1924
1925       case ELM_WIN_POPUP_MENU:
1926         ecore_x_netwm_window_type_set
1927           (sd->x.xwin, ECORE_X_WINDOW_TYPE_POPUP_MENU);
1928         break;
1929
1930       case ELM_WIN_TOOLTIP:
1931         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_TOOLTIP);
1932         break;
1933
1934       case ELM_WIN_NOTIFICATION:
1935         ecore_x_netwm_window_type_set
1936           (sd->x.xwin, ECORE_X_WINDOW_TYPE_NOTIFICATION);
1937         break;
1938
1939       case ELM_WIN_COMBO:
1940         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_COMBO);
1941         break;
1942
1943       case ELM_WIN_DND:
1944         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_DND);
1945         break;
1946
1947       default:
1948         break;
1949      }
1950    ecore_x_e_virtual_keyboard_state_set
1951      (sd->x.xwin, (Ecore_X_Virtual_Keyboard_State)sd->kbdmode);
1952    if (sd->indmode == ELM_WIN_INDICATOR_SHOW)
1953      ecore_x_e_illume_indicator_state_set
1954        (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_STATE_ON);
1955    else if (sd->indmode == ELM_WIN_INDICATOR_HIDE)
1956      ecore_x_e_illume_indicator_state_set
1957        (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_STATE_OFF);
1958 }
1959
1960 #endif
1961
1962 /**
1963   * @internal
1964   *
1965   * Resize the window according to window layout's min and weight.
1966   * If the window layout's weight is 0.0, the window max is limited to layout's
1967   * min size.
1968   *
1969   * This is called when the window layout's weight hint is changed or when the
1970   * window is rotated.
1971   *
1972   * @param obj window object
1973   */
1974 static void
1975 _elm_win_resize_objects_eval(Evas_Object *obj)
1976 {
1977    ELM_WIN_DATA_GET(obj, sd);
1978    Evas_Coord w, h, minw, minh, maxw, maxh;
1979    double wx, wy;
1980
1981    evas_object_size_hint_min_get(sd->layout, &minw, &minh);
1982    if (minw < 1) minw = 1;
1983    if (minh < 1) minh = 1;
1984
1985    evas_object_size_hint_weight_get(sd->layout, &wx, &wy);
1986    if (!wx) maxw = minw;
1987    else maxw = 32767;
1988    if (!wy) maxh = minh;
1989    else maxh = 32767;
1990
1991    evas_object_size_hint_min_set(obj, minw, minh);
1992    evas_object_size_hint_max_set(obj, maxw, maxh);
1993    evas_object_geometry_get(obj, NULL, NULL, &w, &h);
1994    if (w < minw) w = minw;
1995    if (h < minh) h = minh;
1996    if (w > maxw) w = maxw;
1997    if (h > maxh) h = maxh;
1998    evas_object_move(obj, 0, 0);
1999    evas_object_resize(obj, w, h);
2000 }
2001
2002 static void
2003 _elm_win_on_resize_obj_changed_size_hints(void *data,
2004                                           Evas *e EINA_UNUSED,
2005                                           Evas_Object *obj EINA_UNUSED,
2006                                           void *event_info EINA_UNUSED)
2007 {
2008    _elm_win_resize_objects_eval(data);
2009 }
2010
2011 void
2012 _elm_win_shutdown(void)
2013 {
2014    while (_elm_win_list) evas_object_del(_elm_win_list->data);
2015    ELM_SAFE_FREE(_elm_win_state_eval_job, ecore_job_del);
2016 }
2017
2018 void
2019 _elm_win_rescale(Elm_Theme *th,
2020                  Eina_Bool use_theme)
2021 {
2022    const Eina_List *l;
2023    Evas_Object *obj;
2024
2025    if (!use_theme)
2026      {
2027         EINA_LIST_FOREACH(_elm_win_list, l, obj)
2028           elm_widget_theme(obj);
2029      }
2030    else
2031      {
2032         EINA_LIST_FOREACH(_elm_win_list, l, obj)
2033           elm_widget_theme_specific(obj, th, EINA_FALSE);
2034      }
2035 }
2036
2037 void
2038 _elm_win_access(Eina_Bool is_access)
2039 {
2040    Evas *evas;
2041    const Eina_List *l;
2042    Evas_Object *obj;
2043    Evas_Object *fobj;
2044
2045    EINA_LIST_FOREACH(_elm_win_list, l, obj)
2046      {
2047         elm_widget_access(obj, is_access);
2048
2049          /* floating orphan object. if there are A, B, C objects and user does
2050             as below, then there would be floating orphan objects.
2051
2052               1. elm_object_content_set(layout, A);
2053               2. elm_object_content_set(layout, B);
2054               3. elm_object_content_set(layout, C);
2055
2056             now, the object A and B are floating orphan objects */
2057
2058         fobj = obj;
2059         for (;;)
2060           {
2061              fobj = evas_object_below_get(fobj);
2062              if (!fobj) break;
2063
2064              if (elm_widget_is(fobj) && !elm_widget_parent_get(fobj))
2065                {
2066                   elm_widget_access(fobj, is_access);
2067                }
2068           }
2069
2070         if (!is_access)
2071           {
2072              evas = evas_object_evas_get(obj);
2073             if (evas) _elm_access_object_highlight_disable(evas);
2074           }
2075      }
2076 }
2077
2078 void
2079 _elm_win_translate(void)
2080 {
2081    const Eina_List *l;
2082    Evas_Object *obj;
2083
2084    EINA_LIST_FOREACH(_elm_win_list, l, obj)
2085      elm_widget_translate(obj);
2086 }
2087
2088 #ifdef HAVE_ELEMENTARY_X
2089 static Eina_Bool
2090 _elm_win_client_message(void *data,
2091                         int type EINA_UNUSED,
2092                         void *event)
2093 {
2094    ELM_WIN_DATA_GET(data, sd);
2095    Ecore_X_Event_Client_Message *e = event;
2096
2097    if (e->format != 32) return ECORE_CALLBACK_PASS_ON;
2098    if (e->message_type == ECORE_X_ATOM_E_COMP_FLUSH)
2099      {
2100         if ((unsigned int)e->data.l[0] == sd->x.xwin)
2101           {
2102              Evas *evas = evas_object_evas_get(sd->obj);
2103              if (evas)
2104                {
2105                   edje_file_cache_flush();
2106                   edje_collection_cache_flush();
2107                   evas_image_cache_flush(evas);
2108                   evas_font_cache_flush(evas);
2109                }
2110           }
2111      }
2112    else if (e->message_type == ECORE_X_ATOM_E_COMP_DUMP)
2113      {
2114         if ((unsigned int)e->data.l[0] == sd->x.xwin)
2115           {
2116              Evas *evas = evas_object_evas_get(sd->obj);
2117              if (evas)
2118                {
2119                   edje_file_cache_flush();
2120                   edje_collection_cache_flush();
2121                   evas_image_cache_flush(evas);
2122                   evas_font_cache_flush(evas);
2123                   evas_render_dump(evas);
2124                }
2125           }
2126      }
2127    else if (e->message_type == ECORE_X_ATOM_E_ILLUME_ACCESS_CONTROL)
2128      {
2129         if ((unsigned int)e->data.l[0] == sd->x.xwin)
2130           {
2131              if ((unsigned int)e->data.l[1] ==
2132                  ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_NEXT)
2133                {
2134                   // XXX: call right access func
2135                }
2136              else if ((unsigned int)e->data.l[1] ==
2137                       ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_PREV)
2138                {
2139                   // XXX: call right access func
2140                }
2141              else if ((unsigned int)e->data.l[1] ==
2142                       ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_ACTIVATE)
2143                {
2144                   _elm_access_highlight_object_activate
2145                     (sd->obj, ELM_ACTIVATE_DEFAULT);
2146                }
2147              else if ((unsigned int)e->data.l[1] ==
2148                       ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_READ)
2149                {
2150                   /* there would be better way to read highlight object */
2151                   Evas *evas;
2152                   evas = evas_object_evas_get(sd->obj);
2153                   if (!evas) return ECORE_CALLBACK_PASS_ON;
2154
2155                   _elm_access_mouse_event_enabled_set(EINA_TRUE);
2156
2157                   evas_event_feed_mouse_in(evas, 0, NULL);
2158                   evas_event_feed_mouse_move
2159                     (evas, e->data.l[2], e->data.l[3], 0, NULL);
2160
2161                   _elm_access_mouse_event_enabled_set(EINA_FALSE);
2162                }
2163              else if ((unsigned int)e->data.l[1] ==
2164                       ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_READ_NEXT)
2165                {
2166                   _elm_access_highlight_cycle(sd->obj, ELM_FOCUS_NEXT);
2167                }
2168              else if ((unsigned int)e->data.l[1] ==
2169                       ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_READ_PREV)
2170                {
2171                   _elm_access_highlight_cycle(sd->obj, ELM_FOCUS_PREVIOUS);
2172                }
2173              else if ((unsigned int)e->data.l[1] ==
2174                       ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_UP)
2175                {
2176                   _elm_access_highlight_object_activate
2177                     (sd->obj, ELM_ACTIVATE_UP);
2178                }
2179              else if ((unsigned int)e->data.l[1] ==
2180                       ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_DOWN)
2181                {
2182                   _elm_access_highlight_object_activate
2183                     (sd->obj, ELM_ACTIVATE_DOWN);
2184                }
2185           }
2186      }
2187    return ECORE_CALLBACK_PASS_ON;
2188 }
2189
2190 static Eina_Bool
2191 _elm_win_property_change(void *data,
2192                          int type EINA_UNUSED,
2193                          void *event)
2194 {
2195    ELM_WIN_DATA_GET(data, sd);
2196    Ecore_X_Event_Window_Property *e = event;
2197
2198    if (e->atom == ECORE_X_ATOM_E_ILLUME_INDICATOR_STATE)
2199      {
2200         if (e->win == sd->x.xwin)
2201           {
2202              sd->indmode = (Elm_Win_Indicator_Mode)ecore_x_e_illume_indicator_state_get(e->win);
2203              evas_object_smart_callback_call(sd->obj, SIG_INDICATOR_PROP_CHANGED, NULL);
2204           }
2205      }
2206    return ECORE_CALLBACK_PASS_ON;
2207 }
2208 #endif
2209
2210 static void
2211 _elm_win_focus_highlight_hide(void *data EINA_UNUSED,
2212                               Evas_Object *obj,
2213                               const char *emission EINA_UNUSED,
2214                               const char *source EINA_UNUSED)
2215 {
2216    evas_object_hide(obj);
2217 }
2218
2219 static void
2220 _elm_win_focus_highlight_anim_end(void *data,
2221                                   Evas_Object *obj,
2222                                   const char *emission EINA_UNUSED,
2223                                   const char *source EINA_UNUSED)
2224 {
2225    ELM_WIN_DATA_GET(data, sd);
2226
2227    _elm_win_focus_highlight_simple_setup(sd, obj);
2228 }
2229
2230 static void
2231 _elm_win_focus_highlight_init(Elm_Win_Smart_Data *sd)
2232 {
2233    evas_event_callback_add(sd->evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
2234                            _elm_win_object_focus_in, sd->obj);
2235    evas_event_callback_add(sd->evas,
2236                            EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
2237                            _elm_win_object_focus_out, sd->obj);
2238
2239    sd->focus_highlight.cur.target = evas_focus_get(sd->evas);
2240    sd->focus_highlight.fobj = edje_object_add(sd->evas);
2241    sd->focus_highlight.theme_changed = EINA_TRUE;
2242
2243    edje_object_signal_callback_add(sd->focus_highlight.fobj,
2244                                    "elm,action,focus,hide,end", "*",
2245                                    _elm_win_focus_highlight_hide, NULL);
2246    edje_object_signal_callback_add(sd->focus_highlight.fobj,
2247                                    "elm,action,focus,anim,end", "*",
2248                                    _elm_win_focus_highlight_anim_end, sd->obj);
2249    _elm_win_focus_highlight_reconfigure_job_start(sd);
2250 }
2251
2252 static void
2253 _elm_win_frame_cb_move_start(void *data,
2254                              Evas_Object *obj EINA_UNUSED,
2255                              const char *sig EINA_UNUSED,
2256                              const char *source)
2257 {
2258    ELM_WIN_DATA_GET(data, sd);
2259
2260    if (!sd) return;
2261
2262 #ifdef HAVE_ELEMENTARY_WAYLAND
2263    if (!strcmp(source, "elm"))
2264      ecore_wl_window_cursor_from_name_set(sd->wl.win, ELM_CURSOR_HAND1);
2265    else
2266      ecore_wl_window_cursor_default_restore(sd->wl.win);
2267 #else
2268    (void)source;
2269 #endif
2270
2271    /* FIXME: Change mouse pointer */
2272
2273    /* NB: Wayland handles moving surfaces by itself so we cannot
2274     * specify a specific x/y we want. Instead, we will pass in the
2275     * existing x/y values so they can be recorded as 'previous'
2276     * position. The new position will get updated automatically when
2277     * the move is finished */
2278
2279    ecore_evas_wayland_move(sd->ee, sd->screen.x, sd->screen.y);
2280 }
2281
2282 static void
2283 _elm_win_frame_cb_move_stop(void *data,
2284                             Evas_Object *obj EINA_UNUSED,
2285                             const char *sig EINA_UNUSED,
2286                             const char *source EINA_UNUSED)
2287 {
2288    ELM_WIN_DATA_GET(data, sd);
2289
2290    if (!sd) return;
2291
2292 #ifdef HAVE_ELEMENTARY_WAYLAND
2293    ecore_wl_window_cursor_default_restore(sd->wl.win);
2294 #endif
2295 }
2296
2297 #ifdef HAVE_ELEMENTARY_WAYLAND
2298 struct _resize_info
2299 {
2300    const char *name;
2301    int location;
2302 };
2303
2304 static struct _resize_info _border_side[4] =
2305 {
2306      { ELM_CURSOR_TOP_SIDE, 1 },
2307      { ELM_CURSOR_LEFT_SIDE, 4 },
2308      { ELM_CURSOR_BOTTOM_SIDE, 2 },
2309      { ELM_CURSOR_RIGHT_SIDE, 8 },
2310 };
2311
2312 static struct _resize_info _border_corner[4] =
2313 {
2314      { ELM_CURSOR_TOP_LEFT_CORNER, 5 },
2315      { ELM_CURSOR_BOTTOM_LEFT_CORNER, 6 },
2316      { ELM_CURSOR_BOTTOM_RIGHT_CORNER, 10 },
2317      { ELM_CURSOR_TOP_RIGHT_CORNER, 9 },
2318 };
2319 #endif
2320
2321 static void
2322 _elm_win_frame_obj_update(Elm_Win_Smart_Data *sd)
2323 {
2324    int fx, fy, fw, fh;
2325    int ox, oy, ow, oh;
2326    int sx, sy, sw, sh;
2327    int x, y, w, h;
2328    evas_object_geometry_get(sd->frame_obj, &fx, &fy, &fw, &fh);
2329    evas_object_geometry_get(sd->client_obj, &ox, &oy, &ow, &oh);
2330    evas_object_geometry_get(sd->spacer_obj, &sx, &sy, &sw, &sh);
2331
2332    evas_output_framespace_get(sd->evas, &x, &y, &w, &h);
2333
2334    if ((x != (ox - fx)) || (y != (oy - fy)) ||
2335        (w != (fw - ow)) || (h != (fh - oh)))
2336      {
2337         evas_output_framespace_set(sd->evas, (ox - fx), (oy - fy),
2338                                    (fw - ow), (fh - oh));
2339      }
2340
2341 #ifdef HAVE_ELEMENTARY_WAYLAND
2342    ecore_wl_window_opaque_region_set(sd->wl.win, -fx, -(fy - sy), sw, sh);
2343 #endif
2344 }
2345
2346 static void
2347 _elm_win_frame_obj_move(void *data,
2348                         Evas *e EINA_UNUSED,
2349                         Evas_Object *obj EINA_UNUSED,
2350                         void *event_info EINA_UNUSED)
2351 {
2352    Elm_Win_Smart_Data *sd;
2353
2354    if (!(sd = data)) return;
2355    if (!sd->client_obj) return;
2356
2357    _elm_win_frame_obj_update(sd);
2358 }
2359
2360 static void
2361 _elm_win_frame_obj_resize(void *data,
2362                           Evas *e EINA_UNUSED,
2363                           Evas_Object *obj EINA_UNUSED,
2364                           void *event_info EINA_UNUSED)
2365 {
2366    Elm_Win_Smart_Data *sd;
2367
2368    if (!(sd = data)) return;
2369    if (!sd->client_obj) return;
2370
2371    _elm_win_frame_obj_update(sd);
2372 }
2373
2374 static void
2375 _elm_win_frame_cb_resize_show(void *data,
2376                               Evas_Object *obj EINA_UNUSED,
2377                               const char *sig EINA_UNUSED,
2378                               const char *source)
2379 {
2380    ELM_WIN_DATA_GET(data, sd);
2381
2382    if (!sd) return;
2383    if (sd->resizing) return;
2384
2385 #ifdef HAVE_ELEMENTARY_WAYLAND
2386    int i;
2387    i = sd->rot / 90;
2388    if (!strcmp(source, "elm.event.resize.t"))
2389      ecore_wl_window_cursor_from_name_set(sd->wl.win,
2390                                           _border_side[(0 + i) % 4].name);
2391    else if (!strcmp(source, "elm.event.resize.b"))
2392      ecore_wl_window_cursor_from_name_set(sd->wl.win,
2393                                           _border_side[(2 + i) % 4].name);
2394    else if (!strcmp(source, "elm.event.resize.l"))
2395      ecore_wl_window_cursor_from_name_set(sd->wl.win,
2396                                           _border_side[(1 + i) % 4].name);
2397    else if (!strcmp(source, "elm.event.resize.r"))
2398      ecore_wl_window_cursor_from_name_set(sd->wl.win,
2399                                           _border_side[(3 + i) % 4].name);
2400    else if (!strcmp(source, "elm.event.resize.tl"))
2401      ecore_wl_window_cursor_from_name_set(sd->wl.win,
2402                                           _border_corner[(0 + i) % 4].name);
2403    else if (!strcmp(source, "elm.event.resize.tr"))
2404      ecore_wl_window_cursor_from_name_set(sd->wl.win,
2405                                           _border_corner[(3 + i) % 4].name);
2406    else if (!strcmp(source, "elm.event.resize.bl"))
2407      ecore_wl_window_cursor_from_name_set(sd->wl.win,
2408                                           _border_corner[(1 + i) % 4].name);
2409    else if (!strcmp(source, "elm.event.resize.br"))
2410      ecore_wl_window_cursor_from_name_set(sd->wl.win,
2411                                           _border_corner[(2 + i) % 4].name);
2412    else
2413      ecore_wl_window_cursor_default_restore(sd->wl.win);
2414 #else
2415    (void)source;
2416 #endif
2417 }
2418
2419 static void
2420 _elm_win_frame_cb_resize_hide(void *data,
2421                               Evas_Object *obj EINA_UNUSED,
2422                               const char *sig EINA_UNUSED,
2423                               const char *source EINA_UNUSED)
2424 {
2425    ELM_WIN_DATA_GET(data, sd);
2426
2427    if (!sd) return;
2428    if (sd->resizing) return;
2429
2430 #ifdef HAVE_ELEMENTARY_WAYLAND
2431    ecore_wl_window_cursor_default_restore(sd->wl.win);
2432 #endif
2433 }
2434
2435 static void
2436 _elm_win_frame_cb_resize_start(void *data,
2437                                Evas_Object *obj EINA_UNUSED,
2438                                const char *sig EINA_UNUSED,
2439                                const char *source)
2440 {
2441 #ifdef HAVE_ELEMENTARY_WAYLAND
2442    ELM_WIN_DATA_GET(data, sd);
2443    int i;
2444
2445    if (!sd) return;
2446    if (sd->resizing) return;
2447
2448    sd->resizing = EINA_TRUE;
2449    i = sd->rot / 90;
2450    if (!strcmp(source, "elm.event.resize.t"))
2451      sd->resize_location = _border_side[(0 + i) % 4].location;
2452    else if (!strcmp(source, "elm.event.resize.b"))
2453      sd->resize_location = _border_side[(2 + i) % 4].location;
2454    else if (!strcmp(source, "elm.event.resize.l"))
2455      sd->resize_location = _border_side[(1 + i) % 4].location;
2456    else if (!strcmp(source, "elm.event.resize.r"))
2457      sd->resize_location = _border_side[(3 + i) % 4].location;
2458    else if (!strcmp(source, "elm.event.resize.tl"))
2459      sd->resize_location = _border_corner[(0 + i) % 4].location;
2460    else if (!strcmp(source, "elm.event.resize.tr"))
2461      sd->resize_location = _border_corner[(3 + i) % 4].location;
2462    else if (!strcmp(source, "elm.event.resize.bl"))
2463      sd->resize_location = _border_corner[(1 + i) % 4].location;
2464    else if (!strcmp(source, "elm.event.resize.br"))
2465      sd->resize_location = _border_corner[(2 + i) % 4].location;
2466    else
2467      sd->resize_location = 0;
2468
2469    if (sd->resize_location > 0)
2470      ecore_evas_wayland_resize(sd->ee, sd->resize_location);
2471 #else
2472    (void)data;
2473    (void)source;
2474 #endif
2475 }
2476
2477 static void
2478 _elm_win_frame_cb_minimize(void *data,
2479                            Evas_Object *obj EINA_UNUSED,
2480                            const char *sig EINA_UNUSED,
2481                            const char *source EINA_UNUSED)
2482 {
2483    ELM_WIN_DATA_GET(data, sd);
2484
2485    if (!sd) return;
2486 //   sd->iconified = EINA_TRUE;
2487    TRAP(sd, iconified_set, EINA_TRUE);
2488 }
2489
2490 static void
2491 _elm_win_frame_maximized_state_update(Elm_Win_Smart_Data *sd, Eina_Bool maximized)
2492 {
2493    const char *emission;
2494
2495    if (maximized)
2496      emission = "elm,state,maximized";
2497    else
2498      emission = "elm,state,unmaximized";
2499
2500    edje_object_signal_emit(sd->frame_obj, emission, "elm");
2501    edje_object_message_signal_process(sd->frame_obj);
2502    evas_object_smart_calculate(sd->frame_obj);
2503
2504    _elm_win_frame_obj_update(sd);
2505 }
2506
2507 static void
2508 _elm_win_frame_cb_maximize(void *data,
2509                            Evas_Object *obj EINA_UNUSED,
2510                            const char *sig EINA_UNUSED,
2511                            const char *source EINA_UNUSED)
2512 {
2513    Eina_Bool value;
2514    ELM_WIN_DATA_GET(data, sd);
2515
2516    if (!sd) return;
2517    if (sd->maximized) value = EINA_FALSE;
2518    else value = EINA_TRUE;
2519
2520    _elm_win_frame_maximized_state_update(sd, value);
2521
2522    TRAP(sd, maximized_set, value);
2523 }
2524
2525 static void
2526 _elm_win_frame_cb_close(void *data,
2527                         Evas_Object *obj EINA_UNUSED,
2528                         const char *sig EINA_UNUSED,
2529                         const char *source EINA_UNUSED)
2530 {
2531    ELM_WIN_DATA_GET(data, sd);
2532    Evas_Object *win;
2533
2534    /* FIXME: After the current freeze, this should be handled differently.
2535     *
2536     * Ideally, we would want to mimic the X11 backend and use something
2537     * like ECORE_WL_EVENT_WINDOW_DELETE and handle the delete_request
2538     * inside of ecore_evas. That would be the 'proper' way, but since we are
2539     * in a freeze right now, I cannot add a new event value, or a new
2540     * event structure to ecore_wayland.
2541     *
2542     * So yes, this is a temporary 'stop-gap' solution which will be fixed
2543     * when the freeze is over, but it does fix a trac bug for now, and in a
2544     * way which does not break API or the freeze. - dh
2545     */
2546
2547    if (!sd) return;
2548
2549    win = sd->obj;
2550
2551    int autodel = sd->autodel;
2552    sd->autodel_clear = &autodel;
2553    evas_object_ref(win);
2554    evas_object_smart_callback_call(win, SIG_DELETE_REQUEST, NULL);
2555    // FIXME: if above callback deletes - then the below will be invalid
2556    if (autodel) evas_object_del(win);
2557    else sd->autodel_clear = NULL;
2558    evas_object_unref(win);
2559 }
2560
2561 static void
2562 _elm_win_frame_add(Elm_Win_Smart_Data *sd,
2563                    const char *style)
2564 {
2565    Evas_Object *obj = sd->obj;
2566    int w, h, mw, mh;
2567    short layer;
2568
2569    sd->frame_obj = edje_object_add(sd->evas);
2570    layer = evas_object_layer_get(obj);
2571    evas_object_layer_set(sd->frame_obj, layer + 1);
2572    if (!elm_widget_theme_object_set
2573        (sd->obj, sd->frame_obj, "border", "base", style))
2574      {
2575         ELM_SAFE_FREE(sd->frame_obj, evas_object_del);
2576         return;
2577      }
2578
2579    sd->spacer_obj = evas_object_rectangle_add(sd->evas);
2580    evas_object_color_set(sd->spacer_obj, 0, 0, 0, 0);
2581    evas_object_repeat_events_set(sd->spacer_obj, EINA_TRUE);
2582    edje_object_part_swallow(sd->frame_obj, "elm.swallow.frame_spacer",
2583                             sd->spacer_obj);
2584
2585    sd->client_obj = evas_object_rectangle_add(sd->evas);
2586    evas_object_color_set(sd->client_obj, 0, 0, 0, 0);
2587    /* NB: Tried pass_events here, but that fails to send events */
2588    evas_object_repeat_events_set(sd->client_obj, EINA_TRUE);
2589    edje_object_part_swallow(sd->frame_obj, "elm.swallow.client",
2590                             sd->client_obj);
2591
2592    evas_object_is_frame_object_set(sd->frame_obj, EINA_TRUE);
2593
2594    evas_object_event_callback_add
2595      (sd->frame_obj, EVAS_CALLBACK_MOVE, _elm_win_frame_obj_move, sd);
2596    evas_object_event_callback_add
2597      (sd->frame_obj, EVAS_CALLBACK_RESIZE, _elm_win_frame_obj_resize, sd);
2598
2599    /* NB: Do NOT remove these calls !! Needed to calculate proper
2600     * framespace on inital show of the window */
2601    edje_object_size_min_calc(sd->frame_obj, &mw, &mh);
2602    evas_object_move(sd->frame_obj, 0, 0);
2603    evas_object_resize(sd->frame_obj, mw, mh);
2604    evas_object_smart_calculate(sd->frame_obj);
2605
2606    edje_object_signal_callback_add
2607      (sd->frame_obj, "elm,action,move,start", "elm",
2608      _elm_win_frame_cb_move_start, obj);
2609    edje_object_signal_callback_add
2610      (sd->frame_obj, "elm,action,move,stop", "elm",
2611      _elm_win_frame_cb_move_stop, obj);
2612    edje_object_signal_callback_add
2613      (sd->frame_obj, "elm,action,resize,show", "*",
2614      _elm_win_frame_cb_resize_show, obj);
2615    edje_object_signal_callback_add
2616      (sd->frame_obj, "elm,action,resize,hide", "*",
2617      _elm_win_frame_cb_resize_hide, obj);
2618    edje_object_signal_callback_add
2619      (sd->frame_obj, "elm,action,resize,start", "*",
2620      _elm_win_frame_cb_resize_start, obj);
2621    edje_object_signal_callback_add
2622      (sd->frame_obj, "elm,action,minimize", "elm",
2623      _elm_win_frame_cb_minimize, obj);
2624    edje_object_signal_callback_add
2625      (sd->frame_obj, "elm,action,maximize", "elm",
2626      _elm_win_frame_cb_maximize, obj);
2627    edje_object_signal_callback_add
2628      (sd->frame_obj, "elm,action,close", "elm", _elm_win_frame_cb_close, obj);
2629
2630    if (sd->title)
2631      {
2632         edje_object_part_text_escaped_set
2633           (sd->frame_obj, "elm.text.title", sd->title);
2634      }
2635
2636    ecore_evas_geometry_get(sd->ee, NULL, NULL, &w, &h);
2637    ecore_evas_resize(sd->ee, w, h);
2638 }
2639
2640 static void
2641 _elm_win_frame_del(Elm_Win_Smart_Data *sd)
2642 {
2643    int w, h;
2644
2645    ELM_SAFE_FREE(sd->client_obj, evas_object_del);
2646
2647    if (sd->frame_obj)
2648      {
2649         evas_object_event_callback_del_full
2650           (sd->frame_obj, EVAS_CALLBACK_MOVE, _elm_win_frame_obj_move, sd);
2651         evas_object_event_callback_del_full
2652           (sd->frame_obj, EVAS_CALLBACK_RESIZE, _elm_win_frame_obj_resize, sd);
2653
2654         edje_object_signal_callback_del
2655           (sd->frame_obj, "elm,action,move,start", "elm",
2656               _elm_win_frame_cb_move_start);
2657         edje_object_signal_callback_del
2658           (sd->frame_obj, "elm,action,move,stop", "elm",
2659               _elm_win_frame_cb_move_stop);
2660         edje_object_signal_callback_del
2661           (sd->frame_obj, "elm,action,resize,show", "*",
2662               _elm_win_frame_cb_resize_show);
2663         edje_object_signal_callback_del
2664           (sd->frame_obj, "elm,action,resize,hide", "*",
2665               _elm_win_frame_cb_resize_hide);
2666         edje_object_signal_callback_del
2667           (sd->frame_obj, "elm,action,resize,start", "*",
2668               _elm_win_frame_cb_resize_start);
2669         edje_object_signal_callback_del
2670           (sd->frame_obj, "elm,action,minimize", "elm",
2671               _elm_win_frame_cb_minimize);
2672         edje_object_signal_callback_del
2673           (sd->frame_obj, "elm,action,maximize", "elm",
2674               _elm_win_frame_cb_maximize);
2675         edje_object_signal_callback_del
2676           (sd->frame_obj, "elm,action,close", "elm",
2677               _elm_win_frame_cb_close);
2678
2679         ELM_SAFE_FREE(sd->frame_obj, evas_object_del);
2680      }
2681
2682    evas_output_framespace_set(sd->evas, 0, 0, 0, 0);
2683    ecore_evas_geometry_get(sd->ee, NULL, NULL, &w, &h);
2684    ecore_evas_resize(sd->ee, w, h);
2685 }
2686
2687 #ifdef ELM_DEBUG
2688 static void
2689 _debug_key_down(void *data EINA_UNUSED,
2690                 Evas *e EINA_UNUSED,
2691                 Evas_Object *obj,
2692                 void *event_info)
2693 {
2694    Evas_Event_Key_Down *ev = event_info;
2695
2696    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
2697      return;
2698
2699    if ((strcmp(ev->key, "F12")) ||
2700        (!evas_key_modifier_is_set(ev->modifiers, "Control")))
2701      return;
2702
2703    INF("Tree graph generated.");
2704    elm_object_tree_dot_dump(obj, "./dump.dot");
2705 }
2706
2707 #endif
2708
2709 static void
2710 _win_inlined_image_set(Elm_Win_Smart_Data *sd)
2711 {
2712    evas_object_image_alpha_set(sd->img_obj, EINA_FALSE);
2713    evas_object_image_filled_set(sd->img_obj, EINA_TRUE);
2714
2715    evas_object_event_callback_add
2716      (sd->img_obj, EVAS_CALLBACK_DEL, _elm_win_on_img_obj_del, sd->obj);
2717    evas_object_event_callback_add
2718      (sd->img_obj, EVAS_CALLBACK_HIDE, _win_img_hide, sd->obj);
2719    evas_object_event_callback_add
2720      (sd->img_obj, EVAS_CALLBACK_MOUSE_UP, _win_img_mouse_up, sd->obj);
2721    evas_object_event_callback_add
2722      (sd->img_obj, EVAS_CALLBACK_FOCUS_IN, _win_img_focus_in, sd->obj);
2723    evas_object_event_callback_add
2724      (sd->img_obj, EVAS_CALLBACK_FOCUS_OUT, _win_img_focus_out, sd->obj);
2725 }
2726
2727 static void
2728 _elm_win_on_icon_del(void *data,
2729                      Evas *e EINA_UNUSED,
2730                      Evas_Object *obj,
2731                      void *event_info EINA_UNUSED)
2732 {
2733    ELM_WIN_DATA_GET(data, sd);
2734
2735    if (sd->icon == obj) sd->icon = NULL;
2736 }
2737
2738 static void
2739 _elm_win_smart_add(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
2740 {
2741    eo_do_super(obj, MY_CLASS, evas_obj_smart_add());
2742
2743    elm_widget_can_focus_set(obj, EINA_TRUE);
2744
2745    elm_widget_highlight_ignore_set(obj, EINA_TRUE);
2746 }
2747
2748 #ifdef HAVE_ELEMENTARY_X
2749 static void
2750 _elm_x_io_err(void *data EINA_UNUSED)
2751 {
2752    Eina_List *l;
2753    Evas_Object *obj;
2754
2755    EINA_LIST_FOREACH(_elm_win_list, l, obj)
2756      evas_object_smart_callback_call(obj, SIG_IOERR, NULL);
2757    elm_exit();
2758 }
2759 #endif
2760
2761 EAPI Evas_Object *
2762 elm_win_add(Evas_Object *parent,
2763             const char *name,
2764             Elm_Win_Type type)
2765 {
2766    Evas_Object *obj = eo_add_custom(MY_CLASS, parent, elm_obj_win_constructor(name, type));
2767    eo_unref(obj);
2768    return obj;
2769 }
2770
2771 static void
2772 _elm_win_cb_hide(void *data EINA_UNUSED,
2773                  Evas *e EINA_UNUSED,
2774                  Evas_Object *obj EINA_UNUSED,
2775                  void *event_info EINA_UNUSED)
2776 {
2777    _elm_win_state_eval_queue();
2778 }
2779
2780 static void
2781 _elm_win_cb_show(void *data EINA_UNUSED,
2782                  Evas *e EINA_UNUSED,
2783                  Evas_Object *obj EINA_UNUSED,
2784                  void *event_info EINA_UNUSED)
2785 {
2786    _elm_win_state_eval_queue();
2787 }
2788
2789 /**
2790   * @internal
2791   *
2792   * Recalculate the size of window considering its resize objects' weight and
2793   * min size. If any of its resize objects' weight equals to 0.0, window
2794   * layout's weight will be set to 0.0.
2795   *
2796   * @param o box object
2797   * @param p box's private data
2798   * @param data window object
2799   */
2800 static void
2801 _window_layout_stack(Evas_Object *o, Evas_Object_Box_Data *p, void *data)
2802 {
2803    const Eina_List *l;
2804    Evas_Object *child;
2805    Evas_Object_Box_Option *opt;
2806    Evas_Coord x, y, w, h;
2807    double wx, wy;
2808    Evas_Coord minw = -1, minh = -1;
2809    double weight_x = EVAS_HINT_EXPAND;
2810    double weight_y = EVAS_HINT_EXPAND;
2811
2812    EINA_LIST_FOREACH(p->children, l, opt)
2813      {
2814         child = opt->obj;
2815         evas_object_size_hint_weight_get(child, &wx, &wy);
2816         if (wx == 0.0) weight_x = 0;
2817         if (wy == 0.0) weight_y = 0;
2818
2819         evas_object_size_hint_min_get(child, &w, &h);
2820         if (w > minw) minw = w;
2821         if (h > minh) minh = h;
2822      }
2823
2824    evas_object_size_hint_min_set(o, minw, minh);
2825    evas_object_geometry_get(o, &x, &y, &w, &h);
2826    if (w < minw) w = minw;
2827    if (h < minh) h = minh;
2828    evas_object_resize(o, w, h);
2829
2830    EINA_LIST_FOREACH(p->children, l, opt)
2831      {
2832         child = opt->obj;
2833         evas_object_move(child, x, y);
2834         evas_object_resize(child, w, h);
2835      }
2836
2837    ELM_WIN_DATA_GET(data, sd);
2838    evas_object_size_hint_weight_set(sd->layout, weight_x, weight_y);
2839    evas_object_smart_changed(sd->layout);
2840 }
2841
2842 static void
2843 _win_constructor(Eo *obj, void *_pd, va_list *list)
2844 {
2845    Elm_Win_Smart_Data *sd = _pd;
2846    sd->obj = obj; // in ctor
2847
2848    const char *name = va_arg(*list, const char *);
2849    Elm_Win_Type type = va_arg(*list, Elm_Win_Type);
2850    Evas_Object *parent;
2851    Evas *e;
2852    const Eina_List *l;
2853    const char *fontpath, *engine = NULL, *enginelist[32], *disp;
2854    int i;
2855
2856    Elm_Win_Smart_Data tmp_sd;
2857
2858    eo_do(obj, eo_parent_get(&parent));
2859
2860    /* just to store some data while trying out to create a canvas */
2861    memset(&tmp_sd, 0, sizeof(Elm_Win_Smart_Data));
2862
2863    switch (type)
2864      {
2865       case ELM_WIN_INLINED_IMAGE:
2866         if (!parent) break;
2867           {
2868              e = evas_object_evas_get(parent);
2869              Ecore_Evas *ee;
2870
2871              if (!e) break;
2872
2873              ee = ecore_evas_ecore_evas_get(e);
2874              if (!ee) break;
2875
2876              tmp_sd.img_obj = ecore_evas_object_image_new(ee);
2877              if (!tmp_sd.img_obj) break;
2878
2879              tmp_sd.ee = ecore_evas_object_ecore_evas_get(tmp_sd.img_obj);
2880              if (!tmp_sd.ee)
2881                {
2882                   ELM_SAFE_FREE(tmp_sd.img_obj, evas_object_del);
2883                }
2884           }
2885         break;
2886
2887       case ELM_WIN_SOCKET_IMAGE:
2888         tmp_sd.ee = ecore_evas_extn_socket_new(1, 1);
2889         break;
2890
2891       default:
2892         disp = getenv("ELM_DISPLAY");
2893         if ((disp) && (!strcmp(disp, "x11")))
2894           {
2895              if ((_elm_accel_preference) &&
2896                  ((!strcasecmp(_elm_accel_preference, "gl")) ||
2897                   (!strcasecmp(_elm_accel_preference, "opengl")) ||
2898                   (!strcasecmp(_elm_accel_preference, "3d")) ||
2899                   (!strcasecmp(_elm_accel_preference, "hw")) ||
2900                   (!strcasecmp(_elm_accel_preference, "accel")) ||
2901                   (!strcasecmp(_elm_accel_preference, "hardware")) ||
2902                   (!strcasecmp(_elm_accel_preference, "accel"))
2903                  ))
2904                {
2905                   enginelist[0] = ELM_OPENGL_X11;
2906                   enginelist[1] = ELM_SOFTWARE_X11;
2907                   enginelist[2] = NULL;
2908                }
2909              else
2910                {
2911                   enginelist[0] = ENGINE_GET();
2912                   enginelist[1] = ELM_SOFTWARE_X11;
2913                   enginelist[2] = ELM_OPENGL_X11;
2914                   enginelist[3] = NULL;
2915                }
2916           }
2917         else if ((disp) && (!strcmp(disp, "wl")))
2918           {
2919              if ((_elm_accel_preference) &&
2920                  ((!strcasecmp(_elm_accel_preference, "gl")) ||
2921                   (!strcasecmp(_elm_accel_preference, "opengl")) ||
2922                   (!strcasecmp(_elm_accel_preference, "3d")) ||
2923                   (!strcasecmp(_elm_accel_preference, "hw")) ||
2924                   (!strcasecmp(_elm_accel_preference, "accel")) ||
2925                   (!strcasecmp(_elm_accel_preference, "hardware")) ||
2926                   (!strcasecmp(_elm_accel_preference, "accel"))
2927                  ))
2928                {
2929                   enginelist[0] = ELM_WAYLAND_EGL;
2930                   enginelist[1] = ELM_WAYLAND_SHM;
2931                   enginelist[2] = NULL;
2932                }
2933              else
2934                {
2935                   enginelist[0] = ENGINE_GET();
2936                   enginelist[1] = ELM_WAYLAND_SHM;
2937                   enginelist[2] = ELM_WAYLAND_EGL;
2938                   enginelist[3] = NULL;
2939                }
2940           }
2941         else if ((disp) && (!strcmp(disp, "win")))
2942           {
2943              enginelist[0] = ENGINE_GET();
2944              enginelist[1] = ELM_SOFTWARE_WIN32;
2945              enginelist[2] = NULL;
2946           }
2947         else if ((disp) && (!strcmp(disp, "sdl")))
2948           {
2949              if ((_elm_accel_preference) &&
2950                  ((!strcasecmp(_elm_accel_preference, "gl")) ||
2951                   (!strcasecmp(_elm_accel_preference, "opengl")) ||
2952                   (!strcasecmp(_elm_accel_preference, "3d")) ||
2953                   (!strcasecmp(_elm_accel_preference, "hw")) ||
2954                   (!strcasecmp(_elm_accel_preference, "accel")) ||
2955                   (!strcasecmp(_elm_accel_preference, "hardware")) ||
2956                   (!strcasecmp(_elm_accel_preference, "accel"))
2957                  ))
2958                {
2959                   enginelist[0] = ELM_OPENGL_SDL;
2960                   enginelist[1] = ELM_SOFTWARE_SDL;
2961                   enginelist[2] = NULL;
2962                }
2963              else
2964                {
2965                   enginelist[0] = ENGINE_GET();
2966                   enginelist[1] = ELM_SOFTWARE_SDL;
2967                   enginelist[2] = ELM_OPENGL_SDL;
2968                   enginelist[3] = NULL;
2969                }
2970           }
2971         else if ((disp) && (!strcmp(disp, "mac")))
2972           {
2973              enginelist[0] = ENGINE_GET();
2974              enginelist[1] = ELM_OPENGL_COCOA;
2975              enginelist[2] = NULL;
2976           }
2977         else if ((disp) && (!strcmp(disp, "ews")))
2978           {
2979              enginelist[0] = ENGINE_GET();
2980              enginelist[1] = ELM_EWS;
2981              enginelist[2] = NULL;
2982           }
2983         else if ((disp) && (!strcmp(disp, "fb")))
2984           {
2985              enginelist[0] = ENGINE_GET();
2986              enginelist[1] = ELM_SOFTWARE_FB;
2987              enginelist[2] = NULL;
2988           }
2989         else if ((disp) && (!strcmp(disp, "buffer")))
2990           {
2991              enginelist[0] = ENGINE_GET();
2992              enginelist[1] = ELM_BUFFER;
2993              enginelist[2] = NULL;
2994           }
2995         else if ((disp) && (!strcmp(disp, "ps3")))
2996           {
2997              enginelist[0] = ENGINE_GET();
2998              enginelist[1] = ELM_SOFTWARE_PSL1GHT;
2999              enginelist[2] = NULL;
3000           }
3001         else if ((disp) && (!strcmp(disp, "shot")))
3002           {
3003              enginelist[0] = ENGINE_GET();
3004              enginelist[1] = NULL;
3005           }
3006         else
3007           {
3008              if ((_elm_accel_preference) &&
3009                  ((!strcasecmp(_elm_accel_preference, "gl")) ||
3010                   (!strcasecmp(_elm_accel_preference, "opengl")) ||
3011                   (!strcasecmp(_elm_accel_preference, "3d")) ||
3012                   (!strcasecmp(_elm_accel_preference, "hw")) ||
3013                   (!strcasecmp(_elm_accel_preference, "accel")) ||
3014                   (!strcasecmp(_elm_accel_preference, "hardware")) ||
3015                   (!strcasecmp(_elm_accel_preference, "accel"))
3016                  ))
3017                {
3018                   enginelist[0] = ELM_OPENGL_X11;
3019                   enginelist[1] = ELM_WAYLAND_EGL;
3020                   enginelist[2] = ELM_SOFTWARE_FB;
3021                   enginelist[3] = ELM_OPENGL_COCOA;
3022                   enginelist[4] = ELM_OPENGL_SDL;
3023                   enginelist[5] = NULL;
3024                }
3025              else
3026                {
3027                   enginelist[0] = ENGINE_GET();
3028                   enginelist[1] = ELM_SOFTWARE_X11;
3029                   enginelist[2] = ELM_WAYLAND_SHM;
3030                   enginelist[3] = ELM_SOFTWARE_FB;
3031                   enginelist[4] = ELM_OPENGL_COCOA;
3032                   enginelist[5] = ELM_SOFTWARE_SDL;
3033                   enginelist[6] = NULL;
3034                }
3035           }
3036         for (i = 0; i < 30; i++)
3037           {
3038              if ((i > 0) && (!enginelist[i])) break;
3039              if (!strcmp(enginelist[i], ELM_SOFTWARE_X11))
3040                tmp_sd.ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
3041              else if (!strcmp(enginelist[i], ELM_OPENGL_X11))
3042                {
3043                   int opt[10], opt_i = 0;
3044
3045                   if (_elm_config->vsync)
3046                     {
3047                        opt[opt_i++] = ECORE_EVAS_GL_X11_OPT_VSYNC;
3048                        opt[opt_i++] = 1;
3049                        opt[opt_i++] = 0;
3050                     }
3051                   if (opt_i > 0)
3052                     tmp_sd.ee = ecore_evas_gl_x11_options_new(NULL, 0, 0, 0, 1, 1, opt);
3053                   else
3054                     tmp_sd.ee = ecore_evas_gl_x11_new(NULL, 0, 0, 0, 1, 1);
3055                }
3056              else if (!strcmp(enginelist[i], ELM_WAYLAND_SHM))
3057                tmp_sd.ee = ecore_evas_wayland_shm_new(NULL, 0, 0, 0, 1, 1, 0);
3058              else if (!strcmp(enginelist[i], ELM_WAYLAND_EGL))
3059                tmp_sd.ee = ecore_evas_wayland_egl_new(NULL, 0, 0, 0, 1, 1, 0);
3060              else if (!strcmp(enginelist[i], ELM_SOFTWARE_WIN32))
3061                tmp_sd.ee = ecore_evas_software_gdi_new(NULL, 0, 0, 1, 1);
3062              else if (!strcmp(enginelist[i], ELM_SOFTWARE_SDL))
3063                tmp_sd.ee = ecore_evas_sdl_new(NULL, 0, 0, 0, 0, 0, 1);
3064              else if (!strcmp(enginelist[i], ELM_OPENGL_SDL))
3065                tmp_sd.ee = ecore_evas_gl_sdl_new(NULL, 1, 1, 0, 0);
3066              else if (!strcmp(enginelist[i], ELM_OPENGL_COCOA))
3067                tmp_sd.ee = ecore_evas_cocoa_new(NULL, 1, 1, 0, 0);
3068              else if (!strcmp(enginelist[i], ELM_EWS))
3069                tmp_sd.ee = ecore_evas_ews_new(0, 0, 1, 1);
3070              else if (!strcmp(enginelist[i], ELM_SOFTWARE_FB))
3071                tmp_sd.ee = ecore_evas_fb_new(NULL, 0, 1, 1);
3072              else if (!strcmp(enginelist[i], ELM_BUFFER))
3073                tmp_sd.ee = ecore_evas_buffer_new(1, 1);
3074              else if (!strcmp(enginelist[i], ELM_SOFTWARE_PSL1GHT))
3075                tmp_sd.ee = ecore_evas_psl1ght_new(NULL, 1, 1);
3076              else if (!strncmp(enginelist[i], "shot:", 5))
3077                {
3078                   tmp_sd.ee = ecore_evas_buffer_new(1, 1);
3079                   ecore_evas_manual_render_set(tmp_sd.ee, EINA_TRUE);
3080                   tmp_sd.shot.info = eina_stringshare_add(ENGINE_GET() + 5);
3081                }
3082              engine = enginelist[i];
3083              if (tmp_sd.ee) break;
3084           }
3085         break;
3086      }
3087
3088    if (!tmp_sd.ee)
3089      {
3090         ERR("Cannot create window.");
3091         eo_error_set(obj);
3092         return;
3093      }
3094
3095    eo_do(obj, eo_parent_set(ecore_evas_get(tmp_sd.ee)));
3096    eo_do_super(obj, MY_CLASS, eo_constructor());
3097    eo_do(obj,
3098          evas_obj_type_set(MY_CLASS_NAME_LEGACY),
3099          evas_obj_smart_callbacks_descriptions_set(_smart_callbacks, NULL));
3100
3101    if (getenv("ELM_FIRST_FRAME"))
3102      evas_event_callback_add(ecore_evas_get(tmp_sd.ee), EVAS_CALLBACK_RENDER_POST,
3103                              _elm_win_first_frame_do, getenv("ELM_FIRST_FRAME"));
3104
3105    /* copying possibly altered fields back */
3106 #define SD_CPY(_field)             \
3107   do                               \
3108     {                              \
3109        sd->_field = tmp_sd._field; \
3110     } while (0)
3111
3112    SD_CPY(ee);
3113    SD_CPY(img_obj);
3114    SD_CPY(shot.info);
3115 #undef SD_CPY
3116
3117    if ((trap) && (trap->add))
3118      sd->trap_data = trap->add(obj);
3119
3120    /* complementary actions, which depend on final smart data
3121     * pointer */
3122    if (type == ELM_WIN_INLINED_IMAGE)
3123      _win_inlined_image_set(sd);
3124 #ifdef HAVE_ELEMENTARY_X
3125    else if ((engine) &&
3126             ((!strcmp(engine, ELM_SOFTWARE_X11)) ||
3127              (!strcmp(engine, ELM_OPENGL_X11))))
3128      {
3129         sd->x.client_message_handler = ecore_event_handler_add
3130             (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, obj);
3131         sd->x.property_handler = ecore_event_handler_add
3132             (ECORE_X_EVENT_WINDOW_PROPERTY, _elm_win_property_change, obj);
3133      }
3134 #endif
3135    else if ((engine) && (!strncmp(engine, "shot:", 5)))
3136      _shot_init(sd);
3137
3138    sd->kbdmode = ELM_WIN_KEYBOARD_UNKNOWN;
3139    sd->indmode = ELM_WIN_INDICATOR_UNKNOWN;
3140
3141 #ifdef HAVE_ELEMENTARY_X
3142    _elm_win_xwindow_get(sd);
3143    if (sd->x.xwin)
3144      {
3145         ecore_x_io_error_handler_set(_elm_x_io_err, NULL);
3146      }
3147 #endif
3148
3149 #ifdef HAVE_ELEMENTARY_WAYLAND
3150    if ((ENGINE_COMPARE(ELM_WAYLAND_SHM)) || (ENGINE_COMPARE(ELM_WAYLAND_EGL)))
3151      _elm_win_wlwindow_get(sd);
3152 #endif
3153
3154    if ((_elm_config->bgpixmap)
3155 #ifdef HAVE_ELEMENTARY_X
3156        &&
3157        (((sd->x.xwin) && (!ecore_x_screen_is_composited(0))) ||
3158            (!sd->x.xwin)))
3159 #else
3160       )
3161 #endif
3162      TRAP(sd, avoid_damage_set, ECORE_EVAS_AVOID_DAMAGE_EXPOSE);
3163    // bg pixmap done by x - has other issues like can be redrawn by x before it
3164    // is filled/ready by app
3165    //     TRAP(sd, avoid_damage_set, ECORE_EVAS_AVOID_DAMAGE_BUILT_IN);
3166
3167    sd->type = type;
3168    sd->parent = parent;
3169
3170    if (sd->parent)
3171      evas_object_event_callback_add
3172        (sd->parent, EVAS_CALLBACK_DEL, _elm_win_on_parent_del, obj);
3173
3174    sd->evas = ecore_evas_get(sd->ee);
3175
3176    evas_object_color_set(obj, 0, 0, 0, 0);
3177    evas_object_move(obj, 0, 0);
3178    evas_object_resize(obj, 1, 1);
3179    evas_object_layer_set(obj, 50);
3180    evas_object_pass_events_set(obj, EINA_TRUE);
3181
3182    if (type == ELM_WIN_INLINED_IMAGE)
3183      elm_widget_parent2_set(obj, parent);
3184
3185    /* use own version of ecore_evas_object_associate() that does TRAP() */
3186    ecore_evas_data_set(sd->ee, "elm_win", obj);
3187
3188    evas_object_event_callback_add
3189      (obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
3190       _elm_win_obj_callback_changed_size_hints, obj);
3191
3192    evas_object_intercept_raise_callback_add
3193      (obj, _elm_win_obj_intercept_raise, obj);
3194    evas_object_intercept_lower_callback_add
3195      (obj, _elm_win_obj_intercept_lower, obj);
3196    evas_object_intercept_stack_above_callback_add
3197      (obj, _elm_win_obj_intercept_stack_above, obj);
3198    evas_object_intercept_stack_below_callback_add
3199      (obj, _elm_win_obj_intercept_stack_below, obj);
3200    evas_object_intercept_layer_set_callback_add
3201      (obj, _elm_win_obj_intercept_layer_set, obj);
3202    evas_object_intercept_show_callback_add
3203      (obj, _elm_win_obj_intercept_show, obj);
3204
3205    TRAP(sd, name_class_set, name, _elm_appname);
3206    ecore_evas_callback_delete_request_set(sd->ee, _elm_win_delete_request);
3207    ecore_evas_callback_resize_set(sd->ee, _elm_win_resize);
3208    ecore_evas_callback_mouse_in_set(sd->ee, _elm_win_mouse_in);
3209    ecore_evas_callback_focus_in_set(sd->ee, _elm_win_focus_in);
3210    ecore_evas_callback_focus_out_set(sd->ee, _elm_win_focus_out);
3211    ecore_evas_callback_move_set(sd->ee, _elm_win_move);
3212    ecore_evas_callback_state_change_set(sd->ee, _elm_win_state_change);
3213    evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _elm_win_cb_hide, NULL);
3214    evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _elm_win_cb_show, NULL);
3215
3216    evas_image_cache_set(sd->evas, (_elm_config->image_cache * 1024));
3217    evas_font_cache_set(sd->evas, (_elm_config->font_cache * 1024));
3218
3219    EINA_LIST_FOREACH(_elm_config->font_dirs, l, fontpath)
3220      evas_font_path_append(sd->evas, fontpath);
3221
3222    if (!_elm_config->font_hinting)
3223      evas_font_hinting_set(sd->evas, EVAS_FONT_HINTING_NONE);
3224    else if (_elm_config->font_hinting == 1)
3225      evas_font_hinting_set(sd->evas, EVAS_FONT_HINTING_AUTO);
3226    else if (_elm_config->font_hinting == 2)
3227      evas_font_hinting_set(sd->evas, EVAS_FONT_HINTING_BYTECODE);
3228
3229 #ifdef HAVE_ELEMENTARY_X
3230    _elm_win_xwin_update(sd);
3231 #endif
3232
3233    _elm_win_list = eina_list_append(_elm_win_list, obj);
3234    _elm_win_count++;
3235
3236    if ((engine) && (!strcmp(engine, ELM_SOFTWARE_FB)))
3237      {
3238         TRAP(sd, fullscreen_set, 1);
3239      }
3240    else if ((type != ELM_WIN_INLINED_IMAGE) &&
3241             ((engine) &&
3242              ((!strcmp(engine, ELM_WAYLAND_SHM) ||
3243               (!strcmp(engine, ELM_WAYLAND_EGL))))))
3244      _elm_win_frame_add(sd, "default");
3245
3246    if (_elm_config->focus_highlight_enable)
3247      elm_win_focus_highlight_enabled_set(obj, EINA_TRUE);
3248    if (_elm_config->focus_highlight_animate)
3249      elm_win_focus_highlight_animate_set(obj, EINA_TRUE);
3250
3251 #ifdef ELM_DEBUG
3252    Evas_Modifier_Mask mask = evas_key_modifier_mask_get(sd->evas, "Control");
3253    evas_object_event_callback_add
3254      (obj, EVAS_CALLBACK_KEY_DOWN, _debug_key_down, NULL);
3255
3256    if (evas_object_key_grab(obj, "F12", mask, 0, EINA_TRUE))
3257      INF("Ctrl+F12 key combination exclusive for dot tree generation\n");
3258    else
3259      ERR("failed to grab F12 key to elm widgets (dot) tree generation");
3260 #endif
3261
3262    if ((_elm_config->softcursor_mode == ELM_SOFTCURSOR_MODE_ON) ||
3263        ((_elm_config->softcursor_mode == ELM_SOFTCURSOR_MODE_AUTO) &&
3264         ((engine) && (!strcmp(engine, ELM_SOFTWARE_FB)))))
3265      {
3266         Evas_Object *o;
3267         Evas_Coord mw = 1, mh = 1, hx = 0, hy = 0;
3268
3269         sd->pointer.obj = o = edje_object_add(ecore_evas_get(tmp_sd.ee));
3270         _elm_theme_object_set(obj, o, "pointer", "base", "default");
3271         edje_object_size_min_calc(o, &mw, &mh);
3272         evas_object_resize(o, mw, mh);
3273         edje_object_part_geometry_get(o, "elm.swallow.hotspot",
3274                                       &hx, &hy, NULL, NULL);
3275         sd->pointer.hot_x = hx;
3276         sd->pointer.hot_y = hy;
3277         evas_object_show(o);
3278         ecore_evas_object_cursor_set(tmp_sd.ee, o, EVAS_LAYER_MAX, hx, hy);
3279      }
3280    else if (_elm_config->softcursor_mode == ELM_SOFTCURSOR_MODE_OFF)
3281      {
3282         // do nothing
3283      }
3284
3285    sd->wm_rot.wm_supported = ecore_evas_wm_rotation_supported_get(sd->ee);
3286    sd->wm_rot.preferred_rot = -1; // it means that elm_win doesn't use preferred rotation.
3287
3288    sd->layout = edje_object_add(sd->evas);
3289    _elm_theme_object_set(obj, sd->layout, "win", "base", "default");
3290    sd->box = evas_object_box_add(sd->evas);
3291    evas_object_box_layout_set(sd->box, _window_layout_stack, obj, NULL);
3292    edje_object_part_swallow(sd->layout, "elm.swallow.contents", sd->box);
3293    evas_object_move(sd->layout, 0, 0);
3294    evas_object_resize(sd->layout, 1, 1);
3295    edje_object_update_hints_set(sd->layout, EINA_TRUE);
3296    evas_object_event_callback_add(sd->layout, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
3297                                   _elm_win_on_resize_obj_changed_size_hints, obj);
3298    evas_object_show(sd->layout);
3299 }
3300
3301 static void
3302 _constructor(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED)
3303 {
3304    eo_error_set(obj);
3305    ERR("only custom constructor can be used with '%s' class", MY_CLASS_NAME);
3306 }
3307
3308 EAPI Elm_Win_Type
3309 elm_win_type_get(const Evas_Object *obj)
3310 {
3311    ELM_WIN_CHECK(obj) ELM_WIN_UNKNOWN;
3312    Elm_Win_Type ret = ELM_WIN_UNKNOWN;
3313    eo_do((Eo *) obj, elm_obj_win_type_get(&ret));
3314    return ret;
3315 }
3316
3317 static void
3318 _type_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
3319 {
3320    Elm_Win_Type *ret = va_arg(*list, Elm_Win_Type *);
3321    Elm_Win_Smart_Data *sd = _pd;
3322    *ret = sd->type;
3323 }
3324
3325 EAPI Evas_Object *
3326 elm_win_util_standard_add(const char *name,
3327                           const char *title)
3328 {
3329    Evas_Object *win, *bg;
3330
3331    win = elm_win_add(NULL, name, ELM_WIN_BASIC);
3332    if (!win) return NULL;
3333
3334    elm_win_title_set(win, title);
3335    bg = elm_bg_add(win);
3336    if (!bg)
3337      {
3338         evas_object_del(win);
3339         return NULL;
3340      }
3341    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3342    elm_win_resize_object_add(win, bg);
3343    evas_object_show(bg);
3344
3345    return win;
3346 }
3347
3348 EAPI void
3349 elm_win_resize_object_add(Evas_Object *obj,
3350                           Evas_Object *subobj)
3351 {
3352    ELM_WIN_CHECK(obj);
3353    eo_do(obj, elm_obj_win_resize_object_add(subobj));
3354 }
3355
3356 static void
3357 _resize_object_add(Eo *obj, void *_pd, va_list *list)
3358 {
3359    Evas_Object *subobj = va_arg(*list, Evas_Object *);
3360
3361    Elm_Win_Smart_Data *sd = _pd;
3362
3363    elm_widget_sub_object_add(obj, subobj);
3364
3365    if (!evas_object_box_append(sd->box, subobj))
3366      ERR("could not append %p to box", subobj);
3367 }
3368
3369 EAPI void
3370 elm_win_resize_object_del(Evas_Object *obj,
3371                           Evas_Object *subobj)
3372 {
3373    ELM_WIN_CHECK(obj);
3374    eo_do(obj, elm_obj_win_resize_object_del(subobj));
3375 }
3376
3377 static void
3378 _resize_object_del(Eo *obj, void *_pd, va_list *list)
3379 {
3380    Evas_Object *subobj = va_arg(*list, Evas_Object *);
3381    Elm_Win_Smart_Data *sd = _pd;
3382
3383    if (!elm_widget_sub_object_del(obj, subobj))
3384      ERR("could not remove sub object %p from %p", subobj, obj);
3385
3386    evas_object_box_remove(sd->box, subobj);
3387 }
3388
3389 EAPI void
3390 elm_win_title_set(Evas_Object *obj,
3391                   const char *title)
3392 {
3393    ELM_WIN_CHECK(obj);
3394    eo_do(obj, elm_obj_win_title_set(title));
3395 }
3396
3397 static void
3398 _title_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
3399 {
3400    const char *title = va_arg(*list, const char *);
3401    Elm_Win_Smart_Data *sd = _pd;
3402
3403    if (!title) return;
3404    eina_stringshare_replace(&(sd->title), title);
3405    TRAP(sd, title_set, sd->title);
3406    if (sd->frame_obj)
3407      edje_object_part_text_escaped_set
3408        (sd->frame_obj, "elm.text.title", sd->title);
3409 }
3410
3411 EAPI const char *
3412 elm_win_title_get(const Evas_Object *obj)
3413 {
3414    ELM_WIN_CHECK(obj) NULL;
3415    const char *ret = NULL;
3416    eo_do((Eo *) obj, elm_obj_win_title_get(&ret));
3417    return ret;
3418 }
3419
3420 static void
3421 _title_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
3422 {
3423    const char **ret = va_arg(*list, const char **);
3424    Elm_Win_Smart_Data *sd = _pd;
3425    *ret = sd->title;
3426 }
3427
3428 EAPI void
3429 elm_win_icon_name_set(Evas_Object *obj,
3430                       const char *icon_name)
3431 {
3432    ELM_WIN_CHECK(obj);
3433    eo_do(obj, elm_obj_win_icon_name_set(icon_name));
3434 }
3435
3436 static void
3437 _icon_name_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
3438 {
3439    const char *icon_name = va_arg(*list, const char *);
3440    Elm_Win_Smart_Data *sd = _pd;
3441
3442    if (!icon_name) return;
3443    eina_stringshare_replace(&(sd->icon_name), icon_name);
3444 #ifdef HAVE_ELEMENTARY_X
3445    _elm_win_xwin_update(sd);
3446 #endif
3447 }
3448
3449 EAPI const char *
3450 elm_win_icon_name_get(const Evas_Object *obj)
3451 {
3452    ELM_WIN_CHECK(obj) NULL;
3453    const char *ret = NULL;
3454    eo_do((Eo *) obj, elm_obj_win_icon_name_get(&ret));
3455    return ret;
3456 }
3457
3458 static void
3459 _icon_name_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
3460 {
3461    const char **ret = va_arg(*list, const char **);
3462    Elm_Win_Smart_Data *sd = _pd;
3463    *ret = sd->icon_name;
3464 }
3465
3466 EAPI void
3467 elm_win_role_set(Evas_Object *obj, const char *role)
3468 {
3469    ELM_WIN_CHECK(obj);
3470    eo_do(obj, elm_obj_win_role_set(role));
3471 }
3472
3473 static void
3474 _role_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
3475 {
3476    const char *role = va_arg(*list, const char *);
3477    Elm_Win_Smart_Data *sd = _pd;
3478
3479    if (!role) return;
3480    eina_stringshare_replace(&(sd->role), role);
3481 #ifdef HAVE_ELEMENTARY_X
3482    _elm_win_xwin_update(sd);
3483 #endif
3484 }
3485
3486 EAPI const char *
3487 elm_win_role_get(const Evas_Object *obj)
3488 {
3489    ELM_WIN_CHECK(obj) NULL;
3490    const char *ret = NULL;
3491    eo_do((Eo *) obj, elm_obj_win_role_get(&ret));
3492    return ret;
3493 }
3494
3495 static void
3496 _role_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
3497 {
3498    const char **ret = va_arg(*list, const char **);
3499    Elm_Win_Smart_Data *sd = _pd;
3500    *ret = sd->role;
3501 }
3502
3503 EAPI void
3504 elm_win_icon_object_set(Evas_Object *obj,
3505                         Evas_Object *icon)
3506 {
3507    ELM_WIN_CHECK(obj);
3508    eo_do(obj, elm_obj_win_icon_object_set(icon));
3509 }
3510
3511 static void
3512 _icon_object_set(Eo *obj, void *_pd, va_list *list)
3513 {
3514    Evas_Object *icon = va_arg(*list, Evas_Object *);
3515    Elm_Win_Smart_Data *sd = _pd;
3516
3517    if (sd->icon)
3518      evas_object_event_callback_del_full
3519        (sd->icon, EVAS_CALLBACK_DEL, _elm_win_on_icon_del, obj);
3520    sd->icon = icon;
3521    if (sd->icon)
3522      evas_object_event_callback_add
3523        (sd->icon, EVAS_CALLBACK_DEL, _elm_win_on_icon_del, obj);
3524 #ifdef HAVE_ELEMENTARY_X
3525    _elm_win_xwin_update(sd);
3526 #endif
3527 }
3528
3529 EAPI const Evas_Object *
3530 elm_win_icon_object_get(const Evas_Object *obj)
3531 {
3532    ELM_WIN_CHECK(obj) NULL;
3533    const Evas_Object *ret = NULL;
3534    eo_do((Eo *) obj, elm_obj_win_icon_object_get(&ret));
3535    return ret;
3536 }
3537
3538 static void
3539 _icon_object_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
3540 {
3541    const Evas_Object **ret = va_arg(*list, const Evas_Object **);
3542    Elm_Win_Smart_Data *sd = _pd;
3543    *ret = sd->icon;
3544 }
3545
3546 EAPI void
3547 elm_win_autodel_set(Evas_Object *obj,
3548                     Eina_Bool autodel)
3549 {
3550    ELM_WIN_CHECK(obj);
3551    eo_do(obj, elm_obj_win_autodel_set(autodel));
3552 }
3553
3554 static void
3555 _autodel_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
3556 {
3557    Eina_Bool autodel = va_arg(*list, int);
3558    Elm_Win_Smart_Data *sd = _pd;
3559    sd->autodel = autodel;
3560 }
3561
3562 EAPI Eina_Bool
3563 elm_win_autodel_get(const Evas_Object *obj)
3564 {
3565    ELM_WIN_CHECK(obj) EINA_FALSE;
3566    Eina_Bool ret = EINA_FALSE;
3567    eo_do((Eo *) obj, elm_obj_win_autodel_get(&ret));
3568    return ret;
3569 }
3570
3571 static void
3572 _autodel_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
3573 {
3574    Eina_Bool *ret = va_arg(*list, Eina_Bool *);
3575    Elm_Win_Smart_Data *sd = _pd;
3576    *ret = sd->autodel;
3577 }
3578
3579 EAPI void
3580 elm_win_activate(Evas_Object *obj)
3581 {
3582    ELM_WIN_CHECK(obj);
3583    eo_do(obj, elm_obj_win_activate());
3584 }
3585
3586 static void
3587 _activate(Eo *obj EINA_UNUSED, void *_pd, va_list *list EINA_UNUSED)
3588 {
3589    Elm_Win_Smart_Data *sd = _pd;
3590    TRAP(sd, activate);
3591 }
3592
3593 EAPI void
3594 elm_win_lower(Evas_Object *obj)
3595 {
3596    ELM_WIN_CHECK(obj);
3597    eo_do(obj, elm_obj_win_lower());
3598 }
3599
3600 static void
3601 _lower(Eo *obj EINA_UNUSED, void *_pd, va_list *list EINA_UNUSED)
3602 {
3603    Elm_Win_Smart_Data *sd = _pd;
3604    TRAP(sd, lower);
3605 }
3606
3607 EAPI void
3608 elm_win_raise(Evas_Object *obj)
3609 {
3610    ELM_WIN_CHECK(obj);
3611    eo_do(obj, elm_obj_win_raise());
3612 }
3613
3614 static void
3615 _raise(Eo *obj EINA_UNUSED, void *_pd, va_list *list EINA_UNUSED)
3616 {
3617    Elm_Win_Smart_Data *sd = _pd;
3618    TRAP(sd, raise);
3619 }
3620
3621 EAPI void
3622 elm_win_center(Evas_Object *obj,
3623                Eina_Bool h,
3624                Eina_Bool v)
3625 {
3626    ELM_WIN_CHECK(obj);
3627    eo_do(obj, elm_obj_win_center(h, v));
3628 }
3629
3630 static void
3631 _center(Eo *obj, void *_pd, va_list *list)
3632 {
3633    Eina_Bool h = va_arg(*list, int);
3634    Eina_Bool v = va_arg(*list, int);
3635    int win_w, win_h, screen_w, screen_h, nx, ny;
3636
3637    Elm_Win_Smart_Data *sd = _pd;
3638
3639    if ((trap) && (trap->center) && (!trap->center(sd->trap_data, obj)))
3640      return;
3641
3642    ecore_evas_screen_geometry_get(sd->ee, NULL, NULL, &screen_w, &screen_h);
3643    if ((!screen_w) || (!screen_h)) return;
3644
3645    evas_object_geometry_get(obj, NULL, NULL, &win_w, &win_h);
3646    if ((!win_w) || (!win_h)) return;
3647
3648    if (h) nx = win_w >= screen_w ? 0 : (screen_w / 2) - (win_w / 2);
3649    else nx = sd->screen.x;
3650    if (v) ny = win_h >= screen_h ? 0 : (screen_h / 2) - (win_h / 2);
3651    else ny = sd->screen.y;
3652    if (nx < 0) nx = 0;
3653    if (ny < 0) ny = 0;
3654
3655    evas_object_move(obj, nx, ny);
3656 }
3657
3658 EAPI void
3659 elm_win_borderless_set(Evas_Object *obj,
3660                        Eina_Bool borderless)
3661 {
3662    ELM_WIN_CHECK(obj);
3663    eo_do(obj, elm_obj_win_borderless_set(borderless));
3664 }
3665
3666 static void
3667 _borderless_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
3668 {
3669    Eina_Bool borderless = va_arg(*list, int);
3670    Elm_Win_Smart_Data *sd = _pd;
3671
3672    Eina_Bool need_frame = EINA_FALSE;
3673
3674    const char *engine_name = ecore_evas_engine_name_get(sd->ee);
3675    need_frame = engine_name &&
3676                 ((!strcmp(engine_name, ELM_WAYLAND_SHM)) ||
3677                  (!strcmp(engine_name, ELM_WAYLAND_EGL)));
3678
3679    if (borderless)
3680      {
3681         if (need_frame)
3682           _elm_win_frame_del(sd);
3683      }
3684    else
3685      {
3686         if (need_frame)
3687           _elm_win_frame_add(sd, "default");
3688
3689         if (sd->frame_obj)
3690           evas_object_show(sd->frame_obj);
3691      }
3692
3693    TRAP(sd, borderless_set, borderless);
3694 #ifdef HAVE_ELEMENTARY_X
3695    _elm_win_xwin_update(sd);
3696 #endif
3697 }
3698
3699 EAPI Eina_Bool
3700 elm_win_borderless_get(const Evas_Object *obj)
3701 {
3702    ELM_WIN_CHECK(obj) EINA_FALSE;
3703    Eina_Bool ret = EINA_FALSE;
3704    eo_do((Eo *) obj, elm_obj_win_borderless_get(&ret));
3705    return ret;
3706 }
3707
3708 static void
3709 _borderless_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
3710 {
3711    Eina_Bool *ret = va_arg(*list, Eina_Bool *);
3712    Elm_Win_Smart_Data *sd = _pd;
3713    *ret = ecore_evas_borderless_get(sd->ee);
3714 }
3715
3716 EAPI void
3717 elm_win_shaped_set(Evas_Object *obj,
3718                    Eina_Bool shaped)
3719 {
3720    ELM_WIN_CHECK(obj);
3721    eo_do(obj, elm_obj_win_shaped_set(shaped));
3722 }
3723
3724 static void
3725 _shaped_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
3726 {
3727    Eina_Bool shaped = va_arg(*list, int);
3728    Elm_Win_Smart_Data *sd = _pd;
3729
3730    TRAP(sd, shaped_set, shaped);
3731 #ifdef HAVE_ELEMENTARY_X
3732    _elm_win_xwin_update(sd);
3733 #endif
3734 }
3735
3736 EAPI Eina_Bool
3737 elm_win_shaped_get(const Evas_Object *obj)
3738 {
3739    ELM_WIN_CHECK(obj) EINA_FALSE;
3740    Eina_Bool ret = EINA_FALSE;
3741    eo_do((Eo *) obj, elm_obj_win_shaped_get(&ret));
3742    return ret;
3743 }
3744
3745 static void
3746 _shaped_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
3747 {
3748    Eina_Bool *ret = va_arg(*list, Eina_Bool *);
3749    Elm_Win_Smart_Data *sd = _pd;
3750    *ret = ecore_evas_shaped_get(sd->ee);
3751 }
3752
3753 EAPI void
3754 elm_win_alpha_set(Evas_Object *obj,
3755                   Eina_Bool enabled)
3756 {
3757    ELM_WIN_CHECK(obj);
3758    eo_do(obj, elm_obj_win_alpha_set(enabled));
3759 }
3760
3761 static void
3762 _alpha_set(Eo *obj, void *_pd, va_list *list)
3763 {
3764    Eina_Bool enabled = va_arg(*list, int);
3765    Elm_Win_Smart_Data *sd = _pd;
3766
3767    if (sd->img_obj)
3768      {
3769         evas_object_image_alpha_set(sd->img_obj, enabled);
3770         ecore_evas_alpha_set(sd->ee, enabled);
3771      }
3772    else
3773      {
3774 #ifdef HAVE_ELEMENTARY_X
3775         if (sd->x.xwin)
3776           {
3777              if (enabled)
3778                {
3779                   if (!ecore_x_screen_is_composited(0))
3780                     elm_win_shaped_set(obj, enabled);
3781                   else
3782                     TRAP(sd, alpha_set, enabled);
3783                }
3784              else
3785                TRAP(sd, alpha_set, enabled);
3786              _elm_win_xwin_update(sd);
3787           }
3788         else
3789 #endif
3790           TRAP(sd, alpha_set, enabled);
3791      }
3792 }
3793
3794 EAPI Eina_Bool
3795 elm_win_alpha_get(const Evas_Object *obj)
3796 {
3797    ELM_WIN_CHECK(obj) EINA_FALSE;
3798    Eina_Bool ret = EINA_FALSE;
3799    eo_do((Eo *) obj, elm_obj_win_alpha_get(&ret));
3800    return ret;
3801 }
3802
3803 static void
3804 _alpha_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
3805 {
3806    Eina_Bool *ret = va_arg(*list, Eina_Bool *);
3807    Elm_Win_Smart_Data *sd = _pd;
3808
3809    if (sd->img_obj)
3810      {
3811         *ret = evas_object_image_alpha_get(sd->img_obj);
3812      }
3813    else
3814      {
3815         *ret = ecore_evas_alpha_get(sd->ee);
3816      }
3817 }
3818
3819 EAPI void
3820 elm_win_override_set(Evas_Object *obj,
3821                      Eina_Bool override)
3822 {
3823    ELM_WIN_CHECK(obj);
3824    eo_do(obj, elm_obj_win_override_set(override));
3825 }
3826
3827 static void
3828 _override_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
3829 {
3830    Eina_Bool override = va_arg(*list, int);
3831    Elm_Win_Smart_Data *sd = _pd;
3832
3833    TRAP(sd, override_set, override);
3834 #ifdef HAVE_ELEMENTARY_X
3835    _elm_win_xwin_update(sd);
3836 #endif
3837 }
3838
3839 EAPI Eina_Bool
3840 elm_win_override_get(const Evas_Object *obj)
3841 {
3842    ELM_WIN_CHECK(obj) EINA_FALSE;
3843    Eina_Bool ret = EINA_FALSE;
3844    eo_do((Eo *) obj, elm_obj_win_override_get(&ret));
3845    return ret;
3846 }
3847
3848 static void
3849 _override_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
3850 {
3851    Eina_Bool *ret = va_arg(*list, Eina_Bool *);
3852    Elm_Win_Smart_Data *sd = _pd;
3853    *ret = ecore_evas_override_get(sd->ee);
3854 }
3855
3856 EAPI void
3857 elm_win_fullscreen_set(Evas_Object *obj,
3858                        Eina_Bool fullscreen)
3859 {
3860    ELM_WIN_CHECK(obj);
3861    eo_do(obj, elm_obj_win_fullscreen_set(fullscreen));
3862 }
3863
3864 static void
3865 _fullscreen_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
3866 {
3867    Eina_Bool fullscreen = va_arg(*list, int);
3868    Elm_Win_Smart_Data *sd = _pd;
3869    // YYY: handle if sd->img_obj
3870    if (ENGINE_COMPARE(ELM_SOFTWARE_FB) ||
3871        ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE))
3872      {
3873         // these engines... can ONLY be fullscreen
3874         return;
3875      }
3876    else
3877      {
3878 //        sd->fullscreen = fullscreen;
3879
3880         Eina_Bool need_frame = EINA_FALSE;
3881
3882         const char *engine_name = ecore_evas_engine_name_get(sd->ee);
3883         need_frame = engine_name &&
3884                      ((!strcmp(engine_name, ELM_WAYLAND_SHM)) ||
3885                       (!strcmp(engine_name, ELM_WAYLAND_EGL)));
3886
3887         TRAP(sd, fullscreen_set, fullscreen);
3888
3889         if (fullscreen)
3890           {
3891              if (need_frame)
3892                _elm_win_frame_del(sd);
3893           }
3894         else
3895           {
3896              if (need_frame)
3897                _elm_win_frame_add(sd, "default");
3898
3899              if (sd->frame_obj)
3900                evas_object_show(sd->frame_obj);
3901           }
3902 #ifdef HAVE_ELEMENTARY_X
3903         _elm_win_xwin_update(sd);
3904 #endif
3905      }
3906 }
3907
3908 EAPI Eina_Bool
3909 elm_win_fullscreen_get(const Evas_Object *obj)
3910 {
3911    ELM_WIN_CHECK(obj) EINA_FALSE;
3912    Eina_Bool ret = EINA_FALSE;
3913    eo_do((Eo *) obj, elm_obj_win_fullscreen_get(&ret));
3914    return ret;
3915 }
3916
3917 static void
3918 _fullscreen_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
3919 {
3920    Eina_Bool *ret = va_arg(*list, Eina_Bool *);
3921    Elm_Win_Smart_Data *sd = _pd;
3922
3923    if (!ret) return;
3924
3925    const char* engine_name = ecore_evas_engine_name_get(sd->ee);
3926
3927    if (engine_name &&
3928        ((!strcmp(engine_name, ELM_SOFTWARE_FB)) ||
3929         (!strcmp(engine_name, ELM_SOFTWARE_16_WINCE))))
3930      {
3931         // these engines... can ONLY be fullscreen
3932         *ret = EINA_TRUE;
3933      }
3934    else
3935      {
3936         *ret = sd->fullscreen;
3937      }
3938 }
3939
3940 EAPI Evas_Object *
3941 elm_win_main_menu_get(const Evas_Object *obj)
3942 {
3943    ELM_WIN_CHECK(obj) NULL;
3944    Evas_Object *ret;
3945    eo_do((Eo *) obj, elm_obj_win_main_menu_get(&ret));
3946    return ret;
3947 }
3948
3949 static void
3950 _dbus_menu_set(Eina_Bool dbus_connect, void *data)
3951 {
3952    ELM_WIN_DATA_GET_OR_RETURN(data, sd);
3953
3954    if (dbus_connect)
3955      {
3956         DBG("Setting menu to D-Bus");
3957         edje_object_part_unswallow(sd->layout, sd->main_menu);
3958         edje_object_signal_emit(sd->layout, "elm,action,hide_menu", "elm");
3959         _elm_menu_menu_bar_hide(sd->main_menu);
3960      }
3961    else
3962      {
3963         DBG("Setting menu to local mode");
3964         edje_object_part_swallow(sd->layout, "elm.swallow.menu", sd->main_menu);
3965         edje_object_signal_emit(sd->layout, "elm,action,show_menu", "elm");
3966         evas_object_show(sd->main_menu);
3967      }
3968 }
3969
3970 static void
3971 _main_menu_get(Eo *obj, void *_pd, va_list *list)
3972 {
3973    Eo **ret = va_arg(*list, Eo **);
3974    Elm_Win_Smart_Data *sd = _pd;
3975    Eina_Bool use_dbus = EINA_FALSE;
3976
3977    if (sd->main_menu) goto end;
3978
3979    sd->main_menu = elm_menu_add(obj);
3980    _elm_menu_menu_bar_set(sd->main_menu, EINA_TRUE);
3981
3982 #ifdef HAVE_ELEMENTARY_X
3983    if (!_elm_config->disable_external_menu && sd->x.xwin) use_dbus = EINA_TRUE;
3984 #endif
3985
3986 #ifdef HAVE_ELEMENTARY_X
3987    if (use_dbus && _elm_dbus_menu_register(sd->main_menu))
3988      {
3989         _elm_dbus_menu_app_menu_register(sd->x.xwin, sd->main_menu,
3990                                          _dbus_menu_set, obj);
3991      }
3992    else
3993 #endif
3994      _dbus_menu_set(EINA_FALSE, obj);
3995
3996 end:
3997    *ret = sd->main_menu;
3998 }
3999
4000 EAPI void
4001 elm_win_maximized_set(Evas_Object *obj,
4002                       Eina_Bool maximized)
4003 {
4004    ELM_WIN_CHECK(obj);
4005    eo_do(obj, elm_obj_win_maximized_set(maximized));
4006 }
4007
4008 static void
4009 _maximized_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4010 {
4011    Eina_Bool maximized = va_arg(*list, int);
4012    Elm_Win_Smart_Data *sd = _pd;
4013
4014    _elm_win_frame_maximized_state_update(sd, maximized);
4015    // YYY: handle if sd->img_obj
4016    TRAP(sd, maximized_set, maximized);
4017 #ifdef HAVE_ELEMENTARY_X
4018    _elm_win_xwin_update(sd);
4019 #endif
4020 }
4021
4022 EAPI Eina_Bool
4023 elm_win_maximized_get(const Evas_Object *obj)
4024 {
4025    ELM_WIN_CHECK(obj) EINA_FALSE;
4026    Eina_Bool ret = EINA_FALSE;
4027    eo_do((Eo *) obj, elm_obj_win_maximized_get(&ret));
4028    return ret;
4029 }
4030
4031 static void
4032 _maximized_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4033 {
4034    Eina_Bool *ret = va_arg(*list, Eina_Bool *);
4035    Elm_Win_Smart_Data *sd = _pd;
4036    *ret = sd->maximized;
4037 }
4038
4039 EAPI void
4040 elm_win_iconified_set(Evas_Object *obj,
4041                       Eina_Bool iconified)
4042 {
4043    ELM_WIN_CHECK(obj);
4044    eo_do(obj, elm_obj_win_iconified_set(iconified));
4045 }
4046
4047 static void
4048 _iconified_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4049 {
4050    Eina_Bool iconified = va_arg(*list, int);
4051    Elm_Win_Smart_Data *sd = _pd;
4052
4053 //   sd->iconified = iconified;
4054    TRAP(sd, iconified_set, iconified);
4055 #ifdef HAVE_ELEMENTARY_X
4056    _elm_win_xwin_update(sd);
4057 #endif
4058 }
4059
4060 EAPI Eina_Bool
4061 elm_win_iconified_get(const Evas_Object *obj)
4062 {
4063    ELM_WIN_CHECK(obj) EINA_FALSE;
4064    Eina_Bool ret = EINA_FALSE;
4065    eo_do((Eo *) obj, elm_obj_win_iconified_get(&ret));
4066    return ret;
4067 }
4068
4069 static void
4070 _iconified_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4071 {
4072    Eina_Bool *ret = va_arg(*list, Eina_Bool *);
4073    Elm_Win_Smart_Data *sd = _pd;
4074    *ret = sd->iconified;
4075 }
4076
4077 EAPI void
4078 elm_win_withdrawn_set(Evas_Object *obj,
4079                       Eina_Bool withdrawn)
4080 {
4081    ELM_WIN_CHECK(obj);
4082    eo_do(obj, elm_obj_win_withdrawn_set(withdrawn));
4083 }
4084
4085 static void
4086 _withdrawn_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4087 {
4088    Eina_Bool withdrawn = va_arg(*list, int);
4089    Elm_Win_Smart_Data *sd = _pd;
4090
4091 //   sd->withdrawn = withdrawn;
4092    TRAP(sd, withdrawn_set, withdrawn);
4093 #ifdef HAVE_ELEMENTARY_X
4094    _elm_win_xwin_update(sd);
4095 #endif
4096 }
4097
4098 EAPI Eina_Bool
4099 elm_win_withdrawn_get(const Evas_Object *obj)
4100 {
4101    ELM_WIN_CHECK(obj) EINA_FALSE;
4102    Eina_Bool ret = EINA_FALSE;
4103    eo_do((Eo *) obj, elm_obj_win_withdrawn_get(&ret));
4104    return ret;
4105 }
4106
4107 static void
4108 _withdrawn_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4109 {
4110    Eina_Bool *ret = va_arg(*list, Eina_Bool *);
4111    Elm_Win_Smart_Data *sd = _pd;
4112    *ret = sd->withdrawn;
4113 }
4114
4115 EAPI void
4116 elm_win_available_profiles_set(Evas_Object  *obj,
4117                                const char  **profiles,
4118                                unsigned int  count)
4119 {
4120    ELM_WIN_CHECK(obj);
4121    eo_do((Eo *) obj, elm_obj_win_available_profiles_set(profiles, count));
4122 }
4123
4124 static void
4125 _available_profiles_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4126 {
4127    const char **profiles = va_arg(*list, const char **);
4128    unsigned int count = va_arg(*list, unsigned int);
4129    Elm_Win_Smart_Data *sd = _pd;
4130    Eina_Bool found = EINA_FALSE;
4131
4132    _elm_win_available_profiles_del(sd);
4133    if ((profiles) && (count >= 1))
4134      {
4135         sd->profile.available_list = calloc(count, sizeof(char *));
4136         if (sd->profile.available_list)
4137           {
4138              if (!sd->profile.name) found = EINA_TRUE;
4139
4140              unsigned int i;
4141              for (i = 0; i < count; i++)
4142                {
4143                   sd->profile.available_list[i] = eina_stringshare_add(profiles[i]);
4144
4145                   /* check to see if a given array has a current profile of elm_win */
4146                   if ((sd->profile.name) &&
4147                       (!strcmp(sd->profile.name, profiles[i])))
4148                     {
4149                        found = EINA_TRUE;
4150                     }
4151                }
4152              sd->profile.count = count;
4153           }
4154      }
4155
4156    if (ecore_evas_window_profile_supported_get(sd->ee))
4157      {
4158         ecore_evas_window_available_profiles_set(sd->ee,
4159                                                  sd->profile.available_list,
4160                                                  sd->profile.count);
4161
4162         /* current profile of elm_win is wrong, change profile */
4163         if ((sd->profile.available_list) && (!found))
4164           {
4165              eina_stringshare_replace(&(sd->profile.name),
4166                                       sd->profile.available_list[0]);
4167              ecore_evas_window_profile_set(sd->ee, sd->profile.name);
4168           }
4169
4170      }
4171    else
4172      {
4173         if (sd->profile.available_list)
4174           _elm_win_profile_update(sd);
4175      }
4176 }
4177
4178 EAPI Eina_Bool
4179 elm_win_available_profiles_get(Evas_Object   *obj,
4180                                char        ***profiles,
4181                                unsigned int  *count)
4182 {
4183    ELM_WIN_CHECK(obj) EINA_FALSE;
4184    Eina_Bool ret = EINA_FALSE;
4185    eo_do((Eo *) obj, elm_obj_win_available_profiles_get(profiles, count, &ret));
4186    return ret;
4187 }
4188
4189 static void
4190 _available_profiles_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4191 {
4192    char ***profiles = va_arg(*list, char ***);
4193    unsigned int *count = va_arg(*list, unsigned int *);
4194    Eina_Bool *ret = va_arg(*list, Eina_Bool *);
4195    Elm_Win_Smart_Data *sd = _pd;
4196    Eina_Bool res;
4197
4198    if (ecore_evas_window_profile_supported_get(sd->ee))
4199      {
4200         res = ecore_evas_window_available_profiles_get(sd->ee,
4201                                                        profiles,
4202                                                        count);
4203      }
4204    else
4205      {
4206         if (profiles) *profiles = (char **)sd->profile.available_list;
4207         if (count) *count = sd->profile.count;
4208         res = EINA_TRUE;
4209      }
4210    if (ret) *ret = res;
4211 }
4212
4213 EAPI void
4214 elm_win_profile_set(Evas_Object *obj,
4215                     const char *profile)
4216 {
4217    ELM_WIN_CHECK(obj);
4218    eo_do((Eo *) obj, elm_obj_win_profile_set(profile));
4219 }
4220
4221 static void
4222 _profile_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4223 {
4224    const char *profile = va_arg(*list, const char *);
4225    Elm_Win_Smart_Data *sd = _pd;
4226
4227    /* check to see if a given profile is present in an available profiles */
4228    if ((profile) && (sd->profile.available_list))
4229      {
4230         Eina_Bool found = EINA_FALSE;
4231         unsigned int i;
4232         for (i = 0; i < sd->profile.count; i++)
4233           {
4234              if (!strcmp(profile,
4235                          sd->profile.available_list[i]))
4236                {
4237                   found = EINA_TRUE;
4238                   break;
4239                }
4240           }
4241         if (!found) return;
4242      }
4243
4244    if (ecore_evas_window_profile_supported_get(sd->ee))
4245      {
4246         if (!profile) _elm_win_profile_del(sd);
4247         ecore_evas_window_profile_set(sd->ee, profile);
4248      }
4249    else
4250      {
4251         if (_elm_win_profile_set(sd, profile))
4252           _elm_win_profile_update(sd);
4253      }
4254 }
4255
4256 EAPI const char *
4257 elm_win_profile_get(const Evas_Object *obj)
4258 {
4259    ELM_WIN_CHECK(obj) NULL;
4260    const char *ret = NULL;
4261    eo_do((Eo *) obj, elm_obj_win_profile_get(&ret));
4262    return ret;
4263 }
4264
4265 static void
4266 _profile_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4267 {
4268    const char **ret = va_arg(*list, const char **);
4269    Elm_Win_Smart_Data *sd = _pd;
4270    *ret = sd->profile.name;
4271 }
4272
4273 EAPI void
4274 elm_win_urgent_set(Evas_Object *obj,
4275                    Eina_Bool urgent)
4276 {
4277    ELM_WIN_CHECK(obj);
4278    eo_do(obj, elm_obj_win_urgent_set(urgent));
4279 }
4280
4281 static void
4282 _urgent_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4283 {
4284    Eina_Bool urgent = va_arg(*list, int);
4285    Elm_Win_Smart_Data *sd = _pd;
4286
4287    sd->urgent = urgent;
4288    TRAP(sd, urgent_set, urgent);
4289 #ifdef HAVE_ELEMENTARY_X
4290    _elm_win_xwin_update(sd);
4291 #endif
4292 }
4293
4294 EAPI Eina_Bool
4295 elm_win_urgent_get(const Evas_Object *obj)
4296 {
4297    ELM_WIN_CHECK(obj) EINA_FALSE;
4298    Eina_Bool ret = EINA_FALSE;
4299    eo_do((Eo *) obj, elm_obj_win_urgent_get(&ret));
4300    return ret;
4301 }
4302
4303 static void
4304 _urgent_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4305 {
4306    Eina_Bool *ret = va_arg(*list, Eina_Bool *);
4307    Elm_Win_Smart_Data *sd = _pd;
4308    *ret = sd->urgent;
4309 }
4310
4311 EAPI void
4312 elm_win_demand_attention_set(Evas_Object *obj,
4313                              Eina_Bool demand_attention)
4314 {
4315    ELM_WIN_CHECK(obj);
4316    eo_do(obj, elm_obj_win_demand_attention_set(demand_attention));
4317 }
4318
4319 static void
4320 _demand_attention_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4321 {
4322    Eina_Bool demand_attention = va_arg(*list, int);
4323    Elm_Win_Smart_Data *sd = _pd;
4324
4325    sd->demand_attention = demand_attention;
4326    TRAP(sd, demand_attention_set, demand_attention);
4327 #ifdef HAVE_ELEMENTARY_X
4328    _elm_win_xwin_update(sd);
4329 #endif
4330 }
4331
4332 EAPI Eina_Bool
4333 elm_win_demand_attention_get(const Evas_Object *obj)
4334 {
4335    ELM_WIN_CHECK(obj) EINA_FALSE;
4336    Eina_Bool ret = EINA_FALSE;
4337    eo_do((Eo *) obj, elm_obj_win_demand_attention_get(&ret));
4338    return ret;
4339 }
4340
4341 static void
4342 _demand_attention_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4343 {
4344    Eina_Bool *ret = va_arg(*list, Eina_Bool *);
4345    Elm_Win_Smart_Data *sd = _pd;
4346    *ret = sd->demand_attention;
4347 }
4348
4349 EAPI void
4350 elm_win_modal_set(Evas_Object *obj,
4351                   Eina_Bool modal)
4352 {
4353    ELM_WIN_CHECK(obj);
4354    eo_do(obj, elm_obj_win_modal_set(modal));
4355 }
4356
4357 static void
4358 _modal_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4359 {
4360    Eina_Bool modal = va_arg(*list, int);
4361    Elm_Win_Smart_Data *sd = _pd;
4362
4363    sd->modal = modal;
4364    TRAP(sd, modal_set, modal);
4365 #ifdef HAVE_ELEMENTARY_X
4366    _elm_win_xwin_update(sd);
4367 #endif
4368 }
4369
4370 EAPI Eina_Bool
4371 elm_win_modal_get(const Evas_Object *obj)
4372 {
4373    ELM_WIN_CHECK(obj) EINA_FALSE;
4374    Eina_Bool ret = EINA_FALSE;
4375    eo_do((Eo *) obj, elm_obj_win_modal_get(&ret));
4376    return ret;
4377 }
4378
4379 static void
4380 _modal_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4381 {
4382    Eina_Bool *ret = va_arg(*list, Eina_Bool *);
4383    Elm_Win_Smart_Data *sd = _pd;
4384    *ret = sd->modal;
4385 }
4386
4387 EAPI void
4388 elm_win_aspect_set(Evas_Object *obj,
4389                    double aspect)
4390 {
4391    ELM_WIN_CHECK(obj);
4392    eo_do(obj, elm_obj_win_aspect_set(aspect));
4393 }
4394
4395 static void
4396 _aspect_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4397 {
4398    double aspect = va_arg(*list, double);
4399    Elm_Win_Smart_Data *sd = _pd;
4400
4401    sd->aspect = aspect;
4402    TRAP(sd, aspect_set, aspect);
4403 #ifdef HAVE_ELEMENTARY_X
4404    _elm_win_xwin_update(sd);
4405 #endif
4406 }
4407
4408 EAPI double
4409 elm_win_aspect_get(const Evas_Object *obj)
4410 {
4411    ELM_WIN_CHECK(obj) 0.0;
4412    double ret = 0.0;
4413    eo_do((Eo *) obj, elm_obj_win_aspect_get(&ret));
4414    return ret;
4415 }
4416
4417 static void
4418 _aspect_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4419 {
4420    double *ret = va_arg(*list, double *);
4421    Elm_Win_Smart_Data *sd = _pd;
4422    *ret = sd->aspect;
4423 }
4424
4425 EAPI void
4426 elm_win_size_base_set(Evas_Object *obj, int w, int h)
4427 {
4428    ELM_WIN_CHECK(obj);
4429    eo_do(obj, elm_obj_win_size_base_set(w, h));
4430 }
4431
4432 static void
4433 _size_base_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4434 {
4435    int w = va_arg(*list, int);
4436    int h = va_arg(*list, int);
4437    Elm_Win_Smart_Data *sd = _pd;
4438    sd->size_base_w = w;
4439    sd->size_base_h = h;
4440    TRAP(sd, size_base_set, w, h);
4441 #ifdef HAVE_ELEMENTARY_X
4442    _elm_win_xwin_update(sd);
4443 #endif
4444 }
4445
4446 EAPI void
4447 elm_win_size_base_get(Evas_Object *obj, int *w, int *h)
4448 {
4449    ELM_WIN_CHECK(obj);
4450    eo_do(obj, elm_obj_win_size_base_get(w, h));
4451 }
4452
4453 static void
4454 _size_base_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4455 {
4456    int *w = va_arg(*list, int *);
4457    int *h = va_arg(*list, int *);
4458
4459    Elm_Win_Smart_Data *sd = _pd;
4460    if (w) *w = sd->size_base_w;
4461    if (w) *h = sd->size_base_h;
4462 }
4463
4464 EAPI void
4465 elm_win_size_step_set(Evas_Object *obj, int w, int h)
4466 {
4467    ELM_WIN_CHECK(obj);
4468    eo_do(obj, elm_obj_win_size_step_set(w, h));
4469 }
4470
4471 static void
4472 _size_step_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4473 {
4474    int w = va_arg(*list, int);
4475    int h = va_arg(*list, int);
4476    Elm_Win_Smart_Data *sd = _pd;
4477    sd->size_step_w = w;
4478    sd->size_step_h = h;
4479    TRAP(sd, size_step_set, w, h);
4480 #ifdef HAVE_ELEMENTARY_X
4481    _elm_win_xwin_update(sd);
4482 #endif
4483 }
4484
4485 EAPI void
4486 elm_win_size_step_get(Evas_Object *obj, int *w, int *h)
4487 {
4488    ELM_WIN_CHECK(obj);
4489    eo_do(obj, elm_obj_win_size_step_get(w, h));
4490 }
4491
4492 static void
4493 _size_step_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4494 {
4495    int *w = va_arg(*list, int *);
4496    int *h = va_arg(*list, int *);
4497    Elm_Win_Smart_Data *sd = _pd;
4498    if (w) *w = sd->size_step_w;
4499    if (w) *h = sd->size_step_h;
4500 }
4501
4502 EAPI void
4503 elm_win_layer_set(Evas_Object *obj,
4504                   int layer)
4505 {
4506    ELM_WIN_CHECK(obj);
4507    eo_do(obj, elm_obj_win_layer_set(layer));
4508 }
4509
4510 static void
4511 _layer_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4512 {
4513    int layer = va_arg(*list, int);
4514    Elm_Win_Smart_Data *sd = _pd;
4515
4516    TRAP(sd, layer_set, layer);
4517 #ifdef HAVE_ELEMENTARY_X
4518    _elm_win_xwin_update(sd);
4519 #endif
4520 }
4521
4522 EAPI int
4523 elm_win_layer_get(const Evas_Object *obj)
4524 {
4525    ELM_WIN_CHECK(obj) - 1;
4526    int ret = - 1;
4527    eo_do((Eo *) obj, elm_obj_win_layer_get(&ret));
4528    return ret;
4529 }
4530
4531 static void
4532 _layer_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4533 {
4534    int *ret = va_arg(*list, int *);
4535    Elm_Win_Smart_Data *sd = _pd;
4536    *ret = ecore_evas_layer_get(sd->ee);
4537 }
4538
4539 EAPI void
4540 elm_win_norender_push(Evas_Object *obj)
4541 {
4542    ELM_WIN_CHECK(obj);
4543    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4544
4545    sd->norender++;
4546    if (sd->norender == 1) ecore_evas_manual_render_set(sd->ee, EINA_TRUE);
4547 }
4548
4549 EAPI void
4550 elm_win_norender_pop(Evas_Object *obj)
4551 {
4552    ELM_WIN_CHECK(obj);
4553    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4554
4555    if (sd->norender <= 0) return;
4556    sd->norender--;
4557    if (sd->norender == 0) ecore_evas_manual_render_set(sd->ee, EINA_FALSE);
4558 }
4559
4560 EAPI int
4561 elm_win_norender_get(Evas_Object *obj)
4562 {
4563    ELM_WIN_CHECK(obj) - 1;
4564    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, -1);
4565    return sd->norender;
4566 }
4567
4568 EAPI void
4569 elm_win_render(Evas_Object *obj)
4570 {
4571    ELM_WIN_CHECK(obj);
4572    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4573    ecore_evas_manual_render(sd->ee);
4574 }
4575
4576 static int
4577 _win_rotation_degree_check(int rotation)
4578 {
4579    if ((rotation > 360) || (rotation < 0))
4580      {
4581         WRN("Rotation degree should be 0 ~ 360 (passed degree: %d)", rotation);
4582         rotation %= 360;
4583         if (rotation < 0) rotation += 360;
4584      }
4585    return rotation;
4586 }
4587
4588 /*
4589  * This API resizes the internal window(ex: X window) and evas_output.
4590  * But this does not resize the elm window object and its contents.
4591  */
4592 EAPI void
4593 elm_win_rotation_set(Evas_Object *obj,
4594                      int rotation)
4595 {
4596    ELM_WIN_CHECK(obj);
4597    eo_do(obj, elm_obj_win_rotation_set(rotation));
4598 }
4599
4600 static void
4601 _win_rotate(Evas_Object *obj, Elm_Win_Smart_Data *sd, int rotation, Eina_Bool resize)
4602 {
4603    rotation = _win_rotation_degree_check(rotation);
4604    if (sd->rot == rotation) return;
4605    sd->rot = rotation;
4606    if (resize) TRAP(sd, rotation_with_resize_set, rotation);
4607    else TRAP(sd, rotation_set, rotation);
4608    evas_object_size_hint_min_set(obj, -1, -1);
4609    evas_object_size_hint_max_set(obj, -1, -1);
4610    _elm_win_resize_objects_eval(obj);
4611 #ifdef HAVE_ELEMENTARY_X
4612    _elm_win_xwin_update(sd);
4613 #endif
4614    _elm_win_frame_obj_update(sd);
4615    elm_widget_orientation_set(obj, rotation);
4616    evas_object_smart_callback_call(obj, SIG_ROTATION_CHANGED, NULL);
4617 }
4618
4619 static void
4620 _rotation_set(Eo *obj, void *_pd, va_list *list)
4621 {
4622    int rotation = va_arg(*list, int);
4623    Elm_Win_Smart_Data *sd = _pd;
4624    _win_rotate(obj, sd, rotation, EINA_FALSE);
4625 }
4626
4627 /*
4628  * This API does not resize the internal window (ex: X window).
4629  * But this resizes evas_output, elm window, and its contents.
4630  */
4631 EAPI void
4632 elm_win_rotation_with_resize_set(Evas_Object *obj,
4633                                  int rotation)
4634 {
4635    ELM_WIN_CHECK(obj);
4636    eo_do(obj, elm_obj_win_rotation_with_resize_set(rotation));
4637 }
4638
4639 static void
4640 _rotation_with_resize_set(Eo *obj, void *_pd, va_list *list)
4641 {
4642    int rotation = va_arg(*list, int);
4643    Elm_Win_Smart_Data *sd = _pd;
4644    _win_rotate(obj, sd, rotation, EINA_TRUE);
4645 }
4646
4647 EAPI int
4648 elm_win_rotation_get(const Evas_Object *obj)
4649 {
4650    ELM_WIN_CHECK(obj) - 1;
4651    int ret = - 1;
4652    eo_do((Eo *) obj, elm_obj_win_rotation_get(&ret));
4653    return ret;
4654 }
4655
4656 static void
4657 _rotation_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4658 {
4659    int *ret = va_arg(*list, int *);
4660    Elm_Win_Smart_Data *sd = _pd;
4661    *ret = sd->rot;
4662 }
4663
4664 EAPI Eina_Bool
4665 elm_win_wm_rotation_supported_get(const Evas_Object *obj)
4666 {
4667    ELM_WIN_CHECK(obj) EINA_FALSE;
4668    Eina_Bool ret = EINA_FALSE;
4669    eo_do((Eo *) obj, elm_obj_win_wm_rotation_supported_get(&ret));
4670    return ret;
4671 }
4672
4673 static void
4674 _wm_rotation_supported_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4675 {
4676    Eina_Bool *ret = va_arg(*list, Eina_Bool *);
4677    Elm_Win_Smart_Data *sd = _pd;
4678    *ret = sd->wm_rot.wm_supported;
4679 }
4680
4681 /* This will unset a preferred rotation, if given preferred rotation is '-1'.
4682  */
4683 EAPI void
4684 elm_win_wm_rotation_preferred_rotation_set(const Evas_Object *obj,
4685                                            int rotation)
4686 {
4687    ELM_WIN_CHECK(obj);
4688    eo_do((Eo *) obj, elm_obj_win_wm_preferred_rotation_set(rotation));
4689 }
4690
4691 static void
4692 _wm_preferred_rotation_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4693 {
4694    int rotation = va_arg(*list, int);
4695    int rot;
4696    Elm_Win_Smart_Data *sd = _pd;
4697
4698    if (!sd->wm_rot.use)
4699      sd->wm_rot.use = EINA_TRUE;
4700
4701    // '-1' means that elm_win doesn't use preferred rotation.
4702    if (rotation == -1)
4703      rot = -1;
4704    else
4705      rot = _win_rotation_degree_check(rotation);
4706
4707    if (sd->wm_rot.preferred_rot == rot) return;
4708    sd->wm_rot.preferred_rot = rot;
4709
4710    ecore_evas_wm_rotation_preferred_rotation_set(sd->ee, rot);
4711 }
4712
4713 EAPI int
4714 elm_win_wm_rotation_preferred_rotation_get(const Evas_Object *obj)
4715 {
4716    ELM_WIN_CHECK(obj) -1;
4717    int ret = -1;
4718    eo_do((Eo *) obj, elm_obj_win_wm_preferred_rotation_get(&ret));
4719    return ret;
4720 }
4721
4722 static void
4723 _wm_preferred_rotation_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4724 {
4725    int *ret = va_arg(*list, int *);
4726    Elm_Win_Smart_Data *sd = _pd;
4727    *ret = sd->wm_rot.preferred_rot;
4728 }
4729
4730 EAPI void
4731 elm_win_wm_rotation_available_rotations_set(Evas_Object *obj,
4732                                             const int   *rotations,
4733                                             unsigned int count)
4734 {
4735    ELM_WIN_CHECK(obj);
4736    eo_do((Eo *) obj, elm_obj_win_wm_available_rotations_set(rotations, count));
4737 }
4738
4739 static void
4740 _wm_available_rotations_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4741 {
4742    const int *rotations = va_arg(*list, const int *);
4743    unsigned int count = va_arg(*list, unsigned int);
4744    Elm_Win_Smart_Data *sd = _pd;
4745    unsigned int i;
4746    int r;
4747
4748    if (!sd->wm_rot.use)
4749      sd->wm_rot.use = EINA_TRUE;
4750
4751    ELM_SAFE_FREE(sd->wm_rot.rots, free);
4752    sd->wm_rot.count = 0;
4753
4754    if (count > 0)
4755      {
4756         sd->wm_rot.rots = calloc(count, sizeof(int));
4757         if (!sd->wm_rot.rots) return;
4758         for (i = 0; i < count; i++)
4759           {
4760              r = _win_rotation_degree_check(rotations[i]);
4761              sd->wm_rot.rots[i] = r;
4762           }
4763      }
4764
4765    sd->wm_rot.count = count;
4766
4767    ecore_evas_wm_rotation_available_rotations_set(sd->ee,
4768                                                   sd->wm_rot.rots,
4769                                                   sd->wm_rot.count);
4770 }
4771
4772 EAPI Eina_Bool
4773 elm_win_wm_rotation_available_rotations_get(const Evas_Object *obj,
4774                                             int              **rotations,
4775                                             unsigned int      *count)
4776 {
4777    ELM_WIN_CHECK(obj) EINA_FALSE;
4778    Eina_Bool ret = EINA_FALSE;
4779    eo_do((Eo *) obj, elm_obj_win_wm_available_rotations_get(rotations, count, &ret));
4780    return ret;
4781 }
4782
4783 static void
4784 _wm_available_rotations_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4785 {
4786    int **rotations = va_arg(*list, int **);
4787    unsigned int *count = va_arg(*list, unsigned int *);
4788    Eina_Bool *ret = va_arg(*list, Eina_Bool *);
4789    Elm_Win_Smart_Data *sd = _pd;
4790    *ret = EINA_FALSE;
4791    if (!sd->wm_rot.use) return;
4792
4793    if (sd->wm_rot.count > 0)
4794      {
4795         if (rotations)
4796           {
4797              *rotations = calloc(sd->wm_rot.count, sizeof(int));
4798              if (*rotations)
4799                {
4800                   memcpy(*rotations,
4801                          sd->wm_rot.rots,
4802                          sizeof(int) * sd->wm_rot.count);
4803                }
4804           }
4805      }
4806
4807    if (count) *count = sd->wm_rot.count;
4808    *ret = EINA_TRUE;
4809 }
4810
4811 EAPI void
4812 elm_win_wm_rotation_manual_rotation_done_set(Evas_Object *obj,
4813                                              Eina_Bool    set)
4814 {
4815    ELM_WIN_CHECK(obj);
4816    eo_do((Eo *) obj, elm_obj_win_wm_manual_rotation_done_set(set));
4817 }
4818
4819 static void
4820 _wm_manual_rotation_done_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4821 {
4822    int set = va_arg(*list, int);
4823    Elm_Win_Smart_Data *sd = _pd;
4824    if (!sd->wm_rot.use) return;
4825    ecore_evas_wm_rotation_manual_rotation_done_set(sd->ee, set);
4826 }
4827
4828 EAPI Eina_Bool
4829 elm_win_wm_rotation_manual_rotation_done_get(const Evas_Object *obj)
4830 {
4831    ELM_WIN_CHECK(obj) EINA_FALSE;
4832    Eina_Bool ret = EINA_FALSE;
4833    eo_do((Eo *) obj, elm_obj_win_wm_manual_rotation_done_get(&ret));
4834    return ret;
4835 }
4836
4837 static void
4838 _wm_manual_rotation_done_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4839 {
4840    Eina_Bool *ret = va_arg(*list, Eina_Bool *);
4841    Elm_Win_Smart_Data *sd = _pd;
4842    if (!sd->wm_rot.use) return;
4843    *ret = ecore_evas_wm_rotation_manual_rotation_done_get(sd->ee);
4844 }
4845
4846 EAPI void
4847 elm_win_wm_rotation_manual_rotation_done(Evas_Object *obj)
4848 {
4849    ELM_WIN_CHECK(obj);
4850    eo_do((Eo *) obj, elm_obj_win_wm_manual_rotation_done());
4851 }
4852
4853 static void
4854 _wm_manual_rotation_done(Eo *obj EINA_UNUSED, void *_pd, va_list *list EINA_UNUSED)
4855 {
4856    Elm_Win_Smart_Data *sd = _pd;
4857    if (!sd->wm_rot.use) return;
4858    ecore_evas_wm_rotation_manual_rotation_done(sd->ee);
4859 }
4860
4861 EAPI void
4862 elm_win_sticky_set(Evas_Object *obj,
4863                    Eina_Bool sticky)
4864 {
4865    ELM_WIN_CHECK(obj);
4866    eo_do(obj, elm_obj_win_sticky_set(sticky));
4867 }
4868
4869 static void
4870 _sticky_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4871 {
4872    Eina_Bool sticky = va_arg(*list, int);
4873    Elm_Win_Smart_Data *sd = _pd;
4874
4875 //   sd->sticky = sticky;
4876    TRAP(sd, sticky_set, sticky);
4877 #ifdef HAVE_ELEMENTARY_X
4878    _elm_win_xwin_update(sd);
4879 #endif
4880 }
4881
4882 EAPI Eina_Bool
4883 elm_win_sticky_get(const Evas_Object *obj)
4884 {
4885    ELM_WIN_CHECK(obj) EINA_FALSE;
4886    Eina_Bool ret = EINA_FALSE;
4887    eo_do((Eo *) obj, elm_obj_win_sticky_get(&ret));
4888    return ret;
4889 }
4890
4891 static void
4892 _sticky_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4893 {
4894    Eina_Bool *ret = va_arg(*list, Eina_Bool *);
4895    Elm_Win_Smart_Data *sd = _pd;
4896    *ret = sd->sticky;
4897 }
4898
4899 EAPI void
4900 elm_win_keyboard_mode_set(Evas_Object *obj,
4901                           Elm_Win_Keyboard_Mode mode)
4902 {
4903    ELM_WIN_CHECK(obj);
4904    eo_do(obj, elm_obj_win_keyboard_mode_set(mode));
4905 }
4906
4907 static void
4908 _keyboard_mode_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4909 {
4910    Elm_Win_Keyboard_Mode mode = va_arg(*list, Elm_Win_Keyboard_Mode);
4911    Elm_Win_Smart_Data *sd = _pd;
4912
4913    if (mode == sd->kbdmode) return;
4914 #ifdef HAVE_ELEMENTARY_X
4915    _elm_win_xwindow_get(sd);
4916 #endif
4917    sd->kbdmode = mode;
4918 #ifdef HAVE_ELEMENTARY_X
4919    if (sd->x.xwin)
4920      ecore_x_e_virtual_keyboard_state_set
4921        (sd->x.xwin, (Ecore_X_Virtual_Keyboard_State)sd->kbdmode);
4922 #endif
4923 }
4924
4925 EAPI Elm_Win_Keyboard_Mode
4926 elm_win_keyboard_mode_get(const Evas_Object *obj)
4927 {
4928    ELM_WIN_CHECK(obj) ELM_WIN_KEYBOARD_UNKNOWN;
4929    Elm_Win_Keyboard_Mode ret = ELM_WIN_KEYBOARD_UNKNOWN;
4930    eo_do((Eo *) obj, elm_obj_win_keyboard_mode_get(&ret));
4931    return ret;
4932 }
4933
4934 static void
4935 _keyboard_mode_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4936 {
4937    Elm_Win_Keyboard_Mode *ret = va_arg(*list, Elm_Win_Keyboard_Mode *);
4938    Elm_Win_Smart_Data *sd = _pd;
4939    *ret = sd->kbdmode;
4940 }
4941
4942 EAPI void
4943 elm_win_keyboard_win_set(Evas_Object *obj,
4944                          Eina_Bool is_keyboard)
4945 {
4946    ELM_WIN_CHECK(obj);
4947    eo_do(obj, elm_obj_win_keyboard_win_set(is_keyboard));
4948 }
4949
4950 static void
4951 _keyboard_win_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4952 {
4953    Eina_Bool is_keyboard = va_arg(*list, int);
4954    Elm_Win_Smart_Data *sd = _pd;
4955
4956 #ifdef HAVE_ELEMENTARY_X
4957    _elm_win_xwindow_get(sd);
4958    if (sd->x.xwin)
4959      ecore_x_e_virtual_keyboard_set(sd->x.xwin, is_keyboard);
4960 #else
4961    (void)is_keyboard;
4962 #endif
4963 }
4964
4965 EAPI Eina_Bool
4966 elm_win_keyboard_win_get(const Evas_Object *obj)
4967 {
4968    ELM_WIN_CHECK(obj) EINA_FALSE;
4969    Eina_Bool ret = EINA_FALSE;
4970    eo_do((Eo *) obj, elm_obj_win_keyboard_win_get(&ret));
4971    return ret;
4972 }
4973
4974 static void
4975 _keyboard_win_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
4976 {
4977    Eina_Bool *ret = va_arg(*list, Eina_Bool *);
4978    Elm_Win_Smart_Data *sd = _pd;
4979
4980 #ifdef HAVE_ELEMENTARY_X
4981    _elm_win_xwindow_get(sd);
4982    if (sd->x.xwin)
4983      {
4984         *ret = ecore_x_e_virtual_keyboard_get(sd->x.xwin);
4985         return;
4986      }
4987 #endif
4988    *ret = EINA_FALSE;
4989 }
4990
4991 EAPI void
4992 elm_win_indicator_mode_set(Evas_Object *obj,
4993       Elm_Win_Indicator_Mode mode)
4994 {
4995    ELM_WIN_CHECK(obj);
4996    eo_do(obj, elm_obj_win_indicator_mode_set(mode));
4997 }
4998
4999 static void
5000 _indicator_mode_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
5001 {
5002    Elm_Win_Indicator_Mode mode = va_arg(*list, Elm_Win_Indicator_Mode);
5003    Elm_Win_Smart_Data *sd = _pd;
5004
5005    if (mode == sd->indmode) return;
5006 #ifdef HAVE_ELEMENTARY_X
5007    _elm_win_xwindow_get(sd);
5008 #endif
5009    sd->indmode = mode;
5010 #ifdef HAVE_ELEMENTARY_X
5011    if (sd->x.xwin)
5012      {
5013         if (sd->indmode == ELM_WIN_INDICATOR_SHOW)
5014           ecore_x_e_illume_indicator_state_set
5015             (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_STATE_ON);
5016         else if (sd->indmode == ELM_WIN_INDICATOR_HIDE)
5017           ecore_x_e_illume_indicator_state_set
5018             (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_STATE_OFF);
5019      }
5020 #endif
5021    evas_object_smart_callback_call(obj, SIG_INDICATOR_PROP_CHANGED, NULL);
5022 }
5023
5024 EAPI Elm_Win_Indicator_Mode
5025 elm_win_indicator_mode_get(const Evas_Object *obj)
5026 {
5027    ELM_WIN_CHECK(obj) ELM_WIN_INDICATOR_UNKNOWN;
5028    Elm_Win_Indicator_Mode ret = ELM_WIN_INDICATOR_UNKNOWN;
5029    eo_do((Eo *) obj, elm_obj_win_indicator_mode_get(&ret));
5030    return ret;
5031 }
5032
5033 static void
5034 _indicator_mode_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
5035 {
5036    Elm_Win_Indicator_Mode *ret = va_arg(*list, Elm_Win_Indicator_Mode *);
5037    Elm_Win_Smart_Data *sd = _pd;
5038    *ret = sd->indmode;
5039 }
5040
5041 EAPI void
5042 elm_win_indicator_opacity_set(Evas_Object *obj,
5043                               Elm_Win_Indicator_Opacity_Mode mode)
5044 {
5045    ELM_WIN_CHECK(obj);
5046    eo_do(obj, elm_obj_win_indicator_opacity_set(mode));
5047 }
5048
5049 static void
5050 _indicator_opacity_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
5051 {
5052    Elm_Win_Indicator_Opacity_Mode mode = va_arg(*list, Elm_Win_Indicator_Opacity_Mode);
5053    Elm_Win_Smart_Data *sd = _pd;
5054
5055    if (mode == sd->ind_o_mode) return;
5056    sd->ind_o_mode = mode;
5057 #ifdef HAVE_ELEMENTARY_X
5058    _elm_win_xwindow_get(sd);
5059    if (sd->x.xwin)
5060      {
5061         if (sd->ind_o_mode == ELM_WIN_INDICATOR_OPAQUE)
5062           ecore_x_e_illume_indicator_opacity_set
5063             (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_OPAQUE);
5064         else if (sd->ind_o_mode == ELM_WIN_INDICATOR_TRANSLUCENT)
5065           ecore_x_e_illume_indicator_opacity_set
5066             (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_TRANSLUCENT);
5067         else if (sd->ind_o_mode == ELM_WIN_INDICATOR_TRANSPARENT)
5068           ecore_x_e_illume_indicator_opacity_set
5069             (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_TRANSPARENT);
5070      }
5071 #endif
5072    evas_object_smart_callback_call(obj, SIG_INDICATOR_PROP_CHANGED, NULL);
5073 }
5074
5075 EAPI Elm_Win_Indicator_Opacity_Mode
5076 elm_win_indicator_opacity_get(const Evas_Object *obj)
5077 {
5078    ELM_WIN_CHECK(obj) ELM_WIN_INDICATOR_OPACITY_UNKNOWN;
5079    Elm_Win_Indicator_Opacity_Mode ret = ELM_WIN_INDICATOR_OPACITY_UNKNOWN;
5080    eo_do((Eo *) obj, elm_obj_win_indicator_opacity_get(&ret));
5081    return ret;
5082 }
5083
5084 static void
5085 _indicator_opacity_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
5086 {
5087    Elm_Win_Indicator_Opacity_Mode *ret = va_arg(*list, Elm_Win_Indicator_Opacity_Mode *);
5088    Elm_Win_Smart_Data *sd = _pd;
5089    *ret = sd->ind_o_mode;
5090 }
5091
5092 EAPI void
5093 elm_win_screen_position_get(const Evas_Object *obj,
5094                             int *x,
5095                             int *y)
5096 {
5097    ELM_WIN_CHECK(obj);
5098    eo_do((Eo *) obj, elm_obj_win_screen_position_get(x, y));
5099 }
5100
5101 static void
5102 _screen_position_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
5103 {
5104    int *x = va_arg(*list, int *);
5105    int *y = va_arg(*list, int *);
5106    Elm_Win_Smart_Data *sd = _pd;
5107
5108    if (x) *x = sd->screen.x;
5109    if (y) *y = sd->screen.y;
5110 }
5111
5112 EAPI Eina_Bool
5113 elm_win_focus_get(const Evas_Object *obj)
5114 {
5115    ELM_WIN_CHECK(obj) EINA_FALSE;
5116    Eina_Bool ret = EINA_FALSE;
5117    eo_do((Eo *) obj, elm_obj_win_focus_get(&ret));
5118    return ret;
5119 }
5120
5121 static void
5122 _focus_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
5123 {
5124    Eina_Bool *ret = va_arg(*list, Eina_Bool *);
5125    Elm_Win_Smart_Data *sd = _pd;
5126    *ret = ecore_evas_focus_get(sd->ee);
5127 }
5128
5129 EAPI void
5130 elm_win_screen_constrain_set(Evas_Object *obj,
5131                              Eina_Bool constrain)
5132 {
5133    ELM_WIN_CHECK(obj);
5134    eo_do(obj, elm_obj_win_screen_constrain_set(constrain));
5135 }
5136
5137 static void
5138 _screen_constrain_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
5139 {
5140    Eina_Bool constrain = va_arg(*list, int);
5141    Elm_Win_Smart_Data *sd = _pd;
5142    sd->constrain = !!constrain;
5143 }
5144
5145 EAPI Eina_Bool
5146 elm_win_screen_constrain_get(Evas_Object *obj)
5147 {
5148    ELM_WIN_CHECK(obj) EINA_FALSE;
5149    Eina_Bool ret = EINA_FALSE;
5150    eo_do(obj, elm_obj_win_screen_constrain_get(&ret));
5151    return ret;
5152 }
5153
5154 static void
5155 _screen_constrain_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
5156 {
5157    Eina_Bool *ret = va_arg(*list, Eina_Bool *);
5158    Elm_Win_Smart_Data *sd = _pd;
5159    *ret = sd->constrain;
5160 }
5161
5162 EAPI void
5163 elm_win_screen_size_get(const Evas_Object *obj,
5164                         int *x,
5165                         int *y,
5166                         int *w,
5167                         int *h)
5168 {
5169    ELM_WIN_CHECK(obj);
5170    eo_do((Eo *) obj, elm_obj_win_screen_size_get(x, y, w, h));
5171 }
5172
5173 static void
5174 _screen_size_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
5175 {
5176    int *x = va_arg(*list, int *);
5177    int *y = va_arg(*list, int *);
5178    int *w = va_arg(*list, int *);
5179    int *h = va_arg(*list, int *);
5180    Elm_Win_Smart_Data *sd = _pd;
5181
5182    ecore_evas_screen_geometry_get(sd->ee, x, y, w, h);
5183 }
5184
5185 EAPI void
5186 elm_win_screen_dpi_get(const Evas_Object *obj,
5187                        int *xdpi,
5188                        int *ydpi)
5189 {
5190    ELM_WIN_CHECK(obj);
5191    eo_do((Eo *) obj, elm_obj_win_screen_dpi_get(xdpi, ydpi));
5192 }
5193
5194 static void
5195 _screen_dpi_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
5196 {
5197    int *xdpi = va_arg(*list, int *);
5198    int *ydpi = va_arg(*list, int *);
5199    Elm_Win_Smart_Data *sd = _pd;
5200
5201    ecore_evas_screen_dpi_get(sd->ee, xdpi, ydpi);
5202 }
5203
5204 EAPI void
5205 elm_win_conformant_set(Evas_Object *obj,
5206                        Eina_Bool conformant)
5207 {
5208    ELM_WIN_CHECK(obj);
5209    eo_do(obj, elm_obj_win_conformant_set(conformant));
5210 }
5211
5212 static void
5213 _conformant_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
5214 {
5215    Eina_Bool conformant = va_arg(*list, int);
5216    Elm_Win_Smart_Data *sd = _pd;
5217
5218 #ifdef HAVE_ELEMENTARY_X
5219    _elm_win_xwindow_get(sd);
5220    if (sd->x.xwin)
5221      ecore_x_e_illume_conformant_set(sd->x.xwin, conformant);
5222 #else
5223    (void)conformant;
5224 #endif
5225 }
5226
5227 EAPI Eina_Bool
5228 elm_win_conformant_get(const Evas_Object *obj)
5229 {
5230    ELM_WIN_CHECK(obj) EINA_FALSE;
5231    Eina_Bool ret = EINA_FALSE;
5232    eo_do((Eo *) obj, elm_obj_win_conformant_get(&ret));
5233    return ret;
5234 }
5235
5236 static void
5237 _conformant_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
5238 {
5239    Eina_Bool *ret = va_arg(*list, Eina_Bool *);
5240    Elm_Win_Smart_Data *sd = _pd;
5241    *ret = EINA_FALSE;
5242
5243 #ifdef HAVE_ELEMENTARY_X
5244    _elm_win_xwindow_get(sd);
5245    if (sd->x.xwin)
5246      *ret = ecore_x_e_illume_conformant_get(sd->x.xwin);
5247 #endif
5248 }
5249
5250 EAPI void
5251 elm_win_quickpanel_set(Evas_Object *obj,
5252                        Eina_Bool quickpanel)
5253 {
5254    ELM_WIN_CHECK(obj);
5255    eo_do(obj, elm_obj_win_quickpanel_set(quickpanel));
5256 }
5257
5258 static void
5259 _quickpanel_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
5260 {
5261    Eina_Bool quickpanel = va_arg(*list, int);
5262    Elm_Win_Smart_Data *sd = _pd;
5263 #ifdef HAVE_ELEMENTARY_X
5264    _elm_win_xwindow_get(sd);
5265    if (sd->x.xwin)
5266      {
5267         ecore_x_e_illume_quickpanel_set(sd->x.xwin, quickpanel);
5268         if (quickpanel)
5269           {
5270              Ecore_X_Window_State states[2];
5271
5272              states[0] = ECORE_X_WINDOW_STATE_SKIP_TASKBAR;
5273              states[1] = ECORE_X_WINDOW_STATE_SKIP_PAGER;
5274              ecore_x_netwm_window_state_set(sd->x.xwin, states, 2);
5275              ecore_x_icccm_hints_set(sd->x.xwin, 0, 0, 0, 0, 0, 0, 0);
5276           }
5277      }
5278 #else
5279    (void)quickpanel;
5280 #endif
5281 }
5282
5283 EAPI Eina_Bool
5284 elm_win_quickpanel_get(const Evas_Object *obj)
5285 {
5286    ELM_WIN_CHECK(obj) EINA_FALSE;
5287    Eina_Bool ret = EINA_FALSE;
5288    eo_do((Eo *) obj, elm_obj_win_quickpanel_get(&ret));
5289    return ret;
5290 }
5291
5292 static void
5293 _quickpanel_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
5294 {
5295    Eina_Bool *ret = va_arg(*list, Eina_Bool *);
5296    Elm_Win_Smart_Data *sd = _pd;
5297    *ret = EINA_FALSE;
5298
5299 #ifdef HAVE_ELEMENTARY_X
5300    _elm_win_xwindow_get(sd);
5301    if (sd->x.xwin)
5302      *ret = ecore_x_e_illume_quickpanel_get(sd->x.xwin);
5303 #endif
5304 }
5305
5306 EAPI void
5307 elm_win_quickpanel_priority_major_set(Evas_Object *obj,
5308                                       int priority)
5309 {
5310    ELM_WIN_CHECK(obj);
5311    eo_do(obj, elm_obj_win_quickpanel_priority_major_set(priority));
5312 }
5313
5314 static void
5315 _quickpanel_priority_major_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
5316 {
5317    int priority = va_arg(*list, int);
5318    Elm_Win_Smart_Data *sd = _pd;
5319
5320 #ifdef HAVE_ELEMENTARY_X
5321    _elm_win_xwindow_get(sd);
5322    if (sd->x.xwin)
5323      ecore_x_e_illume_quickpanel_priority_major_set(sd->x.xwin, priority);
5324 #else
5325    (void)priority;
5326 #endif
5327 }
5328
5329 EAPI int
5330 elm_win_quickpanel_priority_major_get(const Evas_Object *obj)
5331 {
5332    ELM_WIN_CHECK(obj) - 1;
5333    int ret = - 1;
5334    eo_do((Eo *) obj, elm_obj_win_quickpanel_priority_major_get(&ret));
5335    return ret;
5336 }
5337
5338 static void
5339 _quickpanel_priority_major_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
5340 {
5341    int *ret = va_arg(*list, int *);
5342    Elm_Win_Smart_Data *sd = _pd;
5343    *ret = -1;
5344
5345 #ifdef HAVE_ELEMENTARY_X
5346    _elm_win_xwindow_get(sd);
5347    if (sd->x.xwin)
5348      *ret = ecore_x_e_illume_quickpanel_priority_major_get(sd->x.xwin);
5349 #endif
5350 }
5351
5352 EAPI void
5353 elm_win_quickpanel_priority_minor_set(Evas_Object *obj,
5354                                       int priority)
5355 {
5356    ELM_WIN_CHECK(obj);
5357    eo_do(obj, elm_obj_win_quickpanel_priority_minor_set(priority));
5358 }
5359
5360 static void
5361 _quickpanel_priority_minor_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
5362 {
5363    int priority = va_arg(*list, int);
5364    Elm_Win_Smart_Data *sd = _pd;
5365
5366 #ifdef HAVE_ELEMENTARY_X
5367    _elm_win_xwindow_get(sd);
5368    if (sd->x.xwin)
5369      ecore_x_e_illume_quickpanel_priority_minor_set(sd->x.xwin, priority);
5370 #else
5371    (void)priority;
5372 #endif
5373 }
5374
5375 EAPI int
5376 elm_win_quickpanel_priority_minor_get(const Evas_Object *obj)
5377 {
5378    ELM_WIN_CHECK(obj) - 1;
5379    int ret = - 1;
5380    eo_do((Eo *) obj, elm_obj_win_quickpanel_priority_minor_get(&ret));
5381    return ret;
5382 }
5383
5384 static void
5385 _quickpanel_priority_minor_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
5386 {
5387    int *ret = va_arg(*list, int *);
5388    Elm_Win_Smart_Data *sd = _pd;
5389    *ret = -1;
5390
5391 #ifdef HAVE_ELEMENTARY_X
5392    _elm_win_xwindow_get(sd);
5393    if (sd->x.xwin)
5394      *ret = ecore_x_e_illume_quickpanel_priority_minor_get(sd->x.xwin);
5395 #endif
5396 }
5397
5398 EAPI void
5399 elm_win_quickpanel_zone_set(Evas_Object *obj,
5400                             int zone)
5401 {
5402    ELM_WIN_CHECK(obj);
5403    eo_do(obj, elm_obj_win_quickpanel_zone_set(zone));
5404 }
5405
5406 static void
5407 _quickpanel_zone_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
5408 {
5409    int zone = va_arg(*list, int);
5410    Elm_Win_Smart_Data *sd = _pd;
5411
5412 #ifdef HAVE_ELEMENTARY_X
5413    _elm_win_xwindow_get(sd);
5414    if (sd->x.xwin)
5415      ecore_x_e_illume_quickpanel_zone_set(sd->x.xwin, zone);
5416 #else
5417    (void)zone;
5418 #endif
5419 }
5420
5421 EAPI int
5422 elm_win_quickpanel_zone_get(const Evas_Object *obj)
5423 {
5424    ELM_WIN_CHECK(obj) 0;
5425    int ret = 0;
5426    eo_do((Eo *) obj, elm_obj_win_quickpanel_zone_get(&ret));
5427    return ret;
5428 }
5429
5430 static void
5431 _quickpanel_zone_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
5432 {
5433    int *ret = va_arg(*list, int *);
5434    Elm_Win_Smart_Data *sd = _pd;
5435    *ret = 0;
5436
5437 #ifdef HAVE_ELEMENTARY_X
5438    _elm_win_xwindow_get(sd);
5439    if (sd->x.xwin)
5440      *ret = ecore_x_e_illume_quickpanel_zone_get(sd->x.xwin);
5441 #endif
5442 }
5443
5444 EAPI void
5445 elm_win_prop_focus_skip_set(Evas_Object *obj,
5446                             Eina_Bool skip)
5447 {
5448    ELM_WIN_CHECK(obj);
5449    eo_do(obj, elm_obj_win_prop_focus_skip_set(skip));
5450 }
5451
5452 static void
5453 _prop_focus_skip_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
5454 {
5455    Eina_Bool skip = va_arg(*list, int);
5456    Elm_Win_Smart_Data *sd = _pd;
5457
5458    sd->skip_focus = skip;
5459    TRAP(sd, focus_skip_set, skip);
5460 }
5461
5462 EAPI void
5463 elm_win_illume_command_send(Evas_Object *obj,
5464                             Elm_Illume_Command command,
5465                             void *params)
5466 {
5467    ELM_WIN_CHECK(obj);
5468    eo_do(obj, elm_obj_win_illume_command_send(command, params));
5469 }
5470
5471 static void
5472 _illume_command_send(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
5473 {
5474    Elm_Illume_Command command = va_arg(*list, Elm_Illume_Command);
5475    void *params = va_arg(*list, void *);
5476    (void) params;
5477    Elm_Win_Smart_Data *sd = _pd;
5478
5479 #ifdef HAVE_ELEMENTARY_X
5480    _elm_win_xwindow_get(sd);
5481    if (sd->x.xwin)
5482      {
5483         switch (command)
5484           {
5485            case ELM_ILLUME_COMMAND_FOCUS_BACK:
5486              ecore_x_e_illume_focus_back_send(sd->x.xwin);
5487              break;
5488
5489            case ELM_ILLUME_COMMAND_FOCUS_FORWARD:
5490              ecore_x_e_illume_focus_forward_send(sd->x.xwin);
5491              break;
5492
5493            case ELM_ILLUME_COMMAND_FOCUS_HOME:
5494              ecore_x_e_illume_focus_home_send(sd->x.xwin);
5495              break;
5496
5497            case ELM_ILLUME_COMMAND_CLOSE:
5498              ecore_x_e_illume_close_send(sd->x.xwin);
5499              break;
5500
5501            default:
5502              break;
5503           }
5504      }
5505 #else
5506    (void)command;
5507 #endif
5508 }
5509
5510 EAPI Evas_Object *
5511 elm_win_inlined_image_object_get(Evas_Object *obj)
5512 {
5513    ELM_WIN_CHECK(obj) NULL;
5514    Evas_Object *ret = NULL;
5515    eo_do(obj, elm_obj_win_inlined_image_object_get(&ret));
5516    return ret;
5517 }
5518
5519 static void
5520 _inlined_image_object_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
5521 {
5522    Evas_Object **ret = va_arg(*list, Evas_Object **);
5523    Elm_Win_Smart_Data *sd = _pd;
5524    *ret = sd->img_obj;
5525 }
5526
5527 EAPI void
5528 elm_win_focus_highlight_enabled_set(Evas_Object *obj,
5529                                     Eina_Bool enabled)
5530 {
5531    ELM_WIN_CHECK(obj);
5532    eo_do(obj, elm_obj_win_focus_highlight_enabled_set(enabled));
5533 }
5534
5535 static void
5536 _focus_highlight_enabled_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
5537 {
5538    Eina_Bool enabled = va_arg(*list, int);
5539    Elm_Win_Smart_Data *sd = _pd;
5540
5541    enabled = !!enabled;
5542    if (sd->focus_highlight.enabled == enabled)
5543      return;
5544
5545    sd->focus_highlight.enabled = enabled;
5546
5547    if (sd->focus_highlight.enabled)
5548      _elm_win_focus_highlight_init(sd);
5549    else
5550      _elm_win_focus_highlight_shutdown(sd);
5551 }
5552
5553 EAPI Eina_Bool
5554 elm_win_focus_highlight_enabled_get(const Evas_Object *obj)
5555 {
5556    ELM_WIN_CHECK(obj) EINA_FALSE;
5557    Eina_Bool ret = EINA_FALSE;
5558    eo_do((Eo *) obj, elm_obj_win_focus_highlight_enabled_get(&ret));
5559    return ret;
5560 }
5561
5562 static void
5563 _focus_highlight_enabled_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
5564 {
5565    Eina_Bool *ret = va_arg(*list, Eina_Bool *);
5566    Elm_Win_Smart_Data *sd = _pd;
5567    *ret = sd->focus_highlight.enabled;
5568 }
5569
5570 EAPI void
5571 elm_win_focus_highlight_style_set(Evas_Object *obj,
5572                                   const char *style)
5573 {
5574    ELM_WIN_CHECK(obj);
5575    eo_do(obj, elm_obj_win_focus_highlight_style_set(style));
5576 }
5577
5578 static void
5579 _elm_win_smart_theme(Eo *obj EINA_UNUSED, void *_pd, va_list *list EINA_UNUSED)
5580 {
5581    Elm_Win_Smart_Data *sd = _pd;
5582    Eina_Bool *ret = va_arg(*list, Eina_Bool *);
5583    Eina_Bool int_ret = EINA_FALSE;
5584
5585    if (ret) *ret = EINA_TRUE;
5586
5587    eo_do_super(obj, MY_CLASS, elm_obj_widget_theme_apply(&int_ret));
5588    if (!int_ret) return;
5589
5590    sd->focus_highlight.theme_changed = EINA_TRUE;
5591    _elm_win_focus_highlight_reconfigure_job_start(sd);
5592
5593    if (ret) *ret = EINA_TRUE;
5594 }
5595
5596 static void
5597 _focus_highlight_style_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
5598 {
5599    const char *style = va_arg(*list, const char *);
5600    Elm_Win_Smart_Data *sd = _pd;
5601
5602    eina_stringshare_replace(&sd->focus_highlight.style, style);
5603    sd->focus_highlight.theme_changed = EINA_TRUE;
5604    _elm_win_focus_highlight_reconfigure_job_start(sd);
5605 }
5606
5607 EAPI const char *
5608 elm_win_focus_highlight_style_get(const Evas_Object *obj)
5609 {
5610    ELM_WIN_CHECK(obj) NULL;
5611    const char *ret = NULL;
5612    eo_do((Eo *) obj, elm_obj_win_focus_highlight_style_get(&ret));
5613    return ret;
5614 }
5615
5616 static void
5617 _focus_highlight_style_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
5618 {
5619    const char **ret = va_arg(*list, const char **);
5620    Elm_Win_Smart_Data *sd = _pd;
5621    *ret = sd->focus_highlight.style;
5622 }
5623
5624 EAPI void
5625 elm_win_focus_highlight_animate_set(Evas_Object *obj,
5626                                     Eina_Bool animate)
5627 {
5628    ELM_WIN_CHECK(obj);
5629    eo_do(obj, elm_obj_win_focus_highlight_animate_set(animate));
5630 }
5631
5632 static void
5633 _focus_highlight_animate_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
5634 {
5635    Eina_Bool animate = va_arg(*list, int);
5636    Elm_Win_Smart_Data *sd = _pd;
5637
5638    animate = !!animate;
5639    if (sd->focus_highlight.animate == animate)
5640      return;
5641
5642    sd->focus_highlight.animate = animate;
5643    sd->focus_highlight.theme_changed = EINA_TRUE;
5644    _elm_win_focus_highlight_reconfigure_job_start(sd);
5645 }
5646
5647 EAPI Eina_Bool
5648 elm_win_focus_highlight_animate_get(const Evas_Object *obj)
5649 {
5650    ELM_WIN_CHECK(obj) EINA_FALSE;
5651    Eina_Bool ret = EINA_FALSE;
5652    eo_do((Eo *) obj, elm_obj_win_focus_highlight_animate_get(&ret));
5653    return ret;
5654 }
5655
5656 static void
5657 _focus_highlight_animate_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
5658 {
5659    Eina_Bool *ret = va_arg(*list, Eina_Bool *);
5660    Elm_Win_Smart_Data *sd = _pd;
5661    *ret = sd->focus_highlight.animate;
5662 }
5663
5664 EAPI Eina_Bool
5665 elm_win_socket_listen(Evas_Object *obj,
5666                       const char *svcname,
5667                       int svcnum,
5668                       Eina_Bool svcsys)
5669 {
5670    ELM_WIN_CHECK(obj) EINA_FALSE;
5671    Eina_Bool ret = EINA_FALSE;
5672    eo_do(obj, elm_obj_win_socket_listen(svcname, svcnum, svcsys, &ret));
5673    return ret;
5674 }
5675
5676 static void
5677 _socket_listen(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
5678 {
5679    const char *svcname = va_arg(*list, const char *);
5680    int svcnum = va_arg(*list, int);
5681    Eina_Bool svcsys = va_arg(*list, int);
5682    Eina_Bool *ret = va_arg(*list, Eina_Bool *);
5683    Elm_Win_Smart_Data *sd = _pd;
5684    *ret = EINA_FALSE;
5685
5686    if (!sd->ee) return;
5687
5688    if (!ecore_evas_extn_socket_listen(sd->ee, svcname, svcnum, svcsys))
5689      return;
5690
5691    *ret = EINA_TRUE;
5692 }
5693
5694 /* windowing specific calls - shall we do this differently? */
5695
5696 EAPI Ecore_X_Window
5697 elm_win_xwindow_get(const Evas_Object *obj)
5698 {
5699    if (!obj) return 0;
5700
5701    if (!evas_object_smart_type_check_ptr(obj, MY_CLASS_NAME_LEGACY))
5702      {
5703         Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
5704         return _elm_ee_xwin_get(ee);
5705      }
5706
5707    ELM_WIN_CHECK(obj) 0;
5708    Ecore_X_Window ret = 0;
5709    eo_do((Eo *) obj, elm_obj_win_xwindow_get(&ret));
5710    return ret;
5711 }
5712
5713 static void
5714 _xwindow_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
5715 {
5716    Ecore_X_Window *ret = va_arg(*list, Ecore_X_Window *);
5717    Elm_Win_Smart_Data *sd = _pd;
5718
5719 #ifdef HAVE_ELEMENTARY_X
5720    if (sd->x.xwin)
5721      {
5722         *ret = sd->x.xwin;
5723         return;
5724      }
5725    if (sd->parent)
5726      {
5727         *ret = elm_win_xwindow_get(sd->parent);
5728         return;
5729      }
5730 #endif
5731    *ret = 0;
5732 }
5733
5734 EAPI Ecore_Wl_Window *
5735 elm_win_wl_window_get(const Evas_Object *obj)
5736 {
5737    if (!obj) return NULL;
5738
5739    if ((!ENGINE_COMPARE(ELM_WAYLAND_SHM)) &&
5740        (!ENGINE_COMPARE(ELM_WAYLAND_EGL)))
5741      return NULL;
5742
5743    if (!evas_object_smart_type_check_ptr(obj, MY_CLASS_NAME_LEGACY))
5744      {
5745         Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
5746         return _elm_ee_wlwin_get(ee);
5747      }
5748
5749    ELM_WIN_CHECK(obj) NULL;
5750    Ecore_Wl_Window *ret = NULL;
5751    eo_do((Eo *) obj, elm_obj_win_wl_window_get(&ret));
5752    return ret;
5753 }
5754
5755 static void
5756 _wl_window_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
5757 {
5758    Ecore_Wl_Window **ret = va_arg(*list, Ecore_Wl_Window **);
5759 #if HAVE_ELEMENTARY_WAYLAND
5760    Elm_Win_Smart_Data *sd = _pd;
5761    if (sd->wl.win)
5762      {
5763         *ret = sd->wl.win;
5764         return;
5765      }
5766    if (sd->parent)
5767      {
5768         *ret = elm_win_wl_window_get(sd->parent);
5769         return;
5770      }
5771 #else
5772    (void)_pd;
5773 #endif
5774    *ret = NULL;
5775 }
5776
5777 EAPI Eina_Bool
5778 elm_win_trap_set(const Elm_Win_Trap *t)
5779 {
5780    DBG("old %p, new %p", trap, t);
5781
5782    if ((t) && (t->version != ELM_WIN_TRAP_VERSION))
5783      {
5784         CRI("trying to set a trap version %lu while %lu was expected!",
5785                  t->version, ELM_WIN_TRAP_VERSION);
5786         return EINA_FALSE;
5787      }
5788
5789    trap = t;
5790    return EINA_TRUE;
5791 }
5792
5793 EAPI void
5794 elm_win_floating_mode_set(Evas_Object *obj, Eina_Bool floating)
5795 {
5796    ELM_WIN_CHECK(obj);
5797    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
5798
5799    floating = !!floating;
5800    if (floating == sd->floating) return;
5801    sd->floating = floating;
5802 #ifdef HAVE_ELEMENTARY_X
5803    _elm_win_xwindow_get(sd);
5804    if (sd->x.xwin)
5805      {
5806         if (sd->floating)
5807           ecore_x_e_illume_window_state_set
5808              (sd->x.xwin, ECORE_X_ILLUME_WINDOW_STATE_FLOATING);
5809         else
5810           ecore_x_e_illume_window_state_set
5811              (sd->x.xwin, ECORE_X_ILLUME_WINDOW_STATE_NORMAL);
5812      }
5813 #endif
5814 }
5815
5816 EAPI Eina_Bool
5817 elm_win_floating_mode_get(const Evas_Object *obj)
5818 {
5819    ELM_WIN_CHECK(obj) EINA_FALSE;
5820    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
5821
5822    return sd->floating;
5823 }
5824
5825 static void
5826 _window_id_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
5827 {
5828    Ecore_Window *ret = va_arg(*list, Ecore_Window *);
5829    Elm_Win_Smart_Data *sd = _pd;
5830
5831    if ((ENGINE_COMPARE(ELM_WAYLAND_SHM)) || (ENGINE_COMPARE(ELM_WAYLAND_EGL)))
5832      {
5833 #if HAVE_ELEMENTARY_WAYLAND
5834         if (sd->wl.win)
5835           {
5836              *ret = (Ecore_Window)ecore_wl_window_surface_id_get(sd->wl.win);
5837              return;
5838           }
5839         if (sd->parent)
5840           {
5841              Ecore_Wl_Window *parent;
5842
5843              parent = elm_win_wl_window_get(sd->parent);
5844              if (parent) *ret = (Ecore_Window)ecore_wl_window_surface_id_get(parent);
5845              return;
5846           }
5847 #endif
5848      }
5849    else
5850      {
5851 #ifdef HAVE_ELEMENTARY_X
5852         _elm_win_xwindow_get(sd);
5853         if (sd->x.xwin)
5854           {
5855              *ret = (Ecore_Window)sd->x.xwin;
5856              return;
5857           }
5858         if (sd->parent)
5859           {
5860              *ret = (Ecore_Window)elm_win_xwindow_get(sd->parent);
5861              return;
5862           }
5863 #endif
5864      }
5865
5866    *ret = 0;
5867 }
5868
5869 void
5870 _elm_win_focus_highlight_start(Evas_Object *obj)
5871 {
5872    ELM_WIN_DATA_GET(obj, sd);
5873
5874    if (!elm_win_focus_highlight_enabled_get(obj)) return;
5875    sd->focus_highlight.cur.visible = EINA_TRUE;
5876    sd->focus_highlight.geometry_changed = EINA_TRUE;
5877    _elm_win_focus_highlight_reconfigure_job(obj);
5878 }
5879
5880 EAPI Ecore_Window
5881 elm_win_window_id_get(const Evas_Object *obj)
5882 {
5883    if (!obj) return 0;
5884
5885    if (!evas_object_smart_type_check_ptr(obj, MY_CLASS_NAME_LEGACY))
5886      {
5887         Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
5888         return ecore_evas_window_get(ee);
5889      }
5890
5891    ELM_WIN_CHECK(obj) 0;
5892    Ecore_Window ret = 0;
5893    eo_do((Eo *) obj, elm_obj_win_window_id_get(&ret));
5894    return ret;
5895 }
5896
5897 static void
5898 _class_constructor(Eo_Class *klass)
5899 {
5900    const Eo_Op_Func_Description func_desc[] = {
5901         EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
5902         EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_ADD), _elm_win_smart_add),
5903         EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_DEL), _elm_win_smart_del),
5904         EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_RESIZE), _elm_win_smart_resize),
5905         EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_MOVE), _elm_win_smart_move),
5906         EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_SHOW), _elm_win_smart_show),
5907         EO_OP_FUNC(EVAS_OBJ_SMART_ID(EVAS_OBJ_SMART_SUB_ID_HIDE), _elm_win_smart_hide),
5908
5909         EO_OP_FUNC(ELM_OBJ_WIDGET_ID(ELM_OBJ_WIDGET_SUB_ID_ON_FOCUS), _elm_win_smart_on_focus),
5910         EO_OP_FUNC(ELM_OBJ_WIDGET_ID(ELM_OBJ_WIDGET_SUB_ID_EVENT), _elm_win_smart_event),
5911         EO_OP_FUNC(ELM_OBJ_WIDGET_ID(ELM_OBJ_WIDGET_SUB_ID_FOCUS_NEXT_MANAGER_IS), _elm_win_smart_focus_next_manager_is),
5912         EO_OP_FUNC(ELM_OBJ_WIDGET_ID(ELM_OBJ_WIDGET_SUB_ID_FOCUS_NEXT), _elm_win_smart_focus_next),
5913         EO_OP_FUNC(ELM_OBJ_WIDGET_ID(ELM_OBJ_WIDGET_SUB_ID_FOCUS_DIRECTION_MANAGER_IS), _elm_win_smart_focus_direction_manager_is),
5914         EO_OP_FUNC(ELM_OBJ_WIDGET_ID(ELM_OBJ_WIDGET_SUB_ID_FOCUS_DIRECTION), _elm_win_smart_focus_direction),
5915         EO_OP_FUNC(ELM_OBJ_WIDGET_ID(ELM_OBJ_WIDGET_SUB_ID_THEME_APPLY), _elm_win_smart_theme),
5916
5917         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_WIN_CONSTRUCTOR), _win_constructor),
5918         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_RESIZE_OBJECT_ADD), _resize_object_add),
5919         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_RESIZE_OBJECT_DEL), _resize_object_del),
5920         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_TYPE_GET), _type_get),
5921         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_TITLE_SET), _title_set),
5922         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_TITLE_GET), _title_get),
5923         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_ICON_NAME_SET), _icon_name_set),
5924         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_ICON_NAME_GET), _icon_name_get),
5925         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_ROLE_SET), _role_set),
5926         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_ROLE_GET), _role_get),
5927         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_ICON_OBJECT_SET), _icon_object_set),
5928         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_ICON_OBJECT_GET), _icon_object_get),
5929         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_AUTODEL_SET), _autodel_set),
5930         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_AUTODEL_GET), _autodel_get),
5931         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_ACTIVATE), _activate),
5932         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_LOWER), _lower),
5933         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_RAISE), _raise),
5934         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_CENTER), _center),
5935         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_BORDERLESS_SET), _borderless_set),
5936         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_BORDERLESS_GET), _borderless_get),
5937         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_SHAPED_SET), _shaped_set),
5938         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_SHAPED_GET), _shaped_get),
5939         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_ALPHA_SET), _alpha_set),
5940         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_ALPHA_GET), _alpha_get),
5941         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_OVERRIDE_SET), _override_set),
5942         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_OVERRIDE_GET), _override_get),
5943         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_FULLSCREEN_SET), _fullscreen_set),
5944         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_FULLSCREEN_GET), _fullscreen_get),
5945         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_MAIN_MENU_GET), _main_menu_get),
5946         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_MAXIMIZED_SET), _maximized_set),
5947         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_MAXIMIZED_GET), _maximized_get),
5948         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_ICONIFIED_SET), _iconified_set),
5949         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_ICONIFIED_GET), _iconified_get),
5950         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_WITHDRAWN_SET), _withdrawn_set),
5951         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_WITHDRAWN_GET), _withdrawn_get),
5952         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_AVAILABLE_PROFILES_SET), _available_profiles_set),
5953         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_AVAILABLE_PROFILES_GET), _available_profiles_get),
5954         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_PROFILE_SET), _profile_set),
5955         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_PROFILE_GET), _profile_get),
5956         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_URGENT_SET), _urgent_set),
5957         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_URGENT_GET), _urgent_get),
5958         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_DEMAND_ATTENTION_SET), _demand_attention_set),
5959         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_DEMAND_ATTENTION_GET), _demand_attention_get),
5960         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_MODAL_SET), _modal_set),
5961         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_MODAL_GET), _modal_get),
5962         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_ASPECT_SET), _aspect_set),
5963         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_ASPECT_GET), _aspect_get),
5964         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_SIZE_BASE_SET), _size_base_set),
5965         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_SIZE_BASE_GET), _size_base_get),
5966         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_SIZE_STEP_SET), _size_step_set),
5967         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_SIZE_STEP_GET), _size_step_get),
5968         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_LAYER_SET), _layer_set),
5969         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_LAYER_GET), _layer_get),
5970         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_ROTATION_SET), _rotation_set),
5971         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_ROTATION_WITH_RESIZE_SET), _rotation_with_resize_set),
5972         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_ROTATION_GET), _rotation_get),
5973         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_STICKY_SET), _sticky_set),
5974         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_STICKY_GET), _sticky_get),
5975         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_KEYBOARD_MODE_SET), _keyboard_mode_set),
5976         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_KEYBOARD_MODE_GET), _keyboard_mode_get),
5977         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_KEYBOARD_WIN_SET), _keyboard_win_set),
5978         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_KEYBOARD_WIN_GET), _keyboard_win_get),
5979         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_INDICATOR_MODE_SET), _indicator_mode_set),
5980         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_INDICATOR_MODE_GET), _indicator_mode_get),
5981         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_INDICATOR_OPACITY_SET), _indicator_opacity_set),
5982         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_INDICATOR_OPACITY_GET), _indicator_opacity_get),
5983         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_SCREEN_POSITION_GET), _screen_position_get),
5984         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_FOCUS_GET), _focus_get),
5985         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_SCREEN_CONSTRAIN_SET), _screen_constrain_set),
5986         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_SCREEN_CONSTRAIN_GET), _screen_constrain_get),
5987         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_SCREEN_SIZE_GET), _screen_size_get),
5988         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_SCREEN_DPI_GET), _screen_dpi_get),
5989         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_CONFORMANT_SET), _conformant_set),
5990         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_CONFORMANT_GET), _conformant_get),
5991         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_QUICKPANEL_SET), _quickpanel_set),
5992         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_QUICKPANEL_GET), _quickpanel_get),
5993         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_QUICKPANEL_PRIORITY_MAJOR_SET), _quickpanel_priority_major_set),
5994         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_QUICKPANEL_PRIORITY_MAJOR_GET), _quickpanel_priority_major_get),
5995         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_QUICKPANEL_PRIORITY_MINOR_SET), _quickpanel_priority_minor_set),
5996         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_QUICKPANEL_PRIORITY_MINOR_GET), _quickpanel_priority_minor_get),
5997         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_QUICKPANEL_ZONE_SET), _quickpanel_zone_set),
5998         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_QUICKPANEL_ZONE_GET), _quickpanel_zone_get),
5999         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_PROP_FOCUS_SKIP_SET), _prop_focus_skip_set),
6000         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_ILLUME_COMMAND_SEND), _illume_command_send),
6001         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_INLINED_IMAGE_OBJECT_GET), _inlined_image_object_get),
6002         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_FOCUS_HIGHLIGHT_ENABLED_SET), _focus_highlight_enabled_set),
6003         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_FOCUS_HIGHLIGHT_ENABLED_GET), _focus_highlight_enabled_get),
6004         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_FOCUS_HIGHLIGHT_STYLE_SET), _focus_highlight_style_set),
6005         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_FOCUS_HIGHLIGHT_STYLE_GET), _focus_highlight_style_get),
6006         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_FOCUS_HIGHLIGHT_ANIMATE_SET), _focus_highlight_animate_set),
6007         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_FOCUS_HIGHLIGHT_ANIMATE_GET), _focus_highlight_animate_get),
6008         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_SOCKET_LISTEN), _socket_listen),
6009         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_XWINDOW_GET), _xwindow_get),
6010         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_WL_WINDOW_GET), _wl_window_get),
6011         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_WINDOW_ID_GET), _window_id_get),
6012         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_WM_ROTATION_SUPPORTED_GET), _wm_rotation_supported_get),
6013         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_WM_PREFERRED_ROTATION_SET), _wm_preferred_rotation_set),
6014         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_WM_PREFERRED_ROTATION_GET), _wm_preferred_rotation_get),
6015         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_WM_AVAILABLE_ROTATIONS_SET), _wm_available_rotations_set),
6016         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_WM_AVAILABLE_ROTATIONS_GET), _wm_available_rotations_get),
6017         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_WM_MANUAL_ROTATION_DONE_SET), _wm_manual_rotation_done_set),
6018         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_WM_MANUAL_ROTATION_DONE_GET), _wm_manual_rotation_done_get),
6019         EO_OP_FUNC(ELM_OBJ_WIN_ID(ELM_OBJ_WIN_SUB_ID_WM_MANUAL_ROTATION_DONE), _wm_manual_rotation_done),
6020         EO_OP_FUNC_SENTINEL
6021    };
6022
6023    eo_class_funcs_set(klass, func_desc);
6024
6025    evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
6026 }
6027
6028 static const Eo_Op_Description op_desc[] = {
6029      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_WIN_CONSTRUCTOR, "Adds a window object."),
6030      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_RESIZE_OBJECT_ADD, "Add subobj as a resize object of window obj."),
6031      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_RESIZE_OBJECT_DEL, "Delete subobj as a resize object of window obj."),
6032      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_TYPE_GET, "Get the type of the window."),
6033      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_TITLE_SET, "Set the title of the window."),
6034      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_TITLE_GET, "Get the title of the window."),
6035      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_ICON_NAME_SET, "Set the icon name of the window."),
6036      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_ICON_NAME_GET, "Get the icon name of the window."),
6037      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_ROLE_SET, "Set the role of the window."),
6038      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_ROLE_GET, "Get the role of the window."),
6039      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_ICON_OBJECT_SET, "Set a window object's icon."),
6040      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_ICON_OBJECT_GET, "Get the icon object used for the window."),
6041      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_AUTODEL_SET, "Set the window's autodel state."),
6042      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_AUTODEL_GET, "Get the window's autodel state."),
6043      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_ACTIVATE, "Activate a window object."),
6044      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_LOWER, "Lower a window object."),
6045      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_RAISE, "Raise a window object."),
6046      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_CENTER, "Center a window on its screen."),
6047      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_BORDERLESS_SET, "Set the borderless state of a window."),
6048      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_BORDERLESS_GET, "Get the borderless state of a window."),
6049      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_SHAPED_SET, "Set the shaped state of a window."),
6050      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_SHAPED_GET, "Get the shaped state of a window."),
6051      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_ALPHA_SET, "Set the alpha channel state of a window."),
6052      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_ALPHA_GET, "Get the alpha channel state of a window."),
6053      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_OVERRIDE_SET, "Set the override state of a window."),
6054      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_OVERRIDE_GET, "Get the override state of a window."),
6055      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_FULLSCREEN_SET, "Set the fullscreen state of a window."),
6056      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_FULLSCREEN_GET, "Get the fullscreen state of a window."),
6057      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_MAIN_MENU_GET, "Get the Main Menu of a window."),
6058      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_MAXIMIZED_SET, "Set the maximized state of a window."),
6059      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_MAXIMIZED_GET, "Get the maximized state of a window."),
6060      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_ICONIFIED_SET, "Set the iconified state of a window."),
6061      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_ICONIFIED_GET, "Get the iconified state of a window."),
6062      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_WITHDRAWN_SET, "Set the withdrawn state of a window."),
6063      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_WITHDRAWN_GET, "Get the withdrawn state of a window."),
6064      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_AVAILABLE_PROFILES_SET, "Set the array of available profiles to a window."),
6065      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_AVAILABLE_PROFILES_GET, "Get the array of available profiles of a window."),
6066      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_PROFILE_SET, "Set the profile of a window."),
6067      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_PROFILE_GET, "Get the profile of a window."),
6068      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_URGENT_SET, "Set the urgent state of a window."),
6069      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_URGENT_GET, "Get the urgent state of a window."),
6070      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_DEMAND_ATTENTION_SET, "Set the demand_attention state of a window."),
6071      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_DEMAND_ATTENTION_GET, "Get the demand_attention state of a window."),
6072      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_MODAL_SET, "Set the modal state of a window."),
6073      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_MODAL_GET, "Get the modal state of a window."),
6074      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_ASPECT_SET, "Set the aspect ratio of a window."),
6075      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_ASPECT_GET, "Get the aspect ratio of a window."),
6076      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_SIZE_BASE_SET, "Set the base window size used with stepping calculation."),
6077      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_SIZE_BASE_GET, "Get the base size of a window."),
6078      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_SIZE_STEP_SET, "Set the window stepping used with sizing calculation."),
6079      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_SIZE_STEP_GET, "Get the stepping of a window."),
6080      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_LAYER_SET, "Set the layer of the window."),
6081      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_LAYER_GET, "Get the layer of the window."),
6082      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_ROTATION_SET, "Set the rotation of the window."),
6083      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_ROTATION_WITH_RESIZE_SET, "Rotates the window and resizes it."),
6084      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_ROTATION_GET, "Get the rotation of the window."),
6085      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_STICKY_SET, "Set the sticky state of the window."),
6086      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_STICKY_GET, "Get the sticky state of the window."),
6087      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_KEYBOARD_MODE_SET, "Sets the keyboard mode of the window."),
6088      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_KEYBOARD_MODE_GET, "Get the keyboard mode of the window."),
6089      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_KEYBOARD_WIN_SET, "Sets whether the window is a keyboard."),
6090      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_KEYBOARD_WIN_GET, "Get whether the window is a keyboard."),
6091      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_INDICATOR_MODE_SET, "Sets the indicator mode of the window."),
6092      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_INDICATOR_MODE_GET, "Get the indicator mode of the window."),
6093      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_INDICATOR_OPACITY_SET, "Sets the indicator opacity mode of the window."),
6094      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_INDICATOR_OPACITY_GET, "Get the indicator opacity mode of the window."),
6095      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_SCREEN_POSITION_GET, "Get the screen position of a window."),
6096      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_FOCUS_GET, "Determine whether a window has focus."),
6097      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_SCREEN_CONSTRAIN_SET, "Constrain the maximum width and height of a window to the width and height of its screen."),
6098      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_SCREEN_CONSTRAIN_GET, "Retrieve the constraints on the maximum width and height of a window relative to the width and height of its screen."),
6099      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_SCREEN_SIZE_GET, "Get screen geometry details for the screen that a window is on."),
6100      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_SCREEN_DPI_GET, "Get screen dpi for the screen that a window is on."),
6101      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_CONFORMANT_SET, "Set if this window is an illume conformant window."),
6102      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_CONFORMANT_GET, "Get if this window is an illume conformant window."),
6103      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_QUICKPANEL_SET, "Set a window to be an illume quickpanel window."),
6104      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_QUICKPANEL_GET, "Get if this window is a quickpanel or not."),
6105      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_QUICKPANEL_PRIORITY_MAJOR_SET, "Set the major priority of a quickpanel window."),
6106      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_QUICKPANEL_PRIORITY_MAJOR_GET, "Get the major priority of a quickpanel window."),
6107      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_QUICKPANEL_PRIORITY_MINOR_SET, "Set the minor priority of a quickpanel window."),
6108      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_QUICKPANEL_PRIORITY_MINOR_GET, "Get the minor priority of a quickpanel window."),
6109      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_QUICKPANEL_ZONE_SET, "Set which zone this quickpanel should appear in."),
6110      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_QUICKPANEL_ZONE_GET, "Get which zone this quickpanel should appear in."),
6111      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_PROP_FOCUS_SKIP_SET, "Set the window to be skipped by keyboard focus."),
6112      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_ILLUME_COMMAND_SEND, "Send a command to the windowing environment."),
6113      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_INLINED_IMAGE_OBJECT_GET, "Get the inlined image object handle."),
6114      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_FOCUS_HIGHLIGHT_ENABLED_SET, "Set the enabled status for the focus highlight in a window."),
6115      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_FOCUS_HIGHLIGHT_ENABLED_GET, "Get the enabled value of the focus highlight for this window."),
6116      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_FOCUS_HIGHLIGHT_STYLE_SET, "Set the style for the focus highlight on this window."),
6117      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_FOCUS_HIGHLIGHT_STYLE_GET, "Get the style set for the focus highlight object."),
6118      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_FOCUS_HIGHLIGHT_ANIMATE_SET, "Set the animate status for the focus highlight for this window."),
6119      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_FOCUS_HIGHLIGHT_ANIMATE_GET, "Get the animate status for the focus highlight for this window."),
6120      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_SOCKET_LISTEN, "Create a socket to provide the service for Plug widget."),
6121      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_XWINDOW_GET, "Get the Ecore_X_Window of an Evas_Object."),
6122      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_WL_WINDOW_GET, "Get the Ecore_Wl_Window of an Evas_Object."),
6123      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_WINDOW_ID_GET, "Get the Ecore_Window of an Evas_Object."),
6124      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_WM_ROTATION_SUPPORTED_GET, "Query if the underlying windowing system supports the window manager rotation.."),
6125      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_WM_PREFERRED_ROTATION_SET, "Set the preferred rotation hint."),
6126      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_WM_PREFERRED_ROTATION_GET, "Get the preferred rotation hint."),
6127      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_WM_AVAILABLE_ROTATIONS_SET, "Set the array of available window rotations."),
6128      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_WM_AVAILABLE_ROTATIONS_GET, "Get the array of available window rotations."),
6129      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_WM_MANUAL_ROTATION_DONE_SET, "Set manual rotation done mode of obj window."),
6130      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_WM_MANUAL_ROTATION_DONE_GET, "Get manual rotation done mode of obj window."),
6131      EO_OP_DESCRIPTION(ELM_OBJ_WIN_SUB_ID_WM_MANUAL_ROTATION_DONE, "Set rotation finish manually"),
6132      EO_OP_DESCRIPTION_SENTINEL
6133 };
6134
6135 static const Eo_Class_Description class_desc = {
6136      EO_VERSION,
6137      MY_CLASS_NAME,
6138      EO_CLASS_TYPE_REGULAR,
6139      EO_CLASS_DESCRIPTION_OPS(&ELM_OBJ_WIN_BASE_ID, op_desc, ELM_OBJ_WIN_SUB_ID_LAST),
6140      NULL,
6141      sizeof(Elm_Win_Smart_Data),
6142      _class_constructor,
6143      NULL
6144 };
6145
6146 EO_DEFINE_CLASS(elm_obj_win_class_get, &class_desc, ELM_OBJ_WIDGET_CLASS, NULL);