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