2 # include "elementary_config.h"
5 #include <Elementary.h>
6 #include <Elementary_Cursor.h>
9 #include "elm_widget_menu.h"
11 #define MY_CLASS ELM_OBJ_WIN_CLASS
13 #define MY_CLASS_NAME "Elm_Win"
14 #define MY_CLASS_NAME_LEGACY "elm_win"
16 static const Elm_Win_Trap *trap = NULL;
18 #define TRAP(sd, name, ...) \
21 if ((!trap) || (!trap->name) || \
23 (trap->name(sd->trap_data, sd->obj, ## __VA_ARGS__)))) \
24 ecore_evas_##name(sd->ee, ##__VA_ARGS__); \
28 #define ELM_WIN_DATA_GET(o, sd) \
29 Elm_Win_Data * sd = eo_data_scope_get(o, MY_CLASS)
31 #define ELM_WIN_DATA_GET_OR_RETURN(o, ptr) \
32 ELM_WIN_DATA_GET(o, ptr); \
35 CRI("No widget data for object %p (%s)", \
36 o, evas_object_type_get(o)); \
40 #define ELM_WIN_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
41 ELM_WIN_DATA_GET(o, ptr); \
44 CRI("No widget data for object %p (%s)", \
45 o, evas_object_type_get(o)); \
49 #define ELM_WIN_CHECK(obj) \
50 if (!obj || !eo_isa(obj, MY_CLASS)) \
53 #define DECREMENT_MODALITY() \
54 EINA_LIST_FOREACH(_elm_win_list, l, current) \
56 ELM_WIN_DATA_GET_OR_RETURN(current, cursd); \
57 if ((obj != current) && (cursd->modal_count > 0)) \
59 cursd->modal_count--; \
61 if (cursd->modal_count == 0) \
63 edje_object_signal_emit(cursd->layout, \
64 "elm,action,hide_blocker", "elm"); \
65 evas_object_smart_callback_call(cursd->main_menu, \
66 "elm,action,unblock_menu", NULL); \
70 #define INCREMENT_MODALITY() \
71 EINA_LIST_FOREACH(_elm_win_list, l, current) \
73 ELM_WIN_DATA_GET_OR_RETURN(current, cursd); \
76 cursd->modal_count++; \
78 if (cursd->modal_count > 0) \
80 edje_object_signal_emit(cursd->layout, \
81 "elm,action,show_blocker", "elm"); \
82 evas_object_smart_callback_call(cursd->main_menu, \
83 "elm,action,block_menu", NULL); \
87 #define ENGINE_GET() (_elm_preferred_engine ? _elm_preferred_engine : (_elm_config->engine ? _elm_config->engine : ""))
88 #define ENGINE_COMPARE(name) (!strcmp(ENGINE_GET(), name))
90 typedef struct _Elm_Win_Data Elm_Win_Data;
96 Evas_Object *parent; /* parent *window* object*/
97 Evas_Object *img_obj, *frame_obj;
98 Evas_Object *client_obj; /* rect representing the client */
99 Evas_Object *spacer_obj;
102 Evas_Object *obj; /* The object itself */
103 #ifdef HAVE_ELEMENTARY_X
107 Ecore_Event_Handler *client_message_handler;
108 Ecore_Event_Handler *property_handler;
111 #ifdef HAVE_ELEMENTARY_WAYLAND
114 Ecore_Wl_Window *win;
118 Ecore_Job *deferred_resize_job;
119 Ecore_Job *deferred_child_eval_job;
122 Elm_Win_Keyboard_Mode kbdmode;
123 Elm_Win_Indicator_Mode indmode;
124 Elm_Win_Indicator_Opacity_Mode ind_o_mode;
133 int *autodel_clear, rot;
142 Evas_Object *obj, *hot_obj;
147 Evas_Object *fobj; /* focus highlight edje object */
152 Eina_Bool visible : 1;
153 Eina_Bool in_theme: 1; /**< focus highlight is handled by theme.
154 this is set true if edc data item "focus_highlight" is set to "on" during focus in callback. */
158 Ecore_Job *reconf_job;
160 Eina_Bool enabled : 1;
161 Eina_Bool theme_changed : 1; /* set true when the focus theme is changed */
162 Eina_Bool animate : 1; /* set true when the focus highlight animate is enabled */
163 Eina_Bool animate_supported : 1; /* set true when the focus highlight animate is supported by theme */
164 Eina_Bool geometry_changed : 1;
169 const char *icon_name;
172 Evas_Object *main_menu;
177 const char **available_list;
182 int preferred_rot; /* indicates preferred rotation value, -1 means invalid. */
183 int *rots; /* indicates available rotations */
184 unsigned int count; /* number of elements in available rotations */
185 Eina_Bool wm_supported : 1; /* set true when the window manager support window rotation */
186 Eina_Bool use : 1; /* set ture when application use window manager rotation. */
192 int size_base_w, size_base_h;
193 int size_step_w, size_step_h;
196 Eina_Bool urgent : 1;
198 Eina_Bool demand_attention : 1;
199 Eina_Bool autodel : 1;
200 Eina_Bool constrain : 1;
201 Eina_Bool resizing : 1;
202 Eina_Bool iconified : 1;
203 Eina_Bool withdrawn : 1;
204 Eina_Bool sticky : 1;
205 Eina_Bool fullscreen : 1;
206 Eina_Bool maximized : 1;
207 Eina_Bool skip_focus : 1;
208 Eina_Bool floating : 1;
211 static const char SIG_DELETE_REQUEST[] = "delete,request";
212 static const char SIG_FOCUS_OUT[] = "focus,out"; // deprecated. use "focused" instead.
213 static const char SIG_FOCUS_IN[] = "focus,in"; // deprecated. use "unfocused" instead.
214 static const char SIG_MOVED[] = "moved";
215 static const char SIG_WITHDRAWN[] = "withdrawn";
216 static const char SIG_ICONIFIED[] = "iconified";
217 static const char SIG_NORMAL[] = "normal";
218 static const char SIG_STICK[] = "stick";
219 static const char SIG_UNSTICK[] = "unstick";
220 static const char SIG_FULLSCREEN[] = "fullscreen";
221 static const char SIG_UNFULLSCREEN[] = "unfullscreen";
222 static const char SIG_MAXIMIZED[] = "maximized";
223 static const char SIG_UNMAXIMIZED[] = "unmaximized";
224 static const char SIG_IOERR[] = "ioerr";
225 static const char SIG_INDICATOR_PROP_CHANGED[] = "indicator,prop,changed";
226 static const char SIG_ROTATION_CHANGED[] = "rotation,changed";
227 static const char SIG_PROFILE_CHANGED[] = "profile,changed";
228 static const char SIG_FOCUSED[] = "focused";
229 static const char SIG_UNFOCUSED[] = "unfocused";
230 static const char SIG_WM_ROTATION_CHANGED[] = "wm,rotation,changed";
232 static const Evas_Smart_Cb_Description _smart_callbacks[] = {
233 {SIG_DELETE_REQUEST, ""},
242 {SIG_FULLSCREEN, ""},
243 {SIG_UNFULLSCREEN, ""},
245 {SIG_UNMAXIMIZED, ""},
247 {SIG_INDICATOR_PROP_CHANGED, ""},
248 {SIG_ROTATION_CHANGED, ""},
249 {SIG_PROFILE_CHANGED, ""},
252 {SIG_WM_ROTATION_CHANGED, ""},
256 Eina_List *_elm_win_list = NULL;
257 int _elm_win_deferred_free = 0;
259 static int _elm_win_count = 0;
261 static Eina_Bool _elm_win_auto_throttled = EINA_FALSE;
263 static Ecore_Job *_elm_win_state_eval_job = NULL;
266 _elm_win_on_resize_obj_changed_size_hints(void *data,
271 _elm_win_img_callbacks_del(Evas_Object *obj, Evas_Object *imgobj);
273 #ifdef HAVE_ELEMENTARY_X
274 static void _elm_win_xwin_update(Elm_Win_Data *sd);
277 EAPI double _elm_startup_time = 0;
280 _elm_win_first_frame_do(void *data, Evas *e EINA_UNUSED, void *event_info EINA_UNUSED)
282 double end = ecore_time_unix_get();
290 case 'T': fprintf(stderr, "Startup time: '%f' - '%f' = '%f' sec\n", end, _elm_startup_time, end - _elm_startup_time);
294 evas_event_callback_del_full(e, EVAS_CALLBACK_RENDER_POST, _elm_win_first_frame_do, data);
298 _elm_win_state_eval(void *data EINA_UNUSED)
302 int _elm_win_count_shown = 0;
303 int _elm_win_count_iconified = 0;
304 int _elm_win_count_withdrawn = 0;
306 _elm_win_state_eval_job = NULL;
308 if (_elm_config->auto_norender_withdrawn)
310 EINA_LIST_FOREACH(_elm_win_list, l, obj)
312 if ((elm_win_withdrawn_get(obj)) ||
313 ((elm_win_iconified_get(obj) &&
314 (_elm_config->auto_norender_iconified_same_as_withdrawn))))
316 if (!evas_object_data_get(obj, "__win_auto_norender"))
318 Evas *evas = evas_object_evas_get(obj);
320 elm_win_norender_push(obj);
321 evas_object_data_set(obj, "__win_auto_norender", obj);
323 if (_elm_config->auto_flush_withdrawn)
325 edje_file_cache_flush();
326 edje_collection_cache_flush();
327 evas_image_cache_flush(evas);
328 evas_font_cache_flush(evas);
330 if (_elm_config->auto_dump_withdrawn)
332 evas_render_dump(evas);
338 if (evas_object_data_get(obj, "__win_auto_norender"))
340 elm_win_norender_pop(obj);
341 evas_object_data_del(obj, "__win_auto_norender");
346 if (((_elm_config->auto_throttle) &&
347 (elm_policy_get(ELM_POLICY_THROTTLE) != ELM_POLICY_THROTTLE_NEVER)) ||
348 (elm_policy_get(ELM_POLICY_THROTTLE) == ELM_POLICY_THROTTLE_HIDDEN_ALWAYS))
350 if (_elm_win_count == 0)
352 if (_elm_win_auto_throttled)
354 ecore_throttle_adjust(-_elm_config->auto_throttle_amount);
355 _elm_win_auto_throttled = EINA_FALSE;
360 EINA_LIST_FOREACH(_elm_win_list, l, obj)
362 if (elm_win_withdrawn_get(obj))
363 _elm_win_count_withdrawn++;
364 else if (elm_win_iconified_get(obj))
365 _elm_win_count_iconified++;
366 else if (evas_object_visible_get(obj))
367 _elm_win_count_shown++;
369 if (_elm_win_count_shown <= 0)
371 if (!_elm_win_auto_throttled)
373 ecore_throttle_adjust(_elm_config->auto_throttle_amount);
374 _elm_win_auto_throttled = EINA_TRUE;
379 if (_elm_win_auto_throttled)
381 ecore_throttle_adjust(-_elm_config->auto_throttle_amount);
382 _elm_win_auto_throttled = EINA_FALSE;
390 _elm_win_state_eval_queue(void)
392 ecore_job_del(_elm_win_state_eval_job);
393 _elm_win_state_eval_job = ecore_job_add(_elm_win_state_eval, NULL);
396 // example shot spec (wait 0.1 sec then save as my-window.png):
397 // ELM_ENGINE="shot:delay=0.1:file=my-window.png"
400 _shot_delay_get(Elm_Win_Data *sd)
403 char *d = strdup(sd->shot.info);
406 for (p = (char *)sd->shot.info; *p; p++)
408 if (!strncmp(p, "delay=", 6))
412 for (pd = d, p += 6; (*p) && (*p != ':'); p++, pd++)
428 _shot_file_get(Elm_Win_Data *sd)
431 char *tmp = strdup(sd->shot.info);
432 char *repname = NULL;
434 if (!tmp) return NULL;
436 for (p = (char *)sd->shot.info; *p; p++)
438 if (!strncmp(p, "file=", 5))
441 if (!sd->shot.repeat_count) return tmp;
444 char *dotptr = strrchr(tmp, '.');
447 size_t size = sizeof(char) * (strlen(tmp) + 16);
448 repname = malloc(size);
449 strncpy(repname, tmp, dotptr - tmp);
450 snprintf(repname + (dotptr - tmp), size -
451 (dotptr - tmp), "%03i",
452 sd->shot.shot_counter + 1);
453 strcat(repname, dotptr);
461 if (!sd->shot.repeat_count) return strdup("out.png");
463 repname = malloc(sizeof(char) * 24);
464 snprintf(repname, sizeof(char) * 24, "out%03i.png",
465 sd->shot.shot_counter + 1);
471 _shot_repeat_count_get(Elm_Win_Data *sd)
474 char *d = strdup(sd->shot.info);
477 for (p = (char *)sd->shot.info; *p; p++)
479 if (!strncmp(p, "repeat=", 7))
483 for (pd = d, p += 7; (*p) && (*p != ':'); p++, pd++)
490 if (v > 1000) v = 999;
501 _shot_key_get(Elm_Win_Data *sd EINA_UNUSED)
507 _shot_flags_get(Elm_Win_Data *sd EINA_UNUSED)
513 _shot_do(Elm_Win_Data *sd)
517 unsigned int *pixels;
519 char *file, *key, *flags;
521 ecore_evas_manual_render(sd->ee);
522 pixels = (void *)ecore_evas_buffer_pixels_get(sd->ee);
525 ecore_evas_geometry_get(sd->ee, NULL, NULL, &w, &h);
526 if ((w < 1) || (h < 1)) return;
528 file = _shot_file_get(sd);
531 key = _shot_key_get(sd);
532 flags = _shot_flags_get(sd);
533 ee = ecore_evas_buffer_new(1, 1);
534 o = evas_object_image_add(ecore_evas_get(ee));
535 evas_object_image_alpha_set(o, ecore_evas_alpha_get(sd->ee));
536 evas_object_image_size_set(o, w, h);
537 evas_object_image_data_set(o, pixels);
538 if (!evas_object_image_save(o, file, key, flags))
540 ERR("Cannot save window to '%s' (key '%s', flags '%s')",
547 if (sd->shot.repeat_count) sd->shot.shot_counter++;
551 _shot_delay(void *data)
553 ELM_WIN_DATA_GET(data, sd);
556 if (sd->shot.repeat_count)
558 int remainshot = (sd->shot.repeat_count - sd->shot.shot_counter);
559 if (remainshot > 0) return EINA_TRUE;
561 sd->shot.timer = NULL;
568 _shot_init(Elm_Win_Data *sd)
570 if (!sd->shot.info) return;
572 sd->shot.repeat_count = _shot_repeat_count_get(sd);
573 sd->shot.shot_counter = 0;
577 _shot_handle(Elm_Win_Data *sd)
579 if (!sd->shot.info) return;
582 sd->shot.timer = ecore_timer_add(_shot_delay_get(sd), _shot_delay,
586 /* elm-win specific associate, does the trap while ecore_evas_object_associate()
589 static Elm_Win_Data *
590 _elm_win_associate_get(const Ecore_Evas *ee)
592 Evas_Object *obj = ecore_evas_data_get(ee, "elm_win");
593 if (!obj) return NULL;
594 ELM_WIN_DATA_GET(obj, sd);
598 /* Interceptors Callbacks */
600 _elm_win_obj_intercept_raise(void *data, Evas_Object *obj EINA_UNUSED)
602 ELM_WIN_DATA_GET(data, sd);
607 _elm_win_obj_intercept_lower(void *data, Evas_Object *obj EINA_UNUSED)
609 ELM_WIN_DATA_GET(data, sd);
614 _elm_win_obj_intercept_stack_above(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, Evas_Object *above EINA_UNUSED)
616 INF("TODO: %s", __FUNCTION__);
620 _elm_win_obj_intercept_stack_below(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, Evas_Object *below EINA_UNUSED)
622 INF("TODO: %s", __FUNCTION__);
626 _elm_win_obj_intercept_layer_set(void *data, Evas_Object *obj EINA_UNUSED, int l)
628 ELM_WIN_DATA_GET(data, sd);
629 TRAP(sd, layer_set, l);
632 /* Event Callbacks */
635 _elm_win_obj_callback_changed_size_hints(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
637 ELM_WIN_DATA_GET(data, sd);
640 evas_object_size_hint_min_get(obj, &w, &h);
641 TRAP(sd, size_min_set, w, h);
643 evas_object_size_hint_max_get(obj, &w, &h);
646 TRAP(sd, size_max_set, w, h);
648 /* end of elm-win specific associate */
651 _elm_win_move(Ecore_Evas *ee)
653 Elm_Win_Data *sd = _elm_win_associate_get(ee);
658 ecore_evas_geometry_get(ee, &x, &y, NULL, NULL);
661 evas_object_smart_callback_call(sd->obj, SIG_MOVED, NULL);
662 evas_nochange_push(evas_object_evas_get(sd->obj));
663 evas_object_move(sd->obj, x, y);
664 evas_nochange_pop(evas_object_evas_get(sd->obj));
668 _elm_win_resize_job(void *data)
670 ELM_WIN_DATA_GET(data, sd);
673 sd->deferred_resize_job = NULL;
674 ecore_evas_request_geometry_get(sd->ee, NULL, NULL, &w, &h);
678 ecore_evas_screen_geometry_get(sd->ee, NULL, NULL, &sw, &sh);
687 evas_output_framespace_get(sd->evas, &fx, &fy, &fw, &fh);
688 evas_object_move(sd->frame_obj, -fx, -fy);
689 evas_object_resize(sd->frame_obj, w + fw, h + fh);
692 evas_object_resize(sd->obj, w, h);
693 evas_object_resize(sd->layout, w, h);
697 _elm_win_resize(Ecore_Evas *ee)
699 Elm_Win_Data *sd = _elm_win_associate_get(ee);
702 ecore_job_del(sd->deferred_resize_job);
703 sd->deferred_resize_job = ecore_job_add(_elm_win_resize_job, sd->obj);
707 _elm_win_mouse_in(Ecore_Evas *ee)
709 Elm_Win_Data *sd = _elm_win_associate_get(ee);
712 if (sd->resizing) sd->resizing = EINA_FALSE;
716 _elm_win_focus_highlight_reconfigure_job_stop(Elm_Win_Data *sd)
718 ELM_SAFE_FREE(sd->focus_highlight.reconf_job, ecore_job_del);
722 _elm_win_focus_highlight_visible_set(Elm_Win_Data *sd,
725 Evas_Object *fobj = sd->focus_highlight.fobj;
730 evas_object_show(fobj);
731 edje_object_signal_emit(fobj, "elm,action,focus,show", "elm");
735 edje_object_signal_emit(fobj, "elm,action,focus,hide", "elm");
740 _elm_win_focus_highlight_anim_setup(Elm_Win_Data *sd,
743 Evas_Coord tx, ty, tw, th;
744 Evas_Coord px, py, pw, ph;
745 Edje_Message_Int_Set *m;
746 Evas_Object *target = sd->focus_highlight.cur.target;
748 evas_object_geometry_get(obj, &px, &py, &pw, &ph);
749 elm_widget_focus_highlight_geometry_get(target, &tx, &ty, &tw, &th, EINA_TRUE);
750 evas_object_move(obj, tx, ty);
751 evas_object_resize(obj, tw, th);
753 if ((px == tx) && (py == ty) && (pw == tw) && (ph == th)) return;
755 if (!_elm_config->focus_highlight_clip_disable)
756 evas_object_clip_unset(obj);
758 m = alloca(sizeof(*m) + (sizeof(int) * 8));
768 edje_object_message_send(obj, EDJE_MESSAGE_INT_SET, 1, m);
772 _elm_win_focus_highlight_simple_setup(Elm_Win_Data *sd,
775 Evas_Object *clip, *target = sd->focus_highlight.cur.target;
776 Evas_Coord x, y, w, h;
778 elm_widget_focus_highlight_geometry_get(target, &x, &y, &w, &h, EINA_TRUE);
780 evas_object_move(obj, x, y);
781 evas_object_resize(obj, w, h);
783 if (!_elm_config->focus_highlight_clip_disable)
785 clip = evas_object_clip_get(target);
786 if (clip) evas_object_clip_set(obj, clip);
789 edje_object_signal_emit(obj, "elm,state,anim,stop", "elm");
793 _elm_win_focus_highlight_reconfigure_job(void *data)
795 ELM_WIN_DATA_GET(data, sd);
796 Evas_Object *target = sd->focus_highlight.cur.target;
797 Evas_Object *previous = sd->focus_highlight.prev.target;
798 Evas_Object *fobj = sd->focus_highlight.fobj;
799 Eina_Bool visible_changed;
800 Eina_Bool common_visible;
801 const char *sig = NULL;
802 const char *focus_style_target = NULL;
803 const char *focus_style_previous = NULL;
805 _elm_win_focus_highlight_reconfigure_job_stop(sd);
807 visible_changed = (sd->focus_highlight.cur.visible !=
808 sd->focus_highlight.prev.visible);
810 if ((target == previous) && (!visible_changed) &&
811 (!sd->focus_highlight.geometry_changed) &&
812 (!sd->focus_highlight.theme_changed))
815 if ((previous) && (sd->focus_highlight.prev.in_theme))
816 elm_widget_signal_emit
817 (previous, "elm,action,focus_highlight,hide", "elm");
820 common_visible = EINA_FALSE;
821 else if (sd->focus_highlight.cur.in_theme)
823 common_visible = EINA_FALSE;
824 if (sd->focus_highlight.cur.visible)
825 sig = "elm,action,focus_highlight,show";
827 sig = "elm,action,focus_highlight,hide";
830 common_visible = sd->focus_highlight.cur.visible;
833 elm_widget_signal_emit(target, sig, "elm");
835 if ((!target) || (!common_visible) || (sd->focus_highlight.cur.in_theme))
839 focus_style_previous = elm_widget_focus_highlight_style_get(previous);
840 focus_style_target = elm_widget_focus_highlight_style_get(target);
842 if (sd->focus_highlight.theme_changed ||
843 (focus_style_target != focus_style_previous))
847 if (focus_style_target)
848 str = focus_style_target;
849 else if (sd->focus_highlight.style)
850 str = sd->focus_highlight.style;
854 elm_widget_theme_object_set
855 (sd->obj, fobj, "focus_highlight", "top", str);
856 sd->focus_highlight.theme_changed = EINA_FALSE;
858 if (sd->focus_highlight.animate)
860 str = edje_object_data_get(sd->focus_highlight.fobj, "animate");
861 sd->focus_highlight.animate_supported = ((str) && (!strcmp(str, "on")));
864 sd->focus_highlight.animate_supported = EINA_FALSE;
867 if ((sd->focus_highlight.animate_supported) && (previous) &&
868 (!sd->focus_highlight.prev.in_theme))
869 _elm_win_focus_highlight_anim_setup(sd, fobj);
871 _elm_win_focus_highlight_simple_setup(sd, fobj);
872 evas_object_raise(fobj);
875 _elm_win_focus_highlight_visible_set(sd, common_visible);
876 sd->focus_highlight.geometry_changed = EINA_FALSE;
877 sd->focus_highlight.prev = sd->focus_highlight.cur;
881 _elm_win_focus_highlight_reconfigure_job_start(Elm_Win_Data *sd)
883 ecore_job_del(sd->focus_highlight.reconf_job);
885 sd->focus_highlight.reconf_job = ecore_job_add(
886 _elm_win_focus_highlight_reconfigure_job, sd->obj);
890 _elm_win_focus_in(Ecore_Evas *ee)
892 Elm_Win_Data *sd = _elm_win_associate_get(ee);
894 unsigned int order = 0;
896 if ((!sd) || (sd->modal_count)) return;
900 _elm_widget_top_win_focused_set(obj, EINA_TRUE);
901 if (!elm_widget_focus_order_get(obj)
902 || (obj == elm_widget_newest_focus_order_get(obj, &order, EINA_TRUE)))
904 elm_widget_focus_steal(obj);
907 elm_widget_focus_restore(obj);
908 evas_object_smart_callback_call(obj, SIG_FOCUS_IN, NULL);
909 evas_object_smart_callback_call(obj, SIG_FOCUSED, NULL);
910 sd->focus_highlight.cur.visible = EINA_TRUE;
911 _elm_win_focus_highlight_reconfigure_job_start(sd);
914 edje_object_signal_emit(sd->frame_obj, "elm,action,focus", "elm");
918 /* else if (sd->img_obj) */
924 _elm_win_focus_out(Ecore_Evas *ee)
926 Elm_Win_Data *sd = _elm_win_associate_get(ee);
933 elm_object_focus_set(obj, EINA_FALSE);
934 _elm_widget_top_win_focused_set(obj, EINA_FALSE);
935 evas_object_smart_callback_call(obj, SIG_FOCUS_OUT, NULL);
936 evas_object_smart_callback_call(obj, SIG_UNFOCUSED, NULL);
937 sd->focus_highlight.cur.visible = EINA_FALSE;
938 _elm_win_focus_highlight_reconfigure_job_start(sd);
941 edje_object_signal_emit(sd->frame_obj, "elm,action,unfocus", "elm");
945 _elm_access_object_highlight_disable(evas_object_evas_get(obj));
948 /* if (sd->img_obj) */
954 _elm_win_available_profiles_del(Elm_Win_Data *sd)
956 if (!sd->profile.available_list) return;
959 for (i = 0; i < sd->profile.count; i++)
960 ELM_SAFE_FREE(sd->profile.available_list[i], eina_stringshare_del);
961 sd->profile.count = 0;
962 ELM_SAFE_FREE(sd->profile.available_list, free);
966 _elm_win_profile_del(Elm_Win_Data *sd)
968 ELM_SAFE_FREE(sd->profile.name, eina_stringshare_del);
972 _internal_elm_win_profile_set(Elm_Win_Data *sd, const char *profile)
974 Eina_Bool changed = EINA_FALSE;
977 if (sd->profile.name)
979 if (strcmp(sd->profile.name, profile) != 0)
981 eina_stringshare_replace(&(sd->profile.name), profile);
987 sd->profile.name = eina_stringshare_add(profile);
992 _elm_win_profile_del(sd);
998 _elm_win_profile_update(Elm_Win_Data *sd)
1000 if (sd->profile.available_list)
1002 Eina_Bool found = EINA_FALSE;
1003 if (sd->profile.name)
1006 for (i = 0; i < sd->profile.count; i++)
1008 if (!strcmp(sd->profile.name,
1009 sd->profile.available_list[i]))
1017 /* If current profile is not present in an available profiles,
1018 * change current profile to the 1st element of an array.
1021 _internal_elm_win_profile_set(sd, sd->profile.available_list[0]);
1024 _elm_config_profile_set(sd->profile.name);
1028 Eina_List *sub, *l = NULL;
1030 sub = ecore_evas_sub_ecore_evas_list_get(sd->ee);
1031 EINA_LIST_FOREACH(sub, l, ee2)
1032 ecore_evas_window_profile_set(ee2, sd->profile.name);
1034 evas_object_smart_callback_call(sd->obj, SIG_PROFILE_CHANGED, NULL);
1038 _elm_win_state_change(Ecore_Evas *ee)
1040 Elm_Win_Data *sd = _elm_win_associate_get(ee);
1042 Eina_Bool ch_withdrawn = EINA_FALSE;
1043 Eina_Bool ch_sticky = EINA_FALSE;
1044 Eina_Bool ch_iconified = EINA_FALSE;
1045 Eina_Bool ch_fullscreen = EINA_FALSE;
1046 Eina_Bool ch_maximized = EINA_FALSE;
1047 Eina_Bool ch_profile = EINA_FALSE;
1048 Eina_Bool ch_wm_rotation = EINA_FALSE;
1049 const char *profile;
1055 if (sd->withdrawn != ecore_evas_withdrawn_get(sd->ee))
1057 sd->withdrawn = ecore_evas_withdrawn_get(sd->ee);
1058 ch_withdrawn = EINA_TRUE;
1060 if (sd->sticky != ecore_evas_sticky_get(sd->ee))
1062 sd->sticky = ecore_evas_sticky_get(sd->ee);
1063 ch_sticky = EINA_TRUE;
1065 if (sd->iconified != ecore_evas_iconified_get(sd->ee))
1067 sd->iconified = ecore_evas_iconified_get(sd->ee);
1068 ch_iconified = EINA_TRUE;
1070 if (sd->fullscreen != ecore_evas_fullscreen_get(sd->ee))
1072 sd->fullscreen = ecore_evas_fullscreen_get(sd->ee);
1073 ch_fullscreen = EINA_TRUE;
1075 if (sd->maximized != ecore_evas_maximized_get(sd->ee))
1077 sd->maximized = ecore_evas_maximized_get(sd->ee);
1078 ch_maximized = EINA_TRUE;
1081 profile = ecore_evas_window_profile_get(sd->ee);
1082 ch_profile = _internal_elm_win_profile_set(sd, profile);
1086 if (sd->rot != ecore_evas_rotation_get(sd->ee))
1088 sd->rot = ecore_evas_rotation_get(sd->ee);
1089 ch_wm_rotation = EINA_TRUE;
1093 _elm_win_state_eval_queue();
1095 if ((ch_withdrawn) || (ch_iconified))
1098 evas_object_smart_callback_call(obj, SIG_WITHDRAWN, NULL);
1099 else if (sd->iconified)
1100 evas_object_smart_callback_call(obj, SIG_ICONIFIED, NULL);
1102 evas_object_smart_callback_call(obj, SIG_NORMAL, NULL);
1107 evas_object_smart_callback_call(obj, SIG_STICK, NULL);
1109 evas_object_smart_callback_call(obj, SIG_UNSTICK, NULL);
1114 evas_object_smart_callback_call(obj, SIG_FULLSCREEN, NULL);
1116 evas_object_smart_callback_call(obj, SIG_UNFULLSCREEN, NULL);
1121 evas_object_smart_callback_call(obj, SIG_MAXIMIZED, NULL);
1123 evas_object_smart_callback_call(obj, SIG_UNMAXIMIZED, NULL);
1127 _elm_win_profile_update(sd);
1131 evas_object_size_hint_min_set(obj, -1, -1);
1132 evas_object_size_hint_max_set(obj, -1, -1);
1133 #ifdef HAVE_ELEMENTARY_X
1134 _elm_win_xwin_update(sd);
1136 elm_widget_orientation_set(obj, sd->rot);
1137 evas_object_smart_callback_call(obj, SIG_ROTATION_CHANGED, NULL);
1138 evas_object_smart_callback_call(obj, SIG_WM_ROTATION_CHANGED, NULL);
1142 EOLIAN static Eina_Bool
1143 _elm_win_elm_widget_focus_next_manager_is(Eo *obj EINA_UNUSED, Elm_Win_Data *_pd EINA_UNUSED)
1148 EOLIAN static Eina_Bool
1149 _elm_win_elm_widget_focus_next(Eo *obj, Elm_Win_Data *_pd EINA_UNUSED, Elm_Focus_Direction dir, Evas_Object **next)
1151 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
1153 const Eina_List *items;
1154 void *(*list_data_get)(const Eina_List *list);
1159 if (!(items = elm_widget_focus_custom_chain_get(obj)))
1161 items = wd->subobjs;
1165 list_data_get = eina_list_data_get;
1167 elm_widget_focus_list_next_get(obj, items, list_data_get, dir, next);
1169 if (*next) return EINA_TRUE;
1171 *next = (Evas_Object *)obj;
1175 EOLIAN static Eina_Bool
1176 _elm_win_elm_widget_focus_direction_manager_is(Eo *obj EINA_UNUSED, Elm_Win_Data *_pd EINA_UNUSED)
1181 EOLIAN static Eina_Bool
1182 _elm_win_elm_widget_focus_direction(Eo *obj, Elm_Win_Data *_pd EINA_UNUSED, const Evas_Object *base, double degree, Evas_Object **direction, double *weight)
1184 const Eina_List *items;
1185 void *(*list_data_get)(const Eina_List *list);
1187 ELM_WIDGET_DATA_GET_OR_RETURN(obj, wd, EINA_FALSE);
1192 if (!(items = elm_widget_focus_custom_chain_get(obj)))
1193 items = wd->subobjs;
1195 list_data_get = eina_list_data_get;
1197 return elm_widget_focus_list_direction_get
1198 (obj, base, items, list_data_get, degree, direction, weight);
1204 EOLIAN static Eina_Bool
1205 _elm_win_elm_widget_on_focus(Eo *obj, Elm_Win_Data *sd)
1207 Eina_Bool int_ret = EINA_FALSE;
1208 eo_do_super(obj, MY_CLASS, int_ret = elm_obj_widget_on_focus());
1209 if (!int_ret) return EINA_TRUE;
1212 evas_object_focus_set(sd->img_obj, elm_widget_focus_get(obj));
1214 evas_object_focus_set(obj, elm_widget_focus_get(obj));
1219 EOLIAN static Eina_Bool
1220 _elm_win_elm_widget_event(Eo *obj, Elm_Win_Data *_pd EINA_UNUSED, Evas_Object *src, Evas_Callback_Type type, void *event_info)
1223 Evas_Event_Key_Down *ev = event_info;
1225 if (elm_widget_disabled_get(obj)) return EINA_FALSE;
1226 if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE;
1228 if ((!strcmp(ev->key, "Tab")) ||
1229 (!strcmp(ev->key, "ISO_Left_Tab")))
1231 if (evas_key_modifier_is_set(ev->modifiers, "Control") ||
1232 evas_key_modifier_is_set(ev->modifiers, "Alt"))
1234 if (evas_key_modifier_is_set(ev->modifiers, "Shift"))
1235 elm_widget_focus_cycle(obj, ELM_FOCUS_PREVIOUS);
1237 elm_widget_focus_cycle(obj, ELM_FOCUS_NEXT);
1241 else if ((!strcmp(ev->key, "Left")) ||
1242 ((!strcmp(ev->key, "KP_Left")) && (!ev->string)))
1244 elm_widget_focus_cycle(obj, ELM_FOCUS_LEFT);
1248 else if ((!strcmp(ev->key, "Right")) ||
1249 ((!strcmp(ev->key, "KP_Right")) && (!ev->string)))
1251 elm_widget_focus_cycle(obj, ELM_FOCUS_RIGHT);
1255 else if ((!strcmp(ev->key, "Up")) ||
1256 ((!strcmp(ev->key, "KP_Up")) && (!ev->string)))
1258 elm_widget_focus_cycle(obj, ELM_FOCUS_UP);
1262 else if ((!strcmp(ev->key, "Down")) ||
1263 ((!strcmp(ev->key, "KP_Down")) && (!ev->string)))
1265 elm_widget_focus_cycle(obj, ELM_FOCUS_DOWN);
1273 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1278 _deferred_ecore_evas_free(void *data)
1280 ecore_evas_free(data);
1281 _elm_win_deferred_free--;
1285 _elm_win_evas_smart_show(Eo *obj, Elm_Win_Data *sd)
1287 if (sd->modal_count) return;
1289 Evas_Object *current;
1291 if (!evas_object_visible_get(obj))
1292 _elm_win_state_eval_queue();
1293 eo_do_super(obj, MY_CLASS, evas_obj_smart_show());
1295 if ((sd->modal) && (!evas_object_visible_get(obj)))
1297 INCREMENT_MODALITY()
1302 if (sd->shot.info) _shot_handle(sd);
1306 _elm_win_evas_smart_hide(Eo *obj, Elm_Win_Data *sd)
1308 if (sd->modal_count) return;
1310 Evas_Object *current;
1312 if (evas_object_visible_get(obj))
1313 _elm_win_state_eval_queue();
1314 eo_do_super(obj, MY_CLASS, evas_obj_smart_hide());
1316 if ((sd->modal) && (evas_object_visible_get(obj)))
1318 DECREMENT_MODALITY()
1325 evas_object_hide(sd->frame_obj);
1329 evas_object_hide(sd->img_obj);
1331 if (sd->pointer.obj)
1333 evas_object_hide(sd->pointer.obj);
1334 ecore_evas_hide(sd->pointer.ee);
1339 _elm_win_on_parent_del(void *data,
1340 Evas *e EINA_UNUSED,
1342 void *event_info EINA_UNUSED)
1344 ELM_WIN_DATA_GET(data, sd);
1346 if (obj == sd->parent) sd->parent = NULL;
1350 _elm_win_focus_target_move(void *data,
1351 Evas *e EINA_UNUSED,
1352 Evas_Object *obj EINA_UNUSED,
1353 void *event_info EINA_UNUSED)
1355 ELM_WIN_DATA_GET(data, sd);
1357 sd->focus_highlight.geometry_changed = EINA_TRUE;
1358 _elm_win_focus_highlight_reconfigure_job_start(sd);
1362 _elm_win_focus_target_resize(void *data,
1363 Evas *e EINA_UNUSED,
1364 Evas_Object *obj EINA_UNUSED,
1365 void *event_info EINA_UNUSED)
1367 ELM_WIN_DATA_GET(data, sd);
1369 sd->focus_highlight.geometry_changed = EINA_TRUE;
1370 _elm_win_focus_highlight_reconfigure_job_start(sd);
1374 _elm_win_focus_target_del(void *data,
1375 Evas *e EINA_UNUSED,
1376 Evas_Object *obj EINA_UNUSED,
1377 void *event_info EINA_UNUSED)
1379 ELM_WIN_DATA_GET(data, sd);
1381 sd->focus_highlight.cur.target = NULL;
1383 _elm_win_focus_highlight_reconfigure_job_start(sd);
1386 static Evas_Object *
1387 _elm_win_focus_target_get(Evas_Object *obj)
1389 Evas_Object *o = obj;
1393 if (elm_widget_is(o))
1395 if (!elm_widget_highlight_ignore_get(o))
1397 o = elm_widget_parent_get(o);
1399 o = evas_object_smart_parent_get(o);
1403 o = elm_widget_parent_widget_get(o);
1405 o = evas_object_smart_parent_get(o);
1414 _elm_win_focus_target_callbacks_add(Elm_Win_Data *sd)
1416 Evas_Object *obj = sd->focus_highlight.cur.target;
1419 evas_object_event_callback_add
1420 (obj, EVAS_CALLBACK_MOVE, _elm_win_focus_target_move, sd->obj);
1421 evas_object_event_callback_add
1422 (obj, EVAS_CALLBACK_RESIZE, _elm_win_focus_target_resize, sd->obj);
1423 evas_object_event_callback_add
1424 (obj, EVAS_CALLBACK_DEL, _elm_win_focus_target_del, sd->obj);
1428 _elm_win_focus_target_callbacks_del(Elm_Win_Data *sd)
1430 Evas_Object *obj = sd->focus_highlight.cur.target;
1432 evas_object_event_callback_del_full
1433 (obj, EVAS_CALLBACK_MOVE, _elm_win_focus_target_move, sd->obj);
1434 evas_object_event_callback_del_full
1435 (obj, EVAS_CALLBACK_RESIZE, _elm_win_focus_target_resize, sd->obj);
1436 evas_object_event_callback_del_full
1437 (obj, EVAS_CALLBACK_DEL, _elm_win_focus_target_del, sd->obj);
1441 _elm_win_object_focus_in(void *data,
1442 Evas *e EINA_UNUSED,
1445 Evas_Object *obj = event_info, *target;
1446 ELM_WIN_DATA_GET(data, sd);
1448 if (sd->focus_highlight.cur.target == obj)
1451 target = _elm_win_focus_target_get(obj);
1452 sd->focus_highlight.cur.target = target;
1453 if (target && elm_widget_highlight_in_theme_get(target))
1454 sd->focus_highlight.cur.in_theme = EINA_TRUE;
1456 _elm_win_focus_target_callbacks_add(sd);
1458 _elm_win_focus_highlight_reconfigure_job_start(sd);
1462 _elm_win_object_focus_out(void *data,
1463 Evas *e EINA_UNUSED,
1464 void *event_info EINA_UNUSED)
1466 ELM_WIN_DATA_GET(data, sd);
1468 if (!sd->focus_highlight.cur.target)
1471 if (!sd->focus_highlight.cur.in_theme)
1472 _elm_win_focus_target_callbacks_del(sd);
1474 sd->focus_highlight.cur.target = NULL;
1475 sd->focus_highlight.cur.in_theme = EINA_FALSE;
1477 _elm_win_focus_highlight_reconfigure_job_start(sd);
1481 _elm_win_focus_highlight_shutdown(Elm_Win_Data *sd)
1483 _elm_win_focus_highlight_reconfigure_job_stop(sd);
1484 if (sd->focus_highlight.cur.target)
1486 elm_widget_signal_emit(sd->focus_highlight.cur.target,
1487 "elm,action,focus_highlight,hide", "elm");
1488 _elm_win_focus_target_callbacks_del(sd);
1489 sd->focus_highlight.cur.target = NULL;
1491 ELM_SAFE_FREE(sd->focus_highlight.fobj, evas_object_del);
1493 evas_event_callback_del_full
1494 (sd->evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
1495 _elm_win_object_focus_in, sd->obj);
1496 evas_event_callback_del_full
1497 (sd->evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
1498 _elm_win_object_focus_out, sd->obj);
1502 _win_img_hide(void *data,
1503 Evas *e EINA_UNUSED,
1504 Evas_Object *obj EINA_UNUSED,
1505 void *event_info EINA_UNUSED)
1507 elm_widget_focus_hide_handle(data);
1511 _win_img_mouse_up(void *data,
1512 Evas *e EINA_UNUSED,
1513 Evas_Object *obj EINA_UNUSED,
1516 Evas_Event_Mouse_Up *ev = event_info;
1517 if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD))
1518 elm_widget_focus_mouse_up_handle(data);
1522 _win_img_focus_in(void *data,
1523 Evas *e EINA_UNUSED,
1524 Evas_Object *obj EINA_UNUSED,
1525 void *event_info EINA_UNUSED)
1527 elm_widget_focus_steal(data);
1531 _win_img_focus_out(void *data,
1532 Evas *e EINA_UNUSED,
1533 Evas_Object *obj EINA_UNUSED,
1534 void *event_info EINA_UNUSED)
1536 elm_widget_focused_object_clear(data);
1540 _elm_win_on_img_obj_del(void *data,
1541 Evas *e EINA_UNUSED,
1542 Evas_Object *obj EINA_UNUSED,
1543 void *event_info EINA_UNUSED)
1545 ELM_WIN_DATA_GET(data, sd);
1546 _elm_win_img_callbacks_del(sd->obj, sd->img_obj);
1551 _elm_win_img_callbacks_del(Evas_Object *obj, Evas_Object *imgobj)
1553 evas_object_event_callback_del_full
1554 (imgobj, EVAS_CALLBACK_DEL, _elm_win_on_img_obj_del, obj);
1555 evas_object_event_callback_del_full
1556 (imgobj, EVAS_CALLBACK_HIDE, _win_img_hide, obj);
1557 evas_object_event_callback_del_full
1558 (imgobj, EVAS_CALLBACK_MOUSE_UP, _win_img_mouse_up, obj);
1559 evas_object_event_callback_del_full
1560 (imgobj, EVAS_CALLBACK_FOCUS_IN, _win_img_focus_in, obj);
1561 evas_object_event_callback_del_full
1562 (imgobj, EVAS_CALLBACK_FOCUS_OUT, _win_img_focus_out, obj);
1566 _elm_win_evas_smart_del(Eo *obj, Elm_Win_Data *sd)
1569 Evas_Object *current;
1571 if ((sd->modal) && (evas_object_visible_get(obj)))
1573 DECREMENT_MODALITY()
1576 if ((sd->modal) && (sd->modal_count > 0))
1577 ERR("Deleted modal win was blocked by another modal win which was created after creation of that win.");
1579 evas_object_event_callback_del_full(sd->layout,
1580 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1581 _elm_win_on_resize_obj_changed_size_hints,
1583 evas_object_del(sd->box);
1584 evas_object_del(sd->layout);
1586 /* NB: child deletion handled by parent's smart del */
1588 if ((trap) && (trap->del))
1589 trap->del(sd->trap_data, obj);
1593 evas_object_event_callback_del_full
1594 (sd->parent, EVAS_CALLBACK_DEL, _elm_win_on_parent_del, obj);
1598 if (sd->autodel_clear) *(sd->autodel_clear) = -1;
1600 _elm_win_list = eina_list_remove(_elm_win_list, obj);
1602 _elm_win_state_eval_queue();
1606 ecore_evas_callback_delete_request_set(sd->ee, NULL);
1607 ecore_evas_callback_resize_set(sd->ee, NULL);
1610 ecore_job_del(sd->deferred_resize_job);
1611 ecore_job_del(sd->deferred_child_eval_job);
1612 eina_stringshare_del(sd->shot.info);
1613 ecore_timer_del(sd->shot.timer);
1615 #ifdef HAVE_ELEMENTARY_X
1616 ecore_event_handler_del(sd->x.client_message_handler);
1617 ecore_event_handler_del(sd->x.property_handler);
1622 _elm_win_img_callbacks_del(obj, sd->img_obj);
1629 ecore_job_add(_deferred_ecore_evas_free, sd->ee);
1630 _elm_win_deferred_free++;
1634 _elm_win_focus_highlight_shutdown(sd);
1635 eina_stringshare_del(sd->focus_highlight.style);
1637 eina_stringshare_del(sd->title);
1638 eina_stringshare_del(sd->icon_name);
1639 eina_stringshare_del(sd->role);
1640 evas_object_del(sd->icon);
1641 evas_object_del(sd->main_menu);
1643 _elm_win_profile_del(sd);
1644 _elm_win_available_profiles_del(sd);
1646 /* Don't let callback in the air that point to sd */
1647 ecore_evas_callback_delete_request_set(sd->ee, NULL);
1648 ecore_evas_callback_resize_set(sd->ee, NULL);
1649 ecore_evas_callback_mouse_in_set(sd->ee, NULL);
1650 ecore_evas_callback_focus_in_set(sd->ee, NULL);
1651 ecore_evas_callback_focus_out_set(sd->ee, NULL);
1652 ecore_evas_callback_move_set(sd->ee, NULL);
1653 ecore_evas_callback_state_change_set(sd->ee, NULL);
1655 eo_do_super(obj, MY_CLASS, evas_obj_smart_del());
1657 if ((!_elm_win_list) &&
1658 (elm_policy_get(ELM_POLICY_QUIT) == ELM_POLICY_QUIT_LAST_WINDOW_CLOSED))
1660 edje_file_cache_flush();
1661 edje_collection_cache_flush();
1662 evas_image_cache_flush(evas_object_evas_get(obj));
1663 evas_font_cache_flush(evas_object_evas_get(obj));
1669 _elm_win_obj_intercept_show(void *data,
1672 ELM_WIN_DATA_GET(data, sd);
1674 // this is called to make sure all smart containers have calculated their
1675 // sizes BEFORE we show the window to make sure it initially appears at
1676 // our desired size (ie min size is known first)
1677 evas_smart_objects_calculate(evas_object_evas_get(obj));
1680 evas_object_show(sd->frame_obj);
1684 evas_object_show(sd->img_obj);
1686 if (sd->pointer.obj)
1688 ecore_evas_show(sd->pointer.ee);
1689 evas_object_show(sd->pointer.obj);
1691 evas_object_show(obj);
1695 _elm_win_evas_smart_move(Eo *obj, Elm_Win_Data *sd, Evas_Coord x, Evas_Coord y)
1699 if ((x != sd->screen.x) || (y != sd->screen.y))
1703 evas_object_smart_callback_call(obj, SIG_MOVED, NULL);
1709 TRAP(sd, move, x, y);
1710 if (!ecore_evas_override_get(sd->ee)) return;
1713 eo_do_super(obj, MY_CLASS, evas_obj_smart_move(x, y));
1715 if (ecore_evas_override_get(sd->ee))
1719 evas_object_smart_callback_call(obj, SIG_MOVED, NULL);
1723 /* FIXME: We should update ecore_wl_window_location here !! */
1735 _elm_win_evas_smart_resize(Eo *obj, Elm_Win_Data *sd, Evas_Coord w, Evas_Coord h)
1737 eo_do_super(obj, MY_CLASS, evas_obj_smart_resize(w, h));
1745 ecore_evas_screen_geometry_get(sd->ee, NULL, NULL, &sw, &sh);
1752 evas_object_image_size_set(sd->img_obj, w, h);
1755 TRAP(sd, resize, w, h);
1759 _elm_win_delete_request(Ecore_Evas *ee)
1761 Elm_Win_Data *sd = _elm_win_associate_get(ee);
1768 int autodel = sd->autodel;
1769 sd->autodel_clear = &autodel;
1770 evas_object_ref(obj);
1771 evas_object_smart_callback_call(obj, SIG_DELETE_REQUEST, NULL);
1772 // FIXME: if above callback deletes - then the below will be invalid
1773 if (autodel) evas_object_del(obj);
1774 else sd->autodel_clear = NULL;
1775 evas_object_unref(obj);
1779 _elm_ee_xwin_get(const Ecore_Evas *ee)
1781 #ifdef HAVE_ELEMENTARY_X
1782 const char *engine_name;
1785 engine_name = ecore_evas_engine_name_get(ee);
1786 if (EINA_UNLIKELY(!engine_name)) return 0;
1788 if (!strcmp(engine_name, ELM_SOFTWARE_X11))
1790 return ecore_evas_software_x11_window_get(ee);
1792 else if (!strcmp(engine_name, ELM_OPENGL_X11))
1794 return ecore_evas_gl_x11_window_get(ee);
1802 #ifdef HAVE_ELEMENTARY_X
1804 _internal_elm_win_xwindow_get(Elm_Win_Data *sd)
1806 sd->x.xwin = _elm_ee_xwin_get(sd->ee);
1811 _elm_ee_wlwin_get(const Ecore_Evas *ee)
1813 #ifdef HAVE_ELEMENTARY_WAYLAND
1814 const char *engine_name;
1816 if (!ee) return NULL;
1818 engine_name = ecore_evas_engine_name_get(ee);
1819 if (EINA_UNLIKELY(!engine_name)) return NULL;
1821 if ((!strcmp(engine_name, ELM_WAYLAND_SHM)) ||
1822 (!strcmp(engine_name, ELM_WAYLAND_EGL)))
1824 return ecore_evas_wayland_window_get(ee);
1832 #ifdef HAVE_ELEMENTARY_WAYLAND
1834 _elm_win_wlwindow_get(Elm_Win_Data *sd)
1836 sd->wl.win = _elm_ee_wlwin_get(sd->ee);
1840 #ifdef HAVE_ELEMENTARY_X
1842 _elm_win_xwin_update(Elm_Win_Data *sd)
1846 _internal_elm_win_xwindow_get(sd);
1849 ELM_WIN_DATA_GET(sd->parent, sdp);
1853 ecore_x_icccm_transient_for_set(sd->x.xwin, sdp->x.xwin);
1857 if (!sd->x.xwin) return; /* nothing more to do */
1860 if (!s) s = _elm_appname;
1862 if (sd->icon_name) s = sd->icon_name;
1863 ecore_x_icccm_icon_name_set(sd->x.xwin, s);
1864 ecore_x_netwm_icon_name_set(sd->x.xwin, s);
1867 if (s) ecore_x_icccm_window_role_set(sd->x.xwin, s);
1874 data = evas_object_image_data_get(sd->icon, EINA_FALSE);
1878 int w = 0, h = 0, stride, x, y;
1882 evas_object_image_size_get(sd->icon, &w, &h);
1883 stride = evas_object_image_stride_get(sd->icon);
1884 if ((w > 0) && (h > 0) &&
1885 (stride >= (int)(w * sizeof(unsigned int))))
1889 ic.data = malloc(w * h * sizeof(unsigned int));
1893 p = (unsigned char *)data;
1894 p2 = (unsigned int *)ic.data;
1895 for (y = 0; y < h; y++)
1897 for (x = 0; x < w; x++)
1899 *p2 = *((unsigned int *)p);
1900 p += sizeof(unsigned int);
1903 p += (stride - (w * sizeof(unsigned int)));
1905 ecore_x_netwm_icons_set(sd->x.xwin, &ic, 1);
1909 evas_object_image_data_set(sd->icon, data);
1916 ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_NORMAL);
1919 case ELM_WIN_DIALOG_BASIC:
1920 ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_DIALOG);
1923 case ELM_WIN_DESKTOP:
1924 ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_DESKTOP);
1928 ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_DOCK);
1931 case ELM_WIN_TOOLBAR:
1932 ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_TOOLBAR);
1936 ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_MENU);
1939 case ELM_WIN_UTILITY:
1940 ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_UTILITY);
1943 case ELM_WIN_SPLASH:
1944 ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_SPLASH);
1947 case ELM_WIN_DROPDOWN_MENU:
1948 ecore_x_netwm_window_type_set
1949 (sd->x.xwin, ECORE_X_WINDOW_TYPE_DROPDOWN_MENU);
1952 case ELM_WIN_POPUP_MENU:
1953 ecore_x_netwm_window_type_set
1954 (sd->x.xwin, ECORE_X_WINDOW_TYPE_POPUP_MENU);
1957 case ELM_WIN_TOOLTIP:
1958 ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_TOOLTIP);
1961 case ELM_WIN_NOTIFICATION:
1962 ecore_x_netwm_window_type_set
1963 (sd->x.xwin, ECORE_X_WINDOW_TYPE_NOTIFICATION);
1967 ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_COMBO);
1971 ecore_x_netwm_window_type_set(sd->x.xwin, ECORE_X_WINDOW_TYPE_DND);
1977 ecore_x_e_virtual_keyboard_state_set
1978 (sd->x.xwin, (Ecore_X_Virtual_Keyboard_State)sd->kbdmode);
1979 if (sd->indmode == ELM_WIN_INDICATOR_SHOW)
1980 ecore_x_e_illume_indicator_state_set
1981 (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_STATE_ON);
1982 else if (sd->indmode == ELM_WIN_INDICATOR_HIDE)
1983 ecore_x_e_illume_indicator_state_set
1984 (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_STATE_OFF);
1992 * Resize the window according to window layout's min and weight.
1993 * If the window layout's weight is 0.0, the window max is limited to layout's
1996 * This is called when the window layout's weight hint is changed or when the
1997 * window is rotated.
1999 * @param obj window object
2002 _elm_win_resize_objects_eval(Evas_Object *obj)
2004 ELM_WIN_DATA_GET(obj, sd);
2005 Evas_Coord w, h, minw, minh, maxw, maxh;
2008 evas_object_size_hint_min_get(sd->layout, &minw, &minh);
2009 if (minw < 1) minw = 1;
2010 if (minh < 1) minh = 1;
2012 evas_object_size_hint_weight_get(sd->layout, &wx, &wy);
2013 if (!wx) maxw = minw;
2015 if (!wy) maxh = minh;
2018 evas_object_size_hint_min_set(obj, minw, minh);
2019 evas_object_size_hint_max_set(obj, maxw, maxh);
2020 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
2021 if (w < minw) w = minw;
2022 if (h < minh) h = minh;
2023 if (w > maxw) w = maxw;
2024 if (h > maxh) h = maxh;
2025 evas_object_resize(obj, w, h);
2029 _elm_win_on_resize_obj_changed_size_hints(void *data,
2030 Evas *e EINA_UNUSED,
2031 Evas_Object *obj EINA_UNUSED,
2032 void *event_info EINA_UNUSED)
2034 _elm_win_resize_objects_eval(data);
2038 _elm_win_shutdown(void)
2040 while (_elm_win_list) evas_object_del(_elm_win_list->data);
2041 ELM_SAFE_FREE(_elm_win_state_eval_job, ecore_job_del);
2045 _elm_win_rescale(Elm_Theme *th,
2046 Eina_Bool use_theme)
2053 EINA_LIST_FOREACH(_elm_win_list, l, obj)
2054 elm_widget_theme(obj);
2058 EINA_LIST_FOREACH(_elm_win_list, l, obj)
2059 elm_widget_theme_specific(obj, th, EINA_FALSE);
2064 _elm_win_access(Eina_Bool is_access)
2071 EINA_LIST_FOREACH(_elm_win_list, l, obj)
2073 elm_widget_access(obj, is_access);
2075 /* floating orphan object. if there are A, B, C objects and user does
2076 as below, then there would be floating orphan objects.
2078 1. elm_object_content_set(layout, A);
2079 2. elm_object_content_set(layout, B);
2080 3. elm_object_content_set(layout, C);
2082 now, the object A and B are floating orphan objects */
2087 fobj = evas_object_below_get(fobj);
2090 if (elm_widget_is(fobj) && !elm_widget_parent_get(fobj))
2092 elm_widget_access(fobj, is_access);
2098 evas = evas_object_evas_get(obj);
2099 if (evas) _elm_access_object_highlight_disable(evas);
2105 _elm_win_translate(void)
2110 EINA_LIST_FOREACH(_elm_win_list, l, obj)
2111 elm_widget_translate(obj);
2114 #ifdef HAVE_ELEMENTARY_X
2116 _elm_win_client_message(void *data,
2117 int type EINA_UNUSED,
2120 ELM_WIN_DATA_GET(data, sd);
2121 Ecore_X_Event_Client_Message *e = event;
2123 if (e->format != 32) return ECORE_CALLBACK_PASS_ON;
2124 if (e->message_type == ECORE_X_ATOM_E_COMP_FLUSH)
2126 if ((unsigned int)e->data.l[0] == sd->x.xwin)
2128 Evas *evas = evas_object_evas_get(sd->obj);
2131 edje_file_cache_flush();
2132 edje_collection_cache_flush();
2133 evas_image_cache_flush(evas);
2134 evas_font_cache_flush(evas);
2138 else if (e->message_type == ECORE_X_ATOM_E_COMP_DUMP)
2140 if ((unsigned int)e->data.l[0] == sd->x.xwin)
2142 Evas *evas = evas_object_evas_get(sd->obj);
2145 edje_file_cache_flush();
2146 edje_collection_cache_flush();
2147 evas_image_cache_flush(evas);
2148 evas_font_cache_flush(evas);
2149 evas_render_dump(evas);
2153 else if (e->message_type == ECORE_X_ATOM_E_ILLUME_ACCESS_CONTROL)
2155 if ((unsigned int)e->data.l[0] == sd->x.xwin)
2157 if ((unsigned int)e->data.l[1] ==
2158 ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_NEXT)
2160 // XXX: call right access func
2162 else if ((unsigned int)e->data.l[1] ==
2163 ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_PREV)
2165 // XXX: call right access func
2167 else if ((unsigned int)e->data.l[1] ==
2168 ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_ACTIVATE)
2170 _elm_access_highlight_object_activate
2171 (sd->obj, ELM_ACTIVATE_DEFAULT);
2173 else if ((unsigned int)e->data.l[1] ==
2174 ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_READ)
2176 /* there would be better way to read highlight object */
2178 evas = evas_object_evas_get(sd->obj);
2179 if (!evas) return ECORE_CALLBACK_PASS_ON;
2181 _elm_access_mouse_event_enabled_set(EINA_TRUE);
2183 evas_event_feed_mouse_in(evas, 0, NULL);
2184 evas_event_feed_mouse_move
2185 (evas, e->data.l[2], e->data.l[3], 0, NULL);
2187 _elm_access_mouse_event_enabled_set(EINA_FALSE);
2189 else if ((unsigned int)e->data.l[1] ==
2190 ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_READ_NEXT)
2192 _elm_access_highlight_cycle(sd->obj, ELM_FOCUS_NEXT);
2194 else if ((unsigned int)e->data.l[1] ==
2195 ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_READ_PREV)
2197 _elm_access_highlight_cycle(sd->obj, ELM_FOCUS_PREVIOUS);
2199 else if ((unsigned int)e->data.l[1] ==
2200 ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_UP)
2202 _elm_access_highlight_object_activate
2203 (sd->obj, ELM_ACTIVATE_UP);
2205 else if ((unsigned int)e->data.l[1] ==
2206 ECORE_X_ATOM_E_ILLUME_ACCESS_ACTION_DOWN)
2208 _elm_access_highlight_object_activate
2209 (sd->obj, ELM_ACTIVATE_DOWN);
2213 return ECORE_CALLBACK_PASS_ON;
2217 _elm_win_property_change(void *data,
2218 int type EINA_UNUSED,
2221 ELM_WIN_DATA_GET(data, sd);
2222 Ecore_X_Event_Window_Property *e = event;
2224 if (e->atom == ECORE_X_ATOM_E_ILLUME_INDICATOR_STATE)
2226 if (e->win == sd->x.xwin)
2228 sd->indmode = (Elm_Win_Indicator_Mode)ecore_x_e_illume_indicator_state_get(e->win);
2229 evas_object_smart_callback_call(sd->obj, SIG_INDICATOR_PROP_CHANGED, NULL);
2232 return ECORE_CALLBACK_PASS_ON;
2237 _elm_win_focus_highlight_hide(void *data EINA_UNUSED,
2239 const char *emission EINA_UNUSED,
2240 const char *source EINA_UNUSED)
2242 evas_object_hide(obj);
2246 _elm_win_focus_highlight_anim_end(void *data,
2248 const char *emission EINA_UNUSED,
2249 const char *source EINA_UNUSED)
2251 ELM_WIN_DATA_GET(data, sd);
2253 _elm_win_focus_highlight_simple_setup(sd, obj);
2257 _elm_win_focus_highlight_init(Elm_Win_Data *sd)
2259 evas_event_callback_add(sd->evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
2260 _elm_win_object_focus_in, sd->obj);
2261 evas_event_callback_add(sd->evas,
2262 EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
2263 _elm_win_object_focus_out, sd->obj);
2265 sd->focus_highlight.cur.target = NULL;
2266 sd->focus_highlight.fobj = edje_object_add(sd->evas);
2267 sd->focus_highlight.theme_changed = EINA_TRUE;
2269 edje_object_signal_callback_add(sd->focus_highlight.fobj,
2270 "elm,action,focus,hide,end", "*",
2271 _elm_win_focus_highlight_hide, NULL);
2272 edje_object_signal_callback_add(sd->focus_highlight.fobj,
2273 "elm,action,focus,anim,end", "*",
2274 _elm_win_focus_highlight_anim_end, sd->obj);
2275 _elm_win_focus_highlight_reconfigure_job_start(sd);
2279 _elm_win_frame_cb_move_start(void *data,
2280 Evas_Object *obj EINA_UNUSED,
2281 const char *sig EINA_UNUSED,
2284 ELM_WIN_DATA_GET(data, sd);
2288 #ifdef HAVE_ELEMENTARY_WAYLAND
2289 if (!strcmp(source, "elm"))
2290 ecore_wl_window_cursor_from_name_set(sd->wl.win, ELM_CURSOR_HAND1);
2292 ecore_wl_window_cursor_default_restore(sd->wl.win);
2297 /* NB: Wayland handles moving surfaces by itself so we cannot
2298 * specify a specific x/y we want. Instead, we will pass in the
2299 * existing x/y values so they can be recorded as 'previous'
2300 * position. The new position will get updated automatically when
2301 * the move is finished */
2303 ecore_evas_wayland_move(sd->ee, sd->screen.x, sd->screen.y);
2307 _elm_win_frame_cb_move_stop(void *data,
2308 Evas_Object *obj EINA_UNUSED,
2309 const char *sig EINA_UNUSED,
2310 const char *source EINA_UNUSED)
2312 ELM_WIN_DATA_GET(data, sd);
2316 #ifdef HAVE_ELEMENTARY_WAYLAND
2317 ecore_wl_window_cursor_default_restore(sd->wl.win);
2321 #ifdef HAVE_ELEMENTARY_WAYLAND
2328 static struct _resize_info _border_side[4] =
2330 { ELM_CURSOR_TOP_SIDE, 1 },
2331 { ELM_CURSOR_LEFT_SIDE, 4 },
2332 { ELM_CURSOR_BOTTOM_SIDE, 2 },
2333 { ELM_CURSOR_RIGHT_SIDE, 8 },
2336 static struct _resize_info _border_corner[4] =
2338 { ELM_CURSOR_TOP_LEFT_CORNER, 5 },
2339 { ELM_CURSOR_BOTTOM_LEFT_CORNER, 6 },
2340 { ELM_CURSOR_BOTTOM_RIGHT_CORNER, 10 },
2341 { ELM_CURSOR_TOP_RIGHT_CORNER, 9 },
2346 _elm_win_frame_obj_update(Elm_Win_Data *sd)
2352 evas_object_geometry_get(sd->frame_obj, &fx, &fy, &fw, &fh);
2353 evas_object_geometry_get(sd->client_obj, &ox, &oy, &ow, &oh);
2354 evas_object_geometry_get(sd->spacer_obj, &sx, &sy, &sw, &sh);
2356 evas_output_framespace_get(sd->evas, &x, &y, &w, &h);
2358 if ((x != (ox - fx)) || (y != (oy - fy)) ||
2359 (w != (fw - ow)) || (h != (fh - oh)))
2361 evas_output_framespace_set(sd->evas, (ox - fx), (oy - fy),
2362 (fw - ow), (fh - oh));
2365 #ifdef HAVE_ELEMENTARY_WAYLAND
2366 ecore_wl_window_opaque_region_set(sd->wl.win, -fx, -(fy - sy), sw, sh);
2371 _elm_win_frame_obj_move(void *data,
2372 Evas *e EINA_UNUSED,
2373 Evas_Object *obj EINA_UNUSED,
2374 void *event_info EINA_UNUSED)
2378 if (!(sd = data)) return;
2379 if (!sd->client_obj) return;
2381 _elm_win_frame_obj_update(sd);
2385 _elm_win_frame_obj_resize(void *data,
2386 Evas *e EINA_UNUSED,
2387 Evas_Object *obj EINA_UNUSED,
2388 void *event_info EINA_UNUSED)
2392 if (!(sd = data)) return;
2393 if (!sd->client_obj) return;
2395 _elm_win_frame_obj_update(sd);
2399 _elm_win_frame_cb_resize_show(void *data,
2400 Evas_Object *obj EINA_UNUSED,
2401 const char *sig EINA_UNUSED,
2404 ELM_WIN_DATA_GET(data, sd);
2407 if (sd->resizing) return;
2409 #ifdef HAVE_ELEMENTARY_WAYLAND
2412 if (!strcmp(source, "elm.event.resize.t"))
2413 ecore_wl_window_cursor_from_name_set(sd->wl.win,
2414 _border_side[(0 + i) % 4].name);
2415 else if (!strcmp(source, "elm.event.resize.b"))
2416 ecore_wl_window_cursor_from_name_set(sd->wl.win,
2417 _border_side[(2 + i) % 4].name);
2418 else if (!strcmp(source, "elm.event.resize.l"))
2419 ecore_wl_window_cursor_from_name_set(sd->wl.win,
2420 _border_side[(1 + i) % 4].name);
2421 else if (!strcmp(source, "elm.event.resize.r"))
2422 ecore_wl_window_cursor_from_name_set(sd->wl.win,
2423 _border_side[(3 + i) % 4].name);
2424 else if (!strcmp(source, "elm.event.resize.tl"))
2425 ecore_wl_window_cursor_from_name_set(sd->wl.win,
2426 _border_corner[(0 + i) % 4].name);
2427 else if (!strcmp(source, "elm.event.resize.tr"))
2428 ecore_wl_window_cursor_from_name_set(sd->wl.win,
2429 _border_corner[(3 + i) % 4].name);
2430 else if (!strcmp(source, "elm.event.resize.bl"))
2431 ecore_wl_window_cursor_from_name_set(sd->wl.win,
2432 _border_corner[(1 + i) % 4].name);
2433 else if (!strcmp(source, "elm.event.resize.br"))
2434 ecore_wl_window_cursor_from_name_set(sd->wl.win,
2435 _border_corner[(2 + i) % 4].name);
2437 ecore_wl_window_cursor_default_restore(sd->wl.win);
2444 _elm_win_frame_cb_resize_hide(void *data,
2445 Evas_Object *obj EINA_UNUSED,
2446 const char *sig EINA_UNUSED,
2447 const char *source EINA_UNUSED)
2449 ELM_WIN_DATA_GET(data, sd);
2452 if (sd->resizing) return;
2454 #ifdef HAVE_ELEMENTARY_WAYLAND
2455 ecore_wl_window_cursor_default_restore(sd->wl.win);
2460 _elm_win_frame_cb_resize_start(void *data,
2461 Evas_Object *obj EINA_UNUSED,
2462 const char *sig EINA_UNUSED,
2465 #ifdef HAVE_ELEMENTARY_WAYLAND
2466 ELM_WIN_DATA_GET(data, sd);
2470 if (sd->resizing) return;
2472 sd->resizing = EINA_TRUE;
2474 if (!strcmp(source, "elm.event.resize.t"))
2475 sd->resize_location = _border_side[(0 + i) % 4].location;
2476 else if (!strcmp(source, "elm.event.resize.b"))
2477 sd->resize_location = _border_side[(2 + i) % 4].location;
2478 else if (!strcmp(source, "elm.event.resize.l"))
2479 sd->resize_location = _border_side[(1 + i) % 4].location;
2480 else if (!strcmp(source, "elm.event.resize.r"))
2481 sd->resize_location = _border_side[(3 + i) % 4].location;
2482 else if (!strcmp(source, "elm.event.resize.tl"))
2483 sd->resize_location = _border_corner[(0 + i) % 4].location;
2484 else if (!strcmp(source, "elm.event.resize.tr"))
2485 sd->resize_location = _border_corner[(3 + i) % 4].location;
2486 else if (!strcmp(source, "elm.event.resize.bl"))
2487 sd->resize_location = _border_corner[(1 + i) % 4].location;
2488 else if (!strcmp(source, "elm.event.resize.br"))
2489 sd->resize_location = _border_corner[(2 + i) % 4].location;
2491 sd->resize_location = 0;
2493 if (sd->resize_location > 0)
2494 ecore_evas_wayland_resize(sd->ee, sd->resize_location);
2502 _elm_win_frame_cb_minimize(void *data,
2503 Evas_Object *obj EINA_UNUSED,
2504 const char *sig EINA_UNUSED,
2505 const char *source EINA_UNUSED)
2507 ELM_WIN_DATA_GET(data, sd);
2510 // sd->iconified = EINA_TRUE;
2511 TRAP(sd, iconified_set, EINA_TRUE);
2515 _elm_win_frame_maximized_state_update(Elm_Win_Data *sd, Eina_Bool maximized)
2517 const char *emission;
2520 emission = "elm,state,maximized";
2522 emission = "elm,state,unmaximized";
2524 edje_object_signal_emit(sd->frame_obj, emission, "elm");
2525 edje_object_message_signal_process(sd->frame_obj);
2526 evas_object_smart_calculate(sd->frame_obj);
2528 _elm_win_frame_obj_update(sd);
2532 _elm_win_frame_cb_maximize(void *data,
2533 Evas_Object *obj EINA_UNUSED,
2534 const char *sig EINA_UNUSED,
2535 const char *source EINA_UNUSED)
2538 ELM_WIN_DATA_GET(data, sd);
2541 if (sd->maximized) value = EINA_FALSE;
2542 else value = EINA_TRUE;
2544 _elm_win_frame_maximized_state_update(sd, value);
2546 TRAP(sd, maximized_set, value);
2550 _elm_win_frame_cb_close(void *data,
2551 Evas_Object *obj EINA_UNUSED,
2552 const char *sig EINA_UNUSED,
2553 const char *source EINA_UNUSED)
2555 ELM_WIN_DATA_GET(data, sd);
2558 /* FIXME: After the current freeze, this should be handled differently.
2560 * Ideally, we would want to mimic the X11 backend and use something
2561 * like ECORE_WL_EVENT_WINDOW_DELETE and handle the delete_request
2562 * inside of ecore_evas. That would be the 'proper' way, but since we are
2563 * in a freeze right now, I cannot add a new event value, or a new
2564 * event structure to ecore_wayland.
2566 * So yes, this is a temporary 'stop-gap' solution which will be fixed
2567 * when the freeze is over, but it does fix a trac bug for now, and in a
2568 * way which does not break API or the freeze. - dh
2575 int autodel = sd->autodel;
2576 sd->autodel_clear = &autodel;
2577 evas_object_ref(win);
2578 evas_object_smart_callback_call(win, SIG_DELETE_REQUEST, NULL);
2579 // FIXME: if above callback deletes - then the below will be invalid
2580 if (autodel) evas_object_del(win);
2581 else sd->autodel_clear = NULL;
2582 evas_object_unref(win);
2586 _elm_win_frame_add(Elm_Win_Data *sd,
2589 Evas_Object *obj = sd->obj;
2593 sd->frame_obj = edje_object_add(sd->evas);
2594 layer = evas_object_layer_get(obj);
2595 evas_object_layer_set(sd->frame_obj, layer + 1);
2596 if (!elm_widget_theme_object_set
2597 (sd->obj, sd->frame_obj, "border", "base", style))
2599 ELM_SAFE_FREE(sd->frame_obj, evas_object_del);
2603 sd->spacer_obj = evas_object_rectangle_add(sd->evas);
2604 evas_object_color_set(sd->spacer_obj, 0, 0, 0, 0);
2605 evas_object_repeat_events_set(sd->spacer_obj, EINA_TRUE);
2606 edje_object_part_swallow(sd->frame_obj, "elm.swallow.frame_spacer",
2609 sd->client_obj = evas_object_rectangle_add(sd->evas);
2610 evas_object_color_set(sd->client_obj, 0, 0, 0, 0);
2611 /* NB: Tried pass_events here, but that fails to send events */
2612 evas_object_repeat_events_set(sd->client_obj, EINA_TRUE);
2613 edje_object_part_swallow(sd->frame_obj, "elm.swallow.client",
2616 evas_object_is_frame_object_set(sd->frame_obj, EINA_TRUE);
2618 evas_object_event_callback_add
2619 (sd->frame_obj, EVAS_CALLBACK_MOVE, _elm_win_frame_obj_move, sd);
2620 evas_object_event_callback_add
2621 (sd->frame_obj, EVAS_CALLBACK_RESIZE, _elm_win_frame_obj_resize, sd);
2623 /* NB: Do NOT remove these calls !! Needed to calculate proper
2624 * framespace on inital show of the window */
2625 edje_object_size_min_calc(sd->frame_obj, &mw, &mh);
2626 evas_object_move(sd->frame_obj, 0, 0);
2627 evas_object_resize(sd->frame_obj, mw, mh);
2628 evas_object_smart_calculate(sd->frame_obj);
2630 edje_object_signal_callback_add
2631 (sd->frame_obj, "elm,action,move,start", "elm",
2632 _elm_win_frame_cb_move_start, obj);
2633 edje_object_signal_callback_add
2634 (sd->frame_obj, "elm,action,move,stop", "elm",
2635 _elm_win_frame_cb_move_stop, obj);
2636 edje_object_signal_callback_add
2637 (sd->frame_obj, "elm,action,resize,show", "*",
2638 _elm_win_frame_cb_resize_show, obj);
2639 edje_object_signal_callback_add
2640 (sd->frame_obj, "elm,action,resize,hide", "*",
2641 _elm_win_frame_cb_resize_hide, obj);
2642 edje_object_signal_callback_add
2643 (sd->frame_obj, "elm,action,resize,start", "*",
2644 _elm_win_frame_cb_resize_start, obj);
2645 edje_object_signal_callback_add
2646 (sd->frame_obj, "elm,action,minimize", "elm",
2647 _elm_win_frame_cb_minimize, obj);
2648 edje_object_signal_callback_add
2649 (sd->frame_obj, "elm,action,maximize", "elm",
2650 _elm_win_frame_cb_maximize, obj);
2651 edje_object_signal_callback_add
2652 (sd->frame_obj, "elm,action,close", "elm", _elm_win_frame_cb_close, obj);
2656 edje_object_part_text_escaped_set
2657 (sd->frame_obj, "elm.text.title", sd->title);
2660 ecore_evas_geometry_get(sd->ee, NULL, NULL, &w, &h);
2661 ecore_evas_resize(sd->ee, w, h);
2665 _elm_win_frame_del(Elm_Win_Data *sd)
2669 ELM_SAFE_FREE(sd->client_obj, evas_object_del);
2673 evas_object_event_callback_del_full
2674 (sd->frame_obj, EVAS_CALLBACK_MOVE, _elm_win_frame_obj_move, sd);
2675 evas_object_event_callback_del_full
2676 (sd->frame_obj, EVAS_CALLBACK_RESIZE, _elm_win_frame_obj_resize, sd);
2678 edje_object_signal_callback_del
2679 (sd->frame_obj, "elm,action,move,start", "elm",
2680 _elm_win_frame_cb_move_start);
2681 edje_object_signal_callback_del
2682 (sd->frame_obj, "elm,action,move,stop", "elm",
2683 _elm_win_frame_cb_move_stop);
2684 edje_object_signal_callback_del
2685 (sd->frame_obj, "elm,action,resize,show", "*",
2686 _elm_win_frame_cb_resize_show);
2687 edje_object_signal_callback_del
2688 (sd->frame_obj, "elm,action,resize,hide", "*",
2689 _elm_win_frame_cb_resize_hide);
2690 edje_object_signal_callback_del
2691 (sd->frame_obj, "elm,action,resize,start", "*",
2692 _elm_win_frame_cb_resize_start);
2693 edje_object_signal_callback_del
2694 (sd->frame_obj, "elm,action,minimize", "elm",
2695 _elm_win_frame_cb_minimize);
2696 edje_object_signal_callback_del
2697 (sd->frame_obj, "elm,action,maximize", "elm",
2698 _elm_win_frame_cb_maximize);
2699 edje_object_signal_callback_del
2700 (sd->frame_obj, "elm,action,close", "elm",
2701 _elm_win_frame_cb_close);
2703 ELM_SAFE_FREE(sd->frame_obj, evas_object_del);
2706 evas_output_framespace_set(sd->evas, 0, 0, 0, 0);
2707 ecore_evas_geometry_get(sd->ee, NULL, NULL, &w, &h);
2708 ecore_evas_resize(sd->ee, w, h);
2713 _debug_key_down(void *data EINA_UNUSED,
2714 Evas *e EINA_UNUSED,
2718 Evas_Event_Key_Down *ev = event_info;
2720 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
2723 if ((strcmp(ev->key, "F12")) ||
2724 (!evas_key_modifier_is_set(ev->modifiers, "Control")))
2727 INF("Tree graph generated.");
2728 elm_object_tree_dot_dump(obj, "./dump.dot");
2734 _win_inlined_image_set(Elm_Win_Data *sd)
2736 evas_object_image_alpha_set(sd->img_obj, EINA_FALSE);
2737 evas_object_image_filled_set(sd->img_obj, EINA_TRUE);
2739 evas_object_event_callback_add
2740 (sd->img_obj, EVAS_CALLBACK_DEL, _elm_win_on_img_obj_del, sd->obj);
2741 evas_object_event_callback_add
2742 (sd->img_obj, EVAS_CALLBACK_HIDE, _win_img_hide, sd->obj);
2743 evas_object_event_callback_add
2744 (sd->img_obj, EVAS_CALLBACK_MOUSE_UP, _win_img_mouse_up, sd->obj);
2745 evas_object_event_callback_add
2746 (sd->img_obj, EVAS_CALLBACK_FOCUS_IN, _win_img_focus_in, sd->obj);
2747 evas_object_event_callback_add
2748 (sd->img_obj, EVAS_CALLBACK_FOCUS_OUT, _win_img_focus_out, sd->obj);
2752 _elm_win_on_icon_del(void *data,
2753 Evas *e EINA_UNUSED,
2755 void *event_info EINA_UNUSED)
2757 ELM_WIN_DATA_GET(data, sd);
2759 if (sd->icon == obj) sd->icon = NULL;
2763 _elm_win_evas_smart_add(Eo *obj, Elm_Win_Data *_pd EINA_UNUSED)
2765 eo_do_super(obj, MY_CLASS, evas_obj_smart_add());
2767 elm_widget_can_focus_set(obj, EINA_TRUE);
2769 elm_widget_highlight_ignore_set(obj, EINA_TRUE);
2772 #ifdef HAVE_ELEMENTARY_X
2774 _elm_x_io_err(void *data EINA_UNUSED)
2779 EINA_LIST_FOREACH(_elm_win_list, l, obj)
2780 evas_object_smart_callback_call(obj, SIG_IOERR, NULL);
2786 elm_win_add(Evas_Object *parent,
2790 Evas_Object *obj = eo_add_custom(MY_CLASS, parent, elm_obj_win_constructor(name, type));
2796 _elm_win_cb_hide(void *data EINA_UNUSED,
2797 Evas *e EINA_UNUSED,
2798 Evas_Object *obj EINA_UNUSED,
2799 void *event_info EINA_UNUSED)
2801 _elm_win_state_eval_queue();
2805 _elm_win_cb_show(void *data EINA_UNUSED,
2806 Evas *e EINA_UNUSED,
2807 Evas_Object *obj EINA_UNUSED,
2808 void *event_info EINA_UNUSED)
2810 _elm_win_state_eval_queue();
2816 * Recalculate the size of window considering its resize objects' weight and
2817 * min size. If any of its resize objects' weight equals to 0.0, window
2818 * layout's weight will be set to 0.0.
2820 * @param o box object
2821 * @param p box's private data
2822 * @param data window object
2825 _window_layout_stack(Evas_Object *o, Evas_Object_Box_Data *p, void *data)
2829 Evas_Object_Box_Option *opt;
2830 Evas_Coord x, y, w, h;
2832 Evas_Coord minw = -1, minh = -1;
2833 double weight_x = EVAS_HINT_EXPAND;
2834 double weight_y = EVAS_HINT_EXPAND;
2836 EINA_LIST_FOREACH(p->children, l, opt)
2839 evas_object_size_hint_weight_get(child, &wx, &wy);
2840 if (wx == 0.0) weight_x = 0;
2841 if (wy == 0.0) weight_y = 0;
2843 evas_object_size_hint_min_get(child, &w, &h);
2844 if (w > minw) minw = w;
2845 if (h > minh) minh = h;
2848 evas_object_size_hint_min_set(o, minw, minh);
2849 evas_object_geometry_get(o, &x, &y, &w, &h);
2850 if (w < minw) w = minw;
2851 if (h < minh) h = minh;
2852 evas_object_resize(o, w, h);
2854 EINA_LIST_FOREACH(p->children, l, opt)
2857 evas_object_move(child, x, y);
2858 evas_object_resize(child, w, h);
2861 ELM_WIN_DATA_GET(data, sd);
2862 evas_object_size_hint_weight_set(sd->layout, weight_x, weight_y);
2863 evas_object_smart_changed(sd->layout);
2869 if ((_elm_accel_preference) &&
2870 ((!strcasecmp(_elm_accel_preference, "gl")) ||
2871 (!strcasecmp(_elm_accel_preference, "opengl")) ||
2872 (!strcasecmp(_elm_accel_preference, "3d")) ||
2873 (!strcasecmp(_elm_accel_preference, "hw")) ||
2874 (!strcasecmp(_elm_accel_preference, "accel")) ||
2875 (!strcasecmp(_elm_accel_preference, "hardware"))
2882 _elm_win_constructor(Eo *obj, Elm_Win_Data *sd, const char *name, Elm_Win_Type type)
2884 sd->obj = obj; // in ctor
2886 Evas_Object *parent = NULL;
2889 const char *fontpath, *engine = NULL, *enginelist[32], *disp;
2892 Elm_Win_Data tmp_sd;
2894 eo_do(obj, parent = eo_parent_get());
2896 /* just to store some data while trying out to create a canvas */
2897 memset(&tmp_sd, 0, sizeof(Elm_Win_Data));
2901 case ELM_WIN_INLINED_IMAGE:
2904 e = evas_object_evas_get(parent);
2909 ee = ecore_evas_ecore_evas_get(e);
2912 tmp_sd.img_obj = ecore_evas_object_image_new(ee);
2913 if (!tmp_sd.img_obj) break;
2915 tmp_sd.ee = ecore_evas_object_ecore_evas_get(tmp_sd.img_obj);
2918 ELM_SAFE_FREE(tmp_sd.img_obj, evas_object_del);
2923 case ELM_WIN_SOCKET_IMAGE:
2924 tmp_sd.ee = ecore_evas_extn_socket_new(1, 1);
2928 disp = getenv("ELM_DISPLAY");
2929 if ((disp) && (!strcmp(disp, "x11")))
2933 enginelist[0] = ELM_OPENGL_X11;
2934 enginelist[1] = ELM_SOFTWARE_X11;
2935 enginelist[2] = NULL;
2939 enginelist[0] = ENGINE_GET();
2940 enginelist[1] = ELM_SOFTWARE_X11;
2941 enginelist[2] = ELM_OPENGL_X11;
2942 enginelist[3] = NULL;
2945 else if ((disp) && (!strcmp(disp, "wl")))
2949 enginelist[0] = ELM_WAYLAND_EGL;
2950 enginelist[1] = ELM_WAYLAND_SHM;
2951 enginelist[2] = NULL;
2955 enginelist[0] = ENGINE_GET();
2956 enginelist[1] = ELM_WAYLAND_SHM;
2957 enginelist[2] = ELM_WAYLAND_EGL;
2958 enginelist[3] = NULL;
2961 else if ((disp) && (!strcmp(disp, "win")))
2963 enginelist[0] = ENGINE_GET();
2964 enginelist[1] = ELM_SOFTWARE_WIN32;
2965 enginelist[2] = NULL;
2967 else if ((disp) && (!strcmp(disp, "sdl")))
2971 enginelist[0] = ELM_OPENGL_SDL;
2972 enginelist[1] = ELM_SOFTWARE_SDL;
2973 enginelist[2] = NULL;
2977 enginelist[0] = ENGINE_GET();
2978 enginelist[1] = ELM_SOFTWARE_SDL;
2979 enginelist[2] = ELM_OPENGL_SDL;
2980 enginelist[3] = NULL;
2983 else if ((disp) && (!strcmp(disp, "mac")))
2985 enginelist[0] = ENGINE_GET();
2986 enginelist[1] = ELM_OPENGL_COCOA;
2987 enginelist[2] = NULL;
2989 else if ((disp) && (!strcmp(disp, "ews")))
2991 enginelist[0] = ENGINE_GET();
2992 enginelist[1] = ELM_EWS;
2993 enginelist[2] = NULL;
2995 else if ((disp) && (!strcmp(disp, "fb")))
2997 enginelist[0] = ENGINE_GET();
2998 enginelist[1] = ELM_DRM;
2999 enginelist[2] = ELM_SOFTWARE_FB;
3000 enginelist[3] = NULL;
3002 else if ((disp) && (!strcmp(disp, "buffer")))
3004 enginelist[0] = ENGINE_GET();
3005 enginelist[1] = ELM_BUFFER;
3006 enginelist[2] = NULL;
3008 else if ((disp) && (!strcmp(disp, "ps3")))
3010 enginelist[0] = ENGINE_GET();
3011 enginelist[1] = ELM_SOFTWARE_PSL1GHT;
3012 enginelist[2] = NULL;
3014 else if ((disp) && (!strcmp(disp, "shot")))
3016 enginelist[0] = ENGINE_GET();
3017 enginelist[1] = NULL;
3023 enginelist[0] = ELM_OPENGL_X11;
3024 enginelist[1] = ELM_WAYLAND_EGL;
3025 enginelist[2] = ELM_DRM;
3026 enginelist[3] = ELM_SOFTWARE_FB;
3027 enginelist[4] = ELM_OPENGL_COCOA;
3028 enginelist[5] = ELM_OPENGL_SDL;
3029 enginelist[6] = NULL;
3033 enginelist[0] = ENGINE_GET();
3034 enginelist[1] = ELM_SOFTWARE_X11;
3035 enginelist[2] = ELM_WAYLAND_SHM;
3036 enginelist[3] = ELM_DRM;
3037 enginelist[4] = ELM_SOFTWARE_FB;
3038 enginelist[5] = ELM_OPENGL_COCOA;
3039 enginelist[6] = ELM_SOFTWARE_SDL;
3040 enginelist[7] = NULL;
3043 for (i = 0; i < 30; i++)
3045 if ((i > 0) && (!enginelist[i])) break;
3046 if (!strcmp(enginelist[i], ELM_SOFTWARE_X11))
3047 tmp_sd.ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
3048 else if (!strcmp(enginelist[i], ELM_OPENGL_X11))
3050 int opt[10], opt_i = 0;
3052 if (_elm_config->vsync)
3054 opt[opt_i++] = ECORE_EVAS_GL_X11_OPT_VSYNC;
3059 tmp_sd.ee = ecore_evas_gl_x11_options_new(NULL, 0, 0, 0, 1, 1, opt);
3061 tmp_sd.ee = ecore_evas_gl_x11_new(NULL, 0, 0, 0, 1, 1);
3063 else if (!strcmp(enginelist[i], ELM_WAYLAND_SHM))
3064 tmp_sd.ee = ecore_evas_wayland_shm_new(NULL, 0, 0, 0, 1, 1, 0);
3065 else if (!strcmp(enginelist[i], ELM_WAYLAND_EGL))
3066 tmp_sd.ee = ecore_evas_wayland_egl_new(NULL, 0, 0, 0, 1, 1, 0);
3067 else if (!strcmp(enginelist[i], ELM_SOFTWARE_WIN32))
3068 tmp_sd.ee = ecore_evas_software_gdi_new(NULL, 0, 0, 1, 1);
3069 else if (!strcmp(enginelist[i], ELM_SOFTWARE_SDL))
3070 tmp_sd.ee = ecore_evas_sdl_new(NULL, 0, 0, 0, 0, 0, 1);
3071 else if (!strcmp(enginelist[i], ELM_OPENGL_SDL))
3072 tmp_sd.ee = ecore_evas_gl_sdl_new(NULL, 1, 1, 0, 0);
3073 else if (!strcmp(enginelist[i], ELM_OPENGL_COCOA))
3074 tmp_sd.ee = ecore_evas_cocoa_new(NULL, 1, 1, 0, 0);
3075 else if (!strcmp(enginelist[i], ELM_EWS))
3076 tmp_sd.ee = ecore_evas_ews_new(0, 0, 1, 1);
3077 else if (!strcmp(enginelist[i], ELM_SOFTWARE_FB))
3078 tmp_sd.ee = ecore_evas_fb_new(NULL, 0, 1, 1);
3079 else if (!strcmp(enginelist[i], ELM_BUFFER))
3080 tmp_sd.ee = ecore_evas_buffer_new(1, 1);
3081 else if (!strcmp(enginelist[i], ELM_SOFTWARE_PSL1GHT))
3082 tmp_sd.ee = ecore_evas_psl1ght_new(NULL, 1, 1);
3083 else if (!strcmp(enginelist[i], ELM_DRM))
3084 tmp_sd.ee = ecore_evas_drm_new(NULL, 0, 0, 0, 1, 1);
3085 else if (!strncmp(enginelist[i], "shot:", 5))
3087 tmp_sd.ee = ecore_evas_buffer_new(1, 1);
3088 ecore_evas_manual_render_set(tmp_sd.ee, EINA_TRUE);
3089 tmp_sd.shot.info = eina_stringshare_add(ENGINE_GET() + 5);
3091 engine = enginelist[i];
3092 if (tmp_sd.ee) break;
3099 ERR("Cannot create window.");
3104 eo_do(obj, eo_parent_set(ecore_evas_get(tmp_sd.ee)));
3105 eo_do_super(obj, MY_CLASS, eo_constructor());
3107 evas_obj_type_set(MY_CLASS_NAME_LEGACY),
3108 evas_obj_smart_callbacks_descriptions_set(_smart_callbacks));
3110 if (getenv("ELM_FIRST_FRAME"))
3111 evas_event_callback_add(ecore_evas_get(tmp_sd.ee), EVAS_CALLBACK_RENDER_POST,
3112 _elm_win_first_frame_do, getenv("ELM_FIRST_FRAME"));
3114 /* copying possibly altered fields back */
3115 #define SD_CPY(_field) \
3118 sd->_field = tmp_sd._field; \
3126 if ((trap) && (trap->add))
3127 sd->trap_data = trap->add(obj);
3129 /* complementary actions, which depend on final smart data
3131 if (type == ELM_WIN_INLINED_IMAGE)
3132 _win_inlined_image_set(sd);
3133 #ifdef HAVE_ELEMENTARY_X
3134 else if ((engine) &&
3135 ((!strcmp(engine, ELM_SOFTWARE_X11)) ||
3136 (!strcmp(engine, ELM_OPENGL_X11))))
3138 sd->x.client_message_handler = ecore_event_handler_add
3139 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, obj);
3140 sd->x.property_handler = ecore_event_handler_add
3141 (ECORE_X_EVENT_WINDOW_PROPERTY, _elm_win_property_change, obj);
3144 else if ((engine) && (!strncmp(engine, "shot:", 5)))
3147 sd->kbdmode = ELM_WIN_KEYBOARD_UNKNOWN;
3148 sd->indmode = ELM_WIN_INDICATOR_UNKNOWN;
3150 #ifdef HAVE_ELEMENTARY_X
3151 _internal_elm_win_xwindow_get(sd);
3154 ecore_x_io_error_handler_set(_elm_x_io_err, NULL);
3158 #ifdef HAVE_ELEMENTARY_WAYLAND
3159 if ((ENGINE_COMPARE(ELM_WAYLAND_SHM)) || (ENGINE_COMPARE(ELM_WAYLAND_EGL)))
3160 _elm_win_wlwindow_get(sd);
3163 if ((_elm_config->bgpixmap)
3164 #ifdef HAVE_ELEMENTARY_X
3166 (((sd->x.xwin) && (!ecore_x_screen_is_composited(0))) ||
3171 TRAP(sd, avoid_damage_set, ECORE_EVAS_AVOID_DAMAGE_EXPOSE);
3172 // bg pixmap done by x - has other issues like can be redrawn by x before it
3173 // is filled/ready by app
3174 // TRAP(sd, avoid_damage_set, ECORE_EVAS_AVOID_DAMAGE_BUILT_IN);
3177 sd->parent = parent;
3178 sd->modal_count = 0;
3181 evas_object_event_callback_add
3182 (sd->parent, EVAS_CALLBACK_DEL, _elm_win_on_parent_del, obj);
3184 sd->evas = ecore_evas_get(sd->ee);
3186 evas_object_color_set(obj, 0, 0, 0, 0);
3187 evas_object_move(obj, 0, 0);
3188 evas_object_resize(obj, 1, 1);
3189 evas_object_layer_set(obj, 50);
3190 evas_object_pass_events_set(obj, EINA_TRUE);
3192 if (type == ELM_WIN_INLINED_IMAGE)
3193 elm_widget_parent2_set(obj, parent);
3195 /* use own version of ecore_evas_object_associate() that does TRAP() */
3196 ecore_evas_data_set(sd->ee, "elm_win", obj);
3198 evas_object_event_callback_add
3199 (obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
3200 _elm_win_obj_callback_changed_size_hints, obj);
3202 evas_object_intercept_raise_callback_add
3203 (obj, _elm_win_obj_intercept_raise, obj);
3204 evas_object_intercept_lower_callback_add
3205 (obj, _elm_win_obj_intercept_lower, obj);
3206 evas_object_intercept_stack_above_callback_add
3207 (obj, _elm_win_obj_intercept_stack_above, obj);
3208 evas_object_intercept_stack_below_callback_add
3209 (obj, _elm_win_obj_intercept_stack_below, obj);
3210 evas_object_intercept_layer_set_callback_add
3211 (obj, _elm_win_obj_intercept_layer_set, obj);
3212 evas_object_intercept_show_callback_add
3213 (obj, _elm_win_obj_intercept_show, obj);
3215 TRAP(sd, name_class_set, name, _elm_appname);
3216 ecore_evas_callback_delete_request_set(sd->ee, _elm_win_delete_request);
3217 ecore_evas_callback_resize_set(sd->ee, _elm_win_resize);
3218 ecore_evas_callback_mouse_in_set(sd->ee, _elm_win_mouse_in);
3219 ecore_evas_callback_focus_in_set(sd->ee, _elm_win_focus_in);
3220 ecore_evas_callback_focus_out_set(sd->ee, _elm_win_focus_out);
3221 ecore_evas_callback_move_set(sd->ee, _elm_win_move);
3222 ecore_evas_callback_state_change_set(sd->ee, _elm_win_state_change);
3223 evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _elm_win_cb_hide, NULL);
3224 evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _elm_win_cb_show, NULL);
3226 evas_image_cache_set(sd->evas, (_elm_config->image_cache * 1024));
3227 evas_font_cache_set(sd->evas, (_elm_config->font_cache * 1024));
3229 EINA_LIST_FOREACH(_elm_config->font_dirs, l, fontpath)
3230 evas_font_path_append(sd->evas, fontpath);
3232 if (!_elm_config->font_hinting)
3233 evas_font_hinting_set(sd->evas, EVAS_FONT_HINTING_NONE);
3234 else if (_elm_config->font_hinting == 1)
3235 evas_font_hinting_set(sd->evas, EVAS_FONT_HINTING_AUTO);
3236 else if (_elm_config->font_hinting == 2)
3237 evas_font_hinting_set(sd->evas, EVAS_FONT_HINTING_BYTECODE);
3239 #ifdef HAVE_ELEMENTARY_X
3240 _elm_win_xwin_update(sd);
3243 _elm_win_list = eina_list_append(_elm_win_list, obj);
3246 if ((engine) && ((!strcmp(engine, ELM_SOFTWARE_FB)) || (!strcmp(engine, ELM_DRM))))
3248 TRAP(sd, fullscreen_set, 1);
3250 else if ((type != ELM_WIN_INLINED_IMAGE) &&
3252 ((!strcmp(engine, ELM_WAYLAND_SHM) ||
3253 (!strcmp(engine, ELM_WAYLAND_EGL))))))
3254 _elm_win_frame_add(sd, "default");
3256 if (_elm_config->focus_highlight_enable)
3257 elm_win_focus_highlight_enabled_set(obj, EINA_TRUE);
3258 if (_elm_config->focus_highlight_animate)
3259 elm_win_focus_highlight_animate_set(obj, EINA_TRUE);
3262 Evas_Modifier_Mask mask = evas_key_modifier_mask_get(sd->evas, "Control");
3263 evas_object_event_callback_add
3264 (obj, EVAS_CALLBACK_KEY_DOWN, _debug_key_down, NULL);
3266 if (evas_object_key_grab(obj, "F12", mask, 0, EINA_TRUE))
3267 INF("Ctrl+F12 key combination exclusive for dot tree generation\n");
3269 ERR("failed to grab F12 key to elm widgets (dot) tree generation");
3272 if ((_elm_config->softcursor_mode == ELM_SOFTCURSOR_MODE_ON) ||
3273 ((_elm_config->softcursor_mode == ELM_SOFTCURSOR_MODE_AUTO) &&
3275 ((!strcmp(engine, ELM_SOFTWARE_FB)) || (!strcmp(engine, ELM_DRM))))))
3278 Evas_Coord mw = 1, mh = 1, hx = 0, hy = 0;
3280 sd->pointer.obj = o = edje_object_add(ecore_evas_get(tmp_sd.ee));
3281 _elm_theme_object_set(obj, o, "pointer", "base", "default");
3282 edje_object_size_min_calc(o, &mw, &mh);
3283 evas_object_resize(o, mw, mh);
3284 edje_object_part_geometry_get(o, "elm.swallow.hotspot",
3285 &hx, &hy, NULL, NULL);
3286 sd->pointer.hot_x = hx;
3287 sd->pointer.hot_y = hy;
3288 evas_object_show(o);
3289 ecore_evas_object_cursor_set(tmp_sd.ee, o, EVAS_LAYER_MAX, hx, hy);
3291 else if (_elm_config->softcursor_mode == ELM_SOFTCURSOR_MODE_OFF)
3296 sd->wm_rot.wm_supported = ecore_evas_wm_rotation_supported_get(sd->ee);
3297 sd->wm_rot.preferred_rot = -1; // it means that elm_win doesn't use preferred rotation.
3299 sd->layout = edje_object_add(sd->evas);
3300 _elm_theme_object_set(obj, sd->layout, "win", "base", "default");
3301 sd->box = evas_object_box_add(sd->evas);
3302 evas_object_box_layout_set(sd->box, _window_layout_stack, obj, NULL);
3303 edje_object_part_swallow(sd->layout, "elm.swallow.contents", sd->box);
3304 evas_object_move(sd->layout, 0, 0);
3305 evas_object_resize(sd->layout, 1, 1);
3306 edje_object_update_hints_set(sd->layout, EINA_TRUE);
3307 evas_object_event_callback_add(sd->layout, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
3308 _elm_win_on_resize_obj_changed_size_hints, obj);
3309 evas_object_show(sd->layout);
3313 _elm_win_eo_base_constructor(Eo *obj, Elm_Win_Data *_pd EINA_UNUSED)
3316 ERR("only custom constructor can be used with '%s' class", MY_CLASS_NAME);
3319 EOLIAN static Elm_Win_Type
3320 _elm_win_type_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
3326 elm_win_util_standard_add(const char *name,
3329 Evas_Object *win, *bg;
3331 win = elm_win_add(NULL, name, ELM_WIN_BASIC);
3332 if (!win) return NULL;
3334 elm_win_title_set(win, title);
3335 bg = elm_bg_add(win);
3338 evas_object_del(win);
3341 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3342 elm_win_resize_object_add(win, bg);
3343 evas_object_show(bg);
3349 _elm_win_resize_object_add(Eo *obj, Elm_Win_Data *sd, Evas_Object *subobj)
3351 elm_widget_sub_object_add(obj, subobj);
3353 if (!evas_object_box_append(sd->box, subobj))
3354 ERR("could not append %p to box", subobj);
3358 _elm_win_resize_object_del(Eo *obj, Elm_Win_Data *sd, Evas_Object *subobj)
3360 if (!elm_widget_sub_object_del(obj, subobj))
3361 ERR("could not remove sub object %p from %p", subobj, obj);
3363 evas_object_box_remove(sd->box, subobj);
3367 _elm_win_title_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, const char *title)
3370 eina_stringshare_replace(&(sd->title), title);
3371 TRAP(sd, title_set, sd->title);
3373 edje_object_part_text_escaped_set
3374 (sd->frame_obj, "elm.text.title", sd->title);
3377 EOLIAN static const char*
3378 _elm_win_title_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
3384 _elm_win_icon_name_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, const char *icon_name)
3386 if (!icon_name) return;
3387 eina_stringshare_replace(&(sd->icon_name), icon_name);
3388 #ifdef HAVE_ELEMENTARY_X
3389 _elm_win_xwin_update(sd);
3393 EOLIAN static const char*
3394 _elm_win_icon_name_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
3396 return sd->icon_name;
3400 _elm_win_role_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, const char *role)
3403 eina_stringshare_replace(&(sd->role), role);
3404 #ifdef HAVE_ELEMENTARY_X
3405 _elm_win_xwin_update(sd);
3409 EOLIAN static const char*
3410 _elm_win_role_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
3416 _elm_win_icon_object_set(Eo *obj, Elm_Win_Data *sd, Evas_Object *icon)
3419 evas_object_event_callback_del_full
3420 (sd->icon, EVAS_CALLBACK_DEL, _elm_win_on_icon_del, obj);
3423 evas_object_event_callback_add
3424 (sd->icon, EVAS_CALLBACK_DEL, _elm_win_on_icon_del, obj);
3425 #ifdef HAVE_ELEMENTARY_X
3426 _elm_win_xwin_update(sd);
3430 EOLIAN static const Evas_Object*
3431 _elm_win_icon_object_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
3437 _elm_win_autodel_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool autodel)
3439 sd->autodel = autodel;
3442 EOLIAN static Eina_Bool
3443 _elm_win_autodel_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
3449 _elm_win_activate(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
3455 _elm_win_lower(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
3461 _elm_win_raise(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
3467 _elm_win_center(Eo *obj, Elm_Win_Data *sd, Eina_Bool h, Eina_Bool v)
3469 int win_w, win_h, screen_w, screen_h, nx, ny;
3471 if ((trap) && (trap->center) && (!trap->center(sd->trap_data, obj)))
3474 ecore_evas_screen_geometry_get(sd->ee, NULL, NULL, &screen_w, &screen_h);
3475 if ((!screen_w) || (!screen_h)) return;
3477 evas_object_geometry_get(obj, NULL, NULL, &win_w, &win_h);
3478 if ((!win_w) || (!win_h)) return;
3480 if (h) nx = win_w >= screen_w ? 0 : (screen_w / 2) - (win_w / 2);
3481 else nx = sd->screen.x;
3482 if (v) ny = win_h >= screen_h ? 0 : (screen_h / 2) - (win_h / 2);
3483 else ny = sd->screen.y;
3487 evas_object_move(obj, nx, ny);
3491 _elm_win_borderless_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool borderless)
3493 Eina_Bool need_frame = EINA_FALSE;
3495 const char *engine_name = ecore_evas_engine_name_get(sd->ee);
3496 need_frame = engine_name &&
3497 ((!strcmp(engine_name, ELM_WAYLAND_SHM)) ||
3498 (!strcmp(engine_name, ELM_WAYLAND_EGL)));
3503 _elm_win_frame_del(sd);
3508 _elm_win_frame_add(sd, "default");
3511 evas_object_show(sd->frame_obj);
3514 TRAP(sd, borderless_set, borderless);
3515 #ifdef HAVE_ELEMENTARY_X
3516 _elm_win_xwin_update(sd);
3520 EOLIAN static Eina_Bool
3521 _elm_win_borderless_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
3523 return ecore_evas_borderless_get(sd->ee);
3527 _elm_win_shaped_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool shaped)
3529 TRAP(sd, shaped_set, shaped);
3530 #ifdef HAVE_ELEMENTARY_X
3531 _elm_win_xwin_update(sd);
3535 EOLIAN static Eina_Bool
3536 _elm_win_shaped_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
3538 return ecore_evas_shaped_get(sd->ee);
3542 _elm_win_alpha_set(Eo *obj, Elm_Win_Data *sd, Eina_Bool enabled)
3546 evas_object_image_alpha_set(sd->img_obj, enabled);
3547 ecore_evas_alpha_set(sd->ee, enabled);
3551 #ifdef HAVE_ELEMENTARY_X
3556 if (!ecore_x_screen_is_composited(0))
3557 elm_win_shaped_set(obj, enabled);
3559 TRAP(sd, alpha_set, enabled);
3562 TRAP(sd, alpha_set, enabled);
3563 _elm_win_xwin_update(sd);
3567 TRAP(sd, alpha_set, enabled);
3571 EOLIAN static Eina_Bool
3572 _elm_win_alpha_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
3576 return evas_object_image_alpha_get(sd->img_obj);
3580 return ecore_evas_alpha_get(sd->ee);
3587 _elm_win_override_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool override)
3589 TRAP(sd, override_set, override);
3590 #ifdef HAVE_ELEMENTARY_X
3591 _elm_win_xwin_update(sd);
3595 EOLIAN static Eina_Bool
3596 _elm_win_override_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
3598 return ecore_evas_override_get(sd->ee);
3602 _elm_win_fullscreen_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool fullscreen)
3604 // YYY: handle if sd->img_obj
3605 if (ENGINE_COMPARE(ELM_SOFTWARE_FB) ||
3606 ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE) ||
3607 ENGINE_COMPARE(ELM_DRM))
3609 // these engines... can ONLY be fullscreen
3614 // sd->fullscreen = fullscreen;
3616 Eina_Bool need_frame = EINA_FALSE;
3618 const char *engine_name = ecore_evas_engine_name_get(sd->ee);
3619 need_frame = engine_name &&
3620 ((!strcmp(engine_name, ELM_WAYLAND_SHM)) ||
3621 (!strcmp(engine_name, ELM_WAYLAND_EGL)));
3623 TRAP(sd, fullscreen_set, fullscreen);
3628 _elm_win_frame_del(sd);
3633 _elm_win_frame_add(sd, "default");
3636 evas_object_show(sd->frame_obj);
3638 #ifdef HAVE_ELEMENTARY_X
3639 _elm_win_xwin_update(sd);
3644 EOLIAN static Eina_Bool
3645 _elm_win_fullscreen_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
3647 const char* engine_name = ecore_evas_engine_name_get(sd->ee);
3650 ((!strcmp(engine_name, ELM_SOFTWARE_FB)) ||
3651 (!strcmp(engine_name, ELM_SOFTWARE_16_WINCE)) ||
3652 (!strcmp(engine_name, ELM_DRM))))
3654 // these engines... can ONLY be fullscreen
3659 return sd->fullscreen;
3666 _dbus_menu_set(Eina_Bool dbus_connect, void *data)
3668 ELM_WIN_DATA_GET_OR_RETURN(data, sd);
3672 DBG("Setting menu to D-Bus");
3673 edje_object_part_unswallow(sd->layout, sd->main_menu);
3674 edje_object_signal_emit(sd->layout, "elm,action,hide_menu", "elm");
3675 _elm_menu_menu_bar_hide(sd->main_menu);
3679 DBG("Setting menu to local mode");
3680 edje_object_part_swallow(sd->layout, "elm.swallow.menu", sd->main_menu);
3681 edje_object_signal_emit(sd->layout, "elm,action,show_menu", "elm");
3682 evas_object_show(sd->main_menu);
3686 EOLIAN static Evas_Object *
3687 _elm_win_main_menu_get(Eo *obj, Elm_Win_Data *sd)
3689 Eina_Bool use_dbus = EINA_FALSE;
3691 if (sd->main_menu) goto end;
3693 sd->main_menu = elm_menu_add(obj);
3694 _elm_menu_menu_bar_set(sd->main_menu, EINA_TRUE);
3696 #ifdef HAVE_ELEMENTARY_X
3697 if (!_elm_config->disable_external_menu && sd->x.xwin) use_dbus = EINA_TRUE;
3700 #ifdef HAVE_ELEMENTARY_X
3701 if (use_dbus && _elm_dbus_menu_register(sd->main_menu))
3703 _elm_dbus_menu_app_menu_register(sd->x.xwin, sd->main_menu,
3704 _dbus_menu_set, obj);
3708 _dbus_menu_set(EINA_FALSE, obj);
3711 return sd->main_menu;
3715 _elm_win_maximized_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool maximized)
3717 _elm_win_frame_maximized_state_update(sd, maximized);
3718 // YYY: handle if sd->img_obj
3719 TRAP(sd, maximized_set, maximized);
3720 #ifdef HAVE_ELEMENTARY_X
3721 _elm_win_xwin_update(sd);
3725 EOLIAN static Eina_Bool
3726 _elm_win_maximized_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
3728 return sd->maximized;
3732 _elm_win_iconified_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool iconified)
3734 // sd->iconified = iconified;
3735 TRAP(sd, iconified_set, iconified);
3736 #ifdef HAVE_ELEMENTARY_X
3737 _elm_win_xwin_update(sd);
3741 EOLIAN static Eina_Bool
3742 _elm_win_iconified_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
3744 return sd->iconified;
3748 _elm_win_withdrawn_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool withdrawn)
3750 // sd->withdrawn = withdrawn;
3751 TRAP(sd, withdrawn_set, withdrawn);
3752 #ifdef HAVE_ELEMENTARY_X
3753 _elm_win_xwin_update(sd);
3757 EOLIAN static Eina_Bool
3758 _elm_win_withdrawn_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
3760 return sd->withdrawn;
3764 _elm_win_available_profiles_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, const char **profiles, unsigned int count)
3766 Eina_Bool found = EINA_FALSE;
3768 _elm_win_available_profiles_del(sd);
3769 if ((profiles) && (count >= 1))
3771 sd->profile.available_list = calloc(count, sizeof(char *));
3772 if (sd->profile.available_list)
3774 if (!sd->profile.name) found = EINA_TRUE;
3777 for (i = 0; i < count; i++)
3779 sd->profile.available_list[i] = eina_stringshare_add(profiles[i]);
3781 /* check to see if a given array has a current profile of elm_win */
3782 if ((sd->profile.name) &&
3783 (!strcmp(sd->profile.name, profiles[i])))
3788 sd->profile.count = count;
3792 if (ecore_evas_window_profile_supported_get(sd->ee))
3794 ecore_evas_window_available_profiles_set(sd->ee,
3795 sd->profile.available_list,
3798 /* current profile of elm_win is wrong, change profile */
3799 if ((sd->profile.available_list) && (!found))
3801 eina_stringshare_replace(&(sd->profile.name),
3802 sd->profile.available_list[0]);
3803 ecore_evas_window_profile_set(sd->ee, sd->profile.name);
3809 if (sd->profile.available_list)
3810 _elm_win_profile_update(sd);
3814 EOLIAN static Eina_Bool
3815 _elm_win_available_profiles_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, char ***profiles, unsigned int *count)
3817 if (ecore_evas_window_profile_supported_get(sd->ee))
3819 return ecore_evas_window_available_profiles_get(sd->ee,
3825 if (profiles) *profiles = (char **)sd->profile.available_list;
3826 if (count) *count = sd->profile.count;
3832 _elm_win_profile_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, const char *profile)
3834 /* check to see if a given profile is present in an available profiles */
3835 if ((profile) && (sd->profile.available_list))
3837 Eina_Bool found = EINA_FALSE;
3839 for (i = 0; i < sd->profile.count; i++)
3841 if (!strcmp(profile,
3842 sd->profile.available_list[i]))
3851 if (ecore_evas_window_profile_supported_get(sd->ee))
3853 if (!profile) _elm_win_profile_del(sd);
3854 ecore_evas_window_profile_set(sd->ee, profile);
3858 if (_internal_elm_win_profile_set(sd, profile))
3859 _elm_win_profile_update(sd);
3863 EOLIAN static const char*
3864 _elm_win_profile_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
3866 return sd->profile.name;
3870 _elm_win_urgent_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool urgent)
3872 sd->urgent = urgent;
3873 TRAP(sd, urgent_set, urgent);
3874 #ifdef HAVE_ELEMENTARY_X
3875 _elm_win_xwin_update(sd);
3879 EOLIAN static Eina_Bool
3880 _elm_win_urgent_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
3886 _elm_win_demand_attention_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool demand_attention)
3888 sd->demand_attention = demand_attention;
3889 TRAP(sd, demand_attention_set, demand_attention);
3890 #ifdef HAVE_ELEMENTARY_X
3891 _elm_win_xwin_update(sd);
3895 EOLIAN static Eina_Bool
3896 _elm_win_demand_attention_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
3898 return sd->demand_attention;
3902 _elm_win_modal_set(Eo *obj, Elm_Win_Data *sd, Eina_Bool modal)
3904 if (sd->modal_count) return;
3907 Evas_Object *current;
3909 if ((modal) && (!sd->modal) && (evas_object_visible_get(obj)))
3911 INCREMENT_MODALITY()
3913 else if ((!modal) && (sd->modal) && (evas_object_visible_get(obj)))
3915 DECREMENT_MODALITY()
3919 TRAP(sd, modal_set, modal);
3920 #ifdef HAVE_ELEMENTARY_X
3921 _elm_win_xwin_update(sd);
3925 EOLIAN static Eina_Bool
3926 _elm_win_modal_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
3932 _elm_win_aspect_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, double aspect)
3934 sd->aspect = aspect;
3935 TRAP(sd, aspect_set, aspect);
3936 #ifdef HAVE_ELEMENTARY_X
3937 _elm_win_xwin_update(sd);
3941 EOLIAN static double
3942 _elm_win_aspect_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
3948 _elm_win_size_base_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, int w, int h)
3950 sd->size_base_w = w;
3951 sd->size_base_h = h;
3952 TRAP(sd, size_base_set, w, h);
3953 #ifdef HAVE_ELEMENTARY_X
3954 _elm_win_xwin_update(sd);
3959 _elm_win_size_base_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, int *w, int *h)
3961 if (w) *w = sd->size_base_w;
3962 if (w) *h = sd->size_base_h;
3966 _elm_win_size_step_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, int w, int h)
3968 sd->size_step_w = w;
3969 sd->size_step_h = h;
3970 TRAP(sd, size_step_set, w, h);
3971 #ifdef HAVE_ELEMENTARY_X
3972 _elm_win_xwin_update(sd);
3977 _elm_win_size_step_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, int *w, int *h)
3979 if (w) *w = sd->size_step_w;
3980 if (w) *h = sd->size_step_h;
3984 _elm_win_layer_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, int layer)
3986 TRAP(sd, layer_set, layer);
3987 #ifdef HAVE_ELEMENTARY_X
3988 _elm_win_xwin_update(sd);
3993 _elm_win_layer_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
3995 return ecore_evas_layer_get(sd->ee);
3999 elm_win_norender_push(Evas_Object *obj)
4002 ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4005 if (sd->norender == 1) ecore_evas_manual_render_set(sd->ee, EINA_TRUE);
4009 elm_win_norender_pop(Evas_Object *obj)
4012 ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4014 if (sd->norender <= 0) return;
4016 if (sd->norender == 0) ecore_evas_manual_render_set(sd->ee, EINA_FALSE);
4020 elm_win_norender_get(Evas_Object *obj)
4022 ELM_WIN_CHECK(obj) - 1;
4023 ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, -1);
4024 return sd->norender;
4028 elm_win_render(Evas_Object *obj)
4031 ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4032 ecore_evas_manual_render(sd->ee);
4036 _win_rotation_degree_check(int rotation)
4038 if ((rotation > 360) || (rotation < 0))
4040 WRN("Rotation degree should be 0 ~ 360 (passed degree: %d)", rotation);
4042 if (rotation < 0) rotation += 360;
4048 * This API resizes the internal window(ex: X window) and evas_output.
4049 * But this does not resize the elm window object and its contents.
4052 _win_rotate(Evas_Object *obj, Elm_Win_Data *sd, int rotation, Eina_Bool resize)
4054 rotation = _win_rotation_degree_check(rotation);
4055 if (sd->rot == rotation) return;
4057 if (resize) TRAP(sd, rotation_with_resize_set, rotation);
4058 else TRAP(sd, rotation_set, rotation);
4059 evas_object_size_hint_min_set(obj, -1, -1);
4060 evas_object_size_hint_max_set(obj, -1, -1);
4061 _elm_win_resize_objects_eval(obj);
4062 #ifdef HAVE_ELEMENTARY_X
4063 _elm_win_xwin_update(sd);
4065 _elm_win_frame_obj_update(sd);
4066 elm_widget_orientation_set(obj, rotation);
4067 evas_object_smart_callback_call(obj, SIG_ROTATION_CHANGED, NULL);
4071 _elm_win_rotation_set(Eo *obj, Elm_Win_Data *sd, int rotation)
4073 _win_rotate(obj, sd, rotation, EINA_FALSE);
4077 * This API does not resize the internal window (ex: X window).
4078 * But this resizes evas_output, elm window, and its contents.
4081 _elm_win_rotation_with_resize_set(Eo *obj, Elm_Win_Data *sd, int rotation)
4083 _win_rotate(obj, sd, rotation, EINA_TRUE);
4087 _elm_win_rotation_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
4092 EOLIAN static Eina_Bool
4093 _elm_win_wm_rotation_supported_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
4095 return sd->wm_rot.wm_supported;
4098 /* This will unset a preferred rotation, if given preferred rotation is '-1'.
4101 elm_win_wm_rotation_preferred_rotation_set(const Evas_Object *obj,
4105 eo_do((Eo *) obj, elm_obj_win_wm_preferred_rotation_set(rotation));
4109 _elm_win_wm_preferred_rotation_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, int rotation)
4113 if (!sd->wm_rot.use)
4114 sd->wm_rot.use = EINA_TRUE;
4116 // '-1' means that elm_win doesn't use preferred rotation.
4120 rot = _win_rotation_degree_check(rotation);
4122 if (sd->wm_rot.preferred_rot == rot) return;
4123 sd->wm_rot.preferred_rot = rot;
4125 ecore_evas_wm_rotation_preferred_rotation_set(sd->ee, rot);
4129 _elm_win_wm_preferred_rotation_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
4131 return sd->wm_rot.preferred_rot;
4135 _elm_win_wm_available_rotations_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, const int *rotations, unsigned int count)
4140 if (!sd->wm_rot.use)
4141 sd->wm_rot.use = EINA_TRUE;
4143 ELM_SAFE_FREE(sd->wm_rot.rots, free);
4144 sd->wm_rot.count = 0;
4148 sd->wm_rot.rots = calloc(count, sizeof(int));
4149 if (!sd->wm_rot.rots) return;
4150 for (i = 0; i < count; i++)
4152 r = _win_rotation_degree_check(rotations[i]);
4153 sd->wm_rot.rots[i] = r;
4157 sd->wm_rot.count = count;
4159 ecore_evas_wm_rotation_available_rotations_set(sd->ee,
4164 EOLIAN static Eina_Bool
4165 _elm_win_wm_available_rotations_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, int **rotations, unsigned int *count)
4167 if (!sd->wm_rot.use) return EINA_FALSE;
4169 if (sd->wm_rot.count > 0)
4173 *rotations = calloc(sd->wm_rot.count, sizeof(int));
4178 sizeof(int) * sd->wm_rot.count);
4183 if (count) *count = sd->wm_rot.count;
4188 _elm_win_wm_manual_rotation_done_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool set)
4190 if (!sd->wm_rot.use) return;
4191 ecore_evas_wm_rotation_manual_rotation_done_set(sd->ee, set);
4194 EOLIAN static Eina_Bool
4195 _elm_win_wm_manual_rotation_done_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
4197 if (!sd->wm_rot.use) return EINA_FALSE;
4198 return ecore_evas_wm_rotation_manual_rotation_done_get(sd->ee);
4202 _elm_win_wm_manual_rotation_done(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
4204 if (!sd->wm_rot.use) return;
4205 ecore_evas_wm_rotation_manual_rotation_done(sd->ee);
4209 _elm_win_sticky_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool sticky)
4211 // sd->sticky = sticky;
4212 TRAP(sd, sticky_set, sticky);
4213 #ifdef HAVE_ELEMENTARY_X
4214 _elm_win_xwin_update(sd);
4218 EOLIAN static Eina_Bool
4219 _elm_win_sticky_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
4225 _elm_win_keyboard_mode_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Elm_Win_Keyboard_Mode mode)
4227 if (mode == sd->kbdmode) return;
4228 #ifdef HAVE_ELEMENTARY_X
4229 _internal_elm_win_xwindow_get(sd);
4232 #ifdef HAVE_ELEMENTARY_X
4234 ecore_x_e_virtual_keyboard_state_set
4235 (sd->x.xwin, (Ecore_X_Virtual_Keyboard_State)sd->kbdmode);
4239 EOLIAN static Elm_Win_Keyboard_Mode
4240 _elm_win_keyboard_mode_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
4246 _elm_win_keyboard_win_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool is_keyboard)
4248 #ifdef HAVE_ELEMENTARY_X
4249 _internal_elm_win_xwindow_get(sd);
4251 ecore_x_e_virtual_keyboard_set(sd->x.xwin, is_keyboard);
4257 EOLIAN static Eina_Bool
4258 _elm_win_keyboard_win_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
4260 #ifdef HAVE_ELEMENTARY_X
4261 _internal_elm_win_xwindow_get(sd);
4262 if (sd->x.xwin) return ecore_x_e_virtual_keyboard_get(sd->x.xwin);
4268 _elm_win_indicator_mode_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Elm_Win_Indicator_Mode mode)
4270 if (mode == sd->indmode) return;
4271 #ifdef HAVE_ELEMENTARY_X
4272 _internal_elm_win_xwindow_get(sd);
4275 #ifdef HAVE_ELEMENTARY_X
4278 if (sd->indmode == ELM_WIN_INDICATOR_SHOW)
4279 ecore_x_e_illume_indicator_state_set
4280 (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_STATE_ON);
4281 else if (sd->indmode == ELM_WIN_INDICATOR_HIDE)
4282 ecore_x_e_illume_indicator_state_set
4283 (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_STATE_OFF);
4286 evas_object_smart_callback_call(obj, SIG_INDICATOR_PROP_CHANGED, NULL);
4289 EOLIAN static Elm_Win_Indicator_Mode
4290 _elm_win_indicator_mode_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
4296 _elm_win_indicator_opacity_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Elm_Win_Indicator_Opacity_Mode mode)
4298 if (mode == sd->ind_o_mode) return;
4299 sd->ind_o_mode = mode;
4300 #ifdef HAVE_ELEMENTARY_X
4301 _internal_elm_win_xwindow_get(sd);
4304 if (sd->ind_o_mode == ELM_WIN_INDICATOR_OPAQUE)
4305 ecore_x_e_illume_indicator_opacity_set
4306 (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_OPAQUE);
4307 else if (sd->ind_o_mode == ELM_WIN_INDICATOR_TRANSLUCENT)
4308 ecore_x_e_illume_indicator_opacity_set
4309 (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_TRANSLUCENT);
4310 else if (sd->ind_o_mode == ELM_WIN_INDICATOR_TRANSPARENT)
4311 ecore_x_e_illume_indicator_opacity_set
4312 (sd->x.xwin, ECORE_X_ILLUME_INDICATOR_TRANSPARENT);
4315 evas_object_smart_callback_call(obj, SIG_INDICATOR_PROP_CHANGED, NULL);
4318 EOLIAN static Elm_Win_Indicator_Opacity_Mode
4319 _elm_win_indicator_opacity_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
4321 return sd->ind_o_mode;
4325 _elm_win_screen_position_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, int *x, int *y)
4327 if (x) *x = sd->screen.x;
4328 if (y) *y = sd->screen.y;
4331 EOLIAN static Eina_Bool
4332 _elm_win_focus_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
4334 return ecore_evas_focus_get(sd->ee);
4338 _elm_win_screen_constrain_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool constrain)
4340 sd->constrain = !!constrain;
4343 EOLIAN static Eina_Bool
4344 _elm_win_screen_constrain_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
4346 return sd->constrain;
4350 _elm_win_screen_size_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, int *x, int *y, int *w, int *h)
4352 ecore_evas_screen_geometry_get(sd->ee, x, y, w, h);
4356 _elm_win_screen_dpi_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, int *xdpi, int *ydpi)
4358 ecore_evas_screen_dpi_get(sd->ee, xdpi, ydpi);
4362 _elm_win_conformant_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool conformant)
4364 #ifdef HAVE_ELEMENTARY_X
4365 _internal_elm_win_xwindow_get(sd);
4367 ecore_x_e_illume_conformant_set(sd->x.xwin, conformant);
4373 EOLIAN static Eina_Bool
4374 _elm_win_conformant_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
4376 #ifdef HAVE_ELEMENTARY_X
4377 _internal_elm_win_xwindow_get(sd);
4379 return ecore_x_e_illume_conformant_get(sd->x.xwin);
4386 _elm_win_quickpanel_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool quickpanel)
4388 #ifdef HAVE_ELEMENTARY_X
4389 _internal_elm_win_xwindow_get(sd);
4392 ecore_x_e_illume_quickpanel_set(sd->x.xwin, quickpanel);
4395 Ecore_X_Window_State states[2];
4397 states[0] = ECORE_X_WINDOW_STATE_SKIP_TASKBAR;
4398 states[1] = ECORE_X_WINDOW_STATE_SKIP_PAGER;
4399 ecore_x_netwm_window_state_set(sd->x.xwin, states, 2);
4400 ecore_x_icccm_hints_set(sd->x.xwin, 0, 0, 0, 0, 0, 0, 0);
4408 EOLIAN static Eina_Bool
4409 _elm_win_quickpanel_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
4411 #ifdef HAVE_ELEMENTARY_X
4412 _internal_elm_win_xwindow_get(sd);
4414 return ecore_x_e_illume_quickpanel_get(sd->x.xwin);
4421 _elm_win_quickpanel_priority_major_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, int priority)
4423 #ifdef HAVE_ELEMENTARY_X
4424 _internal_elm_win_xwindow_get(sd);
4426 ecore_x_e_illume_quickpanel_priority_major_set(sd->x.xwin, priority);
4433 _elm_win_quickpanel_priority_major_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
4435 #ifdef HAVE_ELEMENTARY_X
4436 _internal_elm_win_xwindow_get(sd);
4438 return ecore_x_e_illume_quickpanel_priority_major_get(sd->x.xwin);
4445 _elm_win_quickpanel_priority_minor_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, int priority)
4447 #ifdef HAVE_ELEMENTARY_X
4448 _internal_elm_win_xwindow_get(sd);
4450 ecore_x_e_illume_quickpanel_priority_minor_set(sd->x.xwin, priority);
4457 _elm_win_quickpanel_priority_minor_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
4459 #ifdef HAVE_ELEMENTARY_X
4460 _internal_elm_win_xwindow_get(sd);
4462 return ecore_x_e_illume_quickpanel_priority_minor_get(sd->x.xwin);
4469 _elm_win_quickpanel_zone_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, int zone)
4471 #ifdef HAVE_ELEMENTARY_X
4472 _internal_elm_win_xwindow_get(sd);
4474 ecore_x_e_illume_quickpanel_zone_set(sd->x.xwin, zone);
4481 _elm_win_quickpanel_zone_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
4483 #ifdef HAVE_ELEMENTARY_X
4484 _internal_elm_win_xwindow_get(sd);
4486 return ecore_x_e_illume_quickpanel_zone_get(sd->x.xwin);
4493 _elm_win_prop_focus_skip_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool skip)
4495 sd->skip_focus = skip;
4496 TRAP(sd, focus_skip_set, skip);
4500 _elm_win_illume_command_send(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Elm_Illume_Command command, void *params)
4504 #ifdef HAVE_ELEMENTARY_X
4505 _internal_elm_win_xwindow_get(sd);
4510 case ELM_ILLUME_COMMAND_FOCUS_BACK:
4511 ecore_x_e_illume_focus_back_send(sd->x.xwin);
4514 case ELM_ILLUME_COMMAND_FOCUS_FORWARD:
4515 ecore_x_e_illume_focus_forward_send(sd->x.xwin);
4518 case ELM_ILLUME_COMMAND_FOCUS_HOME:
4519 ecore_x_e_illume_focus_home_send(sd->x.xwin);
4522 case ELM_ILLUME_COMMAND_CLOSE:
4523 ecore_x_e_illume_close_send(sd->x.xwin);
4535 EOLIAN static Evas_Object*
4536 _elm_win_inlined_image_object_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
4542 _elm_win_focus_highlight_enabled_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool enabled)
4544 enabled = !!enabled;
4545 if (sd->focus_highlight.enabled == enabled)
4548 sd->focus_highlight.enabled = enabled;
4550 if (sd->focus_highlight.enabled)
4551 _elm_win_focus_highlight_init(sd);
4553 _elm_win_focus_highlight_shutdown(sd);
4556 EOLIAN static Eina_Bool
4557 _elm_win_focus_highlight_enabled_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
4559 return sd->focus_highlight.enabled;
4562 EOLIAN static Eina_Bool
4563 _elm_win_elm_widget_theme_apply(Eo *obj, Elm_Win_Data *sd)
4565 Eina_Bool int_ret = EINA_FALSE;
4566 eo_do_super(obj, MY_CLASS, int_ret = elm_obj_widget_theme_apply());
4567 if (!int_ret) return EINA_TRUE;
4569 sd->focus_highlight.theme_changed = EINA_TRUE;
4570 _elm_win_focus_highlight_reconfigure_job_start(sd);
4576 _elm_win_focus_highlight_style_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, const char *style)
4578 eina_stringshare_replace(&sd->focus_highlight.style, style);
4579 sd->focus_highlight.theme_changed = EINA_TRUE;
4580 _elm_win_focus_highlight_reconfigure_job_start(sd);
4583 EOLIAN static const char*
4584 _elm_win_focus_highlight_style_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
4586 return sd->focus_highlight.style;
4590 _elm_win_focus_highlight_animate_set(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, Eina_Bool animate)
4592 animate = !!animate;
4593 if (sd->focus_highlight.animate == animate)
4596 sd->focus_highlight.animate = animate;
4597 sd->focus_highlight.theme_changed = EINA_TRUE;
4598 _elm_win_focus_highlight_reconfigure_job_start(sd);
4601 EOLIAN static Eina_Bool
4602 _elm_win_focus_highlight_animate_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
4604 return sd->focus_highlight.animate;
4607 EOLIAN static Eina_Bool
4608 _elm_win_socket_listen(Eo *obj EINA_UNUSED, Elm_Win_Data *sd, const char *svcname, int svcnum, Eina_Bool svcsys)
4610 if (!sd->ee) return EINA_FALSE;
4612 if (!ecore_evas_extn_socket_listen(sd->ee, svcname, svcnum, svcsys))
4618 /* windowing specific calls - shall we do this differently? */
4620 EOLIAN static Ecore_X_Window
4621 _elm_win_xwindow_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
4623 #ifdef HAVE_ELEMENTARY_X
4624 if (sd->x.xwin) return sd->x.xwin;
4625 if (sd->parent) return elm_win_xwindow_get(sd->parent);
4630 EAPI Ecore_Wl_Window *
4631 elm_win_wl_window_get(const Evas_Object *obj)
4633 if (!obj) return NULL;
4635 if ((!ENGINE_COMPARE(ELM_WAYLAND_SHM)) &&
4636 (!ENGINE_COMPARE(ELM_WAYLAND_EGL)))
4639 if (!evas_object_smart_type_check_ptr(obj, MY_CLASS_NAME_LEGACY))
4641 Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
4642 return _elm_ee_wlwin_get(ee);
4645 ELM_WIN_CHECK(obj) NULL;
4646 Ecore_Wl_Window *ret = NULL;
4647 eo_do((Eo *) obj, ret = elm_obj_win_wl_window_get());
4651 EOLIAN static Ecore_Wl_Window*
4652 _elm_win_wl_window_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
4654 #if HAVE_ELEMENTARY_WAYLAND
4655 if (sd->wl.win) return sd->wl.win;
4656 if (sd->parent) return elm_win_wl_window_get(sd->parent);
4664 elm_win_trap_set(const Elm_Win_Trap *t)
4666 DBG("old %p, new %p", trap, t);
4668 if ((t) && (t->version != ELM_WIN_TRAP_VERSION))
4670 CRI("trying to set a trap version %lu while %lu was expected!",
4671 t->version, ELM_WIN_TRAP_VERSION);
4680 elm_win_floating_mode_set(Evas_Object *obj, Eina_Bool floating)
4683 ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
4685 floating = !!floating;
4686 if (floating == sd->floating) return;
4687 sd->floating = floating;
4688 #ifdef HAVE_ELEMENTARY_X
4689 _internal_elm_win_xwindow_get(sd);
4693 ecore_x_e_illume_window_state_set
4694 (sd->x.xwin, ECORE_X_ILLUME_WINDOW_STATE_FLOATING);
4696 ecore_x_e_illume_window_state_set
4697 (sd->x.xwin, ECORE_X_ILLUME_WINDOW_STATE_NORMAL);
4703 elm_win_floating_mode_get(const Evas_Object *obj)
4705 ELM_WIN_CHECK(obj) EINA_FALSE;
4706 ELM_WIN_DATA_GET_OR_RETURN_VAL(obj, sd, EINA_FALSE);
4708 return sd->floating;
4711 EOLIAN static Ecore_Window
4712 _elm_win_window_id_get(Eo *obj EINA_UNUSED, Elm_Win_Data *sd)
4714 if ((ENGINE_COMPARE(ELM_WAYLAND_SHM)) || (ENGINE_COMPARE(ELM_WAYLAND_EGL)))
4716 #if HAVE_ELEMENTARY_WAYLAND
4717 if (sd->wl.win) return (Ecore_Window)ecore_wl_window_surface_id_get(sd->wl.win);
4720 Ecore_Wl_Window *parent;
4722 parent = elm_win_wl_window_get(sd->parent);
4723 if (parent) return (Ecore_Window)ecore_wl_window_surface_id_get(parent);
4730 #ifdef HAVE_ELEMENTARY_X
4731 _internal_elm_win_xwindow_get(sd);
4732 if (sd->x.xwin) return (Ecore_Window)sd->x.xwin;
4733 if (sd->parent) return (Ecore_Window)elm_win_xwindow_get(sd->parent);
4741 _elm_win_focus_highlight_start(Evas_Object *obj)
4743 ELM_WIN_DATA_GET(obj, sd);
4745 if (!elm_win_focus_highlight_enabled_get(obj)) return;
4746 sd->focus_highlight.cur.visible = EINA_TRUE;
4747 sd->focus_highlight.geometry_changed = EINA_TRUE;
4748 _elm_win_focus_highlight_reconfigure_job(obj);
4752 elm_win_window_id_get(const Evas_Object *obj)
4756 if (!evas_object_smart_type_check_ptr(obj, MY_CLASS_NAME_LEGACY))
4758 Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
4759 return ecore_evas_window_get(ee);
4762 ELM_WIN_CHECK(obj) 0;
4763 Ecore_Window ret = 0;
4764 eo_do((Eo *) obj, ret = elm_obj_win_window_id_get());
4769 _elm_win_class_constructor(Eo_Class *klass)
4771 evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
4774 #include "elm_win.eo.c"