ecore_wl2: add user width and height for ignoring unexpected configure event.
[platform/upstream/efl.git] / src / lib / elementary / efl_ui_win.c
1 #ifdef HAVE_CONFIG_H
2 # include "elementary_config.h"
3 #endif
4
5 #define EFL_ACCESS_OBJECT_PROTECTED
6 #define EFL_ACCESS_COMPONENT_PROTECTED
7 #define EFL_ACCESS_WIDGET_ACTION_PROTECTED
8 #define EFL_INPUT_EVENT_PROTECTED
9 #define EFL_GFX_HINT_PROTECTED
10 #define EFL_CANVAS_OBJECT_PROTECTED
11 #define EFL_UI_L10N_PROTECTED
12 #define EFL_UI_WIN_INLINED_PROTECTED
13 #define EFL_UI_FOCUS_OBJECT_PROTECTED
14 #define EFL_UI_WIDGET_FOCUS_MANAGER_PROTECTED
15 #define EFL_PART_PROTECTED
16 #define IPA_YLNO_ESU_LANRETNI_MLE
17
18 #include <Elementary.h>
19 #include <Elementary_Cursor.h>
20
21 #include "efl_tracing.h"
22
23 #include "elm_priv.h"
24 #include "elm_widget_menu.h"
25 #ifdef HAVE_ELEMENTARY_WL2
26 # include "ecore_evas_wayland_private.h"
27 #endif
28
29 #include "../evas/canvas/evas_box_eo.h"
30
31 #include "elm_part_helper.h"
32 #include "efl_ui_win_part.eo.h"
33 #include "elm_plug_eo.h"
34 #include "efl_ui_win_legacy_eo.h"
35 #include "efl_ui_win_socket_legacy_eo.h"
36 #include "efl_ui_win_inlined_legacy_eo.h"
37 #include "efl_ui_widget_common.h"
38
39 #define MY_CLASS EFL_UI_WIN_CLASS
40 #define MY_CLASS_NAME "Efl.Ui.Win"
41 #define MY_CLASS_NAME_LEGACY "elm_win"
42
43 #define FRAME_OBJ_THEME_MIN_VERSION 119
44
45 extern void ecore_evas_dnd_mark_motion_used(Ecore_Evas *ee, unsigned int seat);
46
47 Ecore_Evas *_wayland_shm_new(const char *disp_name, Ecore_Window parent, int x, int y, int w, int h, Eina_Bool frame);
48 Ecore_Evas *_wayland_egl_new(const char *disp_name, Ecore_Window parent, int x, int y, int w, int h, Eina_Bool frame, const int *opt);
49
50 static const Elm_Win_Trap *trap = NULL;
51
52 static int _paused_windows = 0;
53
54 #define TRAP(sd, name, ...)                                             \
55   do                                                                    \
56     {                                                                   \
57        if (sd->type != EFL_UI_WIN_TYPE_FAKE)                                    \
58          if ((!trap) || (!trap->name) ||                                \
59              ((trap->name) &&                                           \
60               (trap->name(sd->trap_data, sd->obj, ## __VA_ARGS__))))    \
61            ecore_evas_##name(sd->ee, ##__VA_ARGS__);                    \
62     }                                                                   \
63   while (0)
64
65 #define ELM_WIN_DATA_GET(o, sd) \
66   Efl_Ui_Win_Data *sd = efl_data_scope_get(o, MY_CLASS)
67
68 #define ELM_WIN_DATA_GET_OR_RETURN(o, ptr, ...)      \
69   ELM_WIN_DATA_GET(o, ptr);                          \
70   if (!ptr)                                          \
71     {                                                \
72        ERR("No widget data for object %p (%s)",      \
73             o, efl_class_name_get(o));                \
74        return __VA_ARGS__;                           \
75     }
76
77 // Ecore_Evas callbacks are unsafe unlike EO calls. As a consequence a user
78 // callback (eg evas cb, efl event cb, ...) could be triggered that deletes the
79 // object. This macro ensures the sd data is still valid after a foreign call.
80 #define ELM_WIN_DATA_ALIVE_CHECK(_obj, _sd, ...) do { \
81    _sd = efl_data_scope_safe_get(_obj, MY_CLASS); \
82    if (EINA_UNLIKELY(!(_sd))) { return __VA_ARGS__; } \
83    } while (0)
84
85 #define ENGINE_GET() (_elm_preferred_engine ? _elm_preferred_engine : _elm_config->engine)
86
87 typedef struct _Efl_Ui_Win_Data Efl_Ui_Win_Data;
88 typedef struct _Input_Pointer_Iterator Input_Pointer_Iterator;
89
90 struct _Efl_Ui_Win_Data
91 {
92    Ecore_Evas           *ee;
93    Evas                 *evas;
94    Evas_Object          *parent; /* parent *window* object*/
95    Evas_Object          *img_obj, *frame_obj;
96    Eo /* wref */        *bg, *content;
97    Evas_Object          *obj; /* The object itself */
98    Evas_Object          *indicator;
99 #ifdef HAVE_ELEMENTARY_X
100    struct
101    {
102       Ecore_X_Window       xwin;
103       Ecore_Event_Handler *client_message_handler;
104       Ecore_Event_Handler *property_handler;
105       Eina_Bool shaped : 1;
106    } x;
107 #endif
108 #ifdef HAVE_ELEMENTARY_WL2
109    struct
110    {
111       Ecore_Wl2_Window *win;
112       Ecore_Event_Handler *configure_handler;
113
114       //TIZEN_ONLY(20171110): added signal for effect start and done
115       Ecore_Event_Handler *effect_start_handler;
116       Ecore_Event_Handler *effect_end_handler;
117       //
118       // TIZEN_ONLY(20160801): indicator implementation
119       Ecore_Event_Handler *indicator_flick_handler;
120       //
121       // TIZEN_ONLY(20150722): added signal for aux_hint(auxiliary hint)
122       Ecore_Event_Handler *aux_msg_handler;
123       //
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       Ecore_Event_Handler *key_down_handler;
136    } win32;
137 #endif
138
139    unsigned /* Efl_Ui_Win_Type */    type;
140    Efl_Ui_Win_Keyboard_Mode          kbdmode;
141    Efl_Ui_Win_Indicator_Mode         indimode;
142 // TIZEN_ONLY(20150707): elm_conform for wayland, and signal if parts are changed
143    Eina_Rectangle kbd;
144    Eina_Rectangle ind;
145 //
146    struct
147    {
148       const char  *info;
149       Ecore_Timer *timer;
150       int          repeat_count;
151       int          shot_counter;
152    } shot;
153    int                           *autodel_clear, rot;
154    struct
155    {
156       int x, y;
157    } screen;
158    struct
159    {
160 #ifdef HAVE_ELEMENTARY_WL2
161       Ecore_Wl2_Window *win;
162       struct wl_surface *surf;
163 #endif
164       Ecore_Evas  *ee;
165       Evas_Object *obj;
166       int          hot_x, hot_y;
167       Eina_Bool    visible : 1;
168    } pointer;
169    struct
170    {
171       Evas_Object *fobj; /* focus highlight edje object */
172
173       struct
174       {
175          Evas_Object *target;
176          Eina_Bool    visible : 1;
177          Eina_Bool    in_theme: 1; /**< focus highlight is handled by theme.
178                                      this is set true if edc data item "focus_highlight" is set to "on" during focus in callback. */
179       } cur, prev;
180
181       const char  *style;
182       Ecore_Job   *reconf_job;
183
184       Eina_Bool    enabled : 1;
185       Eina_Bool    theme_changed : 1; /* set true when the focus theme is changed */
186       Eina_Bool    animate : 1; /* set true when the focus highlight animate is enabled */
187       Eina_Bool    animate_supported : 1; /* set true when the focus highlight animate is supported by theme */
188       Eina_Bool    geometry_changed : 1;
189       Eina_Bool    auto_enabled : 1;
190       Eina_Bool    auto_animate : 1;
191    } focus_highlight;
192
193    // TIZEN_ONLY(20171114) Accessibility Highlight Frame added
194    struct
195    {
196       // Evas_Object *fobj; /*accessibility highlight edje object */
197       // Evas_Object *target;
198       // Eina_Bool enabled;
199       Evas_Object *fobj; /* accessibility highlight edje object */
200
201       struct
202       {
203          Evas_Object *target;
204          //TIZEN_ONLY(20160623): atspi: moved highlight when object is out of screen
205          int x;
206          int y;
207          int w;
208          int h;
209          Eina_Bool need_moved;
210          //
211       } cur, prev;
212
213    } accessibility_highlight;
214    //
215    //TIZEN_ONLY(20170919): Handle default label object
216    Eina_List *default_label_objs;
217    //
218    Evas_Object *icon;
219    const char  *title;
220    const char  *icon_name;
221    const char  *role;
222    const char  *stack_id;
223    const char  *stack_master_id;
224    Eina_Stringshare *name;
225    Eina_Stringshare *accel_pref;
226
227    Eina_Future *finalize_future;
228
229    Evas_Object *main_menu;
230
231    Efl_Ui_Focus_Parent_Provider_Standard *provider;
232
233    struct
234    {
235       Eina_Stringshare *name; /* Current profile in use */
236       Eina_Array       *available; /* Never NULL, contains Eina_Stringshare */
237    } profile;
238    struct
239    {
240       int          preferred_rot; /* indicates preferred rotation value, -1 means invalid. */
241       int         *rots; /* indicates available rotations */
242       unsigned int count; /* number of elements in available rotations */
243       Eina_Bool    wm_supported : 1; /* set true when the window manager support window rotation */
244       Eina_Bool    use : 1; /* set true when application use window manager rotation. */
245 // TIZEN_ONLY(20170212): pend rotation until app set rotation
246       Eina_Bool    rotation_pending : 1; /* set true when application will manage the rotation */
247 //
248    } wm_rot;
249
250    void *trap_data;
251
252    double       aspect; /* defined as w/h or 0 */
253    int          size_base_w, size_base_h;
254    int          size_step_w, size_step_h;
255    int          req_x, req_y, req_w, req_h;
256    int          max_w, max_h;
257    int          norender;
258    int          modal_count;
259    int          response;
260    Eina_Bool    req_wh : 1;
261    Eina_Bool    req_xy : 1;
262    Eina_Array   *selection_changed;
263    Eina_Array   *planned_changes;
264    Eina_Inarray *drop_target;
265
266    struct {
267       short     pointer_move;
268       short     pointer_down;
269       short     pointer_up;
270       short     pointer_in;
271       short     pointer_out;
272       short     pointer_cancel;
273       short     pointer_wheel;
274       short     finger_move;
275       short     finger_down;
276       short     finger_up;
277       short     key_down;
278       short     key_up;
279       short     render_pre;
280       short     render_post;
281       short     focus_in;
282       short     focus_out;
283       short     object_focus_in;
284       short     object_focus_out;
285       short     device_changed;
286    } event_forward;
287
288    struct {
289       /* frame_obj is always used except for FAKE */
290       Eina_Bool need : 1; /**< if true, application draws its own csd */
291       Eina_Bool need_shadow : 1; /**< if true, application draws its csd and shadow */
292       Eina_Bool need_borderless : 1;
293       Eina_Bool need_bg_solid : 1;
294       Eina_Bool need_bg_standard : 1;
295       Eina_Bool need_menu : 1;
296       Eina_Bool need_unresizable : 1;
297       Eina_Bool need_indicator : 1;
298       Eina_Bool cur_borderless : 1;
299       Eina_Bool cur_shadow : 1;
300       Eina_Bool cur_focus : 1;
301       Eina_Bool cur_maximized : 1;
302       Eina_Bool cur_bg_solid : 1;
303       Eina_Bool cur_bg_standard : 1;
304       Eina_Bool cur_menu : 1;
305       Eina_Bool cur_unresizable : 1;
306       Eina_Bool cur_indicator : 1;
307       Eina_Bool wayland : 1;
308    } csd;
309
310    struct {
311       Evas_Object *box, *edje;
312       Elm_Win_Indicator_Mode         indmode;
313       Elm_Win_Indicator_Opacity_Mode ind_o_mode;
314       Eina_Bool    forbidden : 1; /**< Marks some legacy APIs as not allowed. */
315       Eina_Bool    bg_must_swallow : 1; /**< Legacy theme compatibility (elm_bg for standard window) */
316       Eina_Bool    bg_must_swallow_init : 1;
317       Eina_Bool    ctor : 1; /**< legacy constructor: elm_win~add */
318    } legacy;
319    Efl_Ui_Shared_Win_Data spd;
320
321    Eina_Value exit_on_close;
322
323    Eina_Bool    first_draw : 1;
324    Eina_Bool    deferred_resize_job : 1;
325    Eina_Bool    urgent : 1;
326    Eina_Bool    modal : 1;
327    Eina_Bool    demand_attention : 1;
328    Eina_Bool    autodel : 1;
329    Eina_Bool    autohide : 1;
330    Eina_Bool    constrain : 1;
331    Eina_Bool    resizing : 1;
332    Eina_Bool    minimized : 1;
333    Eina_Bool    withdrawn : 1;
334    Eina_Bool    sticky : 1;
335    Eina_Bool    fullscreen : 1;
336    Eina_Bool    maximized : 1;
337    Eina_Bool    skip_focus : 1;
338    Eina_Bool    floating : 1;
339    Eina_Bool    noblank : 1;
340    Eina_Bool    theme_alpha : 1; /**< alpha value fetched by a theme. this has higher priority than application_alpha */
341    Eina_Bool    application_alpha : 1; /**< alpha value set by an elm_win_alpha_set() api. this has lower priority than theme_alpha */
342    Eina_Bool    tmp_updating_hints : 1;
343    Eina_Bool    single_edje_content: 1; /* hack for E */
344    Eina_Bool    shown : 1;
345    Eina_Bool    stack_base : 1;
346    Eina_Bool    paused : 1;
347
348    // TIZEN_ONLY(20160120): support visibility_change event
349    Eina_Bool    obscured : 1;
350    //
351 };
352
353 struct _Input_Pointer_Iterator
354 {
355    Eina_Iterator  iterator;
356    Eina_List     *list;
357    Eina_Iterator *real_iterator;
358    const Eo      *object;
359 };
360
361 static const char SIG_DELETE_REQUEST[] = "delete,request";
362 static const char SIG_FOCUS_OUT[] = "focus,out"; // deprecated. use "unfocused" instead.
363 static const char SIG_FOCUS_IN[] = "focus,in"; // deprecated. use "focused" instead.
364 static const char SIG_MOVED[] = "moved";
365 static const char SIG_WITHDRAWN[] = "withdrawn";
366 static const char SIG_MINIMIZED[] = "minimized";
367 static const char SIG_NORMAL[] = "normal";
368 static const char SIG_STICK[] = "stick";
369 static const char SIG_UNSTICK[] = "unstick";
370 static const char SIG_FULLSCREEN[] = "fullscreen";
371 static const char SIG_UNFULLSCREEN[] = "unfullscreen";
372 static const char SIG_MAXIMIZED[] = "maximized";
373 static const char SIG_UNMAXIMIZED[] = "unmaximized";
374 static const char SIG_IOERR[] = "ioerr";
375 static const char SIG_INDICATOR_PROP_CHANGED[] = "indicator,prop,changed";
376 static const char SIG_ROTATION_CHANGED[] = "rotation,changed";
377 static const char SIG_PROFILE_CHANGED[] = "profile,changed";
378 static const char SIG_WM_ROTATION_CHANGED[] = "wm,rotation,changed";
379
380 // TIZEN_ONLY(20160801): indicator implementation
381 #ifdef HAVE_ELEMENTARY_WL2
382 static const char SIG_INDICATOR_FLICK_DONE[] = "indicator,flick,done";
383 #endif
384 //
385 static const char SIG_EFFECT_STARTED[] = "effect,started";
386 static const char SIG_EFFECT_DONE[] = "effect,done";
387 //
388 //TIZEN_ONLY(20161028): add smart signal 'atspi,screen,reader,changed'
389 static const char SIG_ATSPI_SCREEN_READER_CHANGED[] = "atspi,screen,reader,changed";
390 //
391 // TIZEN_ONLY(20160120): support visibility_change event
392 static const char SIG_VISIBILITY_CHANGED[] = "visibility,changed";
393 //
394 //TIZEN_ONLY(20160704): added signal for launch
395 static const char SIG_LAUNCH_DONE[] = "launch,done";
396 //
397 // TIZEN_ONLY(20150722): added signal for aux_hint(auxiliary hint)
398 static const char SIG_AUX_HINT_ALLOWED[] = "aux,hint,allowed";
399 static const char SIG_AUX_MESSAGE_RECEIVED[] = "aux,msg,received";
400 //
401 // TIZEN_ONLY(20150707): elm_conform for wayland, and signal if parts are changed
402 static const char SIG_CONFORMANT_CHANGED[] = "conformant,changed";
403 //
404
405 static const Evas_Smart_Cb_Description _smart_callbacks[] = {
406    {SIG_DELETE_REQUEST, ""},
407    {SIG_FOCUS_OUT, ""},
408    {SIG_FOCUS_IN, ""},
409    {SIG_MOVED, ""},
410    {SIG_WITHDRAWN, ""},
411    {SIG_MINIMIZED, ""},
412    {SIG_NORMAL, ""},
413    {SIG_STICK, ""},
414    {SIG_UNSTICK, ""},
415    {SIG_FULLSCREEN, ""},
416    {SIG_UNFULLSCREEN, ""},
417    {SIG_MAXIMIZED, ""},
418    {SIG_UNMAXIMIZED, ""},
419    {SIG_IOERR, ""},
420    {SIG_INDICATOR_PROP_CHANGED, ""},
421    {SIG_ROTATION_CHANGED, ""},
422    {SIG_PROFILE_CHANGED, ""},
423    {SIG_WM_ROTATION_CHANGED, ""},
424    {SIG_WIDGET_FOCUSED, ""}, /**< handled by elm_widget */
425    {SIG_WIDGET_UNFOCUSED, ""}, /**< handled by elm_widget */
426 // TIZEN_ONLY(20150707): elm_conform for wayland, and signal if parts are changed
427    {SIG_CONFORMANT_CHANGED, ""},
428    {SIG_AUX_HINT_ALLOWED, ""},
429    {SIG_AUX_MESSAGE_RECEIVED, ""},
430    {SIG_EFFECT_STARTED, ""},
431    {SIG_EFFECT_DONE, ""},
432    {SIG_LAUNCH_DONE, ""},
433 //
434 //TIZEN_ONLY(20161028): add smart signal 'atspi,screen,reader,changed'
435    {SIG_ATSPI_SCREEN_READER_CHANGED, ""},
436 //
437 // TIZEN_ONLY(20150707): elm_conform for wayland, and signal if parts are changed
438    {SIG_VISIBILITY_CHANGED, ""},
439 //
440    {NULL, NULL}
441 };
442
443 static Eina_Bool _key_action_return(Evas_Object *obj, const char *params);
444 static Eina_Bool _key_action_move(Evas_Object *obj, const char *params);
445 // TIZEN_ONLY(20171114) Accessibility Highlight Frame added
446 // //TIZEN_ONLY(20171108): bring HIGHLIGHT related changes
447 // static void _elm_win_accessibility_highlight_shutdown(Efl_Ui_Win_Data *sd);
448 // static void _elm_win_accessibility_highlight_update(Efl_Ui_Win_Data *sd);
449 // //
450 //
451
452 static const Elm_Action key_actions[] = {
453    {"return", _key_action_return},
454    {"move", _key_action_move},
455    {NULL, NULL}
456 };
457
458 Eina_List *_elm_win_list = NULL;
459 int _elm_win_deferred_free = 0;
460 static Eina_Value exit_on_all_windows_closed;
461
462 static Eina_Bool _elm_win_throttle_ok = EINA_FALSE;
463 static int _elm_win_count = 0;
464
465 // TIZEN_ONLY(20160218): Improve launching performance.
466 static Evas_Object *_precreated_win_obj = NULL;
467 //
468
469 static Eina_Bool _elm_win_auto_throttled = EINA_FALSE;
470
471 /*TIZEN_ONLY(20171113):Use ecore_job instead of ecore_timer
472 static Ecore_Timer *_elm_win_state_eval_timer = NULL;
473 */
474 static Ecore_Job *_elm_win_state_eval_job = NULL;
475 //
476
477 static void _elm_win_legacy_init(Efl_Ui_Win_Data *sd);
478 static void
479 _elm_win_on_resize_obj_changed_size_hints(void *data,
480                                           Evas *e,
481                                           Evas_Object *obj,
482                                           void *event_info);
483 static void
484 _elm_win_img_callbacks_del(Evas_Object *obj, Evas_Object *imgobj);
485 static Eina_Error _elm_win_theme_internal(Eo *obj, Efl_Ui_Win_Data *sd);
486 static void _elm_win_frame_add(Efl_Ui_Win_Data *sd, const char *element, const char *style);
487 static void _elm_win_frame_style_update(Efl_Ui_Win_Data *sd, Eina_Bool force_emit, Eina_Bool calc);
488 static inline void _elm_win_need_frame_adjust(Efl_Ui_Win_Data *sd, const char *engine);
489 static void _elm_win_resize_objects_eval(Evas_Object *obj, Eina_Bool force_resize);
490 static void _elm_win_frame_obj_update(Efl_Ui_Win_Data *sd, Eina_Bool force);
491 static void _ee_backbone_init(Efl_Ui_Win *obj, Efl_Ui_Win_Data *pd);
492 static void _ee_backbone_shutdown(Efl_Ui_Win *obj, Efl_Ui_Win_Data *pd);
493
494 static inline Efl_Ui_Win_Type
495 _elm_win_type_to_efl_ui_win_type(Elm_Win_Type type)
496 {
497    switch (type)
498      {
499 #define CONVERT_TYPE(TYPE) case ELM_WIN_##TYPE: return EFL_UI_WIN_TYPE_##TYPE
500       CONVERT_TYPE(BASIC);
501       CONVERT_TYPE(DIALOG_BASIC);
502       CONVERT_TYPE(DESKTOP);
503       CONVERT_TYPE(DOCK);
504       CONVERT_TYPE(TOOLBAR);
505       CONVERT_TYPE(MENU);
506       CONVERT_TYPE(UTILITY);
507       CONVERT_TYPE(SPLASH);
508       CONVERT_TYPE(DROPDOWN_MENU);
509       CONVERT_TYPE(POPUP_MENU);
510       CONVERT_TYPE(TOOLTIP);
511       CONVERT_TYPE(NOTIFICATION);
512       CONVERT_TYPE(COMBO);
513       CONVERT_TYPE(DND);
514       CONVERT_TYPE(INLINED_IMAGE);
515       CONVERT_TYPE(SOCKET_IMAGE);
516       CONVERT_TYPE(FAKE);
517       CONVERT_TYPE(NAVIFRAME_BASIC);
518       default: break;
519      }
520    return EFL_UI_WIN_TYPE_UNKNOWN;
521 #undef CONVERT_TYPE
522 }
523
524 static inline Elm_Win_Type
525 _efl_ui_win_type_to_elm_win_type(Efl_Ui_Win_Type type)
526 {
527    switch (type)
528      {
529 //#define CONVERT_TYPE(TYPE) case EFL_UI_WIN_TYPE_##TYPE: return ELM_WIN_##TYPE
530       /*CONVERT_TYPE(BASIC);
531       CONVERT_TYPE(DIALOG_BASIC);
532       CONVERT_TYPE(DESKTOP);
533       CONVERT_TYPE(DOCK);
534       CONVERT_TYPE(TOOLBAR);
535       CONVERT_TYPE(MENU);
536       CONVERT_TYPE(UTILITY);
537       CONVERT_TYPE(SPLASH);
538       CONVERT_TYPE(DROPDOWN_MENU);
539       CONVERT_TYPE(POPUP_MENU);
540       CONVERT_TYPE(TOOLTIP);
541       CONVERT_TYPE(NOTIFICATION);
542       CONVERT_TYPE(COMBO);
543       CONVERT_TYPE(DND);
544       CONVERT_TYPE(INLINED_IMAGE);
545       CONVERT_TYPE(SOCKET_IMAGE);
546       CONVERT_TYPE(FAKE);
547       CONVERT_TYPE(NAVIFRAME_BASIC);*/
548       case EFL_UI_WIN_TYPE_BASIC: return ELM_WIN_BASIC;
549       case EFL_UI_WIN_TYPE_DIALOG_BASIC: return ELM_WIN_DIALOG_BASIC;
550       case EFL_UI_WIN_TYPE_DESKTOP: return ELM_WIN_DESKTOP;
551       case EFL_UI_WIN_TYPE_DOCK: return ELM_WIN_DOCK;
552       case EFL_UI_WIN_TYPE_TOOLBAR: return ELM_WIN_TOOLBAR;
553       case EFL_UI_WIN_TYPE_MENU: return ELM_WIN_MENU;
554       case EFL_UI_WIN_TYPE_UTILITY: return ELM_WIN_UTILITY;
555       case EFL_UI_WIN_TYPE_SPLASH: return ELM_WIN_SPLASH;
556       case EFL_UI_WIN_TYPE_DROPDOWN_MENU: return ELM_WIN_DROPDOWN_MENU;
557       case EFL_UI_WIN_TYPE_POPUP_MENU: return ELM_WIN_POPUP_MENU;
558       case EFL_UI_WIN_TYPE_TOOLTIP: return ELM_WIN_TOOLTIP;
559       case EFL_UI_WIN_TYPE_NOTIFICATION: return ELM_WIN_NOTIFICATION;
560       case EFL_UI_WIN_TYPE_COMBO: return ELM_WIN_COMBO;
561       case EFL_UI_WIN_TYPE_DND: return ELM_WIN_DND;
562       case EFL_UI_WIN_TYPE_INLINED_IMAGE: return ELM_WIN_INLINED_IMAGE;
563       case EFL_UI_WIN_TYPE_SOCKET_IMAGE: return ELM_WIN_SOCKET_IMAGE;
564       case EFL_UI_WIN_TYPE_FAKE: return ELM_WIN_FAKE;
565       case EFL_UI_WIN_TYPE_NAVIFRAME_BASIC: return ELM_WIN_NAVIFRAME_BASIC;
566       default: break;
567      }
568    return ELM_WIN_UNKNOWN;
569 //#undef CONVERT_TYPE
570 }
571
572 #ifdef HAVE_ELEMENTARY_X
573 static void _elm_win_xwin_update(Efl_Ui_Win_Data *sd);
574 #endif
575 // TIZEN_ONLY(20160404)  skip_focus in case invoking elm_win_quickpanel_set
576 static void _elm_win_focus_skip_set(Efl_Ui_Win_Data *sd, Eina_Bool skip);
577 //
578
579 EAPI double _elm_startup_time = 0;
580
581 static void
582 _elm_win_first_frame_do(void *data, Evas *e EINA_UNUSED, void *event_info EINA_UNUSED)
583 {
584    double end = ecore_time_unix_get();
585    char *first = data;
586
587    switch (*first)
588      {
589       case 'A': abort();
590       case 'E':
591       case 'D': exit(-1);
592       case 'T': fprintf(stderr, "Startup time: '%f' - '%f' = '%f' sec\n", end, _elm_startup_time, end - _elm_startup_time);
593                 break;
594      }
595
596    evas_event_callback_del_full(e, EVAS_CALLBACK_RENDER_POST, _elm_win_first_frame_do, data);
597 }
598
599 Ecore_X_Window
600 _elm_ee_xwin_get(const Ecore_Evas *ee)
601 {
602 #ifdef HAVE_ELEMENTARY_X
603    const char *engine_name;
604    if (!ee) return 0;
605
606    engine_name = ecore_evas_engine_name_get(ee);
607    if (EINA_UNLIKELY(!engine_name)) return 0;
608
609    if (!strcmp(engine_name, ELM_SOFTWARE_X11))
610      {
611         return ecore_evas_software_x11_window_get(ee);
612      }
613    else if (!strcmp(engine_name, ELM_OPENGL_X11))
614      {
615         return ecore_evas_gl_x11_window_get(ee);
616      }
617 #else
618    (void)ee;
619 #endif
620    return 0;
621 }
622
623 #ifdef HAVE_ELEMENTARY_X
624 static void
625 _internal_elm_win_xwindow_get(Efl_Ui_Win_Data *sd)
626 {
627    Ecore_X_Window pwin = sd->x.xwin;
628    sd->x.xwin = _elm_ee_xwin_get(sd->ee);
629    if (sd->x.xwin != pwin)
630      {
631         char buf[128];
632
633         snprintf(buf, sizeof(buf), "%x", sd->x.xwin);
634         eina_stringshare_del(sd->stack_id);
635         sd->stack_id = eina_stringshare_add(buf);
636      }
637 }
638 #endif
639
640 Ecore_Wl2_Window *
641 _elm_ee_wlwin_get(const Ecore_Evas *ee)
642 {
643 #ifdef HAVE_ELEMENTARY_WL2
644    const char *engine_name;
645
646    if (!ee) return NULL;
647
648    engine_name = ecore_evas_engine_name_get(ee);
649    if (EINA_UNLIKELY(!engine_name)) return NULL;
650
651    if ((!strcmp(engine_name, ELM_WAYLAND_SHM)) ||
652        (!strcmp(engine_name, ELM_WAYLAND_EGL)))
653      {
654         return ecore_evas_wayland2_window_get(ee);
655      }
656 #else
657    (void)ee;
658 #endif
659    return NULL;
660 }
661
662 static void
663 _win_noblank_eval(void)
664 {
665 #ifdef HAVE_ELEMENTARY_X
666    Eina_List *l;
667    Evas_Object *obj;
668    int noblanks = 0;
669    Eina_Bool change = EINA_FALSE;
670
671    EINA_LIST_FOREACH(_elm_win_list, l, obj)
672      {
673         ELM_WIN_DATA_GET(obj, sd);
674
675         if (sd->x.xwin)
676           {
677              _internal_elm_win_xwindow_get(sd);
678              if ((sd->noblank) && (!sd->minimized) && (!sd->withdrawn) &&
679                  evas_object_visible_get(obj))
680                noblanks++;
681
682              change = EINA_TRUE;
683           }
684      }
685
686    if (!change) return;
687
688    if (noblanks > 0) ecore_x_screensaver_suspend();
689    else ecore_x_screensaver_resume();
690 #endif
691 #ifdef HAVE_ELEMENTARY_WL2
692    // XXX: no wl implementation of this yet - maybe higher up at prop level
693 #endif
694 }
695
696 static Elm_Process_State _elm_process_state = ELM_PROCESS_STATE_FOREGROUND;
697
698 EAPI Elm_Process_State
699 elm_process_state_get(void)
700 {
701    return _elm_process_state;
702 }
703
704 static void
705 _elm_win_apply_alpha(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
706 {
707    Eina_Bool enabled;
708
709    if (!sd->ee) return;
710
711    enabled = sd->theme_alpha | sd->application_alpha;
712    if (sd->img_obj)
713      {
714         evas_object_image_alpha_set(sd->img_obj, enabled);
715         ecore_evas_alpha_set(sd->ee, enabled);
716      }
717    else
718      {
719 #ifdef HAVE_ELEMENTARY_X
720         if (sd->x.xwin)
721           {
722              _internal_elm_win_xwindow_get(sd);
723              enabled |= (sd->csd.need && !sd->fullscreen);
724              if (!ecore_x_screen_is_composited(0))
725                {
726                   if (enabled || (!sd->x.shaped))
727                     TRAP(sd, shaped_set, enabled);
728                }
729              else
730                TRAP(sd, alpha_set, enabled);
731           }
732         else
733 #else
734           (void)obj;
735 #endif
736           TRAP(sd, alpha_set, enabled);
737      }
738 }
739
740 /* auto norender withdrawn is really only for X11.
741  * On other backends like wayland, there's actually
742  * no way for a client to tell if the window is
743  * minimized or not.  You can request minimized state
744  * but there's no explicit feedback for minimization
745  * or return to normal state.
746  *
747  * So, blocking drawing based on client side thinking
748  * it's minimized, and having the compositor think
749  * the client should be drawing will lead to
750  * predictably disappointing results.
751  *
752  * If you maintain a backend that is really capable
753  * of handling this properly, feel free to extend
754  * the whitelist.
755  */
756 static Eina_Bool
757 _elm_win_auto_norender_withdrawn(const Evas_Object *obj)
758 {
759    const char *engine;
760    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
761
762    if (!sd)
763      return _elm_config->auto_norender_withdrawn;
764
765    engine = ecore_evas_engine_name_get(sd->ee);
766    //TIZEN_ONLY(20191119): Tizen Wayland has own policy listener for it.
767    //if (!strcmp(engine, ELM_SOFTWARE_X11) || !strcmp(engine, ELM_OPENGL_X11))
768    if (!strcmp(engine, ELM_WAYLAND_EGL) || !strcmp(engine, ELM_SOFTWARE_X11) || !strcmp(engine, ELM_OPENGL_X11))
769    //
770      return _elm_config->auto_norender_withdrawn;
771
772    return EINA_FALSE;
773 }
774
775 static void
776 _elm_win_state_eval(void *data EINA_UNUSED)
777 {
778    Eina_List *l;
779    Evas_Object *obj;
780    int _elm_win_count_shown = 0;
781    int _elm_win_count_minimized = 0;
782    int _elm_win_count_withdrawn = 0;
783    Eina_Bool throttle = EINA_FALSE;
784
785 /*TIZEN_ONLY(20171113):Use ecore_job instead of ecore_timer
786    _elm_win_state_eval_timer = NULL;
787 */
788    _elm_win_state_eval_job = NULL;
789 //
790
791    EINA_LIST_FOREACH(_elm_win_list, l, obj)
792      {
793         if (_elm_win_auto_norender_withdrawn(obj))
794           {
795              if ((elm_win_withdrawn_get(obj)) ||
796                  ((elm_win_iconified_get(obj) &&
797                    (_elm_config->auto_norender_iconified_same_as_withdrawn))))
798                {
799                   if (!evas_object_data_get(obj, "__win_auto_norender"))
800                     {
801                        Evas *evas = evas_object_evas_get(obj);
802
803                        elm_win_norender_push(obj);
804                        evas_object_data_set(obj, "__win_auto_norender", obj);
805
806                        if (_elm_config->auto_flush_withdrawn)
807                          {
808                             edje_file_cache_flush();
809                             edje_collection_cache_flush();
810                             evas_image_cache_flush(evas);
811                             evas_font_cache_flush(evas);
812                          }
813                        if (_elm_config->auto_dump_withdrawn)
814                          {
815                             evas_render_dump(evas);
816                          }
817                     }
818
819                   if (elm_win_iconified_get(obj))
820                     efl_event_callback_call(obj, EFL_UI_WIN_EVENT_PAUSE, NULL);
821                   continue;
822                }
823           }
824         if (evas_object_data_get(obj, "__win_auto_norender"))
825           {
826              elm_win_norender_pop(obj);
827              evas_object_data_del(obj, "__win_auto_norender");
828           }
829      }
830    if (((_elm_config->auto_throttle) &&
831         (elm_policy_get(ELM_POLICY_THROTTLE) != ELM_POLICY_THROTTLE_NEVER)) ||
832         (elm_policy_get(ELM_POLICY_THROTTLE) == ELM_POLICY_THROTTLE_HIDDEN_ALWAYS))
833      throttle = EINA_TRUE;
834    if (_elm_win_count == 0)
835      {
836         if ((_elm_win_throttle_ok) && (_elm_win_auto_throttled))
837           {
838              _elm_process_state = ELM_PROCESS_STATE_FOREGROUND;
839              ecore_event_add(ELM_EVENT_PROCESS_FOREGROUND, NULL, NULL, NULL);
840              if (throttle)
841                ecore_throttle_adjust(-_elm_config->auto_throttle_amount);
842              _elm_win_auto_throttled = EINA_FALSE;
843           }
844      }
845    else
846      {
847         EINA_LIST_FOREACH(_elm_win_list, l, obj)
848           {
849              if (elm_win_withdrawn_get(obj)) _elm_win_count_withdrawn++;
850              else if (elm_win_iconified_get(obj)) _elm_win_count_minimized++;
851              else if (evas_object_visible_get(obj)) _elm_win_count_shown++;
852           }
853         if (_elm_win_count_shown <= 0)
854           {
855              if ((_elm_win_throttle_ok) && (!_elm_win_auto_throttled))
856                {
857                   _elm_process_state = ELM_PROCESS_STATE_BACKGROUND;
858                   ecore_event_add(ELM_EVENT_PROCESS_BACKGROUND, NULL, NULL, NULL);
859                   if (throttle)
860                     ecore_throttle_adjust(_elm_config->auto_throttle_amount);
861                   _elm_win_auto_throttled = EINA_TRUE;
862                }
863           }
864         else
865           {
866              if ((_elm_win_throttle_ok) && (_elm_win_auto_throttled))
867                {
868                   _elm_process_state = ELM_PROCESS_STATE_FOREGROUND;
869                   ecore_event_add(ELM_EVENT_PROCESS_FOREGROUND, NULL, NULL, NULL);
870                   if (throttle)
871                     ecore_throttle_adjust(-_elm_config->auto_throttle_amount);
872                   _elm_win_auto_throttled = EINA_FALSE;
873                }
874           }
875      }
876    _win_noblank_eval();
877 }
878
879 static Eina_Bool
880 _elm_win_policy_quit_triggered(Eo* triggering_obj)
881 {
882    if (elm_policy_get(ELM_POLICY_QUIT) == ELM_POLICY_QUIT_LAST_WINDOW_HIDDEN)
883      {
884         Eina_List *l;
885         Evas_Object *win;
886
887         EINA_LIST_FOREACH(_elm_win_list, l, win)
888           if (win != triggering_obj && evas_object_visible_get(win) == EINA_TRUE)
889             {
890                return EINA_FALSE;
891             }
892         return EINA_TRUE;
893      }
894
895    return EINA_FALSE;
896 }
897
898 static void
899 _elm_win_flush_cache_and_exit(Eo *obj)
900 {
901    edje_file_cache_flush();
902    edje_collection_cache_flush();
903    evas_image_cache_flush(evas_object_evas_get(obj));
904    evas_font_cache_flush(evas_object_evas_get(obj));
905    elm_exit();
906 }
907
908 static void
909 _elm_win_state_eval_queue(void)
910 {
911 /*TIZEN_ONLY(20171113):Use ecore_job instead of ecore_timer
912   if (_elm_win_state_eval_timer) ecore_timer_del(_elm_win_state_eval_timer);
913    _elm_win_state_eval_timer = ecore_timer_add(0.5, _elm_win_state_eval, NULL);
914 */
915    if (_elm_win_state_eval_job) ecore_job_del(_elm_win_state_eval_job);
916    _elm_win_state_eval_job = ecore_job_add(_elm_win_state_eval, NULL);
917 //
918 }
919
920 // example shot spec (wait 0.1 sec then save as my-window.png):
921 // ELM_ENGINE="shot:delay=0.1:file=my-window.png"
922
923 static double
924 _shot_delay_get(Efl_Ui_Win_Data *sd)
925 {
926    char *p, *pd;
927    char *d = strdup(sd->shot.info);
928
929    if (!d) return 0.5;
930    for (p = (char *)sd->shot.info; *p; p++)
931      {
932         if (!strncmp(p, "delay=", 6))
933           {
934              double v;
935
936              for (pd = d, p += 6; (*p) && (*p != ':'); p++, pd++)
937                {
938                   *pd = *p;
939                }
940              *pd = 0;
941              v = _elm_atof(d);
942              free(d);
943              return v;
944           }
945      }
946    free(d);
947
948    return 0.5;
949 }
950
951 static char *
952 _shot_file_get(Efl_Ui_Win_Data *sd)
953 {
954    char *p;
955    char *tmp = strdup(sd->shot.info);
956    char *repname = NULL;
957
958    if (!tmp) return NULL;
959
960    for (p = (char *)sd->shot.info; *p; p++)
961      {
962         if (!strncmp(p, "file=", 5))
963           {
964              strcpy(tmp, p + 5);
965              if (!sd->shot.repeat_count) return tmp;
966              else
967                {
968                   char *dotptr = strrchr(tmp, '.');
969                   if (dotptr)
970                     {
971                        size_t size = sizeof(char) * (strlen(tmp) + 16);
972                        repname = malloc(size);
973                        if (repname)
974                          {
975                             strncpy(repname, tmp, dotptr - tmp);
976                             snprintf(repname + (dotptr - tmp), size -
977                                      (dotptr - tmp), "%03i",
978                                      sd->shot.shot_counter + 1);
979                             strcat(repname, dotptr);
980                          }
981                        free(tmp);
982                        return repname;
983                     }
984                }
985           }
986      }
987    free(tmp);
988    if (!sd->shot.repeat_count) return strdup("out.png");
989
990    repname = malloc(sizeof(char) * 24);
991    if (!repname) return NULL;
992    snprintf(repname, sizeof(char) * 24, "out%03i.png",
993             sd->shot.shot_counter + 1);
994
995    return repname;
996 }
997
998 static int
999 _shot_repeat_count_get(Efl_Ui_Win_Data *sd)
1000 {
1001    char *p, *pd;
1002    char *d = strdup(sd->shot.info);
1003
1004    if (!d) return 0;
1005    for (p = (char *)sd->shot.info; *p; p++)
1006      {
1007         if (!strncmp(p, "repeat=", 7))
1008           {
1009              int v;
1010
1011              for (pd = d, p += 7; (*p) && (*p != ':'); p++, pd++)
1012                {
1013                   *pd = *p;
1014                }
1015              *pd = 0;
1016              v = atoi(d);
1017              if (v < 0) v = 0;
1018              if (v > 1000) v = 999;
1019              free(d);
1020              return v;
1021           }
1022      }
1023    free(d);
1024
1025    return 0;
1026 }
1027
1028 static char *
1029 _shot_key_get(Efl_Ui_Win_Data *sd EINA_UNUSED)
1030 {
1031    return NULL;
1032 }
1033
1034 static char *
1035 _shot_flags_get(Efl_Ui_Win_Data *sd EINA_UNUSED)
1036 {
1037    return NULL;
1038 }
1039
1040 static void
1041 _shot_do(Efl_Ui_Win_Data *sd)
1042 {
1043    Ecore_Evas *ee;
1044    Evas_Object *o;
1045    unsigned int *pixels;
1046    int w, h;
1047    char *file, *key, *flags;
1048
1049    ecore_evas_manual_render(sd->ee);
1050    pixels = (void *)ecore_evas_buffer_pixels_get(sd->ee);
1051    if (!pixels) return;
1052
1053    ecore_evas_geometry_get(sd->ee, NULL, NULL, &w, &h);
1054    if ((w < 1) || (h < 1)) return;
1055
1056    file = _shot_file_get(sd);
1057    if (!file) return;
1058
1059    key = _shot_key_get(sd);
1060    flags = _shot_flags_get(sd);
1061    ee = ecore_evas_buffer_new(1, 1);
1062    o = evas_object_image_add(ecore_evas_get(ee));
1063    evas_object_image_alpha_set(o,
1064                                sd->theme_alpha | sd->application_alpha);
1065    evas_object_image_size_set(o, w, h);
1066    evas_object_image_data_set(o, pixels);
1067    if (!evas_object_image_save(o, file, key, flags))
1068      {
1069         ERR("Cannot save window to '%s' (key '%s', flags '%s')",
1070             file, key, flags);
1071      }
1072    free(file);
1073    free(key);
1074    free(flags);
1075    ecore_evas_free(ee);
1076    if (sd->shot.repeat_count) sd->shot.shot_counter++;
1077 }
1078
1079 static Eina_Bool
1080 _shot_delay(void *data)
1081 {
1082    ELM_WIN_DATA_GET(data, sd);
1083
1084    _shot_do(sd);
1085    if (sd->shot.repeat_count)
1086      {
1087         int remainshot = (sd->shot.repeat_count - sd->shot.shot_counter);
1088         if (remainshot > 0) return EINA_TRUE;
1089      }
1090    sd->shot.timer = NULL;
1091    elm_exit();
1092
1093    return EINA_FALSE;
1094 }
1095
1096 static void
1097 _shot_init(Efl_Ui_Win_Data *sd)
1098 {
1099    if (!sd->shot.info) return;
1100
1101    sd->shot.repeat_count = _shot_repeat_count_get(sd);
1102    sd->shot.shot_counter = 0;
1103 }
1104
1105 static void
1106 _shot_handle(Efl_Ui_Win_Data *sd)
1107 {
1108    if (!sd->shot.info) return;
1109
1110    if (!sd->shot.timer)
1111      sd->shot.timer = ecore_timer_add(_shot_delay_get(sd), _shot_delay,
1112                                       sd->obj);
1113 }
1114
1115 /* elm-win specific associate, does the trap while ecore_evas_object_associate()
1116  * does not.
1117  */
1118 static Efl_Ui_Win_Data *
1119 _elm_win_associate_get(const Ecore_Evas *ee)
1120 {
1121    Evas_Object *obj = ecore_evas_data_get(ee, "elm_win");
1122    return efl_data_scope_safe_get(obj, MY_CLASS);
1123 }
1124
1125 /* Interceptors Callbacks */
1126 static void
1127 _elm_win_obj_intercept_raise(void *data, Evas_Object *obj EINA_UNUSED)
1128 {
1129    // Note: This is probably not necessary anymore (Win implements raise)
1130    ELM_WIN_DATA_GET(data, sd);
1131    TRAP(sd, raise);
1132 }
1133
1134 static void
1135 _elm_win_obj_intercept_lower(void *data, Evas_Object *obj EINA_UNUSED)
1136 {
1137    // Note: This is probably not necessary anymore (Win ignores lower)
1138    ELM_WIN_DATA_GET(data, sd);
1139    TRAP(sd, lower);
1140 }
1141
1142 static void
1143 _elm_win_obj_intercept_stack_above(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, Evas_Object *above EINA_UNUSED)
1144 {
1145    INF("TODO: %s", __func__);
1146 }
1147
1148 static void
1149 _elm_win_obj_intercept_stack_below(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, Evas_Object *below EINA_UNUSED)
1150 {
1151    INF("TODO: %s", __func__);
1152 }
1153
1154 static void
1155 _elm_win_obj_intercept_layer_set(void *data, Evas_Object *obj EINA_UNUSED, int l)
1156 {
1157    ELM_WIN_DATA_GET(data, sd);
1158    TRAP(sd, layer_set, l);
1159 }
1160
1161 /* Event Callbacks */
1162
1163 static void
1164 _elm_win_size_hints_update(Efl_Ui_Win *win, Efl_Ui_Win_Data *sd)
1165 {
1166    Eina_Size2D min, max;
1167
1168    min = efl_gfx_hint_size_combined_min_get(win);
1169    max = efl_gfx_hint_size_combined_max_get(win);
1170    if (max.w < 1) max.w = -1;
1171    if (max.h < 1) max.h = -1;
1172    /*TIZEN_ONLY(20221111): Disable automatic size_min/max_set.
1173    TRAP(sd, size_min_set, min.w, min.h);
1174    TRAP(sd, size_max_set, max.w, max.h);
1175    */
1176 }
1177
1178 static void
1179 _elm_win_obj_callback_changed_size_hints(void *data EINA_UNUSED, Evas *e EINA_UNUSED,
1180                                          Evas_Object *obj, void *event_info EINA_UNUSED)
1181 {
1182    ELM_WIN_DATA_GET(obj, sd);
1183
1184    if (sd->tmp_updating_hints) return;
1185    _elm_win_size_hints_update(obj, sd);
1186 }
1187 /* end of elm-win specific associate */
1188
1189 static void
1190 _elm_win_move(Ecore_Evas *ee)
1191 {
1192    Efl_Ui_Win_Data *sd = _elm_win_associate_get(ee);
1193    int x, y;
1194    Eo *obj;
1195    Eina_Position2D pos;
1196
1197    if (!sd) return;
1198    obj = sd->obj;
1199
1200    ecore_evas_geometry_get(ee, &x, &y, NULL, NULL);
1201    pos.x = sd->screen.x = x;
1202    pos.y = sd->screen.y = y;
1203    efl_event_callback_call(sd->obj, EFL_GFX_ENTITY_EVENT_POSITION_CHANGED, &pos);
1204    evas_object_smart_callback_call(sd->obj, "move", NULL);
1205    ELM_WIN_DATA_ALIVE_CHECK(obj, sd);
1206    evas_nochange_push(evas_object_evas_get(sd->obj));
1207    sd->response++;
1208    sd->req_xy = EINA_FALSE;
1209    evas_object_move(sd->obj, x, y);
1210    ELM_WIN_DATA_ALIVE_CHECK(obj, sd);
1211    sd->response--;
1212    evas_nochange_pop(evas_object_evas_get(sd->obj));
1213 }
1214
1215 static void
1216 _elm_win_resize_job(void *data)
1217 {
1218    ELM_WIN_DATA_GET(data, sd);
1219    int w, h;
1220
1221    sd->deferred_resize_job = EINA_FALSE;
1222    ecore_evas_geometry_get(sd->ee, NULL, NULL, &w, &h);
1223    if (sd->constrain)
1224      {
1225         int sw, sh;
1226         ecore_evas_screen_geometry_get(sd->ee, NULL, NULL, &sw, &sh);
1227         w = MIN(w, sw);
1228         h = MIN(h, sh);
1229      }
1230
1231    if (sd->frame_obj)
1232      {
1233         int fx, fy, fw, fh;
1234
1235         evas_output_framespace_get(sd->evas, &fx, &fy, &fw, &fh);
1236         evas_object_geometry_set(sd->frame_obj, -fx, -fy, w + fw, h + fh);
1237      }
1238
1239    if (sd->main_menu)
1240      {
1241         Eina_Position2D pos;
1242
1243         pos = efl_gfx_entity_position_get(sd->main_menu);
1244         elm_menu_move(sd->main_menu, pos.x, pos.y);
1245      }
1246
1247    sd->response++;
1248    sd->req_wh = EINA_FALSE;
1249    evas_object_resize(sd->obj, w, h);
1250    evas_object_resize(sd->legacy.edje, w, h);
1251    sd->response--;
1252 }
1253
1254 static void
1255 _elm_win_pre_render(Ecore_Evas *ee)
1256 {
1257    Efl_Ui_Win_Data *sd = _elm_win_associate_get(ee);
1258    Eo *obj;
1259
1260    if (!sd) return;
1261    obj = sd->obj;
1262
1263    _elm_win_throttle_ok = EINA_TRUE;
1264    if (!sd->first_draw)
1265      {
1266         int mw, mh;
1267
1268         if (sd->type != EFL_UI_WIN_TYPE_FAKE)
1269           {
1270              edje_object_thaw(sd->frame_obj);
1271              evas_object_show(sd->frame_obj);
1272           }
1273
1274         _elm_win_frame_style_update(sd, 1, 1);
1275         ELM_WIN_DATA_ALIVE_CHECK(obj, sd);
1276
1277         if (sd->frame_obj)
1278           {
1279              /* force initial sizing on frame to enable sizing of content */
1280              edje_object_size_min_calc(sd->frame_obj, &mw, &mh);
1281              evas_object_resize(sd->frame_obj, mw, mh);
1282           }
1283
1284         if (sd->img_obj)
1285           {
1286              evas_object_show(sd->img_obj);
1287           }
1288         if (sd->pointer.obj) evas_object_show(sd->pointer.obj);
1289 #ifdef ELEMENTARY_X
1290         if (sd->type == ELM_WIN_TOOLTIP)
1291           {
1292              _internal_elm_win_xwindow_get(sd);
1293              ecore_x_window_shape_input_rectangle_set(sd->x.xwin, 0, 0, 0, 0);
1294           }
1295 #endif
1296         sd->first_draw = EINA_TRUE;
1297         /* set this to handle ecore-evas engine code which incorrectly
1298          * assumes that a client resize call is the same as a server resize
1299          * event, or which has no server event
1300          */
1301         sd->deferred_resize_job = EINA_TRUE;
1302      }
1303    if (sd->deferred_resize_job)
1304      {
1305         _elm_win_resize_job(sd->obj);
1306         _elm_win_frame_obj_update(sd, 1);
1307      }
1308 }
1309
1310 static void
1311 _elm_win_resize(Ecore_Evas *ee)
1312 {
1313    Efl_Ui_Win_Data *sd = _elm_win_associate_get(ee);
1314    if (!sd) return;
1315
1316    sd->deferred_resize_job = EINA_TRUE;
1317 }
1318
1319 static void
1320 _elm_win_mouse_in(Ecore_Evas *ee)
1321 {
1322    Efl_Ui_Win_Data *sd = _elm_win_associate_get(ee);
1323    if (!sd) return;
1324
1325    _elm_win_throttle_ok = EINA_TRUE;
1326    sd->resizing = EINA_FALSE;
1327 #ifdef HAVE_ELEMENTARY_WL2
1328    if ((sd->wl.win) && (sd->pointer.ee))
1329      {
1330         sd->pointer.visible = EINA_TRUE;
1331         sd->pointer.surf = ecore_wl2_window_surface_get(sd->pointer.win);
1332         _elm_win_wl_cursor_set(sd->obj, NULL);
1333         //ELM_WIN_DATA_ALIVE_CHECK(obj, sd);
1334      }
1335 #endif
1336 }
1337
1338 static void
1339 _elm_win_mouse_out(Ecore_Evas *ee)
1340 {
1341    Efl_Ui_Win_Data *sd = _elm_win_associate_get(ee);
1342    if (!sd) return;
1343
1344 #ifdef HAVE_ELEMENTARY_WL2
1345    if ((sd->wl.win) && (sd->pointer.ee))
1346      sd->pointer.visible = EINA_FALSE;
1347 #endif
1348 }
1349
1350 static void
1351 _elm_win_focus_highlight_reconfigure_job_stop(Efl_Ui_Win_Data *sd)
1352 {
1353    ELM_SAFE_FREE(sd->focus_highlight.reconf_job, ecore_job_del);
1354 }
1355
1356 // TIZEN_ONLY(20171114) Accessibility Highlight Frame added
1357 static void
1358 _elm_win_accessibility_highlight_visible_set(Efl_Ui_Win_Data *sd,
1359                                      Eina_Bool visible)
1360 {
1361    Evas_Object *fobj = sd->accessibility_highlight.fobj;
1362
1363    if (!fobj)
1364      return;
1365
1366    if (visible)
1367      {
1368         evas_object_show(fobj);
1369      }
1370    else
1371      {
1372         evas_object_smart_member_del(fobj);
1373         evas_object_hide(fobj);
1374         evas_object_del(fobj);
1375      }
1376 }
1377 //
1378
1379 static void
1380 _elm_win_focus_highlight_visible_set(Efl_Ui_Win_Data *sd,
1381                                      Eina_Bool visible)
1382 {
1383    Evas_Object *fobj = sd->focus_highlight.fobj;
1384    if (!fobj) return;
1385
1386    if (visible)
1387      {
1388         evas_object_show(fobj);
1389         if (elm_widget_is_legacy(sd->obj))
1390           edje_object_signal_emit(fobj, "elm,action,focus,show", "elm");
1391         else
1392           edje_object_signal_emit(fobj, "efl,focus,visible,on", "efl");
1393      }
1394    else
1395      {
1396         if (elm_widget_is_legacy(sd->obj))
1397           edje_object_signal_emit(fobj, "elm,action,focus,hide", "elm");
1398         else
1399           edje_object_signal_emit(fobj, "efl,focus,visible,off", "efl");
1400      }
1401 }
1402
1403 Evas_Object *
1404 _elm_win_focus_highlight_object_get(Evas_Object *obj)
1405 {
1406    ELM_WIN_DATA_GET(obj, sd);
1407
1408    return sd->focus_highlight.fobj;
1409 }
1410
1411 static void
1412 _elm_win_focus_highlight_anim_setup(Efl_Ui_Win_Data *sd,
1413                                     Evas_Object *obj)
1414 {
1415    Eina_Rect rt, rp;
1416    Edje_Message_Int_Set *m;
1417    Evas_Object *target = sd->focus_highlight.cur.target;
1418
1419    rp = efl_gfx_entity_geometry_get(obj);
1420    rt = elm_widget_focus_highlight_geometry_get(target);
1421    efl_gfx_entity_geometry_set(obj, rt);
1422
1423    if (eina_rectangle_equal(&rp.rect, &rt.rect)) return;
1424
1425    if (!_elm_config->focus_highlight_clip_disable)
1426      evas_object_clip_unset(obj);
1427
1428    m = alloca(sizeof(*m) + (sizeof(int) * 8));
1429    m->count = 8;
1430    m->val[0] = rp.x - rt.x;
1431    m->val[1] = rp.y - rt.y;
1432    m->val[2] = rp.w;
1433    m->val[3] = rp.h;
1434    m->val[4] = 0;
1435    m->val[5] = 0;
1436    m->val[6] = rt.w;
1437    m->val[7] = rt.h;
1438    edje_object_message_send(obj, EDJE_MESSAGE_INT_SET, 1, m);
1439 }
1440 // TIZEN_ONLY(20180326) : Atspi: enhance finding next and prev item on screen's edge
1441 EAPI Eina_Bool
1442 _elm_win_accessibility_parent_is_item(Evas_Object *obj)
1443 {
1444    Evas_Object *parent;
1445    parent = efl_provider_find(efl_parent_get(obj), EFL_ACCESS_OBJECT_MIXIN);
1446    while (parent)
1447      {
1448         if (efl_isa(parent, ELM_WIDGET_ITEM_CLASS)) return EINA_TRUE;
1449         parent = efl_provider_find(efl_parent_get(parent), EFL_ACCESS_OBJECT_MIXIN);
1450      }
1451    return EINA_FALSE;
1452 }
1453 //
1454 // TIZEN_ONLY(20171114) Accessibility Highlight Frame added
1455 static void
1456 _elm_win_accessibility_highlight_simple_setup(Efl_Ui_Win_Data *sd,
1457                                       Evas_Object *obj)
1458 {
1459    // TIZEN_ONLY(20171117) Accessibility frame follows parent item on scroll event
1460    // Evas_Object *target = sd->accessibility_highlight.cur.target;
1461    Evas_Object *target = sd->accessibility_highlight.cur.target;
1462    //
1463    Evas_Coord x, y, w, h;
1464    //TIZEN_ONLY(20160623): atspi: moved highlight when object is out of screen
1465    Evas_Coord ox, oy;
1466    Efl_Access_Role role;
1467    //
1468
1469    _elm_widget_showing_geometry_get(target, &x, &y, &w, &h);
1470
1471    //TIZEN_ONLY(20160623): atspi: moved highlight when object is out of screen
1472    evas_object_geometry_get(target, &ox, &oy, NULL, NULL);
1473    //TIZEN_ONLY(20171011) : atspi : During the highlight grab, out signal is not sent.
1474    if (!_elm_widget_accessibility_highlight_grabbing_get(target))
1475    //
1476      {
1477         if (((w < 0 && ox > sd->accessibility_highlight.cur.x) || (h < 0 && oy < sd->accessibility_highlight.cur.y))
1478            && sd->accessibility_highlight.cur.need_moved
1479            && efl_isa(target, EFL_ACCESS_OBJECT_MIXIN))
1480           {
1481              role = efl_access_object_role_get(target);
1482              if (role && role != EFL_ACCESS_ROLE_MENU_ITEM && role != EFL_ACCESS_ROLE_LIST_ITEM
1483                  // TIZEN_ONLY(20180326) : Atspi: enhance finding next and prev item on screen's edge
1484                  && ! _elm_win_accessibility_parent_is_item(target))
1485                  //
1486                {
1487                   efl_access_move_outed_signal_emit(target, EFL_ACCESS_MOVE_OUTED_TOP_LEFT);
1488                   sd->accessibility_highlight.cur.need_moved = EINA_FALSE;
1489                   return;
1490                }
1491           }
1492         else if (((w < 0 && ox < sd->accessibility_highlight.cur.x) || (h < 0 && oy > sd->accessibility_highlight.cur.y))
1493             && sd->accessibility_highlight.cur.need_moved
1494             && efl_isa(target, EFL_ACCESS_OBJECT_MIXIN))
1495           {
1496              role = efl_access_object_role_get(target);
1497              if (role && role != EFL_ACCESS_ROLE_MENU_ITEM && role != EFL_ACCESS_ROLE_LIST_ITEM
1498                 // TIZEN_ONLY(20180326) : Atspi: enhance finding next and prev item on screen's edge
1499                 && ! _elm_win_accessibility_parent_is_item(target))
1500                 //
1501                {
1502                   efl_access_move_outed_signal_emit(target, EFL_ACCESS_MOVE_OUTED_BOTTOM_RIGHT);
1503                   sd->accessibility_highlight.cur.need_moved = EINA_FALSE;
1504                   return ;
1505                }
1506           }
1507      }
1508    //
1509
1510    evas_object_move(obj, x, y);
1511    evas_object_resize(obj, w, h);
1512
1513    //TIZEN_ONLY(20160623): atspi: moved highlight when object is out of screen
1514    sd->accessibility_highlight.cur.x = ox;
1515    sd->accessibility_highlight.cur.y = oy;
1516    //
1517
1518    evas_object_smart_member_add(obj, target);
1519 }
1520 //
1521
1522 static void
1523 _elm_win_focus_highlight_simple_setup(Efl_Ui_Win_Data *sd,
1524                                       Evas_Object *obj)
1525 {
1526    Evas_Object *clip, *target = sd->focus_highlight.cur.target;
1527
1528    efl_gfx_entity_geometry_set(obj, elm_widget_focus_highlight_geometry_get(target));
1529
1530    if (!_elm_config->focus_highlight_clip_disable)
1531      {
1532         clip = evas_object_clip_get(target);
1533         if (clip) evas_object_clip_set(obj, clip);
1534      }
1535
1536    if (elm_widget_is_legacy(sd->obj))
1537      edje_object_signal_emit(obj, "elm,state,anim,stop", "elm");
1538    else
1539      edje_object_signal_emit(obj, "efl,state,animating,stopped", "efl");
1540 }
1541
1542 static void
1543 _elm_win_focus_prev_target_del(void *data,
1544                                Evas *e EINA_UNUSED,
1545                                Evas_Object *obj EINA_UNUSED,
1546                                void *event_info EINA_UNUSED)
1547 {
1548    ELM_WIN_DATA_GET(data, sd);
1549    sd->focus_highlight.prev.target = NULL;
1550 }
1551
1552 // TIZEN_ONLY(20171114) Accessibility Highlight Frame added
1553 static void
1554 _elm_win_accessibility_highlight_hide(void *data)
1555 {
1556    ELM_WIN_DATA_GET(data, sd);
1557    _elm_win_accessibility_highlight_visible_set(sd, EINA_FALSE);
1558 }
1559
1560 static void
1561 _elm_win_accessibility_highlight_show(void *data)
1562 {
1563    ELM_WIN_DATA_GET(data, sd);
1564    Evas_Object *fobj = sd->accessibility_highlight.fobj;
1565    elm_widget_theme_object_set (sd->obj, fobj, "accessibility_highlight", "top", "default");
1566    evas_object_raise(fobj);
1567    _elm_win_accessibility_highlight_simple_setup(sd, fobj);
1568    _elm_win_accessibility_highlight_visible_set(sd, EINA_TRUE);
1569 }
1570 //
1571
1572 static void
1573 _elm_win_focus_highlight_reconfigure_job(void *data)
1574 {
1575    ELM_WIN_DATA_GET(data, sd);
1576    Evas_Object *target = sd->focus_highlight.cur.target;
1577    Evas_Object *previous = sd->focus_highlight.prev.target;
1578    Evas_Object *fobj = sd->focus_highlight.fobj;
1579    Eina_Bool visible_changed;
1580    Eina_Bool common_visible;
1581    const char *sig = NULL;
1582
1583    _elm_win_focus_highlight_reconfigure_job_stop(sd);
1584
1585    visible_changed = (sd->focus_highlight.cur.visible !=
1586                       sd->focus_highlight.prev.visible);
1587
1588    if ((target == previous) && (!visible_changed) &&
1589        (!sd->focus_highlight.geometry_changed) &&
1590        (!sd->focus_highlight.theme_changed))
1591      return;
1592
1593    if (previous)
1594      {
1595         evas_object_event_callback_del_full
1596            (previous, EVAS_CALLBACK_DEL, _elm_win_focus_prev_target_del, data);
1597         if (sd->focus_highlight.prev.in_theme)
1598           {
1599              if (elm_widget_is_legacy(sd->obj))
1600                elm_widget_signal_emit
1601                   (previous, "elm,action,focus_highlight,hide", "elm");
1602              else
1603                elm_widget_signal_emit
1604                   (previous, "efl,action,focus_highlight,hide", "efl");
1605           }
1606      }
1607
1608    if (!target)
1609      common_visible = EINA_FALSE;
1610    else if (sd->focus_highlight.cur.in_theme)
1611      {
1612         common_visible = EINA_FALSE;
1613
1614         if (elm_widget_is_legacy(sd->obj))
1615           {
1616              if (sd->focus_highlight.cur.visible)
1617                sig = "elm,action,focus_highlight,show";
1618              else
1619                sig = "elm,action,focus_highlight,hide";
1620           }
1621         else
1622           {
1623              if (sd->focus_highlight.cur.visible)
1624                sig = "efl,action,focus_highlight,show";
1625              else
1626                sig = "efl,action,focus_highlight,hide";
1627           }
1628      }
1629    else
1630      common_visible = sd->focus_highlight.cur.visible;
1631
1632    if (sig)
1633      {
1634         if (elm_widget_is_legacy(sd->obj))
1635           elm_widget_signal_emit(target, sig, "elm");
1636         else
1637           elm_widget_signal_emit(target, sig, "efl");
1638      }
1639
1640    if ((!target) || (!common_visible) || (sd->focus_highlight.cur.in_theme))
1641      {
1642         if (target)
1643           _elm_win_focus_highlight_simple_setup(sd, fobj);
1644         goto the_end;
1645      }
1646
1647    if (sd->focus_highlight.theme_changed)
1648      {
1649         const char *str;
1650
1651        if (sd->focus_highlight.style)
1652           str = sd->focus_highlight.style;
1653         else
1654           str = "default";
1655
1656         elm_widget_theme_object_set
1657           (sd->obj, fobj, "focus_highlight", "top", str);
1658         sd->focus_highlight.theme_changed = EINA_FALSE;
1659
1660         if ((sd->focus_highlight.animate) || (sd->focus_highlight.auto_animate))
1661           {
1662              str = edje_object_data_get(sd->focus_highlight.fobj, "animate");
1663              sd->focus_highlight.animate_supported = ((str) && (!strcmp(str, "on")));
1664           }
1665         else
1666           sd->focus_highlight.animate_supported = EINA_FALSE;
1667      }
1668
1669    if ((sd->focus_highlight.animate_supported) && (previous) &&
1670        (!sd->focus_highlight.prev.in_theme))
1671      _elm_win_focus_highlight_anim_setup(sd, fobj);
1672    else
1673      _elm_win_focus_highlight_simple_setup(sd, fobj);
1674    evas_object_raise(fobj);
1675
1676 the_end:
1677    _elm_win_focus_highlight_visible_set(sd, common_visible);
1678    sd->focus_highlight.geometry_changed = EINA_FALSE;
1679    sd->focus_highlight.prev = sd->focus_highlight.cur;
1680    if (sd->focus_highlight.prev.target)
1681      {
1682         evas_object_event_callback_add
1683               (sd->focus_highlight.prev.target,
1684                EVAS_CALLBACK_DEL, _elm_win_focus_prev_target_del, data);
1685      }
1686 }
1687
1688 static void
1689 _elm_win_focus_highlight_reconfigure_job_start(Efl_Ui_Win_Data *sd)
1690 {
1691    ecore_job_del(sd->focus_highlight.reconf_job);
1692
1693    sd->focus_highlight.reconf_job = ecore_job_add(
1694        _elm_win_focus_highlight_reconfigure_job, sd->obj);
1695 }
1696
1697 static void
1698 _elm_win_focus_in(Ecore_Evas *ee)
1699 {
1700    Efl_Ui_Win_Data *sd = _elm_win_associate_get(ee);
1701    Evas_Object *obj;
1702
1703    if ((!sd) || (sd->modal_count)) return;
1704
1705    _elm_win_throttle_ok = EINA_TRUE;
1706    obj = sd->obj;
1707
1708    _elm_widget_top_win_focused_set(obj, EINA_TRUE);
1709    ELM_WIN_DATA_ALIVE_CHECK(obj, sd);
1710    if (sd->type != EFL_UI_WIN_TYPE_FAKE)
1711      {
1712         /* TIZEN_ONLY(20180607): Restore legacy focus
1713         Efl_Ui_Focus_Manager *man = sd->obj;
1714         while(efl_ui_focus_manager_redirect_get(man))
1715           {
1716              man = efl_ui_focus_manager_redirect_get(man);
1717           }
1718
1719         Evas_Object *focused = efl_ui_focus_manager_focus_get(man);
1720         if (focused)
1721           efl_ui_focus_object_focus_set(focused, EINA_TRUE);
1722         */
1723         if (!efl_ui_widget_focus_order_get(obj))
1724           {
1725              efl_ui_widget_focus_steal(obj, NULL);
1726           }
1727         else
1728           {
1729              Evas_Object *newest = NULL;
1730              unsigned int newest_focus_order = 0;
1731
1732              newest = efl_ui_widget_newest_focus_order_get
1733                 (obj, &newest_focus_order, EINA_TRUE);
1734              if (newest) efl_ui_widget_focus_restore(obj);
1735              else
1736                evas_object_focus_set(obj, EINA_TRUE);
1737           }
1738         //
1739      }
1740
1741    evas_object_smart_callback_call(obj, SIG_FOCUS_IN, NULL);
1742    //TIZEN_ONLY(20180607): Restore legacy focus
1743    //evas_object_smart_callback_call(obj, SIG_WIDGET_FOCUSED, NULL);
1744    //
1745    ELM_WIN_DATA_ALIVE_CHECK(obj, sd);
1746    sd->focus_highlight.cur.visible = EINA_TRUE;
1747    _elm_win_focus_highlight_reconfigure_job_start(sd);
1748    _elm_win_frame_style_update(sd, 0, 1);
1749
1750    //TIZEN_ONLY(20210608): make plug and socket window work
1751    /* elm_plug: do not send activate signal if window is socket window.
1752       The socket window is embedded in another window. if AT-client works
1753       with activated embedded window directly, it will lost chance to work
1754       with embedding window. ex: "1 finger double tap and hold" makes the
1755       embedded window get focus when embedded window has highlight object,
1756       then "1 finger tap" will interact with the embedded window even though
1757       the "1 finger tap" occurs on embedding window */
1758    if (_elm_atspi_enabled() && sd->type != EFL_UI_WIN_TYPE_SOCKET_IMAGE)
1759    //
1760      {
1761         efl_access_window_activated_signal_emit(obj);
1762         efl_access_state_changed_signal_emit(obj, EFL_ACCESS_STATE_TYPE_ACTIVE, EINA_TRUE);
1763      }
1764
1765    /* do nothing */
1766    /* else if (sd->img_obj) */
1767    /*   { */
1768    /*   } */
1769    /* TIZEN_ONLY(20180607): Restore legacy focus
1770    if ((!efl_ui_focus_manager_focus_get(sd->obj)) &&
1771        (!efl_ui_focus_manager_redirect_get(sd->obj)))
1772      {
1773         Efl_Ui_Focus_Object *child;
1774
1775         child = efl_ui_focus_manager_request_subchild(sd->obj, sd->obj);
1776
1777         if (child)
1778           efl_ui_focus_manager_focus_set(sd->obj, sd->obj);
1779         else  if (!evas_focus_get(evas_object_evas_get(sd->obj)))
1780           evas_object_focus_set(obj, EINA_TRUE);
1781      }
1782    */
1783 }
1784
1785 static void
1786 _elm_win_focus_out(Ecore_Evas *ee)
1787 {
1788    Efl_Ui_Win_Data *sd = _elm_win_associate_get(ee);
1789    Evas_Object *obj;
1790
1791    if (!sd) return;
1792
1793    obj = sd->obj;
1794
1795    _elm_widget_top_win_focused_set(obj, EINA_FALSE);
1796    ELM_WIN_DATA_ALIVE_CHECK(obj, sd);
1797    evas_object_smart_callback_call(obj, SIG_FOCUS_OUT, NULL);
1798    //TIZEN_ONLY(20180607): Restore legacy focus
1799    //evas_object_smart_callback_call(obj, SIG_WIDGET_UNFOCUSED, NULL);
1800    //
1801    ELM_WIN_DATA_ALIVE_CHECK(obj, sd);
1802    sd->focus_highlight.cur.visible = EINA_FALSE;
1803    _elm_win_focus_highlight_reconfigure_job_start(sd);
1804    if (!sd->resizing)
1805      _elm_win_frame_style_update(sd, 0, 1);
1806
1807    /* access */
1808    _elm_access_object_highlight_disable(evas_object_evas_get(obj));
1809
1810    //TIZEN_ONLY(20210608): make plug and socket window work
1811    /* elm_plug: do not send deactivate signal if window is socket window.
1812       The socket window is embedded in another window. if AT-client works
1813       with activated embedded window directly, it will lost chance to work
1814       with embedding window. ex: "1 finger double tap and hold" makes the
1815       embedded window get focus when embedded window has highlight object,
1816       then "1 finger tap" will interact with the embedded window even though
1817       the "1 finger tap" occurs on embedding window */
1818    if (_elm_atspi_enabled() && sd->type != EFL_UI_WIN_TYPE_SOCKET_IMAGE)
1819    //
1820      {
1821         efl_access_window_deactivated_signal_emit(obj);
1822         efl_access_state_changed_signal_emit(obj, EFL_ACCESS_STATE_TYPE_ACTIVE, EINA_FALSE);
1823      }
1824
1825    /*TIZEN_ONLY(20180607): Restore legacy focus
1826    if (sd->type != EFL_UI_WIN_TYPE_FAKE)
1827      {
1828         Efl_Ui_Focus_Manager *man = sd->obj;
1829         while(efl_ui_focus_manager_redirect_get(man))
1830           {
1831              man = efl_ui_focus_manager_redirect_get(man);
1832           }
1833
1834         Evas_Object *focused = efl_ui_focus_manager_focus_get(man);
1835         efl_ui_focus_object_focus_set(focused, EINA_FALSE);
1836      }
1837    */
1838    /* do nothing */
1839    /* if (sd->img_obj) */
1840    /*   { */
1841    /*   } */
1842 }
1843
1844 static void
1845 _elm_win_available_profiles_del(Efl_Ui_Win_Data *sd)
1846 {
1847    Eina_Stringshare *prof;
1848    Eina_Iterator *it;
1849
1850    it = eina_array_iterator_new(sd->profile.available);
1851    EINA_ITERATOR_FOREACH(it, prof)
1852      eina_stringshare_del(prof);
1853    eina_iterator_free(it);
1854    eina_array_flush(sd->profile.available);
1855 }
1856
1857 static void
1858 _elm_win_profile_del(Efl_Ui_Win_Data *sd)
1859 {
1860    ELM_SAFE_FREE(sd->profile.name, eina_stringshare_del);
1861 }
1862
1863 static Eina_Bool
1864 _internal_elm_win_profile_set(Efl_Ui_Win_Data *sd, const char *profile)
1865 {
1866    Eina_Bool changed = EINA_FALSE;
1867
1868    if (profile == sd->profile.name) return EINA_FALSE;
1869    if (profile)
1870      {
1871         if (eina_stringshare_replace(&sd->profile.name, profile))
1872           changed = EINA_TRUE;
1873      }
1874    else
1875      _elm_win_profile_del(sd);
1876
1877    return changed;
1878 }
1879
1880 static inline Eina_Bool
1881 _profile_exists(Efl_Ui_Win_Data *sd, const char *profile)
1882 {
1883    Eina_Bool found = EINA_FALSE;
1884    Eina_Stringshare *prof;
1885    Eina_Iterator *it;
1886
1887    if (!profile) return EINA_FALSE;
1888    it = eina_array_iterator_new(sd->profile.available);
1889    EINA_ITERATOR_FOREACH(it, prof)
1890      if (!strcmp(profile, prof))
1891        {
1892           found = EINA_TRUE;
1893           break;
1894        }
1895    eina_iterator_free(it);
1896    return found;
1897 }
1898
1899 static void
1900 _elm_win_profile_update(Efl_Ui_Win_Data *sd)
1901 {
1902    if (getenv("ELM_PROFILE")) return;
1903
1904    if (eina_array_count(sd->profile.available))
1905      {
1906         Eina_Bool found = _profile_exists(sd, sd->profile.name);
1907
1908         /* If current profile is not present in an available profiles,
1909          * change current profile to the 1st element of an array.
1910          */
1911         if (!found)
1912           _internal_elm_win_profile_set(sd, eina_array_data_get(sd->profile.available, 0));
1913      }
1914
1915    _config_profile_lock = EINA_TRUE;
1916    _elm_config_profile_set(sd->profile.name);
1917
1918    /* update sub ee */
1919    Ecore_Evas *ee2;
1920    Eina_List *sub, *l = NULL;
1921
1922    sub = ecore_evas_sub_ecore_evas_list_get(sd->ee);
1923    EINA_LIST_FOREACH(sub, l, ee2)
1924      ecore_evas_window_profile_set(ee2, sd->profile.name);
1925
1926    efl_event_callback_legacy_call(sd->obj, EFL_UI_WIN_EVENT_PROFILE_CHANGED, NULL);
1927 }
1928
1929 static inline void
1930 _elm_win_frame_geometry_adjust(Efl_Ui_Win_Data *sd)
1931 {
1932    int l = 0, t = 0, r = 0, b = 0;
1933
1934    if (sd->frame_obj && sd->csd.need && !sd->fullscreen)
1935      {
1936         int fw, fh, ox, oy, ow, oh;
1937         evas_object_geometry_get(sd->frame_obj, NULL, NULL, &fw, &fh);
1938         if (elm_widget_is_legacy(sd->obj))
1939           edje_object_part_geometry_get(sd->frame_obj, "elm.spacer.opaque",
1940                                         &ox, &oy, &ow, &oh);
1941         else
1942           edje_object_part_geometry_get(sd->frame_obj, "efl.spacer.opaque",
1943                                         &ox, &oy, &ow, &oh);
1944         l = ox;
1945         t = oy;
1946         r = fw - ow - l;
1947         b = fh - oh - t;
1948      }
1949    ecore_evas_shadow_geometry_set(sd->ee, l, r, t, b);
1950 }
1951
1952 static inline Eina_Bool
1953 _elm_win_framespace_set(Efl_Ui_Win_Data *sd, int x, int y, int w, int h)
1954 {
1955    int fx, fy, fw, fh;
1956
1957    evas_output_framespace_get(sd->evas, &fx, &fy, &fw, &fh);
1958    evas_output_framespace_set(sd->evas, x, y, w, h);
1959
1960    // return true if framespace geometry changed
1961    return ((fx != x) || (fy != y) || (fw != w) || (fh != h));
1962 }
1963
1964 static void
1965 _elm_win_frame_obj_update(Efl_Ui_Win_Data *sd, Eina_Bool force)
1966 {
1967    int ox, oy, ow, oh;
1968    int cx, cy, cw, ch;
1969    int w, h;
1970
1971    if (!sd->frame_obj) return;
1972    if (!sd->csd.need) return;
1973    _elm_win_frame_geometry_adjust(sd);
1974    evas_object_geometry_get(sd->frame_obj, &ox, &oy, &ow, &oh);
1975    if (elm_widget_is_legacy(sd->obj))
1976      edje_object_part_geometry_get(sd->frame_obj, "elm.spacer.content", &cx, &cy, &cw, &ch);
1977    else
1978      edje_object_part_geometry_get(sd->frame_obj, "efl.spacer.content", &cx, &cy, &cw, &ch);
1979
1980    if (!_elm_win_framespace_set(sd, cx, cy, ow - cw, oh - ch) && (!force)) return;
1981    _elm_win_frame_geometry_adjust(sd);
1982
1983    if (!sd->first_draw) return;
1984
1985    evas_object_geometry_get(sd->obj, NULL, NULL, &w, &h);
1986    if (w && h)
1987      {
1988         TRAP(sd, resize, w, h);
1989      }
1990 }
1991
1992 static int
1993 _win_rotation_degree_check(int rotation)
1994 {
1995    if ((rotation > 360) || (rotation < 0))
1996      {
1997         WRN("Rotation degree should be 0 ~ 360 (passed degree: %d)", rotation);
1998         rotation %= 360;
1999         if (rotation < 0) rotation += 360;
2000      }
2001    return rotation;
2002 }
2003
2004 /*
2005  * This API resizes the internal window(ex: X window) and evas_output.
2006  * But this does not resize the elm window object and its contents.
2007  */
2008 static void
2009 _win_rotate(Evas_Object *obj, Efl_Ui_Win_Data *sd, int rotation, Eina_Bool resize)
2010 {
2011    rotation = _win_rotation_degree_check(rotation);
2012    if (sd->rot == rotation) return;
2013    sd->rot = rotation;
2014    if (resize) TRAP(sd, rotation_with_resize_set, rotation);
2015    else TRAP(sd, rotation_set, rotation);
2016    efl_gfx_hint_size_restricted_min_set(obj, EINA_SIZE2D(-1, -1));
2017    efl_gfx_hint_size_restricted_max_set(obj, EINA_SIZE2D(-1, -1));
2018    _elm_win_resize_objects_eval(obj, EINA_FALSE);
2019 #ifdef HAVE_ELEMENTARY_X
2020    _elm_win_xwin_update(sd);
2021 #endif
2022    _elm_win_frame_obj_update(sd, 0);
2023    efl_event_callback_call
2024      (obj, EFL_UI_WIN_EVENT_WIN_ROTATION_CHANGED, &rotation);
2025    evas_object_smart_callback_call(obj, "rotation,changed", NULL);
2026    if (_elm_config->atspi_mode)
2027      {
2028         Evas_Coord x = 0, y = 0, width = 0, height = 0;
2029         elm_win_screen_size_get(obj, &x, &y, &width, &height);
2030         if ((sd->rot == 0) || (sd->rot == 180))
2031           {
2032              efl_access_bounds_changed_signal_emit(obj, x, y, width, height);
2033           }
2034         else
2035           {
2036              efl_access_bounds_changed_signal_emit(obj, x, y, height, width);
2037           }
2038      }
2039 }
2040
2041 EOLIAN static void
2042 _efl_ui_win_win_rotation_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *pd, int rotation)
2043 {
2044    Efl_Ui_Widget *widget;
2045    Eina_Iterator *it;
2046    int rot = rotation %360;
2047
2048    if (pd->rot == rot) return;
2049
2050    _win_rotate(obj, pd, rot, EINA_FALSE);
2051
2052    it = efl_ui_widget_tree_widget_iterator(obj);
2053    EINA_ITERATOR_FOREACH(it, widget)
2054      {
2055         if (!efl_isa(widget, EFL_UI_LAYOUT_BASE_CLASS)) continue;
2056
2057         if (efl_ui_layout_automatic_theme_rotation_get(widget))
2058           efl_ui_layout_theme_rotation_apply(widget, rot);
2059      }
2060 }
2061
2062 EOLIAN static int
2063 _efl_ui_win_win_rotation_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *pd)
2064 {
2065    return pd->rot;
2066 }
2067
2068 EAPI void
2069 elm_win_rotation_set(Evas_Object *obj, int rotation)
2070 {
2071    efl_ui_win_rotation_set(obj, rotation);
2072 }
2073
2074 EAPI int
2075 elm_win_rotation_get(const Evas_Object *obj)
2076 {
2077    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, -1);
2078    return efl_ui_win_rotation_get(obj);
2079 }
2080
2081 static void
2082 _elm_win_state_change(Ecore_Evas *ee)
2083 {
2084    Efl_Ui_Win_Data *sd = _elm_win_associate_get(ee);
2085    Evas_Object *obj;
2086    int w, h;
2087    Eina_Bool ch_withdrawn = EINA_FALSE;
2088    Eina_Bool ch_sticky = EINA_FALSE;
2089    Eina_Bool ch_minimized = EINA_FALSE;
2090    Eina_Bool ch_fullscreen = EINA_FALSE;
2091    Eina_Bool ch_maximized = EINA_FALSE;
2092    Eina_Bool ch_profile = EINA_FALSE;
2093    Eina_Bool ch_wm_rotation = EINA_FALSE;
2094 // TIZEN_ONLY(20150707): elm_conform for wayland, and signal if parts are changed
2095    Eina_Bool ch_conformant  = EINA_FALSE;
2096    Eina_Bool ch_visibility = EINA_FALSE;
2097    Eina_Bool ch_aux_hint = EINA_FALSE;
2098    Eina_List *aux_hints = NULL;
2099 //
2100 //
2101 #ifdef HAVE_ELEMENTARY_WL2
2102    Efl_Ui_Win_Conformant_Property property = EFL_UI_WIN_CONFORMANT_PROPERTY_DEFAULT; //TIZEN_ONLY(20160330): add processing properties of window
2103 #endif
2104
2105    const char *profile;
2106
2107    if (!sd) return;
2108
2109    obj = sd->obj;
2110
2111    if (sd->withdrawn != ecore_evas_withdrawn_get(sd->ee))
2112      {
2113         sd->withdrawn = ecore_evas_withdrawn_get(sd->ee);
2114         ch_withdrawn = EINA_TRUE;
2115      }
2116    if (sd->sticky != ecore_evas_sticky_get(sd->ee))
2117      {
2118         sd->sticky = ecore_evas_sticky_get(sd->ee);
2119         ch_sticky = EINA_TRUE;
2120      }
2121    if (sd->minimized != ecore_evas_iconified_get(sd->ee))
2122      {
2123         sd->minimized = ecore_evas_iconified_get(sd->ee);
2124         ch_minimized = EINA_TRUE;
2125      }
2126    if (sd->fullscreen != ecore_evas_fullscreen_get(sd->ee))
2127      {
2128         sd->fullscreen = ecore_evas_fullscreen_get(sd->ee);
2129         ch_fullscreen = EINA_TRUE;
2130      }
2131    if (sd->maximized != ecore_evas_maximized_get(sd->ee))
2132      {
2133         sd->maximized = ecore_evas_maximized_get(sd->ee);
2134         ch_maximized = EINA_TRUE;
2135      }
2136
2137    if (ecore_evas_window_profile_supported_get(sd->ee))
2138      {
2139         profile = ecore_evas_window_profile_get(sd->ee);
2140         ch_profile = _internal_elm_win_profile_set(sd, profile);
2141      }
2142
2143    ELM_WIN_DATA_ALIVE_CHECK(obj, sd);
2144    if (sd->wm_rot.use)
2145      {
2146         if (sd->rot != ecore_evas_rotation_get(sd->ee))
2147           {
2148              ch_wm_rotation = EINA_TRUE;
2149           }
2150      }
2151
2152    // TIZEN_ONLY(20160120): support visibility_change event
2153    if (sd->obscured != ecore_evas_obscured_get(sd->ee))
2154      {
2155         sd->obscured = ecore_evas_obscured_get(sd->ee);
2156         ch_visibility = EINA_TRUE;
2157      }
2158    //
2159    // TIZEN_ONLY(20150722): added signal for aux_hint(auxiliary hint)
2160    aux_hints = ecore_evas_aux_hints_allowed_get(sd->ee);
2161    if (aux_hints)
2162      {
2163         ch_aux_hint = EINA_TRUE;
2164      }
2165    //
2166    // TIZEN_ONLY(20150707): elm_conform for wayland, and signal if parts are changed
2167 #ifdef HAVE_ELEMENTARY_WL2
2168    int x = 0, y = 0;
2169    if (sd->legacy.indmode != (Elm_Win_Indicator_Mode)ecore_wl2_window_indicator_state_get(sd->wl.win))
2170      {
2171         sd->legacy.indmode = (Elm_Win_Indicator_Mode)ecore_wl2_window_indicator_state_get(sd->wl.win);
2172         ch_conformant = EINA_TRUE;
2173         property |= EFL_UI_WIN_CONFORMANT_PROPERTY_INDICATOR_STATE; //TIZEN_ONLY(20160330): add processing properties of window
2174      }
2175    if (sd->kbdmode != (Efl_Ui_Win_Keyboard_Mode)ecore_wl2_window_keyboard_state_get(sd->wl.win))
2176      {
2177         sd->kbdmode = (Efl_Ui_Win_Keyboard_Mode)ecore_wl2_window_keyboard_state_get(sd->wl.win);
2178         ch_conformant = EINA_TRUE;
2179         property |= EFL_UI_WIN_CONFORMANT_PROPERTY_KEYBOARD_STATE; //TIZEN_ONLY(20160330): add processing properties of window
2180
2181      }
2182    if (ecore_wl2_window_indicator_geometry_get(sd->wl.win, &x, &y, &w, &h))
2183      {
2184         if ((sd->ind.x != x) || (sd->ind.y != y) || (sd->ind.w != w) || (sd->ind.h != h))
2185           {
2186              sd->ind.x = x;
2187              sd->ind.y = y;
2188              sd->ind.w = w;
2189              sd->ind.h = h;
2190              ch_conformant  = EINA_TRUE;
2191              property |= EFL_UI_WIN_CONFORMANT_PROPERTY_INDICATOR_GEOMETRY; //TIZEN_ONLY(20160330): add processing properties of window
2192           }
2193      }
2194    if (ecore_wl2_window_keyboard_geometry_get(sd->wl.win, &x, &y, &w, &h))
2195      {
2196         if ((sd->kbd.x != x) || (sd->kbd.y != y) || (sd->kbd.w != w) || (sd->kbd.h != h))
2197           {
2198              sd->kbd.x = x;
2199              sd->kbd.y = y;
2200              sd->kbd.w = w;
2201              sd->kbd.h = h;
2202              ch_conformant  = EINA_TRUE;
2203              property |= EFL_UI_WIN_CONFORMANT_PROPERTY_KEYBOARD_GEOMETRY; //TIZEN_ONLY(20160330): add processing properties of window
2204           }
2205      }
2206 #endif
2207    // END of TIZEN_ONLY(20150707)
2208    _elm_win_state_eval_queue();
2209
2210    if ((ch_withdrawn) || (ch_minimized))
2211      {
2212         ELM_WIN_DATA_ALIVE_CHECK(obj, sd);
2213         if (sd->withdrawn)
2214           efl_event_callback_legacy_call(obj, EFL_UI_WIN_EVENT_WITHDRAWN, NULL);
2215         else if (sd->minimized)
2216           {
2217              efl_event_callback_call(obj, EFL_UI_WIN_EVENT_MINIMIZED, NULL);
2218              evas_object_smart_callback_call(obj, "iconified", NULL);
2219              if (_elm_atspi_enabled())
2220                efl_access_window_minimized_signal_emit(obj);
2221           }
2222         else
2223           {
2224              efl_event_callback_legacy_call(obj, EFL_UI_WIN_EVENT_NORMAL, NULL);
2225              if (_elm_atspi_enabled())
2226                efl_access_window_restored_signal_emit(obj);
2227           }
2228
2229         //TIZEN_ONLY(20200122): add minimized,changed event to avoid name conflict in bindings
2230         if (ch_minimized)
2231           {
2232              Eina_Bool minimized = sd->minimized;
2233              efl_event_callback_call(obj, EFL_UI_WIN_EVENT_MINIMIZED_CHANGED, &minimized);
2234           }
2235         //
2236      }
2237    if (ch_sticky)
2238      {
2239         if (sd->sticky)
2240           efl_event_callback_legacy_call(obj, EFL_UI_WIN_EVENT_STICK, NULL);
2241         else
2242           efl_event_callback_legacy_call(obj, EFL_UI_WIN_EVENT_UNSTICK, NULL);
2243      }
2244 #ifdef HAVE_ELEMENTARY_WL2
2245    if (sd->wl.win)
2246      {
2247         if (sd->csd.cur_focus != ecore_wl2_window_activated_get(sd->wl.win))
2248           _elm_win_frame_style_update(sd, 0, 1);
2249      }
2250 #endif
2251    if (ch_fullscreen)
2252      {
2253         Eina_Bool fullscreen;
2254         ELM_WIN_DATA_ALIVE_CHECK(obj, sd);
2255         _elm_win_frame_style_update(sd, 0, 1);
2256         fullscreen = sd->fullscreen;
2257         if (sd->fullscreen)
2258           {
2259              evas_object_smart_callback_call(obj, "fullscreen", NULL);
2260           }
2261         else
2262           {
2263              evas_object_smart_callback_call(obj, "unfullscreen", NULL);
2264           }
2265         efl_event_callback_call(obj, EFL_UI_WIN_EVENT_FULLSCREEN_CHANGED, &fullscreen);
2266      }
2267    if (ch_maximized)
2268      {
2269         Eina_Bool maximized;
2270         ELM_WIN_DATA_ALIVE_CHECK(obj, sd);
2271         _elm_win_frame_style_update(sd, 0, 1);
2272         maximized = sd->maximized;
2273         if (sd->maximized)
2274           {
2275              evas_object_smart_callback_call(obj, "maximized", NULL);
2276              if (_elm_atspi_enabled())
2277                efl_access_window_maximized_signal_emit(obj);
2278           }
2279         else
2280           {
2281              evas_object_smart_callback_call(obj, "unmaximized", NULL);
2282              if (_elm_atspi_enabled())
2283                efl_access_window_restored_signal_emit(obj);
2284           }
2285         efl_event_callback_call(obj, EFL_UI_WIN_EVENT_MAXIMIZED_CHANGED, &maximized);
2286      }
2287    if (ch_profile)
2288      {
2289         ELM_WIN_DATA_ALIVE_CHECK(obj, sd);
2290         _elm_win_profile_update(sd);
2291      }
2292    if (ch_wm_rotation)
2293      {
2294 //TIZEN_ONLY(20170912)
2295         /* if there are deferred resize job, do the job immediately
2296             before calling rotation change callback */
2297         if (sd->deferred_resize_job)
2298           _elm_win_resize_job(obj);
2299 //
2300         efl_ui_win_rotation_set(obj, ecore_evas_rotation_get(sd->ee));
2301
2302         efl_event_callback_legacy_call
2303           (obj, EFL_UI_WIN_EVENT_WM_ROTATION_CHANGED, NULL);
2304      }
2305
2306    // TIZEN_ONLY(20150707): elm_conform for wayland, and signal if parts are changed
2307    if (ch_conformant)
2308      {
2309 #ifdef HAVE_ELEMENTARY_WL2
2310         evas_object_smart_callback_call(obj, SIG_CONFORMANT_CHANGED, (void *)property); //TIZEN_ONLY(20160330): add processing properties of window
2311 #else
2312         evas_object_smart_callback_call(obj, SIG_CONFORMANT_CHANGED, NULL);
2313 #endif
2314      }
2315    //
2316    // TIZEN_ONLY(20150722): added signal for aux_hint(auxiliary hint)
2317    if (ch_aux_hint)
2318      {
2319         void *id;
2320         Eina_List *l;
2321         EINA_LIST_FOREACH(aux_hints, l, id)
2322           {
2323              evas_object_smart_callback_call(obj, SIG_AUX_HINT_ALLOWED, id);
2324           }
2325         eina_list_free(aux_hints);
2326      }
2327    //
2328    // TIZEN_ONLY(20160120): support visibility_change event
2329    if (ch_visibility)
2330      {
2331         evas_object_smart_callback_call(obj, SIG_VISIBILITY_CHANGED, (void*)!sd->obscured);
2332         //TIZEN_ONLY(20160701): add atspi window state visible change signal
2333         if (_elm_atspi_enabled())
2334           efl_access_state_changed_signal_emit(obj, EFL_ACCESS_STATE_TYPE_VISIBLE, !sd->obscured);
2335         //
2336      }
2337    //
2338 }
2339
2340 // TIZEN_ONLY(20160404)  skip_focus in case invoking elm_win_quickpanel_set
2341 static void
2342 _elm_win_focus_skip_set(Efl_Ui_Win_Data *sd, Eina_Bool skip)
2343 {
2344    if (!sd) return;
2345    sd->skip_focus = skip;
2346    TRAP(sd, focus_skip_set, skip);
2347 }
2348 //
2349
2350 //TIZEN_ONLY(20180607): Restore legacy focus
2351 EOLIAN static Eina_Bool
2352 _efl_ui_win_efl_ui_widget_focus_next_manager_is(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *_pd EINA_UNUSED)
2353 {
2354    return EINA_TRUE;
2355 }
2356
2357 EOLIAN static Eina_Bool
2358 _efl_ui_win_efl_ui_widget_focus_next(Eo *obj, Efl_Ui_Win_Data *_pd EINA_UNUSED, Efl_Ui_Focus_Direction dir, Evas_Object **next, Elm_Object_Item **next_item)
2359 {
2360    ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
2361
2362    const Eina_List *items;
2363    void *(*list_data_get)(const Eina_List *list);
2364
2365    /* Focus chain */
2366    if (wd->children)
2367      {
2368         if (!(items = efl_ui_widget_focus_custom_chain_get(obj)))
2369           {
2370              for (unsigned int i = 0; i < eina_array_count(wd->children); ++i)
2371                items = eina_list_append((Eina_List *)items, eina_array_data_get(wd->children, i));
2372              if (!items)
2373                return EINA_FALSE;
2374           }
2375         list_data_get = eina_list_data_get;
2376
2377         efl_ui_widget_focus_list_next_get(obj, items, list_data_get, dir, next, next_item);
2378
2379         if (*next) return EINA_TRUE;
2380      }
2381    *next = (Evas_Object *)obj;
2382    return EINA_FALSE;
2383 }
2384
2385 EOLIAN static Eina_Bool
2386 _efl_ui_win_efl_ui_widget_focus_direction_manager_is(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *_pd EINA_UNUSED)
2387 {
2388    return EINA_TRUE;
2389 }
2390
2391 EOLIAN static Eina_Bool
2392 _efl_ui_win_efl_ui_widget_focus_direction(Eo *obj, Efl_Ui_Win_Data *_pd EINA_UNUSED, const Evas_Object *base, double degree, Evas_Object **direction, Elm_Object_Item **direction_item, double *weight)
2393 {
2394    const Eina_List *items;
2395    void *(*list_data_get)(const Eina_List *list);
2396
2397    ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
2398
2399    /* Focus chain */
2400    if (wd->children)
2401      {
2402         if (!(items = efl_ui_widget_focus_custom_chain_get(obj)))
2403           {
2404              for (unsigned int i = 0; i < eina_array_count(wd->children); ++i)
2405                items = eina_list_append((Eina_List *)items, eina_array_data_get(wd->children, i));
2406           }
2407
2408         list_data_get = eina_list_data_get;
2409
2410         return efl_ui_widget_focus_list_direction_get
2411                  (obj, base, items, list_data_get, degree, direction, direction_item, weight);
2412      }
2413
2414    return EINA_FALSE;
2415 }
2416 //
2417
2418 EOLIAN static Eina_Bool
2419 _efl_ui_win_efl_ui_focus_object_on_focus_update(Eo *obj, Efl_Ui_Win_Data *sd)
2420 {
2421    if (!efl_ui_focus_object_on_focus_update(efl_super(obj, MY_CLASS)))
2422      return EINA_TRUE;
2423
2424    if (sd->img_obj)
2425      evas_object_focus_set(sd->img_obj, efl_ui_focus_object_focus_get(obj));
2426    else
2427      evas_object_focus_set(obj, efl_ui_focus_object_focus_get(obj));
2428
2429    return EINA_TRUE;
2430 }
2431
2432 static Eina_Bool
2433 _key_action_return(Evas_Object *obj EINA_UNUSED, const char *params EINA_UNUSED)
2434 {
2435    return EINA_FALSE;
2436 }
2437
2438 static Eina_Bool
2439 _key_action_move(Evas_Object *obj, const char *params)
2440 {
2441    const char *dir = params;
2442
2443    _elm_widget_focus_auto_show(obj);
2444
2445    Efl_Ui_Focus_Direction focus_dir;
2446
2447    if (!strcmp(dir, "previous"))
2448      focus_dir = EFL_UI_FOCUS_DIRECTION_PREVIOUS;
2449    else if (!strcmp(dir, "next"))
2450      focus_dir = EFL_UI_FOCUS_DIRECTION_NEXT;
2451    else if (!strcmp(dir, "left"))
2452      focus_dir = EFL_UI_FOCUS_DIRECTION_LEFT;
2453    else if (!strcmp(dir, "right"))
2454      focus_dir = EFL_UI_FOCUS_DIRECTION_RIGHT;
2455    else if (!strcmp(dir, "up"))
2456      focus_dir = EFL_UI_FOCUS_DIRECTION_UP;
2457    else if (!strcmp(dir, "down"))
2458      focus_dir = EFL_UI_FOCUS_DIRECTION_DOWN;
2459    else return EINA_FALSE;
2460
2461    //TIZEN_ONLY(20180607): Restore legacy focus
2462    efl_ui_widget_focus_cycle(obj, focus_dir);
2463    /*
2464   // The handling for legacy is different due to elm_object_next set
2465   if (elm_widget_is_legacy(obj))
2466     elm_object_focus_next(obj, (Elm_Focus_Direction)focus_dir);
2467   else
2468     {
2469        Efl_Ui_Widget *o;
2470
2471        o = efl_ui_focus_manager_move(obj, focus_dir);
2472        if (!o)
2473          {
2474             if (focus_dir == EFL_UI_FOCUS_DIRECTION_NEXT || focus_dir == EFL_UI_FOCUS_DIRECTION_PREVIOUS)
2475               {
2476                  Efl_Ui_Focus_Object *root;
2477
2478                  root = efl_ui_focus_manager_root_get(obj);
2479                  efl_ui_focus_manager_setup_on_first_touch(obj, focus_dir, root);
2480               }
2481          }
2482     }
2483    */
2484    return EINA_TRUE;
2485 }
2486
2487 /* forward events sent to evas to the window */
2488 static void
2489 _evas_event_key_cb(void *data, const Efl_Event *ev)
2490 {
2491    Eo *win = data;
2492    Eo *evt = ev->info;
2493    Efl_Input_Key_Data *evdata;
2494
2495    evdata = efl_data_scope_get(evt, EFL_INPUT_KEY_CLASS);
2496    if (!evdata || evdata->win_fed)
2497      return;
2498
2499    // evas_callbacks will send the event to the focused object (ie. this win)
2500    if (evas_focus_get(evas_object_evas_get(win)) == win)
2501      return;
2502
2503    efl_event_callback_call(win, ev->desc, evt);
2504 }
2505
2506 static void
2507 _evas_event_pointer_cb(void *data, const Efl_Event *ev)
2508 {
2509    Eo *win = data;
2510    Eo *evt = ev->info;
2511    Efl_Input_Pointer_Data *evdata;
2512
2513    evdata = efl_data_scope_get(evt, EFL_INPUT_POINTER_CLASS);
2514    if (!evdata || evdata->win_fed)
2515      return;
2516
2517    efl_event_callback_call(win, ev->desc, evt);
2518 }
2519
2520 /* feed events from the window to evas - for fake inputs */
2521 static void
2522 _evas_event_key_feed_fake_cb(void *data, const Efl_Event *ev)
2523 {
2524    Eo *evas = data;
2525    Efl_Input_Event *evt = ev->info;
2526    Efl_Input_Key_Data *evdata;
2527
2528    if (!efl_input_fake_get(evt))
2529      return;
2530
2531    evdata = efl_data_scope_get(evt, EFL_INPUT_KEY_CLASS);
2532    if (!evdata || evdata->win_fed)
2533      return;
2534    evdata->win_fed = EINA_TRUE;
2535
2536    efl_event_callback_call(evas, ev->desc, evt);
2537    evdata->win_fed = EINA_FALSE;
2538    evdata->evas_done = EINA_FALSE;
2539 }
2540
2541 static void
2542 _evas_event_pointer_feed_fake_cb(void *data, const Efl_Event *ev)
2543 {
2544    Eo *evas = data;
2545    Efl_Input_Event *evt = ev->info;
2546    Efl_Input_Pointer_Data *evdata;
2547
2548    if (!efl_input_fake_get(evt))
2549      return;
2550
2551    evdata = efl_data_scope_get(evt, EFL_INPUT_POINTER_CLASS);
2552    if (!evdata || evdata->win_fed)
2553      return;
2554    evdata->win_fed = EINA_TRUE;
2555
2556    efl_event_callback_call(evas, ev->desc, evt);
2557    evdata->win_fed = EINA_FALSE;
2558    evdata->evas_done = EINA_FALSE;
2559 }
2560
2561 EFL_CALLBACKS_ARRAY_DEFINE(_elm_win_evas_feed_fake_callbacks,
2562 { EFL_EVENT_POINTER_MOVE, _evas_event_pointer_feed_fake_cb },
2563 { EFL_EVENT_POINTER_DOWN, _evas_event_pointer_feed_fake_cb },
2564 { EFL_EVENT_POINTER_UP, _evas_event_pointer_feed_fake_cb },
2565 { EFL_EVENT_POINTER_IN, _evas_event_pointer_feed_fake_cb },
2566 { EFL_EVENT_POINTER_OUT, _evas_event_pointer_feed_fake_cb },
2567 { EFL_EVENT_POINTER_CANCEL, _evas_event_pointer_feed_fake_cb },
2568 { EFL_EVENT_POINTER_WHEEL, _evas_event_pointer_feed_fake_cb },
2569 { EFL_EVENT_FINGER_MOVE, _evas_event_pointer_feed_fake_cb },
2570 { EFL_EVENT_FINGER_DOWN, _evas_event_pointer_feed_fake_cb },
2571 { EFL_EVENT_FINGER_UP, _evas_event_pointer_feed_fake_cb },
2572 { EFL_EVENT_KEY_DOWN, _evas_event_key_feed_fake_cb },
2573 { EFL_EVENT_KEY_UP, _evas_event_key_feed_fake_cb })
2574
2575 static void
2576 _elm_win_evas_render_post(void *data,
2577                           Evas *e EINA_UNUSED,
2578                           void *event_info)
2579 {
2580    Efl_Gfx_Event_Render_Post *ev = event_info;
2581    Eo *win = data;
2582
2583    efl_event_callback_call(win, EFL_CANVAS_SCENE_EVENT_RENDER_POST, ev);
2584 }
2585
2586 static void
2587 _elm_win_evas_render_pre(void *data,
2588                           Evas *e EINA_UNUSED,
2589                           void *event_info EINA_UNUSED)
2590 {
2591    Eo *win = data;
2592
2593    _elm_win_throttle_ok = EINA_TRUE;
2594    efl_event_callback_call(win, EFL_CANVAS_SCENE_EVENT_RENDER_PRE, NULL);
2595 }
2596
2597 static void
2598 _elm_win_evas_focus_in(void *data,
2599                        Evas *e EINA_UNUSED,
2600                        void *event_info EINA_UNUSED)
2601 {
2602    Eo *win = data;
2603
2604    _elm_win_throttle_ok = EINA_TRUE;
2605    efl_event_callback_call(win, EFL_CANVAS_SCENE_EVENT_SCENE_FOCUS_IN, NULL);
2606 }
2607
2608 static void
2609 _elm_win_evas_focus_out(void *data,
2610                         Evas *e EINA_UNUSED,
2611                         void *event_info EINA_UNUSED)
2612 {
2613    Eo *win = data;
2614
2615    efl_event_callback_call(win, EFL_CANVAS_SCENE_EVENT_SCENE_FOCUS_OUT, NULL);
2616 }
2617
2618 static void
2619 _evas_event_focus_object_cb(void *data, const Efl_Event *ev)
2620 {
2621    Eo *win = data;
2622
2623    if (ev->desc == EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_IN)
2624      _elm_win_throttle_ok = EINA_TRUE;
2625
2626    efl_event_callback_call(win, ev->desc, ev->info);
2627 }
2628
2629 static void
2630 _elm_win_evas_device_changed(void *data,
2631                              Evas *e EINA_UNUSED,
2632                              void *event_info)
2633 {
2634    Eo *device = event_info;
2635    Eo *win = data;
2636
2637    efl_event_callback_call(win, EFL_CANVAS_SCENE_EVENT_DEVICE_CHANGED, device);
2638 }
2639
2640 static void
2641 _win_event_add_cb(void *data, const Efl_Event *ev)
2642 {
2643    const Efl_Callback_Array_Item_Full *array = ev->info;
2644    Efl_Ui_Win_Data *sd = data;
2645    Efl_Ui_Win *win = ev->object;
2646    int i;
2647
2648    for (i = 0; array[i].desc; i++)
2649      {
2650         if (array[i].desc == EFL_EVENT_POINTER_MOVE)
2651           {
2652              if (!(sd->event_forward.pointer_move++))
2653                efl_event_callback_add(sd->evas, array[i].desc,
2654                                      _evas_event_pointer_cb, win);
2655           }
2656         else if (array[i].desc == EFL_EVENT_POINTER_DOWN)
2657           {
2658              if (!(sd->event_forward.pointer_down++))
2659                efl_event_callback_add(sd->evas, array[i].desc,
2660                                      _evas_event_pointer_cb, win);
2661           }
2662         else if (array[i].desc == EFL_EVENT_POINTER_UP)
2663           {
2664              if (!(sd->event_forward.pointer_up++))
2665                efl_event_callback_add(sd->evas, array[i].desc,
2666                                      _evas_event_pointer_cb, win);
2667           }
2668         else if (array[i].desc == EFL_EVENT_POINTER_IN)
2669           {
2670              if (!(sd->event_forward.pointer_in++))
2671                efl_event_callback_add(sd->evas, array[i].desc,
2672                                      _evas_event_pointer_cb, win);
2673           }
2674         else if (array[i].desc == EFL_EVENT_POINTER_OUT)
2675           {
2676              if (!(sd->event_forward.pointer_out++))
2677                efl_event_callback_add(sd->evas, array[i].desc,
2678                                      _evas_event_pointer_cb, win);
2679           }
2680         else if (array[i].desc == EFL_EVENT_POINTER_CANCEL)
2681           {
2682              if (!(sd->event_forward.pointer_cancel++))
2683                efl_event_callback_add(sd->evas, array[i].desc,
2684                                      _evas_event_pointer_cb, win);
2685           }
2686         else if (array[i].desc == EFL_EVENT_POINTER_WHEEL)
2687           {
2688              if (!(sd->event_forward.pointer_wheel++))
2689                efl_event_callback_add(sd->evas, array[i].desc,
2690                                      _evas_event_pointer_cb, win);
2691           }
2692         else if (array[i].desc == EFL_EVENT_FINGER_MOVE)
2693           {
2694              if (!(sd->event_forward.finger_move++))
2695                efl_event_callback_add(sd->evas, array[i].desc,
2696                                      _evas_event_pointer_cb, win);
2697           }
2698         else if (array[i].desc == EFL_EVENT_FINGER_DOWN)
2699           {
2700              if (!(sd->event_forward.finger_down++))
2701                efl_event_callback_add(sd->evas, array[i].desc,
2702                                      _evas_event_pointer_cb, win);
2703           }
2704         else if (array[i].desc == EFL_EVENT_FINGER_UP)
2705           {
2706              if (!(sd->event_forward.finger_up++))
2707                efl_event_callback_add(sd->evas, array[i].desc,
2708                                      _evas_event_pointer_cb, win);
2709           }
2710         else if (array[i].desc == EFL_EVENT_KEY_DOWN)
2711           {
2712              // Legacy API: Must grab key
2713              if (elm_widget_is_legacy(win)) return;
2714              if (!(sd->event_forward.key_down++))
2715                efl_event_callback_add(sd->evas, array[i].desc,
2716                                      _evas_event_key_cb, win);
2717           }
2718         else if (array[i].desc == EFL_EVENT_KEY_UP)
2719           {
2720              // Legacy API: Must grab key
2721              if (elm_widget_is_legacy(win)) return;
2722              if (!(sd->event_forward.key_up++))
2723                efl_event_callback_add(sd->evas, array[i].desc,
2724                                      _evas_event_key_cb, win);
2725           }
2726         else if (array[i].desc == EFL_CANVAS_SCENE_EVENT_RENDER_POST)
2727           {
2728              if (!(sd->event_forward.render_post++))
2729                evas_event_callback_add(sd->evas, EVAS_CALLBACK_RENDER_POST,
2730                                        _elm_win_evas_render_post, win);
2731           }
2732         else if (array[i].desc == EFL_CANVAS_SCENE_EVENT_RENDER_PRE)
2733           {
2734              if (!(sd->event_forward.render_pre++))
2735                evas_event_callback_add(sd->evas, EVAS_CALLBACK_RENDER_PRE,
2736                                        _elm_win_evas_render_pre, win);
2737           }
2738         else if (array[i].desc == EFL_CANVAS_SCENE_EVENT_SCENE_FOCUS_IN)
2739           {
2740              if (!(sd->event_forward.focus_in++))
2741                evas_event_callback_add(sd->evas, EVAS_CALLBACK_CANVAS_FOCUS_IN,
2742                                        _elm_win_evas_focus_in, win);
2743           }
2744         else if (array[i].desc == EFL_CANVAS_SCENE_EVENT_SCENE_FOCUS_OUT)
2745           {
2746              if (!(sd->event_forward.focus_out++))
2747                evas_event_callback_add(sd->evas, EVAS_CALLBACK_CANVAS_FOCUS_OUT,
2748                                        _elm_win_evas_focus_out, win);
2749           }
2750         else if (array[i].desc == EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_IN)
2751           {
2752              if (!(sd->event_forward.object_focus_in++))
2753                efl_event_callback_add(sd->evas, EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_IN,
2754                                        _evas_event_focus_object_cb, win);
2755           }
2756         else if (array[i].desc == EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_OUT)
2757           {
2758              if (!(sd->event_forward.object_focus_out++))
2759                efl_event_callback_add(sd->evas, EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_OUT,
2760                                        _evas_event_focus_object_cb, win);
2761           }
2762         else if (array[i].desc == EFL_CANVAS_SCENE_EVENT_DEVICE_CHANGED)
2763           {
2764              if (!(sd->event_forward.device_changed++))
2765                evas_event_callback_add(sd->evas, EVAS_CALLBACK_DEVICE_CHANGED,
2766                                        _elm_win_evas_device_changed, win);
2767           }
2768      }
2769 }
2770
2771 static void
2772 _win_event_del_cb(void *data, const Efl_Event *ev)
2773 {
2774    const Efl_Callback_Array_Item_Full *array = ev->info;
2775    Efl_Ui_Win_Data *sd = data;
2776    Efl_Ui_Win *win = ev->object;
2777    int i;
2778
2779    for (i = 0; array[i].desc; i++)
2780      {
2781         if (array[i].desc == EFL_EVENT_POINTER_MOVE)
2782           {
2783              if (!(--sd->event_forward.pointer_move))
2784                efl_event_callback_del(sd->evas, array[i].desc,
2785                                      _evas_event_pointer_cb, win);
2786           }
2787         else if (array[i].desc == EFL_EVENT_POINTER_DOWN)
2788           {
2789              if (!(--sd->event_forward.pointer_down))
2790                efl_event_callback_del(sd->evas, array[i].desc,
2791                                      _evas_event_pointer_cb, win);
2792           }
2793         else if (array[i].desc == EFL_EVENT_POINTER_UP)
2794           {
2795              if (!(--sd->event_forward.pointer_up))
2796                efl_event_callback_del(sd->evas, array[i].desc,
2797                                      _evas_event_pointer_cb, win);
2798           }
2799         else if (array[i].desc == EFL_EVENT_POINTER_IN)
2800           {
2801              if (!(--sd->event_forward.pointer_in))
2802                efl_event_callback_del(sd->evas, array[i].desc,
2803                                      _evas_event_pointer_cb, win);
2804           }
2805         else if (array[i].desc == EFL_EVENT_POINTER_OUT)
2806           {
2807              if (!(--sd->event_forward.pointer_out))
2808                efl_event_callback_del(sd->evas, array[i].desc,
2809                                      _evas_event_pointer_cb, win);
2810           }
2811         else if (array[i].desc == EFL_EVENT_POINTER_CANCEL)
2812           {
2813              if (!(--sd->event_forward.pointer_cancel))
2814                efl_event_callback_del(sd->evas, array[i].desc,
2815                                      _evas_event_pointer_cb, win);
2816           }
2817         else if (array[i].desc == EFL_EVENT_POINTER_WHEEL)
2818           {
2819              if (!(--sd->event_forward.pointer_wheel))
2820                efl_event_callback_del(sd->evas, array[i].desc,
2821                                      _evas_event_pointer_cb, win);
2822           }
2823         else if (array[i].desc == EFL_EVENT_FINGER_MOVE)
2824           {
2825              if (!(--sd->event_forward.finger_move))
2826                efl_event_callback_del(sd->evas, array[i].desc,
2827                                      _evas_event_pointer_cb, win);
2828           }
2829         else if (array[i].desc == EFL_EVENT_FINGER_DOWN)
2830           {
2831              if (!(--sd->event_forward.finger_down))
2832                efl_event_callback_del(sd->evas, array[i].desc,
2833                                      _evas_event_pointer_cb, win);
2834           }
2835         else if (array[i].desc == EFL_EVENT_FINGER_UP)
2836           {
2837              if (!(--sd->event_forward.finger_up))
2838                efl_event_callback_del(sd->evas, array[i].desc,
2839                                      _evas_event_pointer_cb, win);
2840           }
2841         else if (array[i].desc == EFL_EVENT_KEY_DOWN)
2842           {
2843              // Legacy API: Must grab key
2844              if (elm_widget_is_legacy(win)) return;
2845              if (!(--sd->event_forward.key_down))
2846                efl_event_callback_del(sd->evas, array[i].desc,
2847                                      _evas_event_key_cb, win);
2848           }
2849         else if (array[i].desc == EFL_EVENT_KEY_UP)
2850           {
2851              // Legacy API: Must grab key
2852              if (elm_widget_is_legacy(win)) return;
2853              if (!(--sd->event_forward.key_up))
2854                efl_event_callback_del(sd->evas, array[i].desc,
2855                                      _evas_event_key_cb, win);
2856           }
2857         else if (array[i].desc == EFL_CANVAS_SCENE_EVENT_RENDER_POST)
2858           {
2859              if (!(--sd->event_forward.render_post))
2860                evas_event_callback_del_full(sd->evas, EVAS_CALLBACK_RENDER_POST,
2861                                             _elm_win_evas_render_post, win);
2862           }
2863         else if (array[i].desc == EFL_CANVAS_SCENE_EVENT_RENDER_PRE)
2864           {
2865              if (!(--sd->event_forward.render_pre))
2866                evas_event_callback_del_full(sd->evas, EVAS_CALLBACK_RENDER_PRE,
2867                                             _elm_win_evas_render_pre, win);
2868           }
2869         else if (array[i].desc == EFL_CANVAS_SCENE_EVENT_SCENE_FOCUS_IN)
2870           {
2871              if (!(--sd->event_forward.focus_in))
2872                evas_event_callback_del_full(sd->evas, EVAS_CALLBACK_FOCUS_IN,
2873                                             _elm_win_evas_focus_in, win);
2874           }
2875         else if (array[i].desc == EFL_CANVAS_SCENE_EVENT_SCENE_FOCUS_OUT)
2876           {
2877              if (!(--sd->event_forward.focus_out))
2878                evas_event_callback_del_full(sd->evas, EVAS_CALLBACK_FOCUS_OUT,
2879                                             _elm_win_evas_focus_out, win);
2880           }
2881         else if (array[i].desc == EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_IN)
2882           {
2883              if (!(--sd->event_forward.object_focus_in))
2884                efl_event_callback_del(sd->evas, EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_IN,
2885                                             _evas_event_focus_object_cb, win);
2886           }
2887         else if (array[i].desc == EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_OUT)
2888           {
2889              if (!(--sd->event_forward.object_focus_out))
2890                efl_event_callback_del(sd->evas, EFL_CANVAS_SCENE_EVENT_OBJECT_FOCUS_OUT,
2891                                             _evas_event_focus_object_cb, win);
2892           }
2893         else if (array[i].desc == EFL_CANVAS_SCENE_EVENT_DEVICE_CHANGED)
2894           {
2895              if (!(--sd->event_forward.device_changed))
2896                evas_event_callback_del_full(sd->evas, EVAS_CALLBACK_DEVICE_CHANGED,
2897                                             _elm_win_evas_device_changed, win);
2898           }
2899      }
2900 }
2901
2902 static void
2903 _win_paused(void *data, const Efl_Event *ev)
2904 {
2905    Efl_Ui_Win_Data *sd = data;
2906
2907    if (sd->paused)
2908      {
2909         ERR("A window did receive a pause event while still paused. Dismissing.");
2910         return ;
2911      }
2912    sd->paused = EINA_TRUE;
2913    _paused_windows++;
2914
2915    if (_elm_win_count == _paused_windows)
2916      efl_event_callback_call(efl_loop_get(ev->object), EFL_APP_EVENT_PAUSE, NULL);
2917 }
2918
2919 EFL_CALLBACKS_ARRAY_DEFINE(_elm_win_tracking,
2920                            { EFL_EVENT_CALLBACK_ADD, _win_event_add_cb },
2921                            { EFL_EVENT_CALLBACK_DEL, _win_event_del_cb },
2922                            { EFL_UI_WIN_EVENT_PAUSE, _win_paused })
2923
2924 static void
2925 _elm_win_cb_mouse_up(void *data, const Efl_Event *ev EINA_UNUSED)
2926 {
2927    DBG("Evas mouse up event");
2928    /*Currently wayland server didn't send mouse up event after resize the window*/
2929    Efl_Ui_Win_Data *sd = data;
2930    if(sd->resizing) sd->resizing = EINA_FALSE;
2931 }
2932
2933 static void
2934 _elm_win_resume(void *data, const Efl_Event *ev)
2935 {
2936    Efl_Ui_Win_Data *sd = data;
2937
2938    if (!sd->paused) return ;
2939
2940    efl_event_callback_call(sd->obj, EFL_UI_WIN_EVENT_RESUME, NULL);
2941    sd->paused = EINA_FALSE;
2942
2943    if (_elm_win_count == _paused_windows)
2944      efl_event_callback_call(efl_loop_get(ev->object), EFL_APP_EVENT_RESUME, NULL);
2945
2946    _paused_windows--;
2947 }
2948
2949 EFL_CALLBACKS_ARRAY_DEFINE(_elm_evas_tracking,
2950                            { EFL_EVENT_POINTER_UP, _elm_win_cb_mouse_up },
2951                            { EFL_CANVAS_SCENE_EVENT_RENDER_PRE, _elm_win_resume })
2952
2953 static void
2954 _deferred_ecore_evas_free(void *data)
2955 {
2956    ecore_evas_free(data);
2957    _elm_win_deferred_free--;
2958 }
2959
2960 static inline Edje_Object *
2961 _elm_win_modal_blocker_edje_get(Efl_Ui_Win_Data *sd)
2962 {
2963    /* Legacy theme compatibility */
2964    const char *version = edje_object_data_get(sd->legacy.edje, "version");
2965    int v = version ? atoi(version) : 0;
2966    if (v < FRAME_OBJ_THEME_MIN_VERSION)
2967      {
2968         DBG("Detected legacy theme (<1.19) for modal window blocker.");
2969         return sd->legacy.edje;
2970      }
2971    return sd->frame_obj;
2972 }
2973
2974 static void
2975 _elm_win_modality_increment(Efl_Ui_Win_Data *modalsd)
2976 {
2977    Efl_Ui_Win *current;
2978    Eina_List *l;
2979    Eina_Bool is_legacy = elm_widget_is_legacy(modalsd->obj);
2980
2981    EINA_LIST_FOREACH(_elm_win_list, l, current)
2982      {
2983         ELM_WIN_DATA_GET_OR_RETURN(current, cursd);
2984         if (modalsd != cursd)
2985           cursd->modal_count++;
2986         if (cursd->modal_count > 0)
2987           {
2988              Edje_Object *ed = _elm_win_modal_blocker_edje_get(cursd);
2989              if (is_legacy)
2990                edje_object_signal_emit(ed, "elm,action,show_blocker", "elm");
2991              else
2992                edje_object_signal_emit(ed, "efl,action,show_blocker", "efl");
2993              efl_event_callback_legacy_call
2994                    (cursd->main_menu, EFL_UI_WIN_EVENT_ELM_ACTION_BLOCK_MENU, NULL);
2995              _elm_win_frame_style_update(cursd, 0, 1);
2996           }
2997      }
2998 }
2999
3000 static void
3001 _elm_win_modality_decrement(Efl_Ui_Win_Data *modalsd)
3002 {
3003    Efl_Ui_Win *current;
3004    Eina_List *l;
3005    Eina_Bool is_legacy = elm_widget_is_legacy(modalsd->obj);
3006
3007    EINA_LIST_FOREACH(_elm_win_list, l, current)
3008      {
3009         ELM_WIN_DATA_GET_OR_RETURN(current, cursd);
3010         if ((modalsd != cursd) && (cursd->modal_count > 0))
3011           cursd->modal_count--;
3012         if (cursd->modal_count == 0)
3013           {
3014              Edje_Object *ed = _elm_win_modal_blocker_edje_get(cursd);
3015              if (is_legacy)
3016                edje_object_signal_emit(ed, "elm,action,hide_blocker", "elm");
3017              else
3018                edje_object_signal_emit(ed, "efl,action,hide_blocker", "efl");
3019              efl_event_callback_legacy_call
3020                    (cursd->main_menu, ELM_MENU_EVENT_ELM_ACTION_UNBLOCK_MENU, NULL);
3021              _elm_win_frame_style_update(cursd, 0, 1);
3022           }
3023      }
3024 }
3025
3026 static void
3027 _efl_ui_win_show(Eo *obj, Efl_Ui_Win_Data *sd)
3028 {
3029    Eina_Bool do_eval = EINA_FALSE;
3030
3031    sd->shown = EINA_TRUE;
3032    if (sd->modal_count)
3033      {
3034         /* FIXME FIXME FIXME
3035          * Ugly code flow: legacy code had an early return in smart_show, ie.
3036          * evas object show would be processed but smart object show would be
3037          * aborted. This super call tries to simulate that. */
3038         efl_gfx_entity_visible_set(efl_super(obj, EFL_CANVAS_GROUP_CLASS), EINA_TRUE);
3039         return;
3040      }
3041
3042    if ((sd->modal) && (!evas_object_visible_get(obj)))
3043      _elm_win_modality_increment(sd);
3044
3045    if (!evas_object_visible_get(obj)) do_eval = EINA_TRUE;
3046    efl_gfx_entity_visible_set(efl_super(obj, MY_CLASS), EINA_TRUE);
3047
3048    if (sd->deferred_resize_job)
3049      _elm_win_resize_job(sd->obj);
3050    evas_smart_objects_calculate(evas_object_evas_get(obj));
3051
3052    TRAP(sd, show);
3053
3054    if (_elm_atspi_enabled())
3055      {
3056         Eo *root;
3057         root = efl_access_object_access_root_get();
3058         if (root)
3059            efl_access_children_changed_added_signal_emit(root, obj);
3060
3061         //TIZEN_ONLY(20200508):Listen to socket when widget window is shown
3062         _access_socket_proxy_listen(obj);
3063         //
3064      }
3065
3066    if (do_eval)
3067      {
3068 /*TIZEN_ONLY(20171113):Use ecore_job instead of ecore_timer
3069         if (_elm_win_state_eval_timer)
3070           {
3071              ecore_timer_del(_elm_win_state_eval_timer);
3072              _elm_win_state_eval_timer = NULL;
3073           }
3074 */
3075         if (_elm_win_state_eval_job)
3076           {
3077              ecore_job_del(_elm_win_state_eval_job);
3078              _elm_win_state_eval_job = NULL;
3079           }
3080 //
3081         _elm_win_state_eval(NULL);
3082      }
3083
3084    if (sd->shot.info) _shot_handle(sd);
3085
3086    if (!sd->first_draw) return;
3087    if (sd->frame_obj)
3088      {
3089         evas_object_show(sd->frame_obj);
3090      }
3091    if (sd->img_obj)
3092      {
3093         evas_object_show(sd->img_obj);
3094      }
3095    if (sd->pointer.obj)
3096      {
3097         evas_object_show(sd->pointer.obj);
3098      }
3099 }
3100
3101 static void
3102 _efl_ui_win_hide(Eo *obj, Efl_Ui_Win_Data *sd)
3103 {
3104    if (sd->modal_count)
3105      {
3106         /* FIXME FIXME FIXME
3107          * Ugly code flow: legacy code had an early return in smart_show, ie.
3108          * evas object show would be processed but smart object show would be
3109          * aborted. This super call tries to simulate that. */
3110         efl_gfx_entity_visible_set(efl_super(obj, EFL_CANVAS_GROUP_CLASS), EINA_FALSE);
3111         return;
3112      }
3113
3114    _elm_win_state_eval_queue();
3115
3116    if ((sd->modal) && (evas_object_visible_get(obj)))
3117      _elm_win_modality_decrement(sd);
3118
3119    efl_gfx_entity_visible_set(efl_super(obj, MY_CLASS), EINA_FALSE);
3120    TRAP(sd, hide);
3121
3122    if (sd->frame_obj)
3123      {
3124         evas_object_hide(sd->frame_obj);
3125      }
3126    if (sd->img_obj)
3127      {
3128         evas_object_hide(sd->img_obj);
3129      }
3130    if (sd->pointer.obj)
3131      {
3132         evas_object_hide(sd->pointer.obj);
3133      }
3134
3135    if (_elm_atspi_enabled())
3136      {
3137         Eo *root;
3138         root = efl_access_object_access_root_get();
3139         if (root)
3140            efl_access_children_changed_del_signal_emit(root, obj);
3141      }
3142
3143    if (_elm_win_policy_quit_triggered(obj))
3144      _elm_win_flush_cache_and_exit(obj);
3145 }
3146
3147 EOLIAN static void
3148 _efl_ui_win_efl_gfx_entity_visible_set(Eo *obj, Efl_Ui_Win_Data *sd, Eina_Bool vis)
3149 {
3150    if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_VISIBLE, 0, vis))
3151      return;
3152
3153    if (vis) _efl_ui_win_show(obj, sd);
3154    else _efl_ui_win_hide(obj, sd);
3155 }
3156
3157 EOLIAN static Eina_Bool
3158 _efl_ui_win_efl_canvas_scene_pointer_position_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, Eo *dev, Eina_Position2D *pos)
3159 {
3160    return efl_canvas_scene_pointer_position_get(sd->evas, dev, pos);
3161 }
3162
3163 EOLIAN static Eina_Bool
3164 _efl_ui_win_efl_canvas_pointer_pointer_inside_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, Eo *dev)
3165 {
3166    return efl_canvas_pointer_inside_get(sd->evas, dev);
3167 }
3168
3169 /* multi touch support */
3170 static Eina_Bool
3171 _input_pointer_iterator_next(Input_Pointer_Iterator *it, void **data)
3172 {
3173    Eo *sub;
3174
3175    if (!eina_iterator_next(it->real_iterator, (void **) &sub))
3176      return EINA_FALSE;
3177
3178    if (data) *data = sub;
3179    return EINA_TRUE;
3180 }
3181
3182 static Eo *
3183 _input_pointer_iterator_get_container(Input_Pointer_Iterator *it)
3184 {
3185    return (Eo *) it->object;
3186 }
3187
3188 static void
3189 _input_pointer_iterator_free(Input_Pointer_Iterator *it)
3190 {
3191    Efl_Input_Pointer *ptr;
3192
3193    EINA_LIST_FREE(it->list, ptr)
3194      efl_unref(ptr);
3195    eina_iterator_free(it->real_iterator);
3196    free(it);
3197 }
3198
3199 EOLIAN static Eina_Iterator *
3200 _efl_ui_win_pointer_iterate(const Eo *obj, Efl_Ui_Win_Data *sd,
3201                                        Eina_Bool hover EINA_UNUSED)
3202 {
3203    Input_Pointer_Iterator *it;
3204    Eina_List *list = NULL;
3205    int i, cnt;
3206
3207    // Note: "hover" is here as a possible extension to this API. At the moment
3208    // I don't have any device that could track the position of hovering fingers
3209    // and Evas also wouldn't track those.
3210
3211    ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, NULL);
3212
3213    cnt = evas_touch_point_list_count(sd->evas);
3214    if (!cnt) return NULL;
3215
3216    it = calloc(1, sizeof(*it));
3217    if (!it) return NULL;
3218
3219    EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
3220
3221    for (i = 0; i < cnt; i++)
3222      {
3223         Efl_Input_Pointer_Data *ptrdata;
3224         Evas_Touch_Point_State state;
3225         Efl_Input_Pointer *ptr;
3226         double x, y;
3227
3228         ptr = efl_input_pointer_instance_get( (Eo *) obj, (void **) &ptrdata);
3229         if (!ptrdata) break;
3230
3231         ptrdata->touch_id = evas_touch_point_list_nth_id_get(sd->evas, i);
3232         _efl_input_value_mark(ptrdata, EFL_INPUT_VALUE_TOUCH_ID);
3233
3234         // Note that "still" maps to "down" here.
3235         state = evas_touch_point_list_nth_state_get(sd->evas, i);
3236         switch (state)
3237           {
3238            case EVAS_TOUCH_POINT_DOWN:   ptrdata->action = EFL_POINTER_ACTION_DOWN; break;
3239            case EVAS_TOUCH_POINT_UP:     ptrdata->action = EFL_POINTER_ACTION_UP; break;
3240            case EVAS_TOUCH_POINT_MOVE:   ptrdata->action = EFL_POINTER_ACTION_MOVE; break;
3241            case EVAS_TOUCH_POINT_STILL:  ptrdata->action = EFL_POINTER_ACTION_DOWN; break;
3242            case EVAS_TOUCH_POINT_CANCEL: ptrdata->action = EFL_POINTER_ACTION_CANCEL; break;
3243            default:                      ptrdata->action = EFL_POINTER_ACTION_NONE; break;
3244           }
3245
3246         evas_canvas_touch_point_list_nth_xy_get(sd->evas, i, &x, &y);
3247         _efl_input_value_mark(ptrdata, EFL_INPUT_VALUE_X);
3248         _efl_input_value_mark(ptrdata, EFL_INPUT_VALUE_Y);
3249         ptrdata->cur.x = x;
3250         ptrdata->cur.y = y;
3251         ptrdata->prev = ptrdata->cur;
3252
3253         list = eina_list_append(list, ptr);
3254      }
3255
3256    it->list = list;
3257    it->real_iterator = eina_list_iterator_new(it->list);
3258    it->iterator.version = EINA_ITERATOR_VERSION;
3259    it->iterator.next = FUNC_ITERATOR_NEXT(_input_pointer_iterator_next);
3260    it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(_input_pointer_iterator_get_container);
3261    it->iterator.free = FUNC_ITERATOR_FREE(_input_pointer_iterator_free);
3262    it->object = obj;
3263
3264    return &it->iterator;
3265 }
3266
3267 EOLIAN static Eina_Bool
3268 _efl_ui_win_efl_canvas_scene_image_max_size_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, Eina_Size2D *max)
3269 {
3270    return efl_canvas_scene_image_max_size_get(sd->evas, max);
3271 }
3272
3273 EOLIAN static void
3274 _efl_ui_win_efl_canvas_scene_group_objects_calculate(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
3275 {
3276    evas_smart_objects_calculate(sd->evas);
3277 }
3278
3279 EOLIAN static Eina_Bool
3280 _efl_ui_win_efl_canvas_scene_group_objects_calculating_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
3281 {
3282    return efl_canvas_scene_group_objects_calculating_get(sd->evas);
3283 }
3284
3285 EOLIAN static Eina_Iterator *
3286 _efl_ui_win_efl_canvas_scene_objects_at_xy_get(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, Eina_Position2D pos, Eina_Bool include_pass_events_objects, Eina_Bool include_hidden_objects)
3287 {
3288    Eina_List *objs = NULL;
3289    objs = evas_objects_at_xy_get(sd->evas, pos.x, pos.y, include_pass_events_objects, include_hidden_objects);
3290    return eina_list_iterator_new(objs); // FIXME: This leaks the list!
3291 }
3292
3293 EOLIAN static Efl_Gfx_Entity *
3294 _efl_ui_win_efl_canvas_scene_object_top_at_xy_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, Eina_Position2D pos, Eina_Bool include_pass_events_objects, Eina_Bool include_hidden_objects)
3295 {
3296    return evas_object_top_at_xy_get(sd->evas, pos.x, pos.y, include_pass_events_objects, include_hidden_objects);
3297 }
3298
3299 EOLIAN static Eina_Iterator *
3300 _efl_ui_win_efl_canvas_scene_objects_in_rectangle_get(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, Eina_Rect r, Eina_Bool include_pass_events_objects, Eina_Bool include_hidden_objects)
3301 {
3302    Eina_List *objs = NULL;
3303    objs = evas_objects_in_rectangle_get(sd->evas, r.x, r.y, r.w, r.h, include_pass_events_objects, include_hidden_objects);
3304    return eina_list_iterator_new(objs); // FIXME: This leaks the list!
3305 }
3306
3307 EOLIAN static Efl_Gfx_Entity *
3308 _efl_ui_win_efl_canvas_scene_object_top_in_rectangle_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, Eina_Rect r, Eina_Bool include_pass_events_objects, Eina_Bool include_hidden_objects)
3309 {
3310    return evas_object_top_in_rectangle_get(sd->evas, r.x, r.y, r.w, r.h, include_pass_events_objects, include_hidden_objects);
3311 }
3312
3313 EOLIAN static Efl_Input_Device *
3314 _efl_ui_win_efl_canvas_scene_device_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, const char *name)
3315 {
3316    return efl_canvas_scene_device_get(sd->evas, name);
3317 }
3318
3319 EOLIAN static Efl_Input_Device *
3320 _efl_ui_win_efl_canvas_scene_seat_default_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
3321 {
3322    return efl_canvas_scene_seat_default_get(sd->evas);
3323 }
3324
3325 EOLIAN static Efl_Input_Device *
3326 _efl_ui_win_efl_canvas_scene_seat_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, int id)
3327 {
3328    return efl_canvas_scene_seat_get(sd->evas, id);
3329 }
3330
3331 // TIZEN_ONLY(20171114) Accessibility Highlight Frame added
3332 static void
3333 _elm_win_accessibility_highlight_obj_del(void *data,
3334                            Evas *e EINA_UNUSED,
3335                            Evas_Object *obj,
3336                            void *event_info EINA_UNUSED)
3337 {
3338    ELM_WIN_DATA_GET(data, sd);
3339    // TIZEN_ONLY(20160805): set _accessibility_currently_highlighted_obj to NULL in object delete callback
3340    /* set _accessibility_currently_highlighted_obj to NULL */
3341    elm_object_accessibility_highlight_set(obj, EINA_FALSE);
3342    //
3343    _elm_win_accessibility_highlight_hide(sd->obj);
3344 }
3345
3346 static void
3347 _elm_win_accessibility_highlight_obj_move(void *data,
3348                            Evas *e EINA_UNUSED,
3349                            Evas_Object *obj EINA_UNUSED,
3350                            void *event_info EINA_UNUSED)
3351 {
3352    ELM_WIN_DATA_GET(data, sd);
3353
3354    _elm_win_accessibility_highlight_show(sd->obj);
3355 }
3356
3357 static void
3358 _elm_win_accessibility_highlight_obj_resize(void *data,
3359                              Evas *e EINA_UNUSED,
3360                              Evas_Object *obj EINA_UNUSED,
3361                              void *event_info EINA_UNUSED)
3362 {
3363    ELM_WIN_DATA_GET(data, sd);
3364    _elm_win_accessibility_highlight_show(sd->obj);
3365
3366 }
3367 //
3368
3369 static void
3370 _elm_win_on_parent_del(void *data,
3371                        Evas *e EINA_UNUSED,
3372                        Evas_Object *obj,
3373                        void *event_info EINA_UNUSED)
3374 {
3375    ELM_WIN_DATA_GET(data, sd);
3376
3377    if (obj == sd->parent)
3378      {
3379         ecore_wl2_window_parent_set(sd->wl.win, NULL);
3380         sd->parent = NULL;
3381      }
3382 }
3383
3384 static void
3385 _elm_win_focus_target_move(void *data,
3386                            Evas *e EINA_UNUSED,
3387                            Evas_Object *obj EINA_UNUSED,
3388                            void *event_info EINA_UNUSED)
3389 {
3390    ELM_WIN_DATA_GET(data, sd);
3391
3392    sd->focus_highlight.geometry_changed = EINA_TRUE;
3393    _elm_win_focus_highlight_reconfigure_job_start(sd);
3394 }
3395
3396 static void
3397 _elm_win_focus_target_resize(void *data,
3398                              Evas *e EINA_UNUSED,
3399                              Evas_Object *obj EINA_UNUSED,
3400                              void *event_info EINA_UNUSED)
3401 {
3402    ELM_WIN_DATA_GET(data, sd);
3403
3404    sd->focus_highlight.geometry_changed = EINA_TRUE;
3405    _elm_win_focus_highlight_reconfigure_job_start(sd);
3406 }
3407
3408 static void
3409 _elm_win_focus_target_del(void *data,
3410                           Evas *e EINA_UNUSED,
3411                           Evas_Object *obj EINA_UNUSED,
3412                           void *event_info EINA_UNUSED)
3413 {
3414    ELM_WIN_DATA_GET(data, sd);
3415
3416    sd->focus_highlight.cur.target = NULL;
3417
3418    _elm_win_focus_highlight_reconfigure_job_start(sd);
3419 }
3420
3421 static Evas_Object *
3422 _elm_win_focus_target_get(Evas_Object *obj)
3423 {
3424    Evas_Object *o = obj;
3425
3426    while (o)
3427      {
3428         if (elm_widget_is(o))
3429           {
3430              if (!elm_widget_highlight_ignore_get(o))
3431                break;
3432           }
3433         o = elm_widget_parent_widget_get(o);
3434      }
3435
3436    return o;
3437 }
3438
3439 static void
3440 _elm_win_focus_target_callbacks_add(Efl_Ui_Win_Data *sd)
3441 {
3442    Evas_Object *obj = sd->focus_highlight.cur.target;
3443    if (!obj) return;
3444
3445    evas_object_event_callback_add
3446      (obj, EVAS_CALLBACK_MOVE, _elm_win_focus_target_move, sd->obj);
3447    evas_object_event_callback_add
3448      (obj, EVAS_CALLBACK_RESIZE, _elm_win_focus_target_resize, sd->obj);
3449 }
3450
3451 static void
3452 _elm_win_focus_target_callbacks_del(Efl_Ui_Win_Data *sd)
3453 {
3454    Evas_Object *obj = sd->focus_highlight.cur.target;
3455
3456    evas_object_event_callback_del_full
3457      (obj, EVAS_CALLBACK_MOVE, _elm_win_focus_target_move, sd->obj);
3458    evas_object_event_callback_del_full
3459      (obj, EVAS_CALLBACK_RESIZE, _elm_win_focus_target_resize, sd->obj);
3460 }
3461
3462 // TIZEN_ONLY(20171114) Accessibility Highlight Frame added
3463 static void
3464 _elm_win_accessibility_highlight_callbacks_add(Efl_Ui_Win_Data *sd)
3465 {
3466    Evas_Object *obj = sd->accessibility_highlight.cur.target;
3467    if (!obj) return;
3468    evas_object_event_callback_add
3469      (obj, EVAS_CALLBACK_DEL, _elm_win_accessibility_highlight_obj_del, sd->obj);
3470    evas_object_event_callback_add
3471      (obj, EVAS_CALLBACK_MOVE, _elm_win_accessibility_highlight_obj_move, sd->obj);
3472    evas_object_event_callback_add
3473      (obj, EVAS_CALLBACK_RESIZE, _elm_win_accessibility_highlight_obj_resize, sd->obj);
3474 }
3475 //
3476
3477 static void
3478 _elm_win_object_focus_in(void *data,
3479                          Evas *e EINA_UNUSED,
3480                          void *event_info)
3481 {
3482    Evas_Object *obj = event_info, *target;
3483    ELM_WIN_DATA_GET(data, sd);
3484
3485    if (sd->focus_highlight.cur.target == obj)
3486      return;
3487
3488    target = _elm_win_focus_target_get(obj);
3489    sd->focus_highlight.cur.target = target;
3490
3491    if (target)
3492      {
3493         if (elm_widget_highlight_in_theme_get(target))
3494           sd->focus_highlight.cur.in_theme = EINA_TRUE;
3495         else
3496           _elm_win_focus_target_callbacks_add(sd);
3497         evas_object_event_callback_add
3498               (target, EVAS_CALLBACK_DEL, _elm_win_focus_target_del, sd->obj);
3499      }
3500
3501    _elm_win_focus_highlight_reconfigure_job_start(sd);
3502 }
3503
3504 static void
3505 _elm_win_object_focus_out(void *data,
3506                           Evas *e EINA_UNUSED,
3507                           void *event_info EINA_UNUSED)
3508 {
3509    ELM_WIN_DATA_GET(data, sd);
3510
3511    if (!sd->focus_highlight.cur.target)
3512      return;
3513
3514    if (!sd->focus_highlight.cur.in_theme)
3515      _elm_win_focus_target_callbacks_del(sd);
3516
3517    evas_object_event_callback_del_full
3518       (sd->focus_highlight.cur.target,
3519        EVAS_CALLBACK_DEL, _elm_win_focus_target_del, sd->obj);
3520
3521    sd->focus_highlight.cur.target = NULL;
3522    sd->focus_highlight.cur.in_theme = EINA_FALSE;
3523
3524    _elm_win_focus_highlight_reconfigure_job_start(sd);
3525 }
3526
3527 static void
3528 _elm_win_focus_highlight_shutdown(Efl_Ui_Win_Data *sd)
3529 {
3530    _elm_win_focus_highlight_reconfigure_job_stop(sd);
3531    if (sd->focus_highlight.cur.target)
3532      {
3533         if (elm_widget_is_legacy(sd->obj))
3534           elm_widget_signal_emit(sd->focus_highlight.cur.target,
3535                                  "elm,action,focus_highlight,hide", "elm");
3536         else
3537           elm_widget_signal_emit(sd->focus_highlight.cur.target,
3538                                  "efl,action,focus_highlight,hide", "efl");
3539         _elm_win_focus_target_callbacks_del(sd);
3540         evas_object_event_callback_del_full
3541            (sd->focus_highlight.cur.target,
3542             EVAS_CALLBACK_DEL, _elm_win_focus_target_del, sd->obj);
3543         sd->focus_highlight.cur.target = NULL;
3544      }
3545    ELM_SAFE_FREE(sd->focus_highlight.fobj, evas_object_del);
3546
3547    evas_event_callback_del_full
3548      (sd->evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
3549      _elm_win_object_focus_in, sd->obj);
3550    evas_event_callback_del_full
3551      (sd->evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
3552      _elm_win_object_focus_out, sd->obj);
3553 }
3554
3555 static void
3556 _win_img_hide(void *data,
3557               Evas *e EINA_UNUSED,
3558               Evas_Object *obj EINA_UNUSED,
3559               void *event_info EINA_UNUSED)
3560 {
3561    /* TIZEN_ONLY(20180607): Restore legacy focus
3562    Efl_Ui_Win *real_win = elm_widget_top_get(data);
3563    efl_ui_focus_manager_redirect_set(real_win, NULL);
3564    */
3565    efl_ui_widget_focus_hide_handle(data);
3566    //
3567 }
3568
3569 static void
3570 _win_img_mouse_up(void *data,
3571                   Evas *e EINA_UNUSED,
3572                   Evas_Object *obj EINA_UNUSED,
3573                   void *event_info)
3574 {
3575    Evas_Event_Mouse_Up *ev = event_info;
3576    if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD))
3577      elm_widget_focus_mouse_up_handle(evas_object_widget_parent_find(data));
3578 }
3579
3580 static void
3581 _win_img_focus_in(void *data,
3582                   Evas *e EINA_UNUSED,
3583                   Evas_Object *obj EINA_UNUSED,
3584                   void *event_info EINA_UNUSED)
3585 {
3586    /* TIZEN_ONLY(20180607): Restore legacy focus
3587    Efl_Ui_Win *real_win = elm_widget_top_get(data);
3588    efl_ui_focus_manager_redirect_set(real_win, data);
3589    efl_ui_focus_manager_focus_set(data, efl_ui_focus_manager_root_get(data));
3590    */
3591    efl_ui_widget_focus_steal(data, NULL);
3592    //
3593 }
3594
3595 static void
3596 _win_img_focus_out(void *data,
3597                    Evas *e EINA_UNUSED,
3598                    Evas_Object *obj EINA_UNUSED,
3599                    void *event_info EINA_UNUSED)
3600 {
3601    /* TIZEN_ONLY(20180607): Restore legacy focus
3602    Efl_Ui_Win *real_win = elm_widget_top_get(data);
3603    efl_ui_focus_manager_redirect_set(real_win, NULL);
3604    */
3605    efl_ui_widget_focused_object_clear(data);
3606    //
3607 }
3608
3609 static void
3610 _elm_win_on_img_obj_del(void *data,
3611                         Evas *e EINA_UNUSED,
3612                         Evas_Object *obj EINA_UNUSED,
3613                         void *event_info EINA_UNUSED)
3614 {
3615    ELM_WIN_DATA_GET(data, sd);
3616    _elm_win_img_callbacks_del(sd->obj, sd->img_obj);
3617    sd->img_obj = NULL;
3618 }
3619
3620 static void
3621 _elm_win_img_callbacks_del(Evas_Object *obj, Evas_Object *imgobj)
3622 {
3623    if (!imgobj) return;
3624    evas_object_event_callback_del_full
3625      (imgobj, EVAS_CALLBACK_DEL, _elm_win_on_img_obj_del, obj);
3626    evas_object_event_callback_del_full
3627      (imgobj, EVAS_CALLBACK_HIDE, _win_img_hide, obj);
3628    evas_object_event_callback_del_full
3629      (imgobj, EVAS_CALLBACK_MOUSE_UP, _win_img_mouse_up, obj);
3630    evas_object_event_callback_del_full
3631      (imgobj, EVAS_CALLBACK_FOCUS_IN, _win_img_focus_in, obj);
3632    evas_object_event_callback_del_full
3633      (imgobj, EVAS_CALLBACK_FOCUS_OUT, _win_img_focus_out, obj);
3634 }
3635
3636 EOLIAN static void
3637 _efl_ui_win_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Win_Data *sd)
3638 {
3639    efl_event_freeze(sd->evas);
3640
3641    if ((sd->modal) && (evas_object_visible_get(obj)))
3642      _elm_win_modality_decrement(sd);
3643
3644    if ((sd->modal) && (sd->modal_count > 0))
3645      ERR("Deleted modal win was blocked by another modal win which was created after creation of that win.");
3646
3647    evas_object_event_callback_del_full(sd->legacy.edje,
3648                                        EVAS_CALLBACK_CHANGED_SIZE_HINTS,
3649                                        _elm_win_on_resize_obj_changed_size_hints,
3650                                        obj);
3651
3652    efl_event_callback_array_del(sd->evas, _elm_evas_tracking(), sd);
3653    efl_event_callback_array_del(obj, _elm_win_evas_feed_fake_callbacks(), sd->evas);
3654    efl_event_callback_array_del(obj, _elm_win_tracking(), sd);
3655    evas_object_del(sd->legacy.box);
3656    evas_object_del(sd->legacy.edje);
3657
3658    /* NB: child deletion handled by parent's smart del */
3659
3660    if ((sd->type != EFL_UI_WIN_TYPE_FAKE) && (trap) && (trap->del))
3661      trap->del(sd->trap_data, obj);
3662
3663    if (sd->parent)
3664      {
3665         evas_object_event_callback_del_full
3666           (sd->parent, EVAS_CALLBACK_DEL, _elm_win_on_parent_del, obj);
3667         sd->parent = NULL;
3668      }
3669
3670    if (sd->autodel_clear) *(sd->autodel_clear) = -1;
3671
3672    if (_elm_atspi_enabled())
3673      efl_access_window_destroyed_signal_emit(obj);
3674
3675    _elm_win_list = eina_list_remove(_elm_win_list, obj);
3676    _elm_win_count--;
3677    _elm_win_state_eval_queue();
3678
3679    if (_elm_win_count == _paused_windows)
3680      efl_event_callback_call(efl_loop_get(obj), EFL_APP_EVENT_PAUSE, NULL);
3681
3682    if (sd->ee)
3683      {
3684         ecore_evas_callback_delete_request_set(sd->ee, NULL);
3685         ecore_evas_callback_resize_set(sd->ee, NULL);
3686      }
3687
3688    eina_stringshare_del(sd->shot.info);
3689    ecore_timer_del(sd->shot.timer);
3690
3691 #ifdef HAVE_ELEMENTARY_X
3692    ecore_event_handler_del(sd->x.client_message_handler);
3693    ecore_event_handler_del(sd->x.property_handler);
3694 #endif
3695 #ifdef HAVE_ELEMENTARY_WL2
3696    ecore_event_handler_del(sd->wl.configure_handler);
3697    if (sd->pointer.obj) evas_object_del(sd->pointer.obj);
3698    if (sd->pointer.ee) ecore_evas_free(sd->pointer.ee);
3699    sd->pointer.surf = NULL;
3700    //TIZEN_ONLY(20171110): added signal for effect start and done
3701    ecore_event_handler_del(sd->wl.effect_start_handler);
3702    ecore_event_handler_del(sd->wl.effect_end_handler);
3703    //
3704    // TIZEN_ONLY(20160801): indicator implementation
3705    ecore_event_handler_del(sd->wl.indicator_flick_handler);
3706    //
3707    // TIZEN_ONLY(20150722): added signal for aux_hint(auxiliary hint)
3708    ecore_event_handler_del(sd->wl.aux_msg_handler);
3709    //
3710 #endif
3711 #ifdef HAVE_ELEMENTARY_WIN32
3712    ecore_event_handler_del(sd->win32.key_down_handler);
3713 #endif
3714
3715    if (sd->type == ELM_WIN_INLINED_IMAGE)
3716      {
3717         _elm_win_img_callbacks_del(obj, sd->img_obj);
3718         sd->img_obj = NULL;
3719      }
3720
3721    //TIZEN_ONLY(20211108): delete ecore_evas when inlined image window is deleted
3722    if (sd->ee && (sd->type != EFL_UI_WIN_TYPE_FAKE))
3723      {
3724         ecore_evas_manual_render_set(sd->ee, EINA_TRUE);
3725         edje_object_freeze(sd->frame_obj);
3726         ecore_job_add(_deferred_ecore_evas_free, sd->ee);
3727         _elm_win_deferred_free++;
3728      }
3729    //
3730
3731    _elm_win_focus_highlight_shutdown(sd);
3732    // TIZEN_ONLY(20171114) Accessibility Highlight Frame added
3733    // //TIZEN_ONLY(20171108): bring HIGHLIGHT related changes
3734    // _elm_win_accessibility_highlight_shutdown(sd);
3735    // //
3736    //
3737    eina_stringshare_del(sd->focus_highlight.style);
3738
3739    eina_stringshare_del(sd->title);
3740    eina_stringshare_del(sd->icon_name);
3741    eina_stringshare_del(sd->role);
3742    eina_stringshare_del(sd->name);
3743    eina_stringshare_del(sd->accel_pref);
3744    eina_stringshare_del(sd->stack_id);
3745    eina_stringshare_del(sd->stack_master_id);
3746    evas_object_del(sd->icon);
3747    evas_object_del(sd->main_menu);
3748    evas_object_del(sd->indicator);
3749
3750    sd->focus_highlight.style = NULL;
3751    sd->title = NULL;
3752    sd->icon_name = NULL;
3753    sd->role = NULL;
3754    sd->name = NULL;
3755    sd->icon = NULL;
3756    sd->main_menu = NULL;
3757
3758    _elm_win_profile_del(sd);
3759    _elm_win_available_profiles_del(sd);
3760    eina_array_free(sd->profile.available);
3761    sd->profile.available = NULL;
3762
3763    eina_array_free(sd->planned_changes);
3764    sd->planned_changes = NULL;
3765
3766    free(sd->wm_rot.rots);
3767    sd->wm_rot.rots = NULL;
3768
3769    /* Don't let callback in the air that point to sd */
3770    if (sd->ee)
3771      {
3772         ecore_evas_callback_mouse_in_set(sd->ee, NULL);
3773         ecore_evas_callback_focus_in_set(sd->ee, NULL);
3774         ecore_evas_callback_focus_out_set(sd->ee, NULL);
3775         ecore_evas_callback_move_set(sd->ee, NULL);
3776         ecore_evas_callback_state_change_set(sd->ee, NULL);
3777         ecore_evas_callback_pre_render_set(sd->ee, NULL);
3778      }
3779
3780    efl_canvas_group_del(efl_super(obj, MY_CLASS));
3781
3782    if (eina_value_type_get(&sd->exit_on_close))
3783      efl_loop_quit(efl_loop_get(obj), sd->exit_on_close);
3784    else if (!_elm_win_list)
3785      {
3786        if (elm_policy_get(ELM_POLICY_QUIT) == ELM_POLICY_QUIT_LAST_WINDOW_CLOSED)
3787          _elm_win_flush_cache_and_exit(obj);
3788      }
3789    if (!_elm_win_list)
3790      {
3791         efl_event_callback_call(efl_app_main_get(), EFL_APP_EVENT_STANDBY, NULL);
3792         if (eina_value_type_get(&exit_on_all_windows_closed))
3793           efl_loop_quit(efl_loop_get(obj), exit_on_all_windows_closed);
3794      }
3795 }
3796
3797 /* TIZEN_ONLY(20190520): Support Atomic geometry change */
3798 EOLIAN static void
3799 _efl_ui_win_efl_gfx_entity_geometry_set(Eo *obj, Efl_Ui_Win_Data *sd, Eina_Rect r)
3800 {
3801    sd->response++;
3802    Eina_Rect r2 = efl_gfx_entity_geometry_get(obj);
3803    efl_gfx_entity_geometry_set(efl_super(obj, MY_CLASS), r);
3804    sd->response--;
3805
3806    //Both position and size has been changed, Request atomic move/resize
3807    if (((r.x != r2.x) || (r.y != r2.y)) && ((r.w != r2.w) || (r.h != r2.h)))
3808      ecore_evas_move_resize(sd->ee, r.x, r.y, r.w, r.h);
3809 }
3810 /* End of TIZEN_ONLY */
3811
3812 EOLIAN static void
3813 _efl_ui_win_efl_gfx_entity_position_set(Eo *obj, Efl_Ui_Win_Data *sd, Eina_Position2D pos)
3814 {
3815    if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_MOVE, 0, pos.x, pos.y))
3816      return;
3817
3818    if (sd->img_obj)
3819      {
3820         if ((pos.x != sd->screen.x) || (pos.y != sd->screen.y))
3821           {
3822              sd->screen.x = pos.x;
3823              sd->screen.y = pos.y;
3824              efl_event_callback_call(obj, EFL_GFX_ENTITY_EVENT_POSITION_CHANGED, &pos);
3825              evas_object_smart_callback_call(obj, "move", NULL);
3826           }
3827         goto super_skip;
3828      }
3829    else
3830      {
3831         if (!sd->response)
3832           {
3833              sd->req_xy = EINA_TRUE;
3834              sd->req_x = pos.x;
3835              sd->req_y = pos.y;
3836              TRAP(sd, move, pos.x, pos.y);
3837 // TIZEN_ONLY(20180424): set window position
3838 #ifdef HAVE_ELEMENTARY_WL2
3839              ecore_wl2_window_position_set(sd->wl.win, pos.x, pos.y);
3840 #endif
3841 //
3842           }
3843         if (!ecore_evas_override_get(sd->ee)) goto super_skip;
3844      }
3845
3846    efl_gfx_entity_position_set(efl_super(obj, MY_CLASS), pos);
3847
3848    if (ecore_evas_override_get(sd->ee))
3849      {
3850         sd->screen.x = pos.x;
3851         sd->screen.y = pos.y;
3852         efl_event_callback_call(obj, EFL_GFX_ENTITY_EVENT_POSITION_CHANGED, &pos);
3853         evas_object_smart_callback_call(obj, "move", NULL);
3854      }
3855    if (sd->frame_obj)
3856      {
3857 #ifdef HAVE_ELEMENTARY_WL2
3858         // TIZEN_ONLY(20180424): set window position
3859         ecore_wl2_window_position_set(sd->wl.win, pos.x, pos.y);
3860         //
3861         /* TODO */
3862         /* ecore_wl_window_update_location(sd->wl.win, x, y); */
3863 #endif
3864         sd->screen.x = pos.x;
3865         sd->screen.y = pos.y;
3866      }
3867    if (sd->img_obj)
3868      {
3869         sd->screen.x = pos.x;
3870         sd->screen.y = pos.y;
3871      }
3872
3873    return;
3874
3875 super_skip:
3876    /* FIXME FIXME FIXME
3877     * Ugly code flow: legacy code had an early return in smart_move, ie.
3878     * evas object move would be processed but smart object move would be
3879     * aborted. This super call tries to simulate that. */
3880    efl_gfx_entity_position_set(efl_super(obj, EFL_CANVAS_GROUP_CLASS), pos);
3881 }
3882
3883 EOLIAN static void
3884 _efl_ui_win_efl_gfx_entity_size_set(Eo *obj, Efl_Ui_Win_Data *sd, Eina_Size2D sz)
3885 {
3886    if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_RESIZE, 0, sz.w, sz.h))
3887      return;
3888
3889    if (sd->img_obj)
3890      {
3891         if (sd->constrain)
3892           {
3893              int sw, sh;
3894
3895              ecore_evas_screen_geometry_get(sd->ee, NULL, NULL, &sw, &sh);
3896              sz.w = MIN(sz.w, sw);
3897              sz.h = MIN(sz.h, sh);
3898           }
3899         if (sz.w < 1) sz.w = 1;
3900         if (sz.h < 1) sz.h = 1;
3901
3902         evas_object_image_size_set(sd->img_obj, sz.w, sz.h);
3903      }
3904
3905    _elm_win_frame_obj_update(sd, 1);
3906    if (!sd->response)
3907      {
3908         sd->req_wh = EINA_TRUE;
3909         sd->req_w = sz.w;
3910         sd->req_h = sz.h;
3911         //TIZEN_ONLY(20221228): add resize request set for ignoring configure event
3912         if (sz.w > 1 && sz.h > 1)
3913           {
3914              if ((sd->rot == 0) || (sd->rot == 180))
3915                {
3916                   ERR("Call resize request set w: %d h: %d", sz.w, sz.h);
3917                   ecore_wl2_window_resize_request_set(sd->wl.win, sz.w, sz.h);
3918                }
3919              else
3920                {
3921                   ERR("Call resize request set w: %d h: %d", sz.h, sz.w);
3922                   ecore_wl2_window_resize_request_set(sd->wl.win, sz.h, sz.w);
3923                }
3924           }
3925         //
3926         TRAP(sd, resize, sz.w, sz.h);
3927      }
3928
3929    efl_gfx_entity_size_set(efl_super(obj, MY_CLASS), sz);
3930    /* if window is hidden during a resize,
3931     * revert to initial state where pre-render triggers recalc and other resizes are deferred
3932     */
3933    if (efl_gfx_entity_visible_get(obj)) return;
3934    if (!sd->first_draw) return;
3935    sd->first_draw = EINA_FALSE;
3936    edje_object_freeze(sd->frame_obj);
3937 }
3938
3939 static void
3940 _elm_win_delete_request(Ecore_Evas *ee)
3941 {
3942    Efl_Ui_Win_Data *sd = _elm_win_associate_get(ee);
3943    Evas_Object *obj;
3944
3945    if (!sd) return;
3946
3947    obj = sd->obj;
3948
3949    int autodel = sd->autodel;
3950    sd->autodel_clear = &autodel;
3951    evas_object_ref(obj);
3952    efl_event_callback_legacy_call(obj, EFL_UI_WIN_EVENT_DELETE_REQUEST, NULL);
3953    ELM_WIN_DATA_ALIVE_CHECK(obj, sd);
3954    if (sd->autohide)
3955      evas_object_hide(obj);
3956    ELM_WIN_DATA_ALIVE_CHECK(obj, sd);
3957    if (_elm_atspi_enabled())
3958      efl_access_window_destroyed_signal_emit(obj);
3959    ELM_WIN_DATA_ALIVE_CHECK(obj, sd);
3960    if (autodel) evas_object_del(obj);
3961    else sd->autodel_clear = NULL;
3962    evas_object_unref(obj);
3963 }
3964
3965 // TIZEN_ONLY(20150722): added signal for aux_hint(auxiliary hint)
3966 struct _Elm_Win_Aux_Message
3967 {
3968    const char *key;
3969    const char *val;
3970    Eina_List *options;
3971 };
3972
3973 #ifdef HAVE_ELEMENTARY_WL2
3974 static void
3975 _elm_win_wlwindow_get(Efl_Ui_Win_Data *sd)
3976 {
3977    Ecore_Wl2_Window *pwin = sd->wl.win;
3978    sd->wl.win = _elm_ee_wlwin_get(sd->ee);
3979    if (sd->wl.win != pwin)
3980      {
3981         char buf[128];
3982         int id;
3983
3984         snprintf(buf, sizeof(buf), "%u||%p", getpid(), sd->wl.win);
3985         eina_stringshare_replace(&sd->stack_id, buf);
3986         id = ecore_evas_aux_hint_id_get(sd->ee, "stack_id");
3987         if (id >= 0) ecore_evas_aux_hint_val_set(sd->ee, id, sd->stack_id);
3988         else ecore_evas_aux_hint_add(sd->ee, "stack_id", sd->stack_id);
3989      }
3990 }
3991
3992 void
3993 _elm_win_wl_cursor_set(Evas_Object *obj, const char *cursor)
3994 {
3995    ELM_WIN_DATA_GET(obj, sd);
3996
3997    if (!sd) return;
3998
3999    if (sd->pointer.obj)
4000      {
4001         Evas_Coord mw = 1, mh = 1, hx = 0, hy = 0;
4002
4003         if (cursor)
4004           {
4005              if (elm_widget_theme_object_set(sd->obj, sd->pointer.obj,
4006                                         "cursor", cursor, "default"))
4007                {
4008                   elm_widget_theme_object_set(sd->obj, sd->pointer.obj,
4009                                         "pointer", "base", "default");
4010                }
4011           }
4012         else
4013           elm_widget_theme_object_set(sd->obj, sd->pointer.obj,
4014                                 "pointer", "base", "default");
4015
4016         edje_object_size_min_get(sd->pointer.obj, &mw, &mh);
4017         edje_object_size_min_restricted_calc(sd->pointer.obj, &mw, &mh, mw, mh);
4018         if ((mw < 32) || (mh < 32))
4019           {
4020              mw = 32;
4021              mh = 32;
4022           }
4023         evas_object_geometry_set(sd->pointer.obj, 0, 0, mw, mh);
4024         if (elm_widget_is_legacy(obj))
4025           edje_object_part_geometry_get(sd->pointer.obj,
4026                                         "elm.swallow.hotspot",
4027                                         &hx, &hy, NULL, NULL);
4028         else
4029           edje_object_part_geometry_get(sd->pointer.obj,
4030                                         "efl.hotspot",
4031                                         &hx, &hy, NULL, NULL);
4032
4033         sd->pointer.hot_x = hx;
4034         sd->pointer.hot_y = hy;
4035
4036         ecore_evas_resize(sd->pointer.ee, mw, mh);
4037      }
4038
4039    if ((sd->wl.win) && (sd->pointer.surf) && (sd->pointer.visible))
4040      {
4041         /* FIXME: multiseat */
4042         Ecore_Wl2_Input *input;
4043         Eina_Iterator *it;
4044
4045         /* FIXME: Here be dragons...
4046            pointer_set_cursor is totally unsynchronized, and on a cursor
4047            change we get here before the new cursor is rendered.  So
4048            the cursor frequently moves to its new hotspot with the old
4049            cursor image, causing an ugly jump.
4050            Forcing manual render causes us to render first then set the
4051            cursor, which is still racey but far more likely to win the
4052            race.
4053            The right way to do this is to create an entirely new surface
4054            on every cursor change.
4055          */
4056         ecore_evas_manual_render(sd->pointer.ee);
4057         it = ecore_wl2_display_inputs_get(ecore_wl2_window_display_get(sd->wl.win));
4058         EINA_ITERATOR_FOREACH(it, input)
4059           ecore_wl2_input_pointer_set(input, sd->pointer.surf, sd->pointer.hot_x, sd->pointer.hot_y);
4060         eina_iterator_free(it);
4061      }
4062 }
4063
4064 // TIZEN_ONLY(20171109):allow changing window type after initializing
4065 static void
4066 _elm_win_wlwin_type_update(Efl_Ui_Win_Data *sd)
4067 {
4068    Ecore_Wl2_Window_Type wtype;
4069
4070    if (!sd) return;
4071    if (!sd->wl.win) return;
4072    if (sd->type == ELM_WIN_FAKE) return;
4073
4074    switch (sd->type)
4075      {
4076       case ELM_WIN_BASIC:
4077       case ELM_WIN_TOOLBAR:
4078         wtype = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
4079         break;
4080       case ELM_WIN_DESKTOP:
4081         wtype = ECORE_WL2_WINDOW_TYPE_DESKTOP;
4082         break;
4083       case ELM_WIN_UTILITY:
4084          wtype = ECORE_WL2_WINDOW_TYPE_UTILITY;
4085          break;
4086       case ELM_WIN_DIALOG_BASIC:
4087         wtype = ECORE_WL2_WINDOW_TYPE_DIALOG;
4088         break;
4089       case ELM_WIN_DOCK:
4090         wtype = ECORE_WL2_WINDOW_TYPE_DOCK;
4091         break;
4092       case ELM_WIN_SPLASH:
4093         wtype = ECORE_WL2_WINDOW_TYPE_SPLASH;
4094         break;
4095       case ELM_WIN_TOOLTIP:
4096       case ELM_WIN_COMBO:
4097       case ELM_WIN_MENU:
4098       case ELM_WIN_POPUP_MENU:
4099         wtype = ECORE_WL2_WINDOW_TYPE_MENU;
4100         break;
4101       case ELM_WIN_DND:
4102         wtype = ECORE_WL2_WINDOW_TYPE_DND;
4103         break;
4104       case ELM_WIN_NOTIFICATION:
4105         wtype = ECORE_WL2_WINDOW_TYPE_NOTIFICATION;
4106         break;
4107       default:
4108         wtype = ECORE_WL2_WINDOW_TYPE_NONE;
4109      }
4110    ecore_wl2_window_type_set(sd->wl.win, wtype);
4111 }
4112 //
4113
4114 static Eina_Bool
4115 _elm_win_wl_aux_message(void *data, int type EINA_UNUSED, void *event)
4116 {
4117    ELM_WIN_DATA_GET(data, sd);
4118    Ecore_Wl2_Event_Aux_Message *ev = event;
4119    Elm_Win_Aux_Message *msg = NULL;
4120    const char *opt = NULL, *tmp = NULL;
4121    Eina_List *l;
4122
4123    if (!sd->wl.win) return ECORE_CALLBACK_PASS_ON;
4124
4125    if ((ecore_wl2_window_id_get(sd->wl.win) != (int)ev->win))
4126      return ECORE_CALLBACK_PASS_ON;
4127
4128    msg = calloc(1, sizeof(*msg));
4129    if (!msg) return ECORE_CALLBACK_PASS_ON;
4130
4131    msg->key = eina_stringshare_add(ev->key);
4132    msg->val = eina_stringshare_add(ev->val);
4133
4134    EINA_LIST_FOREACH(ev->options, l, opt)
4135      {
4136         if (!opt) continue;
4137         tmp = eina_stringshare_add(opt);
4138         msg->options = eina_list_append(msg->options, tmp);
4139      }
4140
4141    evas_object_smart_callback_call(sd->obj, SIG_AUX_MESSAGE_RECEIVED, (void*)msg);
4142
4143    eina_stringshare_del(msg->key);
4144    eina_stringshare_del(msg->val);
4145    EINA_LIST_FREE(msg->options, opt)
4146       eina_stringshare_del(opt);
4147    free(msg);
4148
4149    return ECORE_CALLBACK_PASS_ON;
4150 }
4151 // END of TIZEN_ONLY(20150722)
4152 #endif
4153
4154 Ecore_Cocoa_Window *
4155 _elm_ee_cocoa_win_get(const Ecore_Evas *ee)
4156 {
4157 #ifdef HAVE_ELEMENTARY_COCOA
4158    const char *engine_name;
4159
4160    if (!ee) return NULL;
4161
4162    engine_name = ecore_evas_engine_name_get(ee);
4163    if (EINA_UNLIKELY(!engine_name)) return NULL;
4164
4165    if (!strcmp(engine_name, "opengl_cocoa") ||
4166        !strcmp(engine_name, "gl_cocoa"))
4167      return ecore_evas_cocoa_window_get(ee);
4168 #else
4169    (void)ee;
4170 #endif
4171    return NULL;
4172 }
4173
4174 Ecore_Win32_Window *
4175 _elm_ee_win32win_get(const Ecore_Evas *ee)
4176 {
4177 #ifdef HAVE_ELEMENTARY_WIN32
4178    const char *engine_name;
4179
4180    if (!ee) return NULL;
4181
4182    engine_name = ecore_evas_engine_name_get(ee);
4183    if (EINA_UNLIKELY(!engine_name)) return NULL;
4184
4185    if ((!strcmp(engine_name, ELM_SOFTWARE_WIN32)) ||
4186        (!strcmp(engine_name, ELM_SOFTWARE_DDRAW)))
4187      {
4188         return ecore_evas_win32_window_get(ee);
4189      }
4190 #else
4191    (void)ee;
4192 #endif
4193    return NULL;
4194 }
4195
4196 #ifdef HAVE_ELEMENTARY_COCOA
4197 static void
4198 _elm_win_cocoawindow_get(Efl_Ui_Win_Data *sd)
4199 {
4200    sd->cocoa.win = _elm_ee_cocoa_win_get(sd->ee);
4201 }
4202 #endif
4203
4204 #ifdef HAVE_ELEMENTARY_WIN32
4205 static void
4206 _internal_elm_win_win32window_get(Efl_Ui_Win_Data *sd)
4207 {
4208    sd->win32.win = _elm_ee_win32win_get(sd->ee);
4209 }
4210 #endif
4211
4212 #ifdef HAVE_ELEMENTARY_X
4213 static void
4214 _elm_win_xwin_update(Efl_Ui_Win_Data *sd)
4215 {
4216    const char *s;
4217
4218    if (sd->type == EFL_UI_WIN_TYPE_FAKE) return;
4219    _internal_elm_win_xwindow_get(sd);
4220
4221    if (!sd->x.xwin) return;  /* nothing more to do */
4222    _internal_elm_win_xwindow_get(sd);
4223
4224    if (sd->stack_master_id)
4225      {
4226         Ecore_X_Window win = strtol(sd->stack_master_id, NULL, 16);
4227         if (win)
4228           {
4229              ecore_x_icccm_transient_for_set(sd->x.xwin, win);
4230              if (sd->stack_base)
4231                ecore_x_e_stack_type_set(sd->x.xwin, ECORE_X_STACK_BASE);
4232              else
4233                ecore_x_e_stack_type_set(sd->x.xwin, ECORE_X_STACK_STANDARD);
4234           }
4235      }
4236    else
4237      {
4238         if (sd->parent)
4239           {
4240              ELM_WIN_DATA_GET(sd->parent, sdp);
4241              if (sdp)
4242                {
4243                   _internal_elm_win_xwindow_get(sdp);
4244                   ecore_x_icccm_transient_for_set(sd->x.xwin, sdp->x.xwin);
4245                }
4246           }
4247      }
4248
4249    s = sd->title;
4250    if (!s) s = _elm_appname;
4251    if (!s) s = "";
4252    if (sd->icon_name) s = sd->icon_name;
4253    ecore_x_icccm_icon_name_set(sd->x.xwin, s);
4254    ecore_x_netwm_icon_name_set(sd->x.xwin, s);
4255
4256    s = sd->role;
4257    if (s) ecore_x_icccm_window_role_set(sd->x.xwin, s);
4258
4259    // set window icon
4260    if (sd->icon)
4261      {
4262         Eo *image = NULL;
4263
4264         if (efl_isa(sd->icon, EFL_CANVAS_IMAGE_INTERNAL_CLASS))
4265           image = sd->icon;
4266         else if (efl_isa(sd->icon, EFL_UI_IMAGE_CLASS))
4267           image = elm_image_object_get(sd->icon);
4268
4269         if (image)
4270           {
4271              int w = 0, h = 0, stride, x, y;
4272              Eina_Bool unmap = EINA_FALSE;
4273              Eina_Rw_Slice sl = {};
4274
4275              if (efl_isa(image, EFL_CANVAS_IMAGE_CLASS))
4276                {
4277                   Eina_Rect rect = {};
4278
4279                   unmap = EINA_TRUE;
4280                   rect.size = efl_gfx_buffer_size_get(image);
4281                   sl = efl_gfx_buffer_map(image, EFL_GFX_BUFFER_ACCESS_MODE_READ,
4282                                           &rect, EFL_GFX_COLORSPACE_ARGB8888, 0,
4283                                           &stride);
4284                   w = rect.w;
4285                   h = rect.h;
4286                }
4287              else
4288                {
4289                   evas_object_image_size_get(image, &w, &h);
4290                   stride = evas_object_image_stride_get(image);
4291                   sl.mem = evas_object_image_data_get(image, EINA_FALSE);
4292                }
4293
4294              if (sl.mem)
4295                {
4296                   Ecore_X_Icon ic;
4297
4298                   ic.width = w;
4299                   ic.height = h;
4300                   if ((w > 0) && (h > 0) &&
4301                       (stride >= (int)(w * sizeof(unsigned int))))
4302                     {
4303                        if (stride == (int)(w * sizeof(unsigned int)))
4304                          {
4305                             ic.data = sl.mem;
4306                             ecore_x_netwm_icons_set(sd->x.xwin, &ic, 1);
4307                          }
4308                        else
4309                          {
4310                             ic.data = malloc(w * h * sizeof(unsigned int));
4311                             if (ic.data)
4312                               {
4313                                  unsigned char *p = sl.mem;
4314                                  unsigned int *p2 = ic.data;
4315
4316                                  for (y = 0; y < h; y++)
4317                                    {
4318                                       for (x = 0; x < w; x++)
4319                                         {
4320                                            *p2 = *((unsigned int *)p);
4321                                            p += sizeof(unsigned int);
4322                                            p2++;
4323                                         }
4324                                       p += (stride - (w * sizeof(unsigned int)));
4325                                    }
4326                                  ecore_x_netwm_icons_set(sd->x.xwin, &ic, 1);
4327                                  free(ic.data);
4328                               }
4329                          }
4330                     }
4331                   if (unmap) efl_gfx_buffer_unmap(image, sl);
4332                   else evas_object_image_data_set(image, sl.mem);
4333                }
4334           }
4335      }
4336
4337    switch (sd->type)
4338      {
4339       case ELM_WIN_BASIC:
4340         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_NORMAL);
4341         break;
4342
4343       case ELM_WIN_DIALOG_BASIC:
4344         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_DIALOG);
4345         break;
4346
4347       case ELM_WIN_DESKTOP:
4348         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_DESKTOP);
4349         break;
4350
4351       case ELM_WIN_DOCK:
4352         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_DOCK);
4353         break;
4354
4355       case ELM_WIN_TOOLBAR:
4356         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_TOOLBAR);
4357         break;
4358
4359       case ELM_WIN_MENU:
4360         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_MENU);
4361         break;
4362
4363       case ELM_WIN_UTILITY:
4364         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_UTILITY);
4365         break;
4366
4367       case ELM_WIN_SPLASH:
4368         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_SPLASH);
4369         break;
4370
4371       case ELM_WIN_DROPDOWN_MENU:
4372         ecore_x_netwm_window_type_set
4373           (sd->x.xwin, ECORE_X_WINDOW_TYPE_DROPDOWN_MENU);
4374         break;
4375
4376       case ELM_WIN_POPUP_MENU:
4377         ecore_x_netwm_window_type_set
4378           (sd->x.xwin, ECORE_X_WINDOW_TYPE_POPUP_MENU);
4379         break;
4380
4381       case ELM_WIN_TOOLTIP:
4382         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_TOOLTIP);
4383         ecore_x_window_shape_input_rectangle_set(sd->x.xwin, 0, 0, 0, 0);
4384         break;
4385
4386       case ELM_WIN_NOTIFICATION:
4387         ecore_x_netwm_window_type_set
4388           (sd->x.xwin, ECORE_X_WINDOW_TYPE_NOTIFICATION);
4389         break;
4390
4391       case ELM_WIN_COMBO:
4392         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_COMBO);
4393         break;
4394
4395       case ELM_WIN_DND:
4396         ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_DND);
4397         break;
4398
4399       default:
4400         break;
4401      }
4402    ecore_x_e_virtual_keyboard_state_set
4403      (sd->x.xwin, (Ecore_X_Virtual_Keyboard_State)sd->kbdmode);
4404    if (sd->legacy.indmode == ELM_WIN_INDICATOR_SHOW)
4405      ecore_x_e_illume_indicator_state_set
4406        (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_STATE_ON);
4407    else if (sd->legacy.indmode == ELM_WIN_INDICATOR_HIDE)
4408      ecore_x_e_illume_indicator_state_set
4409        (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_STATE_OFF);
4410
4411    if ((sd->wm_rot.count) && (sd->wm_rot.rots))
4412      ecore_evas_wm_rotation_available_rotations_set(sd->ee,
4413                                                     sd->wm_rot.rots,
4414                                                     sd->wm_rot.count);
4415    if (sd->wm_rot.preferred_rot != -1)
4416      ecore_evas_wm_rotation_preferred_rotation_set(sd->ee,
4417                                                    sd->wm_rot.preferred_rot);
4418
4419 #ifdef HAVE_ELEMENTARY_X
4420    if (sd->csd.need && sd->x.xwin)
4421      TRAP(sd, borderless_set, EINA_TRUE);
4422 #endif
4423 }
4424
4425 #endif
4426
4427 /**
4428   * @internal
4429   *
4430   * Resize the window according to window layout's min and weight.
4431   * If the window layout's weight is 0.0, the window max is limited to layout's
4432   * min size.
4433   *
4434   * This is called when the window layout's weight hint is changed or when the
4435   * window is rotated.
4436   *
4437   * @param obj window object
4438   */
4439 static void
4440 _elm_win_resize_objects_eval(Evas_Object *obj, Eina_Bool force_resize)
4441 {
4442    Efl_Ui_Win_Data *sd = efl_data_scope_get(obj, MY_CLASS);
4443    Evas_Coord w, h, minw, minh, maxw, maxh, ow, oh;
4444    Eina_Bool unresizable;
4445    double wx, wy;
4446
4447    evas_object_size_hint_combined_min_get(sd->legacy.edje, &minw, &minh);
4448    if ((!minw) && (!minh) && (!sd->deferred_resize_job)) return;
4449
4450    efl_gfx_hint_size_restricted_max_set(obj, EINA_SIZE2D(-1, -1));
4451    // If content has a weight, make resizable
4452    efl_gfx_hint_weight_get(sd->legacy.edje, &wx, &wy);
4453
4454    // Content max hint is ignored
4455    maxw = sd->max_w;
4456    maxh = sd->max_h;
4457
4458    // Compatibility hack (for E)
4459    if (sd->single_edje_content && EINA_DBL_EQ(wx, 0) && EINA_DBL_EQ(wy, 0))
4460      wx = wy = 1;
4461
4462    if (EINA_DBL_EQ(wx, 0)) maxw = minw;
4463    if (maxw < 1) maxw = 32767;
4464    if (EINA_DBL_EQ(wy, 0)) maxh = minh;
4465    if (maxh < 1) maxh = 32767;
4466    if (maxw < minw) maxw = minw;
4467    if (maxh < minh) maxh = minh;
4468    if (maxw > 32767) maxw = 32767;
4469    if (maxh > 32767) maxh = 32767;
4470
4471    unresizable = ((minw == maxw) && (minh == maxh));
4472
4473    if (sd->csd.need_unresizable != unresizable)
4474      {
4475         sd->csd.need_unresizable = unresizable;
4476         _elm_win_frame_style_update(sd, 0, 1);
4477      }
4478
4479    if (sd->frame_obj)
4480      {
4481         int fw, fh;
4482
4483         evas_output_framespace_get(sd->evas, NULL, NULL, &fw, &fh);
4484         minw += fw;
4485         minh += fh;
4486         maxw += fw;
4487         maxh += fh;
4488      }
4489
4490    sd->tmp_updating_hints = 1;
4491    efl_gfx_hint_size_restricted_min_set(obj, EINA_SIZE2D(minw, minh));
4492    efl_gfx_hint_size_restricted_max_set(obj, EINA_SIZE2D(maxw, maxh));
4493    sd->tmp_updating_hints = 0;
4494    _elm_win_size_hints_update(obj, sd);
4495
4496    /* do not need to go below. if you go, ee could become 0. */
4497    if ((!minw) && (!minh)) return;
4498
4499    evas_object_geometry_get(obj, NULL, NULL, &ow, &oh);
4500    w = ow;
4501    h = oh;
4502    if (w < minw) w = minw;
4503    if (h < minh) h = minh;
4504    if (w > maxw) w = maxw;
4505    if (h > maxh) h = maxh;
4506    if (!force_resize && (w == ow) && (h == oh))
4507      return;
4508
4509    sd->req_wh = EINA_FALSE;
4510    if (sd->img_obj) evas_object_resize(obj, w, h);
4511    else
4512      {
4513         _elm_win_frame_geometry_adjust(sd);
4514         if (!sd->response)
4515           {
4516              sd->req_wh = EINA_TRUE;
4517              sd->req_w = w;
4518              sd->req_h = h;
4519              TRAP(sd, resize, w, h);
4520           }
4521      }
4522 }
4523
4524 static void
4525 _elm_win_on_resize_obj_changed_size_hints(void *data,
4526                                           Evas *e EINA_UNUSED,
4527                                           Evas_Object *obj EINA_UNUSED,
4528                                           void *event_info EINA_UNUSED)
4529 {
4530    _elm_win_resize_objects_eval(data, EINA_FALSE);
4531 }
4532
4533 void
4534 _elm_win_shutdown(void)
4535 {
4536    while (_elm_win_list)
4537      {
4538         Eina_List *itr = _elm_win_list;
4539         evas_object_del(itr->data);
4540         if (_elm_win_list == itr)
4541           {
4542              _elm_win_list = eina_list_remove_list(_elm_win_list, _elm_win_list);
4543           }
4544      }
4545 /*TIZEN_ONLY(20171113):Use ecore_job instead of ecore_timer
4546    ELM_SAFE_FREE(_elm_win_state_eval_timer, ecore_timer_del);
4547 */
4548    ELM_SAFE_FREE(_elm_win_state_eval_job, ecore_job_del);
4549 //
4550 }
4551
4552 void
4553 _elm_win_rescale(Elm_Theme *th,
4554                  Eina_Bool use_theme)
4555 {
4556    const Eina_List *l;
4557    Evas_Object *obj;
4558
4559    if (!use_theme)
4560      {
4561         EINA_LIST_FOREACH(_elm_win_list, l, obj)
4562           elm_widget_theme(obj);
4563      }
4564    else
4565      {
4566         EINA_LIST_FOREACH(_elm_win_list, l, obj)
4567           elm_widget_theme_specific(obj, th, EINA_FALSE);
4568      }
4569 }
4570
4571 void
4572 _elm_win_access(Eina_Bool is_access)
4573 {
4574    Evas *evas;
4575    const Eina_List *l;
4576    Evas_Object *obj;
4577    Evas_Object *fobj;
4578
4579    EINA_LIST_FOREACH(_elm_win_list, l, obj)
4580      {
4581         elm_widget_access(obj, is_access);
4582
4583          /* floating orphan object. if there are A, B, C objects and user does
4584             as below, then there would be floating orphan objects.
4585
4586               1. elm_object_content_set(layout, A);
4587               2. elm_object_content_set(layout, B);
4588               3. elm_object_content_set(layout, C);
4589
4590             now, the object A and B are floating orphan objects */
4591
4592         fobj = obj;
4593         for (;;)
4594           {
4595              fobj = evas_object_below_get(fobj);
4596              if (!fobj) break;
4597
4598              if (elm_widget_is(fobj) && !elm_widget_parent_get(fobj))
4599                {
4600                   elm_widget_access(fobj, is_access);
4601                }
4602           }
4603
4604         if (!is_access)
4605           {
4606              evas = evas_object_evas_get(obj);
4607             if (evas) _elm_access_object_highlight_disable(evas);
4608           }
4609      }
4610 }
4611
4612 //TIZEN_ONLY(20160822): When atspi mode is dynamically switched on/off,
4613 //register/unregister access objects accordingly.
4614 void
4615 _elm_win_screen_reader(Eina_Bool is_screen_reader)
4616 {
4617    const Eina_List *l;
4618    Evas_Object *obj;
4619    Evas_Object *fobj;
4620
4621    EINA_LIST_FOREACH(_elm_win_list, l, obj)
4622      {
4623         elm_widget_screen_reader(obj, is_screen_reader);
4624         evas_object_smart_callback_call(obj, SIG_ATSPI_SCREEN_READER_CHANGED, NULL);
4625
4626          /* floating orphan object. if there are A, B, C objects and user does
4627             as below, then there would be floating orphan objects.
4628
4629               1. elm_object_content_set(layout, A);
4630               2. elm_object_content_set(layout, B);
4631               3. elm_object_content_set(layout, C);
4632
4633             now, the object A and B are floating orphan objects */
4634
4635         fobj = obj;
4636         for (;;)
4637           {
4638              fobj = evas_object_below_get(fobj);
4639              if (!fobj) break;
4640
4641              if (elm_widget_is(fobj) && !elm_widget_parent_get(fobj))
4642                {
4643                   elm_widget_screen_reader(fobj, is_screen_reader);
4644                }
4645           }
4646
4647         if (!is_screen_reader)
4648           {
4649              Evas_Object *ptr = _elm_object_accessibility_currently_highlighted_get();
4650              if (ptr) {
4651                efl_access_component_highlight_clear(ptr);
4652              }
4653           }
4654      }
4655
4656 }
4657 //
4658
4659 //TIZEN_ONLY(20170621) handle atspi proxy connection at runtime
4660 void
4661 _elm_win_atspi(Eina_Bool is_atspi)
4662 {
4663    const Eina_List *l;
4664    Evas_Object *obj;
4665    Efl_Access_State_Set ss;
4666
4667    EINA_LIST_FOREACH(_elm_win_list, l, obj)
4668      {
4669         if (!is_atspi)
4670           {
4671              _access_socket_proxy_del(obj);
4672           }
4673         else
4674           {
4675              _access_socket_proxy_listen(obj);
4676              ss = efl_access_object_state_set_get(obj);
4677              if (STATE_TYPE_GET(ss, EFL_ACCESS_STATE_TYPE_ACTIVE))
4678                {
4679                   efl_access_window_activated_signal_emit(obj);
4680                   efl_access_state_changed_signal_emit(obj, EFL_ACCESS_STATE_TYPE_ACTIVE, EINA_TRUE);
4681                }
4682              else
4683                {
4684                   Efl_Access_Role role;
4685                   role = efl_access_object_role_get(obj);
4686                   if (role == EFL_ACCESS_ROLE_INPUT_METHOD_WINDOW)
4687                     {
4688                        efl_access_window_activated_signal_emit(obj);
4689                        efl_access_state_changed_signal_emit(obj, EFL_ACCESS_STATE_TYPE_ACTIVE, EINA_TRUE);
4690                     }
4691                }
4692           }
4693         elm_widget_atspi(obj, is_atspi);
4694      }
4695 }
4696 //
4697 //
4698 //
4699
4700 void
4701 _elm_win_translate(void)
4702 {
4703    const Eina_List *l;
4704    Evas_Object *obj;
4705
4706    /* TIZEN_ONLY(20180117): Apply paragraph direction according to locale
4707    EINA_LIST_FOREACH(_elm_win_list, l, obj)
4708      efl_ui_l10n_translation_update(obj);
4709     */
4710    EINA_LIST_FOREACH(_elm_win_list, l, obj)
4711      {
4712         if (!strcmp(E_("default:LTR"), "default:RTL"))
4713           efl_canvas_object_paragraph_direction_set(obj, EVAS_BIDI_DIRECTION_ANY_RTL);
4714         else
4715           efl_canvas_object_paragraph_direction_set(obj, EVAS_BIDI_DIRECTION_LTR);
4716
4717         efl_ui_l10n_translation_update(obj);
4718      }
4719    /* END */
4720
4721    //TIZEN_ONLY(20161202): Temporary code - Apply mirroring in _elm_win_translate()
4722    if (_elm_config && _elm_config->language_auto_mirrored)
4723      {
4724         if (!strcmp(E_("default:LTR"), "default:RTL"))
4725           elm_config_mirrored_set(EINA_TRUE);
4726         else
4727           elm_config_mirrored_set(EINA_FALSE);
4728      }
4729    //
4730 }
4731
4732 #ifdef HAVE_ELEMENTARY_X
4733 static Eina_Bool
4734 _elm_win_client_message(void *data,
4735                         int type EINA_UNUSED,
4736                         void *event)
4737 {
4738    ELM_WIN_DATA_GET(data, sd);
4739    Ecore_X_Event_Client_Message *e = event;
4740
4741    if (e->format != 32) return ECORE_CALLBACK_PASS_ON;
4742    _internal_elm_win_xwindow_get(sd);
4743    if (e->message_type == ECORE_X_ATOM_E_COMP_FLUSH)
4744      {
4745         if ((unsigned int)e->data.l[0] == sd->x.xwin)
4746           {
4747              Evas *evas = evas_object_evas_get(sd->obj);
4748              if (evas)
4749                {
4750                   edje_file_cache_flush();
4751                   edje_collection_cache_flush();
4752                   evas_image_cache_flush(evas);
4753                   evas_font_cache_flush(evas);
4754                }
4755           }
4756      }
4757    else if (e->message_type == ECORE_X_ATOM_E_COMP_DUMP)
4758      {
4759         if ((unsigned int)e->data.l[0] == sd->x.xwin)
4760           {
4761              Evas *evas = evas_object_evas_get(sd->obj);
4762              if (evas)
4763                {
4764                   edje_file_cache_flush();
4765                   edje_collection_cache_flush();
4766                   evas_image_cache_flush(evas);
4767                   evas_font_cache_flush(evas);
4768                   evas_render_dump(evas);
4769                }
4770           }
4771      }
4772    else if (e->message_type == ECORE_X_ATOM_E_ILLUME_ACCESS_CONTROL)
4773      {
4774         if ((unsigned int)e->data.l[0] == sd->x.xwin)
4775           {
4776              if ((unsigned int)e->data.l[1] ==
4777                  ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_NEXT)
4778                {
4779                   // XXX: call right access func
4780                }
4781              else if ((unsigned int)e->data.l[1] ==
4782                       ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_PREV)
4783                {
4784                   // XXX: call right access func
4785                }
4786              else if ((unsigned int)e->data.l[1] ==
4787                       ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_ACTIVATE)
4788                {
4789                   _elm_access_highlight_object_activate
4790                     (sd->obj, EFL_UI_ACTIVATE_DEFAULT);
4791                }
4792              else if ((unsigned int)e->data.l[1] ==
4793                       ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_READ)
4794                {
4795                   /* there would be better way to read highlight object */
4796                   Evas *evas;
4797                   evas = evas_object_evas_get(sd->obj);
4798                   if (!evas) return ECORE_CALLBACK_PASS_ON;
4799
4800                   _elm_access_mouse_event_enabled_set(EINA_TRUE);
4801
4802                   evas_event_feed_mouse_in(evas, 0, NULL);
4803                   evas_event_feed_mouse_move
4804                     (evas, e->data.l[2], e->data.l[3], 0, NULL);
4805
4806                   _elm_access_mouse_event_enabled_set(EINA_FALSE);
4807                }
4808              else if ((unsigned int)e->data.l[1] ==
4809                       ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_READ_NEXT)
4810                {
4811                   _elm_access_highlight_cycle(sd->obj, ELM_FOCUS_NEXT);
4812                }
4813              else if ((unsigned int)e->data.l[1] ==
4814                       ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_READ_PREV)
4815                {
4816                   _elm_access_highlight_cycle(sd->obj, ELM_FOCUS_PREVIOUS);
4817                }
4818              else if ((unsigned int)e->data.l[1] ==
4819                       ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_UP)
4820                {
4821                   _elm_access_highlight_object_activate
4822                     (sd->obj, EFL_UI_ACTIVATE_UP);
4823                }
4824              else if ((unsigned int)e->data.l[1] ==
4825                       ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_DOWN)
4826                {
4827                   _elm_access_highlight_object_activate
4828                     (sd->obj, EFL_UI_ACTIVATE_DOWN);
4829                }
4830           }
4831      }
4832    return ECORE_CALLBACK_PASS_ON;
4833 }
4834
4835 static Eina_Bool
4836 _elm_win_property_change(void *data,
4837                          int type EINA_UNUSED,
4838                          void *event)
4839 {
4840    ELM_WIN_DATA_GET(data, sd);
4841    Ecore_X_Event_Window_Property *e = event;
4842
4843    if (e->atom == ECORE_X_ATOM_E_ILLUME_INDICATOR_STATE)
4844      {
4845         _internal_elm_win_xwindow_get(sd);
4846         if (e->win == sd->x.xwin)
4847           {
4848              sd->legacy.indmode = (Elm_Win_Indicator_Mode)ecore_x_e_illume_indicator_state_get(e->win);
4849              efl_event_callback_legacy_call
4850                (sd->obj, EFL_UI_WIN_EVENT_INDICATOR_PROP_CHANGED, NULL);
4851           }
4852      }
4853    return ECORE_CALLBACK_PASS_ON;
4854 }
4855 #endif
4856
4857 #ifdef HAVE_ELEMENTARY_WIN32
4858 static Eina_Bool
4859 _elm_win_key_down(void *data,
4860                   int type EINA_UNUSED,
4861                   void *event)
4862 {
4863    ELM_WIN_DATA_GET(data, sd);
4864    Ecore_Event_Key *e = event;
4865    if ((e->modifiers & ECORE_EVENT_MODIFIER_ALT) &&
4866        (strcmp(e->key, "F4") == 0))
4867      _elm_win_delete_request(sd->ee);
4868
4869    return ECORE_CALLBACK_PASS_ON;
4870 }
4871
4872 #endif
4873
4874 static void
4875 _elm_win_focus_highlight_hide(void *data EINA_UNUSED,
4876                               Evas_Object *obj,
4877                               const char *emission EINA_UNUSED,
4878                               const char *source EINA_UNUSED)
4879 {
4880    evas_object_hide(obj);
4881 }
4882
4883 static void
4884 _elm_win_focus_highlight_anim_end(void *data,
4885                                   Evas_Object *obj,
4886                                   const char *emission EINA_UNUSED,
4887                                   const char *source EINA_UNUSED)
4888 {
4889    ELM_WIN_DATA_GET(data, sd);
4890
4891    _elm_win_focus_highlight_simple_setup(sd, obj);
4892 }
4893
4894 static void
4895 _elm_win_focus_highlight_init(Efl_Ui_Win_Data *sd)
4896 {
4897    evas_event_callback_add(sd->evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
4898                            _elm_win_object_focus_in, sd->obj);
4899    evas_event_callback_add(sd->evas,
4900                            EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
4901                            _elm_win_object_focus_out, sd->obj);
4902
4903    sd->focus_highlight.cur.target = _elm_win_focus_target_get(evas_focus_get(sd->evas));
4904    if (sd->focus_highlight.cur.target)
4905      {
4906         if (elm_widget_highlight_in_theme_get(sd->focus_highlight.cur.target))
4907           sd->focus_highlight.cur.in_theme = EINA_TRUE;
4908         else
4909           _elm_win_focus_target_callbacks_add(sd);
4910
4911         evas_object_event_callback_add
4912            (sd->focus_highlight.cur.target,
4913             EVAS_CALLBACK_DEL, _elm_win_focus_target_del, sd->obj);
4914      }
4915
4916    sd->focus_highlight.prev.target = NULL;
4917    sd->focus_highlight.theme_changed = EINA_TRUE;
4918    if (!sd->focus_highlight.fobj)
4919      {
4920         sd->focus_highlight.fobj = edje_object_add(sd->evas);
4921
4922         if (elm_widget_is_legacy(sd->obj))
4923           {
4924              edje_object_signal_callback_add(sd->focus_highlight.fobj,
4925                                              "elm,action,focus,hide,end", "*",
4926                                              _elm_win_focus_highlight_hide, NULL);
4927              edje_object_signal_callback_add(sd->focus_highlight.fobj,
4928                                              "elm,action,focus,anim,end", "*",
4929                                              _elm_win_focus_highlight_anim_end, sd->obj);
4930           }
4931         else
4932           {
4933              edje_object_signal_callback_add(sd->focus_highlight.fobj,
4934                                              "efl,focus,visible,off,done", "*",
4935                                              _elm_win_focus_highlight_hide, NULL);
4936              edje_object_signal_callback_add(sd->focus_highlight.fobj,
4937                                              "efl,action,focus,anim,end", "*",
4938                                              _elm_win_focus_highlight_anim_end, sd->obj);
4939           }
4940      }
4941
4942    _elm_win_focus_highlight_reconfigure_job_start(sd);
4943 }
4944
4945 typedef struct _resize_info {
4946    const char *source;
4947    const char *cursor;
4948    Efl_Ui_Win_Move_Resize_Mode mode;
4949    int wl_location;
4950 #ifdef HAVE_ELEMENTARY_X
4951 #define XDIR(d) , ECORE_X_NETWM_DIRECTION_##d
4952    Ecore_X_Netwm_Direction x_dir;
4953 #else
4954 # define XDIR(d)
4955 #endif
4956 } resize_info;
4957
4958 static const resize_info _resize_infos_legacy[8] = {
4959    { "elm.event.resize.t",  ELM_CURSOR_TOP_SIDE, EFL_UI_WIN_MOVE_RESIZE_MODE_TOP, 1 XDIR(SIZE_T) },
4960    { "elm.event.resize.b",  ELM_CURSOR_BOTTOM_SIDE, EFL_UI_WIN_MOVE_RESIZE_MODE_BOTTOM, 2 XDIR(SIZE_B) },
4961    { "elm.event.resize.l",  ELM_CURSOR_LEFT_SIDE, EFL_UI_WIN_MOVE_RESIZE_MODE_LEFT, 4 XDIR(SIZE_L) },
4962    { "elm.event.resize.r",  ELM_CURSOR_RIGHT_SIDE, EFL_UI_WIN_MOVE_RESIZE_MODE_RIGHT, 8 XDIR(SIZE_R) },
4963    { "elm.event.resize.tl", ELM_CURSOR_TOP_LEFT_CORNER, EFL_UI_WIN_MOVE_RESIZE_MODE_TOP | EFL_UI_WIN_MOVE_RESIZE_MODE_LEFT, 5 XDIR(SIZE_TL) },
4964    { "elm.event.resize.bl", ELM_CURSOR_BOTTOM_LEFT_CORNER, EFL_UI_WIN_MOVE_RESIZE_MODE_BOTTOM | EFL_UI_WIN_MOVE_RESIZE_MODE_LEFT, 6 XDIR(SIZE_BL) },
4965    { "elm.event.resize.br", ELM_CURSOR_BOTTOM_RIGHT_CORNER, EFL_UI_WIN_MOVE_RESIZE_MODE_BOTTOM | EFL_UI_WIN_MOVE_RESIZE_MODE_RIGHT, 10 XDIR(SIZE_BR) },
4966    { "elm.event.resize.tr", ELM_CURSOR_TOP_RIGHT_CORNER, EFL_UI_WIN_MOVE_RESIZE_MODE_TOP | EFL_UI_WIN_MOVE_RESIZE_MODE_RIGHT, 9 XDIR(SIZE_TR) },
4967 };
4968
4969 static const resize_info _resize_infos[8] = {
4970    { "efl.event.resize.t",  ELM_CURSOR_TOP_SIDE, EFL_UI_WIN_MOVE_RESIZE_MODE_TOP, 1 XDIR(SIZE_T) },
4971    { "efl.event.resize.b",  ELM_CURSOR_BOTTOM_SIDE, EFL_UI_WIN_MOVE_RESIZE_MODE_BOTTOM, 2 XDIR(SIZE_B) },
4972    { "efl.event.resize.l",  ELM_CURSOR_LEFT_SIDE, EFL_UI_WIN_MOVE_RESIZE_MODE_LEFT, 4 XDIR(SIZE_L) },
4973    { "efl.event.resize.r",  ELM_CURSOR_RIGHT_SIDE, EFL_UI_WIN_MOVE_RESIZE_MODE_RIGHT, 8 XDIR(SIZE_R) },
4974    { "efl.event.resize.tl", ELM_CURSOR_TOP_LEFT_CORNER, EFL_UI_WIN_MOVE_RESIZE_MODE_TOP | EFL_UI_WIN_MOVE_RESIZE_MODE_LEFT, 5 XDIR(SIZE_TL) },
4975    { "efl.event.resize.bl", ELM_CURSOR_BOTTOM_LEFT_CORNER, EFL_UI_WIN_MOVE_RESIZE_MODE_BOTTOM | EFL_UI_WIN_MOVE_RESIZE_MODE_LEFT, 6 XDIR(SIZE_BL) },
4976    { "efl.event.resize.br", ELM_CURSOR_BOTTOM_RIGHT_CORNER, EFL_UI_WIN_MOVE_RESIZE_MODE_BOTTOM | EFL_UI_WIN_MOVE_RESIZE_MODE_RIGHT, 10 XDIR(SIZE_BR) },
4977    { "efl.event.resize.tr", ELM_CURSOR_TOP_RIGHT_CORNER, EFL_UI_WIN_MOVE_RESIZE_MODE_TOP | EFL_UI_WIN_MOVE_RESIZE_MODE_RIGHT, 9 XDIR(SIZE_TR) },
4978 };
4979
4980 static inline Efl_Ui_Win_Move_Resize_Mode
4981 _move_resize_mode_rotate(int rotation, Efl_Ui_Win_Move_Resize_Mode mode)
4982 {
4983    const Efl_Ui_Win_Move_Resize_Mode edges[4] = {
4984       EFL_UI_WIN_MOVE_RESIZE_MODE_TOP,    EFL_UI_WIN_MOVE_RESIZE_MODE_LEFT,
4985       EFL_UI_WIN_MOVE_RESIZE_MODE_BOTTOM, EFL_UI_WIN_MOVE_RESIZE_MODE_RIGHT
4986    };
4987
4988    const Efl_Ui_Win_Move_Resize_Mode corners[4] = {
4989       EFL_UI_WIN_MOVE_RESIZE_MODE_TOP    | EFL_UI_WIN_MOVE_RESIZE_MODE_LEFT,
4990       EFL_UI_WIN_MOVE_RESIZE_MODE_BOTTOM | EFL_UI_WIN_MOVE_RESIZE_MODE_LEFT,
4991       EFL_UI_WIN_MOVE_RESIZE_MODE_BOTTOM | EFL_UI_WIN_MOVE_RESIZE_MODE_RIGHT,
4992       EFL_UI_WIN_MOVE_RESIZE_MODE_TOP    | EFL_UI_WIN_MOVE_RESIZE_MODE_RIGHT,
4993    };
4994
4995    const int i = rotation / 90;
4996    int k;
4997
4998    for (k = 0; k < 4; k++)
4999      if (mode == edges[k])
5000        return edges[(k + i) % 4];
5001
5002    for (k = 0; k < 4; k++)
5003      if (mode == corners[k])
5004        return corners[(k + i) % 4];
5005
5006    return EFL_UI_WIN_MOVE_RESIZE_MODE_MOVE;
5007 }
5008
5009 static const resize_info *
5010 _resize_info_get(Evas_Object *obj, int rotation, Efl_Ui_Win_Move_Resize_Mode mode)
5011 {
5012    if (rotation)
5013      return _resize_info_get(obj, 0, _move_resize_mode_rotate(rotation, mode));
5014
5015    if (elm_widget_is_legacy(obj))
5016      {
5017         for (size_t k = 0; k < EINA_C_ARRAY_LENGTH(_resize_infos_legacy); k++)
5018           {
5019              if (_resize_infos_legacy[k].mode == mode)
5020                return &_resize_infos_legacy[k];
5021           }
5022      }
5023    else
5024      {
5025         for (size_t k = 0; k < EINA_C_ARRAY_LENGTH(_resize_infos); k++)
5026           {
5027              if (_resize_infos[k].mode == mode)
5028                return &_resize_infos[k];
5029           }
5030      }
5031
5032    return NULL;
5033 }
5034
5035 static Efl_Ui_Win_Move_Resize_Mode
5036 _move_resize_mode_get(Evas_Object *obj, const char *source)
5037 {
5038    if (elm_widget_is_legacy(obj))
5039      {
5040         for (size_t k = 0; k < EINA_C_ARRAY_LENGTH(_resize_infos_legacy); k++)
5041           if (!strcmp(source, _resize_infos_legacy[k].source))
5042             return _resize_infos_legacy[k].mode;
5043      }
5044    else
5045      {
5046         for (size_t k = 0; k < EINA_C_ARRAY_LENGTH(_resize_infos); k++)
5047           if (!strcmp(source, _resize_infos[k].source))
5048             return _resize_infos[k].mode;
5049      }
5050
5051    return EFL_UI_WIN_MOVE_RESIZE_MODE_MOVE;
5052 }
5053
5054 static void
5055 _elm_win_frame_obj_move(void *data,
5056                         Evas *e EINA_UNUSED,
5057                         Evas_Object *obj EINA_UNUSED,
5058                         void *event_info EINA_UNUSED)
5059 {
5060    Efl_Ui_Win_Data *sd;
5061
5062    if (!(sd = data)) return;
5063    if (!sd->legacy.edje) return;
5064
5065    _elm_win_frame_obj_update(sd, 0);
5066 }
5067
5068 static void
5069 _elm_win_frame_obj_resize(void *data,
5070                           Evas *e EINA_UNUSED,
5071                           Evas_Object *obj EINA_UNUSED,
5072                           void *event_info EINA_UNUSED)
5073 {
5074    Efl_Ui_Win_Data *sd;
5075
5076    if (!(sd = data)) return;
5077    if (!sd->legacy.edje) return;
5078
5079    _elm_win_frame_obj_update(sd, 0);
5080 }
5081
5082 static void
5083 _elm_win_frame_cb_resize_show(void *data,
5084                               Evas_Object *obj EINA_UNUSED,
5085                               const char *sig EINA_UNUSED,
5086                               const char *source)
5087 {
5088    ELM_WIN_DATA_GET(data, sd);
5089
5090    if (!sd) return;
5091    if (sd->resizing) return;
5092
5093 #ifdef HAVE_ELEMENTARY_WL2
5094    if (sd->pointer.obj)
5095      {
5096         Efl_Ui_Win_Move_Resize_Mode mode = _move_resize_mode_get(sd->obj, source);
5097         const resize_info *ri = _resize_info_get(sd->obj, sd->rot, mode);
5098         if (ri) elm_widget_theme_object_set(sd->obj, sd->pointer.obj, "pointer", "base", ri->cursor);
5099      }
5100 #else
5101    (void)source;
5102 #endif
5103 }
5104
5105 static void
5106 _elm_win_frame_cb_resize_hide(void *data,
5107                               Evas_Object *obj EINA_UNUSED,
5108                               const char *sig EINA_UNUSED,
5109                               const char *source EINA_UNUSED)
5110 {
5111    ELM_WIN_DATA_GET(data, sd);
5112
5113    if (!sd) return;
5114    if (sd->resizing) return;
5115
5116 #ifdef HAVE_ELEMENTARY_WL2
5117    if (sd->pointer.obj)
5118      elm_widget_theme_object_set(sd->obj, sd->pointer.obj,
5119                            "pointer", "base", "default");
5120 #endif
5121 }
5122
5123 #ifdef HAVE_ELEMENTARY_WL2
5124 /* This only works when called from an edje event
5125  * that propagates seat info...
5126  */
5127 static Ecore_Wl2_Input *
5128 _elm_win_wayland_input_get(Efl_Ui_Win_Data *sd)
5129 {
5130    Ecore_Wl2_Display *di;
5131    char *sname;
5132    const char *engine;
5133
5134    engine = ecore_evas_engine_name_get(sd->ee);
5135    if (strcmp(engine, ELM_WAYLAND_SHM) &&
5136        strcmp(engine, ELM_WAYLAND_EGL))
5137      return NULL;
5138
5139    di = ecore_wl2_window_display_get(sd->wl.win);
5140
5141    sname = edje_object_signal_callback_seat_data_get();
5142    if (!sname) return NULL;
5143    return ecore_wl2_display_input_find_by_name(di, sname);
5144 }
5145 #endif
5146
5147 static inline Eina_Bool
5148 _win_move_start(Efl_Ui_Win_Data *sd)
5149 {
5150 #ifdef HAVE_ELEMENTARY_WL2
5151    if (sd->wl.win)
5152      {
5153         Ecore_Wl2_Input *ei;
5154
5155         ei = _elm_win_wayland_input_get(sd);
5156         ecore_wl2_window_move(sd->wl.win, ei);
5157         return EINA_TRUE;
5158      }
5159 #endif
5160
5161 #ifdef HAVE_ELEMENTARY_X
5162    if (sd->x.xwin)
5163      {
5164         int x, y;
5165
5166         _internal_elm_win_xwindow_get(sd);
5167         sd->resizing = EINA_TRUE;
5168         ecore_x_pointer_ungrab();
5169         ecore_x_pointer_root_xy_get(&x, &y);
5170         ecore_x_netwm_moveresize_request_send(sd->x.xwin, x, y,
5171                                               ECORE_X_NETWM_DIRECTION_MOVE, 1);
5172         return EINA_TRUE;
5173      }
5174 #endif
5175
5176    INF("Window move request not supported for this window!");
5177    return EINA_FALSE;
5178 }
5179
5180 static Eina_Bool
5181 _win_move_resize_start(Efl_Ui_Win_Data *sd, Efl_Ui_Win_Move_Resize_Mode mode)
5182 {
5183    EINA_SAFETY_ON_NULL_RETURN_VAL(sd, EINA_FALSE);
5184    const resize_info *ri;
5185
5186    // 2. check move_resize already started
5187    if (sd->resizing)
5188      {
5189         ERR("Window is already being resized.");
5190         return EINA_FALSE;
5191      }
5192
5193    if (mode == EFL_UI_WIN_MOVE_RESIZE_MODE_MOVE)
5194      return _win_move_start(sd);
5195
5196    ri = _resize_info_get(sd->obj, sd->rot, mode);
5197    if (!ri)
5198      {
5199         ERR("Unsupported move_resize mode %#x", (int) mode);
5200         return EINA_FALSE;
5201      }
5202
5203    sd->resizing = EINA_TRUE;
5204
5205 #ifdef HAVE_ELEMENTARY_WL2
5206    if (sd->wl.win)
5207      {
5208         Ecore_Wl2_Input *ei;
5209
5210         ei = _elm_win_wayland_input_get(sd);
5211         ecore_wl2_window_resize(sd->wl.win, ei, ri->wl_location);
5212         return EINA_TRUE;
5213      }
5214 #endif
5215
5216 #ifdef HAVE_ELEMENTARY_X
5217    if (sd->x.xwin)
5218      {
5219         int x, y;
5220         _internal_elm_win_xwindow_get(sd);
5221         ecore_x_pointer_ungrab();
5222         ecore_x_pointer_root_xy_get(&x, &y);
5223         ecore_x_netwm_moveresize_request_send(sd->x.xwin, x, y, ri->x_dir, 1);
5224         return EINA_TRUE;
5225      }
5226 #endif
5227
5228    INF("Window resize request not supported for this window!");
5229    return EINA_FALSE;
5230 }
5231 // TIZEN_ONLY(20171114) Accessibility Highlight Frame added
5232 static void
5233 _elm_win_accessibility_highlight_init(Efl_Ui_Win_Data *sd, Evas_Object *atarget)
5234 {
5235    sd->accessibility_highlight.cur.target = atarget;
5236
5237    sd->accessibility_highlight.prev.target = NULL;
5238    sd->accessibility_highlight.fobj = edje_object_add(sd->evas);
5239    if (atarget)
5240       _elm_win_accessibility_highlight_callbacks_add(sd);
5241 }
5242 //
5243
5244 static void
5245 _elm_win_frame_cb_move_start(void *data,
5246                              Evas_Object *obj EINA_UNUSED,
5247                              const char *sig EINA_UNUSED,
5248                              const char *source EINA_UNUSED)
5249 {
5250    ELM_WIN_DATA_GET_OR_RETURN(data, sd);
5251
5252    _win_move_resize_start(sd, EFL_UI_WIN_MOVE_RESIZE_MODE_MOVE);
5253 }
5254
5255 static void
5256 _elm_win_frame_cb_resize_start(void *data, Evas_Object *obj EINA_UNUSED,
5257                                const char *sig EINA_UNUSED, const char *source)
5258 {
5259    ELM_WIN_DATA_GET_OR_RETURN(data, sd);
5260    Efl_Ui_Win_Move_Resize_Mode mode;
5261
5262    mode = _move_resize_mode_get(sd->obj, source);
5263    if (mode == EFL_UI_WIN_MOVE_RESIZE_MODE_MOVE) return;
5264
5265    _win_move_resize_start(sd, mode);
5266 }
5267
5268 //TIZEN_ONLY(20180131):Added resize,end signal for mouse up
5269 static void
5270 _elm_win_frame_cb_resize_end(void *data,
5271                              Evas_Object *obj EINA_UNUSED,
5272                              const char *sig EINA_UNUSED,
5273                              const char *source EINA_UNUSED)
5274 {
5275 #ifdef HAVE_ELEMENTARY_WL2
5276    ELM_WIN_DATA_GET(data, sd);
5277
5278    if (!sd) return;
5279    if (sd->resizing) sd->resizing = EINA_FALSE;
5280 #else
5281    (void)data;
5282 #endif
5283 }
5284 //
5285 static void
5286 _elm_win_frame_cb_minimize(void *data,
5287                            Evas_Object *obj EINA_UNUSED,
5288                            const char *sig EINA_UNUSED,
5289                            const char *source EINA_UNUSED)
5290 {
5291    ELM_WIN_DATA_GET(data, sd);
5292
5293    if (!sd) return;
5294 //   sd->minimized = EINA_TRUE;
5295    TRAP(sd, iconified_set, EINA_TRUE);
5296 }
5297
5298 static void
5299 _elm_win_frame_cb_maximize(void *data,
5300                            Evas_Object *obj EINA_UNUSED,
5301                            const char *sig EINA_UNUSED,
5302                            const char *source EINA_UNUSED)
5303 {
5304    Eina_Bool value;
5305    ELM_WIN_DATA_GET(data, sd);
5306
5307    if (!sd) return;
5308    if (sd->maximized) value = EINA_FALSE;
5309    else value = EINA_TRUE;
5310
5311    efl_ui_win_maximized_set(sd->obj, value);
5312 }
5313
5314 static void
5315 _elm_win_frame_cb_menu(void *data,
5316                         Evas_Object *obj EINA_UNUSED,
5317                         const char *sig EINA_UNUSED,
5318                         const char *source EINA_UNUSED)
5319 {
5320    ELM_WIN_DATA_GET(data, sd);
5321 #ifdef HAVE_ELEMENTARY_WL2
5322    Ecore_Wl2_Input *input;
5323    int x, y, wx, wy;
5324
5325    if (!sd->wl.win) return;
5326    evas_pointer_canvas_xy_get(sd->evas, &x, &y);
5327    ecore_wl2_window_geometry_get(sd->wl.win, &wx, &wy, NULL, NULL);
5328    if (x < 0) x += wx;
5329    if (y < 0) y += wy;
5330
5331    {
5332       Eina_Iterator *it;
5333       Ecore_Wl2_Display *display = ecore_wl2_window_display_get(sd->wl.win);
5334       it = ecore_wl2_display_inputs_get(display);
5335       EINA_ITERATOR_FOREACH(it, input) break;
5336       eina_iterator_free(it);
5337    }
5338    if (sd->wl.win->xdg_toplevel)
5339      {
5340         xdg_toplevel_show_window_menu(sd->wl.win->xdg_toplevel,
5341                                        ecore_wl2_input_seat_get(input), 0, x, y);
5342         ecore_wl2_display_flush(input->display);
5343      }
5344    else if (sd->wl.win->zxdg_toplevel)
5345      {
5346         zxdg_toplevel_v6_show_window_menu(sd->wl.win->zxdg_toplevel,
5347                                        ecore_wl2_input_seat_get(input), 0, x, y);
5348         ecore_wl2_display_flush(input->display);
5349      }
5350 #else
5351    (void)sd;
5352 #endif
5353 }
5354 static void
5355 _elm_win_frame_cb_close(void *data,
5356                         Evas_Object *obj EINA_UNUSED,
5357                         const char *sig EINA_UNUSED,
5358                         const char *source EINA_UNUSED)
5359 {
5360    ELM_WIN_DATA_GET(data, sd);
5361    Evas_Object *win;
5362
5363    /* FIXME: After the current freeze, this should be handled differently.
5364     *
5365     * Ideally, we would want to mimic the X11 backend and use something
5366     * like ECORE_WL_EVENT_WINDOW_DELETE and handle the delete_request
5367     * inside of ecore_evas. That would be the 'proper' way, but since we are
5368     * in a freeze right now, I cannot add a new event value, or a new
5369     * event structure to ecore_wayland.
5370     *
5371     * So yes, this is a temporary 'stop-gap' solution which will be fixed
5372     * when the freeze is over, but it does fix a trac bug for now, and in a
5373     * way which does not break API or the freeze. - dh
5374     */
5375
5376    if (!sd) return;
5377
5378    win = sd->obj;
5379
5380    int autodel = sd->autodel;
5381    sd->autodel_clear = &autodel;
5382    evas_object_ref(win);
5383    efl_event_callback_legacy_call(win, EFL_UI_WIN_EVENT_DELETE_REQUEST, NULL);
5384    if (sd->autohide)
5385      evas_object_hide(win);
5386    // FIXME: if above callback deletes - then the below will be invalid
5387    if (autodel) evas_object_del(win);
5388    else sd->autodel_clear = NULL;
5389    evas_object_unref(win);
5390 }
5391
5392 #ifdef HAVE_ELEMENTARY_WL2
5393 static Eina_Bool
5394 _elm_win_wl_configure(void *data, int t EINA_UNUSED, void *event)
5395 {
5396    Ecore_Wl2_Event_Window_Configure *ev = event;
5397    ELM_WIN_DATA_GET(data, sd);
5398    if (ecore_wl2_window_id_get(sd->wl.win) != (int)ev->win) return ECORE_CALLBACK_RENEW;
5399
5400    if (sd->resizing && (!ev->edges)) sd->resizing = EINA_FALSE;
5401    return ECORE_CALLBACK_RENEW;
5402 }
5403
5404 //TIZEN_ONLY(20171110): added signal for effect start and done
5405 static Eina_Bool
5406 _elm_win_wl_effect_start(void *data, int type EINA_UNUSED, void *event)
5407 {
5408    ELM_WIN_DATA_GET(data, sd);
5409    Ecore_Wl2_Event_Effect_Start *e = event;
5410
5411    if (!sd->wl.win) return ECORE_CALLBACK_PASS_ON;
5412
5413    if (ecore_wl2_window_id_get(sd->wl.win) != (int)e->win)
5414      return ECORE_CALLBACK_PASS_ON;
5415
5416    evas_object_smart_callback_call(data, SIG_EFFECT_STARTED, (void*)e->type);
5417
5418    return ECORE_CALLBACK_PASS_ON;
5419 }
5420
5421 static Eina_Bool
5422 _elm_win_wl_effect_end(void *data, int type EINA_UNUSED, void *event)
5423 {
5424    ELM_WIN_DATA_GET(data, sd);
5425    Ecore_Wl2_Event_Effect_Start *e = event;
5426    unsigned int eff_type;
5427
5428    if (!sd->wl.win) return ECORE_CALLBACK_PASS_ON;
5429
5430    if (ecore_wl2_window_id_get(sd->wl.win) != (int)e->win)
5431      return ECORE_CALLBACK_PASS_ON;
5432
5433    /* TIZEN_ONLY(20160704): added signal for launch */
5434    eff_type = e->type;
5435    if (eff_type == 4)
5436      evas_object_smart_callback_call(data, SIG_LAUNCH_DONE, (void*)e->type);
5437    else
5438    /* end of TIZEN_ONLY(20160704): added signal for launch*/
5439      evas_object_smart_callback_call(data, SIG_EFFECT_DONE, (void*)e->type);
5440
5441    return ECORE_CALLBACK_PASS_ON;
5442 }
5443 // end of TIZEN_ONLY(20171110): added signal for effect start and done
5444 #endif
5445
5446 static inline void
5447 _elm_object_part_cursor_set(Evas_Object *obj, Evas_Object *edj,
5448                             const char *part, const char *cursor)
5449 {
5450    Evas_Object *sub;
5451
5452    edje_object_freeze(edj);
5453    sub = (Evas_Object *)edje_object_part_object_get(edj, part);
5454    edje_object_thaw(edj);
5455    if (!sub) return;
5456
5457    elm_object_sub_cursor_set(sub, obj, cursor);
5458 }
5459
5460 static char *
5461 _efl_system_theme_path_get(void)
5462 {
5463    // Find the default theme from EFL install. Quite ugly.
5464    const char *sysdir;
5465    char *version;
5466    char path[PATH_MAX];
5467    int v;
5468
5469    sysdir = elm_theme_system_dir_get();
5470    if (!sysdir) return NULL;
5471
5472    eina_file_path_join(path, PATH_MAX, sysdir, "default.edj");
5473    version = edje_file_data_get(path, "version");
5474    v = version ? atoi(version) : 0;
5475    free(version);
5476    if (v < FRAME_OBJ_THEME_MIN_VERSION)
5477      {
5478         ERR("Default system theme is too old, something is wrong with your installation of EFL.");
5479         return NULL;
5480      }
5481    return strdup(path);
5482 }
5483
5484 static void
5485 _elm_win_frame_add(Efl_Ui_Win_Data *sd, const char *element, const char *style)
5486 {
5487    Evas_Object *obj = sd->obj;
5488    int w, h, v;
5489    const char *version;
5490
5491    if (sd->frame_obj) return;
5492
5493    sd->frame_obj = edje_object_add(sd->evas);
5494
5495    // Verify theme version. Border requires an exact theme API.
5496    version = elm_theme_data_get(elm_widget_theme_get(sd->obj), "version");
5497    v = version ? atoi(version) : 0;
5498    if (EINA_LIKELY(v >= FRAME_OBJ_THEME_MIN_VERSION))
5499      {
5500         if (elm_widget_theme_object_set
5501             (sd->obj, sd->frame_obj, "border", element, style) == EFL_UI_THEME_APPLY_ERROR_GENERIC)
5502           {
5503              ERR("Failed to set main border theme for the window.");
5504              ELM_SAFE_FREE(sd->frame_obj, evas_object_del);
5505              return;
5506           }
5507
5508         // Verify border.edc version as well
5509         version = edje_object_data_get(sd->frame_obj, "version");
5510         v = version ? atoi(version) : 0;
5511      }
5512
5513    if (v < FRAME_OBJ_THEME_MIN_VERSION)
5514      {
5515         // Theme compatibility
5516         const char *key  = "elm/border/base/default"; // FIXME?
5517         char *sys_theme;
5518
5519         WRN("Selected theme does not support the required border theme API "
5520             "(version = %d, requires >= %d).",
5521             v, FRAME_OBJ_THEME_MIN_VERSION);
5522         sys_theme = _efl_system_theme_path_get();
5523         if (!sys_theme ||
5524             !edje_object_file_set(sd->frame_obj, sys_theme, key))
5525           {
5526              ERR("Failed to set main border theme for the window.");
5527              ELM_SAFE_FREE(sd->frame_obj, evas_object_del);
5528              free(sys_theme);
5529              return;
5530           }
5531         free(sys_theme);
5532      }
5533
5534    edje_object_freeze(sd->frame_obj);
5535    /* Small hack: The special value 2 means this is the top frame object.
5536     * We propagate to the children now (the edc group contents), but subsequent
5537     * calls to smart_member_add will not propagate the flag further. Note that
5538     * this little hack will fall apart if edje creates and destroys objects on
5539     * the fly. */
5540    efl_canvas_object_is_frame_object_set(sd->frame_obj, 2);
5541
5542    if (elm_widget_is_legacy(sd->obj))
5543      edje_object_part_swallow(sd->frame_obj, "elm.swallow.client", sd->legacy.edje);
5544    else
5545      edje_object_part_swallow(sd->frame_obj, "efl.client", sd->legacy.edje);
5546
5547    /* TIZEN_ONLY(20180427): disable unnecessary parts.
5548    if (sd->icon)
5549      evas_object_show(sd->icon);
5550    else
5551      {
5552         Eina_Bool set = EINA_FALSE;
5553         Eina_Bool legacy = elm_widget_is_legacy(sd->obj);
5554
5555         if (legacy)
5556           sd->icon = elm_icon_add(sd->obj);
5557         else
5558           sd->icon = efl_add(EFL_UI_IMAGE_CLASS, sd->obj);
5559
5560         if (sd->icon_name)
5561           {
5562              if (legacy)
5563                set = elm_icon_standard_set(sd->icon, sd->icon_name);
5564              else
5565                set = efl_ui_image_icon_set(sd->icon, sd->icon_name);
5566           }
5567         if (((!sd->icon_name) || (!set)) && _elm_appname)
5568           {
5569              Efreet_Desktop *d;
5570              d = efreet_util_desktop_exec_find(_elm_appname);
5571              if (d)
5572                {
5573                   if (legacy)
5574                     elm_icon_standard_set(sd->icon, d->icon);
5575                   else
5576                     efl_ui_image_icon_set(sd->icon, d->icon);
5577                   efreet_desktop_free(d);
5578                }
5579           }
5580      }
5581
5582    if (elm_widget_is_legacy(sd->obj))
5583      edje_object_part_swallow(sd->frame_obj, "elm.swallow.icon", sd->icon);
5584    else
5585      edje_object_part_swallow(sd->frame_obj, "efl.icon", sd->icon);
5586
5587    efl_canvas_object_is_frame_object_set(sd->icon, EINA_TRUE);
5588    */
5589
5590    evas_object_event_callback_add
5591      (sd->frame_obj, EVAS_CALLBACK_MOVE, _elm_win_frame_obj_move, sd);
5592    evas_object_event_callback_add
5593      (sd->frame_obj, EVAS_CALLBACK_RESIZE, _elm_win_frame_obj_resize, sd);
5594
5595    if (elm_widget_is_legacy(sd->obj))
5596      {
5597         edje_object_signal_callback_add
5598            (sd->frame_obj, "elm,action,move,start", "elm",
5599             _elm_win_frame_cb_move_start, obj);
5600         edje_object_signal_callback_add
5601            (sd->frame_obj, "elm,action,resize,show", "*",
5602             _elm_win_frame_cb_resize_show, obj);
5603         edje_object_signal_callback_add
5604            (sd->frame_obj, "elm,action,resize,hide", "*",
5605             _elm_win_frame_cb_resize_hide, obj);
5606         edje_object_signal_callback_add
5607            (sd->frame_obj, "elm,action,resize,start", "*",
5608             _elm_win_frame_cb_resize_start, obj);
5609 //TIZEN_ONLY(20180131):Added resize,end signal for mouse up
5610         edje_object_signal_callback_add
5611            (sd->frame_obj, "elm,action,resize,end", "*",
5612            _elm_win_frame_cb_resize_end, obj);
5613 //
5614         edje_object_signal_callback_add
5615            (sd->frame_obj, "elm,action,minimize", "elm",
5616             _elm_win_frame_cb_minimize, obj);
5617         edje_object_signal_callback_add
5618            (sd->frame_obj, "elm,action,maximize", "elm",
5619             _elm_win_frame_cb_maximize, obj);
5620         edje_object_signal_callback_add
5621            (sd->frame_obj, "elm,action,close", "elm",
5622             _elm_win_frame_cb_close, obj);
5623         edje_object_signal_callback_add
5624            (sd->frame_obj, "elm,action,menu", "elm",
5625             _elm_win_frame_cb_menu, obj);
5626      }
5627    else
5628      {
5629         edje_object_signal_callback_add
5630            (sd->frame_obj, "efl,action,move,start", "efl",
5631             _elm_win_frame_cb_move_start, obj);
5632         edje_object_signal_callback_add
5633            (sd->frame_obj, "efl,action,resize,show", "*",
5634             _elm_win_frame_cb_resize_show, obj);
5635         edje_object_signal_callback_add
5636            (sd->frame_obj, "efl,action,resize,hide", "*",
5637             _elm_win_frame_cb_resize_hide, obj);
5638         edje_object_signal_callback_add
5639            (sd->frame_obj, "efl,action,resize,start", "*",
5640             _elm_win_frame_cb_resize_start, obj);
5641 //TIZEN_ONLY(20180131):Added resize,end signal for mouse up
5642         edje_object_signal_callback_add
5643            (sd->frame_obj, "efl,action,resize,end", "*",
5644            _elm_win_frame_cb_resize_end, obj);
5645 //
5646         edje_object_signal_callback_add
5647            (sd->frame_obj, "efl,action,minimize", "efl",
5648             _elm_win_frame_cb_minimize, obj);
5649         edje_object_signal_callback_add
5650            (sd->frame_obj, "efl,action,maximize", "efl",
5651             _elm_win_frame_cb_maximize, obj);
5652         edje_object_signal_callback_add
5653            (sd->frame_obj, "efl,action,close", "efl",
5654             _elm_win_frame_cb_close, obj);
5655         edje_object_signal_callback_add
5656            (sd->frame_obj, "efl,action,menu", "efl",
5657             _elm_win_frame_cb_menu, obj);
5658      }
5659
5660    if (!sd->pointer.obj)
5661      {
5662         if (elm_widget_is_legacy(obj))
5663           {
5664              for (size_t k = 0; k < EINA_C_ARRAY_LENGTH(_resize_infos_legacy); k++)
5665                {
5666                   const resize_info *ri = &_resize_infos_legacy[k];
5667                   _elm_object_part_cursor_set(obj, sd->frame_obj, ri->source, ri->cursor);
5668                }
5669           }
5670         else
5671           {
5672              for (size_t k = 0; k < EINA_C_ARRAY_LENGTH(_resize_infos); k++)
5673                {
5674                   const resize_info *ri = &_resize_infos[k];
5675                   _elm_object_part_cursor_set(obj, sd->frame_obj, ri->source, ri->cursor);
5676                }
5677           }
5678      }
5679
5680    if (sd->title)
5681      {
5682         if (elm_widget_is_legacy(sd->obj))
5683           edje_object_part_text_escaped_set(sd->frame_obj, "elm.text.title", sd->title);
5684         else
5685           edje_object_part_text_escaped_set(sd->frame_obj, "efl.text.title", sd->title);
5686      }
5687
5688    {
5689       // HACK: Force render mode of bg rect to COPY. This avoids render garbage.
5690       Eo *bgrect;
5691       if (elm_widget_is_legacy(sd->obj))
5692         bgrect = (Eo *) edje_object_part_object_get(sd->frame_obj, "elm.rect.background");
5693       else
5694         bgrect = (Eo *) edje_object_part_object_get(sd->frame_obj, "efl.rect.background");
5695
5696       efl_canvas_object_render_op_set(bgrect, EFL_GFX_RENDER_OP_COPY);
5697    }
5698
5699    if (sd->first_draw)
5700      edje_object_thaw(sd->frame_obj);
5701    if (!efl_finalized_get(obj)) return;
5702    _elm_win_frame_style_update(sd, 1, 1);
5703    _elm_win_frame_geometry_adjust(sd);
5704    ecore_evas_geometry_get(sd->ee, NULL, NULL, &w, &h);
5705    if ((w > 1) && (h > 1))
5706      {
5707         ecore_evas_resize(sd->ee, w, h);
5708      }
5709 }
5710
5711 static void
5712 _elm_win_frame_style_update(Efl_Ui_Win_Data *sd, Eina_Bool force_emit, Eina_Bool calc)
5713 {
5714    Eina_Bool borderless, maximized, shadow, focus, bg_solid, menu, unresizable,
5715          alpha, bg_standard, indicator;
5716    Eina_Bool changed = EINA_FALSE;
5717
5718    if (!sd->frame_obj)
5719      {
5720         if (!efl_finalized_get(sd->obj)) return;
5721         if (EINA_LIKELY(sd->type == EFL_UI_WIN_TYPE_FAKE))
5722           return;
5723         if (!_elm_config->win_no_border)
5724           CRI("Window has no frame object!");
5725         return;
5726      }
5727
5728    if ((sd->type == ELM_WIN_INLINED_IMAGE) ||
5729        (sd->type == ELM_WIN_SOCKET_IMAGE) ||
5730        (sd->type == ELM_WIN_TOOLTIP) ||
5731        (sd->type == ELM_WIN_COMBO) ||
5732        (sd->type == ELM_WIN_MENU) ||
5733        (sd->type == ELM_WIN_POPUP_MENU))
5734      {
5735         sd->csd.need_shadow = EINA_FALSE;
5736         sd->csd.need_borderless = EINA_TRUE;
5737         sd->csd.need_unresizable = EINA_TRUE;
5738         sd->csd.need_menu = EINA_FALSE;
5739         sd->csd.need_indicator = EINA_FALSE;
5740      }
5741    else if (_elm_config->win_no_border)
5742      sd->csd.need_borderless = EINA_TRUE;
5743    else
5744      {
5745         sd->csd.need_shadow = sd->csd.need && (!sd->maximized);
5746      }
5747
5748    alpha = sd->application_alpha || sd->theme_alpha;
5749    borderless = sd->csd.need_borderless || (!sd->csd.need) || sd->fullscreen;
5750    maximized = sd->maximized;
5751    shadow = sd->csd.need_shadow && (!sd->fullscreen) && (!sd->maximized) && (!borderless);
5752    if (alpha && borderless) shadow = 0;
5753 #ifdef HAVE_ELEMENTARY_WL2
5754    if (sd->wl.win)
5755      focus = ecore_wl2_window_activated_get(sd->wl.win);
5756    else
5757 #endif
5758    focus = ecore_evas_focus_get(sd->ee);
5759    bg_standard = sd->csd.need_bg_standard;
5760    unresizable = sd->csd.need_unresizable;
5761    menu = sd->csd.need_menu;
5762    indicator = sd->csd.need_indicator;
5763    bg_solid = sd->csd.need_bg_solid;
5764    /* Set background transparent if window supports alpha.
5765     * If alpha window does not emit signal to show background rectangle, then
5766     * the background color set by _efl_ui_win_part_color_set cannot be applied
5767     * because the background rectangle remains hidden.
5768     */
5769    if (alpha && bg_solid && !(sd->csd.cur_bg_solid))
5770      edje_object_color_class_set(sd->frame_obj, "elm/win/background", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
5771
5772    /* FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME
5773     * At the moment, E Wayland uses SSD for its internal windows. Which means
5774     * we must hide the shadow if the borderless flag is set. "trap" here means
5775     * we are likely to be running inside E compositor.
5776     * FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME FIXME */
5777    if (trap && sd->csd.wayland && sd->csd.need_borderless)
5778      shadow = 0;
5779
5780 #define STATE_SET(state, s1, s2, s3) do { \
5781    if (force_emit || (state != sd->csd.cur_##state)) \
5782      { \
5783         const char *sig = state ? s1 : s2; \
5784         edje_object_signal_emit(sd->frame_obj, sig, s3); \
5785         DBG("frame style emit: %p %s", sd->obj, sig); \
5786         sd->csd.cur_##state = state; \
5787         changed = EINA_TRUE; \
5788      } } while (0)
5789
5790    if (elm_widget_is_legacy(sd->obj))
5791      {
5792         STATE_SET(borderless, "elm,state,borderless,on", "elm,state,borderless,off", "elm");
5793         STATE_SET(shadow, "elm,state,shadow,on", "elm,state,shadow,off", "elm");
5794         STATE_SET(maximized, "elm,state,maximized", "elm,state,unmaximized", "elm");
5795         STATE_SET(focus, "elm,action,focus", "elm,action,unfocus", "elm");
5796         STATE_SET(bg_solid, "elm,state,background,solid,on", "elm,state,background,solid,off", "elm");
5797         STATE_SET(bg_standard, "elm,state,background,standard,on", "elm,state,background,standard,off", "elm");
5798         STATE_SET(unresizable, "elm,state,unresizable,on", "elm,state,unresizable,off", "elm");
5799         STATE_SET(menu, "elm,action,show_menu", "elm,action,hide_menu", "elm");
5800         STATE_SET(indicator, "elm,action,show_indicator", "elm,action,hide_indicator", "elm");
5801      }
5802    else
5803      {
5804         STATE_SET(borderless, "efl,state,borderless,on", "efl,state,borderless,off", "efl");
5805         STATE_SET(shadow, "efl,state,shadow,on", "efl,state,shadow,off", "efl");
5806         STATE_SET(maximized, "efl,state,maximized", "efl,state,unmaximized", "efl");
5807         STATE_SET(focus, "efl,action,focus", "efl,action,unfocus", "efl");
5808         STATE_SET(bg_solid, "efl,state,background,solid,on", "efl,state,background,solid,off", "efl");
5809         STATE_SET(bg_standard, "efl,state,background,standard,on", "efl,state,background,standard,off", "efl");
5810         STATE_SET(unresizable, "efl,state,unresizable,on", "efl,state,unresizable,off", "efl");
5811         STATE_SET(menu, "efl,action,show_menu", "efl,action,hide_menu", "efl");
5812         STATE_SET(indicator, "efl,action,show_indicator", "efl,action,hide_indicator", "efl");
5813      }
5814
5815 #undef STATE_SET
5816
5817    if (changed)
5818      {
5819         if (calc || force_emit)
5820           edje_object_message_signal_process(sd->frame_obj);
5821         if (calc)
5822           evas_object_smart_calculate(sd->frame_obj);
5823         _elm_win_frame_obj_update(sd, 0);
5824      }
5825 }
5826
5827 #ifdef ELM_DEBUG
5828 static void
5829 _debug_key_down(void *data EINA_UNUSED,
5830                 Evas *e EINA_UNUSED,
5831                 Evas_Object *obj,
5832                 void *event_info)
5833 {
5834    Evas_Event_Key_Down *ev = event_info;
5835
5836    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
5837      return;
5838
5839    if ((strcmp(ev->key, "F12")) ||
5840        (!evas_key_modifier_is_set(ev->modifiers, "Control")))
5841      return;
5842
5843    INF("Tree graph generated.");
5844    elm_object_tree_dot_dump(obj, "./dump.dot");
5845 }
5846
5847 #endif
5848
5849 static void
5850 _win_inlined_image_set(Efl_Ui_Win_Data *sd)
5851 {
5852    evas_object_image_alpha_set(sd->img_obj, EINA_FALSE);
5853    evas_object_image_filled_set(sd->img_obj, EINA_TRUE);
5854
5855    evas_object_event_callback_add
5856      (sd->img_obj, EVAS_CALLBACK_DEL, _elm_win_on_img_obj_del, sd->obj);
5857    evas_object_event_callback_add
5858      (sd->img_obj, EVAS_CALLBACK_HIDE, _win_img_hide, sd->obj);
5859    evas_object_event_callback_add
5860      (sd->img_obj, EVAS_CALLBACK_MOUSE_UP, _win_img_mouse_up, sd->obj);
5861    evas_object_event_callback_add
5862      (sd->img_obj, EVAS_CALLBACK_FOCUS_IN, _win_img_focus_in, sd->obj);
5863    evas_object_event_callback_add
5864      (sd->img_obj, EVAS_CALLBACK_FOCUS_OUT, _win_img_focus_out, sd->obj);
5865 }
5866
5867 static void
5868 _elm_win_on_icon_del(void *data, const Efl_Event *ev)
5869 {
5870    ELM_WIN_DATA_GET(data, sd);
5871
5872    if (sd->icon == ev->object) sd->icon = NULL;
5873 }
5874
5875 EOLIAN static void
5876 _efl_ui_win_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Win_Data *_pd EINA_UNUSED)
5877 {
5878    efl_canvas_group_add(efl_super(obj, MY_CLASS));
5879
5880    elm_widget_theme_klass_set(obj, "win");
5881    elm_widget_can_focus_set(obj, EINA_TRUE);
5882
5883    elm_widget_highlight_ignore_set(obj, EINA_TRUE);
5884 }
5885
5886 #ifdef HAVE_ELEMENTARY_X
5887 static void
5888 _elm_x_io_err(void *data EINA_UNUSED)
5889 {
5890    Eina_List *l;
5891    Evas_Object *obj;
5892
5893    EINA_LIST_FOREACH(_elm_win_list, l, obj)
5894      evas_object_smart_callback_call(obj, "ioerr", NULL);
5895    fprintf(stderr, "X I/O Error - fatal. Exiting\n");
5896    exit(101);
5897 }
5898 #endif
5899
5900 // TIZEN_ONLY(20160218): Improve launching performance.
5901 EAPI void
5902 elm_win_precreated_object_set(Evas_Object *obj)
5903 {
5904    INF("Set precreated obj(%p).", obj);
5905    _precreated_win_obj = obj;
5906 }
5907
5908 EAPI Evas_Object *
5909 elm_win_precreated_object_get(void)
5910 {
5911    INF("Get precreated obj(%p).", _precreated_win_obj);
5912    return _precreated_win_obj;
5913 }
5914 //
5915
5916 // TIZEN_ONLY(20160728): Indicator Implementation
5917 #ifdef HAVE_ELEMENTARY_WL2
5918 static Eina_Bool
5919 _elm_win_wl_indicator_flick(void *data, int type EINA_UNUSED, void *event EINA_UNUSED)
5920 {
5921    ELM_WIN_DATA_GET(data, sd);
5922    evas_object_smart_callback_call(sd->obj, SIG_INDICATOR_FLICK_DONE, NULL);
5923    return ECORE_CALLBACK_PASS_ON;
5924 }
5925 #endif
5926 // END
5927
5928 static void
5929 _elm_win_cb_hide(void *data EINA_UNUSED,
5930                  Evas *e EINA_UNUSED,
5931                  Evas_Object *obj EINA_UNUSED,
5932                  void *event_info EINA_UNUSED)
5933 {
5934    _elm_win_state_eval_queue();
5935 }
5936
5937 static void
5938 _elm_win_cb_show(void *data EINA_UNUSED,
5939                  Evas *e EINA_UNUSED,
5940                  Evas_Object *obj EINA_UNUSED,
5941                  void *event_info EINA_UNUSED)
5942 {
5943    _elm_win_state_eval_queue();
5944 }
5945
5946 static inline Eina_Bool
5947 _efl_ui_win_accel(Efl_Ui_Win_Data *sd, Eina_Stringshare **accel, int *gl_depth, int *gl_stencil, int *gl_msaa)
5948 {
5949    const char *str = sd->accel_pref;
5950    const char *env;
5951    const char *cfg = NULL;
5952    Eina_Bool is_accel = EINA_FALSE;
5953
5954    /* current elm config OR global override */
5955    if ((!str) || ((_elm_config->accel_override) && (_elm_config->accel)))
5956      {
5957         if (_elm_config->accel) cfg = _elm_config->accel;
5958         if (_elm_config->accel_override && _elm_accel_preference) cfg = _elm_accel_preference;
5959      }
5960
5961    /* env var wins */
5962    env = getenv("ELM_ACCEL");
5963
5964    if (env)
5965      is_accel = _elm_config_accel_preference_parse(env, accel, gl_depth, gl_stencil, gl_msaa);
5966    else if (cfg)
5967      {
5968         is_accel = !!cfg;
5969         *accel = eina_stringshare_ref(cfg);
5970         *gl_depth = _elm_config->gl_depth;
5971         *gl_stencil = _elm_config->gl_stencil;
5972         *gl_msaa = _elm_config->gl_msaa;
5973      }
5974    else
5975      is_accel = _elm_config_accel_preference_parse(str, accel, gl_depth, gl_stencil, gl_msaa);
5976
5977    return is_accel;
5978 }
5979
5980 static inline void
5981 _elm_win_need_frame_adjust(Efl_Ui_Win_Data *sd, const char *engine)
5982 {
5983    const char *s;
5984
5985    /* this is for debug only - don't keep forever, it's not an api! */
5986    s = getenv("EFL_WIN_FRAME_MODE");
5987    sd->csd.wayland = (eina_streq(engine, ELM_WAYLAND_SHM) ||
5988                       eina_streq(engine, ELM_WAYLAND_EGL));
5989
5990    if (sd->type == EFL_UI_WIN_TYPE_FAKE)
5991      sd->csd.need = EINA_FALSE;
5992    else if (eina_streq(s, "on"))
5993      sd->csd.need = EINA_TRUE;
5994    else if (eina_streq(s, "off"))
5995      sd->csd.need = EINA_FALSE;
5996    else
5997      sd->csd.need = sd->csd.wayland;
5998 }
5999
6000 static void
6001 _indicator_resized(void *data, const Efl_Event *event)
6002 {
6003    ELM_WIN_DATA_GET_OR_RETURN(data, sd);
6004    Evas_Object *indicator = event->object;
6005    Evas_Coord_Size *size = (Evas_Coord_Size *)event->info;
6006    efl_gfx_hint_size_min_set(indicator, EINA_SIZE2D(size->w, size->h));
6007    _elm_win_frame_obj_update(sd, 0);
6008 }
6009
6010 static Evas_Object*
6011 _create_indicator(Evas_Object *obj)
6012 {
6013    Evas_Object *indicator = NULL;
6014    const char *indicator_serv_name;
6015
6016    indicator_serv_name = "elm_indicator_portrait";
6017
6018    indicator = elm_plug_add(obj);
6019    if (!indicator)
6020      {
6021         ERR("Conformant cannot create plug to server[%s]", indicator_serv_name);
6022         return NULL;
6023      }
6024
6025    if (!elm_plug_connect(indicator, indicator_serv_name, 0, EINA_FALSE))
6026      {
6027         ERR("Conformant cannot connect to server[%s]", indicator_serv_name);
6028         return NULL;
6029      }
6030
6031    return indicator;
6032 }
6033
6034 static void
6035 _indicator_add(Efl_Ui_Win_Data *sd)
6036 {
6037    Eo *obj = sd->obj;
6038
6039    sd->indicator = _create_indicator(obj);
6040
6041    if (!sd->indicator)
6042      return;
6043
6044    if (elm_widget_is_legacy(obj))
6045      {
6046         if (!edje_object_part_swallow(sd->frame_obj, "elm.swallow.indicator", sd->indicator))
6047           return;
6048      }
6049    else
6050      {
6051         if (!edje_object_part_swallow(sd->frame_obj, "efl.indicator", sd->indicator))
6052           return;
6053      }
6054
6055    efl_event_callback_add
6056      (sd->indicator, ELM_PLUG_EVENT_IMAGE_RESIZED, _indicator_resized, obj);
6057
6058    efl_canvas_object_is_frame_object_set(sd->indicator, EINA_TRUE);
6059    sd->csd.need_indicator = EINA_TRUE;
6060
6061    _elm_win_frame_style_update(sd, 0, 1);
6062 }
6063
6064 static void
6065 _indicator_del(Efl_Ui_Win_Data *sd)
6066 {
6067    Eo *obj = sd->obj;
6068
6069    efl_event_callback_del
6070      (sd->indicator, ELM_PLUG_EVENT_IMAGE_RESIZED, _indicator_resized, obj);
6071
6072    efl_del(sd->indicator);
6073    sd->indicator = NULL;
6074
6075    sd->csd.need_indicator = EINA_FALSE;
6076    _elm_win_frame_style_update(sd, 0, 1);
6077 }
6078
6079 static Eina_Value
6080 _win_finalize_job_cb(void *data, const Eina_Value value)
6081 {
6082    Efl_Ui_Win_Data *sd = data;
6083    sd->finalize_future = NULL;
6084    if (!efl_invalidated_get(sd->obj))
6085      evas_render_pending_objects_flush(sd->evas);
6086    return value;
6087 }
6088
6089 static void
6090 _gesture_manager_config_load(Eo *obj)
6091 {
6092    Eina_Value val;
6093    Eo *gm = efl_provider_find(obj, EFL_CONFIG_INTERFACE);
6094
6095    eina_value_setup(&val, EINA_VALUE_TYPE_DOUBLE);
6096    eina_value_set(&val, _elm_config->glayer_long_tap_start_timeout);
6097    efl_config_set(gm, "glayer_long_tap_start_timeout", &val);
6098
6099    eina_value_set(&val, _elm_config->glayer_double_tap_timeout);
6100    efl_config_set(gm, "glayer_double_tap_timeout", &val);
6101
6102    elm_config_scroll_thumbscroll_friction_set(_elm_config->thumbscroll_friction);
6103    elm_config_scroll_thumbscroll_momentum_threshold_set(_elm_config->thumbscroll_momentum_threshold);
6104
6105    eina_value_set(&val, _elm_config->glayer_line_min_length);
6106    efl_config_set(gm, "glayer_line_min_length", &val);
6107
6108    eina_value_set(&val, _elm_config->glayer_line_distance_tolerance);
6109    efl_config_set(gm, "glayer_line_distance_tolerance", &val);
6110
6111    eina_value_set(&val, _elm_config->glayer_line_angular_tolerance);
6112    efl_config_set(gm, "glayer_line_angular_tolerance", &val);
6113
6114    eina_value_set(&val, _elm_config->glayer_zoom_finger_factor);
6115    efl_config_set(gm, "glayer_zoom_finger_factor", &val);
6116
6117    eina_value_set(&val, _elm_config->glayer_zoom_distance_tolerance);
6118    efl_config_set(gm, "glayer_zoom_distance_tolerance", &val);
6119
6120    eina_value_setup(&val, EINA_VALUE_TYPE_UINT);
6121    eina_value_set(&val, _elm_config->glayer_flick_time_limit_ms);
6122    efl_config_set(gm, "glayer_flick_time_limit_ms", &val);
6123
6124    eina_value_setup(&val, EINA_VALUE_TYPE_UCHAR);
6125    eina_value_set(&val, _elm_config->glayer_continues_enable);
6126    efl_config_set(gm, "glayer_continues_enable", &val);
6127
6128    eina_value_set(&val, _elm_config->glayer_zoom_finger_enable);
6129    efl_config_set(gm, "glayer_zoom_finger_enable", &val);
6130 }
6131
6132 static Eo *
6133 _elm_win_finalize_internal(Eo *obj, Efl_Ui_Win_Data *sd, const char *name, Efl_Ui_Win_Type type)
6134 {
6135    Evas_Object *parent = NULL;
6136    Evas *e;
6137    const Eina_List *l;
6138    const char *fontpath, *engine = NULL, *enginelist[32], *disp;
6139    int gl_depth = _elm_config->gl_depth;
6140    int gl_stencil = _elm_config->gl_stencil;
6141    int gl_msaa = _elm_config->gl_msaa;
6142    Eina_Stringshare *accel = NULL;
6143    Eina_Bool is_gl_accel;
6144    int i, p = 0;
6145    Ecore_Window parent_id = 0;
6146
6147    Efl_Ui_Win_Data tmp_sd;
6148
6149    if ((sd->type == ELM_WIN_INLINED_IMAGE) &&
6150        !efl_isa(obj, EFL_UI_WIN_INLINED_CLASS))
6151      {
6152         ERR("Failed to create an inlined window!");
6153         return NULL;
6154      }
6155
6156    parent = efl_parent_get(obj);
6157    //TIZEN_ONLY(20190321): support legacy window behavior compatibility
6158    if (!elm_widget_is_legacy(obj))
6159      {
6160    //
6161    if (!(efl_isa(parent, EFL_UI_WIN_CLASS) ||
6162          efl_isa(parent, EFL_UI_WIN_LEGACY_CLASS) ||
6163          efl_isa(parent, EFL_UI_WIN_INLINED_CLASS))) parent = NULL;
6164    //TIZEN_ONLY(20190321): support legacy window behavior compatibility
6165      }
6166    //
6167
6168    /* just to store some data while trying out to create a canvas */
6169    memset(&tmp_sd, 0, sizeof(Efl_Ui_Win_Data));
6170
6171    is_gl_accel = _efl_ui_win_accel(sd, &accel, &gl_depth, &gl_stencil, &gl_msaa);
6172
6173    switch ((int) type)
6174      {
6175       case EFL_UI_WIN_TYPE_FAKE:
6176         tmp_sd.ee = sd->ee;
6177         break;
6178       case ELM_WIN_INLINED_IMAGE:
6179         if (!parent) break;
6180           {
6181              Ecore_Evas *ee;
6182
6183              e = evas_object_evas_get(parent);
6184              if (!e) break;
6185
6186              ee = ecore_evas_ecore_evas_get(e);
6187              if (!ee) break;
6188
6189              tmp_sd.img_obj = ecore_evas_object_image_new(ee);
6190              if (!tmp_sd.img_obj) break;
6191
6192              tmp_sd.ee = ecore_evas_object_ecore_evas_get(tmp_sd.img_obj);
6193              if (!tmp_sd.ee)
6194                {
6195                   ELM_SAFE_FREE(tmp_sd.img_obj, evas_object_del);
6196                }
6197           }
6198         break;
6199
6200       case ELM_WIN_SOCKET_IMAGE:
6201         tmp_sd.ee = ecore_evas_extn_socket_new(1, 1);
6202         break;
6203
6204       default:
6205         disp = getenv("ELM_DISPLAY");
6206         if ((disp) && (!strcmp(disp, "ews")))
6207           {
6208              enginelist[p++] = ELM_EWS;
6209           }
6210         else if ((disp) && (!strcmp(disp, "buffer")))
6211           {
6212              enginelist[p++] = ELM_BUFFER;
6213           }
6214         else if ((disp) && (!strcmp(disp, "shot")))
6215           {
6216              enginelist[p++] = ENGINE_GET();
6217           }
6218 // welcome to ifdef hell! :)
6219
6220 #ifdef HAVE_ELEMENTARY_X
6221         else if ((disp) && (!strcmp(disp, "x11")))
6222           {
6223              if (is_gl_accel)
6224                {
6225                   enginelist[p++] = ELM_OPENGL_X11;
6226                   enginelist[p++] = ELM_SOFTWARE_X11;
6227                }
6228              else
6229                {
6230                   enginelist[p++] = ELM_SOFTWARE_X11;
6231                   enginelist[p++] = ELM_OPENGL_X11;
6232                }
6233           }
6234 #endif
6235
6236 #ifdef HAVE_ELEMENTARY_WL2
6237         else if ((disp) && (!strcmp(disp, "wl")))
6238           {
6239              if (is_gl_accel)
6240                {
6241                   enginelist[p++] = ELM_WAYLAND_EGL;
6242                   enginelist[p++] = ELM_WAYLAND_SHM;
6243                }
6244              else
6245                {
6246                   enginelist[p++] = ELM_WAYLAND_SHM;
6247                   enginelist[p++] = ELM_WAYLAND_EGL;
6248                }
6249           }
6250 #endif
6251
6252 #ifdef HAVE_ELEMENTARY_WIN32
6253         else if ((disp) && (!strcmp(disp, "win")))
6254           {
6255              enginelist[p++] = ELM_SOFTWARE_WIN32;
6256              enginelist[p++] = ELM_SOFTWARE_DDRAW;
6257           }
6258 #endif
6259
6260 #ifdef HAVE_ELEMENTARY_SDL
6261         else if ((disp) && (!strcmp(disp, "sdl")))
6262           {
6263              if (is_gl_accel)
6264                {
6265                   enginelist[p++] = ELM_OPENGL_SDL;
6266                   enginelist[p++] = ELM_SOFTWARE_SDL;
6267                }
6268              else
6269                {
6270                   enginelist[p++] = ELM_SOFTWARE_SDL;
6271                   enginelist[p++] = ELM_OPENGL_SDL;
6272                }
6273           }
6274 #endif
6275
6276 #ifdef HAVE_ELEMENTARY_COCOA
6277         else if ((disp) && (!strcmp(disp, "mac")))
6278           {
6279              enginelist[p++] = ELM_OPENGL_COCOA;
6280           }
6281 #endif
6282
6283 #if defined(HAVE_ELEMENTARY_DRM) || defined(HAVE_ELEMENTARY_FB)
6284         else if ((disp) && (!strcmp(disp, "fb")))
6285           {
6286 #ifdef HAVE_ELEMENTARY_DRM
6287              if (is_gl_accel)
6288                {
6289                   enginelist[p++] = ELM_GL_DRM;
6290                }
6291              enginelist[p++] = ELM_DRM;
6292 #endif
6293 #ifdef HAVE_ELEMENTARY_FB
6294              enginelist[p++] = ELM_SOFTWARE_FB;
6295 #endif
6296           }
6297 #endif
6298
6299 #ifdef HAVE_ELEMENTARY_X
6300         else if (!_elm_preferred_engine &&
6301                  getenv("DISPLAY") && !getenv("ELM_ENGINE"))
6302           {
6303              if (is_gl_accel)
6304                {
6305                   enginelist[p++] = ELM_OPENGL_X11;
6306                   enginelist[p++] = ELM_SOFTWARE_X11;
6307                }
6308              else
6309                {
6310                   enginelist[p++] = ELM_SOFTWARE_X11;
6311                   enginelist[p++] = ELM_OPENGL_X11;
6312                }
6313           }
6314 #endif
6315 #ifdef HAVE_ELEMENTARY_WL2
6316         else if (!_elm_preferred_engine &&
6317                  getenv("WAYLAND_DISPLAY") && !getenv("ELM_ENGINE"))
6318           {
6319              if (is_gl_accel)
6320                {
6321                   enginelist[p++] = ELM_WAYLAND_EGL;
6322                   enginelist[p++] = ELM_WAYLAND_SHM;
6323                }
6324              else
6325                {
6326                   enginelist[p++] = ELM_WAYLAND_SHM;
6327                   enginelist[p++] = ELM_WAYLAND_EGL;
6328                }
6329           }
6330 #endif
6331         else
6332           {
6333              if (is_gl_accel)
6334                {
6335 // add all engines with selected engine first - if any
6336                   if (ENGINE_GET())
6337                     enginelist[p++] = ENGINE_GET();
6338
6339 // add all engines with gl/accelerated ones first - only engines compiled
6340 #ifdef HAVE_ELEMENTARY_X
6341                   enginelist[p++] = ELM_OPENGL_X11;
6342 #endif
6343 #ifdef HAVE_ELEMENTARY_WL2
6344                   enginelist[p++] = ELM_WAYLAND_EGL;
6345 #endif
6346 #ifdef HAVE_ELEMENTARY_DRM
6347                   enginelist[p++] = ELM_GL_DRM;
6348                   enginelist[p++] = ELM_DRM;
6349 #endif
6350 #ifdef HAVE_ELEMENTARY_FB
6351                   enginelist[p++] = ELM_SOFTWARE_FB;
6352 #endif
6353 #ifdef HAVE_ELEMENTARY_COCOA
6354                   enginelist[p++] = ELM_OPENGL_COCOA;
6355 #endif
6356 #ifdef HAVE_ELEMENTARY_SDL
6357                   enginelist[p++] = ELM_OPENGL_SDL;
6358 #endif
6359 #ifdef HAVE_ELEMENTARY_X
6360                   enginelist[p++] = ELM_SOFTWARE_X11;
6361 #endif
6362 #ifdef HAVE_ELEMENTARY_WL2
6363                   enginelist[p++] = ELM_WAYLAND_SHM;
6364 #endif
6365 #ifdef HAVE_ELEMENTARY_WIN32
6366                   enginelist[p++] = ELM_SOFTWARE_WIN32;
6367                   enginelist[p++] = ELM_SOFTWARE_DDRAW;
6368 #endif
6369 #ifdef HAVE_ELEMENTARY_SDL
6370                   enginelist[p++] = ELM_SOFTWARE_SDL;
6371 #endif
6372                }
6373              else
6374                {
6375 // add all engines with selected engine first - if any
6376                   if (elm_config_preferred_engine_get())
6377                     enginelist[p++] = elm_config_preferred_engine_get();
6378 // add check _elm_gl_preference whether "none" or not
6379                   else if (_elm_config->engine &&
6380                            ((elm_config_accel_preference_get() &&
6381                              !strcmp(elm_config_accel_preference_get(), "none"))
6382                             || (accel && !strcmp(accel, "none"))))
6383                     enginelist[p++] = _elm_config->engine;
6384 // add all engines with gl/accelerated ones first - only engines compiled
6385 #ifdef HAVE_ELEMENTARY_X
6386                   enginelist[p++] = ELM_SOFTWARE_X11;
6387 #endif
6388 #ifdef HAVE_ELEMENTARY_WL2
6389                   enginelist[p++] = ELM_WAYLAND_SHM;
6390 #endif
6391 #ifdef HAVE_ELEMENTARY_DRM
6392                   enginelist[p++] = ELM_DRM;
6393 #endif
6394 #ifdef HAVE_ELEMENTARY_FB
6395                   enginelist[p++] = ELM_SOFTWARE_FB;
6396 #endif
6397 #ifdef HAVE_ELEMENTARY_COCOA
6398                   enginelist[p++] = ELM_OPENGL_COCOA;
6399 #endif
6400 #ifdef HAVE_ELEMENTARY_WIN32
6401                   enginelist[p++] = ELM_SOFTWARE_WIN32;
6402                   enginelist[p++] = ELM_SOFTWARE_DDRAW;
6403 #endif
6404 #ifdef HAVE_ELEMENTARY_SDL
6405                   enginelist[p++] = ELM_SOFTWARE_SDL;
6406 #endif
6407 #ifdef HAVE_ELEMENTARY_X
6408                   enginelist[p++] = ELM_OPENGL_X11;
6409 #endif
6410 #ifdef HAVE_ELEMENTARY_WL2
6411                   enginelist[p++] = ELM_WAYLAND_EGL;
6412 #endif
6413 #ifdef HAVE_ELEMENTARY_DRM
6414                   enginelist[p++] = ELM_GL_DRM;
6415                   enginelist[p++] = ELM_DRM;
6416 #endif
6417 #ifdef HAVE_ELEMENTARY_SDL
6418                   enginelist[p++] = ELM_OPENGL_SDL;
6419 #endif
6420                }
6421           }
6422         if (parent) parent_id = elm_win_window_id_get(parent);
6423         for (i = 0; i < p; i++)
6424           {
6425              int opt[20], opt_i = 0;
6426
6427              if (_elm_config->vsync)
6428                {
6429                   opt[opt_i++] = ECORE_EVAS_OPT_VSYNC;
6430                   opt[opt_i++] = 1;
6431                }
6432              if (gl_depth)
6433                {
6434                   opt[opt_i++] = ECORE_EVAS_OPT_GL_DEPTH;
6435                   opt[opt_i++] = gl_depth;
6436                }
6437              if (gl_stencil)
6438                {
6439                   opt[opt_i++] = ECORE_EVAS_OPT_GL_STENCIL;
6440                   opt[opt_i++] = gl_stencil;
6441                }
6442              if (gl_msaa)
6443                {
6444                   opt[opt_i++] = ECORE_EVAS_OPT_GL_MSAA;
6445                   opt[opt_i++] = gl_msaa;
6446                }
6447              opt[opt_i] = 0;
6448
6449              if (!strcmp(enginelist[i], ELM_SOFTWARE_X11))
6450                tmp_sd.ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 0, 0);
6451              else if (!strcmp(enginelist[i], ELM_OPENGL_X11))
6452                {
6453                   if (opt_i > 0)
6454                     tmp_sd.ee = ecore_evas_gl_x11_options_new(NULL, 0, 0, 0, 0, 0, opt);
6455                   else
6456                     tmp_sd.ee = ecore_evas_gl_x11_new(NULL, 0, 0, 0, 0, 0);
6457                }
6458              else if (!strcmp(enginelist[i], ELM_WAYLAND_SHM))
6459                tmp_sd.ee = _wayland_shm_new(NULL, parent_id, 0, 0, 0, 0, 0);
6460              else if (!strcmp(enginelist[i], ELM_WAYLAND_EGL))
6461                tmp_sd.ee = _wayland_egl_new(NULL, parent_id, 0, 0, 0, 0, 0, (opt_i > 0) ? opt : NULL);
6462              else if (!strcmp(enginelist[i], ELM_SOFTWARE_WIN32))
6463                tmp_sd.ee = ecore_evas_software_gdi_new(NULL, 0, 0, 1, 1);
6464              else if (!strcmp(enginelist[i], ELM_SOFTWARE_DDRAW))
6465                tmp_sd.ee = ecore_evas_software_ddraw_new(NULL, 0, 0, 1, 1);
6466              else if (!strcmp(enginelist[i], ELM_SOFTWARE_SDL))
6467                tmp_sd.ee = ecore_evas_sdl_new(NULL, 0, 0, 0, 0, 0, 1);
6468              else if (!strcmp(enginelist[i], ELM_OPENGL_SDL))
6469                tmp_sd.ee = ecore_evas_gl_sdl_new(NULL, 1, 1, 0, 0);
6470              else if (!strcmp(enginelist[i], ELM_OPENGL_COCOA))
6471                tmp_sd.ee = ecore_evas_cocoa_new(NULL, 1, 1, 0, 0);
6472              else if (!strcmp(enginelist[i], ELM_EWS))
6473                tmp_sd.ee = ecore_evas_ews_new(0, 0, 1, 1);
6474              else if (!strcmp(enginelist[i], ELM_SOFTWARE_FB))
6475                tmp_sd.ee = ecore_evas_fb_new(NULL, 0, 1, 1);
6476              else if (!strcmp(enginelist[i], ELM_BUFFER))
6477                tmp_sd.ee = ecore_evas_buffer_new(1, 1);
6478              else if (!strcmp(enginelist[i], ELM_DRM))
6479                tmp_sd.ee = ecore_evas_drm_new(NULL, 0, 0, 0, 1, 1);
6480              else if (!strcmp(enginelist[i], ELM_GL_DRM))
6481                tmp_sd.ee = ecore_evas_gl_drm_new(NULL, 0, 0, 0, 1, 1);
6482              else if (!strncmp(enginelist[i], "shot:", 5))
6483                {
6484                   tmp_sd.ee = ecore_evas_buffer_new(1, 1);
6485                   ecore_evas_manual_render_set(tmp_sd.ee, EINA_TRUE);
6486                   tmp_sd.shot.info = eina_stringshare_add(ENGINE_GET() + 5);
6487                }
6488              engine = enginelist[i];
6489              if (tmp_sd.ee) break;
6490           }
6491         break;
6492      }
6493
6494    eina_stringshare_del(accel);
6495    if (!tmp_sd.ee)
6496      {
6497         ERR("Cannot create window.");
6498         return NULL;
6499      }
6500
6501    if (!sd->accel_pref)
6502      eina_stringshare_replace(&sd->accel_pref, elm_config_accel_preference_get());
6503
6504    efl_parent_set(obj, ecore_evas_get(tmp_sd.ee));
6505
6506    /* FIXME: Major hack: calling the constructor in the middle of finalize. */
6507    efl_constructor(efl_super(obj, MY_CLASS));
6508    evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
6509
6510    if (getenv("ELM_FIRST_FRAME"))
6511      evas_event_callback_add(ecore_evas_get(tmp_sd.ee), EVAS_CALLBACK_RENDER_POST,
6512                              _elm_win_first_frame_do, getenv("ELM_FIRST_FRAME"));
6513
6514    /* copying possibly altered fields back */
6515 #define SD_CPY(_field)             \
6516   do                               \
6517     {                              \
6518        sd->_field = tmp_sd._field; \
6519     } while (0)
6520
6521    SD_CPY(ee);
6522    SD_CPY(img_obj);
6523    SD_CPY(shot.info);
6524 #undef SD_CPY
6525
6526    if ((type != EFL_UI_WIN_TYPE_FAKE) && (trap) && (trap->add))
6527      sd->trap_data = trap->add(obj);
6528
6529    /* complementary actions, which depend on final smart data
6530     * pointer */
6531    if (type == EFL_UI_WIN_TYPE_INLINED_IMAGE)
6532      _win_inlined_image_set(sd);
6533 #ifdef HAVE_ELEMENTARY_X
6534    else if ((engine) &&
6535             ((!strcmp(engine, ELM_SOFTWARE_X11)) ||
6536              (!strcmp(engine, ELM_OPENGL_X11))))
6537      {
6538         sd->x.client_message_handler = ecore_event_handler_add
6539             (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, obj);
6540         sd->x.property_handler = ecore_event_handler_add
6541             (ECORE_X_EVENT_WINDOW_PROPERTY, _elm_win_property_change, obj);
6542      }
6543 #endif
6544 #ifdef HAVE_ELEMENTARY_WL2
6545       else if ((engine) &&
6546                ((!strcmp(engine, ELM_WAYLAND_SHM)) ||
6547                 (!strcmp(engine, ELM_WAYLAND_EGL))))
6548         {
6549            //TIZEN_ONLY(20171110): added signal for effect start and done
6550            sd->wl.effect_start_handler = ecore_event_handler_add
6551               (ECORE_WL2_EVENT_EFFECT_START, _elm_win_wl_effect_start, obj);
6552            sd->wl.effect_end_handler = ecore_event_handler_add
6553               (ECORE_WL2_EVENT_EFFECT_END, _elm_win_wl_effect_end, obj);
6554            // TIZEN_ONLY(20160801): indicator implementation
6555            sd->wl.indicator_flick_handler = ecore_event_handler_add
6556               (ECORE_WL2_EVENT_INDICATOR_FLICK, _elm_win_wl_indicator_flick, obj);
6557            // END
6558            // TIZEN_ONLY(20150722): added signal for aux_hint(auxiliary hint)
6559            sd->wl.aux_msg_handler = ecore_event_handler_add
6560               (ECORE_WL2_EVENT_AUX_MESSAGE, _elm_win_wl_aux_message, obj);
6561            //
6562         }
6563 #endif
6564
6565    else if ((engine) && (!strncmp(engine, "shot:", 5)))
6566      _shot_init(sd);
6567
6568    sd->kbdmode = EFL_UI_WIN_KEYBOARD_MODE_UNKNOWN;
6569    sd->legacy.indmode = ELM_WIN_INDICATOR_UNKNOWN;
6570    sd->indimode = EFL_UI_WIN_INDICATOR_MODE_OFF;
6571
6572 #ifdef HAVE_ELEMENTARY_X
6573    _internal_elm_win_xwindow_get(sd);
6574    if (sd->x.xwin) ecore_x_io_error_handler_set(_elm_x_io_err, NULL);
6575 #endif
6576
6577 #ifdef HAVE_ELEMENTARY_WL2
6578    _elm_win_wlwindow_get(sd);
6579    if (sd->wl.win)
6580      {
6581 //TIZEN_ONLY(20160720): Allowed changing type after initializing
6582 /*
6583         Ecore_Wl2_Window_Type wtype;
6584 */
6585         sd->wl.configure_handler =
6586           ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_CONFIGURE, _elm_win_wl_configure, obj);
6587 //TIZEN_ONLY(20160720): Allowed changing type after initializing
6588 /*
6589         switch (sd->type)
6590           {
6591            case ELM_WIN_BASIC:
6592            case ELM_WIN_DIALOG_BASIC:
6593            case ELM_WIN_NAVIFRAME_BASIC:
6594            case ELM_WIN_SPLASH:
6595            case ELM_WIN_TOOLBAR:
6596            case ELM_WIN_UTILITY:
6597            case ELM_WIN_DOCK:
6598            case ELM_WIN_DESKTOP:
6599              wtype = ECORE_WL2_WINDOW_TYPE_TOPLEVEL;
6600              break;
6601            case ELM_WIN_TOOLTIP:
6602            case ELM_WIN_COMBO:
6603            case ELM_WIN_MENU:
6604            case ELM_WIN_POPUP_MENU:
6605              wtype = ECORE_WL2_WINDOW_TYPE_MENU;
6606              break;
6607            case ELM_WIN_DND:
6608              wtype = ECORE_WL2_WINDOW_TYPE_DND;
6609              break;
6610            default:
6611              wtype = ECORE_WL2_WINDOW_TYPE_NONE;
6612           }
6613         ecore_wl2_window_type_set(sd->wl.win, wtype);
6614 */
6615         _elm_win_wlwin_type_update(sd);
6616 //
6617      }
6618    else if (sd->type == EFL_UI_WIN_TYPE_FAKE)
6619      {
6620         const char *env = getenv("WAYLAND_DISPLAY");
6621         if (env)
6622           {
6623              Ecore_Wl2_Display *d = ecore_wl2_display_connect(env);
6624              sd->wl.win = ecore_wl2_window_new(d, NULL, 0, 0, 1, 1);
6625              ecore_wl2_display_disconnect(d);
6626 //TIZEN_ONLY(20180518): call ecore_wl2_window_free only fake make it
6627              evas_object_data_set(sd->obj, "__fake_make_wl2", sd->obj);
6628 //
6629           }
6630      }
6631 #endif
6632
6633 #ifdef HAVE_ELEMENTARY_COCOA
6634    _elm_win_cocoawindow_get(sd);
6635 #endif
6636 #ifdef HAVE_ELEMENTARY_WIN32
6637    sd->win32.key_down_handler = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN,
6638                                                         _elm_win_key_down, obj);
6639    _internal_elm_win_win32window_get(sd);
6640 #endif
6641
6642    if ((_elm_config->bgpixmap)
6643 #ifdef HAVE_ELEMENTARY_X
6644        && (((sd->x.xwin) && (!ecore_x_screen_is_composited(0))) ||
6645            (!sd->x.xwin))
6646 #endif
6647       )
6648      TRAP(sd, avoid_damage_set, ECORE_EVAS_AVOID_DAMAGE_EXPOSE);
6649    // bg pixmap done by x - has other issues like can be redrawn by x before it
6650    // is filled/ready by app
6651    //     TRAP(sd, avoid_damage_set, ECORE_EVAS_AVOID_DAMAGE_BUILT_IN);
6652
6653    sd->type = type;
6654    sd->parent = parent;
6655    sd->modal_count = 0;
6656    sd->withdrawn = ecore_evas_withdrawn_get(sd->ee);
6657
6658    if (sd->parent)
6659      {
6660 // TIZEN_ONLY(20160315) set wayland parent window
6661 #ifdef HAVE_ELEMENTARY_WL2
6662         if ((sd->type >= ELM_WIN_BASIC) && (sd->type <= ELM_WIN_DND))
6663 //TIZEN_ONLY(20171208): fix build break by opensource temporarily until migration finish
6664           ecore_wl2_window_parent_set(sd->wl.win, (Ecore_Wl2_Window *)elm_win_wl_window_get(sd->parent));
6665 //TIZEN_ONLY(20171208)
6666 #endif
6667 //
6668         evas_object_event_callback_add
6669            (sd->parent, EVAS_CALLBACK_DEL, _elm_win_on_parent_del, obj);
6670      }
6671
6672 // TIZEN_ONLY(20161114): Sync the state of indicator with window manager
6673 #ifdef HAVE_ELEMENTARY_WL2
6674    if (sd->wl.win)
6675      ecore_wl2_indicator_visible_type_set(sd->wl.win, ECORE_WL2_INDICATOR_VISIBLE_TYPE_SHOWN);
6676 #endif
6677 // END
6678
6679    sd->evas = ecore_evas_get(sd->ee);
6680
6681    evas_object_color_set(obj, 0, 0, 0, 0);
6682    //TIZEN_ONLY(20180530): keep default geometry compatibility
6683    evas_object_move(obj, 0, 0);
6684    evas_object_resize(obj, 1, 1);
6685    //
6686    evas_object_pass_events_set(obj, EINA_TRUE);
6687
6688    if (type == EFL_UI_WIN_TYPE_INLINED_IMAGE)
6689      efl_ui_win_inlined_parent_set(obj, parent);
6690
6691    /* use own version of ecore_evas_object_associate() that does TRAP() */
6692    ecore_evas_data_set(sd->ee, "elm_win", obj);
6693
6694    if (type != EFL_UI_WIN_TYPE_FAKE)
6695      {
6696         evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
6697            _elm_win_obj_callback_changed_size_hints, NULL);
6698         evas_object_intercept_raise_callback_add
6699           (obj, _elm_win_obj_intercept_raise, obj);
6700         evas_object_intercept_lower_callback_add
6701           (obj, _elm_win_obj_intercept_lower, obj);
6702         evas_object_intercept_stack_above_callback_add
6703           (obj, _elm_win_obj_intercept_stack_above, obj);
6704         evas_object_intercept_stack_below_callback_add
6705           (obj, _elm_win_obj_intercept_stack_below, obj);
6706         evas_object_intercept_layer_set_callback_add
6707           (obj, _elm_win_obj_intercept_layer_set, obj);
6708      }
6709
6710    TRAP(sd, name_class_set, name, _elm_appname);
6711    TRAP(sd, title_set, sd->title);
6712    ecore_evas_callback_delete_request_set(sd->ee, _elm_win_delete_request);
6713    ecore_evas_callback_state_change_set(sd->ee, _elm_win_state_change);
6714    ecore_evas_callback_focus_in_set(sd->ee, _elm_win_focus_in);
6715    ecore_evas_callback_focus_out_set(sd->ee, _elm_win_focus_out);
6716    ecore_evas_callback_resize_set(sd->ee, _elm_win_resize);
6717    ecore_evas_callback_move_set(sd->ee, _elm_win_move);
6718    ecore_evas_callback_pre_render_set(sd->ee, _elm_win_pre_render);
6719    if (type != EFL_UI_WIN_TYPE_FAKE)
6720      {
6721          ecore_evas_callback_mouse_in_set(sd->ee, _elm_win_mouse_in);
6722          ecore_evas_callback_mouse_out_set(sd->ee, _elm_win_mouse_out);
6723      }
6724
6725    evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _elm_win_cb_hide, NULL);
6726    evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _elm_win_cb_show, NULL);
6727
6728    evas_image_cache_set(sd->evas, (_elm_config->image_cache * 1024));
6729    evas_font_cache_set(sd->evas, (_elm_config->font_cache * 1024));
6730
6731    EINA_LIST_FOREACH(_elm_config->font_dirs, l, fontpath)
6732      evas_font_path_append(sd->evas, fontpath);
6733
6734    if (!_elm_config->font_hinting)
6735      evas_font_hinting_set(sd->evas, EVAS_FONT_HINTING_NONE);
6736    else if (_elm_config->font_hinting == 1)
6737      evas_font_hinting_set(sd->evas, EVAS_FONT_HINTING_AUTO);
6738    else if (_elm_config->font_hinting == 2)
6739      evas_font_hinting_set(sd->evas, EVAS_FONT_HINTING_BYTECODE);
6740
6741    sd->wm_rot.wm_supported = ecore_evas_wm_rotation_supported_get(sd->ee);
6742    sd->wm_rot.preferred_rot = -1; // it means that elm_win doesn't use preferred rotation.
6743
6744 #ifdef HAVE_ELEMENTARY_X
6745    _elm_win_xwin_update(sd);
6746 #endif
6747
6748    if (type != EFL_UI_WIN_TYPE_FAKE)
6749      {
6750         //Prohibiting auto-rendering, until elm_win is shown.
6751         if (_elm_win_auto_norender_withdrawn(obj))
6752           {
6753              if (elm_win_withdrawn_get(obj))
6754                {
6755                   if (!evas_object_data_get(obj, "__win_auto_norender"))
6756                     {
6757                        elm_win_norender_push(obj);
6758                        evas_object_data_set(obj, "__win_auto_norender", obj);
6759                     }
6760                }
6761           }
6762      }
6763
6764 #ifdef ELM_DEBUG
6765    Evas_Modifier_Mask mask = evas_key_modifier_mask_get(sd->evas, "Control");
6766    evas_object_event_callback_add
6767      (obj, EVAS_CALLBACK_KEY_DOWN, _debug_key_down, NULL);
6768
6769    if (evas_object_key_grab(obj, "F12", mask, 0, EINA_TRUE))
6770      INF("Ctrl+F12 key combination exclusive for dot tree generation\n");
6771    else
6772      ERR("failed to grab F12 key to elm widgets (dot) tree generation");
6773 #endif
6774
6775    if (type != EFL_UI_WIN_TYPE_FAKE)
6776      {
6777         if ((_elm_config->softcursor_mode == ELM_SOFTCURSOR_MODE_ON) ||
6778             ((_elm_config->softcursor_mode == ELM_SOFTCURSOR_MODE_AUTO) &&
6779              ((engine) &&
6780               ((!strcmp(engine, ELM_SOFTWARE_FB)) || (!strcmp(engine, ELM_DRM))
6781               || (!strcmp(engine, ELM_GL_DRM))))))
6782           {
6783              Evas_Object *o;
6784              Evas_Coord mw = 1, mh = 1, hx = 0, hy = 0;
6785
6786              sd->pointer.obj = o = edje_object_add(ecore_evas_get(tmp_sd.ee));
6787              elm_widget_theme_object_set(obj, o, "pointer", "base", "default");
6788              edje_object_size_min_calc(o, &mw, &mh);
6789              evas_object_resize(o, mw, mh);
6790              if (elm_widget_is_legacy(obj))
6791                edje_object_part_geometry_get(o, "elm.swallow.hotspot",
6792                                              &hx, &hy, NULL, NULL);
6793              else
6794                edje_object_part_geometry_get(o, "efl.hotspot",
6795                                              &hx, &hy, NULL, NULL);
6796
6797              sd->pointer.hot_x = hx;
6798              sd->pointer.hot_y = hy;
6799              evas_object_show(o);
6800              ecore_evas_object_cursor_set(tmp_sd.ee, o, EVAS_LAYER_MAX, hx, hy);
6801           }
6802         else if (_elm_config->softcursor_mode == ELM_SOFTCURSOR_MODE_OFF)
6803           {
6804              // do nothing
6805           }
6806      }
6807
6808    _elm_win_legacy_init(sd);
6809    _elm_win_need_frame_adjust(sd, engine);
6810    _elm_win_apply_alpha(obj, sd);
6811
6812 #ifdef HAVE_ELEMENTARY_WL2
6813 //TIZEN_ONLY(20180106): disable pointer window
6814 /*
6815    if ((type != EFL_UI_WIN_TYPE_FAKE) && (type != EFL_UI_WIN_TYPE_INLINED_IMAGE))
6816      {
6817         if ((engine) &&
6818             ((!strcmp(engine, ELM_WAYLAND_SHM) ||
6819               (!strcmp(engine, ELM_WAYLAND_EGL)))))
6820           {
6821              Evas *pevas;
6822
6823              if (!strcmp(engine, ELM_WAYLAND_SHM))
6824                sd->pointer.ee = ecore_evas_wayland_shm_new(NULL, 0, 0, 0, 0, 0, 0);
6825              else if (!strcmp(engine, ELM_WAYLAND_EGL))
6826                sd->pointer.ee = ecore_evas_wayland_egl_new(NULL, 0, 0, 0, 0, 0, 0);
6827              ecore_evas_alpha_set(sd->pointer.ee, EINA_TRUE);
6828
6829              pevas = ecore_evas_get(sd->pointer.ee);
6830
6831              sd->pointer.obj = edje_object_add(pevas);
6832
6833              sd->pointer.win = ecore_evas_wayland2_window_get(sd->pointer.ee);
6834              ecore_wl2_window_type_set(sd->pointer.win,
6835                                        ECORE_WL2_WINDOW_TYPE_NONE);
6836              _elm_win_wl_cursor_set(sd->obj, NULL);
6837              ecore_evas_show(sd->pointer.ee);
6838           }
6839      }
6840 */
6841 //
6842 #endif
6843
6844    /* do not append to list; all windows render as black rects */
6845    if (type != EFL_UI_WIN_TYPE_FAKE)
6846      {
6847         const char *element = "base";
6848         const char *style;
6849
6850         _elm_win_list = eina_list_append(_elm_win_list, obj);
6851         _elm_win_count++;
6852
6853         if ((engine) &&
6854             ((!strcmp(engine, ELM_SOFTWARE_FB)) || (!strcmp(engine, ELM_DRM))
6855              || (!strcmp(engine, ELM_GL_DRM))))
6856           {
6857              TRAP(sd, fullscreen_set, 1);
6858           }
6859         style = elm_widget_style_get(obj);
6860         if (!style) style = "default";
6861         switch (type)
6862           {
6863            case EFL_UI_WIN_TYPE_DIALOG_BASIC:    element = "dialog"; break;
6864            case EFL_UI_WIN_TYPE_NAVIFRAME_BASIC: element = "naviframe"; break;
6865            default: break;
6866           }
6867
6868         if (!_elm_config->win_no_border)
6869           _elm_win_frame_add(sd, element, style);
6870
6871         if (sd->indimode != EFL_UI_WIN_INDICATOR_MODE_OFF)
6872           _indicator_add(sd);
6873
6874         if (_elm_config->focus_highlight_enable)
6875           elm_win_focus_highlight_enabled_set(obj, EINA_TRUE);
6876         if (_elm_config->focus_highlight_animate)
6877           elm_win_focus_highlight_animate_set(obj, EINA_TRUE);
6878      }
6879
6880    efl_access_object_role_set(obj, EFL_ACCESS_ROLE_WINDOW);
6881    if (_elm_atspi_enabled())
6882      efl_access_window_created_signal_emit(obj);
6883
6884    // attach config API
6885    efl_composite_attach(obj, efl_provider_find(efl_main_loop_get(), EFL_CONFIG_GLOBAL_CLASS));
6886
6887    efl_event_callback_array_add(sd->evas, _elm_evas_tracking(), sd);
6888    efl_event_callback_array_add(obj, _elm_win_evas_feed_fake_callbacks(), sd->evas);
6889    efl_event_callback_array_add(obj, _elm_win_tracking(), sd);
6890    evas_object_show(sd->legacy.edje);
6891
6892    if (type == EFL_UI_WIN_TYPE_FAKE)
6893      {
6894         _elm_win_resize_job(obj);
6895         _elm_win_move(sd->ee);
6896      }
6897    else
6898      {
6899         sd->finalize_future = eina_future_then_easy(efl_loop_job(efl_loop_get(obj)),
6900                               .success = _win_finalize_job_cb, .data = sd);
6901      }
6902
6903    // All normal windows are "standard" windows with EO API
6904    if (!sd->legacy.ctor)
6905      {
6906         switch (type)
6907           {
6908            case EFL_UI_WIN_TYPE_UNKNOWN:
6909            case EFL_UI_WIN_TYPE_BASIC:
6910            case EFL_UI_WIN_TYPE_DIALOG_BASIC:
6911              _elm_win_standard_init(obj);
6912              break;
6913            default: break;
6914           }
6915      }
6916
6917    //TIZEN_ONLY(20171201): Use win_no_border config.
6918    if(_elm_config->win_no_border)
6919      {
6920         elm_win_borderless_set(obj, EINA_TRUE);
6921      }
6922    //
6923
6924    /* TIZEN_ONLY(20180117): Apply paragraph direction according to locale */
6925    if (!strcmp(E_("default:LTR"), "default:RTL"))
6926      evas_object_paragraph_direction_set(obj, EVAS_BIDI_DIRECTION_ANY_RTL);
6927    else
6928      evas_object_paragraph_direction_set(obj, EVAS_BIDI_DIRECTION_LTR);
6929    /* END */
6930    // Load the config values into gesutre manager.
6931    _gesture_manager_config_load(obj);
6932
6933    return obj;
6934 }
6935
6936 EOLIAN static Eo *
6937 _efl_ui_win_efl_object_finalize(Eo *obj, Efl_Ui_Win_Data *sd)
6938 {
6939    Eina_Bool resume = !_elm_win_count;
6940
6941    obj = _elm_win_finalize_internal(obj, sd, sd->name, sd->type);
6942    if (!obj) return NULL;
6943    obj = efl_finalize(efl_super(obj, MY_CLASS));
6944    if (obj && resume) efl_event_callback_call(efl_loop_get(obj), EFL_APP_EVENT_RESUME, NULL);
6945    if (obj && (!elm_widget_is_legacy(obj)))
6946      {
6947         /* FIXME: if parts other than background are supported then this should change */
6948         if (efl_file_get(efl_super(efl_part(obj, "background"), EFL_UI_WIN_PART_CLASS)) ||
6949             efl_file_mmap_get(efl_super(efl_part(obj, "background"), EFL_UI_WIN_PART_CLASS)))
6950           efl_file_load(efl_part(obj, "background"));
6951      }
6952    _ee_backbone_init(obj, sd);
6953    return obj;
6954 }
6955
6956 EOLIAN static void
6957 _efl_ui_win_efl_canvas_object_legacy_ctor(Eo *obj, Efl_Ui_Win_Data *sd)
6958 {
6959    efl_canvas_object_legacy_ctor(efl_super(obj, MY_CLASS));
6960    sd->legacy.ctor = EINA_TRUE;
6961 }
6962
6963 EOLIAN EINA_UNUSED static Efl_Ui_Focus_Manager*
6964 _efl_ui_win_efl_ui_widget_focus_manager_focus_manager_create(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *pd EINA_UNUSED, Efl_Ui_Focus_Object *root)
6965 {
6966    Efl_Ui_Focus_Manager *manager;
6967
6968    manager = efl_add(EFL_UI_FOCUS_MANAGER_CALC_CLASS, obj,
6969      efl_ui_focus_manager_root_set(efl_added, root)
6970    );
6971
6972    return manager;
6973 }
6974
6975 EOLIAN static void
6976 _efl_ui_win_efl_object_destructor(Eo *obj, Efl_Ui_Win_Data *pd EINA_UNUSED)
6977 {
6978 #ifdef HAVE_ELEMENTARY_WL2
6979 //TIZEN_ONLY(20180518): call ecore_wl2_window_free only fake make it
6980 // if (pd->type == EFL_UI_WIN_TYPE_FAKE)
6981    if (pd->type == EFL_UI_WIN_TYPE_FAKE && evas_object_data_get(pd->obj, "__fake_make_wl2"))
6982      {
6983         evas_object_data_del(obj, "__fake_make_wl2");
6984 //
6985         if (pd->wl.win)
6986           ecore_wl2_window_free(pd->wl.win);
6987      }
6988 #endif
6989    if (pd->finalize_future)
6990      eina_future_cancel(pd->finalize_future);
6991
6992    _ee_backbone_shutdown(obj, pd);
6993
6994    efl_destructor(efl_super(obj, MY_CLASS));
6995
6996    efl_unref(pd->provider);
6997 }
6998
6999 EOLIAN static Eo *
7000 _efl_ui_win_efl_object_constructor(Eo *obj, Efl_Ui_Win_Data *pd)
7001 {
7002    /* UGLY HACK: Do (almost) nothing here:
7003     * We are calling the constructor chain from the finalizer. It's
7004     * really bad and hacky. Needs fixing. */
7005
7006    pd->obj = obj;
7007    pd->provider = efl_add_ref(EFL_UI_FOCUS_PARENT_PROVIDER_STANDARD_CLASS, NULL);
7008    pd->profile.available = eina_array_new(4);
7009    pd->max_w = pd->max_h = -1;
7010    pd->planned_changes = eina_array_new(10);
7011
7012    // For bindings: if no parent, allow simple unref
7013    if (!efl_parent_get(obj))
7014      efl_allow_parent_unref_set(obj, EINA_TRUE);
7015
7016    //TIZEN_ONLY(20181024): Fix parent-children incosistencies in atspi tree
7017    Eo *root = efl_access_object_access_root_get();
7018    efl_access_object_access_parent_set(obj, root);
7019    //
7020
7021    if (!elm_widget_is_legacy(obj))
7022      pd->type = EFL_UI_WIN_TYPE_BASIC;
7023
7024    return obj;
7025 }
7026
7027 EOLIAN static void
7028 _efl_ui_win_efl_text_text_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, const char *title)
7029 {
7030    if (!title) return;
7031    eina_stringshare_replace(&(sd->title), title);
7032    if (sd->ee)
7033      TRAP(sd, title_set, sd->title);
7034    if (sd->frame_obj)
7035      {
7036         if (elm_widget_is_legacy(sd->obj))
7037           edje_object_part_text_escaped_set(sd->frame_obj, "elm.text.title", sd->title);
7038         else
7039           edje_object_part_text_escaped_set(sd->frame_obj, "efl.text.title", sd->title);
7040      }
7041 }
7042
7043 EOLIAN static const char*
7044 _efl_ui_win_efl_text_text_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
7045 {
7046    return sd->title;
7047 }
7048
7049 EOLIAN void
7050 _efl_ui_win_efl_ui_i18n_language_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, const char *locale)
7051 {
7052    if (sd->frame_obj)
7053      efl_ui_language_set(sd->frame_obj, locale);
7054 }
7055
7056 EOLIAN const char *
7057 _efl_ui_win_efl_ui_i18n_language_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
7058 {
7059    return sd->frame_obj ? efl_ui_language_get(sd->frame_obj) : NULL;
7060 }
7061
7062 EOLIAN static void
7063 _efl_ui_win_efl_ui_l10n_l10n_text_set(Eo *obj, Efl_Ui_Win_Data *sd, const char *label, const char *domain)
7064 {
7065    if (sd->frame_obj)
7066      efl_ui_l10n_text_set(efl_part(obj, "efl.text.title"), label, domain);
7067 }
7068
7069 EOLIAN static const char *
7070 _efl_ui_win_efl_ui_l10n_l10n_text_get(const Eo *obj, Efl_Ui_Win_Data *sd, const char **domain)
7071 {
7072   return sd->frame_obj ?
7073     efl_ui_l10n_text_get(efl_part(obj, "efl.text.title"), domain) : NULL;
7074 }
7075
7076 EOLIAN static void
7077 _efl_ui_win_win_type_set(Eo *obj, Efl_Ui_Win_Data *sd, Efl_Ui_Win_Type type)
7078 {
7079    if (efl_finalized_get(obj))
7080      {
7081 // TIZEN_ONLY(20160720): Allowed changing type after initializing
7082 #ifdef HAVE_ELEMENTARY_WL2
7083         if (sd->type != EFL_UI_WIN_TYPE_FAKE) sd->type = type;
7084         _elm_win_wlwin_type_update(sd);
7085 //TIZEN_ONLY(20161208): supported floating window
7086         if (type != EFL_UI_WIN_TYPE_BASIC)
7087           edje_object_signal_emit(sd->legacy.edje, "elm,state,floating,on", "elm");
7088         else
7089           edje_object_signal_emit(sd->legacy.edje, "elm,state,floating,off", "elm");
7090 //TIZEN_ONLY(20161208)
7091 #endif
7092 //
7093         ERR("This function is only allowed during construction.");
7094         return;
7095      }
7096    sd->type = type;
7097 }
7098
7099 EOLIAN static Efl_Ui_Win_Type
7100 _efl_ui_win_win_type_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
7101 {
7102    return sd->type;
7103 }
7104
7105 EOLIAN static void
7106 _efl_ui_win_win_name_set(Eo *obj, Efl_Ui_Win_Data *sd, const char *name)
7107 {
7108    if (efl_finalized_get(obj))
7109      {
7110         ERR("This function is only allowed during construction.");
7111         return;
7112      }
7113    sd->name = eina_stringshare_add(name);
7114 }
7115
7116 EOLIAN static const char *
7117 _efl_ui_win_win_name_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
7118 {
7119    return sd->name;
7120 }
7121
7122 EOLIAN static void
7123 _efl_ui_win_accel_preference_set(Eo *obj, Efl_Ui_Win_Data *pd, const char *accel)
7124 {
7125    if (efl_finalized_get(obj))
7126      {
7127         ERR("This function is only allowed during construction.");
7128         return;
7129      }
7130    eina_stringshare_replace(&pd->accel_pref, accel);
7131 }
7132
7133 EOLIAN static const char *
7134 _efl_ui_win_accel_preference_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *pd)
7135 {
7136    return pd->accel_pref;
7137 }
7138
7139 EOLIAN static void
7140 _efl_ui_win_win_role_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, const char *role)
7141 {
7142    if (!role) return;
7143    eina_stringshare_replace(&(sd->role), role);
7144 #ifdef HAVE_ELEMENTARY_X
7145    _elm_win_xwin_update(sd);
7146 #endif
7147    //TIZEN_ONLY(20180619): set role for wayland window
7148 #ifdef HAVE_ELEMENTARY_WL2
7149    ecore_wl2_window_role_set(sd->wl.win, role);
7150 #endif
7151    //
7152 }
7153
7154 EOLIAN static const char*
7155 _efl_ui_win_win_role_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
7156 {
7157    return sd->role;
7158 }
7159
7160 EOLIAN static void
7161 _efl_ui_win_icon_object_set(Eo *obj, Efl_Ui_Win_Data *sd, Evas_Object *icon)
7162 {
7163    if (icon && (!efl_isa(icon, EFL_CANVAS_IMAGE_INTERNAL_CLASS) &&
7164                 !efl_isa(icon, EFL_UI_IMAGE_CLASS)))
7165      {
7166         ERR("Icon object type is not supported!");
7167         efl_del(icon);
7168         return;
7169      }
7170
7171    if (sd->icon)
7172      {
7173         efl_event_callback_del(sd->icon, EFL_EVENT_DEL, _elm_win_on_icon_del, obj);
7174         efl_del(sd->icon);
7175      }
7176    sd->icon = icon;
7177    if (sd->icon)
7178      {
7179         efl_event_callback_add(sd->icon, EFL_EVENT_DEL, _elm_win_on_icon_del, obj);
7180         if (sd->frame_obj)
7181           {
7182              if (elm_widget_is_legacy(sd->obj))
7183                edje_object_part_swallow(sd->frame_obj, "elm.swallow.icon", sd->icon);
7184              else
7185                edje_object_part_swallow(sd->frame_obj, "efl.icon", sd->icon);
7186
7187              evas_object_is_frame_object_set(sd->icon, EINA_TRUE);
7188           }
7189      }
7190 #ifdef HAVE_ELEMENTARY_X
7191    _elm_win_xwin_update(sd);
7192 //TIZEN_ONLY(160628): To support an app window icon on SDK UI Tools.
7193 #elif HAVE_ELEMENTARY_WIN32
7194    const char *path;
7195    elm_image_file_get(icon, &path, NULL);
7196    ecore_win32_window_icon_set(sd->win32.win, path);
7197 #endif
7198 }
7199
7200 EOLIAN static const Evas_Object*
7201 _efl_ui_win_icon_object_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
7202 {
7203    return sd->icon;
7204 }
7205
7206 EOLIAN static const Eina_Value *
7207 _efl_ui_win_exit_on_close_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
7208 {
7209    return &sd->exit_on_close;
7210 }
7211
7212 EOLIAN static void
7213 _efl_ui_win_exit_on_close_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, const Eina_Value *exit_code)
7214 {
7215    const Eina_Value_Type *type = eina_value_type_get(exit_code);
7216
7217    if (type)
7218      eina_value_copy(exit_code, &sd->exit_on_close);
7219    else
7220      eina_value_flush(&sd->exit_on_close);
7221 }
7222
7223 /* Only for C API */
7224 EAPI void
7225 elm_win_autodel_set(Eo *obj, Eina_Bool autodel)
7226 {
7227    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
7228    sd->autodel = autodel;
7229 }
7230
7231 EAPI Eina_Bool
7232 elm_win_autodel_get(const Eo *obj)
7233 {
7234    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
7235    if (!sd) return EINA_FALSE;
7236    return sd->autodel;
7237 }
7238
7239 EOLIAN static void
7240 _efl_ui_win_autohide_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, Eina_Bool autohide)
7241 {
7242    sd->autohide = autohide;
7243 }
7244
7245 EOLIAN static Eina_Bool
7246 _efl_ui_win_autohide_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
7247 {
7248    return sd->autohide;
7249 }
7250
7251 EOLIAN static void
7252 _efl_ui_win_activate(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
7253 {
7254    TRAP(sd, activate);
7255 }
7256
7257 EOLIAN static void
7258 _efl_ui_win_efl_gfx_stack_raise_to_top(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *pd)
7259 {
7260    TRAP(pd, raise);
7261 }
7262
7263 EAPI void
7264 elm_win_raise(Eo *obj)
7265 {
7266    efl_gfx_stack_raise_to_top(obj);
7267 }
7268
7269 EOLIAN static void
7270 _efl_ui_win_efl_gfx_stack_lower_to_bottom(Eo *obj, Efl_Ui_Win_Data *pd EINA_UNUSED)
7271 {
7272    // Do nothing: in X we could request to stack lower but that has been abused
7273    // and transformed into a kind of "iconify". As a consequence, lower is
7274    // not allowed in EO land.
7275    if (!elm_widget_is_legacy(obj)) return;
7276
7277    // Legacy support...
7278    elm_win_lower(obj);
7279 }
7280
7281 EOLIAN static void
7282 _efl_ui_win_center(Eo *obj, Efl_Ui_Win_Data *sd, Eina_Bool h, Eina_Bool v)
7283 {
7284    int win_w, win_h, screen_x, screen_y, screen_w, screen_h, nx, ny;
7285
7286    if (sd->deferred_resize_job) _elm_win_resize_job(sd->obj);
7287    if (sd->frame_obj) edje_object_message_signal_process(sd->frame_obj);
7288    evas_smart_objects_calculate(evas_object_evas_get(obj));
7289    _elm_win_resize_objects_eval(obj, EINA_FALSE);
7290    if ((trap) && (trap->center) && (!trap->center(sd->trap_data, obj, h, v)))
7291      return;
7292
7293    if (!efl_gfx_entity_visible_get(obj))
7294      {
7295         // Chose to use env var so this will also translate more easily
7296         // to wayland. yes - we can get x atoms to figure out if wm is
7297         // enlightenment, but this works just as well. for wl we'd need
7298         // an alternate wl specific way... this below works better IMHO
7299         const char *s = getenv("DESKTOP");
7300
7301         if ((s) && (!strcasecmp(s, "Enlightenment")))
7302           {
7303 #ifdef HAVE_ELEMENTARY_X
7304              if (sd->x.xwin)
7305                {
7306                   static Ecore_X_Atom state = 0;
7307                   static Ecore_X_Atom centered = 0;
7308
7309                   _internal_elm_win_xwindow_get(sd);
7310                   if (!centered) centered = ecore_x_atom_get
7311                     ("__E_ATOM_WINDOW_STATE_CENTERED");
7312                   if (!state) state = ecore_x_atom_get
7313                     ("__E_ATOM_WINDOW_STATE");
7314                   ecore_x_window_prop_card32_set(sd->x.xwin, state, &centered, 1);
7315                }
7316 #endif
7317 // XXX: what to do with wayland?
7318 // XXX: what to do with win32?
7319 // XXX: what to do with osx/coca?
7320 // etc.
7321              return;
7322           }
7323         // not e - fall back to manually placing on what we think the screen
7324         // is/will be... to do this move window to where pointer is first
7325 #ifdef HAVE_ELEMENTARY_X
7326         if (sd->x.xwin)
7327           {
7328              int x = 0, y = 0;
7329
7330              if (sd->req_wh)
7331                {
7332                   win_w = sd->req_w;
7333                   win_h = sd->req_h;
7334                }
7335              else evas_object_geometry_get(obj, NULL, NULL, &win_w, &win_h);
7336              ecore_x_pointer_root_xy_get(&x, &y);
7337              ecore_evas_move(sd->ee, x - (win_w / 2), y - (win_h / 2));
7338           }
7339 #endif
7340 // XXX: what to do with wayland?
7341 // XXX: what to do with win32?
7342 // XXX: what to do with osx/coca?
7343 // etc.
7344      }
7345
7346    ecore_evas_screen_geometry_get(sd->ee,
7347                                   &screen_x, &screen_y,
7348                                   &screen_w, &screen_h);
7349    if ((!screen_w) || (!screen_h)) return;
7350
7351    if (sd->req_wh)
7352      {
7353         win_w = sd->req_w;
7354         win_h = sd->req_h;
7355      }
7356    else evas_object_geometry_get(obj, NULL, NULL, &win_w, &win_h);
7357    if (sd->req_xy)
7358      {
7359         nx = sd->req_x;
7360         ny = sd->req_y;
7361      }
7362    else evas_object_geometry_get(obj, &nx, &ny, NULL, NULL);
7363
7364    if ((!win_w) || (!win_h)) return;
7365
7366    if (h) nx = win_w >= screen_w ? 0 : (screen_w / 2) - (win_w / 2);
7367    if (v) ny = win_h >= screen_h ? 0 : (screen_h / 2) - (win_h / 2);
7368
7369    sd->req_xy = EINA_TRUE;
7370    sd->req_x = screen_x + nx;
7371    sd->req_y = screen_y + ny;
7372    evas_object_move(obj, screen_x + nx, screen_y + ny);
7373 }
7374
7375 EOLIAN static void
7376 _efl_ui_win_borderless_set(Eo *obj, Efl_Ui_Win_Data *sd, Eina_Bool borderless)
7377 {
7378    sd->csd.need_borderless = borderless ? 1 : 0;
7379    _elm_win_frame_style_update(sd, 0, 1);
7380
7381 #ifdef HAVE_ELEMENTARY_X
7382    if (!sd->x.xwin || !sd->csd.need)
7383 #endif
7384      TRAP(sd, borderless_set, borderless);
7385
7386    _elm_win_resize_objects_eval(obj, EINA_FALSE);
7387 #ifdef HAVE_ELEMENTARY_X
7388    _elm_win_xwin_update(sd);
7389 #endif
7390 }
7391
7392 EOLIAN static Eina_Bool
7393 _efl_ui_win_borderless_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
7394 {
7395    if (!sd->csd.need)
7396      return ecore_evas_borderless_get(sd->ee);
7397    return sd->csd.need_borderless;
7398 }
7399
7400 EOLIAN static void
7401 _efl_ui_win_alpha_set(Eo *obj, Efl_Ui_Win_Data *sd, Eina_Bool enabled)
7402 {
7403    sd->application_alpha = enabled;
7404    _elm_win_apply_alpha(obj, sd);
7405    _elm_win_frame_style_update(sd, 0, 1);
7406 }
7407
7408 EOLIAN static Eina_Bool
7409 _efl_ui_win_alpha_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
7410 {
7411    if (sd->img_obj)
7412      {
7413         return evas_object_image_alpha_get(sd->img_obj);
7414      }
7415    else
7416      {
7417         return ecore_evas_alpha_get(sd->ee);
7418      }
7419
7420    return EINA_FALSE;
7421 }
7422
7423 EOLIAN static void
7424 _efl_ui_win_fullscreen_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, Eina_Bool fullscreen)
7425 {
7426    const char *engine_name = ecore_evas_engine_name_get(sd->ee);
7427    // YYY: handle if sd->img_obj
7428    if (engine_name &&
7429        ((!strcmp(engine_name, ELM_SOFTWARE_FB)) ||
7430         (!strcmp(engine_name, ELM_DRM)) ||
7431         (!strcmp(engine_name, ELM_GL_DRM))))
7432      {
7433         // these engines... can ONLY be fullscreen
7434         return;
7435      }
7436    else if (sd->type == EFL_UI_WIN_TYPE_FAKE)
7437      sd->fullscreen = !!fullscreen;
7438    else
7439      {
7440 //        sd->fullscreen = fullscreen;
7441         TRAP(sd, fullscreen_set, fullscreen);
7442
7443 #ifdef HAVE_ELEMENTARY_X
7444         _elm_win_xwin_update(sd);
7445 #endif
7446      }
7447 }
7448
7449 EOLIAN static Eina_Bool
7450 _efl_ui_win_fullscreen_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
7451 {
7452    const char *engine_name = ecore_evas_engine_name_get(sd->ee);
7453
7454    if (engine_name &&
7455        ((!strcmp(engine_name, ELM_SOFTWARE_FB)) ||
7456         (!strcmp(engine_name, ELM_DRM)) ||
7457         (!strcmp(engine_name, ELM_GL_DRM))))
7458      {
7459         // these engines... can ONLY be fullscreen
7460         return EINA_TRUE;
7461      }
7462    return sd->fullscreen;
7463 }
7464
7465 static inline Eo *
7466 _main_menu_swallow_get(Efl_Ui_Win_Data *sd)
7467 {
7468    Eina_Bool legacy_menu_swallow = EINA_TRUE;
7469    const char *data;
7470    int version;
7471
7472    data = edje_object_data_get(sd->legacy.edje, "version");
7473    version = data ? atoi(data) : 0;
7474    if (version >= 119) legacy_menu_swallow = EINA_FALSE;
7475
7476 #ifdef HAVE_ELEMENTARY_COCOA
7477    if (sd->cocoa.win) legacy_menu_swallow = EINA_TRUE;
7478 #endif
7479
7480    if (legacy_menu_swallow)
7481      {
7482         DBG("Detected legacy theme, using legacy swallows.");
7483         return sd->legacy.edje;
7484      }
7485    return sd->frame_obj;
7486 }
7487
7488 static void
7489 _main_menu_resize_cb(void *data EINA_UNUSED, const Efl_Event *ev)
7490 {
7491    // After resize, the framespace size has changed, so update the win geometry
7492    _elm_win_resize_objects_eval(ev->object, EINA_FALSE);
7493    efl_event_callback_del(ev->object, EFL_GFX_ENTITY_EVENT_SIZE_CHANGED, _main_menu_resize_cb, NULL);
7494 }
7495
7496 static void
7497 _dbus_menu_set(Eina_Bool dbus_connect, void *data)
7498 {
7499    ELM_WIN_DATA_GET_OR_RETURN(data, sd);
7500    Eo *swallow = _main_menu_swallow_get(sd);
7501
7502    if (dbus_connect)
7503      {
7504         DBG("Setting menu to D-Bus");
7505         edje_object_part_unswallow(swallow, sd->main_menu);
7506         sd->csd.need_menu = EINA_FALSE;
7507         _elm_menu_menu_bar_hide(sd->main_menu);
7508         _elm_win_resize_objects_eval(sd->obj, EINA_FALSE);
7509         if (swallow != sd->frame_obj)
7510           {
7511              // Note: Based on EFL 1.18 the signal was "elm,action,hide"
7512              // and not "elm,action,hide_menu" as expected.
7513              if (elm_widget_is_legacy(data))
7514                edje_object_signal_emit(swallow, "elm,action,hide", "elm");
7515              else
7516                edje_object_signal_emit(swallow, "efl,action,hide", "efl");
7517              edje_object_message_signal_recursive_process(swallow);
7518           }
7519      }
7520    else
7521      {
7522         DBG("Setting menu to local mode");
7523         efl_event_callback_add(sd->obj, EFL_GFX_ENTITY_EVENT_SIZE_CHANGED, _main_menu_resize_cb, NULL);
7524
7525         if (elm_widget_is_legacy(sd->obj))
7526           edje_object_part_swallow(swallow, "elm.swallow.menu", sd->main_menu);
7527         else
7528           edje_object_part_swallow(swallow, "efl.menu", sd->main_menu);
7529
7530         evas_object_show(sd->main_menu);
7531         if (swallow == sd->frame_obj)
7532           {
7533              efl_canvas_object_is_frame_object_set(sd->main_menu, EINA_TRUE);
7534              sd->csd.need_menu = EINA_TRUE;
7535           }
7536         else
7537           {
7538              if (elm_widget_is_legacy(data))
7539                edje_object_signal_emit(swallow, "elm,action,show_menu", "elm");
7540              else
7541                edje_object_signal_emit(swallow, "efl,action,show_menu", "efl");
7542              edje_object_message_signal_recursive_process(swallow);
7543           }
7544      }
7545    _elm_win_frame_style_update(sd, 0, 1);
7546    //sd->deferred_resize_job = EINA_TRUE;
7547 }
7548
7549 EOLIAN static const Eina_Value *
7550 _efl_ui_win_exit_on_all_windows_closed_get(void)
7551 {
7552    return &exit_on_all_windows_closed;
7553 }
7554
7555 EOLIAN static void
7556 _efl_ui_win_exit_on_all_windows_closed_set(const Eina_Value *exit_code)
7557 {
7558    const Eina_Value_Type *type = eina_value_type_get(exit_code);
7559
7560    if (type)
7561      eina_value_copy(exit_code, &exit_on_all_windows_closed);
7562    else
7563      eina_value_flush(&exit_on_all_windows_closed);
7564 }
7565
7566 EOLIAN static void
7567 _efl_ui_win_maximized_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, Eina_Bool maximized)
7568 {
7569    _elm_win_frame_style_update(sd, 0, 1);
7570    // YYY: handle if sd->img_obj
7571    TRAP(sd, maximized_set, maximized);
7572 #ifdef HAVE_ELEMENTARY_X
7573    _elm_win_xwin_update(sd);
7574 #endif
7575 }
7576
7577 EOLIAN static Eina_Bool
7578 _efl_ui_win_maximized_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
7579 {
7580    return sd->maximized;
7581 }
7582
7583 EOLIAN static void
7584 _efl_ui_win_minimized_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, Eina_Bool minimized)
7585 {
7586 //   sd->minimized = minimized;
7587    TRAP(sd, iconified_set, minimized);
7588 #ifdef HAVE_ELEMENTARY_X
7589    _elm_win_xwin_update(sd);
7590 #endif
7591 }
7592
7593 EOLIAN static Eina_Bool
7594 _efl_ui_win_minimized_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
7595 {
7596    return sd->minimized;
7597 }
7598
7599 EOLIAN static void
7600 _efl_ui_win_wm_available_profiles_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, const Eina_Array *profiles)
7601 {
7602    Eina_Bool found = EINA_FALSE;
7603
7604    _elm_win_available_profiles_del(sd);
7605    if (profiles && eina_array_count(profiles))
7606      {
7607         Eina_Iterator *it;
7608         const char *prof;
7609
7610         it = eina_array_iterator_new(profiles);
7611         EINA_ITERATOR_FOREACH(it, prof)
7612           {
7613              Eina_Stringshare *str = eina_stringshare_add(prof);
7614              if (!str) continue;
7615
7616              eina_array_push(sd->profile.available, str);
7617              /* check to see if a given array has a current profile of elm_win */
7618              if (str == sd->profile.name)
7619                found = EINA_TRUE;
7620           }
7621         eina_iterator_free(it);
7622      }
7623
7624    if (ecore_evas_window_profile_supported_get(sd->ee))
7625      {
7626         ecore_evas_window_available_profiles_set(sd->ee,
7627                                                  (const char **) sd->profile.available->data,
7628                                                  eina_array_count(sd->profile.available));
7629
7630         /* current profile of elm_win is wrong, change profile */
7631         if (!found && eina_array_count(sd->profile.available))
7632           {
7633              eina_stringshare_replace(&(sd->profile.name),
7634                                       eina_array_data_get(sd->profile.available, 0));
7635              ecore_evas_window_profile_set(sd->ee, sd->profile.name);
7636           }
7637
7638      }
7639    else
7640      {
7641         if (eina_array_count(sd->profile.available))
7642           _elm_win_profile_update(sd);
7643      }
7644 }
7645
7646 EOLIAN static const Eina_Array *
7647 _efl_ui_win_wm_available_profiles_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
7648 {
7649    if (ecore_evas_window_profile_supported_get(sd->ee))
7650      {
7651         char **profiles = NULL; // all const
7652         unsigned int count, i;
7653         Eina_Bool ok;
7654
7655         ok = ecore_evas_window_available_profiles_get(sd->ee, &profiles, &count);
7656         if (!ok) return NULL;
7657
7658         if (count == eina_array_count(sd->profile.available))
7659           {
7660              for (i = 0; ok && (i < count); i++)
7661                {
7662                   if (!eina_streq(profiles[i], eina_array_data_get(sd->profile.available, i)))
7663                     ok = EINA_FALSE;
7664                }
7665              if (ok) return sd->profile.available;
7666           }
7667
7668         // Oops! What is going on here? Can this happen?
7669         INF("Available profile list has changed in ecore evas!");
7670         _elm_win_available_profiles_del(sd);
7671         for (i = 0; i < count; i++)
7672           {
7673              Eina_Stringshare *str = eina_stringshare_add(profiles[i]);
7674              if (str) eina_array_push(sd->profile.available, str);
7675           }
7676      }
7677
7678    return sd->profile.available;
7679 }
7680
7681 EOLIAN static void
7682 _efl_ui_win_urgent_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, Efl_Ui_Win_Urgent_Mode urgent)
7683 {
7684    Eina_Bool urgent_tmp = !!urgent;
7685
7686    if (sd->urgent == urgent_tmp) return;
7687
7688    sd->urgent = urgent_tmp;
7689    TRAP(sd, urgent_set, urgent_tmp);
7690 #ifdef HAVE_ELEMENTARY_X
7691    _elm_win_xwin_update(sd);
7692 #endif
7693 }
7694
7695 EOLIAN static Efl_Ui_Win_Urgent_Mode
7696 _efl_ui_win_urgent_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
7697 {
7698    if (sd->urgent) return EFL_UI_WIN_URGENT_MODE_URGENT;
7699    return EFL_UI_WIN_URGENT_MODE_NONE;
7700 }
7701
7702 EOLIAN static void
7703 _efl_ui_win_modal_set(Eo *obj, Efl_Ui_Win_Data *sd, Efl_Ui_Win_Modal_Mode modal)
7704 {
7705    Eina_Bool modal_tmp = !!modal;
7706
7707    if (sd->modal_count) return;
7708
7709    if ((modal_tmp) && (!sd->modal) && (evas_object_visible_get(obj)))
7710      _elm_win_modality_increment(sd);
7711    else if ((!modal_tmp) && (sd->modal) && (evas_object_visible_get(obj)))
7712      _elm_win_modality_decrement(sd);
7713
7714    sd->modal = modal_tmp;
7715    TRAP(sd, modal_set, modal_tmp);
7716 #ifdef HAVE_ELEMENTARY_X
7717    _elm_win_xwin_update(sd);
7718 #endif
7719 }
7720
7721 EOLIAN static Efl_Ui_Win_Modal_Mode
7722 _efl_ui_win_modal_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
7723 {
7724    if (sd->modal) return EFL_UI_WIN_MODAL_MODE_MODAL;
7725    return EFL_UI_WIN_MODAL_MODE_NONE;
7726 }
7727
7728 static void
7729 _win_aspect_set(Efl_Ui_Win_Data *sd, double aspect)
7730 {
7731    sd->aspect = aspect;
7732    TRAP(sd, aspect_set, aspect);
7733 #ifdef HAVE_ELEMENTARY_X
7734    _elm_win_xwin_update(sd);
7735 #endif
7736 }
7737
7738 static double
7739 _win_aspect_get(Efl_Ui_Win_Data *sd)
7740 {
7741    return sd->aspect;
7742 }
7743
7744 EOLIAN static void
7745 _efl_ui_win_efl_gfx_hint_hint_aspect_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *pd,
7746                                               Efl_Gfx_Hint_Aspect mode, Eina_Size2D sz)
7747 {
7748    if (sz.h) _win_aspect_set(pd, (double) sz.w / (double) sz.h);
7749    else _win_aspect_set(pd, 0.0);
7750    efl_gfx_hint_aspect_set(efl_super(obj, MY_CLASS), mode, sz);
7751 #ifdef HAVE_ELEMENTARY_WL2
7752    if (pd->wl.win)
7753      ecore_wl2_window_aspect_set(pd->wl.win, sz.w, sz.h, mode);
7754 #endif
7755 }
7756
7757 EOLIAN static void
7758 _efl_ui_win_efl_gfx_hint_hint_weight_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *pd EINA_UNUSED,
7759                                               double w, double h)
7760 {
7761    efl_gfx_hint_weight_set(efl_super(obj, MY_CLASS), w, h);
7762 #ifdef HAVE_ELEMENTARY_WL2
7763    if (pd->wl.win)
7764      ecore_wl2_window_weight_set(pd->wl.win, w, h);
7765 #endif
7766 }
7767
7768 EOLIAN static void
7769 _efl_ui_win_hint_base_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, Eina_Size2D sz)
7770 {
7771    sd->size_base_w = sz.w;
7772    sd->size_base_h = sz.h;
7773    TRAP(sd, size_base_set, sz.w, sz.h);
7774 #ifdef HAVE_ELEMENTARY_X
7775    _elm_win_xwin_update(sd);
7776 #endif
7777 }
7778
7779 EOLIAN static Eina_Size2D
7780 _efl_ui_win_hint_base_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
7781 {
7782    return EINA_SIZE2D(sd->size_base_w, sd->size_base_h);
7783 }
7784
7785 EOLIAN static void
7786 _efl_ui_win_hint_step_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, Eina_Size2D sz)
7787 {
7788    sd->size_step_w = sz.w;
7789    sd->size_step_h = sz.h;
7790    TRAP(sd, size_step_set, sz.w, sz.h);
7791 #ifdef HAVE_ELEMENTARY_X
7792    _elm_win_xwin_update(sd);
7793 #endif
7794 }
7795
7796 EOLIAN static void
7797 _efl_ui_win_efl_gfx_hint_hint_size_max_set(Eo *obj, Efl_Ui_Win_Data *sd, Eina_Size2D sz)
7798 {
7799    if (sd->tmp_updating_hints)
7800      {
7801         efl_gfx_hint_size_max_set(efl_super(obj, MY_CLASS), sz);
7802      }
7803    else
7804      {
7805         if (sz.w < 1) sz.w = -1;
7806         if (sz.h < 1) sz.h = -1;
7807         sd->max_w = sz.w;
7808         sd->max_h = sz.h;
7809         _elm_win_resize_objects_eval(obj, EINA_FALSE);
7810      }
7811 }
7812
7813 EOLIAN static Eina_Size2D
7814 _efl_ui_win_hint_step_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
7815 {
7816    return EINA_SIZE2D(sd->size_step_w, sd->size_step_h);
7817 }
7818
7819 EAPI void
7820 elm_win_norender_push(Evas_Object *obj)
7821 {
7822    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
7823    if (!sd) return;
7824
7825    sd->norender++;
7826    if (sd->norender == 1) ecore_evas_manual_render_set(sd->ee, EINA_TRUE);
7827 }
7828
7829 EAPI void
7830 elm_win_norender_pop(Evas_Object *obj)
7831 {
7832    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
7833    if (!sd) return;
7834
7835    if (sd->norender <= 0) return;
7836    sd->norender--;
7837    if (sd->norender == 0) ecore_evas_manual_render_set(sd->ee, EINA_FALSE);
7838 }
7839
7840 EAPI int
7841 elm_win_norender_get(const Evas_Object *obj)
7842 {
7843    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
7844    if (!sd) return -1;
7845
7846    return sd->norender;
7847 }
7848
7849 EAPI void
7850 elm_win_render(Evas_Object *obj)
7851 {
7852    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
7853    if (!sd) return;
7854
7855    ecore_evas_manual_render(sd->ee);
7856 }
7857
7858 // TIZEN_ONLY(20170212): pend rotation until app set rotation
7859 /*
7860  * This API rotates the window by app side.
7861  */
7862
7863 static void
7864 _win_pending_rotate(Evas_Object *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, int rotation, Eina_Bool resize)
7865 {
7866    rotation = _win_rotation_degree_check(rotation);
7867    DBG("PendingRotation: elm_win pending rotation set rot=%d", rotation);
7868    if (sd->rot == rotation) return;
7869
7870    //TODO: We need time to set up the role of pending rotation between the server and client.
7871    //and also need time to discuss this concept with opensource.
7872    //so until that time, we add ecore evas data instead of opening the new ecore_evas_XXX api.
7873    ecore_evas_data_set(sd->ee, "pending_rotation", (void *)1);
7874
7875    // Currently only support rotation_with_resize
7876    if (resize) TRAP(sd, rotation_with_resize_set, rotation);
7877    else return;
7878 }
7879 //
7880
7881 /*
7882  * This API resizes the internal window(ex: X window) and evas_output.
7883  * But this does not resize the elm window object and its contents.
7884  */
7885
7886 EOLIAN static void
7887 _efl_ui_win_wm_available_rotations_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd,
7888                                        Eina_Bool allow_0, Eina_Bool allow_90,
7889                                        Eina_Bool allow_180, Eina_Bool allow_270)
7890 {
7891    unsigned cnt = 0;
7892    int rots[4];
7893
7894    if (allow_0) rots[cnt++] = 0;
7895    if (allow_90) rots[cnt++] = 90;
7896    if (allow_180) rots[cnt++] = 180;
7897    if (allow_270) rots[cnt++] = 270;
7898    sd->wm_rot.use = EINA_TRUE;
7899
7900    ELM_SAFE_FREE(sd->wm_rot.rots, free);
7901    sd->wm_rot.count = 0;
7902
7903    if (cnt)
7904      {
7905         sd->wm_rot.rots = malloc(sizeof(int) * cnt);
7906         if (!sd->wm_rot.rots) return;
7907         memcpy(sd->wm_rot.rots, rots, cnt * sizeof(int));
7908         sd->wm_rot.count = cnt;
7909      }
7910
7911    ecore_evas_wm_rotation_available_rotations_set(sd->ee,
7912                                                   sd->wm_rot.rots,
7913                                                   sd->wm_rot.count);
7914 }
7915
7916 EOLIAN static Eina_Bool
7917 _efl_ui_win_wm_available_rotations_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd,
7918                                        Eina_Bool *allow_0, Eina_Bool *allow_90,
7919                                        Eina_Bool *allow_180, Eina_Bool *allow_270)
7920 {
7921    if (!sd->wm_rot.use) goto end;
7922
7923    if (allow_0) *allow_0 = EINA_FALSE;
7924    if (allow_90) *allow_90 = EINA_FALSE;
7925    if (allow_180) *allow_180 = EINA_FALSE;
7926    if (allow_270) *allow_270 = EINA_FALSE;
7927
7928    for (unsigned k = 0; k < sd->wm_rot.count; k++)
7929      {
7930         switch (sd->wm_rot.rots[k])
7931           {
7932            case 0: if (allow_0) *allow_0 = EINA_TRUE; break;
7933            case 90: if (allow_90) *allow_90 = EINA_TRUE; break;
7934            case 180: if (allow_180) *allow_180 = EINA_TRUE; break;
7935            case 270: if (allow_270) *allow_270 = EINA_TRUE; break;
7936            default: ERR("Unsupported rotation %d", sd->wm_rot.rots[k]); break;
7937           }
7938      }
7939
7940 end:
7941    return !!sd->wm_rot.use;
7942 }
7943
7944 EAPI void
7945 elm_win_wm_rotation_available_rotations_set(Elm_Win *obj, const int *rotations, unsigned int count)
7946 {
7947    Eina_Bool allow[4] = { 0, };
7948    int found = 0;
7949
7950    if (!rotations || !count) goto end;
7951    for (unsigned k = 0; (k < count) && (found < 4); k++)
7952      {
7953         int rot = (((rotations[k] % 360) + 360) % 360) / 90;
7954         if (!allow[rot])
7955           {
7956              allow[rot] = EINA_TRUE;
7957              found++;
7958           }
7959      }
7960
7961 end:
7962    efl_ui_win_wm_available_rotations_set(obj, allow[0], allow[1], allow[2], allow[3]);
7963 }
7964
7965 EAPI Eina_Bool
7966 elm_win_wm_rotation_available_rotations_get(const Elm_Win *obj, int **rotations, unsigned int *count)
7967 {
7968    int rots[4] = { 0, };
7969    Eina_Bool allow[4] = { 0, };
7970    unsigned cnt = 0;
7971
7972    if (!efl_ui_win_wm_available_rotations_get(obj, &allow[0], &allow[1], &allow[2], &allow[3]))
7973      goto none;
7974
7975    for (int k = 0; k < 4; k++)
7976      if (allow[k])
7977        rots[cnt++] = k * 90;
7978
7979    if (!cnt) goto none;
7980
7981    if (rotations)
7982      {
7983         *rotations = malloc(sizeof(int) * cnt);
7984         if (!*rotations) goto none;
7985         memcpy(*rotations, rots, cnt * sizeof(int));
7986      }
7987    if (count) *count = cnt;
7988    return EINA_TRUE;
7989
7990 none:
7991    if (rotations) *rotations = NULL;
7992    if (count) *count = 0;
7993    return EINA_FALSE;
7994 }
7995
7996 EOLIAN static void
7997 _efl_ui_win_sticky_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, Eina_Bool sticky)
7998 {
7999 //   sd->sticky = sticky;
8000    TRAP(sd, sticky_set, sticky);
8001 #ifdef HAVE_ELEMENTARY_X
8002    _elm_win_xwin_update(sd);
8003 #endif
8004 }
8005
8006 EOLIAN static Eina_Bool
8007 _efl_ui_win_sticky_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
8008 {
8009    return sd->sticky;
8010 }
8011
8012 EOLIAN static void
8013 _efl_ui_win_keyboard_mode_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, Efl_Ui_Win_Keyboard_Mode mode)
8014 {
8015    if (mode == sd->kbdmode) return;
8016 #ifdef HAVE_ELEMENTARY_X
8017    _internal_elm_win_xwindow_get(sd);
8018 #endif
8019    sd->kbdmode = mode;
8020 #ifdef HAVE_ELEMENTARY_X
8021    if (sd->x.xwin)
8022      {
8023         _internal_elm_win_xwindow_get(sd);
8024         ecore_x_e_virtual_keyboard_state_set
8025           (sd->x.xwin, (Ecore_X_Virtual_Keyboard_State)sd->kbdmode);
8026      }
8027 #endif
8028 }
8029
8030 EOLIAN static Efl_Ui_Win_Keyboard_Mode
8031 _efl_ui_win_keyboard_mode_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
8032 {
8033    return sd->kbdmode;
8034 }
8035
8036 EOLIAN static void
8037 _efl_ui_win_indicator_mode_set(Eo *obj, Efl_Ui_Win_Data *sd, Efl_Ui_Win_Indicator_Mode mode)
8038 {
8039    sd->legacy.forbidden = EINA_TRUE;
8040    if (sd->indimode == mode) return;
8041    sd->indimode = mode;
8042
8043    if (sd->indimode == EFL_UI_WIN_INDICATOR_MODE_OFF)
8044      {
8045         _indicator_del(sd);
8046         return;
8047      }
8048
8049    if (!sd->indicator) _indicator_add(sd);
8050
8051    if (elm_widget_is_legacy(obj))
8052      {
8053         if (sd->indimode == EFL_UI_WIN_INDICATOR_MODE_BG_OPAQUE)
8054           edje_object_signal_emit(sd->frame_obj, "elm,action,indicator,bg_opaque", "elm");
8055         else if (sd->indimode == EFL_UI_WIN_INDICATOR_MODE_BG_TRANSPARENT)
8056           edje_object_signal_emit(sd->frame_obj, "elm,action,indicator,bg_transparent", "elm");
8057         else if (sd->indimode == EFL_UI_WIN_INDICATOR_MODE_HIDDEN)
8058           edje_object_signal_emit(sd->frame_obj, "elm,action,indicator,hidden", "elm");
8059      }
8060    else
8061      {
8062         if (sd->indimode == EFL_UI_WIN_INDICATOR_MODE_BG_OPAQUE)
8063           edje_object_signal_emit(sd->frame_obj, "efl,action,indicator,bg_opaque", "efl");
8064         else if (sd->indimode == EFL_UI_WIN_INDICATOR_MODE_BG_TRANSPARENT)
8065           edje_object_signal_emit(sd->frame_obj, "efl,action,indicator,bg_transparent", "efl");
8066         else if (sd->indimode == EFL_UI_WIN_INDICATOR_MODE_HIDDEN)
8067           edje_object_signal_emit(sd->frame_obj, "efl,action,indicator,hidden", "efl");
8068      }
8069
8070    edje_object_message_signal_process(sd->frame_obj);
8071    evas_object_smart_calculate(sd->frame_obj);
8072    _elm_win_frame_obj_update(sd, 0);
8073 }
8074
8075 EOLIAN static Efl_Ui_Win_Indicator_Mode
8076 _efl_ui_win_indicator_mode_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd EINA_UNUSED)
8077 {
8078    sd->legacy.forbidden = EINA_TRUE;
8079    return sd->indimode;
8080 }
8081
8082 EOLIAN EINA_UNUSED static Eina_Bool
8083 _efl_ui_win_efl_ui_focus_object_focus_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
8084 {
8085    // Bypass widget implementation here.
8086    return ecore_evas_focus_get(sd->ee);
8087 }
8088
8089 EOLIAN static void
8090 _efl_ui_win_screen_constrain_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, Eina_Bool constrain)
8091 {
8092    sd->constrain = !!constrain;
8093 }
8094
8095 EOLIAN static Eina_Bool
8096 _efl_ui_win_screen_constrain_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
8097 {
8098    return sd->constrain;
8099 }
8100
8101 EOLIAN static Eina_Size2D
8102 _efl_ui_win_efl_screen_screen_size_in_pixels_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
8103 {
8104    Eina_Size2D sz;
8105    ecore_evas_screen_geometry_get(sd->ee, NULL, NULL, &sz.w, &sz.h);
8106    return sz;
8107 }
8108
8109 EOLIAN static void
8110 _efl_ui_win_efl_screen_screen_dpi_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, int *xdpi, int *ydpi)
8111 {
8112    ecore_evas_screen_dpi_get(sd->ee, xdpi, ydpi);
8113 }
8114
8115 EOLIAN static int
8116 _efl_ui_win_efl_screen_screen_rotation_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
8117 {
8118    //TODO: query to wm about device's rotation
8119    (void)sd;
8120    WRN("Not yet implemented");
8121    return 0;
8122 }
8123
8124 EOLIAN static float
8125 _efl_ui_win_efl_screen_screen_scale_factor_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd EINA_UNUSED)
8126 {
8127    WRN("Not yet implemented");
8128    return 1.0;
8129 }
8130
8131 EOLIAN static void
8132 _efl_ui_win_prop_focus_skip_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, Eina_Bool skip)
8133 {
8134    // TIZEN_ONLY(20160404)  skip_focus in case invoking elm_win_quickpanel_set
8135    _elm_win_focus_skip_set(sd, skip);
8136    //
8137 }
8138
8139 EOLIAN static void
8140 _efl_ui_win_focus_highlight_enabled_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, Eina_Bool enabled)
8141 {
8142    enabled = !!enabled;
8143    if (sd->focus_highlight.enabled == enabled)
8144      return;
8145
8146    sd->focus_highlight.enabled = enabled;
8147
8148    if ((sd->focus_highlight.enabled) || (sd->focus_highlight.auto_enabled))
8149      _elm_win_focus_highlight_init(sd);
8150    else
8151      _elm_win_focus_highlight_shutdown(sd);
8152 }
8153
8154 EOLIAN static Eina_Bool
8155 _efl_ui_win_focus_highlight_enabled_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
8156 {
8157    return sd->focus_highlight.enabled;
8158 }
8159
8160 static Eina_Error
8161 _elm_win_theme_internal(Eo *obj, Efl_Ui_Win_Data *sd)
8162 {
8163    Eina_Error int_ret = EFL_UI_THEME_APPLY_ERROR_GENERIC;
8164    Eina_Bool prev_alpha;
8165    const char *s;
8166
8167    int_ret = elm_widget_theme_object_set(obj, sd->legacy.edje, "win", "base",
8168                                        elm_widget_style_get(obj));
8169    if (int_ret == EFL_UI_THEME_APPLY_ERROR_GENERIC) return int_ret;
8170
8171    edje_object_mirrored_set(sd->legacy.edje, efl_ui_mirrored_get(obj));
8172    edje_object_scale_set(sd->legacy.edje,
8173                          efl_gfx_entity_scale_get(obj) * elm_config_scale_get());
8174
8175    efl_event_callback_legacy_call(obj, EFL_UI_WIN_EVENT_THEME_CHANGED, NULL);
8176
8177    prev_alpha = sd->theme_alpha;
8178    s = edje_object_data_get(sd->legacy.edje, "alpha");
8179    sd->theme_alpha = (eina_streq(s, "1") || eina_streq(s, "true"));
8180    if (sd->theme_alpha != prev_alpha)
8181      _elm_win_apply_alpha(obj, sd);
8182
8183    return int_ret;
8184 }
8185
8186 EOLIAN static Eina_Error
8187 _efl_ui_win_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Win_Data *sd)
8188 {
8189    Eina_Error int_ret = EFL_UI_THEME_APPLY_ERROR_GENERIC;
8190    int_ret = efl_ui_widget_theme_apply(efl_super(obj, MY_CLASS));
8191    if (int_ret == EFL_UI_THEME_APPLY_ERROR_GENERIC) return int_ret;
8192
8193    sd->focus_highlight.theme_changed = EINA_TRUE;
8194
8195    int_ret = _elm_win_theme_internal(obj, sd) & int_ret;
8196    if (int_ret == EFL_UI_THEME_APPLY_ERROR_GENERIC) return int_ret;
8197    _elm_win_focus_highlight_reconfigure_job_start(sd);
8198
8199    return int_ret;
8200 }
8201
8202 EOLIAN static Eina_Bool
8203 _efl_ui_win_focus_highlight_style_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, const char *style)
8204 {
8205    if (!eina_stringshare_replace(&sd->focus_highlight.style, style))
8206      return EINA_TRUE;
8207
8208    sd->focus_highlight.theme_changed = EINA_TRUE;
8209    _elm_win_focus_highlight_reconfigure_job_start(sd);
8210    return EINA_TRUE;
8211 }
8212
8213 EOLIAN static const char*
8214 _efl_ui_win_focus_highlight_style_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
8215 {
8216    return sd->focus_highlight.style;
8217 }
8218
8219 EOLIAN static void
8220 _efl_ui_win_focus_highlight_animate_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, Eina_Bool animate)
8221 {
8222    animate = !!animate;
8223    if (sd->focus_highlight.animate == animate)
8224      return;
8225
8226    sd->focus_highlight.animate = animate;
8227    sd->focus_highlight.theme_changed = EINA_TRUE;
8228    _elm_win_focus_highlight_reconfigure_job_start(sd);
8229 }
8230
8231 EOLIAN static Eina_Bool
8232 _efl_ui_win_focus_highlight_animate_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
8233 {
8234    return sd->focus_highlight.animate;
8235 }
8236
8237 EOLIAN static const char *
8238 _efl_ui_win_stack_id_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
8239 {
8240    return sd->stack_id;
8241 }
8242
8243 EOLIAN static void
8244 _efl_ui_win_stack_master_id_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, const char *id)
8245 {
8246    if (sd->shown) return;
8247    eina_stringshare_replace(&(sd->stack_master_id), id);
8248 #ifdef HAVE_ELEMENTARY_X
8249    if (sd->x.xwin)
8250      _elm_win_xwin_update(sd);
8251    else
8252 #endif
8253      {
8254         int num = ecore_evas_aux_hint_id_get(sd->ee, "stack_master_id");
8255         if (num >= 0)
8256           ecore_evas_aux_hint_val_set(sd->ee, num, id);
8257         else
8258           ecore_evas_aux_hint_add(sd->ee, "stack_master_id", id);
8259      }
8260 }
8261
8262 EOLIAN static const char *
8263 _efl_ui_win_stack_master_id_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
8264 {
8265    return sd->stack_master_id;
8266 }
8267
8268 EOLIAN static void
8269 _efl_ui_win_stack_base_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, Eina_Bool base)
8270 {
8271    int num;
8272    if (sd->shown) return;
8273    sd->stack_base = !!base;
8274    num = ecore_evas_aux_hint_id_get(sd->ee, "stack_base");
8275    if (num >= 0)
8276      ecore_evas_aux_hint_val_set(sd->ee, num, sd->stack_base ? "1" : "0");
8277    else
8278      ecore_evas_aux_hint_add(sd->ee, "stack_base", sd->stack_base ? "1" : "0");
8279 }
8280
8281 EOLIAN static Eina_Bool
8282 _efl_ui_win_stack_base_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
8283 {
8284    return sd->stack_base;
8285 }
8286
8287 #ifdef HAVE_ELEMENTARY_X
8288 // list transient from bottom to top by recursive walking
8289 static void
8290 _x_transients_for_list(Ecore_X_Window base, Ecore_X_Window transient,
8291                        Ecore_X_Window **wins, int *num)
8292 {
8293    Ecore_X_Window t, *children, *w;
8294    int n, i;
8295
8296    children = ecore_x_window_children_get(base, &n);
8297    if (children)
8298      {
8299         for (i = 0; i < n; i++)
8300           {
8301              if (children[i] != transient)
8302                {
8303                   t = ecore_x_icccm_transient_for_get(children[i]);
8304                   if (t == transient)
8305                     {
8306                        (*num)++;
8307                        w = realloc(*wins, *num * sizeof(Ecore_X_Window));
8308                        if (w)
8309                          {
8310                             *wins = w;
8311                             (*wins)[*num - 1] = children[i];
8312                          }
8313                     }
8314                   _x_transients_for_list(children[i], transient, wins, num);
8315                }
8316           }
8317         free(children);
8318      }
8319 }
8320 #endif
8321
8322 EOLIAN static void
8323 _efl_ui_win_stack_pop_to(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd)
8324 {
8325    if (!sd->stack_master_id) return;
8326 #ifdef HAVE_ELEMENTARY_X
8327    if (sd->x.xwin)
8328      {
8329         Ecore_X_Window *wins = NULL;
8330         int i, num = 0;
8331         Eina_Bool del = EINA_FALSE;
8332
8333         _internal_elm_win_xwindow_get(sd);
8334         ecore_x_grab();
8335         _x_transients_for_list
8336           (ecore_x_window_root_get(sd->x.xwin),
8337            ecore_x_icccm_transient_for_get(sd->x.xwin),
8338            &wins, &num);
8339         if (wins)
8340           {
8341              for (i = 0; i < num; i++)
8342                {
8343                   if (del) ecore_x_window_delete_request_send(wins[i]);
8344                   if (wins[i] == sd->x.xwin) del = EINA_TRUE;
8345                }
8346              free(wins);
8347           }
8348         ecore_x_ungrab();
8349      }
8350    else
8351 #endif
8352      {
8353         int num = ecore_evas_aux_hint_id_get(sd->ee, "stack_pop_to");
8354         if (num >= 0) ecore_evas_aux_hint_val_set(sd->ee, num, "1");
8355         else ecore_evas_aux_hint_add(sd->ee, "stack_pop_to", "1");
8356      }
8357    // win32/osx ?
8358 }
8359
8360 EAPI Eina_Bool
8361 elm_win_trap_set(const Elm_Win_Trap *t)
8362 {
8363    DBG("old %p, new %p", trap, t);
8364
8365    if ((t) && (t->version != ELM_WIN_TRAP_VERSION))
8366      {
8367         CRI("trying to set a trap version %lu while %lu was expected!",
8368                  t->version, ELM_WIN_TRAP_VERSION);
8369         return EINA_FALSE;
8370      }
8371
8372    trap = t;
8373    return EINA_TRUE;
8374 }
8375
8376 EAPI void
8377 elm_win_floating_mode_set(Evas_Object *obj, Eina_Bool floating)
8378 {
8379    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
8380    if (!sd) return;
8381
8382    floating = !!floating;
8383    if (floating == sd->floating) return;
8384    sd->floating = floating;
8385 //TIZEN_ONLY(20171114): implement elm_win_floating_mode_set on wayland
8386 #if HAVE_ELEMENTARY_WL2
8387    _elm_win_wlwindow_get(sd);
8388    if (sd->wl.win)
8389      {
8390 //TIZEN_ONLY(20161208): supported floating window
8391         if (floating)
8392           edje_object_signal_emit(sd->legacy.edje, "elm,state,floating,on", "elm");
8393         else
8394           edje_object_signal_emit(sd->legacy.edje, "elm,state,floating,off", "elm");
8395 //
8396
8397         // TODO: frame style(csd) shall be applied refer to Eina_Bool floating
8398         ecore_wl2_window_floating_mode_set(sd->wl.win, floating);
8399      }
8400 #endif
8401 //
8402 #ifdef HAVE_ELEMENTARY_X
8403    _internal_elm_win_xwindow_get(sd);
8404    if (sd->x.xwin)
8405      {
8406         _internal_elm_win_xwindow_get(sd);
8407         if (sd->floating)
8408           ecore_x_e_illume_window_state_set
8409              (sd->x.xwin, ECORE_X_ILLUME_WINDOW_STATE_FLOATING);
8410         else
8411           ecore_x_e_illume_window_state_set
8412              (sd->x.xwin, ECORE_X_ILLUME_WINDOW_STATE_NORMAL);
8413      }
8414 #endif
8415 }
8416
8417 EAPI Eina_Bool
8418 elm_win_floating_mode_get(const Evas_Object *obj)
8419 {
8420    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
8421    if (!sd) return EINA_FALSE;
8422
8423    return sd->floating;
8424 }
8425
8426 void
8427 _elm_win_focus_highlight_in_theme_update(Evas_Object *obj, Eina_Bool in_theme)
8428 {
8429    ELM_WIN_DATA_GET(obj, sd);
8430    sd->focus_highlight.cur.in_theme = !!in_theme;
8431 }
8432
8433 void
8434 _elm_win_focus_highlight_start(Evas_Object *obj)
8435 {
8436    ELM_WIN_DATA_GET(obj, sd);
8437
8438    if (!(sd->focus_highlight.enabled) && !(sd->focus_highlight.auto_enabled)) return;
8439    sd->focus_highlight.cur.visible = EINA_TRUE;
8440    sd->focus_highlight.geometry_changed = EINA_TRUE;
8441    _elm_win_focus_highlight_reconfigure_job(obj);
8442 }
8443
8444 void
8445 _elm_win_focus_auto_show(Evas_Object *obj)
8446 {
8447    ELM_WIN_DATA_GET(obj, sd);
8448    Eina_Bool pfocus = (sd->focus_highlight.enabled) || (sd->focus_highlight.auto_enabled);
8449    sd->focus_highlight.auto_enabled = _elm_config->win_auto_focus_enable;
8450    sd->focus_highlight.auto_animate = _elm_config->win_auto_focus_animate;
8451    if (pfocus != ((sd->focus_highlight.enabled) || (sd->focus_highlight.auto_enabled)))
8452      {
8453         if ((sd->focus_highlight.enabled) || (sd->focus_highlight.auto_enabled))
8454           _elm_win_focus_highlight_init(sd);
8455      }
8456 }
8457
8458 void
8459 _elm_win_focus_auto_hide(Evas_Object *obj)
8460 {
8461    ELM_WIN_DATA_GET(obj, sd);
8462    Eina_Bool pfocus = (sd->focus_highlight.enabled) || (sd->focus_highlight.auto_enabled);
8463    sd->focus_highlight.auto_enabled = EINA_FALSE;
8464    sd->focus_highlight.auto_animate = EINA_FALSE;
8465    if (pfocus != ((sd->focus_highlight.enabled) || (sd->focus_highlight.auto_enabled)))
8466      {
8467         if (!((sd->focus_highlight.enabled) || (sd->focus_highlight.auto_enabled)))
8468           _elm_win_focus_highlight_shutdown(sd);
8469      }
8470 }
8471
8472 EOLIAN static void
8473 _efl_ui_win_class_constructor(Efl_Class *klass EINA_UNUSED)
8474 {
8475 }
8476
8477 EOLIAN static void
8478 _efl_ui_win_efl_object_debug_name_override(Eo *obj, Efl_Ui_Win_Data *pd, Eina_Strbuf *sb)
8479 {
8480    efl_debug_name_override(efl_super(obj, MY_CLASS), sb);
8481    eina_strbuf_append_printf(sb, ":'%s':'%s'", pd->name, pd->title);
8482 }
8483
8484 EOLIAN static const Efl_Access_Action_Data*
8485 _efl_ui_win_efl_access_widget_action_elm_actions_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd EINA_UNUSED)
8486 {
8487    static Efl_Access_Action_Data atspi_actions[] = {
8488           { "move,previous", "move", "previous", _key_action_move},
8489           { "move,next", "move", "next", _key_action_move},
8490           { "move,left", "move", "left", _key_action_move},
8491           { "move,right", "move", "right", _key_action_move},
8492           { "move,up", "move", "up", _key_action_move},
8493           { "move,down", "move", "down", _key_action_move},
8494           { NULL, NULL, NULL, NULL }
8495    };
8496    return &atspi_actions[0];
8497 }
8498
8499 EOLIAN static Efl_Access_State_Set
8500 _efl_ui_win_efl_access_object_state_set_get(const Eo *obj, Efl_Ui_Win_Data *sd EINA_UNUSED)
8501 {
8502    Efl_Access_State_Set ret;
8503    ret = efl_access_object_state_set_get(efl_super(obj, MY_CLASS));
8504
8505    if (elm_win_focus_get(obj))
8506      STATE_TYPE_SET(ret, EFL_ACCESS_STATE_TYPE_ACTIVE);
8507
8508    return ret;
8509 }
8510
8511 EOLIAN static const char*
8512 _efl_ui_win_efl_access_object_i18n_name_get(const Eo *obj, Efl_Ui_Win_Data *sd EINA_UNUSED)
8513 {
8514    const char *ret;
8515    ret = efl_access_object_i18n_name_get(efl_super(obj, EFL_UI_WIN_CLASS));
8516    if (ret) return ret;
8517    const char *name = elm_win_title_get(obj);
8518    return _elm_widget_accessible_plain_name_get(obj, name);
8519 }
8520
8521 //TIZEN_ONLY(20220322): add resource id to window attribute
8522 EOLIAN static Eina_List*
8523 _efl_ui_win_efl_access_object_attributes_get(const Eo *obj, Efl_Ui_Win_Data *sd)
8524 {
8525    Eina_List *attr_list = NULL;
8526    attr_list = efl_access_object_attributes_get(efl_super(obj, EFL_UI_WIN_CLASS));
8527
8528 #ifdef HAVE_ELEMENTARY_WL2
8529    //Add resource id
8530    Eina_Strbuf *str_buf;
8531    unsigned int resource_id;
8532    const char *resID;
8533    Efl_Access_Attribute *attr = NULL;
8534
8535    str_buf = eina_strbuf_new();
8536    resource_id = ecore_wl2_window_resource_id_get(sd->wl.win);
8537
8538    eina_strbuf_append_printf(str_buf, "%u", resource_id);
8539    resID = eina_strbuf_string_get(str_buf);
8540
8541    attr = calloc(1, sizeof(Efl_Access_Attribute));
8542    if (attr)
8543      {
8544         attr->key = eina_stringshare_add("resID");
8545         attr->value = eina_stringshare_add(resID);
8546         attr_list = eina_list_append(attr_list, attr);
8547      }
8548
8549    eina_strbuf_free(str_buf);
8550 #endif
8551
8552    return attr_list;
8553 }
8554 //
8555
8556 EOLIAN static Eina_Rect
8557 _efl_ui_win_efl_access_component_extents_get(const Eo *obj, Efl_Ui_Win_Data *_pd EINA_UNUSED, Eina_Bool screen_coords)
8558 {
8559    Eina_Rect r;
8560
8561    r = efl_gfx_entity_geometry_get(obj);
8562    r.x = r.y = 0;
8563    if (screen_coords)
8564      {
8565         r = _efl_access_component_screen_coords_extents_get(obj, r);
8566      }
8567    return r;
8568 }
8569
8570 EOLIAN static Eina_Bool
8571 _efl_ui_win_efl_input_state_modifier_enabled_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *pd,
8572                                                  Efl_Input_Modifier mod, const Efl_Input_Device *seat)
8573 {
8574    const Evas_Modifier *m = evas_key_modifier_get(pd->evas);
8575    const char *name = _efl_input_modifier_to_string(mod);
8576    return evas_seat_key_modifier_is_set(m, name, seat);
8577 }
8578
8579 EOLIAN static Eina_Bool
8580 _efl_ui_win_efl_input_state_lock_enabled_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *pd,
8581                                              Efl_Input_Lock lock, const Efl_Input_Device *seat)
8582 {
8583    const Evas_Lock *m = evas_key_lock_get(pd->evas);
8584    const char *name = _efl_input_lock_to_string(lock);
8585    return evas_seat_key_lock_is_set(m, name, seat);
8586 }
8587
8588 EOLIAN static Efl_Object *
8589 _efl_ui_win_efl_object_provider_find(const Eo *obj,
8590                                      Efl_Ui_Win_Data *pd EINA_UNUSED,
8591                                      const Efl_Object *klass)
8592 {
8593     if (klass == EFL_UI_WIN_CLASS)
8594       return (Eo *)obj;
8595
8596    // attach all kinds of windows directly to ATSPI application root object
8597    if (klass == EFL_ACCESS_OBJECT_MIXIN) return efl_access_object_access_root_get();
8598
8599     if (klass == EFL_UI_FOCUS_PARENT_PROVIDER_INTERFACE)
8600       return pd->provider;
8601
8602     return efl_provider_find(efl_super(obj, MY_CLASS), klass);
8603 }
8604
8605 // See evas_inline.x
8606 #define _EVAS_COLOR_CLAMP(x, y) do { \
8607 if (x > y) { x = y; bad = 1; } \
8608 if (x < 0) { x = 0; bad = 1; } } while (0)
8609
8610 #define EVAS_COLOR_SANITIZE(r, g, b, a) \
8611 ({ int bad = 0; \
8612    _EVAS_COLOR_CLAMP(a, 255); \
8613    _EVAS_COLOR_CLAMP(r, a); \
8614    _EVAS_COLOR_CLAMP(g, a); \
8615    _EVAS_COLOR_CLAMP(b, a); \
8616    bad; })
8617
8618 /* Efl.Part APIs */
8619
8620 #define WIN_PART_ERR(part) ERR("No such part in window: '%s'. Supported parts are: 'content' and 'background'.", part);
8621
8622 static Eina_Bool
8623 _elm_win_bg_set(Efl_Ui_Win_Data *sd, Eo *bg)
8624 {
8625    ELM_SAFE_DEL(sd->bg);
8626    if (!bg) return EINA_TRUE;
8627
8628    if (!elm_widget_sub_object_add(sd->obj, bg))
8629      return EINA_FALSE;
8630    if (elm_widget_is_legacy(sd->obj))
8631      {
8632         if (!_elm_config->win_no_border)
8633           {
8634              if (!edje_object_part_swallow(sd->frame_obj, "elm.swallow.background", bg))
8635                return EINA_FALSE;
8636           }
8637         else
8638           {
8639              if (!edje_object_part_swallow(sd->legacy.edje, "elm.swallow.background", bg))
8640                return EINA_FALSE;
8641           }
8642      }
8643    else
8644      {
8645         if (!_elm_config->win_no_border)
8646           {
8647              if (!edje_object_part_swallow(sd->frame_obj, "efl.background", bg))
8648                return EINA_FALSE;
8649           }
8650         else
8651           {
8652              if (!edje_object_part_swallow(sd->legacy.edje, "efl.background", bg))
8653                return EINA_FALSE;
8654           }
8655      }
8656    efl_gfx_entity_visible_set(bg, 1);
8657    efl_gfx_hint_fill_set(bg, EINA_TRUE, EINA_TRUE);
8658    efl_gfx_hint_weight_set(bg, 1, 1);
8659    efl_wref_add(bg, &sd->bg);
8660    return EINA_TRUE;
8661 }
8662
8663 /* Legacy theme compatibility */
8664 static Eina_Bool
8665 _elm_win_bg_must_swallow(Efl_Ui_Win_Data *sd, Eo **bg)
8666 {
8667    if (EINA_UNLIKELY(!sd->legacy.bg_must_swallow_init))
8668      {
8669         /* Overkill: check which theme version the standard elm_bg uses */
8670         Elm_Widget_Smart_Data *wd;
8671         const char *version;
8672         int v;
8673
8674         sd->legacy.bg_must_swallow = 1;
8675         sd->legacy.bg_must_swallow_init = 1;
8676
8677         if (sd->legacy.ctor)
8678           *bg = elm_bg_add(sd->obj);
8679         else
8680           {
8681              // Note: This code path is probably not necessary (custom legacy
8682              // theme but efl_add'ed window -- all efl_add'ed widgets would
8683              // use default theme)
8684              *bg = efl_add(EFL_UI_BG_CLASS, sd->obj);
8685           }
8686         wd = efl_data_scope_get(*bg, EFL_UI_WIDGET_CLASS);
8687         if (wd)
8688           {
8689              version = edje_object_data_get(wd->resize_obj, "version");
8690              v = version ? atoi(version) : 0;
8691              if (v >= FRAME_OBJ_THEME_MIN_VERSION)
8692                sd->legacy.bg_must_swallow = 0;
8693           }
8694      }
8695
8696    return sd->legacy.bg_must_swallow;
8697 }
8698
8699 void
8700 _elm_win_standard_init(Eo *obj)
8701 {
8702    traceTaskStart("win_standard_init");
8703
8704    /* Support for elm_util_win_standard_add() and Efl.Ui.Win.Standard */
8705    Efl_Ui_Win_Data *sd = efl_data_scope_get(obj, MY_CLASS);
8706    Eo *bg = NULL;
8707
8708    ELM_SAFE_DEL(sd->bg);
8709
8710    sd->csd.need_bg_standard = 1;
8711    if (!_elm_win_bg_must_swallow(sd, &bg))
8712      {
8713         sd->csd.need_bg_solid = EINA_TRUE;
8714         evas_object_del(bg);
8715      }
8716    else
8717      {
8718         /* Legacy theme compatibility */
8719         DBG("Detected legacy theme used for elm_bg. Swallowing object.");
8720         sd->csd.need_bg_solid = EINA_FALSE;
8721
8722         if (!bg)
8723           {
8724              if (sd->legacy.ctor)
8725                bg = elm_bg_add(obj);
8726              else
8727                {
8728                   // Note: This code path is probably not necessary (custom legacy
8729                   // theme but efl_add'ed window -- all efl_add'ed widgets would
8730                   // use default theme)
8731                   bg = efl_add(EFL_UI_BG_CLASS, obj);
8732                }
8733           }
8734         _elm_win_bg_set(sd, bg);
8735      }
8736
8737    _elm_win_frame_style_update(sd, 0, 1);
8738
8739    traceTaskEnd();
8740 }
8741
8742 static Eina_Bool
8743 _efl_ui_win_content_set(Eo *obj, Efl_Ui_Win_Data *sd, const char *part, Eo *content)
8744 {
8745    sd->legacy.forbidden = EINA_TRUE;
8746    if (eina_streq(part, "content"))
8747      {
8748         if (sd->content == content) return EINA_TRUE;
8749         if (content && !elm_widget_sub_object_add(obj, content))
8750           goto err;
8751         /* FIXME: Switch to swallow inside the frame
8752         if (!edje_object_part_swallow(sd->frame_obj, "elm.swallow.client", content))
8753           goto err;
8754         */
8755         evas_object_box_append(sd->legacy.box, content);
8756         evas_object_show(content);
8757         efl_wref_add(content, &sd->content);
8758         return EINA_TRUE;
8759      }
8760    else if (eina_streq(part, "background"))
8761      {
8762         sd->csd.need_bg_standard = 0;
8763         if (sd->bg == content) return EINA_TRUE;
8764         if (!_elm_win_bg_set(sd, content))
8765           goto err;
8766         return EINA_TRUE;
8767      }
8768    //TIZEN_ONLY(20190425): add circle content part for circle object
8769    else if (eina_streq(part, "efl.content.circle"))
8770      {
8771         Eina_Bool ret;
8772         ret = edje_object_part_swallow(sd->legacy.edje, "efl.content.circle", content);
8773         evas_object_show(content);
8774         return ret;
8775      }
8776    //
8777
8778    WIN_PART_ERR(part);
8779    return EINA_FALSE;
8780
8781 err:
8782    ERR("Failed to set object %p as %s for window %p", content, part, obj);
8783    return EINA_FALSE;
8784 }
8785
8786 static Efl_Canvas_Object *
8787 _efl_ui_win_content_get(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, const char *part)
8788 {
8789    sd->legacy.forbidden = EINA_TRUE;
8790    if (eina_streq(part, "content"))
8791      return sd->content;
8792    else if (eina_streq(part, "background"))
8793      return sd->bg;
8794
8795    WIN_PART_ERR(part);
8796    return NULL;
8797 }
8798
8799 static Efl_Canvas_Object *
8800 _efl_ui_win_content_unset(Eo *obj, Efl_Ui_Win_Data *sd, const char *part)
8801 {
8802    Eo *content;
8803
8804    sd->legacy.forbidden = EINA_TRUE;
8805    content = _efl_ui_win_content_get(obj, sd, part);
8806    if (!content) return NULL;
8807
8808    efl_ref(content);
8809    _efl_ui_win_content_set(obj, sd, part, NULL);
8810    return content;
8811 }
8812
8813 static Eina_Bool
8814 _efl_ui_win_part_color_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, const char *part, int r, int g, int b, int a)
8815 {
8816    sd->legacy.forbidden = EINA_TRUE;
8817    if (eina_streq(part, "background"))
8818      {
8819         sd->csd.need_bg_solid = EINA_TRUE;
8820         edje_object_color_class_set(sd->frame_obj, "elm/win/background", r, g, b, a, 0, 0, 0, 0, 0, 0, 0, 0);
8821         _elm_win_frame_style_update(sd, 0, 1);
8822         return EINA_TRUE;
8823      }
8824
8825    WIN_PART_ERR(part);
8826    return EINA_FALSE;
8827 }
8828
8829 static Eina_Bool
8830 _efl_ui_win_part_color_get(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, const char *part, int *r, int *g, int *b, int *a)
8831 {
8832    sd->legacy.forbidden = EINA_TRUE;
8833    if (eina_streq(part, "background"))
8834      {
8835         edje_object_color_class_get(sd->frame_obj, "elm/win/background", r, g, b, a, 0, 0, 0, 0, 0, 0, 0, 0);
8836         return EINA_TRUE;
8837      }
8838
8839    WIN_PART_ERR(part);
8840    return EINA_FALSE;
8841 }
8842
8843 static void
8844 _efl_ui_win_part_file_unload(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, Eo *part_obj EINA_UNUSED, const char *part)
8845 {
8846    sd->legacy.forbidden = EINA_TRUE;
8847    if (eina_streq(part, "background"))
8848      {
8849         _elm_win_bg_set(sd, NULL);
8850         return;
8851      }
8852
8853    WIN_PART_ERR(part);
8854 }
8855
8856 static Eina_Error
8857 _efl_ui_win_part_file_load(Eo *obj, Efl_Ui_Win_Data *sd, Eo *part_obj, const char *part)
8858 {
8859    const char *file, *key;
8860
8861    sd->legacy.forbidden = EINA_TRUE;
8862    if (efl_file_loaded_get(part_obj)) return 0;
8863    file = efl_file_get(part_obj);
8864    key = efl_file_key_get(part_obj);
8865    if (eina_streq(part, "background"))
8866      {
8867         Eina_Bool ok = EINA_TRUE;
8868         Eo *bg = NULL;
8869
8870         if (file)
8871           {
8872              bg = efl_add(EFL_UI_IMAGE_CLASS, obj);
8873              efl_gfx_image_scale_method_set(bg, EFL_GFX_IMAGE_SCALE_METHOD_EXPAND);
8874              ok = efl_file_simple_load(bg, file, key);
8875              if (!ok) ELM_SAFE_DEL(bg);
8876              _elm_win_bg_set(sd, bg);
8877           }
8878         else
8879           {
8880              _elm_win_standard_init(obj);
8881           }
8882
8883         return ok;
8884      }
8885
8886    WIN_PART_ERR(part);
8887    return EINA_FALSE;
8888 }
8889
8890 static const char *
8891 _efl_ui_win_part_file_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, const Eo *part_obj, const char *part EINA_UNUSED)
8892 {
8893    sd->legacy.forbidden = EINA_TRUE;
8894    return efl_file_get(efl_super(part_obj, EFL_UI_WIN_PART_CLASS));
8895 #if 0
8896
8897    if (eina_streq(part, "background"))
8898      {
8899         const Eo *bg = _efl_ui_win_content_get(obj, sd, "background");
8900         return efl_file_get(bg);
8901      }
8902
8903    WIN_PART_ERR(part);
8904    return NULL;
8905 #endif
8906 }
8907
8908 static const char *
8909 _efl_ui_win_part_file_key_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, const Eo *part_obj, const char *part EINA_UNUSED)
8910 {
8911    sd->legacy.forbidden = EINA_TRUE;
8912    return efl_file_key_get(efl_super(part_obj, EFL_UI_WIN_PART_CLASS));
8913 /* NOTE; if more than one part is ever supported here then this section is needed */
8914 #if 0
8915
8916    if (eina_streq(part, "background"))
8917      {
8918         const Eo *bg = _efl_ui_win_content_get(obj, sd, "background");
8919         return efl_file_get(bg);
8920      }
8921
8922    WIN_PART_ERR(part);
8923    return NULL;
8924 #endif
8925 }
8926
8927 /* Efl.Part begin */
8928
8929 static void
8930 _efl_ui_win_part_efl_gfx_color_color_set(Eo *obj, void *_pd EINA_UNUSED, int r, int g, int b, int a)
8931 {
8932    Elm_Part_Data *pd = efl_data_scope_get(obj, EFL_UI_WIDGET_PART_CLASS);
8933    Efl_Ui_Win_Data *sd = efl_data_scope_get(pd->obj, MY_CLASS);
8934
8935    if (EVAS_COLOR_SANITIZE(r, g, b, a))
8936      ERR("Evas only handles premultiplied colors (0 <= R,G,B <= A <= 255)");
8937
8938    _efl_ui_win_part_color_set(pd->obj, sd, pd->part, r, g, b, a);
8939 }
8940
8941 static void
8942 _efl_ui_win_part_efl_gfx_color_color_get(const Eo *obj, void *_pd EINA_UNUSED, int *r, int *g, int *b, int *a)
8943 {
8944    Elm_Part_Data *pd = efl_data_scope_get(obj, EFL_UI_WIDGET_PART_CLASS);
8945    Efl_Ui_Win_Data *sd = efl_data_scope_get(pd->obj, MY_CLASS);
8946    _efl_ui_win_part_color_get(pd->obj, sd, pd->part, r, g, b, a);
8947 }
8948
8949 EOLIAN static const char *
8950 _efl_ui_win_part_efl_file_file_get(const Eo *obj, void *_pd EINA_UNUSED)
8951 {
8952    Elm_Part_Data *pd = efl_data_scope_get(obj, EFL_UI_WIDGET_PART_CLASS);
8953    Efl_Ui_Win_Data *sd = efl_data_scope_get(pd->obj, MY_CLASS);
8954    return _efl_ui_win_part_file_get(pd->obj, sd, obj, pd->part);
8955 }
8956
8957 EOLIAN static const char *
8958 _efl_ui_win_part_efl_file_key_get(const Eo *obj, void *_pd EINA_UNUSED)
8959 {
8960    Elm_Part_Data *pd = efl_data_scope_get(obj, EFL_UI_WIDGET_PART_CLASS);
8961    Efl_Ui_Win_Data *sd = efl_data_scope_get(pd->obj, MY_CLASS);
8962    return _efl_ui_win_part_file_key_get(pd->obj, sd, obj, pd->part);
8963 }
8964
8965 EOLIAN static void
8966 _efl_ui_win_part_efl_file_unload(Eo *obj, void *_pd EINA_UNUSED)
8967 {
8968    Elm_Part_Data *pd = efl_data_scope_get(obj, EFL_UI_WIDGET_PART_CLASS);
8969    Efl_Ui_Win_Data *sd = efl_data_scope_get(pd->obj, MY_CLASS);
8970    return _efl_ui_win_part_file_unload(pd->obj, sd, obj, pd->part);
8971 }
8972
8973 EOLIAN static Eina_Error
8974 _efl_ui_win_part_efl_file_load(Eo *obj, void *_pd EINA_UNUSED)
8975 {
8976    Elm_Part_Data *pd = efl_data_scope_get(obj, EFL_UI_WIDGET_PART_CLASS);
8977    Efl_Ui_Win_Data *sd = efl_data_scope_get(pd->obj, MY_CLASS);
8978    return _efl_ui_win_part_file_load(pd->obj, sd, obj, pd->part);
8979 }
8980
8981
8982 ELM_PART_OVERRIDE(efl_ui_win, EFL_UI_WIN, Efl_Ui_Win_Data)
8983 ELM_PART_OVERRIDE_CONTENT_SET(efl_ui_win, EFL_UI_WIN, Efl_Ui_Win_Data)
8984 ELM_PART_OVERRIDE_CONTENT_GET(efl_ui_win, EFL_UI_WIN, Efl_Ui_Win_Data)
8985 ELM_PART_OVERRIDE_CONTENT_UNSET(efl_ui_win, EFL_UI_WIN, Efl_Ui_Win_Data)
8986 ELM_PART_CONTENT_DEFAULT_GET(efl_ui_win, "content")
8987 ELM_PART_CONTENT_DEFAULT_IMPLEMENT(efl_ui_win, Efl_Ui_Win_Data)
8988 #include "efl_ui_win_part.eo.c"
8989
8990 /* Efl.Part end */
8991
8992 EOLIAN static Eina_Bool
8993 _efl_ui_win_move_resize_start(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, Efl_Ui_Win_Move_Resize_Mode mode)
8994 {
8995    // 1. move_resize can only be started after mouse down event
8996    if (evas_event_down_count_get(sd->evas) <= 0)
8997      {
8998         ERR("move_resize_start can only be called when a pointer is pressed.");
8999         return EINA_FALSE;
9000      }
9001    return _win_move_resize_start(sd, mode);
9002 }
9003
9004 EAPI Evas_Object *
9005 elm_win_get(Evas_Object *obj)
9006 {
9007    EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
9008    return ecore_evas_data_get(ecore_evas_ecore_evas_get(evas_object_evas_get(obj)), "elm_win");
9009 }
9010
9011 /* windowing specific calls - shall we do this differently? */
9012
9013 EAPI Ecore_X_Window
9014 elm_win_xwindow_get(const Evas_Object *obj)
9015 {
9016    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9017    if (!sd) return 0;
9018
9019 #ifdef HAVE_ELEMENTARY_X
9020    _internal_elm_win_xwindow_get(sd);
9021    if (sd->x.xwin) return sd->x.xwin;
9022    if (sd->parent) return elm_win_xwindow_get(sd->parent);
9023 #else
9024    (void)sd;
9025 #endif
9026    return 0;
9027 }
9028
9029 //TIZEN_ONLY(20171208): fix build break by opensource temporarily until migration finish
9030 EAPI Ecore_Wl_Window *
9031 elm_win_wl_window_get(const Evas_Object *obj)
9032 {
9033    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9034
9035    if (!sd) return NULL;
9036
9037    if (!evas_object_smart_type_check_ptr(obj, MY_CLASS_NAME_LEGACY))
9038      {
9039         Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
9040         return (Ecore_Wl_Window *)_elm_ee_wlwin_get(ee);
9041      }
9042
9043 #if HAVE_ELEMENTARY_WL2
9044    if (sd->wl.win) return (Ecore_Wl_Window *)sd->wl.win;
9045    if (sd->parent) return (Ecore_Wl_Window *)elm_win_wl_window_get(sd->parent);
9046 #endif
9047
9048    return NULL;
9049 }
9050 //TIZEN_ONLY(20171208)
9051
9052
9053 EAPI Ecore_Cocoa_Window *
9054 elm_win_cocoa_window_get(const Evas_Object *obj)
9055 {
9056    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9057    if (!sd) return NULL;
9058
9059 #if HAVE_ELEMENTARY_COCOA
9060    if (sd->cocoa.win) return sd->cocoa.win;
9061    if (sd->ee) return _elm_ee_cocoa_win_get(sd->ee);
9062    if (sd->parent) return elm_win_cocoa_window_get(sd->parent);
9063 #endif
9064
9065    Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
9066    return _elm_ee_cocoa_win_get(ee);
9067
9068    return NULL;
9069 }
9070
9071 EAPI Ecore_Win32_Window *
9072 elm_win_win32_window_get(const Evas_Object *obj)
9073 {
9074    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9075    const char *engine_name;
9076
9077    if (!sd) return NULL;
9078    engine_name = ecore_evas_engine_name_get(sd->ee);
9079    if (!(engine_name &&
9080          ((!strcmp(engine_name, ELM_SOFTWARE_WIN32)) ||
9081           (!strcmp(engine_name, ELM_SOFTWARE_DDRAW)))))
9082      return NULL;
9083
9084    if (!evas_object_smart_type_check_ptr(obj, MY_CLASS_NAME_LEGACY))
9085      {
9086         Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
9087         return _elm_ee_win32win_get(ee);
9088      }
9089
9090    Ecore_Win32_Window *ret = NULL;
9091
9092 #if HAVE_ELEMENTARY_WIN32
9093    if (sd->win32.win) ret = sd->win32.win;
9094    if (sd->parent) ret = elm_win_win32_window_get(sd->parent);
9095 #endif
9096
9097    return ret;
9098 }
9099
9100 EAPI void *
9101 elm_win_trap_data_get(const Evas_Object *obj)
9102 {
9103    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9104    if (!sd) return NULL;
9105
9106    return sd->trap_data;
9107 }
9108
9109 EAPI void
9110 elm_win_override_set(Evas_Object *obj, Eina_Bool override)
9111 {
9112    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9113    if (!sd) return;
9114
9115    TRAP(sd, override_set, override);
9116 #ifdef HAVE_ELEMENTARY_X
9117    _elm_win_xwin_update(sd);
9118 #endif
9119 }
9120
9121 EAPI Eina_Bool
9122 elm_win_override_get(const Evas_Object *obj)
9123 {
9124    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9125    if (!sd) return EINA_FALSE;
9126
9127    return ecore_evas_override_get(sd->ee);
9128 }
9129
9130 EAPI void
9131 elm_win_lower(Evas_Object *obj)
9132 {
9133    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9134    if (!sd) return;
9135
9136    TRAP(sd, lower);
9137 }
9138
9139 EAPI void
9140 elm_win_quickpanel_set(Evas_Object *obj, Eina_Bool quickpanel)
9141 {
9142    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9143    if (!sd) return;
9144
9145 #ifdef HAVE_ELEMENTARY_X
9146    _internal_elm_win_xwindow_get(sd);
9147    if (sd->x.xwin)
9148      {
9149         _internal_elm_win_xwindow_get(sd);
9150         ecore_x_e_illume_quickpanel_set(sd->x.xwin, quickpanel);
9151         if (quickpanel)
9152           {
9153              Ecore_X_Window_State states[2];
9154
9155              states[0] = ECORE_X_WINDOW_STATE_SKIP_TASKBAR;
9156              states[1] = ECORE_X_WINDOW_STATE_SKIP_PAGER;
9157              ecore_x_netwm_window_state_set(sd->x.xwin, states, 2);
9158              ecore_x_icccm_hints_set(sd->x.xwin, 0, 0, 0, 0, 0, 0, 0);
9159           }
9160      }
9161 #else
9162    (void)sd;
9163    (void)quickpanel;
9164 #endif
9165 #ifdef HAVE_ELEMENTARY_WL2
9166    // TIZEN_ONLY(20160404)  skip_focus in case invoking elm_win_quickpanel_set
9167    _elm_win_focus_skip_set(sd, EINA_TRUE);
9168    //
9169 #endif
9170 }
9171
9172 EAPI Eina_Bool
9173 elm_win_quickpanel_get(const Evas_Object *obj)
9174 {
9175    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9176    if (!sd) return EINA_FALSE;
9177
9178 #ifdef HAVE_ELEMENTARY_X
9179    _internal_elm_win_xwindow_get(sd);
9180    if (sd->x.xwin)
9181      {
9182         _internal_elm_win_xwindow_get(sd);
9183         return ecore_x_e_illume_quickpanel_get(sd->x.xwin);
9184      }
9185 #else
9186    (void)sd;
9187 #endif
9188
9189    return EINA_FALSE;
9190 }
9191
9192 EAPI void
9193 elm_win_quickpanel_priority_major_set(Evas_Object *obj, int priority)
9194 {
9195    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9196    if (!sd) return;
9197
9198 #ifdef HAVE_ELEMENTARY_X
9199    _internal_elm_win_xwindow_get(sd);
9200    if (sd->x.xwin)
9201      {
9202         _internal_elm_win_xwindow_get(sd);
9203         ecore_x_e_illume_quickpanel_priority_major_set(sd->x.xwin, priority);
9204      }
9205 #else
9206    (void)sd;
9207    (void)priority;
9208 #endif
9209 }
9210
9211 EAPI int
9212 elm_win_quickpanel_priority_major_get(const Evas_Object *obj)
9213 {
9214    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9215    if (!sd) return -1;
9216
9217 #ifdef HAVE_ELEMENTARY_X
9218    _internal_elm_win_xwindow_get(sd);
9219    if (sd->x.xwin)
9220      {
9221         _internal_elm_win_xwindow_get(sd);
9222         return ecore_x_e_illume_quickpanel_priority_major_get(sd->x.xwin);
9223      }
9224 #else
9225    (void)sd;
9226 #endif
9227
9228    return -1;
9229 }
9230
9231 EAPI void
9232 elm_win_quickpanel_priority_minor_set(Evas_Object *obj, int priority)
9233 {
9234    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9235    if (!sd) return;
9236
9237 #ifdef HAVE_ELEMENTARY_X
9238    _internal_elm_win_xwindow_get(sd);
9239    if (sd->x.xwin)
9240      {
9241         _internal_elm_win_xwindow_get(sd);
9242         ecore_x_e_illume_quickpanel_priority_minor_set(sd->x.xwin, priority);
9243      }
9244 #else
9245    (void)sd;
9246    (void)priority;
9247 #endif
9248 }
9249
9250 EAPI int
9251 elm_win_quickpanel_priority_minor_get(const Evas_Object *obj)
9252 {
9253    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9254    if (!sd) return -1;
9255
9256 #ifdef HAVE_ELEMENTARY_X
9257    _internal_elm_win_xwindow_get(sd);
9258    if (sd->x.xwin)
9259      {
9260         _internal_elm_win_xwindow_get(sd);
9261         return ecore_x_e_illume_quickpanel_priority_minor_get(sd->x.xwin);
9262      }
9263 #else
9264    (void)sd;
9265 #endif
9266
9267    return -1;
9268 }
9269
9270 EAPI void
9271 elm_win_quickpanel_zone_set(Evas_Object *obj, int zone)
9272 {
9273    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9274    if (!sd) return;
9275
9276 #ifdef HAVE_ELEMENTARY_X
9277    _internal_elm_win_xwindow_get(sd);
9278    if (sd->x.xwin)
9279      {
9280         _internal_elm_win_xwindow_get(sd);
9281         ecore_x_e_illume_quickpanel_zone_set(sd->x.xwin, zone);
9282      }
9283 #else
9284    (void)sd;
9285    (void)zone;
9286 #endif
9287 }
9288
9289 EAPI int
9290 elm_win_quickpanel_zone_get(const Evas_Object *obj)
9291 {
9292    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9293    if (!sd) return 0;
9294
9295 #ifdef HAVE_ELEMENTARY_X
9296    _internal_elm_win_xwindow_get(sd);
9297    if (sd->x.xwin)
9298      {
9299         _internal_elm_win_xwindow_get(sd);
9300         return ecore_x_e_illume_quickpanel_zone_get(sd->x.xwin);
9301      }
9302 #else
9303    (void)sd;
9304 #endif
9305
9306    return 0;
9307 }
9308
9309 EAPI void
9310 elm_win_indicator_mode_set(Evas_Object *obj, Elm_Win_Indicator_Mode mode)
9311 {
9312    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9313    if (!sd) return;
9314    if (sd->legacy.forbidden)
9315      {
9316         CRI("Use of this API is forbidden after calling an EO API on this "
9317             "window. Fix your code!");
9318         return;
9319      }
9320
9321    if (mode == sd->legacy.indmode) return;
9322 #ifdef HAVE_ELEMENTARY_X
9323    _internal_elm_win_xwindow_get(sd);
9324 #endif
9325    sd->legacy.indmode = mode;
9326 #ifdef HAVE_ELEMENTARY_X
9327    if (sd->x.xwin)
9328      {
9329         _internal_elm_win_xwindow_get(sd);
9330         if (sd->legacy.indmode == ELM_WIN_INDICATOR_SHOW)
9331           ecore_x_e_illume_indicator_state_set
9332             (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_STATE_ON);
9333         else if (sd->legacy.indmode == ELM_WIN_INDICATOR_HIDE)
9334           ecore_x_e_illume_indicator_state_set
9335             (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_STATE_OFF);
9336      }
9337 #endif
9338 #ifdef HAVE_ELEMENTARY_WL2
9339    _elm_win_wlwindow_get(sd);
9340    if (sd->wl.win)
9341      {
9342         if (sd->legacy.indmode == ELM_WIN_INDICATOR_SHOW)
9343           ecore_wl2_window_indicator_state_set
9344             (sd->wl.win, ECORE_WL2_INDICATOR_STATE_ON);
9345         else if (sd->legacy.indmode == ELM_WIN_INDICATOR_HIDE)
9346           ecore_wl2_window_indicator_state_set
9347             (sd->wl.win, ECORE_WL2_INDICATOR_STATE_OFF);
9348      }
9349 #endif
9350    efl_event_callback_legacy_call
9351      (obj, EFL_UI_WIN_EVENT_INDICATOR_PROP_CHANGED, NULL);
9352 }
9353
9354 EAPI Elm_Win_Indicator_Mode
9355 elm_win_indicator_mode_get(const Evas_Object *obj)
9356 {
9357    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9358    if (!sd) return ELM_WIN_INDICATOR_UNKNOWN;
9359    if (sd->legacy.forbidden)
9360      {
9361         CRI("Use of this API is forbidden after calling an EO API on this "
9362             "window. Fix your code!");
9363         return ELM_WIN_INDICATOR_UNKNOWN;
9364      }
9365
9366    return sd->legacy.indmode;
9367 }
9368
9369 EAPI void
9370 elm_win_indicator_opacity_set(Evas_Object *obj, Elm_Win_Indicator_Opacity_Mode mode)
9371 {
9372    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9373    if (!sd) return;
9374    if (sd->legacy.forbidden)
9375      {
9376         CRI("Use of this API is forbidden after calling an EO API on this "
9377             "window. Fix your code!");
9378         return;
9379      }
9380
9381    if (mode == sd->legacy.ind_o_mode) return;
9382    sd->legacy.ind_o_mode = mode;
9383 #ifdef HAVE_ELEMENTARY_X
9384    _internal_elm_win_xwindow_get(sd);
9385    if (sd->x.xwin)
9386      {
9387         _internal_elm_win_xwindow_get(sd);
9388         if (sd->legacy.ind_o_mode == ELM_WIN_INDICATOR_OPAQUE)
9389           ecore_x_e_illume_indicator_opacity_set
9390             (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_OPAQUE);
9391         else if (sd->legacy.ind_o_mode == ELM_WIN_INDICATOR_TRANSLUCENT)
9392           ecore_x_e_illume_indicator_opacity_set
9393             (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_TRANSLUCENT);
9394         else if (sd->legacy.ind_o_mode == ELM_WIN_INDICATOR_TRANSPARENT)
9395           ecore_x_e_illume_indicator_opacity_set
9396             (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_TRANSPARENT);
9397      }
9398 #endif
9399 #ifdef HAVE_ELEMENTARY_WL2
9400    _elm_win_wlwindow_get(sd);
9401    if (sd->wl.win)
9402      {
9403         if (sd->legacy.ind_o_mode == ELM_WIN_INDICATOR_OPAQUE)
9404           ecore_wl2_window_indicator_opacity_set
9405             (sd->wl.win, ECORE_WL2_INDICATOR_OPAQUE);
9406         else if (sd->legacy.ind_o_mode == ELM_WIN_INDICATOR_TRANSLUCENT)
9407           ecore_wl2_window_indicator_opacity_set
9408             (sd->wl.win, ECORE_WL2_INDICATOR_TRANSLUCENT);
9409         else if (sd->legacy.ind_o_mode == ELM_WIN_INDICATOR_TRANSPARENT)
9410           ecore_wl2_window_indicator_opacity_set
9411             (sd->wl.win, ECORE_WL2_INDICATOR_TRANSPARENT);
9412         else if (sd->legacy.ind_o_mode == ELM_WIN_INDICATOR_BG_TRANSPARENT)
9413           ecore_wl2_window_indicator_opacity_set
9414             (sd->wl.win, ECORE_WL2_INDICATOR_BG_TRANSPARENT);
9415      }
9416 #endif
9417    efl_event_callback_legacy_call
9418      (obj, EFL_UI_WIN_EVENT_INDICATOR_PROP_CHANGED, NULL);
9419 }
9420
9421 EAPI Elm_Win_Indicator_Opacity_Mode
9422 elm_win_indicator_opacity_get(const Evas_Object *obj)
9423 {
9424    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9425    if (!sd) return ELM_WIN_INDICATOR_OPACITY_UNKNOWN;
9426    if (sd->legacy.forbidden)
9427      {
9428         CRI("Use of this API is forbidden after calling an EO API on this "
9429             "window. Fix your code!");
9430         return ELM_WIN_INDICATOR_OPACITY_UNKNOWN;
9431      }
9432
9433    return sd->legacy.ind_o_mode;
9434 }
9435
9436 EAPI void
9437 elm_win_keyboard_win_set(Evas_Object *obj, Eina_Bool is_keyboard)
9438 {
9439    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9440    if (!sd) return;
9441
9442 #ifdef HAVE_ELEMENTARY_X
9443    _internal_elm_win_xwindow_get(sd);
9444    if (sd->x.xwin)
9445      {
9446         _internal_elm_win_xwindow_get(sd);
9447         ecore_x_e_virtual_keyboard_set(sd->x.xwin, is_keyboard);
9448      }
9449 #else
9450    (void)sd;
9451    (void)is_keyboard;
9452 #endif
9453 }
9454
9455 EAPI Eina_Bool
9456 elm_win_keyboard_win_get(const Evas_Object *obj)
9457 {
9458    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9459    if (!sd) return EINA_FALSE;
9460
9461 #ifdef HAVE_ELEMENTARY_X
9462    _internal_elm_win_xwindow_get(sd);
9463    if (sd->x.xwin)
9464      {
9465         _internal_elm_win_xwindow_get(sd);
9466         return ecore_x_e_virtual_keyboard_get(sd->x.xwin);
9467      }
9468 #else
9469    (void)sd;
9470 #endif
9471    return EINA_FALSE;
9472 }
9473
9474 EAPI void
9475 elm_win_conformant_set(Evas_Object *obj, Eina_Bool conformant)
9476 {
9477    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9478    if (!sd) return;
9479
9480 #ifdef HAVE_ELEMENTARY_X
9481    _internal_elm_win_xwindow_get(sd);
9482    if (sd->x.xwin)
9483      {
9484         _internal_elm_win_xwindow_get(sd);
9485         ecore_x_e_illume_conformant_set(sd->x.xwin, conformant);
9486      }
9487 #elif HAVE_ELEMENTARY_WL2
9488    // TIZEN_ONLY(20150707): elm_conform for wayland, and signal if parts are changed
9489    _elm_win_wlwindow_get(sd);
9490    if (sd->wl.win)
9491      ecore_wl2_window_conformant_set(sd->wl.win, conformant);
9492    //
9493 #else
9494    (void)sd;
9495    (void)conformant;
9496 #endif
9497 }
9498
9499 EAPI Eina_Bool
9500 elm_win_conformant_get(const Evas_Object *obj)
9501 {
9502    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9503    if (!sd) return EINA_FALSE;
9504
9505 #ifdef HAVE_ELEMENTARY_X
9506    _internal_elm_win_xwindow_get(sd);
9507    if (sd->x.xwin)
9508      {
9509         _internal_elm_win_xwindow_get(sd);
9510         return ecore_x_e_illume_conformant_get(sd->x.xwin);
9511      }
9512 #elif HAVE_ELEMENTARY_WL2
9513    // TIZEN_ONLY(20150707): elm_conform for wayland, and signal if parts are changed
9514    _elm_win_wlwindow_get(sd);
9515    if (sd->wl.win)
9516      return ecore_wl2_window_conformant_get(sd->wl.win);
9517    //
9518 #else
9519    (void)sd;
9520 #endif
9521
9522    return EINA_FALSE;
9523 }
9524
9525 EAPI void
9526 elm_win_wm_rotation_manual_rotation_done_set(Evas_Object *obj, Eina_Bool set)
9527 {
9528    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9529    if (!sd) return;
9530
9531    if (!sd->wm_rot.use) return;
9532    ecore_evas_wm_rotation_manual_rotation_done_set(sd->ee, set);
9533 }
9534
9535 EAPI Eina_Bool
9536 elm_win_wm_rotation_manual_rotation_done_get(const Evas_Object *obj)
9537 {
9538    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9539    if (!sd) return EINA_FALSE;
9540
9541    if (!sd->wm_rot.use) return EINA_FALSE;
9542    return ecore_evas_wm_rotation_manual_rotation_done_get(sd->ee);
9543 }
9544
9545 EAPI void
9546 elm_win_wm_rotation_manual_rotation_done(Evas_Object *obj)
9547 {
9548    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9549    if (!sd) return;
9550
9551    if (!sd->wm_rot.use) return;
9552    ecore_evas_wm_rotation_manual_rotation_done(sd->ee);
9553 }
9554
9555 /*
9556  * This API does not resize the internal window (ex: X window).
9557  * But this resizes evas_output, elm window, and its contents.
9558  */
9559 EAPI void
9560 elm_win_rotation_with_resize_set(Evas_Object *obj, int rotation)
9561 {
9562    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9563    if (!sd) return;
9564 // TIZEN_ONLY(20170212): pend rotation until app set rotation
9565    if (sd->wm_rot.rotation_pending)
9566      {
9567         _win_pending_rotate(obj, sd, rotation, EINA_TRUE);
9568      }
9569    else
9570 //
9571    _win_rotate(obj, sd, rotation, EINA_TRUE);
9572 }
9573
9574 EAPI int
9575 elm_win_wm_rotation_preferred_rotation_get(const Evas_Object *obj)
9576 {
9577    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9578    if (!sd) return -1;
9579
9580    return sd->wm_rot.preferred_rot;
9581 }
9582
9583 EAPI Eina_Bool
9584 elm_win_wm_rotation_supported_get(const Evas_Object *obj)
9585 {
9586    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9587    if (!sd) return EINA_FALSE;
9588
9589    return sd->wm_rot.wm_supported;
9590 }
9591
9592 EAPI void
9593 elm_win_wm_rotation_preferred_rotation_set(Evas_Object *obj, int rotation)
9594 {
9595    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9596    int rot;
9597
9598    if (!sd) return;
9599    if (!sd->wm_rot.use)
9600      sd->wm_rot.use = EINA_TRUE;
9601
9602    // '-1' means that elm_win doesn't use preferred rotation.
9603    if (rotation == -1)
9604      rot = -1;
9605    else
9606      rot = _win_rotation_degree_check(rotation);
9607
9608    if (sd->wm_rot.preferred_rot == rot) return;
9609    sd->wm_rot.preferred_rot = rot;
9610
9611    ecore_evas_wm_rotation_preferred_rotation_set(sd->ee, rot);
9612 }
9613
9614 EAPI void
9615 elm_win_screen_size_get(const Evas_Object *obj, int *x, int *y, int *w, int *h)
9616 {
9617    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9618    if (!sd) return;
9619
9620    ecore_evas_screen_geometry_get(sd->ee, x, y, w, h);
9621 }
9622
9623 EAPI void
9624 elm_win_screen_position_get(const Evas_Object *obj, int *x, int *y)
9625 {
9626    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9627    if (!sd) return;
9628
9629    if (x) *x = sd->screen.x;
9630    if (y) *y = sd->screen.y;
9631 }
9632
9633 EAPI void
9634 elm_win_screen_dpi_get(const Evas_Object *obj, int *xdpi, int *ydpi)
9635 {
9636    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9637    if (!sd) return;
9638
9639    ecore_evas_screen_dpi_get(sd->ee, xdpi, ydpi);
9640 }
9641
9642 EAPI void
9643 elm_win_icon_name_set(Evas_Object *obj, const char *icon_name)
9644 {
9645    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9646    if (!sd) return;
9647
9648    if (!icon_name) return;
9649    eina_stringshare_replace(&(sd->icon_name), icon_name);
9650 #ifdef HAVE_ELEMENTARY_X
9651    _elm_win_xwin_update(sd);
9652 #endif
9653 }
9654
9655 EAPI const char*
9656 elm_win_icon_name_get(const Evas_Object *obj)
9657 {
9658    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9659    if (!sd) return NULL;
9660
9661    return sd->icon_name;
9662 }
9663
9664 EAPI void
9665 elm_win_withdrawn_set(Evas_Object *obj, Eina_Bool withdrawn)
9666 {
9667    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9668    if (!sd) return;
9669
9670 //   sd->withdrawn = withdrawn;
9671    TRAP(sd, withdrawn_set, withdrawn);
9672 #ifdef HAVE_ELEMENTARY_X
9673    _elm_win_xwin_update(sd);
9674 #endif
9675 }
9676
9677 EAPI Eina_Bool
9678 elm_win_withdrawn_get(const Evas_Object *obj)
9679 {
9680    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9681    if (!sd) return EINA_FALSE;
9682
9683    return sd->withdrawn;
9684 }
9685
9686 EAPI void
9687 elm_win_urgent_set(Evas_Object *obj, Eina_Bool urgent)
9688 {
9689    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9690    if (!sd) return;
9691
9692    if (sd->urgent == urgent)
9693      return;
9694    sd->urgent = urgent;
9695    TRAP(sd, urgent_set, urgent);
9696 #ifdef HAVE_ELEMENTARY_X
9697    _elm_win_xwin_update(sd);
9698 #endif
9699 }
9700
9701 EAPI Eina_Bool
9702 elm_win_urgent_get(const Evas_Object *obj)
9703 {
9704    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9705    if (!sd) return EINA_FALSE;
9706
9707    return sd->urgent;
9708 }
9709
9710 EAPI void
9711 elm_win_demand_attention_set(Evas_Object *obj, Eina_Bool demand_attention)
9712 {
9713    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9714    if (!sd) return;
9715
9716    sd->demand_attention = demand_attention;
9717    TRAP(sd, demand_attention_set, demand_attention);
9718 #ifdef HAVE_ELEMENTARY_X
9719    _elm_win_xwin_update(sd);
9720 #endif
9721 }
9722
9723 EAPI Eina_Bool
9724 elm_win_demand_attention_get(const Evas_Object *obj)
9725 {
9726    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9727    if (!sd) return EINA_FALSE;
9728
9729    return sd->demand_attention;
9730 }
9731
9732 EAPI void
9733 elm_win_modal_set(Evas_Object *obj, Eina_Bool modal)
9734 {
9735    Efl_Ui_Win_Modal_Mode modality;
9736
9737    modality = modal ? EFL_UI_WIN_MODAL_MODE_MODAL : EFL_UI_WIN_MODAL_MODE_NONE;
9738    efl_ui_win_modal_set(obj, modality);
9739 }
9740
9741 EAPI Eina_Bool
9742 elm_win_modal_get(const Evas_Object *obj)
9743 {
9744    Efl_Ui_Win_Modal_Mode modality;
9745
9746    modality = efl_ui_win_modal_get(obj);
9747    return (modality != EFL_UI_WIN_MODAL_MODE_NONE);
9748 }
9749
9750 EAPI void
9751 elm_win_shaped_set(Evas_Object *obj, Eina_Bool shaped)
9752 {
9753    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9754    if (!sd) return;
9755
9756    shaped = !!shaped;
9757
9758 #ifdef HAVE_ELEMENTARY_X
9759    if (sd->x.shaped == shaped) return;
9760    sd->x.shaped = shaped;
9761    TRAP(sd, shaped_set, shaped);
9762 #endif
9763 }
9764
9765 EAPI Eina_Bool
9766 elm_win_shaped_get(const Evas_Object *obj)
9767 {
9768    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9769    if (!sd) return EINA_FALSE;
9770
9771    return ecore_evas_shaped_get(sd->ee);
9772 }
9773
9774 EAPI void
9775 elm_win_title_set(Evas_Object *obj, const char *title)
9776 {
9777    efl_text_set(obj, title);
9778 }
9779
9780 EAPI const char*
9781 elm_win_title_get(const Evas_Object *obj)
9782 {
9783    return efl_text_get(obj);
9784 }
9785
9786 EAPI void
9787 elm_win_size_base_set(Evas_Object *obj, int w, int h)
9788 {
9789    efl_ui_win_hint_base_set(obj, EINA_SIZE2D(w, h));
9790 }
9791
9792 EAPI void
9793 elm_win_size_base_get(const Evas_Object *obj, int *w, int *h)
9794 {
9795    Eina_Size2D sz;
9796    sz = efl_ui_win_hint_base_get(obj);
9797    if (w) *w = sz.w;
9798    if (h) *h = sz.h;
9799 }
9800
9801 EAPI void
9802 elm_win_size_step_set(Evas_Object *obj, int w, int h)
9803 {
9804    efl_ui_win_hint_step_set(obj, EINA_SIZE2D(w, h));
9805 }
9806
9807 EAPI void
9808 elm_win_size_step_get(const Evas_Object *obj, int *w, int *h)
9809 {
9810    Eina_Size2D sz;
9811    sz = efl_ui_win_hint_step_get(obj);
9812    if (w) *w = sz.w;
9813    if (h) *h = sz.h;
9814 }
9815
9816 EAPI void
9817 elm_win_illume_command_send(Evas_Object *obj, Elm_Illume_Command command, void *params EINA_UNUSED)
9818 {
9819    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9820    if (!sd) return;
9821
9822 #ifdef HAVE_ELEMENTARY_X
9823    _internal_elm_win_xwindow_get(sd);
9824    if (sd->x.xwin)
9825      {
9826         _internal_elm_win_xwindow_get(sd);
9827         switch (command)
9828           {
9829            case ELM_ILLUME_COMMAND_FOCUS_BACK:
9830              ecore_x_e_illume_focus_back_send(sd->x.xwin);
9831              break;
9832
9833            case ELM_ILLUME_COMMAND_FOCUS_FORWARD:
9834              ecore_x_e_illume_focus_forward_send(sd->x.xwin);
9835              break;
9836
9837            case ELM_ILLUME_COMMAND_FOCUS_HOME:
9838              ecore_x_e_illume_focus_home_send(sd->x.xwin);
9839              break;
9840
9841            case ELM_ILLUME_COMMAND_CLOSE:
9842              ecore_x_e_illume_close_send(sd->x.xwin);
9843              break;
9844
9845            default:
9846              break;
9847           }
9848      }
9849 #else
9850    (void)sd;
9851    (void)command;
9852 #endif
9853 }
9854
9855 EAPI void
9856 elm_win_profile_set(Evas_Object *obj, const char *profile)
9857 {
9858    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9859    if (!sd) return;
9860
9861    /* check to see if a given profile is present in an available profiles */
9862    if (profile && eina_array_count(sd->profile.available))
9863      {
9864         if (!_profile_exists(sd, profile))
9865           return;
9866      }
9867
9868    if (ecore_evas_window_profile_supported_get(sd->ee))
9869      {
9870         if (!profile) _elm_win_profile_del(sd);
9871         ecore_evas_window_profile_set(sd->ee, profile);
9872      }
9873    else
9874      {
9875         if (_internal_elm_win_profile_set(sd, profile))
9876           _elm_win_profile_update(sd);
9877      }
9878 }
9879
9880 EAPI const char*
9881 elm_win_profile_get(const Evas_Object *obj)
9882 {
9883    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9884    if (!sd) return NULL;
9885
9886    return sd->profile.name;
9887 }
9888
9889 EAPI void
9890 elm_win_layer_set(Evas_Object *obj, int layer)
9891 {
9892    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9893    if (!sd) return;
9894
9895    TRAP(sd, layer_set, layer);
9896 #ifdef HAVE_ELEMENTARY_X
9897    _elm_win_xwin_update(sd);
9898 #endif
9899 }
9900
9901 EAPI int
9902 elm_win_layer_get(const Evas_Object *obj)
9903 {
9904    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9905    if (!sd) return 0;
9906
9907    return ecore_evas_layer_get(sd->ee);
9908 }
9909
9910 EAPI Evas_Object*
9911 elm_win_inlined_image_object_get(const Evas_Object *obj)
9912 {
9913    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
9914    if (!sd) return NULL;
9915
9916    return sd->img_obj;
9917 }
9918
9919 // TIZEN_ONLY(20170212): pend rotation until app set rotation
9920
9921 /* Efl don't have any plan to open new API to support the client rotation.(ex: elm_win_rotation_set)
9922  * But it is need that apps deal with rotation
9923  * For example, if the app want to do the object rotation effect during the rotation,
9924  * canvas should not be rotated until app's rotation effect ends.
9925  * so until to decide app's rotaion policy,
9926  * just use the "wm.policy.win.rot.render.nopending" aux_hint.
9927  * Using this hint, elm- ecore_evas - engine -tizen display server will manage the pending rotation.
9928 */
9929
9930 static int
9931 _elm_win_wm_pending_rotation_set(Evas_Object *obj EINA_UNUSED, const char *hint EINA_UNUSED, const char *val)
9932 {
9933    ELM_WIN_DATA_GET_OR_RETURN(obj, sd, -1);
9934
9935    int id = -1;
9936
9937    //TODO: aux_hint_del, aux_hint_val_set.
9938    //Currently only 1 is available.
9939
9940    if (!val || (strncmp(val, "1", 1))) return -1;
9941    id = ecore_evas_aux_hint_add(sd->ee, "wm.policy.win.rot.render.nopending", val);
9942
9943    if (id == -1)
9944      {
9945         ERR("PendingRotation: elm_win pending_rotation_set aux id failed");
9946         //return id;
9947      }
9948    sd->wm_rot.rotation_pending = EINA_TRUE;
9949    DBG("PendingRotation: elm_win rotation_pending_set sucess");
9950    return id;
9951 }
9952 //
9953
9954 // TIZEN_ONLY(20171114) Accessibility Highlight Frame added
9955 static void _elm_win_accessibility_highlight_callbacks_del(Efl_Ui_Win_Data *sd)
9956 {
9957    Evas_Object *obj = sd->accessibility_highlight.cur.target;
9958    if (!obj) return;
9959
9960    evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL, _elm_win_accessibility_highlight_obj_del, sd->obj);
9961
9962    if (efl_isa(obj, EFL_UI_WIDGET_CLASS) && elm_widget_access_highlight_in_theme_get(obj))
9963       return;
9964
9965    evas_object_event_callback_del_full(obj, EVAS_CALLBACK_MOVE, _elm_win_accessibility_highlight_obj_move, sd->obj);
9966    evas_object_event_callback_del_full(obj, EVAS_CALLBACK_RESIZE, _elm_win_accessibility_highlight_obj_resize, sd->obj);
9967 }
9968
9969 void
9970 _elm_win_object_set_accessibility_highlight(Evas_Object *win, Evas_Object *obj, Eina_Bool visible)
9971 {
9972    if (!win) return;
9973    ELM_WIN_DATA_GET(win, sd);
9974    if (visible || sd->accessibility_highlight.cur.target == obj)
9975      {
9976         if (sd->obj)
9977           _elm_win_accessibility_highlight_hide(sd->obj);
9978         // TIZEN_ONLY(20171117) Accessibility frame follows parent item on scroll event
9979         _elm_win_accessibility_highlight_callbacks_del(sd);
9980         //
9981      }
9982    if (visible)
9983      {
9984          _elm_win_accessibility_highlight_init(sd, obj);
9985          _elm_win_accessibility_highlight_show(win);
9986          //TIZEN_ONLY(20160623): atspi: moved highlight when object is out of screen
9987          sd->accessibility_highlight.cur.need_moved = EINA_TRUE;
9988          //
9989      }
9990 }
9991 //
9992
9993 //TIZEN_ONLY(20170919): Handle default label object
9994 static void
9995 _default_label_obj_del_cb (void *data,
9996                            Evas *e EINA_UNUSED,
9997                            Evas_Object *obj,
9998                            void *event_info EINA_UNUSED)
9999 {
10000    ELM_WIN_DATA_GET(data, sd);
10001    if (!sd) return;
10002
10003    sd->default_label_objs = eina_list_remove(sd->default_label_objs, obj);
10004 }
10005
10006 static int _sort_parent_child_order(const void *data1, const void *data2)
10007 {
10008    if (data1)
10009      {
10010         Eo *parent;
10011         parent = efl_provider_find(efl_parent_get(data1), EFL_ACCESS_OBJECT_MIXIN);
10012         while (parent)
10013           {
10014              if (parent == data2) return 1;
10015              parent = efl_provider_find(efl_parent_get(parent), EFL_ACCESS_OBJECT_MIXIN);
10016           }
10017      }
10018    return -1;
10019 }
10020
10021 void
10022 _elm_win_default_label_obj_append(Evas_Object *default_label_obj)
10023 {
10024    if (!default_label_obj) return;
10025
10026    Evas_Object *win = elm_widget_top_get(default_label_obj);
10027    if (!win || !efl_isa(win, EFL_UI_WIN_CLASS))
10028      {
10029         WRN("The top object of %s is not a window.",
10030             efl_class_name_get(efl_class_get(default_label_obj)));
10031         return;
10032      }
10033
10034    ELM_WIN_DATA_GET(win, sd);
10035    if (!sd) return;
10036
10037    if (eina_list_data_find(sd->default_label_objs, default_label_obj))
10038      {
10039         sd->default_label_objs =
10040           eina_list_remove(sd->default_label_objs, default_label_obj);
10041         evas_object_event_callback_del_full(default_label_obj, EVAS_CALLBACK_DEL,
10042                                             _default_label_obj_del_cb, win);
10043      }
10044
10045    evas_object_event_callback_add(default_label_obj, EVAS_CALLBACK_DEL,
10046                                   _default_label_obj_del_cb, win);
10047    sd->default_label_objs =
10048      eina_list_append(sd->default_label_objs, default_label_obj);
10049
10050    sd->default_label_objs =
10051      eina_list_sort(sd->default_label_objs, -1, _sort_parent_child_order);
10052 }
10053
10054 void
10055 _elm_win_default_label_obj_remove(Evas_Object *default_label_obj)
10056 {
10057    if (!default_label_obj) return;
10058
10059    Evas_Object *win = elm_widget_top_get(default_label_obj);
10060    if (!win || !efl_isa(win, EFL_UI_WIN_CLASS))
10061      {
10062         WRN("The top object of %s is not a window.",
10063             efl_class_name_get(efl_class_get(default_label_obj)));
10064         return;
10065      }
10066
10067    ELM_WIN_DATA_GET(win, sd);
10068    if (!sd) return;
10069
10070    if (eina_list_data_find(sd->default_label_objs, default_label_obj))
10071      {
10072         sd->default_label_objs =
10073           eina_list_remove(sd->default_label_objs, default_label_obj);
10074         evas_object_event_callback_del_full(default_label_obj, EVAS_CALLBACK_DEL,
10075                                             _default_label_obj_del_cb, win);
10076      }
10077 }
10078
10079 Evas_Object *
10080 _elm_win_default_label_obj_get(Evas_Object *obj)
10081 {
10082    if (!obj) return NULL;
10083    ELM_WIN_DATA_GET(obj, sd);
10084    if (!sd) return NULL;
10085
10086    return eina_list_last_data_get(sd->default_label_objs);
10087 }
10088 //
10089
10090 static Ecore_Window
10091 _elm_win_window_id_get(Efl_Ui_Win_Data *sd)
10092 {
10093 #if HAVE_ELEMENTARY_WL2
10094    if (sd->wl.win)
10095      return (Ecore_Window)ecore_wl2_window_id_get(sd->wl.win);
10096    if (sd->parent)
10097      {
10098         Ecore_Wl2_Window *parent;
10099 //TIZEN_ONLY(20171208): fix build break by opensource temporarily until migration finish
10100         parent = (Ecore_Wl2_Window *)elm_win_wl_window_get(sd->parent);
10101 //TIZEN_ONLY(20171208)
10102         if (parent)
10103           return (Ecore_Window)ecore_wl2_window_id_get(parent);
10104      }
10105 #endif
10106 #ifdef HAVE_ELEMENTARY_X
10107    _internal_elm_win_xwindow_get(sd);
10108    if (sd->x.xwin)
10109      {
10110         _internal_elm_win_xwindow_get(sd);
10111         return (Ecore_Window)sd->x.xwin;
10112      }
10113    if (sd->parent)
10114      {
10115         Ecore_Window xwin = elm_win_xwindow_get(sd->parent);
10116         if (xwin) return xwin;
10117      }
10118 #endif
10119 #ifdef HAVE_ELEMENTARY_COCOA
10120    if (sd->cocoa.win) return (Ecore_Window)(sd->cocoa.win);
10121    if (sd->parent)
10122      {
10123         Ecore_Cocoa_Window *pwin;
10124         pwin = elm_win_cocoa_window_get(sd->parent);
10125         if (pwin) return (Ecore_Window)pwin;
10126      }
10127 #endif
10128 #ifdef HAVE_ELEMENTARY_WIN32
10129         _internal_elm_win_win32window_get(sd);
10130         if (sd->win32.win) return (Ecore_Window)sd->win32.win;
10131         if (sd->parent)
10132           {
10133              Ecore_Window wwin = (Ecore_Window)elm_win_win32_window_get(sd->parent);
10134              if (wwin) return wwin;
10135           }
10136 #endif
10137
10138    return 0;
10139 }
10140
10141 EAPI Ecore_Window
10142 elm_win_window_id_get(const Evas_Object *obj)
10143 {
10144    Efl_Ui_Win_Data *sd;
10145    if (!obj) return 0;
10146
10147    if (!evas_object_smart_type_check_ptr(obj, MY_CLASS_NAME_LEGACY))
10148      {
10149         Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
10150         if (!ee) return 0;
10151         return ecore_evas_window_get(ee);
10152      }
10153
10154    sd = efl_data_scope_safe_get(obj, MY_CLASS);
10155    if (!sd) return 0;
10156    return _elm_win_window_id_get(sd);
10157 }
10158
10159 EAPI Evas_Object *
10160 elm_win_main_menu_get(Evas_Object *obj)
10161 {
10162    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
10163    if (!sd) return NULL;
10164
10165 #ifdef HAVE_ELEMENTARY_X
10166    Eina_Bool use_dbus = EINA_FALSE;
10167 #endif
10168
10169    if (sd->main_menu) goto end;
10170
10171    sd->main_menu = elm_menu_add(obj);
10172    _elm_menu_menu_bar_set(sd->main_menu, EINA_TRUE);
10173
10174 #ifdef HAVE_ELEMENTARY_X
10175    if (!_elm_config->disable_external_menu && sd->x.xwin) use_dbus = EINA_TRUE;
10176
10177    if (use_dbus && _elm_dbus_menu_register(sd->main_menu))
10178      {
10179         _internal_elm_win_xwindow_get(sd);
10180         _elm_dbus_menu_app_menu_register(sd->x.xwin, sd->main_menu,
10181                                          _dbus_menu_set, obj);
10182      }
10183    else
10184 #endif
10185      _dbus_menu_set(EINA_FALSE, obj);
10186
10187 end:
10188    return sd->main_menu;
10189 }
10190
10191 EAPI void
10192 elm_win_aspect_set(Eo *obj, double aspect)
10193 {
10194    Eina_Size2D sz = { 0, 0 };
10195
10196    if (aspect > DBL_EPSILON)
10197      sz = EINA_SIZE2D(1000 * aspect, 1000);
10198
10199    efl_gfx_hint_aspect_set(obj, EFL_GFX_HINT_ASPECT_NONE, sz);
10200 }
10201
10202 EAPI double
10203 elm_win_aspect_get(const Eo *obj)
10204 {
10205    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
10206    if (!sd) return 0.0;
10207    return _win_aspect_get(sd);
10208 }
10209
10210 /* legacy APIs */
10211
10212 static void
10213 _fake_canvas_set(Evas_Object *obj, Ecore_Evas *oee)
10214 {
10215    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
10216    if (!sd) return;
10217
10218    sd->ee = oee;
10219    _elm_win_need_frame_adjust(sd, ecore_evas_engine_name_get(oee));
10220 }
10221
10222 /**
10223   * @internal
10224   *
10225   * Recalculate the size of window considering its resize objects' weight and
10226   * min size. If any of its resize objects' weight equals to 0.0, window
10227   * layout's weight will be set to 0.0.
10228   *
10229   * @param o box object
10230   * @param p box's private data
10231   * @param data window object
10232   */
10233 static void
10234 _window_layout_stack(Evas_Object *o, Evas_Object_Box_Data *p, void *data)
10235 {
10236    const Eina_List *l;
10237    Evas_Object *child;
10238    Evas_Object_Box_Option *opt;
10239    Evas_Coord x, y, w, h, menuw = 0;
10240    double wx, wy;
10241    Evas_Coord minw = -1, minh = -1;
10242    double weight_x = EVAS_HINT_EXPAND;
10243    double weight_y = EVAS_HINT_EXPAND;
10244
10245    ELM_WIN_DATA_GET(data, sd);
10246    if (sd->main_menu && efl_gfx_entity_visible_get(sd->main_menu))
10247      evas_object_size_hint_combined_min_get(sd->main_menu, &menuw, NULL);
10248
10249    EINA_LIST_FOREACH(p->children, l, opt)
10250      {
10251         child = opt->obj;
10252         efl_gfx_hint_weight_get(child, &wx, &wy);
10253         if (EINA_DBL_EQ(wx, 0.0)) weight_x = 0;
10254         if (EINA_DBL_EQ(wy, 0.0)) weight_y = 0;
10255
10256         evas_object_size_hint_combined_min_get(child, &w, &h);
10257         if (w > minw) minw = w;
10258         if (h > minh) minh = h;
10259      }
10260
10261    if (minw < menuw) minw = menuw;
10262    efl_gfx_hint_size_restricted_min_set(o, EINA_SIZE2D(minw, minh));
10263    evas_object_geometry_get(o, &x, &y, &w, &h);
10264    if (w < minw) w = minw;
10265    if (h < minh) h = minh;
10266    evas_object_resize(o, w, h);
10267
10268    EINA_LIST_FOREACH(p->children, l, opt)
10269      {
10270         child = opt->obj;
10271         evas_object_geometry_set(child, x, y, w, h);
10272      }
10273
10274    efl_gfx_hint_weight_set(sd->legacy.edje, weight_x, weight_y);
10275    //evas_object_smart_changed(sd->legacy.edje);
10276 }
10277
10278 static void
10279 _elm_win_legacy_init(Efl_Ui_Win_Data *sd)
10280 {
10281    sd->legacy.edje = edje_object_add(sd->evas);
10282    _elm_win_theme_internal(sd->obj, sd);
10283
10284 //TIZEN_ONLY(20161208): supported floating window
10285    if (sd->type != ELM_WIN_BASIC)
10286      edje_object_signal_emit(sd->legacy.edje, "elm,state,floating,on", "elm");
10287 //
10288
10289    sd->legacy.box = evas_object_box_add(sd->evas);
10290    evas_object_box_layout_set(sd->legacy.box, _window_layout_stack, sd->obj, NULL);
10291
10292    if (elm_widget_is_legacy(sd->obj))
10293      edje_object_part_swallow(sd->legacy.edje, "elm.swallow.contents", sd->legacy.box);
10294    else
10295      edje_object_part_swallow(sd->legacy.edje, "efl.contents", sd->legacy.box);
10296
10297    if (sd->type != EFL_UI_WIN_TYPE_FAKE)
10298      {
10299         edje_object_update_hints_set(sd->legacy.edje, EINA_TRUE);
10300         evas_object_event_callback_add(sd->legacy.edje, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
10301                                        _elm_win_on_resize_obj_changed_size_hints, sd->obj);
10302      }
10303 }
10304
10305 EAPI void
10306 elm_win_resize_object_add(Eo *obj, Evas_Object *subobj)
10307 {
10308    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
10309    Eina_Bool ret;
10310
10311    if (!sd) return;
10312    if (sd->legacy.forbidden)
10313      {
10314         CRI("Use of this API is forbidden after calling an EO API on this "
10315             "window. Fix your code!");
10316         return;
10317      }
10318
10319    // Little hack for E
10320    if (evas_obj_box_count(sd->legacy.box) > 0)
10321      sd->single_edje_content = 0;
10322    else if (efl_isa(subobj, EFL_CANVAS_LAYOUT_CLASS))
10323      sd->single_edje_content = 1;
10324
10325    ret  = elm_widget_sub_object_add(obj, subobj);
10326    ret &= (evas_object_box_append(sd->legacy.box, subobj) != NULL);
10327
10328    if (!ret)
10329      ERR("could not add sub object %p to window %p", subobj, obj);
10330 }
10331
10332 EAPI void
10333 elm_win_resize_object_del(Eo *obj, Evas_Object *subobj)
10334 {
10335    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
10336    Eina_Bool ret;
10337
10338    if (!sd) return;
10339    if (sd->legacy.forbidden)
10340      {
10341         CRI("Use of this API is forbidden after calling an EO API on this "
10342             "window. Fix your code!");
10343         return;
10344      }
10345
10346    ret  = elm_widget_sub_object_del(obj, subobj);
10347    ret &= evas_object_box_remove(sd->legacy.box, subobj);
10348
10349    if (!ret)
10350      ERR("could not remove sub object %p from window %p", subobj, obj);
10351 }
10352
10353 EAPI Eina_Bool
10354 elm_win_keygrab_set(Elm_Win *obj, const char *key,
10355                     Evas_Modifier_Mask modifiers EINA_UNUSED,
10356                     Evas_Modifier_Mask not_modifiers EINA_UNUSED,
10357                     int priority EINA_UNUSED, Elm_Win_Keygrab_Mode grab_mode)
10358 {
10359    // Note: Not converting modifiers as they are not used in the implementation
10360    Eina_Bool ret = EINA_FALSE;
10361 #ifdef HAVE_ELEMENTARY_X
10362    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
10363    EINA_SAFETY_ON_NULL_RETURN_VAL(sd, EINA_FALSE);
10364    _internal_elm_win_xwindow_get(sd);
10365    if (sd->x.xwin)
10366      {
10367         _internal_elm_win_xwindow_get(sd);
10368         Ecore_X_Win_Keygrab_Mode x_grab_mode;
10369         switch (grab_mode)
10370           {
10371            case ELM_WIN_KEYGRAB_SHARED:
10372              x_grab_mode = ECORE_X_WIN_KEYGRAB_SHARED;
10373              break;
10374            case ELM_WIN_KEYGRAB_TOPMOST:
10375              x_grab_mode = ECORE_X_WIN_KEYGRAB_TOPMOST;
10376              break;
10377            case ELM_WIN_KEYGRAB_EXCLUSIVE:
10378              x_grab_mode = ECORE_X_WIN_KEYGRAB_EXCLUSIVE;
10379              break;
10380            case ELM_WIN_KEYGRAB_OVERRIDE_EXCLUSIVE:
10381              x_grab_mode = ECORE_X_WIN_KEYGRAB_OVERRIDE_EXCLUSIVE;
10382              break;
10383            default:
10384              return ret;
10385           }
10386          ret = ecore_x_window_keygrab_set(sd->x.xwin, key, 0, 0, 0, x_grab_mode);
10387      }
10388 #else
10389
10390 // TIZEN_ONLY(20150722): Add ecore_wl2_window_keygrab_* APIs
10391 #ifdef HAVE_ELEMENTARY_WL2
10392    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
10393    EINA_SAFETY_ON_FALSE_RETURN_VAL(sd, EINA_FALSE);
10394    _elm_win_wlwindow_get(sd);
10395    if (sd->wl.win)
10396      {
10397         Ecore_Wl2_Window_Keygrab_Mode wl_grab_mode;
10398         switch (grab_mode)
10399           {
10400            case ELM_WIN_KEYGRAB_SHARED:
10401              wl_grab_mode = ECORE_WL2_WINDOW_KEYGRAB_SHARED;
10402              break;
10403            case ELM_WIN_KEYGRAB_TOPMOST:
10404              wl_grab_mode = ECORE_WL2_WINDOW_KEYGRAB_TOPMOST;
10405              break;
10406            case ELM_WIN_KEYGRAB_EXCLUSIVE:
10407              wl_grab_mode = ECORE_WL2_WINDOW_KEYGRAB_EXCLUSIVE;
10408              break;
10409            case ELM_WIN_KEYGRAB_OVERRIDE_EXCLUSIVE:
10410              wl_grab_mode = ECORE_WL2_WINDOW_KEYGRAB_OVERRIDE_EXCLUSIVE;
10411              break;
10412            default:
10413              return ret;
10414           }
10415         ret = ecore_wl2_window_keygrab_set(sd->wl.win, key, 0, 0, 0, wl_grab_mode);
10416      }
10417 #endif
10418 //
10419
10420    (void)obj;
10421    (void)key;
10422    (void)grab_mode;
10423 #endif
10424    return ret;
10425 }
10426
10427 EAPI Eina_Bool
10428 elm_win_keygrab_unset(Elm_Win *obj, const char *key,
10429                       Evas_Modifier_Mask modifiers EINA_UNUSED,
10430                       Evas_Modifier_Mask not_modifiers EINA_UNUSED)
10431 {
10432    // Note: Not converting modifiers as they are not used in the implementation
10433    Eina_Bool ret = EINA_FALSE;
10434 #ifdef HAVE_ELEMENTARY_X
10435    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
10436    EINA_SAFETY_ON_NULL_RETURN_VAL(sd, EINA_FALSE);
10437    _internal_elm_win_xwindow_get(sd);
10438    if (sd->x.xwin)
10439      {
10440         _internal_elm_win_xwindow_get(sd);
10441         ret = ecore_x_window_keygrab_unset(sd->x.xwin, key, 0, 0);
10442      }
10443 #else
10444
10445 // TIZEN_ONLY(20150722): Add ecore_wl2_window_keygrab_* APIs
10446 #ifdef HAVE_ELEMENTARY_WL2
10447    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
10448    EINA_SAFETY_ON_FALSE_RETURN_VAL(sd, EINA_FALSE);
10449    _elm_win_wlwindow_get(sd);
10450    if (sd->wl.win)
10451      ret = ecore_wl2_window_keygrab_unset(sd->wl.win, key, 0, 0);
10452 #endif
10453 //
10454
10455    (void)obj;
10456    (void)key;
10457 #endif
10458    return ret;
10459 }
10460
10461 EAPI Eina_Bool
10462 elm_win_socket_listen(Efl_Ui_Win *obj, const char *svcname, int svcnum, Eina_Bool svcsys)
10463 {
10464    return efl_ui_win_socket_listen(obj, svcname, svcnum, svcsys);
10465 }
10466
10467 EAPI Eina_Bool
10468 elm_win_focus_get(const Efl_Ui_Win *obj)
10469 {
10470    EINA_SAFETY_ON_FALSE_RETURN_VAL(efl_isa(obj, MY_CLASS), EINA_FALSE);
10471    /* TIZEN_ONLY(20180607): Restore legacy focus
10472    return efl_ui_focus_object_focus_get(obj);
10473    */
10474    ELM_WIN_DATA_GET_OR_RETURN(obj, sd, EINA_FALSE);
10475    return ecore_evas_focus_get(sd->ee);
10476    //
10477 }
10478
10479 EAPI Eina_Bool
10480 elm_win_available_profiles_get(const Elm_Win *obj, char ***profiles, unsigned int *count)
10481 {
10482    const Eina_Array *ar;
10483
10484    if (!efl_isa(obj, MY_CLASS)) return EINA_FALSE;
10485    ar = efl_ui_win_wm_available_profiles_get(obj);
10486    if (!ar)
10487      {
10488         if (profiles) *profiles = NULL;
10489         if (count) *count = 0;
10490         return EINA_FALSE;
10491      }
10492
10493    if (profiles) *profiles = (char **) ar->data;
10494    if (count) *count = ar->count;
10495    return EINA_TRUE;
10496 }
10497
10498 EAPI void
10499 elm_win_available_profiles_set(Elm_Win *obj, const char **profiles, unsigned int count)
10500 {
10501    if (!efl_isa(obj, MY_CLASS)) return;
10502    if ((count > 0) && (profiles))
10503      {
10504         Eina_Array *ar;
10505         unsigned int i;
10506
10507         ar = eina_array_new(count);
10508         if (ar)
10509           {
10510              for (i = 0; i < count; i++)
10511                eina_array_push(ar, profiles[i]);
10512              efl_ui_win_wm_available_profiles_set(obj, ar);
10513              eina_array_free(ar);
10514           }
10515      }
10516    else efl_ui_win_wm_available_profiles_set(obj, NULL);
10517 }
10518
10519 // TIZEN_ONLY(20171114) Accessibility Highlight Frame added
10520 // //TIZEN_ONLY(20171108): bring HIGHLIGHT related changes
10521 // static void
10522 // _elm_win_accessibility_highlight_obj_del(void *data,
10523 //                                          Evas *e EINA_UNUSED,
10524 //                                          Evas_Object *obj EINA_UNUSED,
10525 //                                          void *event_info EINA_UNUSED)
10526 // {
10527 //    ELM_WIN_DATA_GET(data, sd);
10528 //    _elm_win_accessibility_highlight_shutdown(sd);
10529 // }
10530 //
10531 // static void
10532 // _elm_win_accessibility_highlight_obj_move(void *data,
10533 //                                           Evas *e EINA_UNUSED,
10534 //                                           Evas_Object *obj EINA_UNUSED,
10535 //                                           void *event_info EINA_UNUSED)
10536 // {
10537 //    ELM_WIN_DATA_GET(data, sd);
10538 //    _elm_win_accessibility_highlight_update(sd);
10539 // }
10540 //
10541 // static void
10542 // _elm_win_accessibility_highlight_obj_resize(void *data,
10543 //                                             Evas *e EINA_UNUSED,
10544 //                                             Evas_Object *obj EINA_UNUSED,
10545 //                                             void *event_info EINA_UNUSED)
10546 // {
10547 //    ELM_WIN_DATA_GET(data, sd);
10548 //    _elm_win_accessibility_highlight_update(sd);
10549 // }
10550 //
10551 // static void _elm_win_accessibility_highlight_callbacks_add(Efl_Ui_Win_Data *sd)
10552 // {
10553 //    Evas_Object *obj = sd->accessibility_highlight.target;
10554 //    if (!obj) return;
10555 //
10556 //    evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, _elm_win_accessibility_highlight_obj_del, sd->obj);
10557 //
10558 //    if (efl_isa(obj, ELM_WIDGET_CLASS) && elm_widget_access_highlight_in_theme_get(obj))
10559 //       return;
10560 //
10561 //    evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _elm_win_accessibility_highlight_obj_move, sd->obj);
10562 //    evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _elm_win_accessibility_highlight_obj_resize, sd->obj);
10563 // }
10564
10565 // static void _elm_win_accessibility_highlight_init(Efl_Ui_Win_Data *sd)
10566 // {
10567 //    if (sd->accessibility_highlight.enabled) return;
10568 //    sd->accessibility_highlight.enabled = EINA_TRUE;
10569 //
10570 //    sd->accessibility_highlight.fobj = edje_object_add(sd->evas);
10571 //    elm_widget_theme_object_set(sd->obj, sd->accessibility_highlight.fobj, "access", "base", "default");
10572 // }
10573 //
10574 // static void
10575 // _elm_win_accessibility_highlight_visible_set(Efl_Ui_Win_Data *sd,
10576 // Eina_Bool visible)
10577 // {
10578 //    Evas_Object *fobj = sd->accessibility_highlight.fobj;
10579 //    Evas_Object *target = sd->accessibility_highlight.target;
10580 //
10581 //    if (!target) return;
10582 //
10583 //    if (efl_isa(target, ELM_WIDGET_CLASS) && elm_widget_access_highlight_in_theme_get(target))
10584 //      {
10585 //         if (visible)
10586 //           elm_widget_signal_emit(target, "elm,action,access_highlight,show", "elm");
10587 //         else
10588 //           elm_widget_signal_emit(target, "elm,action,access_highlight,hide", "elm");
10589 //         }
10590 //    else
10591 //      {
10592 //         if (visible)
10593 //           evas_object_show(fobj);
10594 //         else
10595 //           evas_object_hide(fobj);
10596 //      }
10597 // }
10598 //
10599 // static void
10600 // _elm_win_accessibility_highlight_update(Efl_Ui_Win_Data *sd)
10601 // {
10602 //    Evas_Coord x, y, w, h;
10603 //    Evas_Object *target = sd->accessibility_highlight.target;
10604 //    Evas_Object *fobj = sd->accessibility_highlight.fobj;
10605 //
10606 //    if (!target) return;
10607 //    if (efl_isa(target, ELM_WIDGET_CLASS) && elm_widget_access_highlight_in_theme_get(target))
10608 //       return;
10609 //
10610 //    evas_object_geometry_get(target, &x, &y, &w, &h);
10611 //    evas_object_move(fobj, x, y);
10612 //    evas_object_resize(fobj, w, h);
10613 //    evas_object_raise(fobj);
10614 // }
10615 //
10616 // static void
10617 // _elm_win_accessibility_highlight_target_set(Efl_Ui_Win_Data *sd, Evas_Object *target)
10618 // {
10619 //    Evas_Object *clip, *fobj = sd->accessibility_highlight.fobj;
10620 //
10621 //    if (sd->accessibility_highlight.target == target)
10622 //       return;
10623 //
10624 //    _elm_win_accessibility_highlight_visible_set(sd, EINA_FALSE);
10625 //    _elm_win_accessibility_highlight_callbacks_del(sd);
10626 //
10627 //    sd->accessibility_highlight.target = target;
10628 //    if (!target) return;
10629 //
10630 //    clip = evas_object_clip_get(target);
10631 //    if (clip) evas_object_clip_set(fobj, clip);
10632 //
10633 //    _elm_win_accessibility_highlight_callbacks_add(sd);
10634 //    _elm_win_accessibility_highlight_update(sd);
10635 //    _elm_win_accessibility_highlight_visible_set(sd, EINA_TRUE);
10636 // }
10637 //
10638 // static void _elm_win_accessibility_highlight_shutdown(Efl_Ui_Win_Data *sd)
10639 // {
10640 //    if (!sd->accessibility_highlight.enabled) return;
10641 //
10642 //    _elm_win_accessibility_highlight_target_set(sd, NULL);
10643 //    evas_object_del(sd->accessibility_highlight.fobj);
10644 //    sd->accessibility_highlight.fobj = NULL;
10645 //    sd->accessibility_highlight.enabled = EINA_FALSE;
10646 // }
10647 //
10648 // void
10649 // _elm_win_accessibility_highlight_set(Evas_Object *win, Evas_Object *obj)
10650 // {
10651 //    ELM_WIN_DATA_GET_OR_RETURN(win, sd);
10652 //
10653 //    if (obj)
10654 //       {
10655 //          _elm_win_accessibility_highlight_init(sd);
10656 //          _elm_win_accessibility_highlight_target_set(sd, obj);
10657 //       }
10658 //    else
10659 //      _elm_win_accessibility_highlight_shutdown(sd);
10660 // }
10661 //
10662 // Evas_Object*
10663 // _elm_win_accessibility_highlight_get(Evas_Object *win)
10664 // {
10665 //    ELM_WIN_DATA_GET_OR_RETURN(win, sd, NULL);
10666 //    return sd->accessibility_highlight.target;
10667 // }
10668 // //
10669 //
10670
10671 // deprecated
10672
10673 EAPI void
10674 elm_win_fake_canvas_set(Evas_Object *obj EINA_UNUSED, Ecore_Evas *oee EINA_UNUSED)
10675 {
10676    ERR("Calling deprecrated function '%s'", __func__);
10677 }
10678
10679 EAPI void
10680 elm_win_name_set(Evas_Object *obj, const char *name)
10681 {
10682    ERR("Calling deprecrated function '%s'", __func__);
10683    efl_ui_win_name_set(obj, name);
10684 }
10685
10686 EAPI void
10687 elm_win_type_set(Evas_Object *obj, Elm_Win_Type type)
10688 {
10689    ERR("Calling deprecrated function '%s'", __func__);
10690    efl_ui_win_type_set(obj, _elm_win_type_to_efl_ui_win_type(type));
10691 }
10692
10693 EAPI void
10694 elm_win_teamwork_uri_preload(Efl_Ui_Win *obj EINA_UNUSED, const char *uri EINA_UNUSED)
10695 {
10696    ERR("Calling deprecrated function '%s'", __func__);
10697 }
10698
10699 EAPI void
10700 elm_win_teamwork_uri_show(Efl_Ui_Win *obj EINA_UNUSED, const char *uri EINA_UNUSED)
10701 {
10702    ERR("Calling deprecrated function '%s'", __func__);
10703 }
10704
10705 EAPI void
10706 elm_win_teamwork_uri_hide(Efl_Ui_Win *obj EINA_UNUSED)
10707 {
10708    ERR("Calling deprecrated function '%s'", __func__);
10709 }
10710
10711 EAPI void
10712 elm_win_teamwork_uri_open(Efl_Ui_Win *obj EINA_UNUSED, const char *uri EINA_UNUSED)
10713 {
10714    ERR("Calling deprecrated function '%s'", __func__);
10715 }
10716
10717 // TIZEN_ONLY(20160216) : elm_win_input_rect_set/add/subtract added
10718 EAPI void
10719 elm_win_input_rect_set(Evas_Object *obj, Eina_Rectangle *input_rect)
10720 {
10721    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
10722    TRAP(sd, input_rect_set, input_rect);
10723 }
10724
10725 EAPI void
10726 elm_win_input_rect_add(Evas_Object *obj, Eina_Rectangle *input_rect)
10727 {
10728    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
10729    TRAP(sd, input_rect_add, input_rect);
10730 }
10731
10732 EAPI void
10733 elm_win_input_rect_subtract(Evas_Object *obj, Eina_Rectangle *input_rect)
10734 {
10735    ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
10736    TRAP(sd, input_rect_subtract, input_rect);
10737 }
10738 //
10739
10740 // TIZEN_ONLY(20160617) : add elm_win_active_win_orientation_get
10741 EAPI int
10742 elm_win_active_win_orientation_get(Evas_Object *obj)
10743 {
10744    int angle = -1;
10745 #ifdef HAVE_ELEMENTARY_WL2
10746    Ecore_Wl2_Window *win = NULL;
10747    if (obj)
10748      {
10749         ELM_WIN_DATA_GET_OR_RETURN(obj, sd, angle);
10750         if (sd)
10751           win = sd->wl.win;
10752      }
10753    if (win) angle = ecore_wl2_window_active_angle_get(win);
10754 #endif
10755    return angle;
10756 }
10757 //
10758
10759 //////////////////////////////////////////////////////////////////
10760 // TIZEN_ONLY(20150722): added signal for aux_hint(auxiliary hint)
10761 EAPI const Eina_List *
10762 elm_win_aux_hints_supported_get(const Evas_Object *obj)
10763 {
10764    ELM_WIN_DATA_GET_OR_RETURN(obj, sd, NULL);
10765    return ecore_evas_aux_hints_supported_get(sd->ee);
10766 }
10767
10768 EAPI int
10769 elm_win_aux_hint_add(Evas_Object *obj, const char *hint, const char *val)
10770 {
10771    ELM_WIN_DATA_GET_OR_RETURN(obj, sd, -1);
10772 // TIZEN_ONLY(20170212): pend rotation until app set rotation
10773    if ((hint) && (!strncmp(hint, "wm.policy.win.rot.render.nopending", strlen(hint))))
10774      {
10775         return _elm_win_wm_pending_rotation_set(obj, hint, val);
10776      }
10777 //
10778    return ecore_evas_aux_hint_add(sd->ee, hint, val);
10779 }
10780
10781 EAPI Eina_Bool
10782 elm_win_aux_hint_del(Evas_Object *obj,
10783                      const int    id)
10784 {
10785    ELM_WIN_DATA_GET_OR_RETURN(obj, sd, EINA_FALSE);
10786    return ecore_evas_aux_hint_del(sd->ee, id);
10787 }
10788
10789 EAPI Eina_Bool
10790 elm_win_aux_hint_val_set(Evas_Object *obj, const int id, const char *val)
10791 {
10792    ELM_WIN_DATA_GET_OR_RETURN(obj, sd, EINA_FALSE);
10793    return ecore_evas_aux_hint_val_set(sd->ee, id, val);
10794 }
10795
10796 EAPI const char *
10797 elm_win_aux_hint_val_get(Evas_Object *obj, int id)
10798 {
10799    ELM_WIN_DATA_GET_OR_RETURN(obj, sd, NULL);
10800    return ecore_evas_aux_hint_val_get(sd->ee, id);
10801 }
10802
10803 EAPI int
10804 elm_win_aux_hint_id_get(Evas_Object *obj, const char *hint)
10805 {
10806    ELM_WIN_DATA_GET_OR_RETURN(obj, sd, -1);
10807    return ecore_evas_aux_hint_id_get(sd->ee, hint);
10808 }
10809
10810 EAPI const char *
10811 elm_win_aux_msg_key_get(Evas_Object *obj,
10812                         Elm_Win_Aux_Message *msg)
10813 {
10814    ELM_WIN_DATA_GET_OR_RETURN(obj, sd, NULL);
10815
10816    if (!msg) return NULL;
10817    return msg->key;
10818 }
10819
10820 EAPI const char *
10821 elm_win_aux_msg_val_get(Evas_Object *obj,
10822                         Elm_Win_Aux_Message *msg)
10823 {
10824    ELM_WIN_DATA_GET_OR_RETURN(obj, sd, NULL);
10825
10826    if (!msg) return NULL;
10827    return msg->val;
10828 }
10829
10830 EAPI const Eina_List *
10831 elm_win_aux_msg_options_get(Evas_Object *obj,
10832                             Elm_Win_Aux_Message *msg)
10833 {
10834    ELM_WIN_DATA_GET_OR_RETURN(obj, sd, NULL);
10835
10836    if (!msg) return NULL;
10837    return msg->options;
10838 }
10839 // END of TIZEN_ONLY(20150722): added signal for aux_hint(auxiliary hint)
10840 //////////////////////////////////////////////////////////////////
10841
10842 /***********************************************************
10843  * TIZEN_ONLY(20180117): Override Paragraph Direction APIs *
10844  ***********************************************************/
10845 EOLIAN static void
10846 _efl_ui_win_efl_canvas_object_paragraph_direction_set(Eo *obj, Efl_Ui_Win_Data *sd, Efl_Text_Bidirectional_Type dir)
10847 {
10848    efl_canvas_object_paragraph_direction_set(sd->legacy.edje, dir);
10849
10850    efl_canvas_object_paragraph_direction_set(efl_super(obj, MY_CLASS), dir);
10851 }
10852 /*******
10853  * END *
10854  *******/
10855
10856 /* What here follows is code that implements the glue between ecore evas and efl_ui* side */
10857 typedef struct {
10858    Eo *obj;
10859    Eina_Bool currently_inside;
10860 } Ui_Dnd_Target;
10861
10862 static inline Efl_Ui_Cnp_Buffer
10863 _ui_buffer_get(Ecore_Evas_Selection_Buffer buffer)
10864 {
10865    if (buffer == ECORE_EVAS_SELECTION_BUFFER_SELECTION_BUFFER)
10866      return EFL_UI_CNP_BUFFER_SELECTION;
10867    else if (buffer == ECORE_EVAS_SELECTION_BUFFER_COPY_AND_PASTE_BUFFER)
10868      return EFL_UI_CNP_BUFFER_COPY_AND_PASTE;
10869
10870    return -1;
10871 }
10872
10873 void
10874 _register_selection_changed(Efl_Ui_Selection *selection)
10875 {
10876    ELM_WIN_DATA_GET(efl_provider_find(selection, EFL_UI_WIN_CLASS), pd);
10877
10878    eina_array_push(pd->planned_changes, selection);
10879 }
10880
10881 static Eina_Bool
10882 _remove_object(void *data, void *gdata)
10883 {
10884    if (data == gdata)
10885      return EINA_FALSE;
10886    return EINA_TRUE;
10887 }
10888
10889 static void
10890 _selection_changed_cb(Ecore_Evas *ee, unsigned int seat, Ecore_Evas_Selection_Buffer selection)
10891 {
10892    Efl_Ui_Win_Data *pd = _elm_win_associate_get(ee);
10893    Efl_Ui_Wm_Selection_Changed changed = {
10894       .seat = seat,
10895       .buffer = _ui_buffer_get(selection),
10896       .caused_by = eina_array_count(pd->planned_changes) > 0 ? eina_array_data_get(pd->planned_changes, 0) : NULL,
10897    };
10898
10899    for (unsigned int i = 0; i < eina_array_count(pd->selection_changed); ++i)
10900      {
10901         Eo *obj = eina_array_data_get(pd->selection_changed, i);
10902
10903         efl_event_callback_call(obj, EFL_UI_SELECTION_EVENT_WM_SELECTION_CHANGED, &changed);
10904      }
10905
10906    if (changed.caused_by)
10907      eina_array_remove(pd->planned_changes, _remove_object, changed.caused_by);
10908 }
10909
10910 static void
10911 _motion_cb(Ecore_Evas *ee, unsigned int seat, Eina_Position2D p)
10912 {
10913    Efl_Ui_Win_Data *pd = _elm_win_associate_get(ee);
10914    // TIZEN_ONLY(20211208): keep the order of enter and leave event
10915    /*
10916    for (unsigned int i = 0; i < eina_inarray_count(pd->drop_target); ++i)
10917      {
10918         Ui_Dnd_Target *target = eina_inarray_nth(pd->drop_target, i);
10919         Eina_Rect rect = efl_gfx_entity_geometry_get(target->obj);
10920         Eina_Bool inside = eina_rectangle_coords_inside(&rect.rect, p.x, p.y);
10921         Efl_Ui_Drop_Event ev = {p, seat, ecore_evas_drop_available_types_get(ee, seat)};
10922
10923         if (target->currently_inside && !inside)
10924           {
10925              target->currently_inside = EINA_FALSE;
10926              efl_event_callback_call(target->obj, EFL_UI_DND_EVENT_DROP_LEFT, &ev);
10927              ecore_evas_dnd_mark_motion_used(ee, seat);
10928           }
10929         else if (!target->currently_inside && inside)
10930           {
10931              target->currently_inside = EINA_TRUE;
10932              efl_event_callback_call(target->obj, EFL_UI_DND_EVENT_DROP_ENTERED, &ev);
10933              ecore_evas_dnd_mark_motion_used(ee, seat);
10934           }
10935         else if (target->currently_inside && inside)
10936           {
10937              efl_event_callback_call(target->obj, EFL_UI_DND_EVENT_DROP_POSITION_CHANGED, &ev);
10938              ecore_evas_dnd_mark_motion_used(ee, seat);
10939           }
10940         eina_accessor_free(ev.available_types);
10941      }
10942    */
10943    for (unsigned int i = 0; i < eina_inarray_count(pd->drop_target); ++i)
10944      {
10945         Ui_Dnd_Target *target = eina_inarray_nth(pd->drop_target, i);
10946         Eina_Rect rect = efl_gfx_entity_geometry_get(target->obj);
10947         Eina_Bool inside = eina_rectangle_coords_inside(&rect.rect, p.x, p.y);
10948         Efl_Ui_Drop_Event ev = {p, seat, ecore_evas_drop_available_types_get(ee, seat)};
10949
10950         if (target->currently_inside && !inside)
10951           {
10952              target->currently_inside = EINA_FALSE;
10953              efl_event_callback_call(target->obj, EFL_UI_DND_EVENT_DROP_LEFT, &ev);
10954              ecore_evas_dnd_mark_motion_used(ee, seat);
10955           }
10956      }
10957
10958    for (unsigned int i = 0; i < eina_inarray_count(pd->drop_target); ++i)
10959      {
10960         Ui_Dnd_Target *target = eina_inarray_nth(pd->drop_target, i);
10961         Eina_Rect rect = efl_gfx_entity_geometry_get(target->obj);
10962         Eina_Bool inside = eina_rectangle_coords_inside(&rect.rect, p.x, p.y);
10963         Efl_Ui_Drop_Event ev = {p, seat, ecore_evas_drop_available_types_get(ee, seat)};
10964
10965         if (!target->currently_inside && inside)
10966           {
10967              target->currently_inside = EINA_TRUE;
10968              efl_event_callback_call(target->obj, EFL_UI_DND_EVENT_DROP_ENTERED, &ev);
10969              ecore_evas_dnd_mark_motion_used(ee, seat);
10970           }
10971         else if (target->currently_inside && inside)
10972           {
10973              efl_event_callback_call(target->obj, EFL_UI_DND_EVENT_DROP_POSITION_CHANGED, &ev);
10974              ecore_evas_dnd_mark_motion_used(ee, seat);
10975           }
10976         eina_accessor_free(ev.available_types);
10977      }
10978    //
10979 }
10980
10981 static void
10982 _enter_state_change_cb(Ecore_Evas *ee, unsigned int seat EINA_UNUSED, Eina_Position2D p, Eina_Bool move_inside)
10983 {
10984    Efl_Ui_Win_Data *pd = _elm_win_associate_get(ee);
10985    for (unsigned int i = 0; i < eina_inarray_count(pd->drop_target); ++i)
10986      {
10987         Ui_Dnd_Target *target = eina_inarray_nth(pd->drop_target, i);
10988         Eina_Rect rect = efl_gfx_entity_geometry_get(target->obj);
10989         Eina_Bool inside = eina_rectangle_coords_inside(&rect.rect, p.x, p.y);
10990         Efl_Ui_Drop_Event ev = {p, seat, ecore_evas_drop_available_types_get(ee, seat)};
10991
10992         if (inside && move_inside)
10993           {
10994              target->currently_inside = EINA_TRUE;
10995              // TIZEN_ONLY(20211208): keep the order of enter and leave event
10996              //efl_event_callback_call(target->obj, EFL_UI_DND_EVENT_DROP_ENTERED, &ev);
10997              //
10998           }
10999         else if (!move_inside && !target->currently_inside)
11000           {
11001              target->currently_inside = EINA_FALSE;
11002              // TIZEN_ONLY(20211208): keep the order of enter and leave event
11003              //efl_event_callback_call(target->obj, EFL_UI_DND_EVENT_DROP_LEFT, &ev);
11004              //
11005           }
11006      }
11007 }
11008
11009 static void
11010 _drop_cb(Ecore_Evas *ee, unsigned int seat EINA_UNUSED, Eina_Position2D p, const char *action)
11011 {
11012    Eina_List *itr, *top_objects_list = NULL;
11013    Efl_Ui_Win_Data *pd = _elm_win_associate_get(ee);
11014    Eina_Array *tmp = eina_array_new(10);
11015    Eo *top_obj;
11016
11017    for (unsigned int i = 0; i < eina_inarray_count(pd->drop_target); ++i)
11018      {
11019         Ui_Dnd_Target *target = eina_inarray_nth(pd->drop_target, i);
11020         Eina_Rect rect = efl_gfx_entity_geometry_get(target->obj);
11021         Eina_Bool inside = eina_rectangle_coords_inside(&rect.rect, p.x, p.y);
11022
11023         if (inside)
11024           {
11025              EINA_SAFETY_ON_FALSE_GOTO(target->currently_inside, end);
11026              eina_array_push(tmp, target->obj);
11027              // TIZEN_ONLY(20211208): keep the order of enter and leave event
11028              target->currently_inside = EINA_FALSE;
11029              //
11030           }
11031      }
11032
11033    /* We retrieve the (non-smart) objects pointed by (px, py) */
11034    top_objects_list = evas_tree_objects_at_xy_get(ecore_evas_get(ee), NULL, p.x, p.y);
11035    /* We walk on this list from the last because if the list contains more than one
11036     * element, all but the last will repeat events. The last one can repeat events
11037     * or not. Anyway, this last one is the first that has to be taken into account
11038     * for the determination of the drop target.
11039     */
11040    EINA_LIST_REVERSE_FOREACH(top_objects_list, itr, top_obj)
11041      {
11042         Evas_Object *object = top_obj;
11043         /* We search for the dropable data into the object. If not found, we search into its parent.
11044          * For example, if a button is a drop target, the first object will be an (internal) image.
11045          * The drop target is attached to the button, i.e to image's parent. That's why we need to
11046          * walk on the parents until NULL.
11047          * If we find this dropable data, we found our drop target.
11048          */
11049         while (object)
11050           {
11051              unsigned int out_idx;
11052              if (!eina_array_find(tmp, object, &out_idx))
11053                {
11054                   object = evas_object_smart_parent_get(object);
11055                }
11056              else
11057                {
11058                   Efl_Ui_Drop_Dropped_Event ev = {{p, seat, ecore_evas_drop_available_types_get(ee, seat)}, action};
11059                   efl_event_callback_call(object, EFL_UI_DND_EVENT_DROP_DROPPED, &ev);
11060                   goto end;
11061                }
11062           }
11063      }
11064 end:
11065    eina_list_free(top_objects_list);
11066    eina_array_free(tmp);
11067 }
11068
11069 static void
11070 _ee_backbone_init(Efl_Ui_Win *obj EINA_UNUSED, Efl_Ui_Win_Data *pd)
11071 {
11072    pd->selection_changed = eina_array_new(1);
11073    pd->drop_target = eina_inarray_new(sizeof(Ui_Dnd_Target), 1);
11074
11075    ecore_evas_callback_selection_changed_set(pd->ee, _selection_changed_cb);
11076    ecore_evas_callback_drop_drop_set(pd->ee, _drop_cb);
11077    ecore_evas_callback_drop_motion_set(pd->ee, _motion_cb);
11078    ecore_evas_callback_drop_state_changed_set(pd->ee, _enter_state_change_cb);
11079 }
11080
11081 static void
11082 _ee_backbone_shutdown(Efl_Ui_Win *obj EINA_UNUSED, Efl_Ui_Win_Data *pd)
11083 {
11084    ecore_evas_callback_selection_changed_set(pd->ee, NULL);
11085    ecore_evas_callback_drop_drop_set(pd->ee, NULL);
11086    ecore_evas_callback_drop_motion_set(pd->ee, NULL);
11087    ecore_evas_callback_drop_state_changed_set(pd->ee, NULL);
11088
11089    eina_array_free(pd->selection_changed);
11090    pd->selection_changed = NULL;
11091    eina_inarray_free(pd->drop_target);
11092    pd->drop_target = NULL;
11093
11094 }
11095
11096 static Eina_Bool
11097 _remove(void *data, void *gdata)
11098 {
11099    if (data == gdata)
11100      return EINA_FALSE;
11101    return EINA_TRUE;
11102 }
11103
11104 Efl_Ui_Win*
11105 efl_ui_win_get(Evas_Object *obj)
11106 {
11107    Efl_Ui_Win *win = efl_provider_find(obj, MY_CLASS);
11108    if (!win)
11109      {
11110         Evas *e = evas_object_evas_get(obj);
11111         Ecore_Evas *ee = ecore_evas_ecore_evas_get(e);
11112
11113         win = ecore_evas_data_get(ee, "elm_win");
11114      }
11115    EINA_SAFETY_ON_NULL_RETURN_VAL(win, NULL);
11116    return win;
11117 }
11118
11119 static Efl_Ui_Win_Data*
11120 _fetch_win_data_from_arbitary_obj(Efl_Canvas_Object *obj)
11121 {
11122    Efl_Ui_Win *win = efl_ui_win_get(obj);
11123    EINA_SAFETY_ON_NULL_RETURN_VAL(win, NULL);
11124    Efl_Ui_Win_Data *pd = efl_data_scope_safe_get(win, MY_CLASS);
11125    EINA_SAFETY_ON_NULL_RETURN_VAL(pd, NULL);
11126    return pd;
11127 }
11128
11129 void
11130 _drop_event_register(Eo *obj)
11131 {
11132    Ui_Dnd_Target target = {obj, EINA_FALSE};
11133    Efl_Ui_Win_Data *pd = _fetch_win_data_from_arbitary_obj(obj);
11134    if (!pd) return;
11135
11136    eina_inarray_push(pd->drop_target, &target);
11137 }
11138
11139 void
11140 _drop_event_unregister(Eo *obj)
11141 {
11142    int idx = -1;
11143
11144    Efl_Ui_Win_Data *pd = _fetch_win_data_from_arbitary_obj(obj);
11145    if (!pd) return;
11146
11147    for (unsigned int i = 0; i < eina_inarray_count(pd->drop_target); ++i)
11148      {
11149         Ui_Dnd_Target *target = eina_inarray_nth(pd->drop_target, i);
11150         if (target->obj == obj)
11151           {
11152              //FIXME emit drop
11153              target->currently_inside = EINA_FALSE;
11154              idx = i;
11155           }
11156      }
11157    if (idx != -1)
11158      eina_inarray_remove_at(pd->drop_target, idx);
11159 }
11160
11161 void
11162 _selection_changed_event_register(Eo *obj)
11163 {
11164    Efl_Ui_Win_Data *pd = _fetch_win_data_from_arbitary_obj(obj);
11165    if (!pd) return;
11166
11167    eina_array_push(pd->selection_changed, obj);
11168 }
11169 void
11170 _selection_changed_event_unregister(Eo *obj)
11171 {
11172    Efl_Ui_Win_Data *pd = _fetch_win_data_from_arbitary_obj(obj);
11173    if (!pd) return;
11174
11175    eina_array_remove(pd->selection_changed, _remove, obj);
11176 }
11177 /* Internal EO APIs and hidden overrides */
11178
11179 ELM_WIDGET_KEY_DOWN_DEFAULT_IMPLEMENT(efl_ui_win, Efl_Ui_Win_Data)
11180
11181 /* Internal EO APIs and hidden overrides */
11182
11183 #define EFL_UI_WIN_EXTRA_OPS \
11184    EFL_CANVAS_GROUP_ADD_DEL_OPS(efl_ui_win), \
11185    ELM_PART_CONTENT_DEFAULT_OPS(efl_ui_win), \
11186    EFL_OBJECT_OP_FUNC(efl_canvas_object_legacy_ctor, _efl_ui_win_efl_canvas_object_legacy_ctor)
11187
11188 #include "efl_ui_win.eo.c"
11189
11190 static void
11191 _efl_ui_win_legacy_class_constructor(Efl_Class *klass)
11192 {
11193    evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
11194 }
11195
11196 EOLIAN static Eo *
11197 _efl_ui_win_legacy_efl_object_finalize(Eo *obj, void *pd EINA_UNUSED)
11198 {
11199    obj = efl_finalize(efl_super(obj, EFL_UI_WIN_LEGACY_CLASS));
11200    efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
11201    return obj;
11202 }
11203
11204
11205 Efl_Object *_efl_ui_win_legacy_efl_object_finalize(Eo *obj, void *pd);
11206
11207
11208 static Eina_Bool
11209 _efl_ui_win_legacy_class_initializer(Efl_Class *klass)
11210 {
11211    const Efl_Object_Ops *opsp = NULL;
11212
11213    const Efl_Object_Property_Reflection_Ops *ropsp = NULL;
11214
11215 #ifndef EFL_UI_WIN_LEGACY_EXTRA_OPS
11216 #define EFL_UI_WIN_LEGACY_EXTRA_OPS
11217 #endif
11218
11219    EFL_OPS_DEFINE(ops,
11220       EFL_OBJECT_OP_FUNC(efl_finalize, _efl_ui_win_legacy_efl_object_finalize),
11221       EFL_UI_WIN_LEGACY_EXTRA_OPS
11222    );
11223    opsp = &ops;
11224
11225    return efl_class_functions_set(klass, opsp, ropsp);
11226 }
11227
11228 static const Efl_Class_Description _efl_ui_win_legacy_class_desc = {
11229    EO_VERSION,
11230    "Efl.Ui.Win_Legacy",
11231    EFL_CLASS_TYPE_REGULAR,
11232    0,
11233    _efl_ui_win_legacy_class_initializer,
11234    _efl_ui_win_legacy_class_constructor,
11235    NULL
11236 };
11237
11238 EFL_DEFINE_CLASS(efl_ui_win_legacy_class_get, &_efl_ui_win_legacy_class_desc, EFL_UI_WIN_CLASS, EFL_UI_LEGACY_INTERFACE, NULL);
11239
11240
11241 EAPI Evas_Object *
11242 elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type)
11243 {
11244 //TIZEN_ONLY(20160628):  Add Performance log for cold booting
11245    traceTaskStart("elm_win_add");
11246 //
11247    const Efl_Class *klass = EFL_UI_WIN_LEGACY_CLASS;
11248
11249 //TIZEN_ONLY(20161202): Temporary code - Apply mirroring in elm_win_add()
11250    if (_elm_config && _elm_config->language_auto_mirrored)
11251      {
11252         if (!strcmp(E_("default:LTR"), "default:RTL"))
11253           elm_config_mirrored_set(EINA_TRUE);
11254         else
11255           elm_config_mirrored_set(EINA_FALSE);
11256      }
11257 //
11258
11259    switch ((int) type)
11260      {
11261       case ELM_WIN_INLINED_IMAGE:
11262         klass = EFL_UI_WIN_INLINED_LEGACY_CLASS;
11263         break;
11264       case ELM_WIN_SOCKET_IMAGE:
11265         klass = EFL_UI_WIN_SOCKET_LEGACY_CLASS;
11266         break;
11267       default:
11268         break;
11269      }
11270 // TIZEN_ONLY(20160218): Improve launching performance.
11271    if (_precreated_win_obj)
11272      {
11273         ELM_WIN_DATA_GET(_precreated_win_obj, sd);
11274
11275         if (sd)
11276           {
11277              if ((!parent) || (sd->parent == parent))
11278                {
11279                   Evas_Object *tmp = _precreated_win_obj;
11280                   TRAP(sd, name_class_set, name, _elm_appname);
11281                   //TIZEN_ONLY(20180131):Added code to set the window title
11282                   TRAP(sd, title_set, sd->title ? sd->title : name);
11283                   _precreated_win_obj = NULL;
11284                   if (sd->type != type)
11285                     efl_ui_win_type_set(tmp, type);
11286                   INF("Return precreated obj(%p).", tmp);
11287
11288                   /* TIZEN_ONLY(20180117): Apply paragraph direction according to locale */
11289                   if (!strcmp(E_("default:LTR"), "default:RTL"))
11290                     efl_canvas_object_paragraph_direction_set(tmp, EVAS_BIDI_DIRECTION_ANY_RTL);
11291                   else
11292                     efl_canvas_object_paragraph_direction_set(tmp, EVAS_BIDI_DIRECTION_LTR);
11293                   /* END */
11294                   traceTaskEnd();
11295                   return tmp;
11296                }
11297           }
11298      }
11299 //
11300
11301    Evas_Object *obj = elm_legacy_add(klass, parent,
11302                          efl_ui_win_name_set(efl_added, name),
11303                          efl_ui_win_type_set(efl_added, (Efl_Ui_Win_Type)type));
11304
11305 //TIZEN_ONLY(20160628):  Add Performance log for cold booting
11306    traceTaskEnd();
11307 //
11308    return obj;
11309 }
11310
11311
11312 EAPI Evas_Object *
11313 elm_win_fake_add(Ecore_Evas *ee)
11314 {
11315    return elm_legacy_add(EFL_UI_WIN_LEGACY_CLASS, NULL,
11316                         _fake_canvas_set(efl_added, ee),
11317                         efl_ui_win_name_set(efl_added, NULL),
11318                         efl_ui_win_type_set(efl_added, EFL_UI_WIN_TYPE_FAKE));
11319 }
11320
11321 EAPI Evas_Object *
11322 elm_win_util_standard_add(const char *name, const char *title)
11323 {
11324    Evas_Object *win;
11325
11326    traceTaskStart("win_standard_add");
11327
11328    // TIZEN_ONLY(20180518): apply precreated window
11329     win = elm_win_add(NULL, name, ELM_WIN_BASIC);
11330     if (!win) return NULL;
11331
11332     efl_text_set(win, title);
11333    /*
11334    win = elm_legacy_add(EFL_UI_WIN_LEGACY_CLASS, NULL,
11335                         efl_text_set(efl_added, title),
11336                         efl_ui_win_name_set(efl_added, name),
11337                         efl_ui_win_type_set(efl_added, EFL_UI_WIN_TYPE_BASIC));
11338    if (!win) return NULL;
11339    *//////
11340
11341    _elm_win_standard_init(win);
11342
11343    traceTaskEnd();
11344
11345    return win;
11346 }
11347
11348 EAPI Evas_Object *
11349 elm_win_util_dialog_add(Evas_Object *parent, const char *name, const char *title)
11350 {
11351    Evas_Object *win;
11352
11353    win = elm_legacy_add(EFL_UI_WIN_LEGACY_CLASS, parent,
11354                         efl_text_set(efl_added, title),
11355                         efl_ui_win_name_set(efl_added, name),
11356                         efl_ui_win_type_set(efl_added, EFL_UI_WIN_TYPE_DIALOG_BASIC));
11357    if (!win) return NULL;
11358
11359    _elm_win_standard_init(win);
11360    return win;
11361 }
11362
11363
11364 EAPI void
11365 elm_win_keyboard_mode_set(Evas_Object *obj, Elm_Win_Keyboard_Mode mode)
11366 {
11367    efl_ui_win_keyboard_mode_set(obj, (Efl_Ui_Win_Keyboard_Mode)mode);
11368 }
11369
11370 EAPI Elm_Win_Keyboard_Mode
11371 elm_win_keyboard_mode_get(const Evas_Object *obj)
11372 {
11373    return (Elm_Win_Keyboard_Mode)efl_ui_win_keyboard_mode_get(obj);
11374 }
11375
11376 EAPI void
11377 elm_win_screen_constrain_set(Evas_Object *obj, Eina_Bool constrain)
11378 {
11379    efl_ui_win_screen_constrain_set(obj, constrain);
11380 }
11381
11382 EAPI Eina_Bool
11383 elm_win_screen_constrain_get(const Evas_Object *obj)
11384 {
11385    return efl_ui_win_screen_constrain_get(obj);
11386 }
11387
11388 EAPI void
11389 elm_win_prop_focus_skip_set(Evas_Object *obj, Eina_Bool skip)
11390 {
11391    efl_ui_win_prop_focus_skip_set(obj, skip);
11392 }
11393
11394 EAPI void
11395 elm_win_autohide_set(Evas_Object *obj, Eina_Bool autohide)
11396 {
11397    efl_ui_win_autohide_set(obj, autohide);
11398 }
11399
11400 EAPI Eina_Bool
11401 elm_win_autohide_get(const Evas_Object *obj)
11402 {
11403    return efl_ui_win_autohide_get(obj);
11404 }
11405
11406 EAPI void
11407 elm_win_exit_on_close_set(Evas_Object *obj, const Eina_Value *exit_code)
11408 {
11409    efl_ui_win_exit_on_close_set(obj, exit_code);
11410 }
11411
11412 EAPI const Eina_Value *
11413 elm_win_exit_on_close_get(const Evas_Object *obj)
11414 {
11415    return efl_ui_win_exit_on_close_get(obj);
11416 }
11417
11418 EAPI void
11419 elm_win_icon_object_set(Evas_Object *obj, Evas_Object *icon)
11420 {
11421    efl_ui_win_icon_object_set(obj, icon);
11422 }
11423
11424 EAPI const Evas_Object *
11425 elm_win_icon_object_get(const Evas_Object *obj)
11426 {
11427    return efl_ui_win_icon_object_get(obj);
11428 }
11429
11430 EAPI void
11431 elm_win_iconified_set(Evas_Object *obj, Eina_Bool iconified)
11432 {
11433    efl_ui_win_minimized_set(obj, iconified);
11434 }
11435
11436 EAPI Eina_Bool
11437 elm_win_iconified_get(const Evas_Object *obj)
11438 {
11439    return efl_ui_win_minimized_get(obj);
11440 }
11441
11442 EAPI void
11443 elm_win_maximized_set(Evas_Object *obj, Eina_Bool maximized)
11444 {
11445    efl_ui_win_maximized_set(obj, maximized);
11446 }
11447
11448 EAPI Eina_Bool
11449 elm_win_maximized_get(const Evas_Object *obj)
11450 {
11451    return efl_ui_win_maximized_get(obj);
11452 }
11453
11454 EAPI void
11455 elm_win_fullscreen_set(Evas_Object *obj, Eina_Bool fullscreen)
11456 {
11457    efl_ui_win_fullscreen_set(obj, fullscreen);
11458 }
11459
11460 EAPI Eina_Bool
11461 elm_win_fullscreen_get(const Evas_Object *obj)
11462 {
11463    return efl_ui_win_fullscreen_get(obj);
11464 }
11465
11466 EAPI void
11467 elm_win_sticky_set(Evas_Object *obj, Eina_Bool sticky)
11468 {
11469    efl_ui_win_sticky_set(obj, sticky);
11470 }
11471
11472 EAPI Eina_Bool
11473 elm_win_sticky_get(const Evas_Object *obj)
11474 {
11475    return efl_ui_win_sticky_get(obj);
11476 }
11477
11478 EAPI void
11479 elm_win_noblank_set(Evas_Object *obj, Eina_Bool noblank)
11480 {
11481    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
11482    EINA_SAFETY_ON_NULL_RETURN(sd);
11483    noblank = !!noblank;
11484    if (sd->noblank == noblank) return;
11485    sd->noblank = noblank;
11486    _win_noblank_eval();
11487 }
11488
11489 EAPI Eina_Bool
11490 elm_win_noblank_get(const Evas_Object *obj)
11491 {
11492    Efl_Ui_Win_Data *sd = efl_data_scope_safe_get(obj, MY_CLASS);
11493    EINA_SAFETY_ON_NULL_RETURN_VAL(sd, EINA_FALSE);
11494    return sd->noblank;
11495 }
11496
11497 EAPI void
11498 elm_win_borderless_set(Evas_Object *obj, Eina_Bool borderless)
11499 {
11500    efl_ui_win_borderless_set(obj, borderless);
11501 }
11502
11503 EAPI Eina_Bool
11504 elm_win_borderless_get(const Evas_Object *obj)
11505 {
11506    return efl_ui_win_borderless_get(obj);
11507 }
11508
11509 EAPI void
11510 elm_win_role_set(Evas_Object *obj, const char *role)
11511 {
11512    efl_ui_win_role_set(obj, role);
11513 }
11514
11515 EAPI const char *
11516 elm_win_role_get(const Evas_Object *obj)
11517 {
11518    return efl_ui_win_role_get(obj);
11519 }
11520
11521 EAPI const char *
11522 elm_win_name_get(const Evas_Object *obj)
11523 {
11524    return efl_ui_win_name_get(obj);
11525 }
11526
11527 EAPI Elm_Win_Type
11528 elm_win_type_get(const Evas_Object *obj)
11529 {
11530    if (!(efl_isa(obj, EFL_UI_WIN_CLASS) ||
11531          efl_isa(obj, EFL_UI_WIN_LEGACY_CLASS) ||
11532          efl_isa(obj, EFL_UI_WIN_INLINED_CLASS))) return ELM_WIN_UNKNOWN;
11533
11534    return _efl_ui_win_type_to_elm_win_type(efl_ui_win_type_get(obj));
11535 }
11536
11537 EAPI const char *
11538 elm_win_accel_preference_get(const Evas_Object *obj)
11539 {
11540    return efl_ui_win_accel_preference_get(obj);
11541 }
11542
11543 EAPI void
11544 elm_win_alpha_set(Evas_Object *obj, Eina_Bool alpha)
11545 {
11546    efl_ui_win_alpha_set(obj, alpha);
11547 }
11548
11549 EAPI Eina_Bool
11550 elm_win_alpha_get(const Evas_Object *obj)
11551 {
11552    return efl_ui_win_alpha_get(obj);
11553 }
11554
11555 EAPI void
11556 elm_win_activate(Evas_Object *obj)
11557 {
11558    efl_ui_win_activate(obj);
11559 }
11560
11561 EAPI void
11562 elm_win_center(Evas_Object *obj, Eina_Bool h, Eina_Bool v)
11563 {
11564    efl_ui_win_center(obj, h, v);
11565 }
11566
11567 EAPI Eina_Bool
11568 elm_win_move_resize_start(Evas_Object *obj, Elm_Win_Move_Resize_Mode mode)
11569 {
11570    return efl_ui_win_move_resize_start(obj, (Efl_Ui_Win_Move_Resize_Mode)mode);
11571 }
11572
11573 EAPI void
11574 elm_win_focus_highlight_animate_set(Efl_Ui_Win *obj, Eina_Bool animate)
11575 {
11576    efl_ui_win_focus_highlight_animate_set(obj, animate);
11577 }
11578
11579 EAPI Eina_Bool
11580 elm_win_focus_highlight_animate_get(const Efl_Ui_Win *obj)
11581 {
11582    return efl_ui_win_focus_highlight_animate_get(obj);
11583 }
11584
11585 EAPI void
11586 elm_win_focus_highlight_enabled_set(Efl_Ui_Win *obj, Eina_Bool enabled)
11587 {
11588    efl_ui_win_focus_highlight_enabled_set(obj, enabled);
11589 }
11590
11591 EAPI Eina_Bool
11592 elm_win_focus_highlight_enabled_get(const Efl_Ui_Win *obj)
11593 {
11594    return efl_ui_win_focus_highlight_enabled_get(obj);
11595 }
11596
11597 EAPI Eina_Bool
11598 elm_win_focus_highlight_style_set(Efl_Ui_Win *obj, const char *style)
11599 {
11600    return efl_ui_win_focus_highlight_style_set(obj, style);
11601 }
11602
11603 EAPI const char *
11604 elm_win_focus_highlight_style_get(const Efl_Ui_Win *obj)
11605 {
11606    return efl_ui_win_focus_highlight_style_get(obj);
11607 }
11608
11609 EAPI Efl_Ui_Shared_Win_Data*
11610 efl_ui_win_shared_data_get(Efl_Ui_Win *obj)
11611 {
11612    Efl_Ui_Win_Data *pd = efl_data_scope_safe_get(obj, MY_CLASS);
11613    EINA_SAFETY_ON_NULL_RETURN_VAL(pd, NULL);
11614
11615    return &pd->spd;
11616 }
11617
11618 EAPI void
11619 efl_ui_win_autodel_set(Efl_Ui_Win *obj, Eina_Bool autodel)
11620 {
11621    elm_win_autodel_set(obj, autodel);
11622 }
11623
11624 EAPI Eina_Bool
11625 efl_ui_win_autodel_get(const Efl_Ui_Win *obj)
11626 {
11627    return elm_win_autodel_get(obj);
11628 }