Atspi: enhance finding next and prev item on screen's edge
[platform/upstream/elementary.git] / src / lib / elm_win.c
1 #ifdef HAVE_CONFIG_H
2 # include "elementary_config.h"
3 #endif
4
5 #define ELM_INTERFACE_ATSPI_ACCESSIBLE_PROTECTED
6 #define ELM_INTERFACE_ATSPI_WIDGET_ACTION_PROTECTED
7 #define ELM_INTERFACE_ATSPI_COMPONENT_PROTECTED
8 #define ELM_WIN_PROTECTED
9
10 #include <Elementary.h>
11 #include <Elementary_Cursor.h>
12
13 #include "elm_priv.h"
14 #include "elm_widget_menu.h"
15
16 #define MY_CLASS ELM_WIN_CLASS
17
18 #define MY_CLASS_NAME "Elm_Win"
19 #define MY_CLASS_NAME_LEGACY "elm_win"
20
21 static const Elm_Win_Trap *trap = NULL;
22
23 #define TRAP(sd, name, ...)                                             \
24   do                                                                    \
25     {                                                                   \
26        if (sd->type != ELM_WIN_FAKE)                                    \
27          if ((!trap) || (!trap->name) ||                                \
28              ((trap->name) &&                                           \
29               (trap->name(sd->trap_data, sd->obj, ## __VA_ARGS__))))    \
30            ecore_evas_##name(sd->ee, ##__VA_ARGS__);                    \
31     }                                                                   \
32   while (0)
33
34 #define ELM_WIN_DATA_GET(o, sd) \
35   Elm_Win_Data * sd = eo_data_scope_get(o, MY_CLASS)
36
37 #define ELM_WIN_DATA_GET_OR_RETURN(o, ptr)           \
38   ELM_WIN_DATA_GET(o, ptr);                          \
39   if (!ptr)                                          \
40     {                                                \
41        CRI("No widget data for object %p (%s)", \
42                 o, evas_object_type_get(o));         \
43        return;                                       \
44     }
45
46 #define ELM_WIN_DATA_GET_OR_RETURN_VAL(o, ptr, val)  \
47   ELM_WIN_DATA_GET(o, ptr);                          \
48   if (!ptr)                                          \
49     {                                                \
50        CRI("No widget data for object %p (%s)", \
51                 o, evas_object_type_get(o));         \
52        return val;                                   \
53     }
54
55 #define ELM_WIN_CHECK(obj)                                             \
56   if (!obj || !eo_isa(obj, MY_CLASS)) \
57     return
58
59 #define DECREMENT_MODALITY()                                    \
60   EINA_LIST_FOREACH(_elm_win_list, l, current)                  \
61     {                                                           \
62        ELM_WIN_DATA_GET_OR_RETURN(current, cursd);              \
63        if ((obj != current) && (cursd->modal_count > 0))        \
64          {                                                      \
65             cursd->modal_count--;                               \
66          }                                                      \
67        if (cursd->modal_count == 0)                             \
68          {                                                      \
69             edje_object_signal_emit(cursd->edje, \
70                         "elm,action,hide_blocker", "elm");      \
71             eo_do(cursd->main_menu, eo_event_callback_call      \
72               (ELM_MENU_EVENT_ELM_ACTION_UNBLOCK_MENU, NULL));  \
73          }                                                      \
74     }
75
76 #define INCREMENT_MODALITY()                                    \
77   EINA_LIST_FOREACH(_elm_win_list, l, current)                  \
78     {                                                           \
79        ELM_WIN_DATA_GET_OR_RETURN(current, cursd);              \
80        if (obj != current)                                      \
81          {                                                      \
82             cursd->modal_count++;                               \
83          }                                                      \
84        if (cursd->modal_count > 0)                              \
85          {                                                      \
86             edje_object_signal_emit(cursd->edje, \
87                              "elm,action,show_blocker", "elm"); \
88             eo_do(cursd->main_menu, eo_event_callback_call      \
89               (ELM_WIN_EVENT_ELM_ACTION_BLOCK_MENU, NULL));     \
90          }                                                      \
91     }
92
93 #define ENGINE_GET() (_elm_preferred_engine ? _elm_preferred_engine : _elm_config->engine)
94
95 typedef struct _Elm_Win_Data Elm_Win_Data;
96
97 struct _Elm_Win_Data
98 {
99    Ecore_Evas           *ee;
100    Evas                 *evas;
101    Evas_Object          *parent; /* parent *window* object*/
102    Evas_Object          *img_obj, *frame_obj;
103    Evas_Object          *client_obj; /* rect representing the client */
104    Eo                   *edje; /**< edje object for a window layout */
105    Eo                   *box;
106    Evas_Object          *obj; /* The object itself */
107 #ifdef HAVE_ELEMENTARY_X
108    struct
109    {
110       Ecore_X_Window       xwin;
111       Ecore_Event_Handler *client_message_handler;
112       Ecore_Event_Handler *property_handler;
113    } x;
114 #endif
115 #ifdef HAVE_ELEMENTARY_WAYLAND
116    struct
117    {
118       Ecore_Wl_Window *win;
119       Eina_Bool opaque_dirty : 1;
120       Ecore_Event_Handler *effect_start_handler;
121       Ecore_Event_Handler *effect_end_handler;
122       Ecore_Event_Handler *indicator_flick_handler; // TIZEN_ONLY(20160801): indicator implementation
123       Ecore_Event_Handler *aux_msg_handler;
124    } wl;
125 #endif
126 #ifdef HAVE_ELEMENTARY_COCOA
127    struct {
128       Ecore_Cocoa_Window *win;
129    } cocoa;
130 #endif
131 #ifdef HAVE_ELEMENTARY_WIN32
132    struct
133    {
134       Ecore_Win32_Window *win;
135    } win32;
136 #endif
137
138    Ecore_Job                     *deferred_resize_job;
139    Ecore_Job                     *deferred_child_eval_job;
140    Ecore_Event_Handler           *mouse_up_handler;//TIZEN_ONLY(20161121) tizen don't have canvas mouse up event like opensource now.
141
142    Elm_Win_Type                   type;
143    Elm_Win_Keyboard_Mode          kbdmode;
144    Elm_Win_Indicator_Mode         indmode;
145    Elm_Win_Indicator_Opacity_Mode ind_o_mode;
146    Eina_Rectangle kbd;
147    Eina_Rectangle ind;
148    struct
149    {
150       const char  *info;
151       Ecore_Timer *timer;
152       int          repeat_count;
153       int          shot_counter;
154    } shot;
155    int                            resize_location;
156    int                           *autodel_clear, rot;
157    struct
158    {
159       int x, y;
160    } screen;
161    struct
162    {
163 #if 0
164       Ecore_Evas  *ee;
165 #endif
166       Evas        *evas;
167       Evas_Object *obj, *hot_obj;
168       int          hot_x, hot_y;
169    } pointer;
170    struct
171    {
172       Evas_Object *fobj; /* focus highlight edje object */
173
174       struct
175       {
176          Evas_Object *target;
177          Eina_Bool    visible : 1;
178          Eina_Bool    in_theme: 1; /**< focus highlight is handled by theme.
179                                      this is set true if edc data item "focus_highlight" is set to "on" during focus in callback. */
180       } cur, prev;
181
182       const char  *style;
183       Ecore_Job   *reconf_job;
184
185       Eina_Bool    enabled : 1;
186       Eina_Bool    theme_changed : 1; /* set true when the focus theme is changed */
187       Eina_Bool    animate : 1; /* set true when the focus highlight animate is enabled */
188       Eina_Bool    animate_supported : 1; /* set true when the focus highlight animate is supported by theme */
189       Eina_Bool    geometry_changed : 1;
190       Eina_Bool    auto_enabled : 1;
191       Eina_Bool    auto_animate : 1;
192    } focus_highlight;
193    //TIZEN_ONLY(20160404) Accessibility Highlight Frame added (99248ce)
194    struct
195    {
196       Evas_Object *fobj; /* accessibility highlight edje object */
197
198       struct
199       {
200          Evas_Object *target;
201          //TIZEN_ONLY(20160623): atspi: moved highlight when object is out of screen
202          int x;
203          int y;
204          int w;
205          int h;
206          Eina_Bool need_moved;
207          //
208       } cur, prev;
209
210    } accessibility_highlight;
211    //
212    //TIZEN_ONLY(20170919): Handle default label object
213    Eina_List *default_label_objs;
214    //
215    Evas_Object *icon;
216    const char  *title;
217    const char  *icon_name;
218    const char  *role;
219    const char  *frame_style;
220    Eina_Stringshare *name;
221
222    Evas_Object *main_menu;
223
224    struct
225    {
226       const char  *name;
227       const char **available_list;
228       unsigned int count;
229    } profile;
230    struct
231    {
232       int          preferred_rot; /* indicates preferred rotation value, -1 means invalid. */
233       int         *rots; /* indicates available rotations */
234       unsigned int count; /* number of elements in available rotations */
235       Eina_Bool    wm_supported : 1; /* set true when the window manager support window rotation */
236       Eina_Bool    use : 1; /* set ture when application use window manager rotation. */
237 // TIZEN_ONLY(20170212): pend rotation until app set rotation
238       Eina_Bool    rotation_pending : 1; /* set true when application will manage the rotation */
239 //
240    } wm_rot;
241
242    Eo *socket_proxy; /* reference object to atspi object in separate process @since 1.15 */
243
244    void *trap_data;
245
246    struct
247      {
248         Ecore_Animator *obj;
249         unsigned short wants;
250      } animator;
251
252    double       aspect;
253    int          size_base_w, size_base_h;
254    int          size_step_w, size_step_h;
255    int          norender;
256    int          modal_count;
257    Eina_Bool    urgent : 1;
258    Eina_Bool    modal : 1;
259    Eina_Bool    demand_attention : 1;
260    Eina_Bool    autodel : 1;
261    Eina_Bool    autohide : 1;
262    Eina_Bool    constrain : 1;
263    Eina_Bool    resizing : 1;
264    Eina_Bool    iconified : 1;
265    Eina_Bool    withdrawn : 1;
266    Eina_Bool    sticky : 1;
267    Eina_Bool    fullscreen : 1;
268    Eina_Bool    maximized : 1;
269    Eina_Bool    skip_focus : 1;
270    Eina_Bool    floating : 1;
271    Eina_Bool    noblank : 1;
272    Eina_Bool    theme_alpha : 1; /**< alpha value fetched by a theme. this has higher priority than application_alpha */
273    Eina_Bool    application_alpha : 1; /**< alpha value set by an elm_win_alpha_set() api. this has lower priority than theme_alpha */
274    Eina_Bool    obscured :1;
275    Eina_Bool    borderless : 1;
276 };
277
278 static const char SIG_DELETE_REQUEST[] = "delete,request";
279 static const char SIG_FOCUS_OUT[] = "focus,out"; // deprecated. use "unfocused" instead.
280 static const char SIG_FOCUS_IN[] = "focus,in"; // deprecated. use "focused" instead.
281 static const char SIG_MOVED[] = "moved";
282 static const char SIG_WITHDRAWN[] = "withdrawn";
283 static const char SIG_ICONIFIED[] = "iconified";
284 static const char SIG_NORMAL[] = "normal";
285 static const char SIG_STICK[] = "stick";
286 static const char SIG_UNSTICK[] = "unstick";
287 static const char SIG_FULLSCREEN[] = "fullscreen";
288 static const char SIG_UNFULLSCREEN[] = "unfullscreen";
289 static const char SIG_MAXIMIZED[] = "maximized";
290 static const char SIG_UNMAXIMIZED[] = "unmaximized";
291 static const char SIG_IOERR[] = "ioerr";
292 static const char SIG_INDICATOR_PROP_CHANGED[] = "indicator,prop,changed";
293 static const char SIG_ROTATION_CHANGED[] = "rotation,changed";
294 static const char SIG_PROFILE_CHANGED[] = "profile,changed";
295 static const char SIG_WM_ROTATION_CHANGED[] = "wm,rotation,changed";
296 #ifdef HAVE_ELEMENTARY_WAYLAND
297 static const char SIG_CONFORMANT_CHANGED[] = "conformant,changed";
298 static const char SIG_INDICATOR_FLICK_DONE[] = "indicator,flick,done"; // TIZEN_ONLY(20160801): indicator implementation
299 #endif
300 static const char SIG_AUX_HINT_ALLOWED[] = "aux,hint,allowed";
301 static const char SIG_AUX_MESSAGE_RECEIVED[] = "aux,msg,received";
302 static const char SIG_VISIBILITY_CHANGED[] = "visibility,changed";
303 static const char SIG_EFFECT_STARTED[] = "effect,started";
304 static const char SIG_EFFECT_DONE[] = "effect,done";
305 static const char SIG_LAUNCH_DONE[] = "launch,done";
306 //TIZEN_ONLY(20161028): add smart signal 'atspi,screen,reader,changed'
307 static const char SIG_ATSPI_SCREEN_READER_CHANGED[] = "atspi,screen,reader,changed";
308 //
309
310 static const Evas_Smart_Cb_Description _smart_callbacks[] = {
311    {SIG_DELETE_REQUEST, ""},
312    {SIG_FOCUS_OUT, ""},
313    {SIG_FOCUS_IN, ""},
314    {SIG_MOVED, ""},
315    {SIG_WITHDRAWN, ""},
316    {SIG_ICONIFIED, ""},
317    {SIG_NORMAL, ""},
318    {SIG_STICK, ""},
319    {SIG_UNSTICK, ""},
320    {SIG_FULLSCREEN, ""},
321    {SIG_UNFULLSCREEN, ""},
322    {SIG_MAXIMIZED, ""},
323    {SIG_UNMAXIMIZED, ""},
324    {SIG_IOERR, ""},
325    {SIG_INDICATOR_PROP_CHANGED, ""},
326    {SIG_ROTATION_CHANGED, ""},
327    {SIG_PROFILE_CHANGED, ""},
328    {SIG_WM_ROTATION_CHANGED, ""},
329    {SIG_WIDGET_FOCUSED, ""}, /**< handled by elm_widget */
330    {SIG_WIDGET_UNFOCUSED, ""}, /**< handled by elm_widget */
331 #ifdef HAVE_ELEMENTARY_WAYLAND
332    {SIG_CONFORMANT_CHANGED, ""},
333 #endif
334    {SIG_AUX_HINT_ALLOWED, ""},
335    {SIG_VISIBILITY_CHANGED, ""},
336    {SIG_EFFECT_STARTED, ""},
337    {SIG_EFFECT_DONE, ""},
338    {SIG_LAUNCH_DONE, ""},
339    //TIZEN_ONLY(20161028): add smart signal 'atspi,screen,reader,changed'
340    {SIG_ATSPI_SCREEN_READER_CHANGED, ""},
341    //
342    {NULL, NULL}
343 };
344
345 static Eina_Bool _key_action_return(Evas_Object *obj, const char *params);
346 static Eina_Bool _key_action_move(Evas_Object *obj, const char *params);
347
348 static const Elm_Action key_actions[] = {
349    {"return", _key_action_return},
350    {"move", _key_action_move},
351    {NULL, NULL}
352 };
353
354 Eina_List *_elm_win_list = NULL;
355 int _elm_win_deferred_free = 0;
356
357 static Eina_Bool _elm_win_throttle_ok = EINA_FALSE;
358 static int _elm_win_count = 0;
359
360 // TIZEN_ONLY(20160218): Improve launching performance.
361 static Evas_Object *_precreated_win_obj = NULL;
362 //
363
364 static Eina_Bool _elm_win_auto_throttled = EINA_FALSE;
365
366 static Ecore_Job *_elm_win_state_eval_job = NULL;
367
368 static void
369 _elm_win_on_resize_obj_changed_size_hints(void *data,
370                                           Evas *e,
371                                           Evas_Object *obj,
372                                           void *event_info);
373 static void
374 _elm_win_img_callbacks_del(Evas_Object *obj, Evas_Object *imgobj);
375 static Elm_Theme_Apply _elm_win_theme_internal(Eo *obj, Elm_Win_Data *sd);
376 static void
377 _elm_win_borderless_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool borderless);
378
379 #ifdef HAVE_ELEMENTARY_X
380 static void _elm_win_xwin_update(Elm_Win_Data *sd);
381 #endif
382
383 EAPI double _elm_startup_time = 0;
384
385 static void
386 _elm_win_first_frame_do(void *data, Evas *e EINA_UNUSED, void *event_info EINA_UNUSED)
387 {
388    double end = ecore_time_unix_get();
389    char *first = data;
390
391    switch (*first)
392      {
393       case 'A': abort();
394       case 'E':
395       case 'D': exit(-1);
396       case 'T': fprintf(stderr, "Startup time: '%f' - '%f' = '%f' sec\n", end, _elm_startup_time, end - _elm_startup_time);
397                 break;
398      }
399
400    evas_event_callback_del_full(e, EVAS_CALLBACK_RENDER_POST, _elm_win_first_frame_do, data);
401 }
402
403 static void
404 _win_noblank_eval(void)
405 {
406 #ifdef HAVE_ELEMENTARY_X
407    Eina_List *l;
408    Evas_Object *obj;
409    int noblanks = 0;
410    Eina_Bool change = EINA_FALSE;
411
412    EINA_LIST_FOREACH(_elm_win_list, l, obj)
413      {
414         ELM_WIN_DATA_GET(obj, sd);
415
416         if (sd->x.xwin)
417           {
418              if ((sd->noblank) && (!sd->iconified) && (!sd->withdrawn) &&
419                  evas_object_visible_get(obj))
420                noblanks++;
421
422              change = EINA_TRUE;
423           }
424      }
425
426    if (!change) return;
427
428    if (noblanks > 0) ecore_x_screensaver_suspend();
429    else ecore_x_screensaver_resume();
430 #endif
431 #ifdef HAVE_ELEMENTARY_WAYLAND
432    // XXX: no wl implementation of this yet - maybe higher up at prop level
433 #endif
434 }
435
436 static Elm_Process_State _elm_process_state = ELM_PROCESS_STATE_FOREGROUND;
437
438 EAPI Elm_Process_State
439 elm_process_state_get(void)
440 {
441    return _elm_process_state;
442 }
443
444 static void
445 _elm_win_apply_alpha(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
446 {
447    Eina_Bool enabled;
448
449    enabled = sd->theme_alpha | sd->application_alpha;
450    if (sd->img_obj)
451      {
452         evas_object_image_alpha_set(sd->img_obj, enabled);
453         ecore_evas_alpha_set(sd->ee, enabled);
454      }
455    else
456      {
457 #ifdef HAVE_ELEMENTARY_X
458         if (sd->x.xwin)
459           {
460              if (enabled)
461                {
462                   if (!ecore_x_screen_is_composited(0))
463                     elm_win_shaped_set(obj, enabled);
464                   else
465                     TRAP(sd, alpha_set, enabled);
466                }
467              else
468                TRAP(sd, alpha_set, enabled);
469              _elm_win_xwin_update(sd);
470           }
471         else
472 #endif
473           TRAP(sd, alpha_set, enabled);
474      }
475 }
476
477 static void
478 _elm_win_state_eval(void *data EINA_UNUSED)
479 {
480    Eina_List *l;
481    Evas_Object *obj;
482    int _elm_win_count_shown = 0;
483    int _elm_win_count_iconified = 0;
484    int _elm_win_count_withdrawn = 0;
485    Eina_Bool throttle = EINA_FALSE;
486
487    _elm_win_state_eval_job = NULL;
488
489    EINA_LIST_FOREACH(_elm_win_list, l, obj)
490      {
491         if (_elm_config->auto_norender_withdrawn)
492           {
493              if ((elm_win_withdrawn_get(obj)) ||
494                  ((elm_win_iconified_get(obj) &&
495                    (_elm_config->auto_norender_iconified_same_as_withdrawn))))
496                {
497                   if (!evas_object_data_get(obj, "__win_auto_norender"))
498                     {
499                        Evas *evas = evas_object_evas_get(obj);
500
501                        elm_win_norender_push(obj);
502                        evas_object_data_set(obj, "__win_auto_norender", obj);
503
504                        if (_elm_config->auto_flush_withdrawn)
505                          {
506                             edje_file_cache_flush();
507                             edje_collection_cache_flush();
508                             evas_image_cache_flush(evas);
509                             evas_font_cache_flush(evas);
510                          }
511                        if (_elm_config->auto_dump_withdrawn)
512                          {
513                             evas_render_dump(evas);
514                          }
515                     }
516                   continue;
517                }
518           }
519         if (evas_object_data_get(obj, "__win_auto_norender"))
520           {
521              elm_win_norender_pop(obj);
522              evas_object_data_del(obj, "__win_auto_norender");
523           }
524      }
525    if (((_elm_config->auto_throttle) &&
526         (elm_policy_get(ELM_POLICY_THROTTLE) != ELM_POLICY_THROTTLE_NEVER)) ||
527         (elm_policy_get(ELM_POLICY_THROTTLE) == ELM_POLICY_THROTTLE_HIDDEN_ALWAYS))
528      throttle = EINA_TRUE;
529    if (_elm_win_count == 0)
530      {
531         if ((_elm_win_throttle_ok) && (_elm_win_auto_throttled))
532           {
533              _elm_process_state = ELM_PROCESS_STATE_FOREGROUND;
534              ecore_event_add(ELM_EVENT_PROCESS_FOREGROUND, NULL, NULL, NULL);
535              if (throttle)
536                ecore_throttle_adjust(-_elm_config->auto_throttle_amount);
537              _elm_win_auto_throttled = EINA_FALSE;
538           }
539      }
540    else
541      {
542         EINA_LIST_FOREACH(_elm_win_list, l, obj)
543           {
544              if (elm_win_withdrawn_get(obj)) _elm_win_count_withdrawn++;
545              else if (elm_win_iconified_get(obj)) _elm_win_count_iconified++;
546              else if (evas_object_visible_get(obj)) _elm_win_count_shown++;
547           }
548         if (_elm_win_count_shown <= 0)
549           {
550              if ((_elm_win_throttle_ok) && (!_elm_win_auto_throttled))
551                {
552                   _elm_process_state = ELM_PROCESS_STATE_BACKGROUND;
553                   ecore_event_add(ELM_EVENT_PROCESS_BACKGROUND, NULL, NULL, NULL);
554                   if (throttle)
555                     ecore_throttle_adjust(_elm_config->auto_throttle_amount);
556                   _elm_win_auto_throttled = EINA_TRUE;
557                }
558           }
559         else
560           {
561              if ((_elm_win_throttle_ok) && (_elm_win_auto_throttled))
562                {
563                   _elm_process_state = ELM_PROCESS_STATE_FOREGROUND;
564                   ecore_event_add(ELM_EVENT_PROCESS_FOREGROUND, NULL, NULL, NULL);
565                   if (throttle)
566                     ecore_throttle_adjust(-_elm_config->auto_throttle_amount);
567                   _elm_win_auto_throttled = EINA_FALSE;
568                }
569           }
570      }
571    _win_noblank_eval();
572    return;
573 }
574
575 static Eina_Bool
576 _elm_win_policy_quit_triggered(Eo* triggering_obj)
577 {
578    if ((!_elm_win_list) &&
579        (elm_policy_get(ELM_POLICY_QUIT) == ELM_POLICY_QUIT_LAST_WINDOW_CLOSED))
580      {
581         return EINA_TRUE;
582      }
583
584    if (elm_policy_get(ELM_POLICY_QUIT) == ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN)
585      {
586         Eina_List *l;
587         Evas_Object *win;
588
589         EINA_LIST_FOREACH(_elm_win_list, l, win)
590           if (win != triggering_obj && evas_object_visible_get(win) == EINA_TRUE)
591             {
592                return EINA_FALSE;
593             }
594         return EINA_TRUE;
595      }
596
597    return EINA_FALSE;
598 }
599
600 static void
601 _elm_win_flush_cache_and_exit(Eo *obj)
602 {
603    edje_file_cache_flush();
604    edje_collection_cache_flush();
605    evas_image_cache_flush(evas_object_evas_get(obj));
606    evas_font_cache_flush(evas_object_evas_get(obj));
607    elm_exit();
608 }
609
610 static void
611 _elm_win_state_eval_queue(void)
612 {
613    if (_elm_win_state_eval_job) ecore_job_del(_elm_win_state_eval_job);
614    _elm_win_state_eval_job = ecore_job_add(_elm_win_state_eval, NULL);
615 }
616
617 // example shot spec (wait 0.1 sec then save as my-window.png):
618 // ELM_ENGINE="shot:delay=0.1:file=my-window.png"
619
620 static double
621 _shot_delay_get(Elm_Win_Data *sd)
622 {
623    char *p, *pd;
624    char *d = strdup(sd->shot.info);
625
626    if (!d) return 0.5;
627    for (p = (char *)sd->shot.info; *p; p++)
628      {
629         if (!strncmp(p, "delay=", 6))
630           {
631              double v;
632
633              for (pd = d, p += 6; (*p) && (*p != ':'); p++, pd++)
634                {
635                   *pd = *p;
636                }
637              *pd = 0;
638              v = _elm_atof(d);
639              free(d);
640              return v;
641           }
642      }
643    free(d);
644
645    return 0.5;
646 }
647
648 static char *
649 _shot_file_get(Elm_Win_Data *sd)
650 {
651    char *p;
652    char *tmp = strdup(sd->shot.info);
653    char *repname = NULL;
654
655    if (!tmp) return NULL;
656
657    for (p = (char *)sd->shot.info; *p; p++)
658      {
659         if (!strncmp(p, "file=", 5))
660           {
661              strcpy(tmp, p + 5);
662              if (!sd->shot.repeat_count) return tmp;
663              else
664                {
665                   char *dotptr = strrchr(tmp, '.');
666                   if (dotptr)
667                     {
668                        size_t size = sizeof(char) * (strlen(tmp) + 16);
669                        repname = malloc(size);
670                        if (repname)
671                          {
672                             strncpy(repname, tmp, dotptr - tmp);
673                             snprintf(repname + (dotptr - tmp), size -
674                                      (dotptr - tmp), "%03i",
675                                      sd->shot.shot_counter + 1);
676                             strcat(repname, dotptr);
677                          }
678                        free(tmp);
679                        return repname;
680                     }
681                }
682           }
683      }
684    free(tmp);
685    if (!sd->shot.repeat_count) return strdup("out.png");
686
687    repname = malloc(sizeof(char) * 24);
688    if (!repname) return NULL;
689    snprintf(repname, sizeof(char) * 24, "out%03i.png",
690             sd->shot.shot_counter + 1);
691
692    return repname;
693 }
694
695 static int
696 _shot_repeat_count_get(Elm_Win_Data *sd)
697 {
698    char *p, *pd;
699    char *d = strdup(sd->shot.info);
700
701    if (!d) return 0;
702    for (p = (char *)sd->shot.info; *p; p++)
703      {
704         if (!strncmp(p, "repeat=", 7))
705           {
706              int v;
707
708              for (pd = d, p += 7; (*p) && (*p != ':'); p++, pd++)
709                {
710                   *pd = *p;
711                }
712              *pd = 0;
713              v = atoi(d);
714              if (v < 0) v = 0;
715              if (v > 1000) v = 999;
716              free(d);
717              return v;
718           }
719      }
720    free(d);
721
722    return 0;
723 }
724
725 static char *
726 _shot_key_get(Elm_Win_Data *sd EINA_UNUSED)
727 {
728    return NULL;
729 }
730
731 static char *
732 _shot_flags_get(Elm_Win_Data *sd EINA_UNUSED)
733 {
734    return NULL;
735 }
736
737 static void
738 _shot_do(Elm_Win_Data *sd)
739 {
740    Ecore_Evas *ee;
741    Evas_Object *o;
742    unsigned int *pixels;
743    int w, h;
744    char *file, *key, *flags;
745
746    ecore_evas_manual_render(sd->ee);
747    pixels = (void *)ecore_evas_buffer_pixels_get(sd->ee);
748    if (!pixels) return;
749
750    ecore_evas_geometry_get(sd->ee, NULL, NULL, &w, &h);
751    if ((w < 1) || (h < 1)) return;
752
753    file = _shot_file_get(sd);
754    if (!file) return;
755
756    key = _shot_key_get(sd);
757    flags = _shot_flags_get(sd);
758    ee = ecore_evas_buffer_new(1, 1);
759    o = evas_object_image_add(ecore_evas_get(ee));
760    evas_object_image_alpha_set(o,
761                                sd->theme_alpha | sd->application_alpha);
762    evas_object_image_size_set(o, w, h);
763    evas_object_image_data_set(o, pixels);
764    if (!evas_object_image_save(o, file, key, flags))
765      {
766         ERR("Cannot save window to '%s' (key '%s', flags '%s')",
767             file, key, flags);
768      }
769    free(file);
770    free(key);
771    free(flags);
772    ecore_evas_free(ee);
773    if (sd->shot.repeat_count) sd->shot.shot_counter++;
774 }
775
776 static Eina_Bool
777 _shot_delay(void *data)
778 {
779    ELM_WIN_DATA_GET(data, sd);
780
781    _shot_do(sd);
782    if (sd->shot.repeat_count)
783      {
784         int remainshot = (sd->shot.repeat_count - sd->shot.shot_counter);
785         if (remainshot > 0) return EINA_TRUE;
786      }
787    sd->shot.timer = NULL;
788    elm_exit();
789
790    return EINA_FALSE;
791 }
792
793 static void
794 _shot_init(Elm_Win_Data *sd)
795 {
796    if (!sd->shot.info) return;
797
798    sd->shot.repeat_count = _shot_repeat_count_get(sd);
799    sd->shot.shot_counter = 0;
800 }
801
802 static void
803 _shot_handle(Elm_Win_Data *sd)
804 {
805    if (!sd->shot.info) return;
806
807    if (!sd->shot.timer)
808      sd->shot.timer = ecore_timer_add(_shot_delay_get(sd), _shot_delay,
809                                       sd->obj);
810 }
811
812 /* elm-win specific associate, does the trap while ecore_evas_object_associate()
813  * does not.
814  */
815 static Elm_Win_Data *
816 _elm_win_associate_get(const Ecore_Evas *ee)
817 {
818    Evas_Object *obj = ecore_evas_data_get(ee, "elm_win");
819    if (!obj) return NULL;
820    ELM_WIN_DATA_GET(obj, sd);
821    return sd;
822 }
823
824 /* Interceptors Callbacks */
825 static void
826 _elm_win_obj_intercept_raise(void *data, Evas_Object *obj EINA_UNUSED)
827 {
828    ELM_WIN_DATA_GET(data, sd);
829    TRAP(sd, raise);
830 }
831
832 static void
833 _elm_win_obj_intercept_lower(void *data, Evas_Object *obj EINA_UNUSED)
834 {
835    ELM_WIN_DATA_GET(data, sd);
836    TRAP(sd, lower);
837 }
838
839 static void
840 _elm_win_obj_intercept_stack_above(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, Evas_Object *above EINA_UNUSED)
841 {
842    INF("TODO: %s", __FUNCTION__);
843 }
844
845 static void
846 _elm_win_obj_intercept_stack_below(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, Evas_Object *below EINA_UNUSED)
847 {
848    INF("TODO: %s", __FUNCTION__);
849 }
850
851 static void
852 _elm_win_obj_intercept_layer_set(void *data, Evas_Object *obj EINA_UNUSED, int l)
853 {
854    ELM_WIN_DATA_GET(data, sd);
855    TRAP(sd, layer_set, l);
856 }
857
858 /* Event Callbacks */
859
860 static void
861 _elm_win_obj_callback_changed_size_hints(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
862 {
863    ELM_WIN_DATA_GET(data, sd);
864    Evas_Coord w, h;
865
866    evas_object_size_hint_min_get(obj, &w, &h);
867    TRAP(sd, size_min_set, w, h);
868
869    evas_object_size_hint_max_get(obj, &w, &h);
870    if (w < 1) w = -1;
871    if (h < 1) h = -1;
872    TRAP(sd, size_max_set, w, h);
873 }
874 /* end of elm-win specific associate */
875
876 static void
877 _elm_win_move(Ecore_Evas *ee)
878 {
879    Elm_Win_Data *sd = _elm_win_associate_get(ee);
880    int x, y;
881
882    if (!sd) return;
883
884    ecore_evas_geometry_get(ee, &x, &y, NULL, NULL);
885    sd->screen.x = x;
886    sd->screen.y = y;
887    eo_do(sd->obj, eo_event_callback_call(ELM_WIN_EVENT_MOVED, NULL));
888    evas_nochange_push(evas_object_evas_get(sd->obj));
889    evas_object_move(sd->obj, x, y);
890    evas_nochange_pop(evas_object_evas_get(sd->obj));
891 }
892
893 static void
894 _elm_win_resize_job(void *data)
895 {
896    ELM_WIN_DATA_GET(data, sd);
897    int x, y, w, h;
898
899    sd->deferred_resize_job = NULL;
900    ecore_evas_request_geometry_get(sd->ee, &x, &y, &w, &h);
901    if (sd->constrain)
902      {
903         int sw, sh;
904         ecore_evas_screen_geometry_get(sd->ee, NULL, NULL, &sw, &sh);
905         w = MIN(w, sw);
906         h = MIN(h, sh);
907      }
908
909    if (sd->frame_obj)
910      {
911         int fx, fy, fw, fh;
912
913         evas_output_framespace_get(sd->evas, &fx, &fy, &fw, &fh);
914         evas_object_move(sd->frame_obj, -fx, -fy);
915         evas_object_resize(sd->frame_obj, w + fw, h + fh);
916      }
917
918    evas_object_resize(sd->obj, w, h);
919    evas_object_resize(sd->edje, w, h);
920
921 #ifdef HAVE_ELEMENTARY_WAYLAND
922    ecore_wl_window_opaque_region_set(sd->wl.win, x, y, w, h);
923 #endif
924 }
925
926 static void
927 _elm_win_resize(Ecore_Evas *ee)
928 {
929    Elm_Win_Data *sd = _elm_win_associate_get(ee);
930    if (!sd) return;
931
932    ecore_job_del(sd->deferred_resize_job);
933    sd->deferred_resize_job = ecore_job_add(_elm_win_resize_job, sd->obj);
934 }
935
936 static void
937 _elm_win_mouse_in(Ecore_Evas *ee)
938 {
939    Elm_Win_Data *sd = _elm_win_associate_get(ee);
940    if (!sd) return;
941
942    _elm_win_throttle_ok = EINA_TRUE;
943    if (sd->resizing) sd->resizing = EINA_FALSE;
944 }
945
946 static void
947 _elm_win_focus_highlight_reconfigure_job_stop(Elm_Win_Data *sd)
948 {
949    ELM_SAFE_FREE(sd->focus_highlight.reconf_job, ecore_job_del);
950 }
951
952 static void
953 _elm_win_accessibility_highlight_visible_set(Elm_Win_Data *sd,
954                                      Eina_Bool visible)
955 {
956    Evas_Object *fobj = sd->accessibility_highlight.fobj;
957
958    if (!fobj)
959      return;
960
961    if (visible)
962      {
963         evas_object_show(fobj);
964      }
965    else
966      {
967         evas_object_smart_member_del(fobj);
968         evas_object_hide(fobj);
969         evas_object_del(fobj);
970      }
971 }
972
973 static void
974 _elm_win_focus_highlight_visible_set(Elm_Win_Data *sd,
975                                      Eina_Bool visible)
976 {
977    Evas_Object *fobj = sd->focus_highlight.fobj;
978    if (!fobj) return;
979
980    if (visible)
981      {
982         evas_object_show(fobj);
983         edje_object_signal_emit(fobj, "elm,action,focus,show", "elm");
984      }
985    else
986      {
987         edje_object_signal_emit(fobj, "elm,action,focus,hide", "elm");
988      }
989 }
990
991 Evas_Object *
992 _elm_win_focus_highlight_object_get(Evas_Object *obj)
993 {
994    ELM_WIN_DATA_GET(obj, sd);
995
996    return sd->focus_highlight.fobj;
997 }
998
999 static void
1000 _elm_win_focus_highlight_anim_setup(Elm_Win_Data *sd,
1001                                     Evas_Object *obj)
1002 {
1003    Evas_Coord tx, ty, tw, th;
1004    Evas_Coord px, py, pw, ph;
1005    Edje_Message_Int_Set *m;
1006    Evas_Object *target = sd->focus_highlight.cur.target;
1007
1008    evas_object_geometry_get(obj, &px, &py, &pw, &ph);
1009    elm_widget_focus_highlight_geometry_get(target, &tx, &ty, &tw, &th);
1010    evas_object_move(obj, tx, ty);
1011    evas_object_resize(obj, tw, th);
1012
1013    if ((px == tx) && (py == ty) && (pw == tw) && (ph == th)) return;
1014
1015    if (!_elm_config->focus_highlight_clip_disable)
1016      evas_object_clip_unset(obj);
1017
1018    m = alloca(sizeof(*m) + (sizeof(int) * 8));
1019    m->count = 8;
1020    m->val[0] = px - tx;
1021    m->val[1] = py - ty;
1022    m->val[2] = pw;
1023    m->val[3] = ph;
1024    m->val[4] = 0;
1025    m->val[5] = 0;
1026    m->val[6] = tw;
1027    m->val[7] = th;
1028    edje_object_message_send(obj, EDJE_MESSAGE_INT_SET, 1, m);
1029 }
1030
1031 // TIZEN_ONLY(20180326) : Atspi: enhance finding next and prev item on screen's edge
1032 EAPI Eina_Bool
1033 _elm_win_accessibility_parent_is_item(Evas_Object *obj)
1034 {
1035    Evas_Object *parent;
1036    eo_do(obj, parent = elm_interface_atspi_accessible_parent_get());
1037    while (parent)
1038      {
1039         if (eo_isa(parent, ELM_WIDGET_ITEM_CLASS)) return EINA_TRUE;
1040         eo_do(parent, parent = elm_interface_atspi_accessible_parent_get());
1041      }
1042    return EINA_FALSE;
1043 }
1044 //
1045
1046 static void
1047 _elm_win_accessibility_highlight_simple_setup(Elm_Win_Data *sd,
1048                                       Evas_Object *obj)
1049 {
1050    Evas_Object *target = sd->accessibility_highlight.cur.target;
1051    Evas_Coord x, y, w, h;
1052    //TIZEN_ONLY(20160623): atspi: moved highlight when object is out of screen
1053    Evas_Coord ox, oy;
1054    Elm_Atspi_Role role;
1055    //
1056
1057    _elm_widget_showing_geometry_get(target, &x, &y, &w, &h);
1058
1059    //TIZEN_ONLY(20160623): atspi: moved highlight when object is out of screen
1060    evas_object_geometry_get(target, &ox, &oy, NULL, NULL);
1061
1062    //TIZEN_ONLY(20171011) : atspi : During the highlight grab, out signal is not sent.
1063    if (!_elm_widget_accessibility_highlight_grabbing_get(target))
1064    //
1065      {
1066         if (((w < 0 && ox > sd->accessibility_highlight.cur.x) || (h < 0 && oy < sd->accessibility_highlight.cur.y))
1067           && sd->accessibility_highlight.cur.need_moved
1068           && eo_isa(target, ELM_INTERFACE_ATSPI_ACCESSIBLE_MIXIN))
1069           {
1070              eo_do(target, role = elm_interface_atspi_accessible_role_get());
1071              if (role && role != ELM_ATSPI_ROLE_MENU_ITEM && role != ELM_ATSPI_ROLE_LIST_ITEM
1072                  // TIZEN_ONLY(20180326) : Atspi: enhance finding next and prev item on screen's edge
1073                  && ! _elm_win_accessibility_parent_is_item(target))
1074                  //
1075                {
1076                   elm_interface_atspi_accessible_move_outed_signal_emit(target, ELM_ATSPI_MOVE_OUTED_TOP_LEFT);
1077                   sd->accessibility_highlight.cur.need_moved = EINA_FALSE;
1078                   return ;
1079                }
1080           }
1081         else if (((w < 0 && ox < sd->accessibility_highlight.cur.x) || (h < 0 && oy > sd->accessibility_highlight.cur.y))
1082                 && sd->accessibility_highlight.cur.need_moved
1083                 && eo_isa(target, ELM_INTERFACE_ATSPI_ACCESSIBLE_MIXIN))
1084           {
1085              eo_do(target, role = elm_interface_atspi_accessible_role_get());
1086              if (role && role != ELM_ATSPI_ROLE_MENU_ITEM && role != ELM_ATSPI_ROLE_LIST_ITEM
1087                  // TIZEN_ONLY(20180326) : Atspi: enhance finding next and prev item on screen's edge
1088                  && ! _elm_win_accessibility_parent_is_item(target))
1089                  //
1090                {
1091                   elm_interface_atspi_accessible_move_outed_signal_emit(target, ELM_ATSPI_MOVE_OUTED_BOTTOM_RIGHT);
1092                   sd->accessibility_highlight.cur.need_moved = EINA_FALSE;
1093                   return ;
1094                }
1095           }
1096      }
1097    //
1098
1099    evas_object_move(obj, x, y);
1100    evas_object_resize(obj, w, h);
1101
1102    //TIZEN_ONLY(20160623): atspi: moved highlight when object is out of screen
1103    sd->accessibility_highlight.cur.x = ox;
1104    sd->accessibility_highlight.cur.y = oy;
1105    //
1106 }
1107
1108 static void
1109 _elm_win_focus_highlight_simple_setup(Elm_Win_Data *sd,
1110                                       Evas_Object *obj)
1111 {
1112    Evas_Object *clip, *target = sd->focus_highlight.cur.target;
1113    Evas_Coord x, y, w, h;
1114
1115    elm_widget_focus_highlight_geometry_get(target, &x, &y, &w, &h);
1116
1117    evas_object_move(obj, x, y);
1118    evas_object_resize(obj, w, h);
1119
1120    if (!_elm_config->focus_highlight_clip_disable)
1121      {
1122         clip = evas_object_clip_get(target);
1123         if (clip) evas_object_clip_set(obj, clip);
1124      }
1125
1126    edje_object_signal_emit(obj, "elm,state,anim,stop", "elm");
1127 }
1128
1129 static void
1130 _elm_win_focus_prev_target_del(void *data,
1131                                Evas *e EINA_UNUSED,
1132                                Evas_Object *obj EINA_UNUSED,
1133                                void *event_info EINA_UNUSED)
1134 {
1135    ELM_WIN_DATA_GET(data, sd);
1136    sd->focus_highlight.prev.target = NULL;
1137 }
1138
1139 static void
1140 _elm_win_accessibility_highlight_hide(void *data)
1141 {
1142    ELM_WIN_DATA_GET(data, sd);
1143    _elm_win_accessibility_highlight_visible_set(sd, EINA_FALSE);
1144 }
1145
1146 static void
1147 _elm_win_accessibility_highlight_show(void *data)
1148 {
1149    ELM_WIN_DATA_GET(data, sd);
1150    Evas_Object *fobj = sd->accessibility_highlight.fobj;
1151    _elm_win_accessibility_highlight_simple_setup(sd, fobj);
1152    _elm_win_accessibility_highlight_visible_set(sd, EINA_TRUE);
1153 }
1154
1155
1156 static void
1157 _elm_win_focus_highlight_reconfigure_job(void *data)
1158 {
1159    ELM_WIN_DATA_GET(data, sd);
1160    Evas_Object *target = sd->focus_highlight.cur.target;
1161    Evas_Object *previous = sd->focus_highlight.prev.target;
1162    Evas_Object *fobj = sd->focus_highlight.fobj;
1163    Eina_Bool visible_changed;
1164    Eina_Bool common_visible;
1165    const char *sig = NULL;
1166    const char *focus_style_target = NULL;
1167    const char *focus_style_previous = NULL;
1168
1169    _elm_win_focus_highlight_reconfigure_job_stop(sd);
1170
1171    visible_changed = (sd->focus_highlight.cur.visible !=
1172                       sd->focus_highlight.prev.visible);
1173
1174    if ((target == previous) && (!visible_changed) &&
1175        (!sd->focus_highlight.geometry_changed) &&
1176        (!sd->focus_highlight.theme_changed))
1177      return;
1178
1179    if (previous)
1180      {
1181         evas_object_event_callback_del_full
1182            (previous, EVAS_CALLBACK_DEL, _elm_win_focus_prev_target_del, data);
1183         if (sd->focus_highlight.prev.in_theme)
1184           elm_widget_signal_emit
1185              (previous, "elm,action,focus_highlight,hide", "elm");
1186      }
1187
1188    if (!target)
1189      common_visible = EINA_FALSE;
1190    else if (sd->focus_highlight.cur.in_theme)
1191      {
1192         common_visible = EINA_FALSE;
1193         if (sd->focus_highlight.cur.visible)
1194           sig = "elm,action,focus_highlight,show";
1195         else
1196           sig = "elm,action,focus_highlight,hide";
1197      }
1198    else
1199      common_visible = sd->focus_highlight.cur.visible;
1200
1201    if (sig)
1202      elm_widget_signal_emit(target, sig, "elm");
1203
1204    if ((!target) || (!common_visible) || (sd->focus_highlight.cur.in_theme))
1205      {
1206         if (target)
1207           _elm_win_focus_highlight_simple_setup(sd, fobj);
1208         goto the_end;
1209      }
1210
1211    if (previous)
1212      focus_style_previous = elm_widget_focus_highlight_style_get(previous);
1213    focus_style_target = elm_widget_focus_highlight_style_get(target);
1214
1215    if (sd->focus_highlight.theme_changed ||
1216        (focus_style_target != focus_style_previous))
1217      {
1218         const char *str;
1219
1220         if (focus_style_target)
1221           str = focus_style_target;
1222         else if (sd->focus_highlight.style)
1223           str = sd->focus_highlight.style;
1224         else
1225           str = "default";
1226
1227         elm_widget_theme_object_set
1228           (sd->obj, fobj, "focus_highlight", "top", str);
1229         sd->focus_highlight.theme_changed = EINA_FALSE;
1230
1231         if ((sd->focus_highlight.animate) || (sd->focus_highlight.auto_animate))
1232           {
1233              str = edje_object_data_get(sd->focus_highlight.fobj, "animate");
1234              sd->focus_highlight.animate_supported = ((str) && (!strcmp(str, "on")));
1235           }
1236         else
1237           sd->focus_highlight.animate_supported = EINA_FALSE;
1238      }
1239
1240    if ((sd->focus_highlight.animate_supported) && (previous) &&
1241        (!sd->focus_highlight.prev.in_theme))
1242      _elm_win_focus_highlight_anim_setup(sd, fobj);
1243    else
1244      _elm_win_focus_highlight_simple_setup(sd, fobj);
1245    evas_object_raise(fobj);
1246
1247 the_end:
1248    _elm_win_focus_highlight_visible_set(sd, common_visible);
1249    sd->focus_highlight.geometry_changed = EINA_FALSE;
1250    sd->focus_highlight.prev = sd->focus_highlight.cur;
1251    evas_object_event_callback_add
1252      (sd->focus_highlight.prev.target,
1253       EVAS_CALLBACK_DEL, _elm_win_focus_prev_target_del, data);
1254 }
1255
1256 static void
1257 _elm_win_focus_highlight_reconfigure_job_start(Elm_Win_Data *sd)
1258 {
1259    ecore_job_del(sd->focus_highlight.reconf_job);
1260
1261    sd->focus_highlight.reconf_job = ecore_job_add(
1262        _elm_win_focus_highlight_reconfigure_job, sd->obj);
1263 }
1264
1265 static void
1266 _elm_win_focus_in(Ecore_Evas *ee)
1267 {
1268    Elm_Win_Data *sd = _elm_win_associate_get(ee);
1269    Evas_Object *obj;
1270
1271    if ((!sd) || (sd->modal_count)) return;
1272
1273    _elm_win_throttle_ok = EINA_TRUE;
1274    obj = sd->obj;
1275
1276    _elm_widget_top_win_focused_set(obj, EINA_TRUE);
1277    if (sd->type != ELM_WIN_FAKE)
1278      {
1279         if (!elm_widget_focus_order_get(obj))
1280           {
1281              elm_widget_focus_steal(obj, NULL);
1282           }
1283         else
1284           {
1285              Evas_Object *newest = NULL;
1286              unsigned int newest_focus_order = 0;
1287
1288              newest = elm_widget_newest_focus_order_get
1289                (obj, &newest_focus_order, EINA_TRUE);
1290              // TIZEN_ONLY(20161118): onscreen_is should not be checked
1291              //                       to keep compatibility with Tizen 2.4
1292              /*
1293              if ((newest) &&
1294                  (_elm_widget_onscreen_is(newest) || (newest == obj)))
1295                elm_widget_focus_restore(obj);
1296              */
1297              if (newest) elm_widget_focus_restore(obj);
1298              /////////////////////////////////////////////////////////
1299              else
1300                evas_object_focus_set(obj, EINA_TRUE);
1301           }
1302      }
1303    // FIXME: the event is deprecated but still in use.
1304    // Has to be removed in EFL2.0
1305    evas_object_smart_callback_call(obj, SIG_FOCUS_IN, NULL);
1306    sd->focus_highlight.cur.visible = EINA_TRUE;
1307    _elm_win_focus_highlight_reconfigure_job_start(sd);
1308    if (sd->frame_obj)
1309      {
1310         edje_object_signal_emit(sd->frame_obj, "elm,action,focus", "elm");
1311      }
1312
1313    if (_elm_atspi_enabled())
1314      {
1315         elm_interface_atspi_window_activated_signal_emit(obj);
1316         elm_interface_atspi_accessible_state_changed_signal_emit(obj, ELM_ATSPI_STATE_ACTIVE, EINA_TRUE);
1317      }
1318
1319    /* do nothing */
1320    /* else if (sd->img_obj) */
1321    /*   { */
1322    /*   } */
1323 }
1324
1325 static void
1326 _elm_win_focus_out(Ecore_Evas *ee)
1327 {
1328    Elm_Win_Data *sd = _elm_win_associate_get(ee);
1329    Evas_Object *obj;
1330
1331    if (!sd) return;
1332
1333    obj = sd->obj;
1334
1335    _elm_widget_top_win_focused_set(obj, EINA_FALSE);
1336    // FIXME: the event is deprecated but still in use.
1337    // Has to be removed in EFL2.0
1338    evas_object_smart_callback_call(obj, SIG_FOCUS_OUT, NULL);
1339    sd->focus_highlight.cur.visible = EINA_FALSE;
1340    _elm_win_focus_highlight_reconfigure_job_start(sd);
1341    if (sd->frame_obj)
1342      {
1343         edje_object_signal_emit(sd->frame_obj, "elm,action,unfocus", "elm");
1344      }
1345
1346    /* access */
1347    _elm_access_object_highlight_disable(evas_object_evas_get(obj));
1348
1349    if (_elm_atspi_enabled())
1350      {
1351         elm_interface_atspi_window_deactivated_signal_emit(obj);
1352         elm_interface_atspi_accessible_state_changed_signal_emit(obj, ELM_ATSPI_STATE_ACTIVE, EINA_FALSE);
1353      }
1354
1355    /* do nothing */
1356    /* if (sd->img_obj) */
1357    /*   { */
1358    /*   } */
1359 }
1360
1361 static void
1362 _elm_win_available_profiles_del(Elm_Win_Data *sd)
1363 {
1364    if (!sd->profile.available_list) return;
1365
1366    unsigned int i;
1367    for (i = 0; i < sd->profile.count; i++)
1368      ELM_SAFE_FREE(sd->profile.available_list[i], eina_stringshare_del);
1369    sd->profile.count = 0;
1370    ELM_SAFE_FREE(sd->profile.available_list, free);
1371 }
1372
1373 static void
1374 _elm_win_profile_del(Elm_Win_Data *sd)
1375 {
1376    ELM_SAFE_FREE(sd->profile.name, eina_stringshare_del);
1377 }
1378
1379 static Eina_Bool
1380 _internal_elm_win_profile_set(Elm_Win_Data *sd, const char *profile)
1381 {
1382    Eina_Bool changed = EINA_FALSE;
1383    if (profile)
1384      {
1385         if (sd->profile.name)
1386           {
1387              if (strcmp(sd->profile.name, profile) != 0)
1388                {
1389                   eina_stringshare_replace(&(sd->profile.name), profile);
1390                   changed = EINA_TRUE;
1391                }
1392           }
1393         else
1394           {
1395              sd->profile.name = eina_stringshare_add(profile);
1396              changed = EINA_TRUE;
1397           }
1398      }
1399    else
1400      _elm_win_profile_del(sd);
1401
1402    return changed;
1403 }
1404
1405 static void
1406 _elm_win_profile_update(Elm_Win_Data *sd)
1407 {
1408    if (getenv("ELM_PROFILE")) return;
1409
1410    if (sd->profile.available_list)
1411      {
1412         Eina_Bool found = EINA_FALSE;
1413         if (sd->profile.name)
1414           {
1415              unsigned int i;
1416              for (i = 0; i < sd->profile.count; i++)
1417                {
1418                   if (!strcmp(sd->profile.name,
1419                               sd->profile.available_list[i]))
1420                     {
1421                        found = EINA_TRUE;
1422                        break;
1423                     }
1424                }
1425           }
1426
1427         /* If current profile is not present in an available profiles,
1428          * change current profile to the 1st element of an array.
1429          */
1430         if (!found)
1431           _internal_elm_win_profile_set(sd, sd->profile.available_list[0]);
1432      }
1433
1434    _config_profile_lock = EINA_TRUE;
1435    _elm_config_profile_set(sd->profile.name);
1436
1437    /* update sub ee */
1438    Ecore_Evas *ee2;
1439    Eina_List *sub, *l = NULL;
1440
1441    sub = ecore_evas_sub_ecore_evas_list_get(sd->ee);
1442    EINA_LIST_FOREACH(sub, l, ee2)
1443      ecore_evas_window_profile_set(ee2, sd->profile.name);
1444
1445    eo_do(sd->obj, eo_event_callback_call(ELM_WIN_EVENT_PROFILE_CHANGED, NULL));
1446 }
1447
1448 #ifdef HAVE_ELEMENTARY_WAYLAND
1449 static void
1450 _elm_win_opaque_update(Elm_Win_Data *sd)
1451 {
1452    int ox = 0, oy = 0, ow = 0, oh = 0;
1453
1454    if (sd->fullscreen)
1455      {
1456         ecore_evas_geometry_get(sd->ee, NULL, NULL, &ow, &oh);
1457         ecore_wl_window_opaque_region_set(sd->wl.win, 0, 0, ow, oh);
1458         ecore_wl_window_update_location(sd->wl.win, 0, 0);
1459         return;
1460      }
1461
1462    if (sd->frame_obj)
1463      edje_object_part_geometry_get(sd->frame_obj, "elm.spacer.opaque",
1464                                    &ox, &oy, &ow, &oh);
1465    ecore_wl_window_opaque_region_set(sd->wl.win, ox, oy, ow, oh);
1466    ecore_wl_window_update_location(sd->wl.win, sd->screen.x + ox, sd->screen.y + oy);
1467 }
1468 #endif
1469
1470 static void
1471 _elm_win_frame_obj_update(Elm_Win_Data *sd)
1472 {
1473    int fx = 0, fy = 0, fw = 0, fh = 0;
1474    int ox = 0, oy = 0, ow = 0, oh = 0;
1475
1476 #ifdef HAVE_ELEMENTARY_WAYLAND
1477    sd->wl.opaque_dirty = 1;
1478 #endif
1479    if (sd->fullscreen || !sd->frame_obj)
1480      {
1481         evas_output_framespace_set(sd->evas, 0, 0, 0, 0);
1482         return;
1483      }
1484
1485    evas_object_geometry_get(sd->frame_obj, &fx, &fy, &fw, &fh);
1486    evas_object_geometry_get(sd->client_obj, &ox, &oy, &ow, &oh);
1487
1488    evas_output_framespace_set(sd->evas, (ox - fx), (oy - fy), (fw - ow), (fh - oh));
1489 }
1490
1491 static void
1492 _elm_win_state_change(Ecore_Evas *ee)
1493 {
1494    Elm_Win_Data *sd = _elm_win_associate_get(ee);
1495    Evas_Object *obj;
1496    int w, h;
1497    Eina_Bool ch_withdrawn = EINA_FALSE;
1498    Eina_Bool ch_sticky = EINA_FALSE;
1499    Eina_Bool ch_iconified = EINA_FALSE;
1500    Eina_Bool ch_fullscreen = EINA_FALSE;
1501    Eina_Bool ch_maximized = EINA_FALSE;
1502    Eina_Bool ch_profile = EINA_FALSE;
1503    Eina_Bool ch_wm_rotation = EINA_FALSE;
1504 #ifdef HAVE_ELEMENTARY_WAYLAND
1505    Eina_Bool ch_conformant  = EINA_FALSE;
1506 #endif
1507    Eina_Bool ch_visibility = EINA_FALSE;
1508    Eina_Bool ch_aux_hint = EINA_FALSE;
1509    Eina_List *aux_hints = NULL;
1510    const char *profile;
1511 #ifdef HAVE_ELEMENTARY_WAYLAND
1512    Conformant_Property property = CONFORMANT_DEFAULT; //TIZEN_ONLY(20160330): add processing properties of window
1513 #endif
1514
1515    if (!sd) return;
1516
1517    obj = sd->obj;
1518
1519    if (sd->withdrawn != ecore_evas_withdrawn_get(sd->ee))
1520      {
1521         sd->withdrawn = ecore_evas_withdrawn_get(sd->ee);
1522         ch_withdrawn = EINA_TRUE;
1523      }
1524    if (sd->sticky != ecore_evas_sticky_get(sd->ee))
1525      {
1526         sd->sticky = ecore_evas_sticky_get(sd->ee);
1527         ch_sticky = EINA_TRUE;
1528      }
1529    if (sd->iconified != ecore_evas_iconified_get(sd->ee))
1530      {
1531         sd->iconified = ecore_evas_iconified_get(sd->ee);
1532         ch_iconified = EINA_TRUE;
1533      }
1534    if (sd->fullscreen != ecore_evas_fullscreen_get(sd->ee))
1535      {
1536         sd->fullscreen = ecore_evas_fullscreen_get(sd->ee);
1537         ch_fullscreen = EINA_TRUE;
1538      }
1539    if (sd->maximized != ecore_evas_maximized_get(sd->ee))
1540      {
1541         sd->maximized = ecore_evas_maximized_get(sd->ee);
1542         ch_maximized = EINA_TRUE;
1543      }
1544
1545    if (ecore_evas_window_profile_supported_get(sd->ee))
1546      {
1547         profile = ecore_evas_window_profile_get(sd->ee);
1548         ch_profile = _internal_elm_win_profile_set(sd, profile);
1549      }
1550
1551    if (sd->wm_rot.use)
1552      {
1553         if (sd->rot != ecore_evas_rotation_get(sd->ee))
1554           {
1555              sd->rot = ecore_evas_rotation_get(sd->ee);
1556              ch_wm_rotation = EINA_TRUE;
1557           }
1558      }
1559
1560    if (sd->obscured != ecore_evas_obscured_get(sd->ee))
1561      {
1562         sd->obscured = ecore_evas_obscured_get(sd->ee);
1563         ch_visibility = EINA_TRUE;
1564      }
1565
1566    aux_hints = ecore_evas_aux_hints_allowed_get(sd->ee);
1567    if (aux_hints)
1568      {
1569         ch_aux_hint = EINA_TRUE;
1570      }
1571
1572 #ifdef HAVE_ELEMENTARY_WAYLAND
1573    int x = 0, y = 0;
1574    if (sd->indmode != (Elm_Win_Indicator_Mode)ecore_wl_window_indicator_state_get(sd->wl.win))
1575      {
1576         sd->indmode = (Elm_Win_Indicator_Mode)ecore_wl_window_indicator_state_get(sd->wl.win);
1577         ch_conformant = EINA_TRUE;
1578         property |= CONFORMANT_INDICATOR_STATE; //TIZEN_ONLY(20160330): add processing properties of window
1579
1580      }
1581    if (sd->kbdmode != (Elm_Win_Keyboard_Mode)ecore_wl_window_keyboard_state_get(sd->wl.win))
1582      {
1583         sd->kbdmode = (Elm_Win_Keyboard_Mode)ecore_wl_window_keyboard_state_get(sd->wl.win);
1584         ch_conformant = EINA_TRUE;
1585         property |= CONFORMANT_KEYBOARD_STATE; //TIZEN_ONLY(20160330): add processing properties of window
1586
1587      }
1588    if (ecore_wl_window_indicator_geometry_get(sd->wl.win, &x, &y, &w, &h))
1589      {
1590         if ((sd->ind.x != x) || (sd->ind.y != y) || (sd->ind.w != w) || (sd->ind.h != h))
1591           {
1592              sd->ind.x = x;
1593              sd->ind.y = y;
1594              sd->ind.w = w;
1595              sd->ind.h = h;
1596              ch_conformant  = EINA_TRUE;
1597              property |= CONFORMANT_INDICATOR_GEOMETRY; //TIZEN_ONLY(20160330): add processing properties of window
1598
1599           }
1600      }
1601    if (ecore_wl_window_keyboard_geometry_get(sd->wl.win, &x, &y, &w, &h))
1602      {
1603         if ((sd->kbd.x != x) || (sd->kbd.y != y) || (sd->kbd.w != w) || (sd->kbd.h != h))
1604           {
1605              sd->kbd.x = x;
1606              sd->kbd.y = y;
1607              sd->kbd.w = w;
1608              sd->kbd.h = h;
1609              ch_conformant  = EINA_TRUE;
1610              property |= CONFORMANT_KEYBOARD_GEOMETRY; //TIZEN_ONLY(20160330): add processing properties of window
1611
1612           }
1613      }
1614 #endif
1615
1616    _elm_win_state_eval_queue();
1617
1618    if ((ch_withdrawn) || (ch_iconified))
1619      {
1620         if (sd->withdrawn)
1621           eo_do(obj, eo_event_callback_call(ELM_WIN_EVENT_WITHDRAWN, NULL));
1622         else if (sd->iconified)
1623           {
1624              eo_do(obj, eo_event_callback_call(ELM_WIN_EVENT_ICONIFIED, NULL));
1625              if (_elm_atspi_enabled())
1626                elm_interface_atspi_window_minimized_signal_emit(obj);
1627           }
1628         else
1629           {
1630              eo_do(obj, eo_event_callback_call(ELM_WIN_EVENT_NORMAL, NULL));
1631              if (_elm_atspi_enabled())
1632                elm_interface_atspi_window_restored_signal_emit(obj);
1633           }
1634      }
1635    if (ch_sticky)
1636      {
1637         if (sd->sticky)
1638           eo_do(obj, eo_event_callback_call(ELM_WIN_EVENT_STICK, NULL));
1639         else
1640           eo_do(obj, eo_event_callback_call(ELM_WIN_EVENT_UNSTICK, NULL));
1641      }
1642    if (ch_fullscreen)
1643      {
1644         _elm_win_frame_obj_update(sd);
1645         if (sd->fullscreen)
1646           {
1647              eo_do(obj, eo_event_callback_call
1648                (ELM_WIN_EVENT_FULLSCREEN, NULL));
1649              if (sd->frame_obj)
1650                evas_object_hide(sd->frame_obj);
1651              ecore_evas_geometry_get(sd->ee, NULL, NULL, &w, &h);
1652              ecore_evas_resize(sd->ee, w, h);
1653           }
1654         else
1655           {
1656              eo_do(obj, eo_event_callback_call
1657                (ELM_WIN_EVENT_UNFULLSCREEN, NULL));
1658              if (sd->frame_obj)
1659                evas_object_show(sd->frame_obj);
1660           }
1661      }
1662    if (ch_maximized)
1663      {
1664         if (sd->maximized)
1665           {
1666              eo_do(obj, eo_event_callback_call(ELM_WIN_EVENT_MAXIMIZED, NULL));
1667              if (_elm_atspi_enabled())
1668                elm_interface_atspi_window_maximized_signal_emit(obj);
1669           }
1670         else
1671           {
1672              eo_do(obj, eo_event_callback_call(ELM_WIN_EVENT_UNMAXIMIZED, NULL));
1673              if (_elm_atspi_enabled())
1674                elm_interface_atspi_window_restored_signal_emit(obj);
1675           }
1676      }
1677    if (ch_profile)
1678      {
1679         _elm_win_profile_update(sd);
1680      }
1681    if (ch_wm_rotation)
1682      {
1683         evas_object_size_hint_min_set(obj, -1, -1);
1684         evas_object_size_hint_max_set(obj, -1, -1);
1685 #ifdef HAVE_ELEMENTARY_X
1686         _elm_win_xwin_update(sd);
1687 #endif
1688         elm_widget_orientation_set(obj, sd->rot);
1689
1690         /* if there are deferred resize job, do the job immediately
1691            before calling rotation change callback */
1692         if (sd->deferred_resize_job)
1693           {
1694              ecore_job_del(sd->deferred_resize_job);
1695              sd->deferred_resize_job = NULL;
1696              _elm_win_resize_job(obj);
1697           }
1698
1699         eo_do(obj, eo_event_callback_call
1700           (ELM_WIN_EVENT_ROTATION_CHANGED, NULL));
1701         eo_do(obj, eo_event_callback_call
1702           (ELM_WIN_EVENT_WM_ROTATION_CHANGED, NULL));
1703         //TIZEN_ONLY(20160915): send information to screen reader on window rotation
1704         if (_elm_atspi_enabled())
1705           {
1706              Evas_Coord width = 0, height = 0;
1707              elm_win_screen_size_get(obj, NULL, NULL, &width, &height);
1708              if ((sd->rot == 0) || (sd->rot == 180))
1709                {
1710                   elm_interface_atspi_accessible_bounds_changed_signal_emit(obj, 0, 0, width, height);
1711                }
1712              else
1713                {
1714                   elm_interface_atspi_accessible_bounds_changed_signal_emit(obj, 0, 0, height, width);
1715                }
1716           }
1717           //
1718      }
1719 #ifdef HAVE_ELEMENTARY_WAYLAND
1720    if (ch_conformant)
1721      {
1722         evas_object_smart_callback_call(obj, SIG_CONFORMANT_CHANGED, (void *)property); //TIZEN_ONLY(20160330): add processing properties of window
1723
1724      }
1725 #endif
1726    if (ch_aux_hint)
1727      {
1728         void *id;
1729         Eina_List *l;
1730         EINA_LIST_FOREACH(aux_hints, l, id)
1731           {
1732              evas_object_smart_callback_call(obj, SIG_AUX_HINT_ALLOWED, id);
1733           }
1734         eina_list_free(aux_hints);
1735      }
1736    if (ch_visibility)
1737      {
1738         evas_object_smart_callback_call(obj, SIG_VISIBILITY_CHANGED, (void*)!sd->obscured);
1739         //TIZEN_ONLY(20160701): add atspi window state visible change signal
1740         if (_elm_atspi_enabled())
1741           elm_interface_atspi_accessible_state_changed_signal_emit(obj, ELM_ATSPI_STATE_VISIBLE, !sd->obscured);
1742         //
1743      }
1744 }
1745
1746 EOLIAN static Eina_Bool
1747 _elm_win_elm_widget_focus_next_manager_is(Eo *obj EINA_UNUSED, Elm_Win_Data *_pd EINA_UNUSED)
1748 {
1749    return EINA_TRUE;
1750 }
1751
1752 EOLIAN static Eina_Bool
1753 _elm_win_elm_widget_focus_next(Eo *obj, Elm_Win_Data *_pd EINA_UNUSED, Elm_Focus_Direction dir, Evas_Object **next, Elm_Object_Item **next_item)
1754 {
1755    ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
1756
1757    const Eina_List *items;
1758    void *(*list_data_get)(const Eina_List *list);
1759
1760    /* Focus chain */
1761    if (wd->subobjs)
1762      {
1763         if (!(items = elm_widget_focus_custom_chain_get(obj)))
1764           {
1765              items = wd->subobjs;
1766              if (!items)
1767                return EINA_FALSE;
1768           }
1769         list_data_get = eina_list_data_get;
1770
1771         elm_widget_focus_list_next_get(obj, items, list_data_get, dir, next, next_item);
1772
1773         if (*next) return EINA_TRUE;
1774      }
1775    *next = (Evas_Object *)obj;
1776    return EINA_FALSE;
1777 }
1778
1779 EOLIAN static Eina_Bool
1780 _elm_win_elm_widget_focus_direction_manager_is(Eo *obj EINA_UNUSED, Elm_Win_Data *_pd EINA_UNUSED)
1781 {
1782    return EINA_TRUE;
1783 }
1784
1785 EOLIAN static Eina_Bool
1786 _elm_win_elm_widget_focus_direction(Eo *obj, Elm_Win_Data *_pd EINA_UNUSED, const Evas_Object *base, double degree, Evas_Object **direction, Elm_Object_Item **direction_item, double *weight)
1787 {
1788    const Eina_List *items;
1789    void *(*list_data_get)(const Eina_List *list);
1790
1791    ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
1792
1793    /* Focus chain */
1794    if (wd->subobjs)
1795      {
1796         if (!(items = elm_widget_focus_custom_chain_get(obj)))
1797           items = wd->subobjs;
1798
1799         list_data_get = eina_list_data_get;
1800
1801         return elm_widget_focus_list_direction_get
1802                  (obj, base, items, list_data_get, degree, direction, direction_item, weight);
1803      }
1804
1805    return EINA_FALSE;
1806 }
1807
1808 EOLIAN static Eina_Bool
1809 _elm_win_elm_widget_on_focus(Eo *obj, Elm_Win_Data *sd, Elm_Object_Item *item EINA_UNUSED)
1810 {
1811    Eina_Bool int_ret = EINA_FALSE;
1812    eo_do_super(obj, MY_CLASS, int_ret = elm_obj_widget_on_focus(NULL));
1813    if (!int_ret) return EINA_TRUE;
1814
1815    if (sd->img_obj)
1816      evas_object_focus_set(sd->img_obj, elm_widget_focus_get(obj));
1817    else
1818      evas_object_focus_set(obj, elm_widget_focus_get(obj));
1819
1820    return EINA_TRUE;
1821 }
1822
1823 static Eina_Bool
1824 _key_action_return(Evas_Object *obj EINA_UNUSED, const char *params EINA_UNUSED)
1825 {
1826    return EINA_FALSE;
1827 }
1828
1829 static Eina_Bool
1830 _key_action_move(Evas_Object *obj, const char *params)
1831 {
1832    const char *dir = params;
1833
1834    _elm_widget_focus_auto_show(obj);
1835    if (!strcmp(dir, "previous"))
1836      elm_widget_focus_cycle(obj, ELM_FOCUS_PREVIOUS);
1837    else if (!strcmp(dir, "next"))
1838      elm_widget_focus_cycle(obj, ELM_FOCUS_NEXT);
1839    else if (!strcmp(dir, "left"))
1840      elm_widget_focus_cycle(obj, ELM_FOCUS_LEFT);
1841    else if (!strcmp(dir, "right"))
1842      elm_widget_focus_cycle(obj, ELM_FOCUS_RIGHT);
1843    else if (!strcmp(dir, "up"))
1844      elm_widget_focus_cycle(obj, ELM_FOCUS_UP);
1845    else if (!strcmp(dir, "down"))
1846      elm_widget_focus_cycle(obj, ELM_FOCUS_DOWN);
1847    else return EINA_FALSE;
1848
1849    return EINA_TRUE;
1850 }
1851
1852 EOLIAN static Eina_Bool
1853 _elm_win_elm_widget_event(Eo *obj, Elm_Win_Data *_pd EINA_UNUSED, Evas_Object *src EINA_UNUSED, Evas_Callback_Type type, void *event_info)
1854 {
1855    Evas_Event_Key_Down *ev = event_info;
1856
1857    if (elm_widget_disabled_get(obj)) return EINA_FALSE;
1858    if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
1859
1860    if (!_elm_config_key_binding_call(obj, ev, key_actions))
1861      return EINA_FALSE;
1862
1863    ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1864    return EINA_TRUE;
1865 }
1866
1867 static void
1868 _deferred_ecore_evas_free(void *data)
1869 {
1870    ecore_evas_free(data);
1871    _elm_win_deferred_free--;
1872 }
1873
1874 //TIZEN_ONLY(20170613) -listen if atspi is enabled
1875 static void
1876 _atspi_socket_proxy_listen(Eo * obj)
1877 {
1878    ELM_WIN_DATA_GET(obj, sd);
1879
1880    const char *plug_id;
1881    plug_id = evas_object_data_get(obj, "___PLUGID");
1882    if ((plug_id) != NULL)
1883      {
1884         char *svcname, *svcnum;
1885         if (!sd->socket_proxy && _elm_atspi_bridge_plug_id_split(plug_id, &svcname, &svcnum))
1886           {
1887              sd->socket_proxy = _elm_atspi_bridge_utils_proxy_create(obj, svcname, atoi(svcnum), ELM_ATSPI_PROXY_TYPE_SOCKET);
1888              elm_atspi_bridge_utils_proxy_listen(sd->socket_proxy);
1889              free(svcname);
1890              free(svcnum);
1891           }
1892      }
1893 }
1894 //
1895
1896 EOLIAN static void
1897 _elm_win_evas_object_smart_show(Eo *obj, Elm_Win_Data *sd)
1898 {
1899    if (sd->modal_count) return;
1900    const Eina_List *l;
1901    Evas_Object *current;
1902    Eina_Bool do_eval = EINA_FALSE;
1903
1904    if (!evas_object_visible_get(obj)) do_eval = EINA_TRUE;
1905    eo_do_super(obj, MY_CLASS, evas_obj_smart_show());
1906
1907    if ((sd->modal) && (!evas_object_visible_get(obj)))
1908      {
1909         INCREMENT_MODALITY()
1910      }
1911
1912    evas_smart_objects_calculate(evas_object_evas_get(obj));
1913
1914    TRAP(sd, show);
1915
1916    if (_elm_atspi_enabled())
1917      {
1918         Eo *bridge = _elm_atspi_bridge_get();
1919         elm_interface_atspi_window_created_signal_emit(obj);
1920         if (bridge)
1921            elm_interface_atspi_accessible_children_changed_added_signal_emit(elm_atspi_bridge_root_get(bridge), obj);
1922      }
1923
1924    // TIZEN_ONLY(20160705) - enable atspi_proxy to work
1925    if (_elm_atspi_enabled())
1926      {
1927         //TIZEN_ONLY(20170613) -listen if atspi is enabled
1928         _atspi_socket_proxy_listen(obj);
1929         //
1930      }
1931    //
1932
1933    if (do_eval)
1934      {
1935         if (_elm_win_state_eval_job)
1936           {
1937              ecore_job_del(_elm_win_state_eval_job);
1938              _elm_win_state_eval_job = NULL;
1939           }
1940         _elm_win_state_eval(NULL);
1941      }
1942    if (sd->shot.info) _shot_handle(sd);
1943 }
1944
1945 EOLIAN static void
1946 _elm_win_evas_object_smart_hide(Eo *obj, Elm_Win_Data *sd)
1947 {
1948    if (sd->modal_count) return;
1949    const Eina_List *l;
1950    Evas_Object *current;
1951
1952    if (evas_object_visible_get(obj))
1953      _elm_win_state_eval_queue();
1954    eo_do_super(obj, MY_CLASS, evas_obj_smart_hide());
1955
1956    if ((sd->modal) && (evas_object_visible_get(obj)))
1957      {
1958         DECREMENT_MODALITY()
1959      }
1960
1961    TRAP(sd, hide);
1962
1963    if (sd->frame_obj)
1964      {
1965         evas_object_hide(sd->frame_obj);
1966      }
1967    if (sd->img_obj)
1968      {
1969         evas_object_hide(sd->img_obj);
1970      }
1971    if (sd->pointer.obj)
1972      {
1973         evas_object_hide(sd->pointer.obj);
1974 #if 0
1975         ecore_evas_hide(sd->pointer.ee);
1976 #endif
1977      }
1978    if (_elm_atspi_enabled())
1979      {
1980         Eo *bridge = _elm_atspi_bridge_get();
1981         elm_interface_atspi_window_destroyed_signal_emit(obj);
1982         if (bridge)
1983            elm_interface_atspi_accessible_children_changed_del_signal_emit(elm_atspi_bridge_root_get(bridge), obj);
1984      }
1985
1986    if (_elm_win_policy_quit_triggered(obj))
1987      _elm_win_flush_cache_and_exit(obj);
1988 }
1989
1990 static void
1991 _elm_win_accessibility_highlight_obj_del(void *data,
1992                            Evas *e EINA_UNUSED,
1993                            Evas_Object *obj EINA_UNUSED,
1994                            void *event_info EINA_UNUSED)
1995 {
1996    ELM_WIN_DATA_GET(data, sd);
1997
1998    // TIZEN_ONLY(20160805): set _accessibility_currently_highlighted_obj to NULL in object delete callback
1999    /* set _accessibility_currently_highlighted_obj to NULL */
2000    elm_object_accessibility_highlight_set(obj, EINA_FALSE);
2001    //
2002    _elm_win_accessibility_highlight_hide(sd->obj);
2003 }
2004
2005 static void
2006 _elm_win_accessibility_highlight_obj_move(void *data,
2007                            Evas *e EINA_UNUSED,
2008                            Evas_Object *obj EINA_UNUSED,
2009                            void *event_info EINA_UNUSED)
2010 {
2011    ELM_WIN_DATA_GET(data, sd);
2012
2013    _elm_win_accessibility_highlight_show(sd->obj);
2014 }
2015
2016 static void
2017 _elm_win_accessibility_highlight_obj_resize(void *data,
2018                              Evas *e EINA_UNUSED,
2019                              Evas_Object *obj EINA_UNUSED,
2020                              void *event_info EINA_UNUSED)
2021 {
2022    ELM_WIN_DATA_GET(data, sd);
2023    _elm_win_accessibility_highlight_show(sd->obj);
2024
2025 }
2026
2027 static void
2028 _elm_win_on_parent_del(void *data,
2029                        Evas *e EINA_UNUSED,
2030                        Evas_Object *obj,
2031                        void *event_info EINA_UNUSED)
2032 {
2033    ELM_WIN_DATA_GET(data, sd);
2034
2035    if (obj == sd->parent) sd->parent = NULL;
2036 }
2037
2038 static void
2039 _elm_win_focus_target_move(void *data,
2040                            Evas *e EINA_UNUSED,
2041                            Evas_Object *obj EINA_UNUSED,
2042                            void *event_info EINA_UNUSED)
2043 {
2044    ELM_WIN_DATA_GET(data, sd);
2045
2046    sd->focus_highlight.geometry_changed = EINA_TRUE;
2047    _elm_win_focus_highlight_reconfigure_job_start(sd);
2048 }
2049
2050 static void
2051 _elm_win_focus_target_resize(void *data,
2052                              Evas *e EINA_UNUSED,
2053                              Evas_Object *obj EINA_UNUSED,
2054                              void *event_info EINA_UNUSED)
2055 {
2056    ELM_WIN_DATA_GET(data, sd);
2057
2058    sd->focus_highlight.geometry_changed = EINA_TRUE;
2059    _elm_win_focus_highlight_reconfigure_job_start(sd);
2060 }
2061
2062 static void
2063 _elm_win_focus_target_del(void *data,
2064                           Evas *e EINA_UNUSED,
2065                           Evas_Object *obj EINA_UNUSED,
2066                           void *event_info EINA_UNUSED)
2067 {
2068    ELM_WIN_DATA_GET(data, sd);
2069
2070    sd->focus_highlight.cur.target = NULL;
2071
2072    _elm_win_focus_highlight_reconfigure_job_start(sd);
2073 }
2074
2075 static Evas_Object *
2076 _elm_win_focus_target_get(Evas_Object *obj)
2077 {
2078    Evas_Object *o = obj;
2079
2080    do
2081      {
2082         if (elm_widget_is(o))
2083           {
2084              if (!elm_widget_highlight_ignore_get(o))
2085                break;
2086              o = elm_widget_parent_get(o);
2087              if (!o)
2088                o = evas_object_smart_parent_get(o);
2089           }
2090         else
2091           {
2092              o = elm_widget_parent_widget_get(o);
2093              if (!o)
2094                o = evas_object_smart_parent_get(o);
2095           }
2096      }
2097    while (o);
2098
2099    return o;
2100 }
2101
2102 static void
2103 _elm_win_focus_target_callbacks_add(Elm_Win_Data *sd)
2104 {
2105    Evas_Object *obj = sd->focus_highlight.cur.target;
2106    if (!obj) return;
2107
2108    evas_object_event_callback_add
2109      (obj, EVAS_CALLBACK_MOVE, _elm_win_focus_target_move, sd->obj);
2110    evas_object_event_callback_add
2111      (obj, EVAS_CALLBACK_RESIZE, _elm_win_focus_target_resize, sd->obj);
2112 }
2113
2114 static void
2115 _elm_win_focus_target_callbacks_del(Elm_Win_Data *sd)
2116 {
2117    Evas_Object *obj = sd->focus_highlight.cur.target;
2118
2119    evas_object_event_callback_del_full
2120      (obj, EVAS_CALLBACK_MOVE, _elm_win_focus_target_move, sd->obj);
2121    evas_object_event_callback_del_full
2122      (obj, EVAS_CALLBACK_RESIZE, _elm_win_focus_target_resize, sd->obj);
2123 }
2124
2125 static void
2126 _elm_win_accessibility_highlight_callbacks_add(Elm_Win_Data *sd)
2127 {
2128    Evas_Object *obj = sd->accessibility_highlight.cur.target;
2129    if (!obj) return;
2130    evas_object_event_callback_add
2131      (obj, EVAS_CALLBACK_DEL, _elm_win_accessibility_highlight_obj_del, sd->obj);
2132    evas_object_event_callback_add
2133      (obj, EVAS_CALLBACK_MOVE, _elm_win_accessibility_highlight_obj_move, sd->obj);
2134    evas_object_event_callback_add
2135      (obj, EVAS_CALLBACK_RESIZE, _elm_win_accessibility_highlight_obj_resize, sd->obj);
2136 }
2137
2138 static void
2139 _elm_win_accessibility_highlight_callbacks_del(Elm_Win_Data *sd)
2140 {
2141    Evas_Object *obj = sd->accessibility_highlight.cur.target;
2142    if (!obj) return;
2143
2144    evas_object_event_callback_del_full
2145      (obj, EVAS_CALLBACK_DEL, _elm_win_accessibility_highlight_obj_del, sd->obj);
2146    evas_object_event_callback_del_full
2147      (obj, EVAS_CALLBACK_MOVE, _elm_win_accessibility_highlight_obj_move, sd->obj);
2148    evas_object_event_callback_del_full
2149      (obj, EVAS_CALLBACK_RESIZE, _elm_win_accessibility_highlight_obj_resize, sd->obj);
2150 }
2151
2152 static void
2153 _elm_win_object_focus_in(void *data,
2154                          Evas *e EINA_UNUSED,
2155                          void *event_info)
2156 {
2157    Evas_Object *obj = event_info, *target;
2158    ELM_WIN_DATA_GET(data, sd);
2159
2160    if (sd->focus_highlight.cur.target == obj)
2161      return;
2162
2163    target = _elm_win_focus_target_get(obj);
2164    sd->focus_highlight.cur.target = target;
2165    if (target && elm_widget_highlight_in_theme_get(target))
2166      sd->focus_highlight.cur.in_theme = EINA_TRUE;
2167    else
2168      _elm_win_focus_target_callbacks_add(sd);
2169
2170    evas_object_event_callback_add
2171      (target, EVAS_CALLBACK_DEL, _elm_win_focus_target_del, sd->obj);
2172
2173    _elm_win_focus_highlight_reconfigure_job_start(sd);
2174 }
2175
2176 static void
2177 _elm_win_object_focus_out(void *data,
2178                           Evas *e EINA_UNUSED,
2179                           void *event_info EINA_UNUSED)
2180 {
2181    ELM_WIN_DATA_GET(data, sd);
2182
2183    if (!sd->focus_highlight.cur.target)
2184      return;
2185
2186    if (!sd->focus_highlight.cur.in_theme)
2187      _elm_win_focus_target_callbacks_del(sd);
2188
2189    evas_object_event_callback_del_full
2190       (sd->focus_highlight.cur.target,
2191        EVAS_CALLBACK_DEL, _elm_win_focus_target_del, sd->obj);
2192
2193    sd->focus_highlight.cur.target = NULL;
2194    sd->focus_highlight.cur.in_theme = EINA_FALSE;
2195
2196    _elm_win_focus_highlight_reconfigure_job_start(sd);
2197 }
2198
2199 static void
2200 _elm_win_focus_highlight_shutdown(Elm_Win_Data *sd)
2201 {
2202    _elm_win_focus_highlight_reconfigure_job_stop(sd);
2203    if (sd->focus_highlight.cur.target)
2204      {
2205         elm_widget_signal_emit(sd->focus_highlight.cur.target,
2206                                "elm,action,focus_highlight,hide", "elm");
2207         _elm_win_focus_target_callbacks_del(sd);
2208         evas_object_event_callback_del_full
2209            (sd->focus_highlight.cur.target,
2210             EVAS_CALLBACK_DEL, _elm_win_focus_target_del, sd->obj);
2211         sd->focus_highlight.cur.target = NULL;
2212      }
2213    ELM_SAFE_FREE(sd->focus_highlight.fobj, evas_object_del);
2214
2215    evas_event_callback_del_full
2216      (sd->evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
2217      _elm_win_object_focus_in, sd->obj);
2218    evas_event_callback_del_full
2219      (sd->evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
2220      _elm_win_object_focus_out, sd->obj);
2221 }
2222
2223 static void
2224 _win_img_hide(void *data,
2225               Evas *e EINA_UNUSED,
2226               Evas_Object *obj EINA_UNUSED,
2227               void *event_info EINA_UNUSED)
2228 {
2229    elm_widget_focus_hide_handle(data);
2230 }
2231
2232 static void
2233 _win_img_mouse_up(void *data,
2234                   Evas *e EINA_UNUSED,
2235                   Evas_Object *obj EINA_UNUSED,
2236                   void *event_info)
2237 {
2238    Evas_Event_Mouse_Up *ev = event_info;
2239    if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD))
2240      elm_widget_focus_mouse_up_handle(data);
2241 }
2242
2243 static void
2244 _win_img_focus_in(void *data,
2245                   Evas *e EINA_UNUSED,
2246                   Evas_Object *obj EINA_UNUSED,
2247                   void *event_info EINA_UNUSED)
2248 {
2249    elm_widget_focus_steal(data, NULL);
2250 }
2251
2252 static void
2253 _win_img_focus_out(void *data,
2254                    Evas *e EINA_UNUSED,
2255                    Evas_Object *obj EINA_UNUSED,
2256                    void *event_info EINA_UNUSED)
2257 {
2258    elm_widget_focused_object_clear(data);
2259 }
2260
2261 static void
2262 _elm_win_on_img_obj_del(void *data,
2263                         Evas *e EINA_UNUSED,
2264                         Evas_Object *obj EINA_UNUSED,
2265                         void *event_info EINA_UNUSED)
2266 {
2267    ELM_WIN_DATA_GET(data, sd);
2268    _elm_win_img_callbacks_del(sd->obj, sd->img_obj);
2269    sd->img_obj = NULL;
2270 }
2271
2272 static void
2273 _elm_win_img_callbacks_del(Evas_Object *obj, Evas_Object *imgobj)
2274 {
2275    evas_object_event_callback_del_full
2276      (imgobj, EVAS_CALLBACK_DEL, _elm_win_on_img_obj_del, obj);
2277    evas_object_event_callback_del_full
2278      (imgobj, EVAS_CALLBACK_HIDE, _win_img_hide, obj);
2279    evas_object_event_callback_del_full
2280      (imgobj, EVAS_CALLBACK_MOUSE_UP, _win_img_mouse_up, obj);
2281    evas_object_event_callback_del_full
2282      (imgobj, EVAS_CALLBACK_FOCUS_IN, _win_img_focus_in, obj);
2283    evas_object_event_callback_del_full
2284      (imgobj, EVAS_CALLBACK_FOCUS_OUT, _win_img_focus_out, obj);
2285 }
2286
2287 EOLIAN static void
2288 _elm_win_evas_object_smart_del(Eo *obj, Elm_Win_Data *sd)
2289 {
2290    const Eina_List *l;
2291    Evas_Object *current;
2292
2293    if ((sd->modal) && (evas_object_visible_get(obj)))
2294      {
2295        DECREMENT_MODALITY()
2296      }
2297
2298    if ((sd->modal) && (sd->modal_count > 0))
2299      ERR("Deleted modal win was blocked by another modal win which was created after creation of that win.");
2300
2301    evas_object_event_callback_del_full(sd->edje,
2302                                        EVAS_CALLBACK_CHANGED_SIZE_HINTS,
2303                                        _elm_win_on_resize_obj_changed_size_hints,
2304                                        obj);
2305    evas_object_del(sd->box);
2306    evas_object_del(sd->edje);
2307
2308    /* NB: child deletion handled by parent's smart del */
2309
2310    if ((sd->type != ELM_WIN_FAKE) && (trap) && (trap->del))
2311      trap->del(sd->trap_data, obj);
2312
2313    if (sd->parent)
2314      {
2315         evas_object_event_callback_del_full
2316           (sd->parent, EVAS_CALLBACK_DEL, _elm_win_on_parent_del, obj);
2317         sd->parent = NULL;
2318      }
2319
2320    if (sd->autodel_clear) *(sd->autodel_clear) = -1;
2321
2322    if (_elm_atspi_enabled())
2323      elm_interface_atspi_window_destroyed_signal_emit(obj);
2324
2325    _elm_win_list = eina_list_remove(_elm_win_list, obj);
2326    _elm_win_count--;
2327    _elm_win_state_eval_queue();
2328
2329    if (sd->ee)
2330      {
2331         ecore_evas_callback_delete_request_set(sd->ee, NULL);
2332         ecore_evas_callback_resize_set(sd->ee, NULL);
2333      }
2334
2335    ecore_job_del(sd->deferred_resize_job);
2336    ecore_job_del(sd->deferred_child_eval_job);
2337    eina_stringshare_del(sd->shot.info);
2338    ecore_timer_del(sd->shot.timer);
2339
2340 #ifdef HAVE_ELEMENTARY_X
2341    ecore_event_handler_del(sd->x.client_message_handler);
2342    ecore_event_handler_del(sd->x.property_handler);
2343 #endif
2344 #ifdef HAVE_ELEMENTARY_WAYLAND
2345    ecore_event_handler_del(sd->wl.effect_start_handler);
2346    ecore_event_handler_del(sd->wl.effect_end_handler);
2347    ecore_event_handler_del(sd->wl.indicator_flick_handler); // TIZEN_ONLY(20160801): indicator implementation
2348    ecore_event_handler_del(sd->wl.aux_msg_handler);
2349 #endif
2350    ecore_event_handler_del(sd->mouse_up_handler);//TIZEN_ONLY(20161121) tizen don't have canvas mouse up event like opensource now.
2351
2352    if (sd->img_obj)
2353      {
2354         _elm_win_img_callbacks_del(obj, sd->img_obj);
2355         sd->img_obj = NULL;
2356      }
2357    else
2358      {
2359         if (sd->ee && (sd->type != ELM_WIN_FAKE))
2360           {
2361              ecore_job_add(_deferred_ecore_evas_free, sd->ee);
2362              _elm_win_deferred_free++;
2363           }
2364      }
2365
2366    _elm_win_focus_highlight_shutdown(sd);
2367    eina_stringshare_del(sd->focus_highlight.style);
2368
2369    eina_stringshare_del(sd->title);
2370    eina_stringshare_del(sd->icon_name);
2371    eina_stringshare_del(sd->role);
2372    eina_stringshare_del(sd->frame_style);
2373    eina_stringshare_del(sd->name);
2374    evas_object_del(sd->icon);
2375    evas_object_del(sd->main_menu);
2376
2377    sd->focus_highlight.style = NULL;
2378    sd->title = NULL;
2379    sd->icon_name = NULL;
2380    sd->role = NULL;
2381    sd->name = NULL;
2382    sd->icon = NULL;
2383    sd->main_menu = NULL;
2384
2385    _elm_win_profile_del(sd);
2386    _elm_win_available_profiles_del(sd);
2387
2388    free(sd->wm_rot.rots);
2389    sd->wm_rot.rots = NULL;
2390
2391    /* Don't let callback in the air that point to sd */
2392    ecore_evas_callback_delete_request_set(sd->ee, NULL);
2393    ecore_evas_callback_resize_set(sd->ee, NULL);
2394    ecore_evas_callback_mouse_in_set(sd->ee, NULL);
2395    ecore_evas_callback_focus_in_set(sd->ee, NULL);
2396    ecore_evas_callback_focus_out_set(sd->ee, NULL);
2397    ecore_evas_callback_move_set(sd->ee, NULL);
2398    ecore_evas_callback_state_change_set(sd->ee, NULL);
2399
2400    eo_do_super(obj, MY_CLASS, evas_obj_smart_del());
2401
2402    if (_elm_win_policy_quit_triggered(obj))
2403      {
2404         _elm_win_flush_cache_and_exit(obj);
2405      }
2406 }
2407
2408 static void
2409 _elm_win_obj_intercept_show(void *data,
2410                             Evas_Object *obj)
2411 {
2412    ELM_WIN_DATA_GET(data, sd);
2413
2414    // this is called to make sure all smart containers have calculated their
2415    // sizes BEFORE we show the window to make sure it initially appears at
2416    // our desired size (ie min size is known first)
2417    evas_smart_objects_calculate(evas_object_evas_get(obj));
2418    if (sd->frame_obj)
2419      {
2420         evas_object_show(sd->frame_obj);
2421      }
2422    if (sd->img_obj)
2423      {
2424         evas_object_show(sd->img_obj);
2425      }
2426    if (sd->pointer.obj)
2427      {
2428 #if 0
2429         ecore_evas_show(sd->pointer.ee);
2430 #endif
2431         evas_object_show(sd->pointer.obj);
2432      }
2433    evas_object_show(obj);
2434 #ifdef HAVE_ELEMENTARY_WAYLAND
2435    int x, y, w, h;
2436    Eina_Rectangle input_rect = { -1, -1, 1, 1 };
2437
2438    evas_object_geometry_get(obj, &x, &y, &w, &h);
2439    ecore_wl_window_opaque_region_set(sd->wl.win, x, y, w, h);
2440
2441    /* TIZEN_ONLY: ecore_evas_input_rect_set api is exist only in tizen */
2442    if (sd->type == ELM_WIN_TOOLTIP)
2443      ecore_evas_input_rect_set(sd->ee, &input_rect);
2444 #endif
2445
2446 #ifdef ELEMENTARY_X
2447    if (sd->type == ELM_WIN_TOOLTIP)
2448      ecore_x_window_shape_input_rectangle_set(sd->x.xwin, 0, 0, 0, 0);
2449 #endif
2450 }
2451
2452 EOLIAN static void
2453 _elm_win_evas_object_smart_move(Eo *obj, Elm_Win_Data *sd, Evas_Coord x, Evas_Coord y)
2454 {
2455    if (sd->img_obj)
2456      {
2457         if ((x != sd->screen.x) || (y != sd->screen.y))
2458           {
2459              sd->screen.x = x;
2460              sd->screen.y = y;
2461              eo_do(obj, eo_event_callback_call(ELM_WIN_EVENT_MOVED, NULL));
2462           }
2463         return;
2464      }
2465    else
2466      {
2467         TRAP(sd, move, x, y);
2468         if (!ecore_evas_override_get(sd->ee))  return;
2469      }
2470
2471    eo_do_super(obj, MY_CLASS, evas_obj_smart_move(x, y));
2472
2473    if (ecore_evas_override_get(sd->ee))
2474      {
2475         sd->screen.x = x;
2476         sd->screen.y = y;
2477         eo_do(obj, eo_event_callback_call(ELM_WIN_EVENT_MOVED, NULL));
2478      }
2479    if (sd->frame_obj)
2480      {
2481 #ifdef HAVE_ELEMENTARY_WAYLAND
2482         ecore_wl_window_update_location(sd->wl.win, x, y);
2483 #endif
2484         sd->screen.x = x;
2485         sd->screen.y = y;
2486      }
2487    if (sd->img_obj)
2488      {
2489         sd->screen.x = x;
2490         sd->screen.y = y;
2491      }
2492 }
2493
2494 EOLIAN static void
2495 _elm_win_evas_object_smart_resize(Eo *obj, Elm_Win_Data *sd, Evas_Coord w, Evas_Coord h)
2496 {
2497    eo_do_super(obj, MY_CLASS, evas_obj_smart_resize(w, h));
2498
2499    if (sd->img_obj)
2500      {
2501         if (sd->constrain)
2502           {
2503              int sw, sh;
2504
2505              ecore_evas_screen_geometry_get(sd->ee, NULL, NULL, &sw, &sh);
2506              w = MIN(w, sw);
2507              h = MIN(h, sh);
2508           }
2509         if (w < 1) w = 1;
2510         if (h < 1) h = 1;
2511
2512         evas_object_image_size_set(sd->img_obj, w, h);
2513      }
2514
2515    TRAP(sd, resize, w, h);
2516 }
2517
2518 static void
2519 _elm_win_delete_request(Ecore_Evas *ee)
2520 {
2521    Elm_Win_Data *sd = _elm_win_associate_get(ee);
2522    Evas_Object *obj;
2523
2524    if (!sd) return;
2525
2526    obj = sd->obj;
2527
2528    int autodel = sd->autodel;
2529    sd->autodel_clear = &autodel;
2530    evas_object_ref(obj);
2531    eo_do(obj, eo_event_callback_call(ELM_WIN_EVENT_DELETE_REQUEST, NULL));
2532    if (sd->autohide)
2533      evas_object_hide(obj);
2534    // FIXME: if above callback deletes - then the below will be invalid
2535    if (_elm_atspi_enabled())
2536      elm_interface_atspi_window_destroyed_signal_emit(obj);
2537    if (autodel) evas_object_del(obj);
2538    else sd->autodel_clear = NULL;
2539    evas_object_unref(obj);
2540 }
2541
2542 Ecore_X_Window
2543 _elm_ee_xwin_get(const Ecore_Evas *ee)
2544 {
2545 #ifdef HAVE_ELEMENTARY_X
2546    const char *engine_name;
2547    if (!ee) return 0;
2548
2549    engine_name = ecore_evas_engine_name_get(ee);
2550    if (EINA_UNLIKELY(!engine_name)) return 0;
2551
2552    if (!strcmp(engine_name, ELM_SOFTWARE_X11))
2553      {
2554         return ecore_evas_software_x11_window_get(ee);
2555      }
2556    else if (!strcmp(engine_name, ELM_OPENGL_X11))
2557      {
2558         return ecore_evas_gl_x11_window_get(ee);
2559      }
2560 #else
2561    (void)ee;
2562 #endif
2563    return 0;
2564 }
2565
2566 #ifdef HAVE_ELEMENTARY_X
2567 static void
2568 _internal_elm_win_xwindow_get(Elm_Win_Data *sd)
2569 {
2570    sd->x.xwin = _elm_ee_xwin_get(sd->ee);
2571 }
2572 #endif
2573
2574 Ecore_Wl_Window *
2575 _elm_ee_wlwin_get(const Ecore_Evas *ee)
2576 {
2577 #ifdef HAVE_ELEMENTARY_WAYLAND
2578    const char *engine_name;
2579
2580    if (!ee) return NULL;
2581
2582    engine_name = ecore_evas_engine_name_get(ee);
2583    if (EINA_UNLIKELY(!engine_name)) return NULL;
2584
2585    if ((!strcmp(engine_name, ELM_WAYLAND_SHM)) ||
2586        (!strcmp(engine_name, ELM_WAYLAND_EGL)))
2587      {
2588         return ecore_evas_wayland_window_get(ee);
2589      }
2590 #else
2591    (void)ee;
2592 #endif
2593    return NULL;
2594 }
2595
2596 struct _Elm_Win_Aux_Message
2597 {
2598    const char *key;
2599    const char *val;
2600    Eina_List *options;
2601 };
2602
2603 #ifdef HAVE_ELEMENTARY_WAYLAND
2604 static void
2605 _elm_win_wlwindow_get(Elm_Win_Data *sd)
2606 {
2607    sd->wl.win = _elm_ee_wlwin_get(sd->ee);
2608 }
2609
2610 static Eina_Bool
2611 _elm_win_wl_effect_start(void *data, int type EINA_UNUSED, void *event)
2612 {
2613    ELM_WIN_DATA_GET(data, sd);
2614    Ecore_Wl_Event_Effect_Start *e = event;
2615
2616    if (!sd->wl.win) return ECORE_CALLBACK_PASS_ON;
2617
2618    if ((ecore_wl_window_id_get(sd->wl.win) != e->win))
2619      return ECORE_CALLBACK_PASS_ON;
2620
2621    evas_object_smart_callback_call(data, SIG_EFFECT_STARTED, (void*)e->type);
2622
2623    return ECORE_CALLBACK_PASS_ON;
2624 }
2625
2626 static Eina_Bool
2627 _elm_win_wl_effect_end(void *data, int type EINA_UNUSED, void *event)
2628 {
2629    ELM_WIN_DATA_GET(data, sd);
2630    Ecore_Wl_Event_Effect_End *e = event;
2631    unsigned int eff_type;
2632
2633    if (!sd->wl.win) return ECORE_CALLBACK_PASS_ON;
2634
2635    if ((ecore_wl_window_id_get(sd->wl.win) != e->win))
2636      return ECORE_CALLBACK_PASS_ON;
2637
2638    eff_type = e->type;
2639    if (eff_type == 4)
2640      evas_object_smart_callback_call(data, SIG_LAUNCH_DONE, (void*)e->type);
2641    else
2642      evas_object_smart_callback_call(data, SIG_EFFECT_DONE, (void*)e->type);
2643
2644    return ECORE_CALLBACK_PASS_ON;
2645 }
2646
2647 static Eina_Bool
2648 _elm_win_wl_aux_message(void *data, int type EINA_UNUSED, void *event)
2649 {
2650    ELM_WIN_DATA_GET(data, sd);
2651    Ecore_Wl_Event_Aux_Message *ev = event;
2652    Elm_Win_Aux_Message *msg = NULL;
2653    const char *opt = NULL, *tmp = NULL;
2654    Eina_List *l;
2655
2656    if (!sd->wl.win) return ECORE_CALLBACK_PASS_ON;
2657
2658    if ((ecore_wl_window_id_get(sd->wl.win) != ev->win))
2659      return ECORE_CALLBACK_PASS_ON;
2660
2661    msg = calloc(1, sizeof(*msg));
2662    if (!msg) return ECORE_CALLBACK_PASS_ON;
2663
2664    msg->key = eina_stringshare_add(ev->key);
2665    msg->val = eina_stringshare_add(ev->val);
2666
2667    EINA_LIST_FOREACH(ev->options, l, opt)
2668      {
2669         if (!opt) continue;
2670         tmp = eina_stringshare_add(opt);
2671         msg->options = eina_list_append(msg->options, tmp);
2672      }
2673
2674    evas_object_smart_callback_call(sd->obj, SIG_AUX_MESSAGE_RECEIVED, (void*)msg);
2675
2676    eina_stringshare_del(msg->key);
2677    eina_stringshare_del(msg->val);
2678    EINA_LIST_FREE(msg->options, opt)
2679       eina_stringshare_del(opt);
2680    free(msg);
2681
2682    return ECORE_CALLBACK_PASS_ON;
2683 }
2684 #endif
2685
2686 static Eina_Bool
2687 _elm_win_mouse_up(void *data, int type EINA_UNUSED, void *event EINA_UNUSED)
2688 {
2689    ELM_WIN_DATA_GET(data, sd);
2690
2691    if (sd->resizing) sd->resizing = EINA_FALSE;
2692
2693    return ECORE_CALLBACK_PASS_ON;
2694 }
2695
2696 Ecore_Cocoa_Window *
2697 _elm_ee_cocoa_win_get(const Ecore_Evas *ee)
2698 {
2699 #ifdef HAVE_ELEMENTARY_COCOA
2700    const char *engine_name;
2701
2702    if (!ee) return NULL;
2703
2704    engine_name = ecore_evas_engine_name_get(ee);
2705    if (EINA_UNLIKELY(!engine_name)) return NULL;
2706
2707    if (!strcmp(engine_name, "opengl_cocoa") ||
2708        !strcmp(engine_name, "gl_cocoa"))
2709      return ecore_evas_cocoa_window_get(ee);
2710 #else
2711    (void)ee;
2712 #endif
2713    return NULL;
2714 }
2715
2716 Ecore_Win32_Window *
2717 _elm_ee_win32win_get(const Ecore_Evas *ee)
2718 {
2719 #ifdef HAVE_ELEMENTARY_WIN32
2720    const char *engine_name;
2721
2722    if (!ee) return NULL;
2723
2724    engine_name = ecore_evas_engine_name_get(ee);
2725    if (EINA_UNLIKELY(!engine_name)) return NULL;
2726
2727    if ((!strcmp(engine_name, ELM_SOFTWARE_WIN32)) ||
2728        (!strcmp(engine_name, ELM_SOFTWARE_DDRAW)))
2729      {
2730         return ecore_evas_win32_window_get(ee);
2731      }
2732 #else
2733    (void)ee;
2734 #endif
2735    return NULL;
2736 }
2737
2738 #ifdef HAVE_ELEMENTARY_COCOA
2739 static void
2740 _elm_win_cocoawindow_get(Elm_Win_Data *sd)
2741 {
2742    sd->cocoa.win = _elm_ee_cocoa_win_get(sd->ee);
2743 }
2744 #endif
2745
2746 #ifdef HAVE_ELEMENTARY_WIN32
2747 static void
2748 _internal_elm_win_win32window_get(Elm_Win_Data *sd)
2749 {
2750    sd->win32.win = _elm_ee_win32win_get(sd->ee);
2751 }
2752 #endif
2753
2754 #ifdef HAVE_ELEMENTARY_X
2755 static void
2756 _elm_win_xwin_update(Elm_Win_Data *sd)
2757 {
2758    const char *s;
2759
2760    if (sd->type == ELM_WIN_FAKE) return;
2761    _internal_elm_win_xwindow_get(sd);
2762    if (sd->parent)
2763      {
2764         ELM_WIN_DATA_GET(sd->parent, sdp);
2765         if (sdp)
2766           {
2767              if (sd->x.xwin)
2768                ecore_x_icccm_transient_for_set(sd->x.xwin, sdp->x.xwin);
2769           }
2770      }
2771
2772    if (!sd->x.xwin) return;  /* nothing more to do */
2773
2774    s = sd->title;
2775    if (!s) s = _elm_appname;
2776    if (!s) s = "";
2777    if (sd->icon_name) s = sd->icon_name;
2778    ecore_x_icccm_icon_name_set(sd->x.xwin, s);
2779    ecore_x_netwm_icon_name_set(sd->x.xwin, s);
2780
2781    s = sd->role;
2782    if (s) ecore_x_icccm_window_role_set(sd->x.xwin, s);
2783
2784    // set window icon
2785    if (sd->icon)
2786      {
2787         void *data;
2788
2789         data = evas_object_image_data_get(sd->icon, EINA_FALSE);
2790         if (data)
2791           {
2792              Ecore_X_Icon ic;
2793              int w = 0, h = 0, stride, x, y;
2794              unsigned char *p;
2795              unsigned int *p2;
2796
2797              evas_object_image_size_get(sd->icon, &w, &h);
2798              stride = evas_object_image_stride_get(sd->icon);
2799              if ((w > 0) && (h > 0) &&
2800                  (stride >= (int)(w * sizeof(unsigned int))))
2801                {
2802                   ic.width = w;
2803                   ic.height = h;
2804                   ic.data = malloc(w * h * sizeof(unsigned int));
2805
2806                   if (ic.data)
2807                     {
2808                        p = (unsigned char *)data;
2809                        p2 = (unsigned int *)ic.data;
2810                        for (y = 0; y < h; y++)
2811                          {
2812                             for (x = 0; x < w; x++)
2813                               {
2814                                  *p2 = *((unsigned int *)p);
2815                                  p += sizeof(unsigned int);
2816                                  p2++;
2817                               }
2818                             p += (stride - (w * sizeof(unsigned int)));
2819                          }
2820                        ecore_x_netwm_icons_set(sd->x.xwin, &ic, 1);
2821                        free(ic.data);
2822                     }
2823                }
2824              evas_object_image_data_set(sd->icon, data);
2825           }
2826      }
2827
2828    switch (sd->type)
2829      {
2830       case ELM_WIN_BASIC:
2831         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_NORMAL);
2832         break;
2833
2834       case ELM_WIN_DIALOG_BASIC:
2835         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_DIALOG);
2836         break;
2837
2838       case ELM_WIN_DESKTOP:
2839         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_DESKTOP);
2840         break;
2841
2842       case ELM_WIN_DOCK:
2843         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_DOCK);
2844         break;
2845
2846       case ELM_WIN_TOOLBAR:
2847         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_TOOLBAR);
2848         break;
2849
2850       case ELM_WIN_MENU:
2851         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_MENU);
2852         break;
2853
2854       case ELM_WIN_UTILITY:
2855         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_UTILITY);
2856         break;
2857
2858       case ELM_WIN_SPLASH:
2859         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_SPLASH);
2860         break;
2861
2862       case ELM_WIN_DROPDOWN_MENU:
2863         ecore_x_netwm_window_type_set
2864           (sd->x.xwin, ECORE_X_WINDOW_TYPE_DROPDOWN_MENU);
2865         break;
2866
2867       case ELM_WIN_POPUP_MENU:
2868         ecore_x_netwm_window_type_set
2869           (sd->x.xwin, ECORE_X_WINDOW_TYPE_POPUP_MENU);
2870         break;
2871
2872       case ELM_WIN_TOOLTIP:
2873         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_TOOLTIP);
2874         ecore_x_window_shape_input_rectangle_set(sd->x.xwin, 0, 0, 0, 0);
2875         break;
2876
2877       case ELM_WIN_NOTIFICATION:
2878         ecore_x_netwm_window_type_set
2879           (sd->x.xwin, ECORE_X_WINDOW_TYPE_NOTIFICATION);
2880         break;
2881
2882       case ELM_WIN_COMBO:
2883         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_COMBO);
2884         break;
2885
2886       case ELM_WIN_DND:
2887         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_DND);
2888         break;
2889
2890       default:
2891         break;
2892      }
2893    ecore_x_e_virtual_keyboard_state_set
2894      (sd->x.xwin, (Ecore_X_Virtual_Keyboard_State)sd->kbdmode);
2895    if (sd->indmode == ELM_WIN_INDICATOR_SHOW)
2896      ecore_x_e_illume_indicator_state_set
2897        (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_STATE_ON);
2898    else if (sd->indmode == ELM_WIN_INDICATOR_HIDE)
2899      ecore_x_e_illume_indicator_state_set
2900        (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_STATE_OFF);
2901
2902    if ((sd->wm_rot.count) && (sd->wm_rot.rots))
2903      ecore_evas_wm_rotation_available_rotations_set(sd->ee,
2904                                                     sd->wm_rot.rots,
2905                                                     sd->wm_rot.count);
2906    if (sd->wm_rot.preferred_rot != -1)
2907      ecore_evas_wm_rotation_preferred_rotation_set(sd->ee,
2908                                                    sd->wm_rot.preferred_rot);
2909 }
2910
2911 #endif
2912
2913 #ifdef HAVE_ELEMENTARY_WAYLAND
2914 static void
2915 _elm_win_wlwin_update(Elm_Win_Data *sd)
2916 {
2917    switch (sd->type)
2918      {
2919         case ELM_WIN_BASIC:
2920           ecore_evas_wayland_type_set(sd->ee, ECORE_WL_WINDOW_TYPE_TOPLEVEL);
2921           break;
2922         case ELM_WIN_NOTIFICATION:
2923           ecore_evas_wayland_type_set(sd->ee, ECORE_WL_WINDOW_TYPE_NOTIFICATION);
2924           break;
2925         case ELM_WIN_UTILITY:
2926           ecore_evas_wayland_type_set(sd->ee, ECORE_WL_WINDOW_TYPE_UTILITY);
2927           break;
2928         case ELM_WIN_DIALOG_BASIC:
2929           ecore_evas_wayland_type_set(sd->ee, ECORE_WL_WINDOW_TYPE_DIALOG);
2930           break;
2931         case ELM_WIN_DOCK:
2932           ecore_evas_wayland_type_set(sd->ee, ECORE_WL_WINDOW_TYPE_DOCK);
2933           break;
2934         case ELM_WIN_SPLASH:
2935           ecore_evas_wayland_type_set(sd->ee, ECORE_WL_WINDOW_TYPE_SPLASH);
2936           break;
2937         default:
2938           break;
2939      }
2940 }
2941
2942 #endif
2943
2944 /**
2945   * @internal
2946   *
2947   * Resize the window according to window layout's min and weight.
2948   * If the window layout's weight is 0.0, the window max is limited to layout's
2949   * min size.
2950   *
2951   * This is called when the window layout's weight hint is changed or when the
2952   * window is rotated.
2953   *
2954   * @param obj window object
2955   */
2956 static void
2957 _elm_win_resize_objects_eval(Evas_Object *obj)
2958 {
2959    ELM_WIN_DATA_GET(obj, sd);
2960    Evas_Coord w, h, minw, minh, maxw, maxh;
2961    double wx, wy;
2962
2963    evas_object_size_hint_min_get(sd->edje, &minw, &minh);
2964    if (minw < 1) minw = 1;
2965    if (minh < 1) minh = 1;
2966
2967    evas_object_size_hint_weight_get(sd->edje, &wx, &wy);
2968    if (!wx) maxw = minw;
2969    else maxw = 32767;
2970    if (!wy) maxh = minh;
2971    else maxh = 32767;
2972
2973    evas_object_size_hint_min_set(obj, minw, minh);
2974    evas_object_size_hint_max_set(obj, maxw, maxh);
2975
2976    /* if there are deferred resize job, do the job immediately */
2977    if (sd->deferred_resize_job)
2978      {
2979         ecore_job_del(sd->deferred_resize_job);
2980         sd->deferred_resize_job = NULL;
2981         _elm_win_resize_job(obj);
2982      }
2983
2984    evas_object_geometry_get(obj, NULL, NULL, &w, &h);
2985    if (w < minw) w = minw;
2986    if (h < minh) h = minh;
2987    if (w > maxw) w = maxw;
2988    if (h > maxh) h = maxh;
2989    evas_object_resize(obj, w, h);
2990 }
2991
2992 static void
2993 _elm_win_on_resize_obj_changed_size_hints(void *data,
2994                                           Evas *e EINA_UNUSED,
2995                                           Evas_Object *obj EINA_UNUSED,
2996                                           void *event_info EINA_UNUSED)
2997 {
2998    _elm_win_resize_objects_eval(data);
2999 }
3000
3001 void
3002 _elm_win_shutdown(void)
3003 {
3004    while (_elm_win_list)
3005      {
3006         Eina_List *itr = _elm_win_list;
3007         evas_object_del(itr->data);
3008         if (_elm_win_list == itr)
3009           {
3010              _elm_win_list = eina_list_remove_list(_elm_win_list, _elm_win_list);
3011           }
3012      }
3013    ELM_SAFE_FREE(_elm_win_state_eval_job, ecore_job_del);
3014 }
3015
3016 void
3017 _elm_win_rescale(Elm_Theme *th,
3018                  Eina_Bool use_theme)
3019 {
3020    const Eina_List *l;
3021    Evas_Object *obj;
3022
3023    if (!use_theme)
3024      {
3025         EINA_LIST_FOREACH(_elm_win_list, l, obj)
3026           elm_widget_theme(obj);
3027      }
3028    else
3029      {
3030         EINA_LIST_FOREACH(_elm_win_list, l, obj)
3031           elm_widget_theme_specific(obj, th, EINA_FALSE);
3032      }
3033 }
3034
3035 void
3036 _elm_win_access(Eina_Bool is_access)
3037 {
3038    Evas *evas;
3039    const Eina_List *l;
3040    Evas_Object *obj;
3041    Evas_Object *fobj;
3042
3043    EINA_LIST_FOREACH(_elm_win_list, l, obj)
3044      {
3045         elm_widget_access(obj, is_access);
3046
3047          /* floating orphan object. if there are A, B, C objects and user does
3048             as below, then there would be floating orphan objects.
3049
3050               1. elm_object_content_set(layout, A);
3051               2. elm_object_content_set(layout, B);
3052               3. elm_object_content_set(layout, C);
3053
3054             now, the object A and B are floating orphan objects */
3055
3056         fobj = obj;
3057         for (;;)
3058           {
3059              fobj = evas_object_below_get(fobj);
3060              if (!fobj) break;
3061
3062              if (elm_widget_is(fobj) && !elm_widget_parent_get(fobj))
3063                {
3064                   elm_widget_access(fobj, is_access);
3065                }
3066           }
3067
3068         if (!is_access)
3069           {
3070              evas = evas_object_evas_get(obj);
3071             if (evas) _elm_access_object_highlight_disable(evas);
3072           }
3073      }
3074 }
3075
3076 //TIZEN_ONLY(20160822): When atspi mode is dynamically switched on/off,
3077 //register/unregister access objects accordingly.
3078 // TIZEN_ONLY(20170516): connect to at-spi dbus based on org.a11y.Status.IsEnabled property
3079 void
3080 _elm_win_screen_reader(Eina_Bool is_screen_reader)
3081 {
3082    const Eina_List *l;
3083    Evas_Object *obj;
3084    Evas_Object *fobj;
3085
3086    EINA_LIST_FOREACH(_elm_win_list, l, obj)
3087      {
3088         elm_widget_screen_reader(obj, is_screen_reader);
3089         evas_object_smart_callback_call(obj, SIG_ATSPI_SCREEN_READER_CHANGED, &is_screen_reader);
3090
3091          /* floating orphan object. if there are A, B, C objects and user does
3092             as below, then there would be floating orphan objects.
3093
3094               1. elm_object_content_set(layout, A);
3095               2. elm_object_content_set(layout, B);
3096               3. elm_object_content_set(layout, C);
3097
3098             now, the object A and B are floating orphan objects */
3099
3100         fobj = obj;
3101         for (;;)
3102           {
3103              fobj = evas_object_below_get(fobj);
3104              if (!fobj) break;
3105
3106              if (elm_widget_is(fobj) && !elm_widget_parent_get(fobj))
3107                {
3108                   elm_widget_screen_reader(fobj, is_screen_reader);
3109                }
3110           }
3111      }
3112
3113    if (!is_screen_reader)
3114      {
3115         Evas_Object *highlighted_obj;
3116         highlighted_obj = _elm_object_accessibility_currently_highlighted_get();
3117         elm_object_accessibility_highlight_set(highlighted_obj, EINA_FALSE);
3118      }
3119 }
3120
3121 //TIZEN_ONLY(20170621) handle atspi proxy connection at runtime
3122 void
3123 _elm_win_atspi(Eina_Bool is_atspi)
3124 {
3125    const Eina_List *l;
3126    Evas_Object *obj;
3127    Elm_Atspi_State_Set ss;
3128
3129    EINA_LIST_FOREACH(_elm_win_list, l, obj)
3130      {
3131         if (!is_atspi)
3132           {
3133              ELM_WIN_DATA_GET(obj, sd);
3134              if (sd->socket_proxy)
3135                {
3136                   eo_unref(sd->socket_proxy);
3137                   sd->socket_proxy = NULL;
3138                }
3139           }
3140         else
3141           {
3142              _atspi_socket_proxy_listen(obj);
3143              eo_do(obj, ss = elm_interface_atspi_accessible_state_set_get());
3144              if (STATE_TYPE_GET(ss, ELM_ATSPI_STATE_ACTIVE))
3145                {
3146                   elm_interface_atspi_window_activated_signal_emit(obj);
3147                   elm_interface_atspi_accessible_state_changed_signal_emit(obj, ELM_ATSPI_STATE_ACTIVE, EINA_TRUE);
3148                }
3149              else
3150                {
3151                   Elm_Atspi_Role role;
3152                   eo_do(obj, role = elm_interface_atspi_accessible_role_get());
3153                   if (role == ELM_ATSPI_ROLE_INPUT_METHOD_WINDOW)
3154                     {
3155                        elm_interface_atspi_window_activated_signal_emit(obj);
3156                        elm_interface_atspi_accessible_state_changed_signal_emit(obj, ELM_ATSPI_STATE_ACTIVE, EINA_TRUE);
3157                     }
3158                }
3159           }
3160
3161         elm_widget_atspi(obj, is_atspi);
3162      }
3163 }
3164 //
3165 //
3166 //
3167
3168 void
3169 _elm_win_translate(void)
3170 {
3171    const Eina_List *l;
3172    Evas_Object *obj;
3173
3174    /* TIZEN_ONLY(20160622): Apply paragraph direction when language is changed
3175    EINA_LIST_FOREACH(_elm_win_list, l, obj)
3176      elm_widget_translate(obj);
3177     */
3178    EINA_LIST_FOREACH(_elm_win_list, l, obj)
3179      {
3180         if (!strcmp(E_("default:LTR"), "default:RTL"))
3181           evas_object_paragraph_direction_set(obj, EVAS_BIDI_DIRECTION_ANY_RTL);
3182         else
3183           evas_object_paragraph_direction_set(obj, EVAS_BIDI_DIRECTION_LTR);
3184
3185         elm_widget_translate(obj);
3186      }
3187    /* END */
3188
3189    //TIZEN_ONLY(20161202): Temporary code - Apply mirroring in _elm_win_translate()
3190    if (_elm_config && _elm_config->language_auto_mirrored)
3191      {
3192         if (!strcmp(E_("default:LTR"), "default:RTL"))
3193           elm_config_mirrored_set(EINA_TRUE);
3194         else
3195           elm_config_mirrored_set(EINA_FALSE);
3196      }
3197    //
3198 }
3199
3200 void
3201 _elm_win_focus_reconfigure(void)
3202 {
3203    const Eina_List *l;
3204    Evas_Object *obj;
3205
3206    EINA_LIST_FOREACH(_elm_win_list, l, obj)
3207      elm_widget_focus_reconfigure(obj);
3208 }
3209
3210 #ifdef HAVE_ELEMENTARY_X
3211 static Eina_Bool
3212 _elm_win_client_message(void *data,
3213                         int type EINA_UNUSED,
3214                         void *event)
3215 {
3216    ELM_WIN_DATA_GET(data, sd);
3217    Ecore_X_Event_Client_Message *e = event;
3218
3219    if (e->format != 32) return ECORE_CALLBACK_PASS_ON;
3220    if (e->message_type == ECORE_X_ATOM_E_COMP_FLUSH)
3221      {
3222         if ((unsigned int)e->data.l[0] == sd->x.xwin)
3223           {
3224              Evas *evas = evas_object_evas_get(sd->obj);
3225              if (evas)
3226                {
3227                   edje_file_cache_flush();
3228                   edje_collection_cache_flush();
3229                   evas_image_cache_flush(evas);
3230                   evas_font_cache_flush(evas);
3231                }
3232           }
3233      }
3234    else if (e->message_type == ECORE_X_ATOM_E_COMP_DUMP)
3235      {
3236         if ((unsigned int)e->data.l[0] == sd->x.xwin)
3237           {
3238              Evas *evas = evas_object_evas_get(sd->obj);
3239              if (evas)
3240                {
3241                   edje_file_cache_flush();
3242                   edje_collection_cache_flush();
3243                   evas_image_cache_flush(evas);
3244                   evas_font_cache_flush(evas);
3245                   evas_render_dump(evas);
3246                }
3247           }
3248      }
3249    else if (e->message_type == ECORE_X_ATOM_E_ILLUME_ACCESS_CONTROL)
3250      {
3251         if ((unsigned int)e->data.l[0] == sd->x.xwin)
3252           {
3253              if ((unsigned int)e->data.l[1] ==
3254                  ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_NEXT)
3255                {
3256                   // XXX: call right access func
3257                }
3258              else if ((unsigned int)e->data.l[1] ==
3259                       ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_PREV)
3260                {
3261                   // XXX: call right access func
3262                }
3263              else if ((unsigned int)e->data.l[1] ==
3264                       ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_ACTIVATE)
3265                {
3266                   _elm_access_highlight_object_activate
3267                     (sd->obj, ELM_ACTIVATE_DEFAULT);
3268                }
3269              else if ((unsigned int)e->data.l[1] ==
3270                       ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_READ)
3271                {
3272                   /* there would be better way to read highlight object */
3273                   Evas *evas;
3274                   evas = evas_object_evas_get(sd->obj);
3275                   if (!evas) return ECORE_CALLBACK_PASS_ON;
3276
3277                   _elm_access_mouse_event_enabled_set(EINA_TRUE);
3278
3279                   evas_event_feed_mouse_in(evas, 0, NULL);
3280                   evas_event_feed_mouse_move
3281                     (evas, e->data.l[2], e->data.l[3], 0, NULL);
3282
3283                   _elm_access_mouse_event_enabled_set(EINA_FALSE);
3284                }
3285              else if ((unsigned int)e->data.l[1] ==
3286                       ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_READ_NEXT)
3287                {
3288                   _elm_access_highlight_cycle(sd->obj, ELM_FOCUS_NEXT);
3289                }
3290              else if ((unsigned int)e->data.l[1] ==
3291                       ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_READ_PREV)
3292                {
3293                   _elm_access_highlight_cycle(sd->obj, ELM_FOCUS_PREVIOUS);
3294                }
3295              else if ((unsigned int)e->data.l[1] ==
3296                       ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_UP)
3297                {
3298                   _elm_access_highlight_object_activate
3299                     (sd->obj, ELM_ACTIVATE_UP);
3300                }
3301              else if ((unsigned int)e->data.l[1] ==
3302                       ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_DOWN)
3303                {
3304                   _elm_access_highlight_object_activate
3305                     (sd->obj, ELM_ACTIVATE_DOWN);
3306                }
3307           }
3308      }
3309    return ECORE_CALLBACK_PASS_ON;
3310 }
3311
3312 static Eina_Bool
3313 _elm_win_property_change(void *data,
3314                          int type EINA_UNUSED,
3315                          void *event)
3316 {
3317    ELM_WIN_DATA_GET(data, sd);
3318    Ecore_X_Event_Window_Property *e = event;
3319
3320    if (e->atom == ECORE_X_ATOM_E_ILLUME_INDICATOR_STATE)
3321      {
3322         if (e->win == sd->x.xwin)
3323           {
3324              sd->indmode = (Elm_Win_Indicator_Mode)ecore_x_e_illume_indicator_state_get(e->win);
3325              eo_do(sd->obj, eo_event_callback_call
3326                (ELM_WIN_EVENT_INDICATOR_PROP_CHANGED, NULL));
3327           }
3328      }
3329    return ECORE_CALLBACK_PASS_ON;
3330 }
3331 #endif
3332
3333 static void
3334 _elm_win_focus_highlight_hide(void *data EINA_UNUSED,
3335                               Evas_Object *obj,
3336                               const char *emission EINA_UNUSED,
3337                               const char *source EINA_UNUSED)
3338 {
3339    evas_object_hide(obj);
3340 }
3341
3342 static void
3343 _elm_win_focus_highlight_anim_end(void *data,
3344                                   Evas_Object *obj,
3345                                   const char *emission EINA_UNUSED,
3346                                   const char *source EINA_UNUSED)
3347 {
3348    ELM_WIN_DATA_GET(data, sd);
3349
3350    _elm_win_focus_highlight_simple_setup(sd, obj);
3351 }
3352
3353 static void
3354 _elm_win_focus_skip_set(Elm_Win_Data *sd, Eina_Bool skip)
3355 {
3356    sd->skip_focus = skip;
3357    TRAP(sd, focus_skip_set, skip);
3358 }
3359
3360 static void
3361 _elm_win_focus_highlight_init(Elm_Win_Data *sd)
3362 {
3363    evas_event_callback_add(sd->evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
3364                            _elm_win_object_focus_in, sd->obj);
3365    evas_event_callback_add(sd->evas,
3366                            EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
3367                            _elm_win_object_focus_out, sd->obj);
3368
3369    sd->focus_highlight.cur.target = _elm_win_focus_target_get(evas_focus_get(sd->evas));
3370    if (sd->focus_highlight.cur.target)
3371      {
3372         if (elm_widget_highlight_in_theme_get(sd->focus_highlight.cur.target))
3373           sd->focus_highlight.cur.in_theme = EINA_TRUE;
3374         else
3375           _elm_win_focus_target_callbacks_add(sd);
3376
3377         evas_object_event_callback_add
3378            (sd->focus_highlight.cur.target,
3379             EVAS_CALLBACK_DEL, _elm_win_focus_target_del, sd->obj);
3380      }
3381
3382    sd->focus_highlight.prev.target = NULL;
3383    sd->focus_highlight.fobj = edje_object_add(sd->evas);
3384    sd->focus_highlight.theme_changed = EINA_TRUE;
3385
3386    edje_object_signal_callback_add(sd->focus_highlight.fobj,
3387                                    "elm,action,focus,hide,end", "*",
3388                                    _elm_win_focus_highlight_hide, NULL);
3389    edje_object_signal_callback_add(sd->focus_highlight.fobj,
3390                                    "elm,action,focus,anim,end", "*",
3391                                    _elm_win_focus_highlight_anim_end, sd->obj);
3392    _elm_win_focus_highlight_reconfigure_job_start(sd);
3393 }
3394 static void
3395 _elm_win_accessibility_highlight_init(Elm_Win_Data *sd, Evas_Object *atarget)
3396 {
3397    sd->accessibility_highlight.cur.target = atarget;
3398
3399    Evas_Object *fobj = edje_object_add(sd->evas);
3400    sd->accessibility_highlight.fobj = fobj;
3401    elm_widget_theme_object_set (sd->obj, fobj, "accessibility_highlight", "top", "default");
3402    if (atarget)
3403      {
3404         evas_object_smart_member_add(fobj, atarget);
3405         evas_object_smart_changed(atarget);
3406         _elm_win_accessibility_highlight_callbacks_add(sd);
3407      }
3408 }
3409
3410 static void
3411 _elm_win_frame_cb_move_start(void *data,
3412                              Evas_Object *obj EINA_UNUSED,
3413                              const char *sig EINA_UNUSED,
3414                              const char *source)
3415 {
3416    int ox, oy;
3417
3418    ELM_WIN_DATA_GET(data, sd);
3419
3420    if (!sd) return;
3421
3422 #ifdef HAVE_ELEMENTARY_WAYLAND
3423    if (!strcmp(source, "elm"))
3424      ecore_wl_window_cursor_from_name_set(sd->wl.win, ELM_CURSOR_HAND1);
3425    else
3426      ecore_wl_window_cursor_default_restore(sd->wl.win);
3427 #else
3428    (void)source;
3429 #endif
3430
3431    /* NB: Wayland handles moving surfaces by itself so we cannot
3432     * specify a specific x/y we want. Instead, we will pass in the
3433     * existing x/y values so they can be recorded as 'previous'
3434     * position. The new position will get updated automatically when
3435     * the move is finished */
3436
3437    edje_object_part_geometry_get(sd->frame_obj, "elm.spacer.opaque",
3438                                  &ox, &oy, NULL, NULL);
3439    ecore_evas_wayland_move(sd->ee, ox, oy);
3440 }
3441
3442 static void
3443 _elm_win_frame_cb_move_stop(void *data,
3444                             Evas_Object *obj EINA_UNUSED,
3445                             const char *sig EINA_UNUSED,
3446                             const char *source EINA_UNUSED)
3447 {
3448    ELM_WIN_DATA_GET(data, sd);
3449
3450    if (!sd) return;
3451
3452 #ifdef HAVE_ELEMENTARY_WAYLAND
3453    ecore_wl_window_cursor_default_restore(sd->wl.win);
3454 #endif
3455 }
3456
3457 #ifdef HAVE_ELEMENTARY_WAYLAND
3458 struct _resize_info
3459 {
3460    const char *name;
3461    int location;
3462 };
3463
3464 static struct _resize_info _border_side[4] =
3465 {
3466      { ELM_CURSOR_TOP_SIDE, 1 },
3467      { ELM_CURSOR_LEFT_SIDE, 4 },
3468      { ELM_CURSOR_BOTTOM_SIDE, 2 },
3469      { ELM_CURSOR_RIGHT_SIDE, 8 },
3470 };
3471
3472 static struct _resize_info _border_corner[4] =
3473 {
3474      { ELM_CURSOR_TOP_LEFT_CORNER, 5 },
3475      { ELM_CURSOR_BOTTOM_LEFT_CORNER, 6 },
3476      { ELM_CURSOR_BOTTOM_RIGHT_CORNER, 10 },
3477      { ELM_CURSOR_TOP_RIGHT_CORNER, 9 },
3478 };
3479 #endif
3480
3481 static void
3482 _elm_win_frame_obj_move(void *data,
3483                         Evas *e EINA_UNUSED,
3484                         Evas_Object *obj EINA_UNUSED,
3485                         void *event_info EINA_UNUSED)
3486 {
3487    Elm_Win_Data *sd;
3488
3489    if (!(sd = data)) return;
3490    if (!sd->client_obj) return;
3491
3492    _elm_win_frame_obj_update(sd);
3493 }
3494
3495 static void
3496 _elm_win_frame_obj_resize(void *data,
3497                           Evas *e EINA_UNUSED,
3498                           Evas_Object *obj EINA_UNUSED,
3499                           void *event_info EINA_UNUSED)
3500 {
3501    Elm_Win_Data *sd;
3502
3503    if (!(sd = data)) return;
3504    if (!sd->client_obj) return;
3505
3506    _elm_win_frame_obj_update(sd);
3507 }
3508
3509 static void
3510 _elm_win_frame_cb_resize_show(void *data,
3511                               Evas_Object *obj EINA_UNUSED,
3512                               const char *sig EINA_UNUSED,
3513                               const char *source)
3514 {
3515    ELM_WIN_DATA_GET(data, sd);
3516
3517    if (!sd) return;
3518    if (sd->resizing) return;
3519
3520 #ifdef HAVE_ELEMENTARY_WAYLAND
3521    int i;
3522    i = sd->rot / 90;
3523    if (!strcmp(source, "elm.event.resize.t"))
3524      ecore_wl_window_cursor_from_name_set(sd->wl.win,
3525                                           _border_side[(0 + i) % 4].name);
3526    else if (!strcmp(source, "elm.event.resize.b"))
3527      ecore_wl_window_cursor_from_name_set(sd->wl.win,
3528                                           _border_side[(2 + i) % 4].name);
3529    else if (!strcmp(source, "elm.event.resize.l"))
3530      ecore_wl_window_cursor_from_name_set(sd->wl.win,
3531                                           _border_side[(1 + i) % 4].name);
3532    else if (!strcmp(source, "elm.event.resize.r"))
3533      ecore_wl_window_cursor_from_name_set(sd->wl.win,
3534                                           _border_side[(3 + i) % 4].name);
3535    else if (!strcmp(source, "elm.event.resize.tl"))
3536      ecore_wl_window_cursor_from_name_set(sd->wl.win,
3537                                           _border_corner[(0 + i) % 4].name);
3538    else if (!strcmp(source, "elm.event.resize.tr"))
3539      ecore_wl_window_cursor_from_name_set(sd->wl.win,
3540                                           _border_corner[(3 + i) % 4].name);
3541    else if (!strcmp(source, "elm.event.resize.bl"))
3542      ecore_wl_window_cursor_from_name_set(sd->wl.win,
3543                                           _border_corner[(1 + i) % 4].name);
3544    else if (!strcmp(source, "elm.event.resize.br"))
3545      ecore_wl_window_cursor_from_name_set(sd->wl.win,
3546                                           _border_corner[(2 + i) % 4].name);
3547    else
3548      ecore_wl_window_cursor_default_restore(sd->wl.win);
3549 #else
3550    (void)source;
3551 #endif
3552 }
3553
3554 static void
3555 _elm_win_frame_cb_resize_hide(void *data,
3556                               Evas_Object *obj EINA_UNUSED,
3557                               const char *sig EINA_UNUSED,
3558                               const char *source EINA_UNUSED)
3559 {
3560    ELM_WIN_DATA_GET(data, sd);
3561
3562    if (!sd) return;
3563    if (sd->resizing) return;
3564
3565 #ifdef HAVE_ELEMENTARY_WAYLAND
3566    ecore_wl_window_cursor_default_restore(sd->wl.win);
3567 #endif
3568 }
3569
3570 static void
3571 _elm_win_frame_cb_resize_start(void *data,
3572                                Evas_Object *obj EINA_UNUSED,
3573                                const char *sig EINA_UNUSED,
3574                                const char *source)
3575 {
3576 #ifdef HAVE_ELEMENTARY_WAYLAND
3577    ELM_WIN_DATA_GET(data, sd);
3578    int i;
3579
3580    if (!sd) return;
3581    if (sd->resizing) return;
3582
3583    sd->resizing = EINA_TRUE;
3584    i = sd->rot / 90;
3585    if (!strcmp(source, "elm.event.resize.t"))
3586      sd->resize_location = _border_side[(0 + i) % 4].location;
3587    else if (!strcmp(source, "elm.event.resize.b"))
3588      sd->resize_location = _border_side[(2 + i) % 4].location;
3589    else if (!strcmp(source, "elm.event.resize.l"))
3590      sd->resize_location = _border_side[(1 + i) % 4].location;
3591    else if (!strcmp(source, "elm.event.resize.r"))
3592      sd->resize_location = _border_side[(3 + i) % 4].location;
3593    else if (!strcmp(source, "elm.event.resize.tl"))
3594      sd->resize_location = _border_corner[(0 + i) % 4].location;
3595    else if (!strcmp(source, "elm.event.resize.tr"))
3596      sd->resize_location = _border_corner[(3 + i) % 4].location;
3597    else if (!strcmp(source, "elm.event.resize.bl"))
3598      sd->resize_location = _border_corner[(1 + i) % 4].location;
3599    else if (!strcmp(source, "elm.event.resize.br"))
3600      sd->resize_location = _border_corner[(2 + i) % 4].location;
3601    else
3602      sd->resize_location = 0;
3603
3604    if (sd->resize_location > 0)
3605      ecore_evas_wayland_resize(sd->ee, sd->resize_location);
3606 #else
3607    (void)data;
3608    (void)source;
3609 #endif
3610 }
3611
3612 static void
3613 _elm_win_frame_cb_resize_end(void *data,
3614                              Evas_Object *obj EINA_UNUSED,
3615                              const char *sig EINA_UNUSED,
3616                              const char *source EINA_UNUSED)
3617 {
3618 #ifdef HAVE_ELEMENTARY_WAYLAND
3619    ELM_WIN_DATA_GET(data, sd);
3620
3621    if (!sd) return;
3622    if (sd->resizing) sd->resizing = EINA_FALSE;
3623 #else
3624    (void)data;
3625 #endif
3626 }
3627 static void
3628 _elm_win_frame_cb_minimize(void *data,
3629                            Evas_Object *obj EINA_UNUSED,
3630                            const char *sig EINA_UNUSED,
3631                            const char *source EINA_UNUSED)
3632 {
3633    ELM_WIN_DATA_GET(data, sd);
3634
3635    if (!sd) return;
3636 //   sd->iconified = EINA_TRUE;
3637    TRAP(sd, iconified_set, EINA_TRUE);
3638 }
3639
3640 static void
3641 _elm_win_frame_maximized_state_update(Elm_Win_Data *sd, Eina_Bool maximized)
3642 {
3643    const char *emission;
3644
3645    if (!sd->frame_obj) return;
3646
3647    if (maximized)
3648      emission = "elm,state,maximized";
3649    else
3650      emission = "elm,state,unmaximized";
3651
3652    edje_object_signal_emit(sd->frame_obj, emission, "elm");
3653    edje_object_message_signal_process(sd->frame_obj);
3654    evas_object_smart_calculate(sd->frame_obj);
3655
3656    _elm_win_frame_obj_update(sd);
3657 }
3658
3659 static void
3660 _elm_win_frame_cb_maximize(void *data,
3661                            Evas_Object *obj EINA_UNUSED,
3662                            const char *sig EINA_UNUSED,
3663                            const char *source EINA_UNUSED)
3664 {
3665    Eina_Bool value;
3666    ELM_WIN_DATA_GET(data, sd);
3667
3668    if (!sd) return;
3669    if (sd->maximized) value = EINA_FALSE;
3670    else value = EINA_TRUE;
3671
3672    _elm_win_frame_maximized_state_update(sd, value);
3673
3674    TRAP(sd, maximized_set, value);
3675 }
3676
3677 static void
3678 _elm_win_frame_cb_close(void *data,
3679                         Evas_Object *obj EINA_UNUSED,
3680                         const char *sig EINA_UNUSED,
3681                         const char *source EINA_UNUSED)
3682 {
3683    ELM_WIN_DATA_GET(data, sd);
3684    Evas_Object *win;
3685
3686    /* FIXME: After the current freeze, this should be handled differently.
3687     *
3688     * Ideally, we would want to mimic the X11 backend and use something
3689     * like ECORE_WL_EVENT_WINDOW_DELETE and handle the delete_request
3690     * inside of ecore_evas. That would be the 'proper' way, but since we are
3691     * in a freeze right now, I cannot add a new event value, or a new
3692     * event structure to ecore_wayland.
3693     *
3694     * So yes, this is a temporary 'stop-gap' solution which will be fixed
3695     * when the freeze is over, but it does fix a trac bug for now, and in a
3696     * way which does not break API or the freeze. - dh
3697     */
3698
3699    if (!sd) return;
3700
3701    win = sd->obj;
3702
3703    int autodel = sd->autodel;
3704    sd->autodel_clear = &autodel;
3705    evas_object_ref(win);
3706    eo_do(win, eo_event_callback_call(ELM_WIN_EVENT_DELETE_REQUEST, NULL));
3707    if (sd->autohide)
3708      evas_object_hide(win);
3709    // FIXME: if above callback deletes - then the below will be invalid
3710    if (autodel) evas_object_del(win);
3711    else sd->autodel_clear = NULL;
3712    evas_object_unref(win);
3713 }
3714
3715 #ifdef HAVE_ELEMENTARY_WAYLAND
3716 static void
3717 _elm_win_frame_pre_render(void *data, Evas *e EINA_UNUSED, void *ev EINA_UNUSED)
3718 {
3719    Elm_Win_Data *sd = data;
3720
3721    if (sd->wl.opaque_dirty)
3722      _elm_win_opaque_update(sd);
3723    sd->wl.opaque_dirty = 0;
3724 }
3725 #endif
3726
3727 static void
3728 _elm_win_frame_add(Elm_Win_Data *sd,
3729                    const char *style)
3730 {
3731    Evas_Object *obj = sd->obj;
3732    int w, h, mw, mh;
3733    short layer;
3734
3735    sd->frame_obj = edje_object_add(sd->evas);
3736    layer = evas_object_layer_get(obj);
3737    evas_object_layer_set(sd->frame_obj, layer + 1);
3738    if (!elm_widget_theme_object_set
3739        (sd->obj, sd->frame_obj, "border", "base", style))
3740      {
3741         ELM_SAFE_FREE(sd->frame_obj, evas_object_del);
3742         return;
3743      }
3744
3745    sd->client_obj = evas_object_rectangle_add(sd->evas);
3746    evas_object_color_set(sd->client_obj, 0, 0, 0, 0);
3747    /* NB: Tried pass_events here, but that fails to send events */
3748    evas_object_repeat_events_set(sd->client_obj, EINA_TRUE);
3749    edje_object_part_swallow(sd->frame_obj, "elm.swallow.client",
3750                             sd->client_obj);
3751
3752    evas_object_is_frame_object_set(sd->frame_obj, EINA_TRUE);
3753
3754    if (sd->icon)
3755      evas_object_show(sd->icon);
3756    else
3757      {
3758         Eina_Bool set = EINA_FALSE;
3759
3760         sd->icon = elm_icon_add(sd->obj);
3761
3762         if (sd->icon_name)
3763           set = elm_icon_standard_set(sd->icon, sd->icon_name);
3764         if ((!sd->icon_name) || (!set))
3765           {
3766              Efreet_Desktop *d;
3767              d = efreet_util_desktop_exec_find(_elm_appname);
3768              if (d)
3769                {
3770                   elm_icon_standard_set(sd->icon, d->icon);
3771                   efreet_desktop_free(d);
3772                }
3773           }
3774      }
3775
3776    edje_object_part_swallow(sd->frame_obj, "elm.swallow.icon",
3777                             sd->icon);
3778
3779    evas_object_event_callback_add
3780      (sd->frame_obj, EVAS_CALLBACK_MOVE, _elm_win_frame_obj_move, sd);
3781    evas_object_event_callback_add
3782      (sd->frame_obj, EVAS_CALLBACK_RESIZE, _elm_win_frame_obj_resize, sd);
3783 #ifdef HAVE_ELEMENTARY_WAYLAND
3784    evas_event_callback_add(sd->evas, EVAS_CALLBACK_RENDER_PRE, _elm_win_frame_pre_render, sd);
3785 #endif
3786
3787    /* NB: Do NOT remove these calls !! Needed to calculate proper
3788     * framespace on initial show of the window */
3789    edje_object_size_min_calc(sd->frame_obj, &mw, &mh);
3790    evas_object_move(sd->frame_obj, 0, 0);
3791    evas_object_resize(sd->frame_obj, mw, mh);
3792    evas_object_smart_calculate(sd->frame_obj);
3793
3794    edje_object_signal_callback_add
3795      (sd->frame_obj, "elm,action,move,start", "elm",
3796      _elm_win_frame_cb_move_start, obj);
3797    edje_object_signal_callback_add
3798      (sd->frame_obj, "elm,action,move,stop", "elm",
3799      _elm_win_frame_cb_move_stop, obj);
3800    edje_object_signal_callback_add
3801      (sd->frame_obj, "elm,action,resize,show", "*",
3802      _elm_win_frame_cb_resize_show, obj);
3803    edje_object_signal_callback_add
3804      (sd->frame_obj, "elm,action,resize,hide", "*",
3805      _elm_win_frame_cb_resize_hide, obj);
3806    edje_object_signal_callback_add
3807      (sd->frame_obj, "elm,action,resize,start", "*",
3808      _elm_win_frame_cb_resize_start, obj);
3809    edje_object_signal_callback_add
3810      (sd->frame_obj, "elm,action,resize,end", "*",
3811      _elm_win_frame_cb_resize_end, obj);
3812    edje_object_signal_callback_add
3813      (sd->frame_obj, "elm,action,minimize", "elm",
3814      _elm_win_frame_cb_minimize, obj);
3815    edje_object_signal_callback_add
3816      (sd->frame_obj, "elm,action,maximize", "elm",
3817      _elm_win_frame_cb_maximize, obj);
3818    edje_object_signal_callback_add
3819      (sd->frame_obj, "elm,action,close", "elm", _elm_win_frame_cb_close, obj);
3820
3821    if (sd->title)
3822      {
3823         edje_object_part_text_escaped_set
3824           (sd->frame_obj, "elm.text.title", sd->title);
3825      }
3826
3827    ecore_evas_geometry_get(sd->ee, NULL, NULL, &w, &h);
3828    ecore_evas_resize(sd->ee, w, h);
3829 }
3830
3831 static void
3832 _elm_win_frame_del(Elm_Win_Data *sd)
3833 {
3834    int w, h;
3835
3836    ELM_SAFE_FREE(sd->client_obj, evas_object_del);
3837
3838    if (sd->frame_obj)
3839      {
3840         evas_object_event_callback_del_full
3841           (sd->frame_obj, EVAS_CALLBACK_MOVE, _elm_win_frame_obj_move, sd);
3842         evas_object_event_callback_del_full
3843           (sd->frame_obj, EVAS_CALLBACK_RESIZE, _elm_win_frame_obj_resize, sd);
3844 #ifdef HAVE_ELEMENTARY_WAYLAND
3845         evas_event_callback_del_full(sd->evas, EVAS_CALLBACK_RENDER_PRE, _elm_win_frame_pre_render, sd);
3846 #endif
3847
3848         edje_object_signal_callback_del
3849           (sd->frame_obj, "elm,action,move,start", "elm",
3850               _elm_win_frame_cb_move_start);
3851         edje_object_signal_callback_del
3852           (sd->frame_obj, "elm,action,move,stop", "elm",
3853               _elm_win_frame_cb_move_stop);
3854         edje_object_signal_callback_del
3855           (sd->frame_obj, "elm,action,resize,show", "*",
3856               _elm_win_frame_cb_resize_show);
3857         edje_object_signal_callback_del
3858           (sd->frame_obj, "elm,action,resize,hide", "*",
3859               _elm_win_frame_cb_resize_hide);
3860         edje_object_signal_callback_del
3861           (sd->frame_obj, "elm,action,resize,start", "*",
3862               _elm_win_frame_cb_resize_start);
3863         edje_object_signal_callback_del
3864           (sd->frame_obj, "elm,action,resize,end", "*",
3865               _elm_win_frame_cb_resize_end);
3866         edje_object_signal_callback_del
3867           (sd->frame_obj, "elm,action,minimize", "elm",
3868               _elm_win_frame_cb_minimize);
3869         edje_object_signal_callback_del
3870           (sd->frame_obj, "elm,action,maximize", "elm",
3871               _elm_win_frame_cb_maximize);
3872         edje_object_signal_callback_del
3873           (sd->frame_obj, "elm,action,close", "elm",
3874               _elm_win_frame_cb_close);
3875
3876         ELM_SAFE_FREE(sd->frame_obj, evas_object_del);
3877      }
3878    if (sd->icon) evas_object_hide(sd->icon);
3879
3880    evas_output_framespace_set(sd->evas, 0, 0, 0, 0);
3881    ecore_evas_geometry_get(sd->ee, NULL, NULL, &w, &h);
3882    ecore_evas_resize(sd->ee, w, h);
3883 }
3884
3885 #ifdef ELM_DEBUG
3886 static void
3887 _debug_key_down(void *data EINA_UNUSED,
3888                 Evas *e EINA_UNUSED,
3889                 Evas_Object *obj,
3890                 void *event_info)
3891 {
3892    Evas_Event_Key_Down *ev = event_info;
3893
3894    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
3895      return;
3896
3897    if ((strcmp(ev->key, "F12")) ||
3898        (!evas_key_modifier_is_set(ev->modifiers, "Control")))
3899      return;
3900
3901    INF("Tree graph generated.");
3902    elm_object_tree_dot_dump(obj, "./dump.dot");
3903 }
3904
3905 #endif
3906
3907 static void
3908 _win_inlined_image_set(Elm_Win_Data *sd)
3909 {
3910    evas_object_image_alpha_set(sd->img_obj, EINA_FALSE);
3911    evas_object_image_filled_set(sd->img_obj, EINA_TRUE);
3912
3913    evas_object_event_callback_add
3914      (sd->img_obj, EVAS_CALLBACK_DEL, _elm_win_on_img_obj_del, sd->obj);
3915    evas_object_event_callback_add
3916      (sd->img_obj, EVAS_CALLBACK_HIDE, _win_img_hide, sd->obj);
3917    evas_object_event_callback_add
3918      (sd->img_obj, EVAS_CALLBACK_MOUSE_UP, _win_img_mouse_up, sd->obj);
3919    evas_object_event_callback_add
3920      (sd->img_obj, EVAS_CALLBACK_FOCUS_IN, _win_img_focus_in, sd->obj);
3921    evas_object_event_callback_add
3922      (sd->img_obj, EVAS_CALLBACK_FOCUS_OUT, _win_img_focus_out, sd->obj);
3923 }
3924
3925 static void
3926 _elm_win_on_icon_del(void *data,
3927                      Evas *e EINA_UNUSED,
3928                      Evas_Object *obj,
3929                      void *event_info EINA_UNUSED)
3930 {
3931    ELM_WIN_DATA_GET(data, sd);
3932
3933    if (sd->icon == obj) sd->icon = NULL;
3934 }
3935
3936 EOLIAN static void
3937 _elm_win_evas_object_smart_add(Eo *obj, Elm_Win_Data *_pd EINA_UNUSED)
3938 {
3939    eo_do_super(obj, MY_CLASS, evas_obj_smart_add());
3940
3941    elm_widget_can_focus_set(obj, EINA_TRUE);
3942
3943    elm_widget_highlight_ignore_set(obj, EINA_TRUE);
3944 }
3945
3946 #ifdef HAVE_ELEMENTARY_X
3947 static void
3948 _elm_x_io_err(void *data EINA_UNUSED)
3949 {
3950    Eina_List *l;
3951    Evas_Object *obj;
3952
3953    EINA_LIST_FOREACH(_elm_win_list, l, obj)
3954      eo_do(obj, eo_event_callback_call(ELM_WIN_EVENT_IOERR, NULL));
3955    elm_exit();
3956 }
3957 #endif
3958
3959 // TIZEN_ONLY(20160218): Improve launching performance.
3960 EAPI void
3961 elm_win_precreated_object_set(Evas_Object *obj)
3962 {
3963    INF("Set precreated obj(%p).", obj);
3964    _precreated_win_obj = obj;
3965 }
3966
3967 EAPI Evas_Object *
3968 elm_win_precreated_object_get(void)
3969 {
3970    INF("Get precreated obj(%p).", _precreated_win_obj);
3971    return _precreated_win_obj;
3972 }
3973 //
3974
3975 // TIZEN_ONLY(20160728): Indicator Implementation
3976 #ifdef HAVE_ELEMENTARY_WAYLAND
3977 static Eina_Bool
3978 _elm_win_wl_indicator_flick(void *data, int type EINA_UNUSED, void *event EINA_UNUSED)
3979 {
3980    ELM_WIN_DATA_GET(data, sd);
3981    evas_object_smart_callback_call(sd->obj, SIG_INDICATOR_FLICK_DONE, NULL);
3982    return ECORE_CALLBACK_PASS_ON;
3983 }
3984 #endif
3985 // END
3986
3987 EAPI Evas_Object *
3988 elm_win_add(Evas_Object *parent,
3989             const char *name,
3990             Elm_Win_Type type)
3991 {
3992 //TIZEN_ONLY(20160628):  Add Performance log for cold booting
3993 #ifdef ENABLE_TTRACE
3994    traceBegin(TTRACE_TAG_EFL, "elm_win_add");
3995 #endif
3996 //
3997
3998 //TIZEN_ONLY(20161202): Temporary code - Apply mirroring in elm_win_add()
3999    if (_elm_config && _elm_config->language_auto_mirrored)
4000      {
4001         if (!strcmp(E_("default:LTR"), "default:RTL"))
4002           elm_config_mirrored_set(EINA_TRUE);
4003         else
4004           elm_config_mirrored_set(EINA_FALSE);
4005      }
4006 //
4007
4008 // TIZEN_ONLY(20160218): Improve launching performance.
4009    if (_precreated_win_obj)
4010      {
4011         ELM_WIN_DATA_GET(_precreated_win_obj, sd);
4012
4013         if ((type != ELM_WIN_SOCKET_IMAGE) &&
4014             (type != ELM_WIN_INLINED_IMAGE))
4015           {
4016              if (sd)
4017                {
4018                   if (sd->parent == parent)
4019                     {
4020                        Evas_Object *tmp = _precreated_win_obj;
4021                        TRAP(sd, name_class_set, name, _elm_appname);
4022                        TRAP(sd, title_set, sd->title ? sd->title : name);
4023                        _precreated_win_obj = NULL;
4024                        if (sd->type != type)
4025                          elm_win_type_set(tmp, type);
4026                        INF("Return precreated obj(%p).", tmp);
4027
4028                        //TIZEN_ONLY(20160628):  Add Performance log for cold booting
4029 #ifdef ENABLE_TTRACE
4030                        traceEnd(TTRACE_TAG_EFL);
4031 #endif
4032                        //
4033
4034                        // TIZEN_ONLY(20161202): Apply paragraph direction
4035                        if (!strcmp(E_("default:LTR"), "default:RTL"))
4036                          evas_object_paragraph_direction_set(tmp, EVAS_BIDI_DIRECTION_ANY_RTL);
4037                        else
4038                          evas_object_paragraph_direction_set(tmp, EVAS_BIDI_DIRECTION_LTR);
4039                        //
4040
4041                        return tmp;
4042                     }
4043                }
4044           }
4045         Evas_Object *bg = elm_bg_precreated_object_get();
4046         if (bg)
4047           {
4048              evas_object_del(bg);
4049              elm_bg_precreated_object_set(NULL);
4050           }
4051         Evas_Object *conform = elm_conformant_precreated_object_get();
4052         if (conform)
4053           {
4054              evas_object_del(conform);
4055              elm_conformant_precreated_object_set(NULL);
4056           }
4057         evas_object_del(_precreated_win_obj);
4058         _precreated_win_obj = NULL;
4059      }
4060 //
4061
4062    Evas_Object *obj = eo_add(MY_CLASS, parent,
4063                              elm_obj_win_name_set(name),
4064                              elm_obj_win_type_set(type));
4065 //TIZEN_ONLY(20160628):  Add Performance log for cold booting
4066 #ifdef ENABLE_TTRACE
4067    traceEnd(TTRACE_TAG_EFL);
4068 #endif
4069 //
4070
4071
4072    return obj;
4073 }
4074
4075 EAPI Evas_Object *
4076 elm_win_fake_add(Ecore_Evas *ee)
4077 {
4078    return eo_add(MY_CLASS, NULL,
4079          elm_obj_win_fake_canvas_set(ee),
4080          elm_obj_win_name_set(NULL),
4081          elm_obj_win_type_set(ELM_WIN_FAKE));
4082 }
4083
4084 static void
4085 _elm_win_cb_hide(void *data EINA_UNUSED,
4086                  Evas *e EINA_UNUSED,
4087                  Evas_Object *obj EINA_UNUSED,
4088                  void *event_info EINA_UNUSED)
4089 {
4090    _elm_win_state_eval_queue();
4091 }
4092
4093 static void
4094 _elm_win_cb_show(void *data EINA_UNUSED,
4095                  Evas *e EINA_UNUSED,
4096                  Evas_Object *obj EINA_UNUSED,
4097                  void *event_info EINA_UNUSED)
4098 {
4099    _elm_win_state_eval_queue();
4100 }
4101
4102 /**
4103   * @internal
4104   *
4105   * Recalculate the size of window considering its resize objects' weight and
4106   * min size. If any of its resize objects' weight equals to 0.0, window
4107   * layout's weight will be set to 0.0.
4108   *
4109   * @param o box object
4110   * @param p box's private data
4111   * @param data window object
4112   */
4113 static void
4114 _window_layout_stack(Evas_Object *o, Evas_Object_Box_Data *p, void *data)
4115 {
4116    const Eina_List *l;
4117    Evas_Object *child;
4118    Evas_Object_Box_Option *opt;
4119    Evas_Coord x, y, w, h;
4120    double wx, wy;
4121    Evas_Coord minw = -1, minh = -1;
4122    double weight_x = EVAS_HINT_EXPAND;
4123    double weight_y = EVAS_HINT_EXPAND;
4124
4125    EINA_LIST_FOREACH(p->children, l, opt)
4126      {
4127         child = opt->obj;
4128         evas_object_size_hint_weight_get(child, &wx, &wy);
4129         if (wx == 0.0) weight_x = 0;
4130         if (wy == 0.0) weight_y = 0;
4131
4132         evas_object_size_hint_min_get(child, &w, &h);
4133         if (w > minw) minw = w;
4134         if (h > minh) minh = h;
4135      }
4136
4137    evas_object_size_hint_min_set(o, minw, minh);
4138    evas_object_geometry_get(o, &x, &y, &w, &h);
4139    if (w < minw) w = minw;
4140    if (h < minh) h = minh;
4141    evas_object_resize(o, w, h);
4142
4143    EINA_LIST_FOREACH(p->children, l, opt)
4144      {
4145         child = opt->obj;
4146         evas_object_move(child, x, y);
4147         evas_object_resize(child, w, h);
4148      }
4149
4150    ELM_WIN_DATA_GET(data, sd);
4151    evas_object_size_hint_weight_set(sd->edje, weight_x, weight_y);
4152    evas_object_smart_changed(sd->edje);
4153 }
4154
4155 static Eina_Bool
4156 _accel_is_gl(void)
4157 {
4158    const char *env = NULL;
4159    const char *str = NULL;
4160
4161    if (_elm_config->accel) str = _elm_config->accel;
4162    if (_elm_accel_preference) str = _elm_accel_preference;
4163    if ((_elm_config->accel_override) && (_elm_config->accel))
4164      str = _elm_config->accel;
4165    env = getenv("ELM_ACCEL");
4166    if (env) str = env;
4167    if ((str) &&
4168        ((!strcasecmp(str, "gl")) ||
4169         (!strcasecmp(str, "opengl")) ||
4170         (!strcasecmp(str, "3d")) ||
4171         (!strcasecmp(str, "hw")) ||
4172         (!strcasecmp(str, "accel")) ||
4173         (!strcasecmp(str, "hardware"))
4174        ))
4175      return EINA_TRUE;
4176    return EINA_FALSE;
4177 }
4178
4179 static Eina_Bool
4180 _animator_tick_cb(void *_obj)
4181 {
4182    Elm_Win *obj = _obj;
4183    eo_do(obj, eo_event_callback_call(ELM_WIN_EVENT_ANIMATOR_TICK, NULL));
4184
4185    return ECORE_CALLBACK_RENEW;
4186 }
4187
4188 static Eina_Bool
4189 _cb_added(void *_data,
4190           Eo *obj,
4191           const Eo_Event_Description *desc EINA_UNUSED,
4192           void *event_info)
4193 {
4194    const Eo_Callback_Array_Item *event = event_info;
4195    Elm_Win_Data *data = _data;
4196
4197    if (event->desc == ELM_WIN_EVENT_ANIMATOR_TICK)
4198      {
4199         data->animator.wants++;
4200         if (data->animator.wants == 1)
4201           {
4202              data->animator.obj = eo_add(ECORE_ANIMATOR_CLASS, obj,
4203                    ecore_animator_constructor(_animator_tick_cb, obj));
4204           }
4205      }
4206
4207    return EO_CALLBACK_CONTINUE;
4208 }
4209
4210 static Eina_Bool
4211 _cb_deled(void *_data,
4212           Eo *obj EINA_UNUSED,
4213           const Eo_Event_Description *desc EINA_UNUSED,
4214           void *event_info)
4215 {
4216    const Eo_Callback_Array_Item *event = event_info;
4217    Elm_Win_Data *data = _data;
4218
4219    if (event->desc == ELM_WIN_EVENT_ANIMATOR_TICK)
4220      {
4221         data->animator.wants--;
4222         if (data->animator.wants == 0)
4223           {
4224              eo_del(data->animator.obj);
4225              data->animator.obj = NULL;
4226           }
4227      }
4228
4229    return EO_CALLBACK_CONTINUE;
4230 }
4231
4232 static Eo *
4233 _elm_win_finalize_internal(Eo *obj, Elm_Win_Data *sd, const char *name, Elm_Win_Type type)
4234 {
4235    sd->obj = obj; // in ctor
4236
4237    Evas_Object *parent = NULL;
4238    Evas *e;
4239    const Eina_List *l;
4240    const char *fontpath, *engine = NULL, *enginelist[32], *disp;
4241    int i, p = 0;
4242
4243    Elm_Win_Data tmp_sd;
4244
4245    eo_do(obj, parent = eo_parent_get());
4246
4247    /* just to store some data while trying out to create a canvas */
4248    memset(&tmp_sd, 0, sizeof(Elm_Win_Data));
4249
4250    switch (type)
4251      {
4252       case ELM_WIN_FAKE:
4253         tmp_sd.ee = sd->ee;
4254         break;
4255       case ELM_WIN_INLINED_IMAGE:
4256         if (!parent) break;
4257           {
4258              e = evas_object_evas_get(parent);
4259              Ecore_Evas *ee;
4260
4261              if (!e) break;
4262
4263              ee = ecore_evas_ecore_evas_get(e);
4264              if (!ee) break;
4265
4266              tmp_sd.img_obj = ecore_evas_object_image_new(ee);
4267              if (!tmp_sd.img_obj) break;
4268
4269              tmp_sd.ee = ecore_evas_object_ecore_evas_get(tmp_sd.img_obj);
4270              if (!tmp_sd.ee)
4271                {
4272                   ELM_SAFE_FREE(tmp_sd.img_obj, evas_object_del);
4273                }
4274           }
4275         break;
4276
4277       case ELM_WIN_SOCKET_IMAGE:
4278         tmp_sd.ee = ecore_evas_extn_socket_new(1, 1);
4279         break;
4280
4281       default:
4282         disp = getenv("ELM_DISPLAY");
4283         if ((disp) && (!strcmp(disp, "ews")))
4284           {
4285              enginelist[p++] = ELM_EWS;
4286           }
4287         else if ((disp) && (!strcmp(disp, "buffer")))
4288           {
4289              enginelist[p++] = ELM_BUFFER;
4290           }
4291         else if ((disp) && (!strcmp(disp, "shot")))
4292           {
4293              enginelist[p++] = ENGINE_GET();
4294           }
4295 // welcome to ifdef hell! :)
4296
4297 #ifdef HAVE_ELEMENTARY_X
4298         else if ((disp) && (!strcmp(disp, "x11")))
4299           {
4300              if (_accel_is_gl())
4301                {
4302                   enginelist[p++] = ELM_OPENGL_X11;
4303                   enginelist[p++] = ELM_SOFTWARE_X11;
4304                }
4305              else
4306                {
4307                   enginelist[p++] = ELM_SOFTWARE_X11;
4308                   enginelist[p++] = ELM_OPENGL_X11;
4309                }
4310           }
4311 #endif
4312
4313 #ifdef HAVE_ELEMENTARY_WAYLAND
4314         else if ((disp) && (!strcmp(disp, "wl")))
4315           {
4316              if (_accel_is_gl())
4317                {
4318                   enginelist[p++] = ELM_WAYLAND_EGL;
4319                   enginelist[p++] = ELM_WAYLAND_SHM;
4320                }
4321              else
4322                {
4323                   enginelist[p++] = ELM_WAYLAND_SHM;
4324                   enginelist[p++] = ELM_WAYLAND_EGL;
4325                }
4326           }
4327 #endif
4328
4329 #ifdef HAVE_ELEMENTARY_WIN32
4330         else if ((disp) && (!strcmp(disp, "win")))
4331           {
4332              enginelist[p++] = ELM_SOFTWARE_WIN32;
4333              enginelist[p++] = ELM_SOFTWARE_DDRAW;
4334           }
4335 #endif
4336
4337 #ifdef HAVE_ELEMENTARY_SDL
4338         else if ((disp) && (!strcmp(disp, "sdl")))
4339           {
4340              if (_accel_is_gl())
4341                {
4342                   enginelist[p++] = ELM_OPENGL_SDL;
4343                   enginelist[p++] = ELM_SOFTWARE_SDL;
4344                }
4345              else
4346                {
4347                   enginelist[p++] = ELM_SOFTWARE_SDL;
4348                   enginelist[p++] = ELM_OPENGL_SDL;
4349                }
4350           }
4351 #endif
4352
4353 #ifdef HAVE_ELEMENTARY_COCOA
4354         else if ((disp) && (!strcmp(disp, "mac")))
4355           {
4356              enginelist[p++] = ELM_OPENGL_COCOA;
4357           }
4358 #endif
4359
4360 #if defined(HAVE_ELEMENTARY_DRM) || defined(HAVE_ELEMENTARY_FB)
4361         else if ((disp) && (!strcmp(disp, "fb")))
4362           {
4363 #ifdef HAVE_ELEMENTARY_DRM
4364              enginelist[p++] = ELM_DRM;
4365 #endif
4366 #ifdef HAVE_ELEMENTARY_FB
4367              enginelist[p++] = ELM_SOFTWARE_FB;
4368 #endif
4369           }
4370 #endif
4371
4372 #ifdef HAVE_ELEMENTARY_PSL1GHT
4373         else if ((disp) && (!strcmp(disp, "ps3")))
4374           {
4375              enginelist[p++] = ELM_SOFTWARE_PSL1GHT;
4376           }
4377 #endif
4378 #ifdef HAVE_ELEMENTARY_X
4379         else if (!_elm_preferred_engine &&
4380                  getenv("DISPLAY") && !getenv("ELM_ENGINE"))
4381           {
4382              if (_accel_is_gl())
4383                {
4384                   enginelist[p++] = ELM_OPENGL_X11;
4385                   enginelist[p++] = ELM_SOFTWARE_X11;
4386                }
4387              else
4388                {
4389                   enginelist[p++] = ELM_SOFTWARE_X11;
4390                   enginelist[p++] = ELM_OPENGL_X11;
4391                }
4392           }
4393 #endif
4394 #ifdef HAVE_ELEMENTARY_WAYLAND
4395         else if (!_elm_preferred_engine &&
4396                  getenv("WAYLAND_DISPLAY") && !getenv("ELM_ENGINE"))
4397           {
4398              if (_accel_is_gl())
4399                {
4400                   enginelist[p++] = ELM_WAYLAND_EGL;
4401                   enginelist[p++] = ELM_WAYLAND_SHM;
4402                }
4403              else
4404                {
4405                   enginelist[p++] = ELM_WAYLAND_SHM;
4406                   enginelist[p++] = ELM_WAYLAND_EGL;
4407                }
4408           }
4409 #endif
4410         else
4411           {
4412              if (_accel_is_gl())
4413                {
4414 // add all engines with selected engine first - if any
4415                   if (ENGINE_GET())
4416                     enginelist[p++] = ENGINE_GET();
4417
4418 // add all engines with gl/accelerated ones first - only engines compiled
4419 #ifdef HAVE_ELEMENTARY_X
4420                   enginelist[p++] = ELM_OPENGL_X11;
4421 #endif
4422 #ifdef HAVE_ELEMENTARY_WAYLAND
4423                   enginelist[p++] = ELM_WAYLAND_EGL;
4424 #endif
4425 #ifdef HAVE_ELEMENTARY_DRM
4426                   enginelist[p++] = ELM_DRM;
4427 #endif
4428 #ifdef HAVE_ELEMENTARY_FB
4429                   enginelist[p++] = ELM_SOFTWARE_FB;
4430 #endif
4431 #ifdef HAVE_ELEMENTARY_COCOA
4432                   enginelist[p++] = ELM_OPENGL_COCOA;
4433 #endif
4434 #ifdef HAVE_ELEMENTARY_SDL
4435                   enginelist[p++] = ELM_OPENGL_SDL;
4436 #endif
4437 #ifdef HAVE_ELEMENTARY_X
4438                   enginelist[p++] = ELM_SOFTWARE_X11;
4439 #endif
4440 #ifdef HAVE_ELEMENTARY_WAYLAND
4441                   enginelist[p++] = ELM_WAYLAND_SHM;
4442 #endif
4443 #ifdef HAVE_ELEMENTARY_WIN32
4444                   enginelist[p++] = ELM_SOFTWARE_WIN32;
4445                   enginelist[p++] = ELM_SOFTWARE_DDRAW;
4446 #endif
4447 #ifdef HAVE_ELEMENTARY_SDL
4448                   enginelist[p++] = ELM_SOFTWARE_SDL;
4449 #endif
4450 #ifdef HAVE_ELEMENTARY_PSL1GHT
4451                   enginelist[p++] = ELM_SOFTWARE_PSL1GHT;
4452 #endif
4453                }
4454              else
4455                {
4456 // add all engines with selected engine first - if any
4457                   if (elm_config_preferred_engine_get())
4458                     enginelist[p++] = elm_config_preferred_engine_get();
4459 // add check _elm_gl_preference whether "none" or not
4460                   else if (_elm_config->engine &&
4461                            elm_config_accel_preference_get() &&
4462                            !strcmp(elm_config_accel_preference_get(),"none"))
4463                     enginelist[p++] = _elm_config->engine;
4464 // add all engines with gl/accelerated ones first - only engines compiled
4465 #ifdef HAVE_ELEMENTARY_X
4466                   enginelist[p++] = ELM_SOFTWARE_X11;
4467 #endif
4468 #ifdef HAVE_ELEMENTARY_WAYLAND
4469                   enginelist[p++] = ELM_WAYLAND_SHM;
4470 #endif
4471 #ifdef HAVE_ELEMENTARY_DRM
4472                   enginelist[p++] = ELM_DRM;
4473 #endif
4474 #ifdef HAVE_ELEMENTARY_FB
4475                   enginelist[p++] = ELM_SOFTWARE_FB;
4476 #endif
4477 #ifdef HAVE_ELEMENTARY_COCOA
4478                   enginelist[p++] = ELM_OPENGL_COCOA;
4479 #endif
4480 #ifdef HAVE_ELEMENTARY_WIN32
4481                   enginelist[p++] = ELM_SOFTWARE_WIN32;
4482                   enginelist[p++] = ELM_SOFTWARE_DDRAW;
4483 #endif
4484 #ifdef HAVE_ELEMENTARY_SDL
4485                   enginelist[p++] = ELM_SOFTWARE_SDL;
4486 #endif
4487 #ifdef HAVE_ELEMENTARY_X
4488                   enginelist[p++] = ELM_OPENGL_X11;
4489 #endif
4490 #ifdef HAVE_ELEMENTARY_WAYLAND
4491                   enginelist[p++] = ELM_WAYLAND_EGL;
4492 #endif
4493 #ifdef HAVE_ELEMENTARY_DRM
4494                   enginelist[p++] = ELM_DRM;
4495 #endif
4496 #ifdef HAVE_ELEMENTARY_SDL
4497                   enginelist[p++] = ELM_OPENGL_SDL;
4498 #endif
4499 #ifdef HAVE_ELEMENTARY_PSL1GHT
4500                   enginelist[p++] = ELM_SOFTWARE_PSL1GHT;
4501 #endif
4502                }
4503           }
4504
4505         for (i = 0; i < p; i++)
4506           {
4507              if (!strcmp(enginelist[i], ELM_SOFTWARE_X11))
4508                tmp_sd.ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
4509              else if (!strcmp(enginelist[i], ELM_OPENGL_X11))
4510                {
4511                   int opt[20], opt_i = 0;
4512
4513                   if (_elm_config->vsync)
4514                     {
4515                        opt[opt_i++] = ECORE_EVAS_GL_X11_OPT_VSYNC;
4516                        opt[opt_i++] = 1;
4517                     }
4518                   if (_elm_config->gl_depth)
4519                     {
4520                        opt[opt_i++] = ECORE_EVAS_GL_X11_OPT_GL_DEPTH;
4521                        opt[opt_i++] = _elm_config->gl_depth;
4522                     }
4523                   if (_elm_config->gl_stencil)
4524                     {
4525                        opt[opt_i++] = ECORE_EVAS_GL_X11_OPT_GL_STENCIL;
4526                        opt[opt_i++] = _elm_config->gl_stencil;
4527                     }
4528                   if (_elm_config->gl_msaa)
4529                     {
4530                        opt[opt_i++] = ECORE_EVAS_GL_X11_OPT_GL_MSAA;
4531                        opt[opt_i++] = _elm_config->gl_msaa;
4532                     }
4533                   opt[opt_i] = 0;
4534                   if (opt_i > 0)
4535                     tmp_sd.ee = ecore_evas_gl_x11_options_new(NULL, 0, 0, 0, 1, 1, opt);
4536                   else
4537                     tmp_sd.ee = ecore_evas_gl_x11_new(NULL, 0, 0, 0, 1, 1);
4538                }
4539              else if (!strcmp(enginelist[i], ELM_WAYLAND_SHM))
4540                tmp_sd.ee = ecore_evas_wayland_shm_new(NULL, 0, 0, 0, 1, 1, 0);
4541              else if (!strcmp(enginelist[i], ELM_WAYLAND_EGL))
4542                {
4543                   int opt[20], opt_i = 0;
4544
4545                   if (_elm_config->vsync)
4546                     {
4547                        opt[opt_i++] = ECORE_EVAS_OPT_VSYNC;
4548                        opt[opt_i++] = 1;
4549                     }
4550                   if (_elm_config->gl_depth)
4551                     {
4552                        opt[opt_i++] = ECORE_EVAS_OPT_GL_DEPTH;
4553                        opt[opt_i++] = _elm_config->gl_depth;
4554                     }
4555                   if (_elm_config->gl_stencil)
4556                     {
4557                        opt[opt_i++] = ECORE_EVAS_OPT_GL_STENCIL;
4558                        opt[opt_i++] = _elm_config->gl_stencil;
4559                     }
4560                   if (_elm_config->gl_msaa)
4561                     {
4562                        opt[opt_i++] = ECORE_EVAS_OPT_GL_MSAA;
4563                        opt[opt_i++] = _elm_config->gl_msaa;
4564                     }
4565                   opt[opt_i] = 0;
4566                   if (opt_i > 0)
4567                     tmp_sd.ee = ecore_evas_wayland_egl_options_new(NULL, 0, 0, 0, 1, 1, 0, opt);
4568                   else
4569                     tmp_sd.ee = ecore_evas_wayland_egl_new(NULL, 0, 0, 0, 1, 1, 0);
4570                }
4571              else if (!strcmp(enginelist[i], ELM_SOFTWARE_WIN32))
4572                tmp_sd.ee = ecore_evas_software_gdi_new(NULL, 0, 0, 1, 1);
4573              else if (!strcmp(enginelist[i], ELM_SOFTWARE_DDRAW))
4574                tmp_sd.ee = ecore_evas_software_ddraw_new(NULL, 0, 0, 1, 1);
4575              else if (!strcmp(enginelist[i], ELM_SOFTWARE_SDL))
4576                tmp_sd.ee = ecore_evas_sdl_new(NULL, 0, 0, 0, 0, 0, 1);
4577              else if (!strcmp(enginelist[i], ELM_OPENGL_SDL))
4578                tmp_sd.ee = ecore_evas_gl_sdl_new(NULL, 1, 1, 0, 0);
4579              else if (!strcmp(enginelist[i], ELM_OPENGL_COCOA))
4580                tmp_sd.ee = ecore_evas_cocoa_new(NULL, 1, 1, 0, 0);
4581              else if (!strcmp(enginelist[i], ELM_EWS))
4582                tmp_sd.ee = ecore_evas_ews_new(0, 0, 1, 1);
4583              else if (!strcmp(enginelist[i], ELM_SOFTWARE_FB))
4584                tmp_sd.ee = ecore_evas_fb_new(NULL, 0, 1, 1);
4585              else if (!strcmp(enginelist[i], ELM_BUFFER))
4586                tmp_sd.ee = ecore_evas_buffer_new(1, 1);
4587              else if (!strcmp(enginelist[i], ELM_SOFTWARE_PSL1GHT))
4588                tmp_sd.ee = ecore_evas_psl1ght_new(NULL, 1, 1);
4589              else if (!strcmp(enginelist[i], ELM_DRM))
4590                tmp_sd.ee = ecore_evas_drm_new(NULL, 0, 0, 0, 1, 1);
4591              else if (!strncmp(enginelist[i], "shot:", 5))
4592                {
4593                   tmp_sd.ee = ecore_evas_buffer_new(1, 1);
4594                   ecore_evas_manual_render_set(tmp_sd.ee, EINA_TRUE);
4595                   tmp_sd.shot.info = eina_stringshare_add(ENGINE_GET() + 5);
4596                }
4597              engine = enginelist[i];
4598              if (tmp_sd.ee) break;
4599           }
4600         break;
4601      }
4602
4603    if (!tmp_sd.ee)
4604      {
4605         ERR("Cannot create window.");
4606         return NULL;
4607      }
4608
4609    eo_do(obj, eo_parent_set(ecore_evas_get(tmp_sd.ee)));
4610
4611    eo_do_super(obj, MY_CLASS, eo_constructor());
4612    eo_do(obj,
4613          evas_obj_type_set(MY_CLASS_NAME_LEGACY),
4614          evas_obj_smart_callbacks_descriptions_set(_smart_callbacks));
4615
4616    if (getenv("ELM_FIRST_FRAME"))
4617      evas_event_callback_add(ecore_evas_get(tmp_sd.ee), EVAS_CALLBACK_RENDER_POST,
4618                              _elm_win_first_frame_do, getenv("ELM_FIRST_FRAME"));
4619
4620    /* copying possibly altered fields back */
4621 #define SD_CPY(_field)             \
4622   do                               \
4623     {                              \
4624        sd->_field = tmp_sd._field; \
4625     } while (0)
4626
4627    SD_CPY(ee);
4628    SD_CPY(img_obj);
4629    SD_CPY(shot.info);
4630 #undef SD_CPY
4631
4632    if ((type != ELM_WIN_FAKE) && (trap) && (trap->add))
4633      sd->trap_data = trap->add(obj);
4634
4635    /* complementary actions, which depend on final smart data
4636     * pointer */
4637    if (type == ELM_WIN_INLINED_IMAGE)
4638      _win_inlined_image_set(sd);
4639 #ifdef HAVE_ELEMENTARY_X
4640    else if ((engine) &&
4641             ((!strcmp(engine, ELM_SOFTWARE_X11)) ||
4642              (!strcmp(engine, ELM_OPENGL_X11))))
4643      {
4644         sd->x.client_message_handler = ecore_event_handler_add
4645             (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, obj);
4646         sd->x.property_handler = ecore_event_handler_add
4647             (ECORE_X_EVENT_WINDOW_PROPERTY, _elm_win_property_change, obj);
4648      }
4649 #endif
4650 #ifdef HAVE_ELEMENTARY_WAYLAND
4651    else if ((engine) &&
4652             ((!strcmp(engine, ELM_WAYLAND_SHM)) ||
4653              (!strcmp(engine, ELM_WAYLAND_EGL))))
4654      {
4655         sd->wl.effect_start_handler = ecore_event_handler_add
4656            (ECORE_WL_EVENT_EFFECT_START, _elm_win_wl_effect_start, obj);
4657         sd->wl.effect_end_handler = ecore_event_handler_add
4658            (ECORE_WL_EVENT_EFFECT_END, _elm_win_wl_effect_end, obj);
4659         // TIZEN_ONLY(20160801): indicator implementation
4660         sd->wl.indicator_flick_handler = ecore_event_handler_add
4661            (ECORE_WL_EVENT_INDICATOR_FLICK, _elm_win_wl_indicator_flick, obj);
4662         // END
4663         sd->wl.aux_msg_handler = ecore_event_handler_add
4664            (ECORE_WL_EVENT_AUX_MESSAGE, _elm_win_wl_aux_message, obj);
4665      }
4666 #endif
4667    else if ((engine) && (!strncmp(engine, "shot:", 5)))
4668      _shot_init(sd);
4669    //TIZEN_ONLY(20161121) tizen don't have canvas mouse up event like opensource now.
4670    //window should deal with mouse up event related with move resize.
4671    sd->mouse_up_handler = ecore_event_handler_add
4672       (ECORE_EVENT_MOUSE_BUTTON_UP, _elm_win_mouse_up, obj);
4673
4674    sd->kbdmode = ELM_WIN_KEYBOARD_UNKNOWN;
4675    sd->indmode = ELM_WIN_INDICATOR_UNKNOWN;
4676
4677 #ifdef HAVE_ELEMENTARY_X
4678    _internal_elm_win_xwindow_get(sd);
4679    if (sd->x.xwin)
4680      {
4681         ecore_x_io_error_handler_set(_elm_x_io_err, NULL);
4682      }
4683 #endif
4684
4685 #ifdef HAVE_ELEMENTARY_WAYLAND
4686    _elm_win_wlwindow_get(sd);
4687 #endif
4688
4689 #ifdef HAVE_ELEMENTARY_COCOA
4690    _elm_win_cocoawindow_get(sd);
4691 #endif
4692 #ifdef HAVE_ELEMENTARY_WIN32
4693    _internal_elm_win_win32window_get(sd);
4694 #endif
4695
4696    if ((_elm_config->bgpixmap)
4697 #ifdef HAVE_ELEMENTARY_X
4698        &&
4699        (((sd->x.xwin) && (!ecore_x_screen_is_composited(0))) ||
4700            (!sd->x.xwin)))
4701 #else
4702      )
4703 #endif
4704      TRAP(sd, avoid_damage_set, ECORE_EVAS_AVOID_DAMAGE_EXPOSE);
4705    // bg pixmap done by x - has other issues like can be redrawn by x before it
4706    // is filled/ready by app
4707    //     TRAP(sd, avoid_damage_set, ECORE_EVAS_AVOID_DAMAGE_BUILT_IN);
4708
4709    sd->type = type;
4710    sd->parent = parent;
4711    sd->modal_count = 0;
4712    sd->withdrawn = ecore_evas_withdrawn_get(sd->ee);
4713    sd->obscured = ecore_evas_obscured_get(sd->ee);
4714
4715    if (sd->parent)
4716      {
4717 #ifdef HAVE_ELEMENTARY_WAYLAND
4718         if ((sd->type >= ELM_WIN_BASIC) && (sd->type <= ELM_WIN_DND))
4719           ecore_wl_window_parent_set(sd->wl.win, elm_win_wl_window_get(sd->parent));
4720 #endif
4721         evas_object_event_callback_add
4722           (sd->parent, EVAS_CALLBACK_DEL, _elm_win_on_parent_del, obj);
4723      }
4724
4725 // TIZEN_ONLY(20161114): Sync the state of indicator with window manager
4726 #ifdef HAVE_ELEMENTARY_WAYLAND
4727    if (sd->wl.win)
4728      ecore_wl_indicator_visible_type_set(sd->wl.win, ECORE_WL_INDICATOR_VISIBLE_TYPE_SHOWN);
4729 #endif
4730 // END
4731
4732    sd->evas = ecore_evas_get(sd->ee);
4733
4734    evas_object_color_set(obj, 0, 0, 0, 0);
4735    evas_object_move(obj, 0, 0);
4736    evas_object_resize(obj, 1, 1);
4737    evas_object_pass_events_set(obj, EINA_TRUE);
4738
4739    if (type == ELM_WIN_INLINED_IMAGE)
4740      elm_widget_parent2_set(obj, parent);
4741
4742    /* use own version of ecore_evas_object_associate() that does TRAP() */
4743    ecore_evas_data_set(sd->ee, "elm_win", obj);
4744
4745    if (type != ELM_WIN_FAKE)
4746      {
4747         evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
4748            _elm_win_obj_callback_changed_size_hints, obj);
4749         evas_object_intercept_raise_callback_add
4750           (obj, _elm_win_obj_intercept_raise, obj);
4751         evas_object_intercept_lower_callback_add
4752           (obj, _elm_win_obj_intercept_lower, obj);
4753         evas_object_intercept_stack_above_callback_add
4754           (obj, _elm_win_obj_intercept_stack_above, obj);
4755         evas_object_intercept_stack_below_callback_add
4756           (obj, _elm_win_obj_intercept_stack_below, obj);
4757         evas_object_intercept_layer_set_callback_add
4758           (obj, _elm_win_obj_intercept_layer_set, obj);
4759         evas_object_intercept_show_callback_add
4760           (obj, _elm_win_obj_intercept_show, obj);
4761      }
4762
4763    TRAP(sd, name_class_set, name, _elm_appname);
4764    TRAP(sd, title_set, sd->title);
4765    ecore_evas_callback_delete_request_set(sd->ee, _elm_win_delete_request);
4766    ecore_evas_callback_state_change_set(sd->ee, _elm_win_state_change);
4767    ecore_evas_callback_focus_in_set(sd->ee, _elm_win_focus_in);
4768    ecore_evas_callback_focus_out_set(sd->ee, _elm_win_focus_out);
4769    ecore_evas_callback_resize_set(sd->ee, _elm_win_resize);
4770    ecore_evas_callback_move_set(sd->ee, _elm_win_move);
4771    if (type != ELM_WIN_FAKE)
4772      ecore_evas_callback_mouse_in_set(sd->ee, _elm_win_mouse_in);
4773    evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _elm_win_cb_hide, NULL);
4774    evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _elm_win_cb_show, NULL);
4775
4776    evas_image_cache_set(sd->evas, (_elm_config->image_cache * 1024));
4777    evas_font_cache_set(sd->evas, (_elm_config->font_cache * 1024));
4778
4779    EINA_LIST_FOREACH(_elm_config->font_dirs, l, fontpath)
4780      evas_font_path_append(sd->evas, fontpath);
4781
4782    if (!_elm_config->font_hinting)
4783      evas_font_hinting_set(sd->evas, EVAS_FONT_HINTING_NONE);
4784    else if (_elm_config->font_hinting == 1)
4785      evas_font_hinting_set(sd->evas, EVAS_FONT_HINTING_AUTO);
4786    else if (_elm_config->font_hinting == 2)
4787      evas_font_hinting_set(sd->evas, EVAS_FONT_HINTING_BYTECODE);
4788
4789    sd->wm_rot.wm_supported = ecore_evas_wm_rotation_supported_get(sd->ee);
4790    sd->wm_rot.preferred_rot = -1; // it means that elm_win doesn't use preferred rotation.
4791
4792 #ifdef HAVE_ELEMENTARY_X
4793    _elm_win_xwin_update(sd);
4794 #endif
4795 #ifdef HAVE_ELEMENTARY_WAYLAND
4796    _elm_win_wlwin_update(sd);
4797 #endif
4798
4799    /* do not append to list; all windows render as black rects */
4800
4801    sd->frame_style = eina_stringshare_add("default");
4802    if (type != ELM_WIN_FAKE)
4803      {
4804         _elm_win_list = eina_list_append(_elm_win_list, obj);
4805         _elm_win_count++;
4806
4807         if ((engine) && ((!strcmp(engine, ELM_SOFTWARE_FB)) || (!strcmp(engine, ELM_DRM))))
4808           {
4809              TRAP(sd, fullscreen_set, 1);
4810           }
4811         else if ((type != ELM_WIN_INLINED_IMAGE) &&
4812                  (!_elm_config->win_no_border) && //TIZEN_ONLY(20160601): In order to avoid creating unnecessary part.
4813                  ((engine) &&
4814                   ((!strcmp(engine, ELM_WAYLAND_SHM) ||
4815                    (!strcmp(engine, ELM_WAYLAND_EGL))))))
4816           _elm_win_frame_add(sd, sd->frame_style);
4817
4818         if (_elm_config->focus_highlight_enable)
4819           elm_win_focus_highlight_enabled_set(obj, EINA_TRUE);
4820         if (_elm_config->focus_highlight_animate)
4821           elm_win_focus_highlight_animate_set(obj, EINA_TRUE);
4822
4823         //Prohibiting auto-rendering, until elm_win is shown.
4824         if (_elm_config->auto_norender_withdrawn)
4825           {
4826              if (elm_win_withdrawn_get(obj))
4827                {
4828                   if (!evas_object_data_get(obj, "__win_auto_norender"))
4829                     {
4830                        elm_win_norender_push(obj);
4831                        evas_object_data_set(obj, "__win_auto_norender", obj);
4832                     }
4833                }
4834           }
4835      }
4836
4837 #ifdef ELM_DEBUG
4838    Evas_Modifier_Mask mask = evas_key_modifier_mask_get(sd->evas, "Control");
4839    evas_object_event_callback_add
4840      (obj, EVAS_CALLBACK_KEY_DOWN, _debug_key_down, NULL);
4841
4842    if (evas_object_key_grab(obj, "F12", mask, 0, EINA_TRUE))
4843      INF("Ctrl+F12 key combination exclusive for dot tree generation\n");
4844    else
4845      ERR("failed to grab F12 key to elm widgets (dot) tree generation");
4846 #endif
4847
4848    if (type != ELM_WIN_FAKE)
4849      {
4850         if ((_elm_config->softcursor_mode == ELM_SOFTCURSOR_MODE_ON) ||
4851             ((_elm_config->softcursor_mode == ELM_SOFTCURSOR_MODE_AUTO) &&
4852              ((engine) &&
4853               ((!strcmp(engine, ELM_SOFTWARE_FB)) || (!strcmp(engine, ELM_DRM))))))
4854           {
4855              Evas_Object *o;
4856              Evas_Coord mw = 1, mh = 1, hx = 0, hy = 0;
4857
4858              sd->pointer.obj = o = edje_object_add(ecore_evas_get(tmp_sd.ee));
4859              _elm_theme_object_set(obj, o, "pointer", "base", "default");
4860              edje_object_size_min_calc(o, &mw, &mh);
4861              evas_object_resize(o, mw, mh);
4862              edje_object_part_geometry_get(o, "elm.swallow.hotspot",
4863                                            &hx, &hy, NULL, NULL);
4864              sd->pointer.hot_x = hx;
4865              sd->pointer.hot_y = hy;
4866              evas_object_show(o);
4867              ecore_evas_object_cursor_set(tmp_sd.ee, o, EVAS_LAYER_MAX, hx, hy);
4868           }
4869         else if (_elm_config->softcursor_mode == ELM_SOFTCURSOR_MODE_OFF)
4870           {
4871              // do nothing
4872           }
4873      }
4874
4875    sd->edje = edje_object_add(sd->evas);
4876    _elm_win_theme_internal(obj, sd);
4877
4878    //TIZEN_ONLY(20161208): supported floating window
4879    if (type != ELM_WIN_BASIC)
4880      edje_object_signal_emit(sd->edje, "elm,state,floating,on", "elm");
4881    //
4882    sd->box = evas_object_box_add(sd->evas);
4883    evas_object_box_layout_set(sd->box, _window_layout_stack, obj, NULL);
4884    edje_object_part_swallow(sd->edje, "elm.swallow.contents", sd->box);
4885    evas_object_move(sd->edje, 0, 0);
4886    evas_object_resize(sd->edje, 1, 1);
4887    if (type != ELM_WIN_FAKE)
4888      {
4889         edje_object_update_hints_set(sd->edje, EINA_TRUE);
4890         evas_object_event_callback_add(sd->edje, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
4891                                        _elm_win_on_resize_obj_changed_size_hints, obj);
4892      }
4893
4894    eo_do(obj, elm_interface_atspi_accessible_role_set(ELM_ATSPI_ROLE_WINDOW));
4895    if (_elm_atspi_enabled())
4896      elm_interface_atspi_window_created_signal_emit(obj);
4897
4898    if(_elm_config->win_no_border)
4899      _elm_win_borderless_set(obj, sd, EINA_TRUE);
4900
4901    evas_object_show(sd->edje);
4902
4903    eo_do(obj, eo_event_callback_add(EO_EV_CALLBACK_ADD, _cb_added, sd),
4904          eo_event_callback_add(EO_EV_CALLBACK_DEL, _cb_deled, sd));
4905    if (type == ELM_WIN_FAKE)
4906      {
4907         _elm_win_resize_job(obj);
4908         _elm_win_move(sd->ee);
4909      }
4910
4911    /* TIZEN_ONLY(20160622): Apply paragraph direction when language is changed */
4912    if (!strcmp(E_("default:LTR"), "default:RTL"))
4913      evas_object_paragraph_direction_set(obj, EVAS_BIDI_DIRECTION_ANY_RTL);
4914    else
4915      evas_object_paragraph_direction_set(obj, EVAS_BIDI_DIRECTION_LTR);
4916    /* END */
4917
4918    return obj;
4919 }
4920
4921 EOLIAN static Eo *
4922 _elm_win_eo_base_finalize(Eo *obj, Elm_Win_Data *_pd)
4923 {
4924    obj = _elm_win_finalize_internal(obj, _pd, _pd->name, _pd->type);
4925    if (obj)
4926      {
4927         eo_do_super(obj, MY_CLASS, obj = eo_finalize());
4928      }
4929    return obj;
4930 }
4931
4932 EOLIAN static Eo *
4933 _elm_win_eo_base_constructor(Eo *obj, Elm_Win_Data *_pd EINA_UNUSED)
4934 {
4935    /* Do nothing. */
4936    /* XXX: We are calling the constructor chain from the finalizer. It's
4937     * really bad and hacky. Needs fixing. */
4938
4939    return obj;
4940 }
4941
4942 EOLIAN static void
4943 _elm_win_fake_canvas_set(Eo *obj EINA_UNUSED, Elm_Win_Data *pd, Ecore_Evas *oee)
4944 {
4945    pd->ee = oee;
4946 }
4947
4948 EOLIAN static void
4949 _elm_win_type_set(Eo *obj, Elm_Win_Data *sd, Elm_Win_Type type)
4950 {
4951    Eina_Bool finalized;
4952    if (eo_do_ret(obj, finalized, eo_finalized_get()))
4953      {
4954 // TIZEN_ONLY(20160720): Allowed changing type after initializing
4955 #ifdef HAVE_ELEMENTARY_WAYLAND
4956         sd->type = type;
4957         _elm_win_wlwin_update(sd);
4958         //TIZEN_ONLY(20161208): supported floating window
4959         if (type != ELM_WIN_BASIC)
4960           edje_object_signal_emit(sd->edje, "elm,state,floating,on", "elm");
4961         else
4962           edje_object_signal_emit(sd->edje, "elm,state,floating,off", "elm");
4963         //
4964 #endif
4965 //
4966         ERR("This function is only allowed during construction.");
4967         return;
4968      }
4969    sd->type = type;
4970 }
4971
4972 EOLIAN static Elm_Win_Type
4973 _elm_win_type_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
4974 {
4975    return sd->type;
4976 }
4977
4978 EOLIAN static void
4979 _elm_win_name_set(Eo *obj, Elm_Win_Data *sd, const char *name)
4980 {
4981    Eina_Bool finalized;
4982    if (eo_do_ret(obj, finalized, eo_finalized_get()))
4983      {
4984         ERR("This function is only allowed during construction.");
4985         return;
4986      }
4987    sd->name = eina_stringshare_add(name);
4988 }
4989
4990 EOLIAN static void
4991 _elm_win_noblank_set(Eo *obj EINA_UNUSED, Elm_Win_Data *pd, Eina_Bool noblank)
4992 {
4993    noblank = !!noblank;
4994    if (pd->noblank == noblank) return;
4995    pd->noblank = noblank;
4996    _win_noblank_eval();
4997 }
4998
4999 EOLIAN static Eina_Bool
5000 _elm_win_noblank_get(Eo *obj EINA_UNUSED, Elm_Win_Data *pd)
5001 {
5002    return pd->noblank;
5003 }
5004
5005 EOLIAN static void *
5006 _elm_win_trap_data_get(Eo *obj EINA_UNUSED, Elm_Win_Data *pd)
5007 {
5008    return pd->trap_data;
5009 }
5010
5011
5012 EAPI Evas_Object *
5013 elm_win_util_standard_add(const char *name, const char *title)
5014 {
5015    Evas_Object *win, *bg;
5016
5017    win = elm_win_add(NULL, name, ELM_WIN_BASIC);
5018    if (!win) return NULL;
5019
5020    elm_win_title_set(win, title);
5021    bg = elm_bg_add(win);
5022    if (!bg)
5023      {
5024         evas_object_del(win);
5025         return NULL;
5026      }
5027    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
5028    elm_win_resize_object_add(win, bg);
5029    evas_object_show(bg);
5030
5031    return win;
5032 }
5033
5034 EAPI Evas_Object *
5035 elm_win_util_dialog_add(Evas_Object *parent, const char *name, const char *title)
5036 {
5037    Evas_Object *win, *bg;
5038
5039    win = elm_win_add(parent, name, ELM_WIN_DIALOG_BASIC);
5040    if (!win) return NULL;
5041
5042    elm_win_title_set(win, title);
5043    bg = elm_bg_add(win);
5044    if (!bg)
5045      {
5046         evas_object_del(win);
5047         return NULL;
5048      }
5049    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
5050    elm_win_resize_object_add(win, bg);
5051    evas_object_show(bg);
5052
5053    return win;
5054 }
5055
5056 EOLIAN static void
5057 _elm_win_resize_object_add(Eo *obj, Elm_Win_Data *sd, Evas_Object *subobj)
5058 {
5059    elm_widget_sub_object_add(obj, subobj);
5060
5061    if (!evas_object_box_append(sd->box, subobj))
5062      ERR("could not append %p to box", subobj);
5063 }
5064
5065 EOLIAN static void
5066 _elm_win_resize_object_del(Eo *obj, Elm_Win_Data *sd, Evas_Object *subobj)
5067 {
5068    if (!elm_widget_sub_object_del(obj, subobj))
5069      ERR("could not remove sub object %p from %p", subobj, obj);
5070
5071    evas_object_box_remove(sd->box, subobj);
5072 }
5073
5074 // TIZEN_ONLY(20170212): pend rotation until app set rotation
5075
5076 /* Efl don't have any plan to open new API to support the client rotation.(ex: elm_win_rotation_set)
5077  * But it is need that apps deal with rotation
5078  * For example, if the app want to do the object rotation effect during the rotation,
5079  * canvas should not be rotated until app's rotation effect ends.
5080  * so until to decide app's rotaion policy,
5081  * just use the "wm.policy.win.rot.render.nopending" aux_hint.
5082  * Using this hint, elm- ecore_evas - engine -tizen display server will manage the pending rotation.
5083 */
5084
5085 static int
5086 _elm_win_wm_pending_rotation_set(Evas_Object *obj EINA_UNUSED, const char *hint EINA_UNUSED, const char *val)
5087 {
5088    ELM_WIN_CHECK(obj) -1;
5089    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, -1);
5090
5091    int id = -1;
5092
5093    //TODO: aux_hint_del, aux_hint_val_set.
5094    //Currently only 1 is available.
5095
5096    if (!val || (strncmp(val, "1", 1))) return -1;
5097    id = ecore_evas_aux_hint_add(sd->ee, "wm.policy.win.rot.render.nopending", val);
5098
5099    if (id == -1)
5100      {
5101         ERR("PendingRotation: elm_win pending_rotation_set aux id failed");
5102         //return id;
5103      }
5104    sd->wm_rot.rotation_pending = EINA_TRUE;
5105    DBG("PendingRotation: elm_win rotation_pending_set sucess");
5106    return id;
5107 }
5108 //
5109
5110 EOLIAN static void
5111 _elm_win_title_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, const char *title)
5112 {
5113    if (!title) return;
5114    eina_stringshare_replace(&(sd->title), title);
5115    if (sd->ee)
5116      TRAP(sd, title_set, sd->title);
5117    if (sd->frame_obj)
5118      edje_object_part_text_escaped_set
5119        (sd->frame_obj, "elm.text.title", sd->title);
5120 }
5121
5122 EOLIAN static const char*
5123 _elm_win_title_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
5124 {
5125    return sd->title;
5126 }
5127
5128 EOLIAN static void
5129 _elm_win_icon_name_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, const char *icon_name)
5130 {
5131    if (!icon_name) return;
5132    eina_stringshare_replace(&(sd->icon_name), icon_name);
5133 #ifdef HAVE_ELEMENTARY_X
5134    _elm_win_xwin_update(sd);
5135 #endif
5136 }
5137
5138 EOLIAN static const char*
5139 _elm_win_icon_name_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
5140 {
5141    return sd->icon_name;
5142 }
5143
5144 EOLIAN static void
5145 _elm_win_role_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, const char *role)
5146 {
5147    if (!role) return;
5148    eina_stringshare_replace(&(sd->role), role);
5149 #ifdef HAVE_ELEMENTARY_X
5150    _elm_win_xwin_update(sd);
5151 #endif
5152 #ifdef HAVE_ELEMENTARY_WAYLAND
5153    ecore_wl_window_role_set(sd->wl.win, role);
5154 #endif
5155 }
5156
5157 EOLIAN static const char*
5158 _elm_win_role_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
5159 {
5160    return sd->role;
5161 }
5162
5163 EOLIAN static void
5164 _elm_win_icon_object_set(Eo *obj, Elm_Win_Data *sd, Evas_Object *icon)
5165 {
5166    if (sd->icon)
5167      evas_object_event_callback_del_full(sd->icon, EVAS_CALLBACK_DEL,
5168        _elm_win_on_icon_del, obj);
5169    evas_object_del(sd->icon);
5170    sd->icon = icon;
5171    if (sd->icon)
5172      {
5173         evas_object_event_callback_add(sd->icon, EVAS_CALLBACK_DEL,
5174           _elm_win_on_icon_del, obj);
5175         if (sd->frame_obj)
5176           edje_object_part_swallow(sd->frame_obj, "elm.swallow.icon", sd->icon);
5177      }
5178 #ifdef HAVE_ELEMENTARY_X
5179    _elm_win_xwin_update(sd);
5180 //TIZEN_ONLY(160628): To support an app window icon on SDK UI Tools.
5181 #elif HAVE_ELEMENTARY_WIN32
5182    const char *path;
5183    elm_image_file_get(icon, &path, NULL);
5184    ecore_win32_window_icon_set(ecore_evas_win32_window_get(sd->ee), path);
5185 #endif
5186 }
5187
5188 EOLIAN static const Evas_Object*
5189 _elm_win_icon_object_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
5190 {
5191    return sd->icon;
5192 }
5193
5194 EOLIAN static void
5195 _elm_win_autodel_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool autodel)
5196 {
5197    sd->autodel = autodel;
5198 }
5199
5200 EOLIAN static Eina_Bool
5201 _elm_win_autodel_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
5202 {
5203    return sd->autodel;
5204 }
5205
5206 EOLIAN static void
5207 _elm_win_autohide_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool autohide)
5208 {
5209    sd->autohide = autohide;
5210 }
5211
5212 EOLIAN static Eina_Bool
5213 _elm_win_autohide_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
5214 {
5215    return sd->autohide;
5216 }
5217
5218 EOLIAN static void
5219 _elm_win_activate(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
5220 {
5221    TRAP(sd, activate);
5222 }
5223
5224 EOLIAN static void
5225 _elm_win_lower(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
5226 {
5227    TRAP(sd, lower);
5228 }
5229
5230 EOLIAN static void
5231 _elm_win_raise(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
5232 {
5233    TRAP(sd, raise);
5234 }
5235
5236 EOLIAN static void
5237 _elm_win_center(Eo *obj, Elm_Win_Data *sd, Eina_Bool h, Eina_Bool v)
5238 {
5239    int win_w, win_h, screen_w, screen_h, nx, ny;
5240
5241    if ((trap) && (trap->center) && (!trap->center(sd->trap_data, obj, h, v)))
5242      return;
5243
5244    ecore_evas_screen_geometry_get(sd->ee, NULL, NULL, &screen_w, &screen_h);
5245    if ((!screen_w) || (!screen_h)) return;
5246
5247    evas_object_geometry_get(obj, &nx, &ny, &win_w, &win_h);
5248    if ((!win_w) || (!win_h)) return;
5249
5250    if (h) nx = win_w >= screen_w ? 0 : (screen_w / 2) - (win_w / 2);
5251    if (v) ny = win_h >= screen_h ? 0 : (screen_h / 2) - (win_h / 2);
5252    if (nx < sd->screen.x) nx = sd->screen.x;
5253    if (ny < sd->screen.y) ny = sd->screen.y;
5254
5255    evas_object_move(obj, nx, ny);
5256 }
5257
5258 EOLIAN static void
5259 _elm_win_borderless_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool borderless)
5260 {
5261    const char *engine_name = ecore_evas_engine_name_get(sd->ee);
5262    Eina_Bool need_frame = engine_name &&
5263                           ((!strcmp(engine_name, ELM_WAYLAND_SHM)) ||
5264                            (!strcmp(engine_name, ELM_WAYLAND_EGL)));
5265
5266    if (need_frame)
5267      need_frame = !sd->fullscreen;
5268
5269    if (borderless)
5270      {
5271         if (need_frame)
5272           _elm_win_frame_del(sd);
5273      }
5274    else
5275      {
5276         if (need_frame)
5277           _elm_win_frame_add(sd, sd->frame_style);
5278
5279         if (sd->frame_obj)
5280           evas_object_show(sd->frame_obj);
5281      }
5282
5283    sd->borderless = borderless;
5284
5285    TRAP(sd, borderless_set, borderless);
5286 #ifdef HAVE_ELEMENTARY_X
5287    _elm_win_xwin_update(sd);
5288 #endif
5289 }
5290
5291 EOLIAN static Eina_Bool
5292 _elm_win_borderless_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
5293 {
5294    return ecore_evas_borderless_get(sd->ee);
5295 }
5296
5297 EOLIAN static void
5298 _elm_win_border_style_set(Eo *obj, Elm_Win_Data *sd, const char *style)
5299 {
5300    Elm_Theme *theme;
5301    char buf[1024];
5302
5303    if (!style) return;
5304    if (!strcmp(sd->frame_style, style))
5305      return;
5306
5307    theme = elm_widget_theme_get(obj);
5308    if (!theme) theme = elm_theme_default_get();
5309    if (theme)
5310      {
5311         snprintf(buf, sizeof(buf), "elm/border/base/%s", style);
5312         if (!elm_theme_group_path_find(theme, buf))
5313           return;
5314      }
5315
5316    eina_stringshare_replace(&(sd->frame_style), style);
5317
5318    if (sd->frame_obj)
5319      {
5320         _elm_win_frame_del(sd);
5321         _elm_win_frame_add(sd, sd->frame_style);
5322
5323         if (sd->frame_obj)
5324           evas_object_show(sd->frame_obj);
5325      }
5326 }
5327
5328 EOLIAN static const char*
5329 _elm_win_border_style_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
5330 {
5331    return sd->frame_style;
5332 }
5333
5334 EOLIAN static void
5335 _elm_win_shaped_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool shaped)
5336 {
5337    TRAP(sd, shaped_set, shaped);
5338 #ifdef HAVE_ELEMENTARY_X
5339    _elm_win_xwin_update(sd);
5340 #endif
5341 }
5342
5343 EOLIAN static Eina_Bool
5344 _elm_win_shaped_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
5345 {
5346    return ecore_evas_shaped_get(sd->ee);
5347 }
5348
5349 EOLIAN static void
5350 _elm_win_alpha_set(Eo *obj, Elm_Win_Data *sd, Eina_Bool enabled)
5351 {
5352    sd->application_alpha = enabled;
5353    _elm_win_apply_alpha(obj, sd);
5354 }
5355
5356 EOLIAN static Eina_Bool
5357 _elm_win_alpha_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
5358 {
5359    if (sd->img_obj)
5360      {
5361         return evas_object_image_alpha_get(sd->img_obj);
5362      }
5363    else
5364      {
5365         return ecore_evas_alpha_get(sd->ee);
5366      }
5367
5368    return EINA_FALSE;
5369 }
5370
5371 EOLIAN static void
5372 _elm_win_override_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool override)
5373 {
5374    TRAP(sd, override_set, override);
5375 #ifdef HAVE_ELEMENTARY_X
5376    _elm_win_xwin_update(sd);
5377 #endif
5378 }
5379
5380 EOLIAN static Eina_Bool
5381 _elm_win_override_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
5382 {
5383    return ecore_evas_override_get(sd->ee);
5384 }
5385
5386 EOLIAN static void
5387 _elm_win_fullscreen_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool fullscreen)
5388 {
5389    const char *engine_name = ecore_evas_engine_name_get(sd->ee);
5390    // YYY: handle if sd->img_obj
5391    if (engine_name &&
5392        ((!strcmp(engine_name, ELM_SOFTWARE_FB)) ||
5393         (!strcmp(engine_name, ELM_DRM))))
5394      {
5395         // these engines... can ONLY be fullscreen
5396         return;
5397      }
5398    else if (sd->type == ELM_WIN_FAKE)
5399      sd->fullscreen = !!fullscreen;
5400    else
5401      {
5402 //        sd->fullscreen = fullscreen;
5403         Eina_Bool need_frame = engine_name &&
5404                                ((!strcmp(engine_name, ELM_WAYLAND_SHM)) ||
5405                                 (!strcmp(engine_name, ELM_WAYLAND_EGL)));
5406
5407         if (need_frame)
5408           need_frame = !ecore_evas_borderless_get(sd->ee);
5409
5410         TRAP(sd, fullscreen_set, fullscreen);
5411
5412         if (fullscreen)
5413           {
5414              if (need_frame)
5415                _elm_win_frame_del(sd);
5416           }
5417         else
5418           {
5419              if (need_frame)
5420                _elm_win_frame_add(sd, sd->frame_style);
5421
5422              if (sd->frame_obj)
5423                evas_object_show(sd->frame_obj);
5424           }
5425 #ifdef HAVE_ELEMENTARY_X
5426         _elm_win_xwin_update(sd);
5427 #endif
5428      }
5429 }
5430
5431 EOLIAN static Eina_Bool
5432 _elm_win_fullscreen_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
5433 {
5434    const char *engine_name = ecore_evas_engine_name_get(sd->ee);
5435
5436    if (engine_name &&
5437        ((!strcmp(engine_name, ELM_SOFTWARE_FB)) ||
5438         (!strcmp(engine_name, ELM_DRM))))
5439      {
5440         // these engines... can ONLY be fullscreen
5441         return EINA_TRUE;
5442      }
5443    return sd->fullscreen;
5444 }
5445
5446 static void
5447 _dbus_menu_set(Eina_Bool dbus_connect, void *data)
5448 {
5449    ELM_WIN_DATA_GET_OR_RETURN(data, sd);
5450
5451    if (dbus_connect)
5452      {
5453         DBG("Setting menu to D-Bus");
5454         edje_object_part_unswallow(sd->edje, sd->main_menu);
5455         edje_object_signal_emit(sd->edje, "elm,action,hide_menu", "elm");
5456         _elm_menu_menu_bar_hide(sd->main_menu);
5457      }
5458    else
5459      {
5460         DBG("Setting menu to local mode");
5461         edje_object_part_swallow(sd->edje, "elm.swallow.menu", sd->main_menu);
5462         edje_object_signal_emit(sd->edje, "elm,action,show_menu", "elm");
5463         evas_object_show(sd->main_menu);
5464      }
5465 }
5466
5467 EOLIAN static Evas_Object *
5468 _elm_win_main_menu_get(Eo *obj, Elm_Win_Data *sd)
5469 {
5470    if (sd->main_menu) goto end;
5471
5472    sd->main_menu = elm_menu_add(obj);
5473    _elm_menu_menu_bar_set(sd->main_menu, EINA_TRUE);
5474
5475 #ifdef HAVE_ELEMENTARY_X
5476    Eina_Bool use_dbus = EINA_FALSE;
5477
5478    if (!_elm_config->disable_external_menu && sd->x.xwin) use_dbus = EINA_TRUE;
5479
5480    if (use_dbus && _elm_dbus_menu_register(sd->main_menu))
5481      {
5482         _elm_dbus_menu_app_menu_register(sd->x.xwin, sd->main_menu,
5483                                          _dbus_menu_set, obj);
5484      }
5485    else
5486 #endif
5487      _dbus_menu_set(EINA_FALSE, obj);
5488
5489 end:
5490    return sd->main_menu;
5491 }
5492
5493 EOLIAN static void
5494 _elm_win_maximized_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool maximized)
5495 {
5496    _elm_win_frame_maximized_state_update(sd, maximized);
5497    // YYY: handle if sd->img_obj
5498    TRAP(sd, maximized_set, maximized);
5499 #ifdef HAVE_ELEMENTARY_X
5500    _elm_win_xwin_update(sd);
5501 #endif
5502 }
5503
5504 EOLIAN static Eina_Bool
5505 _elm_win_maximized_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
5506 {
5507    return sd->maximized;
5508 }
5509
5510 EOLIAN static void
5511 _elm_win_iconified_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool iconified)
5512 {
5513 //   sd->iconified = iconified;
5514    TRAP(sd, iconified_set, iconified);
5515 #ifdef HAVE_ELEMENTARY_X
5516    _elm_win_xwin_update(sd);
5517 #endif
5518 }
5519
5520 EOLIAN static Eina_Bool
5521 _elm_win_iconified_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
5522 {
5523    return sd->iconified;
5524 }
5525
5526 EOLIAN static void
5527 _elm_win_withdrawn_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool withdrawn)
5528 {
5529 //   sd->withdrawn = withdrawn;
5530    TRAP(sd, withdrawn_set, withdrawn);
5531 #ifdef HAVE_ELEMENTARY_X
5532    _elm_win_xwin_update(sd);
5533 #endif
5534 }
5535
5536 EOLIAN static Eina_Bool
5537 _elm_win_withdrawn_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
5538 {
5539    return sd->withdrawn;
5540 }
5541
5542 EOLIAN static void
5543 _elm_win_available_profiles_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, const char **profiles, unsigned int count)
5544 {
5545    Eina_Bool found = EINA_FALSE;
5546
5547    _elm_win_available_profiles_del(sd);
5548    if ((profiles) && (count >= 1))
5549      {
5550         sd->profile.available_list = calloc(count, sizeof(char *));
5551         if (sd->profile.available_list)
5552           {
5553              if (!sd->profile.name) found = EINA_TRUE;
5554
5555              unsigned int i;
5556              for (i = 0; i < count; i++)
5557                {
5558                   sd->profile.available_list[i] = eina_stringshare_add(profiles[i]);
5559
5560                   /* check to see if a given array has a current profile of elm_win */
5561                   if ((sd->profile.name) &&
5562                       (!strcmp(sd->profile.name, profiles[i])))
5563                     {
5564                        found = EINA_TRUE;
5565                     }
5566                }
5567              sd->profile.count = count;
5568           }
5569      }
5570
5571    if (ecore_evas_window_profile_supported_get(sd->ee))
5572      {
5573         ecore_evas_window_available_profiles_set(sd->ee,
5574                                                  sd->profile.available_list,
5575                                                  sd->profile.count);
5576
5577         /* current profile of elm_win is wrong, change profile */
5578         if ((sd->profile.available_list) && (!found))
5579           {
5580              eina_stringshare_replace(&(sd->profile.name),
5581                                       sd->profile.available_list[0]);
5582              ecore_evas_window_profile_set(sd->ee, sd->profile.name);
5583           }
5584
5585      }
5586    else
5587      {
5588         if (sd->profile.available_list)
5589           _elm_win_profile_update(sd);
5590      }
5591 }
5592
5593 EOLIAN static Eina_Bool
5594 _elm_win_available_profiles_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, char ***profiles, unsigned int *count)
5595 {
5596    if (ecore_evas_window_profile_supported_get(sd->ee))
5597      {
5598         return ecore_evas_window_available_profiles_get(sd->ee,
5599                                                        profiles,
5600                                                        count);
5601      }
5602    else
5603      {
5604         if (profiles) *profiles = (char **)sd->profile.available_list;
5605         if (count) *count = sd->profile.count;
5606         return EINA_TRUE;
5607      }
5608 }
5609
5610 EOLIAN static void
5611 _elm_win_profile_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, const char *profile)
5612 {
5613    /* check to see if a given profile is present in an available profiles */
5614    if ((profile) && (sd->profile.available_list))
5615      {
5616         Eina_Bool found = EINA_FALSE;
5617         unsigned int i;
5618         for (i = 0; i < sd->profile.count; i++)
5619           {
5620              if (!strcmp(profile,
5621                          sd->profile.available_list[i]))
5622                {
5623                   found = EINA_TRUE;
5624                   break;
5625                }
5626           }
5627         if (!found) return;
5628      }
5629
5630    if (ecore_evas_window_profile_supported_get(sd->ee))
5631      {
5632         if (!profile) _elm_win_profile_del(sd);
5633         ecore_evas_window_profile_set(sd->ee, profile);
5634      }
5635    else
5636      {
5637         if (_internal_elm_win_profile_set(sd, profile))
5638           _elm_win_profile_update(sd);
5639      }
5640 }
5641
5642 EOLIAN static const char*
5643 _elm_win_profile_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
5644 {
5645    return sd->profile.name;
5646 }
5647
5648 EOLIAN static void
5649 _elm_win_urgent_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool urgent)
5650 {
5651    if (sd->urgent == urgent)
5652      return;
5653    sd->urgent = urgent;
5654    TRAP(sd, urgent_set, urgent);
5655 #ifdef HAVE_ELEMENTARY_X
5656    _elm_win_xwin_update(sd);
5657 #endif
5658 }
5659
5660 EOLIAN static Eina_Bool
5661 _elm_win_urgent_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
5662 {
5663    return sd->urgent;
5664 }
5665
5666 EOLIAN static void
5667 _elm_win_demand_attention_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool demand_attention)
5668 {
5669    sd->demand_attention = demand_attention;
5670    TRAP(sd, demand_attention_set, demand_attention);
5671 #ifdef HAVE_ELEMENTARY_X
5672    _elm_win_xwin_update(sd);
5673 #endif
5674 }
5675
5676 EOLIAN static Eina_Bool
5677 _elm_win_demand_attention_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
5678 {
5679    return sd->demand_attention;
5680 }
5681
5682 EOLIAN static void
5683 _elm_win_modal_set(Eo *obj, Elm_Win_Data *sd, Eina_Bool modal)
5684 {
5685    if (sd->modal_count) return;
5686
5687    const Eina_List *l;
5688    Evas_Object *current;
5689
5690    if ((modal) && (!sd->modal) && (evas_object_visible_get(obj)))
5691      {
5692        INCREMENT_MODALITY()
5693      }
5694    else if ((!modal) && (sd->modal) && (evas_object_visible_get(obj)))
5695      {
5696        DECREMENT_MODALITY()
5697      }
5698
5699    sd->modal = modal;
5700    TRAP(sd, modal_set, modal);
5701 #ifdef HAVE_ELEMENTARY_X
5702    _elm_win_xwin_update(sd);
5703 #endif
5704 }
5705
5706 EOLIAN static Eina_Bool
5707 _elm_win_modal_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
5708 {
5709    return sd->modal;
5710 }
5711
5712 EOLIAN static void
5713 _elm_win_aspect_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, double aspect)
5714 {
5715    sd->aspect = aspect;
5716    TRAP(sd, aspect_set, aspect);
5717 #ifdef HAVE_ELEMENTARY_X
5718    _elm_win_xwin_update(sd);
5719 #endif
5720 }
5721
5722 EOLIAN static double
5723 _elm_win_aspect_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
5724 {
5725    return sd->aspect;
5726 }
5727
5728 EOLIAN static void
5729 _elm_win_size_base_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, int w, int h)
5730 {
5731    sd->size_base_w = w;
5732    sd->size_base_h = h;
5733    TRAP(sd, size_base_set, w, h);
5734 #ifdef HAVE_ELEMENTARY_X
5735    _elm_win_xwin_update(sd);
5736 #endif
5737 }
5738
5739 EOLIAN static void
5740 _elm_win_size_base_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, int *w, int *h)
5741 {
5742    if (w) *w = sd->size_base_w;
5743    if (h) *h = sd->size_base_h;
5744 }
5745
5746 EOLIAN static void
5747 _elm_win_size_step_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, int w, int h)
5748 {
5749    sd->size_step_w = w;
5750    sd->size_step_h = h;
5751    TRAP(sd, size_step_set, w, h);
5752 #ifdef HAVE_ELEMENTARY_X
5753    _elm_win_xwin_update(sd);
5754 #endif
5755 }
5756
5757 EOLIAN static void
5758 _elm_win_size_step_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, int *w, int *h)
5759 {
5760    if (w) *w = sd->size_step_w;
5761    if (h) *h = sd->size_step_h;
5762 }
5763
5764 EOLIAN static void
5765 _elm_win_layer_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, int layer)
5766 {
5767    TRAP(sd, layer_set, layer);
5768 #ifdef HAVE_ELEMENTARY_X
5769    _elm_win_xwin_update(sd);
5770 #endif
5771 }
5772
5773 EOLIAN static int
5774 _elm_win_layer_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
5775 {
5776    return ecore_evas_layer_get(sd->ee);
5777 }
5778
5779 EAPI void
5780 elm_win_norender_push(Evas_Object *obj)
5781 {
5782    ELM_WIN_CHECK(obj);
5783    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
5784
5785    sd->norender++;
5786    if (sd->norender == 1) ecore_evas_manual_render_set(sd->ee, EINA_TRUE);
5787 }
5788
5789 EAPI void
5790 elm_win_norender_pop(Evas_Object *obj)
5791 {
5792    ELM_WIN_CHECK(obj);
5793    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
5794
5795    if (sd->norender <= 0) return;
5796    sd->norender--;
5797    if (sd->norender == 0) ecore_evas_manual_render_set(sd->ee, EINA_FALSE);
5798 }
5799
5800 EAPI int
5801 elm_win_norender_get(const Evas_Object *obj)
5802 {
5803    ELM_WIN_CHECK(obj) - 1;
5804    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, -1);
5805    return sd->norender;
5806 }
5807
5808 EAPI void
5809 elm_win_render(Evas_Object *obj)
5810 {
5811    ELM_WIN_CHECK(obj);
5812    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
5813    ecore_evas_manual_render(sd->ee);
5814 }
5815
5816 static int
5817 _win_rotation_degree_check(int rotation)
5818 {
5819    if ((rotation > 360) || (rotation < 0))
5820      {
5821         WRN("Rotation degree should be 0 ~ 360 (passed degree: %d)", rotation);
5822         rotation %= 360;
5823         if (rotation < 0) rotation += 360;
5824      }
5825    return rotation;
5826 }
5827
5828 // TIZEN_ONLY(20170212): pend rotation until app set rotation
5829 /*
5830  * This API rotates the window by app side.
5831  */
5832
5833 static void
5834 _win_pending_rotate(Evas_Object *obj EINA_UNUSED, Elm_Win_Data *sd, int rotation, Eina_Bool resize)
5835 {
5836    rotation = _win_rotation_degree_check(rotation);
5837    DBG("PendingRotation: elm_win pending rotation set rot=%d", rotation);
5838    if (sd->rot == rotation) return;
5839
5840    //TODO: We need time to set up the role of pending rotation between the server and client.
5841    //and also need time to discuss this concept with opensource.
5842    //so until that time, we add ecore evas data instead of opening the new ecore_evas_XXX api.
5843    ecore_evas_data_set(sd->ee, "pending_rotation", (void *)1);
5844
5845    // Currently only support rotation_with_resize
5846    if (resize) TRAP(sd, rotation_with_resize_set, rotation);
5847    else return;
5848 }
5849 //
5850
5851 /*
5852  * This API resizes the internal window(ex: X window) and evas_output.
5853  * But this does not resize the elm window object and its contents.
5854  */
5855 static void
5856 _win_rotate(Evas_Object *obj, Elm_Win_Data *sd, int rotation, Eina_Bool resize)
5857 {
5858    rotation = _win_rotation_degree_check(rotation);
5859    if (sd->rot == rotation) return;
5860    sd->rot = rotation;
5861    if (resize) TRAP(sd, rotation_with_resize_set, rotation);
5862    else TRAP(sd, rotation_set, rotation);
5863    evas_object_size_hint_min_set(obj, -1, -1);
5864    evas_object_size_hint_max_set(obj, -1, -1);
5865    _elm_win_resize_objects_eval(obj);
5866 #ifdef HAVE_ELEMENTARY_X
5867    _elm_win_xwin_update(sd);
5868 #endif
5869    _elm_win_frame_obj_update(sd);
5870    elm_widget_orientation_set(obj, rotation);
5871    eo_do(obj, eo_event_callback_call
5872      (ELM_WIN_EVENT_ROTATION_CHANGED, NULL));
5873    //TIZEN_ONLY(20160915): send information to screen reader on window rotation.
5874    if (_elm_atspi_enabled())
5875      {
5876         Evas_Coord width = 0, height = 0;
5877         elm_win_screen_size_get(obj, NULL, NULL, &width, &height);
5878         if ((sd->rot == 0) || (sd->rot == 180))
5879           {
5880              elm_interface_atspi_accessible_bounds_changed_signal_emit(obj, 0, 0, width, height);
5881           }
5882         else
5883           {
5884              elm_interface_atspi_accessible_bounds_changed_signal_emit(obj, 0, 0, height, width);
5885           }
5886      }
5887      //
5888 }
5889
5890 EOLIAN static void
5891 _elm_win_rotation_set(Eo *obj, Elm_Win_Data *sd, int rotation)
5892 {
5893    _win_rotate(obj, sd, rotation, EINA_FALSE);
5894 }
5895
5896 /*
5897  * This API does not resize the internal window (ex: X window).
5898  * But this resizes evas_output, elm window, and its contents.
5899  */
5900 EOLIAN static void
5901 _elm_win_rotation_with_resize_set(Eo *obj, Elm_Win_Data *sd, int rotation)
5902 {
5903 // TIZEN_ONLY(20170212): pend rotation until app set rotation
5904    if (sd->wm_rot.rotation_pending)
5905      {
5906         _win_pending_rotate(obj, sd, rotation, EINA_TRUE);
5907      }
5908    else
5909 //
5910      _win_rotate(obj, sd, rotation, EINA_TRUE);
5911 }
5912
5913 EOLIAN static int
5914 _elm_win_rotation_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
5915 {
5916    return sd->rot;
5917 }
5918
5919 EOLIAN static Eina_Bool
5920 _elm_win_wm_rotation_supported_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
5921 {
5922    return sd->wm_rot.wm_supported;
5923 }
5924
5925 /* This will unset a preferred rotation, if given preferred rotation is '-1'.
5926  */
5927 EAPI void
5928 elm_win_wm_rotation_preferred_rotation_set(const Evas_Object *obj,
5929                                            int rotation)
5930 {
5931    ELM_WIN_CHECK(obj);
5932    eo_do((Eo *) obj, elm_obj_win_wm_preferred_rotation_set(rotation));
5933 }
5934
5935 EOLIAN static void
5936 _elm_win_wm_preferred_rotation_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, int rotation)
5937 {
5938    int rot;
5939
5940    if (!sd->wm_rot.use)
5941      sd->wm_rot.use = EINA_TRUE;
5942
5943    // '-1' means that elm_win doesn't use preferred rotation.
5944    if (rotation == -1)
5945      rot = -1;
5946    else
5947      rot = _win_rotation_degree_check(rotation);
5948
5949    if (sd->wm_rot.preferred_rot == rot) return;
5950    sd->wm_rot.preferred_rot = rot;
5951
5952    ecore_evas_wm_rotation_preferred_rotation_set(sd->ee, rot);
5953 }
5954
5955 EOLIAN static int
5956 _elm_win_wm_preferred_rotation_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
5957 {
5958    return sd->wm_rot.preferred_rot;
5959 }
5960
5961 EOLIAN static void
5962 _elm_win_wm_available_rotations_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, const int *rotations, unsigned int count)
5963 {
5964    unsigned int i;
5965    int r;
5966
5967    if (!sd->wm_rot.use)
5968      sd->wm_rot.use = EINA_TRUE;
5969
5970    ELM_SAFE_FREE(sd->wm_rot.rots, free);
5971    sd->wm_rot.count = 0;
5972
5973    if (count > 0)
5974      {
5975         sd->wm_rot.rots = calloc(count, sizeof(int));
5976         if (!sd->wm_rot.rots) return;
5977         for (i = 0; i < count; i++)
5978           {
5979              r = _win_rotation_degree_check(rotations[i]);
5980              sd->wm_rot.rots[i] = r;
5981           }
5982      }
5983
5984    sd->wm_rot.count = count;
5985
5986    ecore_evas_wm_rotation_available_rotations_set(sd->ee,
5987                                                   sd->wm_rot.rots,
5988                                                   sd->wm_rot.count);
5989 }
5990
5991 EOLIAN static Eina_Bool
5992 _elm_win_wm_available_rotations_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, int **rotations, unsigned int *count)
5993 {
5994    if (!sd->wm_rot.use) return EINA_FALSE;
5995
5996    if (sd->wm_rot.count > 0)
5997      {
5998         if (rotations)
5999           {
6000              *rotations = calloc(sd->wm_rot.count, sizeof(int));
6001              if (*rotations)
6002                {
6003                   memcpy(*rotations,
6004                          sd->wm_rot.rots,
6005                          sizeof(int) * sd->wm_rot.count);
6006                }
6007           }
6008      }
6009
6010    if (count) *count = sd->wm_rot.count;
6011    return EINA_TRUE;
6012 }
6013
6014 EOLIAN static void
6015 _elm_win_wm_manual_rotation_done_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool set)
6016 {
6017    if (!sd->wm_rot.use) return;
6018    ecore_evas_wm_rotation_manual_rotation_done_set(sd->ee, set);
6019 }
6020
6021 EOLIAN static Eina_Bool
6022 _elm_win_wm_manual_rotation_done_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
6023 {
6024    if (!sd->wm_rot.use) return EINA_FALSE;
6025    return ecore_evas_wm_rotation_manual_rotation_done_get(sd->ee);
6026 }
6027
6028 EOLIAN static void
6029 _elm_win_wm_manual_rotation_done_manual(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
6030 {
6031    if (!sd->wm_rot.use) return;
6032    ecore_evas_wm_rotation_manual_rotation_done(sd->ee);
6033 }
6034
6035 EOLIAN static void
6036 _elm_win_sticky_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool sticky)
6037 {
6038 //   sd->sticky = sticky;
6039    TRAP(sd, sticky_set, sticky);
6040 #ifdef HAVE_ELEMENTARY_X
6041    _elm_win_xwin_update(sd);
6042 #endif
6043 }
6044
6045 EOLIAN static Eina_Bool
6046 _elm_win_sticky_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
6047 {
6048    return sd->sticky;
6049 }
6050
6051 EOLIAN static void
6052 _elm_win_keyboard_mode_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Elm_Win_Keyboard_Mode mode)
6053 {
6054    if (mode == sd->kbdmode) return;
6055 #ifdef HAVE_ELEMENTARY_X
6056    _internal_elm_win_xwindow_get(sd);
6057 #endif
6058    sd->kbdmode = mode;
6059 #ifdef HAVE_ELEMENTARY_X
6060    if (sd->x.xwin)
6061      ecore_x_e_virtual_keyboard_state_set
6062        (sd->x.xwin, (Ecore_X_Virtual_Keyboard_State)sd->kbdmode);
6063 #endif
6064 }
6065
6066 EOLIAN static Elm_Win_Keyboard_Mode
6067 _elm_win_keyboard_mode_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
6068 {
6069    return sd->kbdmode;
6070 }
6071
6072 EOLIAN static void
6073 _elm_win_keyboard_win_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool is_keyboard)
6074 {
6075 #ifdef HAVE_ELEMENTARY_X
6076    _internal_elm_win_xwindow_get(sd);
6077    if (sd->x.xwin)
6078      ecore_x_e_virtual_keyboard_set(sd->x.xwin, is_keyboard);
6079 #else
6080    (void)is_keyboard;
6081    (void)sd;
6082 #endif
6083 }
6084
6085 EOLIAN static Eina_Bool
6086 _elm_win_keyboard_win_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
6087 {
6088 #ifdef HAVE_ELEMENTARY_X
6089    _internal_elm_win_xwindow_get(sd);
6090    if (sd->x.xwin) return ecore_x_e_virtual_keyboard_get(sd->x.xwin);
6091 #else
6092    (void)sd;
6093 #endif
6094    return EINA_FALSE;
6095 }
6096
6097 EOLIAN static void
6098 _elm_win_indicator_mode_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Elm_Win_Indicator_Mode mode)
6099 {
6100    if (mode == sd->indmode) return;
6101 #ifdef HAVE_ELEMENTARY_X
6102    _internal_elm_win_xwindow_get(sd);
6103 #endif
6104    sd->indmode = mode;
6105 #ifdef HAVE_ELEMENTARY_X
6106    if (sd->x.xwin)
6107      {
6108         if (sd->indmode == ELM_WIN_INDICATOR_SHOW)
6109           ecore_x_e_illume_indicator_state_set
6110             (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_STATE_ON);
6111         else if (sd->indmode == ELM_WIN_INDICATOR_HIDE)
6112           ecore_x_e_illume_indicator_state_set
6113             (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_STATE_OFF);
6114      }
6115 #endif
6116 #ifdef HAVE_ELEMENTARY_WAYLAND
6117    _elm_win_wlwindow_get(sd);
6118    if (sd->wl.win)
6119      {
6120         if (sd->indmode == ELM_WIN_INDICATOR_SHOW)
6121           ecore_wl_window_indicator_state_set
6122             (sd->wl.win, ECORE_WL_INDICATOR_STATE_ON);
6123         else if (sd->indmode == ELM_WIN_INDICATOR_HIDE)
6124           ecore_wl_window_indicator_state_set
6125             (sd->wl.win, ECORE_WL_INDICATOR_STATE_OFF);
6126      }
6127 #endif
6128    eo_do(obj, eo_event_callback_call
6129      (ELM_WIN_EVENT_INDICATOR_PROP_CHANGED, NULL));
6130 }
6131
6132 EOLIAN static Elm_Win_Indicator_Mode
6133 _elm_win_indicator_mode_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
6134 {
6135    return sd->indmode;
6136 }
6137
6138 EOLIAN static void
6139 _elm_win_indicator_opacity_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Elm_Win_Indicator_Opacity_Mode mode)
6140 {
6141    if (mode == sd->ind_o_mode) return;
6142    sd->ind_o_mode = mode;
6143 #ifdef HAVE_ELEMENTARY_X
6144    _internal_elm_win_xwindow_get(sd);
6145    if (sd->x.xwin)
6146      {
6147         if (sd->ind_o_mode == ELM_WIN_INDICATOR_OPAQUE)
6148           ecore_x_e_illume_indicator_opacity_set
6149             (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_OPAQUE);
6150         else if (sd->ind_o_mode == ELM_WIN_INDICATOR_TRANSLUCENT)
6151           ecore_x_e_illume_indicator_opacity_set
6152             (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_TRANSLUCENT);
6153         else if (sd->ind_o_mode == ELM_WIN_INDICATOR_TRANSPARENT)
6154           ecore_x_e_illume_indicator_opacity_set
6155             (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_TRANSPARENT);
6156      }
6157 #endif
6158 #ifdef HAVE_ELEMENTARY_WAYLAND
6159    _elm_win_wlwindow_get(sd);
6160    if (sd->wl.win)
6161      {
6162         if (sd->ind_o_mode == ELM_WIN_INDICATOR_OPAQUE)
6163           ecore_wl_window_indicator_opacity_set
6164             (sd->wl.win, ECORE_WL_INDICATOR_OPAQUE);
6165         else if (sd->ind_o_mode == ELM_WIN_INDICATOR_TRANSLUCENT)
6166           ecore_wl_window_indicator_opacity_set
6167             (sd->wl.win, ECORE_WL_INDICATOR_TRANSLUCENT);
6168         else if (sd->ind_o_mode == ELM_WIN_INDICATOR_TRANSPARENT)
6169           ecore_wl_window_indicator_opacity_set
6170             (sd->wl.win, ECORE_WL_INDICATOR_TRANSPARENT);
6171         else if (sd->ind_o_mode == ELM_WIN_INDICATOR_BG_TRANSPARENT)
6172           ecore_wl_window_indicator_opacity_set
6173             (sd->wl.win, ECORE_WL_INDICATOR_BG_TRANSPARENT);
6174      }
6175 #endif
6176    eo_do(obj, eo_event_callback_call
6177      (ELM_WIN_EVENT_INDICATOR_PROP_CHANGED, NULL));
6178 }
6179
6180 EOLIAN static Elm_Win_Indicator_Opacity_Mode
6181 _elm_win_indicator_opacity_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
6182 {
6183    return sd->ind_o_mode;
6184 }
6185
6186 EOLIAN static void
6187 _elm_win_screen_position_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, int *x, int *y)
6188 {
6189    if (x) *x = sd->screen.x;
6190    if (y) *y = sd->screen.y;
6191 }
6192
6193 EOLIAN static Eina_Bool
6194 _elm_win_focus_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
6195 {
6196    return ecore_evas_focus_get(sd->ee);
6197 }
6198
6199 EOLIAN static void
6200 _elm_win_screen_constrain_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool constrain)
6201 {
6202    sd->constrain = !!constrain;
6203 }
6204
6205 EOLIAN static Eina_Bool
6206 _elm_win_screen_constrain_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
6207 {
6208    return sd->constrain;
6209 }
6210
6211 EOLIAN static void
6212 _elm_win_screen_size_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, int *x, int *y, int *w, int *h)
6213 {
6214    ecore_evas_screen_geometry_get(sd->ee, x, y, w, h);
6215 }
6216
6217 EOLIAN static void
6218 _elm_win_screen_dpi_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, int *xdpi, int *ydpi)
6219 {
6220    ecore_evas_screen_dpi_get(sd->ee, xdpi, ydpi);
6221 }
6222
6223 EOLIAN static void
6224 _elm_win_conformant_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool conformant)
6225 {
6226 #ifdef HAVE_ELEMENTARY_X
6227    _internal_elm_win_xwindow_get(sd);
6228    if (sd->x.xwin)
6229      ecore_x_e_illume_conformant_set(sd->x.xwin, conformant);
6230 #elif HAVE_ELEMENTARY_WAYLAND
6231    _elm_win_wlwindow_get(sd);
6232    if (sd->wl.win)
6233      ecore_wl_window_conformant_set(sd->wl.win, conformant);
6234 #else
6235    (void)conformant;
6236 #endif
6237 }
6238
6239 EOLIAN static Eina_Bool
6240 _elm_win_conformant_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
6241 {
6242 #ifdef HAVE_ELEMENTARY_X
6243    _internal_elm_win_xwindow_get(sd);
6244    if (sd->x.xwin)
6245      return ecore_x_e_illume_conformant_get(sd->x.xwin);
6246 #endif
6247 #if HAVE_ELEMENTARY_WAYLAND
6248    _elm_win_wlwindow_get(sd);
6249    if (sd->wl.win)
6250      return ecore_wl_window_conformant_get(sd->wl.win);
6251 #endif
6252
6253    return EINA_FALSE;
6254 }
6255
6256 EOLIAN static void
6257 _elm_win_quickpanel_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool quickpanel)
6258 {
6259 #ifdef HAVE_ELEMENTARY_X
6260    _internal_elm_win_xwindow_get(sd);
6261    if (sd->x.xwin)
6262      {
6263         ecore_x_e_illume_quickpanel_set(sd->x.xwin, quickpanel);
6264         if (quickpanel)
6265           {
6266              Ecore_X_Window_State states[2];
6267
6268              states[0] = ECORE_X_WINDOW_STATE_SKIP_TASKBAR;
6269              states[1] = ECORE_X_WINDOW_STATE_SKIP_PAGER;
6270              ecore_x_netwm_window_state_set(sd->x.xwin, states, 2);
6271              ecore_x_icccm_hints_set(sd->x.xwin, 0, 0, 0, 0, 0, 0, 0);
6272           }
6273      }
6274 #else
6275    (void)quickpanel;
6276 #endif
6277 #ifdef HAVE_ELEMENTARY_WAYLAND
6278    _elm_win_focus_skip_set(sd, EINA_TRUE);
6279 #endif
6280 }
6281
6282 EOLIAN static Eina_Bool
6283 _elm_win_quickpanel_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
6284 {
6285 #ifdef HAVE_ELEMENTARY_X
6286    _internal_elm_win_xwindow_get(sd);
6287    if (sd->x.xwin)
6288      return ecore_x_e_illume_quickpanel_get(sd->x.xwin);
6289 #else
6290    (void)sd;
6291 #endif
6292
6293    return EINA_FALSE;
6294 }
6295
6296 EOLIAN static void
6297 _elm_win_quickpanel_priority_major_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, int priority)
6298 {
6299 #ifdef HAVE_ELEMENTARY_X
6300    _internal_elm_win_xwindow_get(sd);
6301    if (sd->x.xwin)
6302      ecore_x_e_illume_quickpanel_priority_major_set(sd->x.xwin, priority);
6303 #else
6304    (void)priority;
6305    (void)sd;
6306 #endif
6307 }
6308
6309 EOLIAN static int
6310 _elm_win_quickpanel_priority_major_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
6311 {
6312 #ifdef HAVE_ELEMENTARY_X
6313    _internal_elm_win_xwindow_get(sd);
6314    if (sd->x.xwin)
6315      return ecore_x_e_illume_quickpanel_priority_major_get(sd->x.xwin);
6316 #else
6317    (void)sd;
6318 #endif
6319
6320    return -1;
6321 }
6322
6323 EOLIAN static void
6324 _elm_win_quickpanel_priority_minor_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, int priority)
6325 {
6326 #ifdef HAVE_ELEMENTARY_X
6327    _internal_elm_win_xwindow_get(sd);
6328    if (sd->x.xwin)
6329      ecore_x_e_illume_quickpanel_priority_minor_set(sd->x.xwin, priority);
6330 #else
6331    (void)priority;
6332    (void)sd;
6333 #endif
6334 }
6335
6336 EOLIAN static int
6337 _elm_win_quickpanel_priority_minor_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
6338 {
6339 #ifdef HAVE_ELEMENTARY_X
6340    _internal_elm_win_xwindow_get(sd);
6341    if (sd->x.xwin)
6342      return ecore_x_e_illume_quickpanel_priority_minor_get(sd->x.xwin);
6343 #else
6344    (void)sd;
6345 #endif
6346
6347    return -1;
6348 }
6349
6350 EOLIAN static void
6351 _elm_win_quickpanel_zone_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, int zone)
6352 {
6353 #ifdef HAVE_ELEMENTARY_X
6354    _internal_elm_win_xwindow_get(sd);
6355    if (sd->x.xwin)
6356      ecore_x_e_illume_quickpanel_zone_set(sd->x.xwin, zone);
6357 #else
6358    (void)zone;
6359    (void)sd;
6360 #endif
6361 }
6362
6363 EOLIAN static int
6364 _elm_win_quickpanel_zone_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
6365 {
6366 #ifdef HAVE_ELEMENTARY_X
6367    _internal_elm_win_xwindow_get(sd);
6368    if (sd->x.xwin)
6369      return ecore_x_e_illume_quickpanel_zone_get(sd->x.xwin);
6370 #else
6371    (void)sd;
6372 #endif
6373
6374    return 0;
6375 }
6376
6377 EOLIAN static void
6378 _elm_win_prop_focus_skip_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool skip)
6379 {
6380    _elm_win_focus_skip_set(sd, skip);
6381 }
6382
6383 EOLIAN static void
6384 _elm_win_illume_command_send(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Elm_Illume_Command command, void *params)
6385 {
6386    (void) params;
6387
6388 #ifdef HAVE_ELEMENTARY_X
6389    _internal_elm_win_xwindow_get(sd);
6390    if (sd->x.xwin)
6391      {
6392         switch (command)
6393           {
6394            case ELM_ILLUME_COMMAND_FOCUS_BACK:
6395              ecore_x_e_illume_focus_back_send(sd->x.xwin);
6396              break;
6397
6398            case ELM_ILLUME_COMMAND_FOCUS_FORWARD:
6399              ecore_x_e_illume_focus_forward_send(sd->x.xwin);
6400              break;
6401
6402            case ELM_ILLUME_COMMAND_FOCUS_HOME:
6403              ecore_x_e_illume_focus_home_send(sd->x.xwin);
6404              break;
6405
6406            case ELM_ILLUME_COMMAND_CLOSE:
6407              ecore_x_e_illume_close_send(sd->x.xwin);
6408              break;
6409
6410            default:
6411              break;
6412           }
6413      }
6414 #else
6415    (void)command;
6416    (void)sd;
6417 #endif
6418 }
6419
6420 EOLIAN static Eina_Bool
6421 _elm_win_keygrab_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, const char *key, Evas_Modifier_Mask modifiers EINA_UNUSED, Evas_Modifier_Mask not_modifiers EINA_UNUSED, int priority EINA_UNUSED, Elm_Win_Keygrab_Mode grab_mode)
6422 {
6423    Eina_Bool ret = EINA_FALSE;
6424 #ifdef HAVE_ELEMENTARY_X
6425    _internal_elm_win_xwindow_get(sd);
6426    if (sd->x.xwin)
6427      {
6428         Ecore_X_Win_Keygrab_Mode x_grab_mode;
6429         switch (grab_mode)
6430           {
6431            case ELM_WIN_KEYGRAB_SHARED:
6432              x_grab_mode = ECORE_X_WIN_KEYGRAB_SHARED;
6433              break;
6434            case ELM_WIN_KEYGRAB_TOPMOST:
6435              x_grab_mode = ECORE_X_WIN_KEYGRAB_TOPMOST;
6436              break;
6437            case ELM_WIN_KEYGRAB_EXCLUSIVE:
6438              x_grab_mode = ECORE_X_WIN_KEYGRAB_EXCLUSIVE;
6439              break;
6440            case ELM_WIN_KEYGRAB_OVERRIDE_EXCLUSIVE:
6441              x_grab_mode = ECORE_X_WIN_KEYGRAB_OVERRIDE_EXCLUSIVE;
6442              break;
6443            default:
6444              return ret;
6445           }
6446          ret = ecore_x_window_keygrab_set(sd->x.xwin, key, 0, 0, 0, x_grab_mode);
6447      }
6448 #endif
6449 // TIZEN_ONLY(20150722): Add ecore_wl_window_keygrab_* APIs
6450 #ifdef HAVE_ELEMENTARY_WAYLAND
6451    _elm_win_wlwindow_get(sd);
6452    if (sd->wl.win)
6453      {
6454         Ecore_Wl_Window_Keygrab_Mode wl_grab_mode;
6455         switch (grab_mode)
6456           {
6457            case ELM_WIN_KEYGRAB_SHARED:
6458              wl_grab_mode = ECORE_WL_WINDOW_KEYGRAB_SHARED;
6459              break;
6460            case ELM_WIN_KEYGRAB_TOPMOST:
6461              wl_grab_mode = ECORE_WL_WINDOW_KEYGRAB_TOPMOST;
6462              break;
6463            case ELM_WIN_KEYGRAB_EXCLUSIVE:
6464              wl_grab_mode = ECORE_WL_WINDOW_KEYGRAB_EXCLUSIVE;
6465              break;
6466            case ELM_WIN_KEYGRAB_OVERRIDE_EXCLUSIVE:
6467              wl_grab_mode = ECORE_WL_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
6468              break;
6469            default:
6470              return ret;
6471           }
6472         ret = ecore_wl_window_keygrab_set(sd->wl.win, key, 0, 0, 0, wl_grab_mode);
6473      }
6474 #endif
6475 //
6476    return ret;
6477 }
6478
6479 EOLIAN static Eina_Bool
6480 _elm_win_keygrab_unset(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, const char *key, Evas_Modifier_Mask modifiers EINA_UNUSED, Evas_Modifier_Mask not_modifiers EINA_UNUSED)
6481 {
6482    Eina_Bool ret = EINA_FALSE;
6483 #ifdef HAVE_ELEMENTARY_X
6484    _internal_elm_win_xwindow_get(sd);
6485    if (sd->x.xwin)
6486      ret = ecore_x_window_keygrab_unset(sd->x.xwin, key, 0, 0);
6487 #endif
6488 // TIZEN_ONLY(20150722): Add ecore_wl_window_keygrab_* APIs
6489 #ifdef HAVE_ELEMENTARY_WAYLAND
6490    _elm_win_wlwindow_get(sd);
6491    if (sd->wl.win)
6492      ret = ecore_wl_window_keygrab_unset(sd->wl.win, key, 0, 0);
6493 #endif
6494 //
6495    return ret;
6496 }
6497
6498 EOLIAN static Evas_Object*
6499 _elm_win_inlined_image_object_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
6500 {
6501    return sd->img_obj;
6502 }
6503
6504 EOLIAN static void
6505 _elm_win_focus_highlight_enabled_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool enabled)
6506 {
6507    enabled = !!enabled;
6508    if (sd->focus_highlight.enabled == enabled)
6509      return;
6510
6511    sd->focus_highlight.enabled = enabled;
6512
6513    if ((sd->focus_highlight.enabled) || (sd->focus_highlight.auto_enabled))
6514      _elm_win_focus_highlight_init(sd);
6515    else
6516      _elm_win_focus_highlight_shutdown(sd);
6517 }
6518
6519 EOLIAN static Eina_Bool
6520 _elm_win_focus_highlight_enabled_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
6521 {
6522    return sd->focus_highlight.enabled;
6523 }
6524
6525 static Elm_Theme_Apply
6526 _elm_win_theme_internal(Eo *obj, Elm_Win_Data *sd)
6527 {
6528    Elm_Theme_Apply int_ret = ELM_THEME_APPLY_FAILED;
6529    Eina_Bool ret = EINA_FALSE;
6530    const char *s;
6531
6532    int_ret = _elm_theme_object_set(obj, sd->edje, "win", "base",
6533                                    elm_widget_style_get(obj));
6534
6535    if (!int_ret) return ELM_THEME_APPLY_FAILED;
6536
6537    edje_object_mirrored_set(sd->edje, elm_widget_mirrored_get(obj));
6538    edje_object_scale_set(sd->edje,
6539                          elm_widget_scale_get(obj) * elm_config_scale_get());
6540
6541    eo_do(obj, eo_event_callback_call(ELM_WIN_EVENT_THEME_CHANGED, NULL));
6542    eo_do(obj, ret = elm_obj_widget_disable());
6543
6544    if (!ret) int_ret = ELM_THEME_APPLY_FAILED;
6545
6546    if (!sd->theme_alpha && !sd->application_alpha)
6547      {
6548         s = edje_object_data_get(sd->edje, "alpha");
6549         if (s)
6550           {
6551              if (!strcmp(s, "1") ||
6552                  !strcmp(s, "true"))
6553                {
6554                   sd->application_alpha = 1;
6555                   _elm_win_apply_alpha(obj, sd);
6556                }
6557           }
6558      }
6559
6560    return int_ret;
6561 }
6562
6563 EOLIAN static Elm_Theme_Apply
6564 _elm_win_elm_widget_theme_apply(Eo *obj, Elm_Win_Data *sd)
6565 {
6566    Elm_Theme_Apply int_ret = ELM_THEME_APPLY_FAILED;
6567    eo_do_super(obj, MY_CLASS, int_ret = elm_obj_widget_theme_apply());
6568    if (!int_ret) return ELM_THEME_APPLY_FAILED;
6569
6570    sd->focus_highlight.theme_changed = EINA_TRUE;
6571
6572    int_ret = _elm_win_theme_internal(obj, sd) & int_ret;
6573    if (!int_ret)
6574      return ELM_THEME_APPLY_FAILED;
6575    _elm_win_focus_highlight_reconfigure_job_start(sd);
6576
6577    return int_ret;
6578 }
6579
6580 EOLIAN static void
6581 _elm_win_focus_highlight_style_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, const char *style)
6582 {
6583    eina_stringshare_replace(&sd->focus_highlight.style, style);
6584    sd->focus_highlight.theme_changed = EINA_TRUE;
6585    _elm_win_focus_highlight_reconfigure_job_start(sd);
6586 }
6587
6588 EOLIAN static const char*
6589 _elm_win_focus_highlight_style_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
6590 {
6591    return sd->focus_highlight.style;
6592 }
6593
6594 EOLIAN static void
6595 _elm_win_focus_highlight_animate_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool animate)
6596 {
6597    animate = !!animate;
6598    if (sd->focus_highlight.animate == animate)
6599      return;
6600
6601    sd->focus_highlight.animate = animate;
6602    sd->focus_highlight.theme_changed = EINA_TRUE;
6603    _elm_win_focus_highlight_reconfigure_job_start(sd);
6604 }
6605
6606 EOLIAN static Eina_Bool
6607 _elm_win_focus_highlight_animate_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
6608 {
6609    return sd->focus_highlight.animate;
6610 }
6611
6612 EOLIAN static Eina_Bool
6613 _elm_win_socket_listen(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, const char *svcname, int svcnum, Eina_Bool svcsys)
6614 {
6615    if (!sd->ee) return EINA_FALSE;
6616    if (sd->type != ELM_WIN_SOCKET_IMAGE) return EINA_FALSE;
6617
6618    if (!ecore_evas_extn_socket_listen(sd->ee, svcname, svcnum, svcsys))
6619      return EINA_FALSE;
6620
6621    if (_elm_atspi_enabled())
6622      {
6623         if (sd->socket_proxy)
6624           eo_unref(sd->socket_proxy);
6625         sd->socket_proxy = _elm_atspi_bridge_utils_proxy_create(obj, svcname, svcnum, ELM_ATSPI_PROXY_TYPE_SOCKET);
6626         elm_atspi_bridge_utils_proxy_listen(sd->socket_proxy);
6627      }
6628
6629    return EINA_TRUE;
6630 }
6631
6632 EOLIAN static Eina_Bool
6633 _elm_win_move_resize_start(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Elm_Win_Move_Resize_Mode mode)
6634 {
6635    Eina_Bool res = EINA_FALSE;
6636
6637 #ifdef HAVE_ELEMENTARY_WAYLAND
6638    int i;
6639    //1. move_resize can be start after mouse down event
6640    i = evas_event_down_count_get(sd->evas);
6641    if (i <= 0) return res;
6642
6643    //2. check move_resize start already .
6644    if (sd->resizing) return res;
6645
6646    i = sd->rot / 90;
6647    if (mode == ELM_WIN_MOVE_RESIZE_MOVE)
6648      {
6649         if (sd->wl.win)
6650           {
6651              sd->resizing = EINA_TRUE;
6652              ecore_wl_window_pointer_set(sd->wl.win, NULL,
6653                                          sd->pointer.hot_x, sd->pointer.hot_y);
6654
6655              /* Note: Not passing any X,Y position as those don't make sense, only
6656               * the compositor can really handle the window & pointer position. */
6657              ecore_evas_wayland_move(sd->ee, 0, 0);
6658              res = EINA_TRUE;
6659           }
6660      }
6661    else
6662      {
6663         if(mode == ELM_WIN_MOVE_RESIZE_TOP)
6664           sd->resize_location = _border_side[(0 + i) % 4].location;
6665         else if (mode == ELM_WIN_MOVE_RESIZE_BOTTOM)
6666           sd->resize_location = _border_side[(2 + i) % 4].location;
6667         else if (mode == ELM_WIN_MOVE_RESIZE_LEFT)
6668           sd->resize_location = _border_side[(1 + i) % 4].location;
6669         else if (mode == ELM_WIN_MOVE_RESIZE_RIGHT)
6670           sd->resize_location = _border_side[(3 + i) % 4].location;
6671         else if (mode == (ELM_WIN_MOVE_RESIZE_TOP | ELM_WIN_MOVE_RESIZE_LEFT))
6672           sd->resize_location = _border_corner[(0 + i) % 4].location;
6673         else if (mode == (ELM_WIN_MOVE_RESIZE_TOP | ELM_WIN_MOVE_RESIZE_RIGHT))
6674           sd->resize_location = _border_corner[(3 + i) % 4].location;
6675         else if (mode == (ELM_WIN_MOVE_RESIZE_BOTTOM | ELM_WIN_MOVE_RESIZE_LEFT))
6676           sd->resize_location = _border_corner[(1 + i) % 4].location;
6677         else if (mode == (ELM_WIN_MOVE_RESIZE_BOTTOM | ELM_WIN_MOVE_RESIZE_RIGHT))
6678           sd->resize_location = _border_corner[(2 + i) % 4].location;
6679         else
6680           sd->resize_location = 0;
6681
6682         if (sd->resize_location > 0)
6683           {
6684              sd->resizing = EINA_TRUE;
6685              ecore_evas_wayland_resize(sd->ee, sd->resize_location);
6686              res = EINA_TRUE;
6687           }
6688      }
6689 #endif
6690    return res;
6691 }
6692
6693 /* windowing specific calls - shall we do this differently? */
6694
6695 EOLIAN static Ecore_X_Window
6696 _elm_win_xwindow_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
6697 {
6698 #ifdef HAVE_ELEMENTARY_X
6699    if (sd->x.xwin) return sd->x.xwin;
6700    if (sd->parent) return elm_win_xwindow_get(sd->parent);
6701 #else
6702    (void)sd;
6703 #endif
6704    return 0;
6705 }
6706
6707 EAPI Ecore_Wl_Window *
6708 elm_win_wl_window_get(const Evas_Object *obj)
6709 {
6710    ELM_WIN_CHECK(obj) NULL;
6711    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, NULL);
6712    const char *engine_name = ecore_evas_engine_name_get(sd->ee);
6713
6714    if (!(engine_name &&
6715          ((!strcmp(engine_name, ELM_WAYLAND_SHM)) ||
6716           (!strcmp(engine_name, ELM_WAYLAND_EGL)))))
6717      return NULL;
6718
6719    if (!evas_object_smart_type_check_ptr(obj, MY_CLASS_NAME_LEGACY))
6720      {
6721         Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
6722         return _elm_ee_wlwin_get(ee);
6723      }
6724
6725    Ecore_Wl_Window *ret = NULL;
6726    eo_do((Eo *) obj, ret = elm_obj_win_wl_window_get());
6727    return ret;
6728 }
6729
6730 EOLIAN static Ecore_Cocoa_Window *
6731 _elm_win_cocoa_window_get(Eo           *obj,
6732                           Elm_Win_Data *sd)
6733 {
6734    const char *engine_name = ecore_evas_engine_name_get(sd->ee);
6735    if (!engine_name) return NULL;
6736    if (strcmp(engine_name, "gl_cocoa") != 0 &&
6737        strcmp(engine_name, "opengl_cocoa") != 0)
6738        return NULL;
6739
6740    Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
6741    return _elm_ee_cocoa_win_get(ee);
6742 }
6743
6744 EOLIAN static Ecore_Wl_Window*
6745 _elm_win_wl_window_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
6746 {
6747 #if HAVE_ELEMENTARY_WAYLAND
6748    if (sd->wl.win) return sd->wl.win;
6749    if (sd->parent) return elm_win_wl_window_get(sd->parent);
6750 #else
6751    (void)sd;
6752 #endif
6753    return NULL;
6754 }
6755
6756 EAPI Ecore_Win32_Window *
6757 elm_win_win32_window_get(const Evas_Object *obj)
6758 {
6759    ELM_WIN_CHECK(obj) NULL;
6760    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, NULL);
6761    const char *engine_name = ecore_evas_engine_name_get(sd->ee);
6762
6763    if (!(engine_name &&
6764          ((!strcmp(engine_name, ELM_SOFTWARE_WIN32)) ||
6765           (!strcmp(engine_name, ELM_SOFTWARE_DDRAW)))))
6766      return NULL;
6767
6768    if (!evas_object_smart_type_check_ptr(obj, MY_CLASS_NAME_LEGACY))
6769      {
6770         Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
6771         return _elm_ee_win32win_get(ee);
6772      }
6773
6774    Ecore_Win32_Window *ret = NULL;
6775    eo_do((Eo *) obj, ret = elm_obj_win_win32_window_get());
6776    return ret;
6777 }
6778
6779 EOLIAN static Ecore_Win32_Window *
6780 _elm_win_win32_window_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
6781 {
6782 #if HAVE_ELEMENTARY_WIN32
6783    if (sd->win32.win) return sd->win32.win;
6784    if (sd->parent) return elm_win_win32_window_get(sd->parent);
6785 #else
6786    (void)sd;
6787 #endif
6788    return NULL;
6789 }
6790
6791 EAPI Eina_Bool
6792 elm_win_trap_set(const Elm_Win_Trap *t)
6793 {
6794    DBG("old %p, new %p", trap, t);
6795
6796    if ((t) && (t->version != ELM_WIN_TRAP_VERSION))
6797      {
6798         CRI("trying to set a trap version %lu while %lu was expected!",
6799                  t->version, ELM_WIN_TRAP_VERSION);
6800         return EINA_FALSE;
6801      }
6802
6803    trap = t;
6804    return EINA_TRUE;
6805 }
6806
6807 EAPI void
6808 elm_win_floating_mode_set(Evas_Object *obj, Eina_Bool floating)
6809 {
6810    ELM_WIN_CHECK(obj);
6811    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
6812
6813    floating = !!floating;
6814    if (floating == sd->floating) return;
6815    sd->floating = floating;
6816 #if HAVE_ELEMENTARY_WAYLAND
6817    _elm_win_wlwindow_get(sd);
6818    if (sd->wl.win)
6819      {
6820         if (floating)
6821           {
6822              if (!sd->borderless)
6823                {
6824                   const char *engine_name = ecore_evas_engine_name_get(sd->ee);
6825                   Eina_Bool need_frame = engine_name &&
6826                      ((!strcmp(engine_name, ELM_WAYLAND_SHM)) ||
6827                       (!strcmp(engine_name, ELM_WAYLAND_EGL)));
6828
6829                   if (need_frame)
6830                     need_frame = !sd->fullscreen;
6831
6832                   if (need_frame)
6833                     {
6834                        _elm_win_frame_del(sd);
6835                        _elm_win_frame_add(sd, "floating");
6836                     }
6837
6838                   if (sd->frame_obj)
6839                     evas_object_show(sd->frame_obj);
6840                }
6841
6842              //TIZEN_ONLY(20161208): supported floating window
6843              edje_object_signal_emit(sd->edje, "elm,state,floating,on", "elm");
6844              //
6845           }
6846         else
6847           {
6848              elm_win_borderless_set(obj, sd->borderless);
6849              //TIZEN_ONLY(20161208): supported floating window
6850              edje_object_signal_emit(sd->edje, "elm,state,floating,off", "elm");
6851              //
6852           }
6853         ecore_wl_window_floating_mode_set(sd->wl.win, floating);
6854      }
6855 #endif
6856 #ifdef HAVE_ELEMENTARY_X
6857    _internal_elm_win_xwindow_get(sd);
6858    if (sd->x.xwin)
6859      {
6860         if (sd->floating)
6861           ecore_x_e_illume_window_state_set
6862              (sd->x.xwin, ECORE_X_ILLUME_WINDOW_STATE_FLOATING);
6863         else
6864           ecore_x_e_illume_window_state_set
6865              (sd->x.xwin, ECORE_X_ILLUME_WINDOW_STATE_NORMAL);
6866      }
6867 #endif
6868 }
6869
6870 EAPI Eina_Bool
6871 elm_win_floating_mode_get(const Evas_Object *obj)
6872 {
6873    ELM_WIN_CHECK(obj) EINA_FALSE;
6874    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
6875
6876    return sd->floating;
6877 }
6878
6879 EOLIAN static Ecore_Window
6880 _elm_win_window_id_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
6881 {
6882    const char *engine_name = ecore_evas_engine_name_get(sd->ee);
6883
6884    if ((engine_name &&
6885         ((!strcmp(engine_name, ELM_WAYLAND_SHM)) ||
6886          (!strcmp(engine_name, ELM_WAYLAND_EGL)))))
6887      {
6888 #if HAVE_ELEMENTARY_WAYLAND
6889         if (sd->wl.win) return (Ecore_Window)ecore_wl_window_surface_id_get(sd->wl.win);
6890         if (sd->parent)
6891           {
6892              Ecore_Wl_Window *parent;
6893
6894              parent = elm_win_wl_window_get(sd->parent);
6895              if (parent) return (Ecore_Window)ecore_wl_window_surface_id_get(parent);
6896              return 0;
6897           }
6898 #endif
6899      }
6900    else if ((engine_name &&
6901              ((!strcmp(engine_name, ELM_SOFTWARE_X11)) ||
6902               (!strcmp(engine_name, ELM_OPENGL_X11)))))
6903      {
6904 #ifdef HAVE_ELEMENTARY_X
6905         _internal_elm_win_xwindow_get(sd);
6906         if (sd->x.xwin) return (Ecore_Window)sd->x.xwin;
6907         if (sd->parent) return (Ecore_Window)elm_win_xwindow_get(sd->parent);
6908 #endif
6909      }
6910    else if (engine_name &&
6911             ((!strcmp(engine_name, ELM_OPENGL_COCOA)) ||
6912              (!strcmp(engine_name, "gl_cocoa"))))
6913      {
6914 #ifdef HAVE_ELEMENTARY_COCOA
6915         if (sd->cocoa.win) return (Ecore_Window)(sd->cocoa.win);
6916         if (sd->parent)
6917           {
6918              Ecore_Cocoa_Window *pwin;
6919              eo_do(sd->parent, pwin = elm_obj_win_cocoa_window_get());
6920              return (Ecore_Window)pwin;
6921           }
6922 #endif
6923      }
6924    else if ((engine_name &&
6925              ((!strcmp(engine_name, ELM_SOFTWARE_WIN32)) ||
6926               (!strcmp(engine_name, ELM_SOFTWARE_DDRAW)))))
6927      {
6928 #ifdef HAVE_ELEMENTARY_WIN32
6929         _internal_elm_win_win32window_get(sd);
6930         if (sd->win32.win) return (Ecore_Window)sd->win32.win;
6931         if (sd->parent) return (Ecore_Window)elm_win_win32_window_get(sd->parent);
6932 #endif
6933      }
6934
6935    return 0;
6936 }
6937
6938 void
6939 _elm_win_focus_highlight_in_theme_update(Evas_Object *obj, Eina_Bool in_theme)
6940 {
6941    ELM_WIN_DATA_GET(obj, sd);
6942    sd->focus_highlight.cur.in_theme = !!in_theme;
6943 }
6944
6945 void
6946 _elm_win_focus_highlight_start(Evas_Object *obj)
6947 {
6948    ELM_WIN_DATA_GET(obj, sd);
6949
6950    if (!(sd->focus_highlight.enabled) && !(sd->focus_highlight.auto_enabled)) return;
6951    sd->focus_highlight.cur.visible = EINA_TRUE;
6952    sd->focus_highlight.geometry_changed = EINA_TRUE;
6953    _elm_win_focus_highlight_reconfigure_job(obj);
6954 }
6955
6956 void
6957 _elm_win_focus_auto_show(Evas_Object *obj)
6958 {
6959    ELM_WIN_DATA_GET(obj, sd);
6960    Eina_Bool pfocus = (sd->focus_highlight.enabled) || (sd->focus_highlight.auto_enabled);
6961    sd->focus_highlight.auto_enabled = _elm_config->win_auto_focus_enable;
6962    sd->focus_highlight.auto_animate = _elm_config->win_auto_focus_animate;
6963    if (pfocus != ((sd->focus_highlight.enabled) || (sd->focus_highlight.auto_enabled)))
6964      {
6965         if ((sd->focus_highlight.enabled) || (sd->focus_highlight.auto_enabled))
6966           _elm_win_focus_highlight_init(sd);
6967      }
6968 }
6969
6970 void
6971 _elm_win_focus_auto_hide(Evas_Object *obj)
6972 {
6973    ELM_WIN_DATA_GET(obj, sd);
6974    Eina_Bool pfocus = (sd->focus_highlight.enabled) || (sd->focus_highlight.auto_enabled);
6975    sd->focus_highlight.auto_enabled = EINA_FALSE;
6976    sd->focus_highlight.auto_animate = EINA_FALSE;
6977    if (pfocus != ((sd->focus_highlight.enabled) || (sd->focus_highlight.auto_enabled)))
6978      {
6979         if (!((sd->focus_highlight.enabled) || (sd->focus_highlight.auto_enabled)))
6980           _elm_win_focus_highlight_shutdown(sd);
6981      }
6982 }
6983
6984 void
6985 _elm_win_object_set_accessibility_highlight(Evas_Object *win, Evas_Object *obj, Eina_Bool visible)
6986 {
6987    if (!win) return;
6988    ELM_WIN_DATA_GET(win, sd);
6989    if (visible || sd->accessibility_highlight.cur.target == obj)
6990      {
6991          _elm_win_accessibility_highlight_hide(win);
6992          _elm_win_accessibility_highlight_callbacks_del(sd);
6993      }
6994
6995    if (visible)
6996      {
6997          _elm_win_accessibility_highlight_init(sd, obj);
6998          _elm_win_accessibility_highlight_show(win);
6999          //TIZEN_ONLY(20160623): atspi: moved highlight when object is out of screen
7000          sd->accessibility_highlight.cur.need_moved = EINA_TRUE;
7001          //
7002      }
7003 }
7004
7005 //TIZEN_ONLY(20170919): Handle default label object
7006 static void
7007 _default_label_obj_del_cb (void *data,
7008                            Evas *e EINA_UNUSED,
7009                            Evas_Object *obj,
7010                            void *event_info EINA_UNUSED)
7011 {
7012    ELM_WIN_DATA_GET(data, sd);
7013    if (!sd) return;
7014
7015    sd->default_label_objs = eina_list_remove(sd->default_label_objs, obj);
7016 }
7017
7018 static int _sort_parent_child_order(const void *data1, const void *data2)
7019 {
7020    if (data1)
7021      {
7022         Eo *parent;
7023         eo_do(data1, parent = elm_interface_atspi_accessible_parent_get());
7024         while (parent)
7025           {
7026              if (parent == data2) return 1;
7027              eo_do(parent, parent = elm_interface_atspi_accessible_parent_get());
7028           }
7029      }
7030    return -1;
7031 }
7032
7033 void
7034 _elm_win_default_label_obj_append(Evas_Object *default_label_obj)
7035 {
7036    if (!default_label_obj) return;
7037
7038    Evas_Object *win = elm_widget_top_get(default_label_obj);
7039    if (!win || !eo_isa(win, ELM_WIN_CLASS))
7040      {
7041         WRN("The top object of %s is not a window.",
7042             eo_class_name_get(eo_class_get(default_label_obj)));
7043         return;
7044      }
7045
7046    ELM_WIN_DATA_GET(win, sd);
7047    if (!sd) return;
7048
7049    if (eina_list_data_find(sd->default_label_objs, default_label_obj))
7050      {
7051         sd->default_label_objs =
7052           eina_list_remove(sd->default_label_objs, default_label_obj);
7053         evas_object_event_callback_del_full(default_label_obj, EVAS_CALLBACK_DEL,
7054                                             _default_label_obj_del_cb, win);
7055      }
7056
7057    evas_object_event_callback_add(default_label_obj, EVAS_CALLBACK_DEL,
7058                                   _default_label_obj_del_cb, win);
7059    sd->default_label_objs =
7060      eina_list_append(sd->default_label_objs, default_label_obj);
7061
7062    sd->default_label_objs =
7063      eina_list_sort(sd->default_label_objs, -1, _sort_parent_child_order);
7064 }
7065
7066 void
7067 _elm_win_default_label_obj_remove(Evas_Object *default_label_obj)
7068 {
7069    if (!default_label_obj) return;
7070
7071    Evas_Object *win = elm_widget_top_get(default_label_obj);
7072    if (!win || !eo_isa(win, ELM_WIN_CLASS))
7073      {
7074         WRN("The top object of %s is not a window.",
7075             eo_class_name_get(eo_class_get(default_label_obj)));
7076         return;
7077      }
7078
7079    ELM_WIN_DATA_GET(win, sd);
7080    if (!sd) return;
7081
7082    if (eina_list_data_find(sd->default_label_objs, default_label_obj))
7083      {
7084         sd->default_label_objs =
7085           eina_list_remove(sd->default_label_objs, default_label_obj);
7086         evas_object_event_callback_del_full(default_label_obj, EVAS_CALLBACK_DEL,
7087                                             _default_label_obj_del_cb, win);
7088      }
7089 }
7090
7091 Evas_Object *
7092 _elm_win_default_label_obj_get(Evas_Object *obj)
7093 {
7094    if (!obj) return NULL;
7095    ELM_WIN_DATA_GET(obj, sd);
7096    if (!sd) return NULL;
7097
7098    return eina_list_last_data_get(sd->default_label_objs);
7099 }
7100 //
7101
7102 EAPI Ecore_Window
7103 elm_win_window_id_get(const Evas_Object *obj)
7104 {
7105    if (!obj) return 0;
7106
7107    if (!evas_object_smart_type_check_ptr(obj, MY_CLASS_NAME_LEGACY))
7108      {
7109         Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
7110         return ecore_evas_window_get(ee);
7111      }
7112
7113    ELM_WIN_CHECK(obj) 0;
7114    Ecore_Window ret = 0;
7115    eo_do((Eo *) obj, ret = elm_obj_win_window_id_get());
7116    return ret;
7117 }
7118
7119 /* TIZEN_ONLY(20160622): Override Paragraph Direction APIs */
7120 EOLIAN static void
7121 _elm_win_evas_object_paragraph_direction_set(Eo *obj, Elm_Win_Data *sd, Evas_BiDi_Direction dir)
7122 {
7123    evas_object_paragraph_direction_set(sd->edje, dir);
7124
7125    eo_do_super(obj, MY_CLASS, evas_obj_paragraph_direction_set(dir));
7126 }
7127 /* END */
7128
7129 EOLIAN static void
7130 _elm_win_class_constructor(Eo_Class *klass)
7131 {
7132    evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
7133 }
7134
7135 EOLIAN static Eo*
7136 _elm_win_elm_interface_atspi_accessible_parent_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
7137 {
7138    // TIZEN_ONLY(20160705) - enable atspi_proxy to work
7139    if (sd->socket_proxy) return sd->socket_proxy;
7140    //
7141
7142    // attach all kinds of windows directly to ATSPI application root object
7143    Eo *bridge = _elm_atspi_bridge_get();
7144    return elm_atspi_bridge_root_get(bridge);
7145 }
7146
7147 EOLIAN static const Elm_Atspi_Action*
7148 _elm_win_elm_interface_atspi_widget_action_elm_actions_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd EINA_UNUSED)
7149 {
7150    static Elm_Atspi_Action atspi_actions[] = {
7151           { "move,previous", "move", "previous", _key_action_move},
7152           { "move,next", "move", "next", _key_action_move},
7153           { "move,left", "move", "left", _key_action_move},
7154           { "move,right", "move", "right", _key_action_move},
7155           { "move,up", "move", "up", _key_action_move},
7156           { "move,down", "move", "down", _key_action_move},
7157           { NULL, NULL, NULL, NULL }
7158    };
7159    return &atspi_actions[0];
7160 }
7161
7162 EOLIAN static Elm_Atspi_State_Set
7163 _elm_win_elm_interface_atspi_accessible_state_set_get(Eo *obj, Elm_Win_Data *sd EINA_UNUSED)
7164 {
7165    Elm_Atspi_State_Set ret;
7166    eo_do_super(obj, MY_CLASS, ret = elm_interface_atspi_accessible_state_set_get());
7167
7168    if (elm_win_focus_get(obj))
7169      STATE_TYPE_SET(ret, ELM_ATSPI_STATE_ACTIVE);
7170
7171    return ret;
7172 }
7173
7174 EOLIAN static const char*
7175 _elm_win_elm_interface_atspi_accessible_name_get(Eo *obj, Elm_Win_Data *sd EINA_UNUSED)
7176 {
7177    const char *ret = NULL;
7178    eo_do_super(obj, ELM_WIN_CLASS, ret = elm_interface_atspi_accessible_name_get());
7179    if (ret) return ret;
7180
7181    return _elm_widget_accessible_plain_name_get(obj, elm_win_title_get(obj));
7182 }
7183
7184 EOLIAN static void
7185 _elm_win_elm_interface_atspi_component_extents_get(Eo *obj, Elm_Win_Data *sd EINA_UNUSED, Eina_Bool screen_coords, int *x, int *y, int *w, int *h)
7186 {
7187    int ee_x, ee_y;
7188
7189    if (x) *x = 0;
7190    if (y) *y = 0;
7191    evas_object_geometry_get(obj, NULL, NULL, w, h);
7192    if (screen_coords)
7193      {
7194         Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
7195         if (!ee) return;
7196         ecore_evas_geometry_get(ee, &ee_x, &ee_y, NULL, NULL);
7197         if (x) *x += ee_x;
7198         if (y) *y += ee_y;
7199      }
7200 }
7201
7202 #include "elm_win.eo.c"
7203
7204 //////////////////////////////////////////////////////////////////
7205
7206 EAPI const Eina_List *
7207 elm_win_aux_hints_supported_get(const Evas_Object *obj)
7208 {
7209    ELM_WIN_CHECK(obj) NULL;
7210    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, NULL);
7211    return ecore_evas_aux_hints_supported_get(sd->ee);
7212 }
7213
7214 EAPI int
7215 elm_win_aux_hint_add(Evas_Object *obj, const char *hint, const char *val)
7216 {
7217    ELM_WIN_CHECK(obj) -1;
7218    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, -1);
7219
7220 // TIZEN_ONLY(20170212): pend rotation until app set rotation
7221    if ((hint) && (!strncmp(hint, "wm.policy.win.rot.render.nopending", strlen(hint))))
7222      {
7223         return _elm_win_wm_pending_rotation_set(obj, hint, val);
7224      }
7225 //
7226    return ecore_evas_aux_hint_add(sd->ee, hint, val);
7227 }
7228
7229 EAPI Eina_Bool
7230 elm_win_aux_hint_del(Evas_Object *obj,
7231                      const int    id)
7232 {
7233    ELM_WIN_CHECK(obj) EINA_FALSE;
7234    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
7235    return ecore_evas_aux_hint_del(sd->ee, id);
7236 }
7237
7238 EAPI Eina_Bool
7239 elm_win_aux_hint_val_set(Evas_Object *obj, const int id, const char *val)
7240 {
7241    ELM_WIN_CHECK(obj) EINA_FALSE;
7242    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
7243    return ecore_evas_aux_hint_val_set(sd->ee, id, val);
7244 }
7245
7246 EAPI const char *
7247 elm_win_aux_hint_val_get(Evas_Object *obj, int id)
7248 {
7249    ELM_WIN_CHECK(obj) EINA_FALSE;
7250    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
7251    return ecore_evas_aux_hint_val_get(sd->ee, id);
7252 }
7253
7254 EAPI int
7255 elm_win_aux_hint_id_get(Evas_Object *obj, const char *hint)
7256 {
7257    ELM_WIN_CHECK(obj) EINA_FALSE;
7258    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
7259    return ecore_evas_aux_hint_id_get(sd->ee, hint);
7260 }
7261
7262 EINA_DEPRECATED EAPI void
7263 elm_win_profiles_set(Evas_Object *obj, const char **profiles, unsigned int num_profiles)
7264 {
7265    ELM_WIN_CHECK(obj);
7266    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
7267
7268    _elm_win_available_profiles_set(obj, sd, profiles, num_profiles);
7269 }
7270
7271 EAPI void
7272 elm_win_input_rect_set(Evas_Object *obj, Eina_Rectangle *input_rect)
7273 {
7274    ELM_WIN_CHECK(obj);
7275    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
7276    TRAP(sd, input_rect_set, input_rect);
7277 }
7278
7279 EAPI void
7280 elm_win_input_rect_add(Evas_Object *obj, Eina_Rectangle *input_rect)
7281 {
7282    ELM_WIN_CHECK(obj);
7283    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
7284    TRAP(sd, input_rect_add, input_rect);
7285 }
7286
7287 EAPI void
7288 elm_win_input_rect_subtract(Evas_Object *obj, Eina_Rectangle *input_rect)
7289 {
7290    ELM_WIN_CHECK(obj);
7291    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
7292    TRAP(sd, input_rect_subtract, input_rect);
7293 }
7294
7295 EAPI int
7296 elm_win_active_win_orientation_get(Evas_Object *obj)
7297 {
7298    int angle = -1;
7299 #ifdef HAVE_ELEMENTARY_WAYLAND
7300    Ecore_Wl_Window *win = NULL;
7301    if (obj)
7302      {
7303         ELM_WIN_DATA_GET(obj, sd);
7304         if (sd)
7305           win = sd->wl.win;
7306      }
7307    angle = ecore_wl_window_active_angle_get(win);
7308 #endif
7309    return angle;
7310 }
7311
7312 EAPI const char *
7313 elm_win_aux_msg_key_get(Evas_Object *obj,
7314                         Elm_Win_Aux_Message *msg)
7315 {
7316    ELM_WIN_CHECK(obj) NULL;
7317    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, NULL);
7318
7319    if (!msg) return NULL;
7320    return msg->key;
7321 }
7322
7323 EAPI const char *
7324 elm_win_aux_msg_val_get(Evas_Object *obj,
7325                         Elm_Win_Aux_Message *msg)
7326 {
7327    ELM_WIN_CHECK(obj) NULL;
7328    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, NULL);
7329
7330    if (!msg) return NULL;
7331    return msg->val;
7332 }
7333
7334 EAPI const Eina_List *
7335 elm_win_aux_msg_options_get(Evas_Object *obj,
7336                             Elm_Win_Aux_Message *msg)
7337 {
7338    ELM_WIN_CHECK(obj) NULL;
7339    ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, NULL);
7340
7341    if (!msg) return NULL;
7342    return msg->options;
7343 }
7344 //////////////////////////////////////////////////////////////////