1 #include <Elementary.h>
4 typedef struct _Elm_Win Elm_Win;
10 Evas_Object *parent, *win_obj, *img_obj, *frame_obj;
12 #ifdef HAVE_ELEMENTARY_X
14 Ecore_Event_Handler *client_message_handler;
16 Ecore_Job *deferred_resize_job;
17 Ecore_Job *deferred_child_eval_job;
20 Elm_Win_Keyboard_Mode kbdmode;
27 Eina_Bool autodel : 1;
28 Eina_Bool constrain : 1;
29 Eina_Bool resizing : 1;
31 int *autodel_clear, rot;
40 Evas_Object *obj, *hot_obj;
48 Eina_Bool visible : 1;
49 Eina_Bool handled : 1;
53 Ecore_Job *reconf_job;
55 Eina_Bool enabled : 1;
56 Eina_Bool changed_theme : 1;
57 Eina_Bool top_animate : 1;
58 Eina_Bool geometry_changed : 1;
62 static const char *widtype = NULL;
63 static void _elm_win_obj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
64 static void _elm_win_obj_callback_img_obj_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
65 static void _elm_win_obj_callback_parent_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
66 static void _elm_win_obj_intercept_move(void *data, Evas_Object *obj, Evas_Coord x, Evas_Coord y);
67 static void _elm_win_obj_intercept_show(void *data, Evas_Object *obj);
68 static void _elm_win_move(Ecore_Evas *ee);
69 static void _elm_win_resize(Ecore_Evas *ee);
70 static void _elm_win_delete_request(Ecore_Evas *ee);
71 static void _elm_win_resize_job(void *data);
72 #ifdef HAVE_ELEMENTARY_X
73 static void _elm_win_xwin_update(Elm_Win *win);
75 static void _elm_win_eval_subobjs(Evas_Object *obj);
76 static void _elm_win_subobj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
77 static void _elm_win_subobj_callback_changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
78 static void _elm_win_focus_highlight_init(Elm_Win *win);
79 static void _elm_win_focus_highlight_shutdown(Elm_Win *win);
80 static void _elm_win_focus_highlight_visible_set(Elm_Win *win, Eina_Bool visible);
81 static void _elm_win_focus_highlight_reconfigure_job_start(Elm_Win *win);
82 static void _elm_win_focus_highlight_reconfigure_job_stop(Elm_Win *win);
83 static void _elm_win_focus_highlight_anim_end(void *data, Evas_Object *obj, const char *emission, const char *source);
84 static void _elm_win_focus_highlight_reconfigure(Elm_Win *win);
86 static void _elm_win_frame_add(Elm_Win *win, const char *style);
87 static void _elm_win_frame_cb_move_start(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__);
88 static void _elm_win_frame_cb_resize_start(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source);
89 static void _elm_win_frame_cb_minimize(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__);
90 static void _elm_win_frame_cb_maximize(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__);
91 static void _elm_win_frame_cb_close(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__);
93 static void _elm_win_pointer_add(Elm_Win *win, const char *style);
95 static const char SIG_DELETE_REQUEST[] = "delete,request";
96 static const char SIG_FOCUS_OUT[] = "focus,out";
97 static const char SIG_FOCUS_IN[] = "focus,in";
98 static const char SIG_MOVED[] = "moved";
99 static const char SIG_THEME_CHANGED[] = "theme,changed";
101 static const Evas_Smart_Cb_Description _signals[] = {
102 {SIG_DELETE_REQUEST, ""},
111 Eina_List *_elm_win_list = NULL;
112 int _elm_win_deferred_free = 0;
114 // exmaple shot spec (wait 0.1 sec then save as my-window.png):
115 // ELM_ENGINE="shot:delay=0.1:file=my-window.png"
118 _shot_delay_get(Elm_Win *win)
121 char *d = strdup(win->shot.info);
124 for (p = (char *)win->shot.info; *p; p++)
126 if (!strncmp(p, "delay=", 6))
130 for (pd = d, p += 6; (*p) && (*p != ':'); p++, pd++)
145 _shot_file_get(Elm_Win *win)
148 char *tmp = strdup(win->shot.info);
149 char *repname = NULL;
151 if (!tmp) return NULL;
153 for (p = (char *)win->shot.info; *p; p++)
155 if (!strncmp(p, "file=", 5))
158 if (!win->shot.repeat_count) return tmp;
161 char *dotptr = strrchr(tmp, '.');
164 size_t size = sizeof(char)*(strlen(tmp) + 16);
165 repname = malloc(size);
166 strncpy(repname, tmp, dotptr - tmp);
167 snprintf(repname + (dotptr - tmp), size - (dotptr - tmp), "%03i",
168 win->shot.shot_counter + 1);
169 strcat(repname, dotptr);
177 if (!win->shot.repeat_count) return strdup("out.png");
179 repname = malloc(sizeof(char) * 24);
180 snprintf(repname, sizeof(char) * 24, "out%03i.png", win->shot.shot_counter + 1);
185 _shot_repeat_count_get(Elm_Win *win)
188 char *d = strdup(win->shot.info);
191 for (p = (char *)win->shot.info; *p; p++)
193 if (!strncmp(p, "repeat=", 7))
197 for (pd = d, p += 7; (*p) && (*p != ':'); p++, pd++)
204 if (v > 1000) v = 999;
214 _shot_key_get(Elm_Win *win __UNUSED__)
220 _shot_flags_get(Elm_Win *win __UNUSED__)
226 _shot_do(Elm_Win *win)
230 unsigned int *pixels;
232 char *file, *key, *flags;
234 ecore_evas_manual_render(win->ee);
235 pixels = (void *)ecore_evas_buffer_pixels_get(win->ee);
237 ecore_evas_geometry_get(win->ee, NULL, NULL, &w, &h);
238 if ((w < 1) || (h < 1)) return;
239 file = _shot_file_get(win);
241 key = _shot_key_get(win);
242 flags = _shot_flags_get(win);
243 ee = ecore_evas_buffer_new(1, 1);
244 o = evas_object_image_add(ecore_evas_get(ee));
245 evas_object_image_alpha_set(o, ecore_evas_alpha_get(win->ee));
246 evas_object_image_size_set(o, w, h);
247 evas_object_image_data_set(o, pixels);
248 if (!evas_object_image_save(o, file, key, flags))
250 ERR("Cannot save window to '%s' (key '%s', flags '%s')",
255 if (flags) free(flags);
257 if (win->shot.repeat_count) win->shot.shot_counter++;
261 _shot_delay(void *data)
265 if (win->shot.repeat_count)
267 int remainshot = (win->shot.repeat_count - win->shot.shot_counter);
268 if (remainshot > 0) return EINA_TRUE;
270 win->shot.timer = NULL;
276 _shot_init(Elm_Win *win)
278 if (!win->shot.info) return;
279 win->shot.repeat_count = _shot_repeat_count_get(win);
280 win->shot.shot_counter = 0;
284 _shot_handle(Elm_Win *win)
286 if (!win->shot.info) return;
287 win->shot.timer = ecore_timer_add(_shot_delay_get(win), _shot_delay, win);
291 _elm_win_move(Ecore_Evas *ee)
293 Evas_Object *obj = ecore_evas_object_associate_get(ee);
298 win = elm_widget_data_get(obj);
300 ecore_evas_geometry_get(ee, &x, &y, NULL, NULL);
303 evas_object_smart_callback_call(win->win_obj, SIG_MOVED, NULL);
307 _elm_win_resize(Ecore_Evas *ee)
309 Evas_Object *obj = ecore_evas_object_associate_get(ee);
313 win = elm_widget_data_get(obj);
315 if (win->deferred_resize_job) ecore_job_del(win->deferred_resize_job);
316 win->deferred_resize_job = ecore_job_add(_elm_win_resize_job, win);
320 _elm_win_mouse_in(Ecore_Evas *ee)
325 if (!(obj = ecore_evas_object_associate_get(ee))) return;
326 if (!(win = elm_widget_data_get(obj))) return;
327 if (win->resizing) win->resizing = EINA_FALSE;
331 _elm_win_focus_in(Ecore_Evas *ee)
333 Evas_Object *obj = ecore_evas_object_associate_get(ee);
337 win = elm_widget_data_get(obj);
339 _elm_widget_top_win_focused_set(win->win_obj, EINA_TRUE);
340 if (!elm_widget_focus_order_get(obj))
342 elm_widget_focus_steal(win->win_obj);
346 elm_widget_focus_restore(win->win_obj);
347 evas_object_smart_callback_call(win->win_obj, SIG_FOCUS_IN, NULL);
348 win->focus_highlight.cur.visible = EINA_TRUE;
349 _elm_win_focus_highlight_reconfigure_job_start(win);
352 edje_object_signal_emit(win->frame_obj, "elm,action,focus", "elm");
354 else if (win->img_obj)
361 _elm_win_focus_out(Ecore_Evas *ee)
363 Evas_Object *obj = ecore_evas_object_associate_get(ee);
367 win = elm_widget_data_get(obj);
369 elm_object_focus_set(win->win_obj, EINA_FALSE);
370 _elm_widget_top_win_focused_set(win->win_obj, EINA_FALSE);
371 evas_object_smart_callback_call(win->win_obj, SIG_FOCUS_OUT, NULL);
372 win->focus_highlight.cur.visible = EINA_FALSE;
373 _elm_win_focus_highlight_reconfigure_job_start(win);
376 edje_object_signal_emit(win->frame_obj, "elm,action,unfocus", "elm");
378 else if (win->img_obj)
385 _elm_win_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
387 Elm_Win *wd = elm_widget_data_get(obj);
388 const Eina_List *items;
389 void *(*list_data_get) (const Eina_List *list);
397 if (!(items = elm_widget_focus_custom_chain_get(obj)))
403 list_data_get = eina_list_data_get;
405 elm_widget_focus_list_next_get(obj, items, list_data_get, dir, next);
411 *next = (Evas_Object *)obj;
416 _elm_win_on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
418 Elm_Win *win = elm_widget_data_get(obj);
422 evas_object_focus_set(win->img_obj, elm_widget_focus_get(obj));
424 evas_object_focus_set(obj, elm_widget_focus_get(obj));
428 _elm_win_event_cb(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
430 if (type == EVAS_CALLBACK_KEY_DOWN)
432 Evas_Event_Key_Down *ev = event_info;
433 if (!strcmp(ev->keyname, "Tab"))
435 if (evas_key_modifier_is_set(ev->modifiers, "Shift"))
436 elm_widget_focus_cycle(obj, ELM_FOCUS_PREVIOUS);
438 elm_widget_focus_cycle(obj, ELM_FOCUS_NEXT);
439 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
442 else if ((!strcmp(ev->keyname, "Left")) ||
443 (!strcmp(ev->keyname, "KP_Left")))
445 //TODO : woohyun jung
447 else if ((!strcmp(ev->keyname, "Right")) ||
448 (!strcmp(ev->keyname, "KP_Right")))
450 //TODO : woohyun jung
452 else if ((!strcmp(ev->keyname, "Up")) ||
453 (!strcmp(ev->keyname, "KP_Up")))
455 //TODO : woohyun jung
457 else if ((!strcmp(ev->keyname, "Down")) ||
458 (!strcmp(ev->keyname, "KP_Down")))
460 //TODO : woohyun jung
468 _deferred_ecore_evas_free(void *data)
470 ecore_evas_free(data);
471 _elm_win_deferred_free--;
475 _elm_win_obj_callback_show(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
479 if (!win->show_count) win->show_count++;
480 if (win->shot.info) _shot_handle(win);
484 _elm_win_obj_callback_hide(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
490 evas_object_hide(win->frame_obj);
492 else if (win->img_obj)
494 evas_object_hide(win->img_obj);
496 if (win->pointer.obj)
498 evas_object_hide(win->pointer.obj);
499 ecore_evas_hide(win->pointer.ee);
504 _elm_win_obj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info __UNUSED__)
511 evas_object_event_callback_del_full(win->parent, EVAS_CALLBACK_DEL,
512 _elm_win_obj_callback_parent_del, win);
515 if (win->autodel_clear) *(win->autodel_clear) = -1;
516 _elm_win_list = eina_list_remove(_elm_win_list, win->win_obj);
517 while (win->subobjs) elm_win_resize_object_del(obj, win->subobjs->data);
520 ecore_evas_callback_delete_request_set(win->ee, NULL);
521 ecore_evas_callback_resize_set(win->ee, NULL);
523 if (win->deferred_resize_job) ecore_job_del(win->deferred_resize_job);
524 if (win->deferred_child_eval_job) ecore_job_del(win->deferred_child_eval_job);
525 if (win->shot.info) eina_stringshare_del(win->shot.info);
526 if (win->shot.timer) ecore_timer_del(win->shot.timer);
527 evas_object_event_callback_del_full(win->win_obj, EVAS_CALLBACK_DEL,
528 _elm_win_obj_callback_del, win);
529 while (((child = evas_object_bottom_get(win->evas))) &&
532 evas_object_del(child);
534 while (((child = evas_object_top_get(win->evas))) &&
537 evas_object_del(child);
539 #ifdef HAVE_ELEMENTARY_X
540 if (win->client_message_handler)
541 ecore_event_handler_del(win->client_message_handler);
543 // FIXME: Why are we flushing edje on every window destroy ??
544 // edje_file_cache_flush();
545 // edje_collection_cache_flush();
546 // evas_image_cache_flush(win->evas);
547 // evas_font_cache_flush(win->evas);
548 // FIXME: we are in the del handler for the object and delete the canvas
549 // that lives under it from the handler... nasty. deferring doesn't help either
559 ecore_job_add(_deferred_ecore_evas_free, win->ee);
560 _elm_win_deferred_free++;
564 _elm_win_focus_highlight_shutdown(win);
565 eina_stringshare_del(win->focus_highlight.style);
569 if ((!_elm_win_list) &&
570 (elm_policy_get(ELM_POLICY_QUIT) == ELM_POLICY_QUIT_LAST_WINDOW_CLOSED))
572 edje_file_cache_flush();
573 edje_collection_cache_flush();
574 evas_image_cache_flush(e);
575 evas_font_cache_flush(e);
581 _elm_win_obj_callback_img_obj_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
584 if (!win->img_obj) return;
585 evas_object_event_callback_del_full
586 (win->img_obj, EVAS_CALLBACK_DEL, _elm_win_obj_callback_img_obj_del, win);
587 evas_object_del(win->img_obj);
591 _elm_win_obj_callback_parent_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
594 if (obj == win->parent) win->parent = NULL;
598 _elm_win_obj_intercept_move(void *data, Evas_Object *obj, Evas_Coord x, Evas_Coord y)
604 if ((x != win->screen.x) || (y != win->screen.y))
608 evas_object_smart_callback_call(win->win_obj, SIG_MOVED, NULL);
613 evas_object_move(obj, x, y);
618 _elm_win_obj_intercept_show(void *data, Evas_Object *obj)
621 // this is called to make sure all smart containers have calculated their
622 // sizes BEFORE we show the window to make sure it initially appears at
623 // our desired size (ie min size is known first)
624 evas_smart_objects_calculate(evas_object_evas_get(obj));
627 evas_object_show(win->frame_obj);
629 else if (win->img_obj)
631 evas_object_show(win->img_obj);
633 if (win->pointer.obj)
635 ecore_evas_show(win->pointer.ee);
636 evas_object_show(win->pointer.obj);
637 ecore_evas_wayland_pointer_set(win->pointer.ee, 10, 10);
639 evas_object_show(obj);
643 _elm_win_obj_callback_move(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
647 if (ecore_evas_override_get(win->ee))
651 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
654 evas_object_smart_callback_call(win->win_obj, SIG_MOVED, NULL);
660 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
664 else if (win->img_obj)
668 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
671 // evas_object_move(win->img_obj, x, y);
676 _elm_win_obj_callback_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
683 else if (win->img_obj)
685 Evas_Coord w = 1, h = 1;
687 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
691 ecore_evas_screen_geometry_get(win->ee, NULL, NULL, &sw, &sh);
697 evas_object_image_size_set(win->img_obj, w, h);
702 _elm_win_delete_request(Ecore_Evas *ee)
704 Evas_Object *obj = ecore_evas_object_associate_get(ee);
706 if (strcmp(elm_widget_type_get(obj), "win")) return;
708 win = elm_widget_data_get(obj);
710 int autodel = win->autodel;
711 win->autodel_clear = &autodel;
712 evas_object_ref(win->win_obj);
713 evas_object_smart_callback_call(win->win_obj, SIG_DELETE_REQUEST, NULL);
714 // FIXME: if above callback deletes - then the below will be invalid
715 if (autodel) evas_object_del(win->win_obj);
716 else win->autodel_clear = NULL;
717 evas_object_unref(win->win_obj);
721 _elm_win_resize_job(void *data)
728 win->deferred_resize_job = NULL;
729 ecore_evas_request_geometry_get(win->ee, NULL, NULL, &w, &h);
733 ecore_evas_screen_geometry_get(win->ee, NULL, NULL, &sw, &sh);
739 evas_object_resize(win->frame_obj, w, h);
741 else if (win->img_obj)
744 evas_object_resize(win->win_obj, w, h);
745 EINA_LIST_FOREACH(win->subobjs, l, obj)
747 evas_object_move(obj, 0, 0);
748 evas_object_resize(obj, w, h);
752 #ifdef HAVE_ELEMENTARY_X
754 _elm_win_xwindow_get(Elm_Win *win)
758 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
759 if (ENGINE_COMPARE(ELM_SOFTWARE_X11))
761 if (win->ee) win->xwin = ecore_evas_software_x11_window_get(win->ee);
763 else if (ENGINE_COMPARE(ELM_SOFTWARE_X11) ||
764 ENGINE_COMPARE(ELM_SOFTWARE_FB) ||
765 ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE) ||
766 ENGINE_COMPARE(ELM_SOFTWARE_SDL) ||
767 ENGINE_COMPARE(ELM_SOFTWARE_16_SDL) ||
768 ENGINE_COMPARE(ELM_OPENGL_SDL) ||
769 ENGINE_COMPARE(ELM_OPENGL_COCOA))
772 else if (ENGINE_COMPARE(ELM_SOFTWARE_16_X11))
774 if (win->ee) win->xwin = ecore_evas_software_x11_16_window_get(win->ee);
776 else if (ENGINE_COMPARE(ELM_SOFTWARE_8_X11))
778 if (win->ee) win->xwin = ecore_evas_software_x11_8_window_get(win->ee);
781 else if (ENGINE_COMPARE(ELM_XRENDER_X11))
783 if (win->ee) win->xwin = ecore_evas_xrender_x11_window_get(win->ee);
786 else if (ENGINE_COMPARE(ELM_OPENGL_X11))
788 if (win->ee) win->xwin = ecore_evas_gl_x11_window_get(win->ee);
790 else if (ENGINE_COMPARE(ELM_SOFTWARE_WIN32))
792 if (win->ee) win->xwin = (long)ecore_evas_win32_window_get(win->ee);
794 #undef ENGINE_COMPARE
798 #ifdef HAVE_ELEMENTARY_X
800 _elm_win_xwin_update(Elm_Win *win)
802 _elm_win_xwindow_get(win);
807 win2 = elm_widget_data_get(win->parent);
811 ecore_x_icccm_transient_for_set(win->xwin, win2->xwin);
815 if (!win->xwin) return; /* nothing more to do */
820 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_NORMAL);
822 case ELM_WIN_DIALOG_BASIC:
823 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DIALOG);
825 case ELM_WIN_DESKTOP:
826 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DESKTOP);
829 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DOCK);
831 case ELM_WIN_TOOLBAR:
832 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_TOOLBAR);
835 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_MENU);
837 case ELM_WIN_UTILITY:
838 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_UTILITY);
841 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_SPLASH);
843 case ELM_WIN_DROPDOWN_MENU:
844 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DROPDOWN_MENU);
846 case ELM_WIN_POPUP_MENU:
847 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_POPUP_MENU);
849 case ELM_WIN_TOOLTIP:
850 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_TOOLTIP);
852 case ELM_WIN_NOTIFICATION:
853 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_NOTIFICATION);
856 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_COMBO);
859 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DND);
864 ecore_x_e_virtual_keyboard_state_set
865 (win->xwin, (Ecore_X_Virtual_Keyboard_State)win->kbdmode);
870 _elm_win_eval_subobjs(Evas_Object *obj)
873 const Evas_Object *child;
875 Elm_Win *win = elm_widget_data_get(obj);
876 Evas_Coord w, h, minw = -1, minh = -1, maxw = -1, maxh = -1;
880 EINA_LIST_FOREACH(win->subobjs, l, child)
882 evas_object_size_hint_weight_get(child, &wx, &wy);
883 if (wx == 0.0) xx = 0;
884 if (wy == 0.0) xy = 0;
886 evas_object_size_hint_min_get(child, &w, &h);
889 if (w > minw) minw = w;
890 if (h > minh) minh = h;
892 evas_object_size_hint_max_get(child, &w, &h);
895 if (maxw == -1) maxw = w;
896 else if ((w > 0) && (w < maxw)) maxw = w;
897 if (maxh == -1) maxh = h;
898 else if ((h > 0) && (h < maxh)) maxh = h;
900 if (!xx) maxw = minw;
902 if (!xy) maxh = minh;
904 evas_object_size_hint_min_set(obj, minw, minh);
905 evas_object_size_hint_max_set(obj, maxw, maxh);
906 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
907 if (w < minw) w = minw;
908 if (h < minh) h = minh;
909 if ((maxw >= 0) && (w > maxw)) w = maxw;
910 if ((maxh >= 0) && (h > maxh)) h = maxh;
911 evas_object_resize(obj, w, h);
915 _elm_win_subobj_callback_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
917 Elm_Win *win = elm_widget_data_get(data);
918 win->subobjs = eina_list_remove(win->subobjs, obj);
919 _elm_win_eval_subobjs(win->win_obj);
923 _elm_win_subobj_callback_changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
925 _elm_win_eval_subobjs(data);
929 _elm_win_shutdown(void)
931 while (_elm_win_list)
932 evas_object_del(_elm_win_list->data);
936 _elm_win_rescale(Elm_Theme *th, Eina_Bool use_theme)
943 EINA_LIST_FOREACH(_elm_win_list, l, obj)
944 elm_widget_theme(obj);
948 EINA_LIST_FOREACH(_elm_win_list, l, obj)
949 elm_widget_theme_specific(obj, th, EINA_FALSE);
954 _elm_win_translate(void)
959 EINA_LIST_FOREACH(_elm_win_list, l, obj)
960 elm_widget_translate(obj);
963 #ifdef HAVE_ELEMENTARY_X
965 _elm_win_client_message(void *data, int type __UNUSED__, void *event)
968 Ecore_X_Event_Client_Message *e = event;
970 if (e->format != 32) return ECORE_CALLBACK_PASS_ON;
971 if (e->message_type == ECORE_X_ATOM_E_COMP_FLUSH)
973 if ((unsigned)e->data.l[0] == win->xwin)
975 Evas *evas = evas_object_evas_get(win->win_obj);
978 edje_file_cache_flush();
979 edje_collection_cache_flush();
980 evas_image_cache_flush(evas);
981 evas_font_cache_flush(evas);
985 else if (e->message_type == ECORE_X_ATOM_E_COMP_DUMP)
987 if ((unsigned)e->data.l[0] == win->xwin)
989 Evas *evas = evas_object_evas_get(win->win_obj);
992 edje_file_cache_flush();
993 edje_collection_cache_flush();
994 evas_image_cache_flush(evas);
995 evas_font_cache_flush(evas);
996 evas_render_dump(evas);
1000 return ECORE_CALLBACK_PASS_ON;
1005 _elm_win_focus_target_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1007 Elm_Win *win = data;
1009 win->focus_highlight.geometry_changed = EINA_TRUE;
1010 _elm_win_focus_highlight_reconfigure_job_start(win);
1014 _elm_win_focus_target_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1016 Elm_Win *win = data;
1018 win->focus_highlight.geometry_changed = EINA_TRUE;
1019 _elm_win_focus_highlight_reconfigure_job_start(win);
1023 _elm_win_focus_target_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1025 Elm_Win *win = data;
1027 win->focus_highlight.cur.target = NULL;
1029 _elm_win_focus_highlight_reconfigure_job_start(win);
1033 _elm_win_focus_target_callbacks_add(Elm_Win *win)
1035 Evas_Object *obj = win->focus_highlight.cur.target;
1037 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE,
1038 _elm_win_focus_target_move, win);
1039 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE,
1040 _elm_win_focus_target_resize, win);
1041 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
1042 _elm_win_focus_target_del, win);
1046 _elm_win_focus_target_callbacks_del(Elm_Win *win)
1048 Evas_Object *obj = win->focus_highlight.cur.target;
1050 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_MOVE,
1051 _elm_win_focus_target_move, win);
1052 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_RESIZE,
1053 _elm_win_focus_target_resize, win);
1054 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL,
1055 _elm_win_focus_target_del, win);
1058 static Evas_Object *
1059 _elm_win_focus_target_get(Evas_Object *obj)
1061 Evas_Object *o = obj;
1065 if (elm_widget_is(o))
1067 if (!elm_widget_highlight_ignore_get(o))
1069 o = elm_widget_parent_get(o);
1071 o = evas_object_smart_parent_get(o);
1075 o = elm_widget_parent_widget_get(o);
1077 o = evas_object_smart_parent_get(o);
1086 _elm_win_object_focus_in(void *data, Evas *e __UNUSED__, void *event_info)
1088 Evas_Object *obj = event_info, *target;
1089 Elm_Win *win = data;
1091 if (win->focus_highlight.cur.target == obj)
1094 target = _elm_win_focus_target_get(obj);
1095 win->focus_highlight.cur.target = target;
1096 if (elm_widget_highlight_in_theme_get(target))
1097 win->focus_highlight.cur.handled = EINA_TRUE;
1099 _elm_win_focus_target_callbacks_add(win);
1101 _elm_win_focus_highlight_reconfigure_job_start(win);
1105 _elm_win_object_focus_out(void *data, Evas *e __UNUSED__, void *event_info __UNUSED__)
1107 Elm_Win *win = data;
1109 if (!win->focus_highlight.cur.target)
1112 if (!win->focus_highlight.cur.handled)
1113 _elm_win_focus_target_callbacks_del(win);
1114 win->focus_highlight.cur.target = NULL;
1115 win->focus_highlight.cur.handled = EINA_FALSE;
1117 _elm_win_focus_highlight_reconfigure_job_start(win);
1121 _elm_win_focus_highlight_hide(void *data __UNUSED__, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
1123 evas_object_hide(obj);
1127 _elm_win_focus_highlight_init(Elm_Win *win)
1129 evas_event_callback_add(win->evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
1130 _elm_win_object_focus_in, win);
1131 evas_event_callback_add(win->evas,
1132 EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
1133 _elm_win_object_focus_out, win);
1135 win->focus_highlight.cur.target = evas_focus_get(win->evas);
1137 win->focus_highlight.top = edje_object_add(win->evas);
1138 win->focus_highlight.changed_theme = EINA_TRUE;
1139 edje_object_signal_callback_add(win->focus_highlight.top,
1140 "elm,action,focus,hide,end", "",
1141 _elm_win_focus_highlight_hide, NULL);
1142 edje_object_signal_callback_add(win->focus_highlight.top,
1143 "elm,action,focus,anim,end", "",
1144 _elm_win_focus_highlight_anim_end, win);
1145 _elm_win_focus_highlight_reconfigure_job_start(win);
1149 _elm_win_focus_highlight_shutdown(Elm_Win *win)
1151 _elm_win_focus_highlight_reconfigure_job_stop(win);
1152 if (win->focus_highlight.cur.target)
1154 _elm_win_focus_target_callbacks_del(win);
1155 win->focus_highlight.cur.target = NULL;
1157 if (win->focus_highlight.top)
1159 evas_object_del(win->focus_highlight.top);
1160 win->focus_highlight.top = NULL;
1163 evas_event_callback_del_full(win->evas,
1164 EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
1165 _elm_win_object_focus_in, win);
1166 evas_event_callback_del_full(win->evas,
1167 EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
1168 _elm_win_object_focus_out, win);
1172 _elm_win_focus_highlight_visible_set(Elm_Win *win, Eina_Bool visible)
1176 top = win->focus_highlight.top;
1181 evas_object_show(top);
1182 edje_object_signal_emit(top, "elm,action,focus,show", "elm");
1188 edje_object_signal_emit(top, "elm,action,focus,hide", "elm");
1193 _elm_win_focus_highlight_reconfigure_job(void *data)
1195 _elm_win_focus_highlight_reconfigure((Elm_Win *)data);
1199 _elm_win_focus_highlight_reconfigure_job_start(Elm_Win *win)
1201 if (win->focus_highlight.reconf_job)
1202 ecore_job_del(win->focus_highlight.reconf_job);
1203 win->focus_highlight.reconf_job = ecore_job_add(
1204 _elm_win_focus_highlight_reconfigure_job, win);
1208 _elm_win_focus_highlight_reconfigure_job_stop(Elm_Win *win)
1210 if (win->focus_highlight.reconf_job)
1211 ecore_job_del(win->focus_highlight.reconf_job);
1212 win->focus_highlight.reconf_job = NULL;
1216 _elm_win_focus_highlight_simple_setup(Elm_Win *win, Evas_Object *obj)
1218 Evas_Object *clip, *target = win->focus_highlight.cur.target;
1219 Evas_Coord x, y, w, h;
1221 clip = evas_object_clip_get(target);
1222 evas_object_geometry_get(target, &x, &y, &w, &h);
1224 evas_object_move(obj, x, y);
1225 evas_object_resize(obj, w, h);
1226 evas_object_clip_set(obj, clip);
1230 _elm_win_focus_highlight_anim_setup(Elm_Win *win, Evas_Object *obj)
1232 Evas_Coord tx, ty, tw, th;
1233 Evas_Coord w, h, px, py, pw, ph;
1234 Edje_Message_Int_Set *m;
1235 Evas_Object *previous = win->focus_highlight.prev.target;
1236 Evas_Object *target = win->focus_highlight.cur.target;
1238 evas_object_geometry_get(win->win_obj, NULL, NULL, &w, &h);
1239 evas_object_geometry_get(target, &tx, &ty, &tw, &th);
1240 evas_object_geometry_get(previous, &px, &py, &pw, &ph);
1241 evas_object_move(obj, 0, 0);
1242 evas_object_resize(obj, tw, th);
1243 evas_object_clip_unset(obj);
1245 m = alloca(sizeof(*m) + (sizeof(int) * 8));
1255 edje_object_message_send(obj, EDJE_MESSAGE_INT_SET, 1, m);
1259 _elm_win_focus_highlight_anim_end(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
1261 Elm_Win *win = data;
1262 _elm_win_focus_highlight_simple_setup(win, obj);
1266 _elm_win_focus_highlight_reconfigure(Elm_Win *win)
1268 Evas_Object *target = win->focus_highlight.cur.target;
1269 Evas_Object *previous = win->focus_highlight.prev.target;
1270 Evas_Object *top = win->focus_highlight.top;
1271 Eina_Bool visible_changed;
1272 Eina_Bool common_visible;
1273 const char *sig = NULL;
1275 _elm_win_focus_highlight_reconfigure_job_stop(win);
1277 visible_changed = (win->focus_highlight.cur.visible !=
1278 win->focus_highlight.prev.visible);
1280 if ((target == previous) && (!visible_changed) &&
1281 (!win->focus_highlight.geometry_changed))
1284 if ((previous) && (win->focus_highlight.prev.handled))
1285 elm_widget_signal_emit(previous, "elm,action,focus_highlight,hide", "elm");
1288 common_visible = EINA_FALSE;
1289 else if (win->focus_highlight.cur.handled)
1291 common_visible = EINA_FALSE;
1292 if (win->focus_highlight.cur.visible)
1293 sig = "elm,action,focus_highlight,show";
1295 sig = "elm,action,focus_highlight,hide";
1298 common_visible = win->focus_highlight.cur.visible;
1300 _elm_win_focus_highlight_visible_set(win, common_visible);
1302 elm_widget_signal_emit(target, sig, "elm");
1304 if ((!target) || (!common_visible) || (win->focus_highlight.cur.handled))
1307 if (win->focus_highlight.changed_theme)
1310 if (win->focus_highlight.style)
1311 str = win->focus_highlight.style;
1314 _elm_theme_object_set(win->win_obj, top, "focus_highlight", "top",
1316 win->focus_highlight.changed_theme = EINA_FALSE;
1318 if (_elm_config->focus_highlight_animate)
1320 str = edje_object_data_get(win->focus_highlight.top, "animate");
1321 win->focus_highlight.top_animate = ((str) && (!strcmp(str, "on")));
1325 if ((win->focus_highlight.top_animate) && (previous) &&
1326 (!win->focus_highlight.prev.handled))
1327 _elm_win_focus_highlight_anim_setup(win, top);
1329 _elm_win_focus_highlight_simple_setup(win, top);
1330 evas_object_raise(top);
1333 win->focus_highlight.geometry_changed = EINA_FALSE;
1334 win->focus_highlight.prev = win->focus_highlight.cur;
1338 _elm_win_frame_add(Elm_Win *win, const char *style)
1340 evas_output_framespace_set(win->evas, 0, 22, 0, 26);
1342 win->frame_obj = edje_object_add(win->evas);
1343 _elm_theme_set(NULL, win->frame_obj, "border", "base", style);
1344 evas_object_is_frame_object_set(win->frame_obj, EINA_TRUE);
1345 evas_object_move(win->frame_obj, 0, 0);
1346 evas_object_resize(win->frame_obj, 1, 1);
1348 edje_object_signal_callback_add(win->frame_obj, "elm,action,move,start",
1349 "elm", _elm_win_frame_cb_move_start, win);
1350 edje_object_signal_callback_add(win->frame_obj, "elm,action,resize,start",
1351 "*", _elm_win_frame_cb_resize_start, win);
1352 edje_object_signal_callback_add(win->frame_obj, "elm,action,minimize",
1353 "elm", _elm_win_frame_cb_minimize, win);
1354 edje_object_signal_callback_add(win->frame_obj, "elm,action,maximize",
1355 "elm", _elm_win_frame_cb_maximize, win);
1356 edje_object_signal_callback_add(win->frame_obj, "elm,action,close",
1357 "elm", _elm_win_frame_cb_close, win);
1361 _elm_win_frame_cb_move_start(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__)
1365 if (!(win = data)) return;
1366 /* FIXME: Change mouse pointer */
1368 /* NB: 0,0 are dummy values. Wayland handles the move by itself */
1369 ecore_evas_move(win->ee, 0, 0);
1373 _elm_win_frame_cb_resize_start(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source)
1377 if (!(win = data)) return;
1378 if (win->resizing) return;
1379 win->resizing = EINA_TRUE;
1381 /* FIXME: Change mouse pointer */
1383 if (!strcmp(source, "elm.event.resize.t"))
1384 win->resize_location = 1;
1385 else if (!strcmp(source, "elm.event.resize.b"))
1386 win->resize_location = 2;
1387 else if (!strcmp(source, "elm.event.resize.l"))
1388 win->resize_location = 4;
1389 else if (!strcmp(source, "elm.event.resize.r"))
1390 win->resize_location = 8;
1391 else if (!strcmp(source, "elm.event.resize.tl"))
1392 win->resize_location = 5;
1393 else if (!strcmp(source, "elm.event.resize.tr"))
1394 win->resize_location = 9;
1395 else if (!strcmp(source, "elm.event.resize.bl"))
1396 win->resize_location = 6;
1397 else if (!strcmp(source, "elm.event.resize.br"))
1398 win->resize_location = 10;
1400 win->resize_location = 0;
1402 if (win->resize_location > 0)
1403 ecore_evas_wayland_resize(win->ee, win->resize_location);
1407 _elm_win_frame_cb_minimize(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__)
1411 if (!(win = data)) return;
1412 ecore_evas_iconified_set(win->ee, EINA_TRUE);
1416 _elm_win_frame_cb_maximize(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__)
1420 if (!(win = data)) return;
1421 ecore_evas_maximized_set(win->ee, EINA_TRUE);
1425 _elm_win_frame_cb_close(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__)
1429 if (!(win = data)) return;
1430 evas_object_del(win->win_obj);
1434 _elm_win_pointer_add(Elm_Win *win, const char *style)
1438 win->pointer.ee = ecore_evas_wayland_shm_new(NULL, 0, 0, 32, 32, 0);
1439 ecore_evas_resize(win->pointer.ee, 32, 32);
1441 win->pointer.evas = ecore_evas_get(win->ee);
1443 win->pointer.obj = edje_object_add(win->pointer.evas);
1444 _elm_theme_set(NULL, win->pointer.obj, "pointer", "base", style);
1445 edje_object_size_min_calc(win->pointer.obj, &mw, &mh);
1446 printf("ELM Win Pointer Size: %d %d\n", mw, mh);
1447 evas_object_move(win->pointer.obj, 0, 0);
1448 evas_object_resize(win->pointer.obj, 32, 32);
1449 evas_object_show(win->pointer.obj);
1454 _debug_key_down(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
1456 Evas_Event_Key_Down *ev = event_info;
1458 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1461 if ((strcmp(ev->keyname, "F12")) ||
1462 (!evas_key_modifier_is_set(ev->modifiers, "Control")))
1465 printf("Tree graph generated.\n");
1466 elm_object_tree_dot_dump(obj, "./dump.dot");
1471 _win_img_hide(void *data,
1473 Evas_Object *obj __UNUSED__,
1474 void *event_info __UNUSED__)
1476 Elm_Win *win = data;
1478 elm_widget_focus_hide_handle(win->win_obj);
1482 _win_img_mouse_up(void *data,
1484 Evas_Object *obj __UNUSED__,
1487 Elm_Win *win = data;
1488 Evas_Event_Mouse_Up *ev = event_info;
1489 if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD))
1490 elm_widget_focus_mouse_up_handle(win->win_obj);
1494 _win_img_focus_in(void *data,
1496 Evas_Object *obj __UNUSED__,
1497 void *event_info __UNUSED__)
1499 Elm_Win *win = data;
1500 elm_widget_focus_steal(win->win_obj);
1504 _win_img_focus_out(void *data,
1506 Evas_Object *obj __UNUSED__,
1507 void *event_info __UNUSED__)
1509 Elm_Win *win = data;
1510 elm_widget_focused_object_clear(win->win_obj);
1514 _win_inlined_image_set(Elm_Win *win)
1516 evas_object_image_alpha_set(win->img_obj, EINA_FALSE);
1517 evas_object_image_filled_set(win->img_obj, EINA_TRUE);
1518 evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_DEL,
1519 _elm_win_obj_callback_img_obj_del, win);
1521 evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_HIDE,
1522 _win_img_hide, win);
1523 evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_MOUSE_UP,
1524 _win_img_mouse_up, win);
1525 evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_FOCUS_IN,
1526 _win_img_focus_in, win);
1527 evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_FOCUS_OUT,
1528 _win_img_focus_out, win);
1532 _subobj_del(Elm_Win *win, Evas_Object *obj, Evas_Object *subobj)
1534 evas_object_event_callback_del_full(subobj,
1535 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1536 _elm_win_subobj_callback_changed_size_hints,
1538 evas_object_event_callback_del_full(subobj, EVAS_CALLBACK_DEL,
1539 _elm_win_subobj_callback_del, obj);
1540 win->subobjs = eina_list_remove(win->subobjs, subobj);
1541 _elm_win_eval_subobjs(obj);
1545 elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type)
1549 const char *fontpath;
1551 win = ELM_NEW(Elm_Win);
1553 #define FALLBACK_TRY(engine) \
1556 CRITICAL(engine " engine creation failed. Trying default."); \
1557 win->ee = ecore_evas_new(NULL, 0, 0, 1, 1, NULL); \
1559 elm_engine_set(ecore_evas_engine_name_get(win->ee)); \
1561 #define ENGINE_COMPARE(name) (_elm_config->engine && !strcmp(_elm_config->engine, name))
1565 case ELM_WIN_INLINED_IMAGE:
1568 Evas *e = evas_object_evas_get(parent);
1571 ee = ecore_evas_ecore_evas_get(e);
1573 win->img_obj = ecore_evas_object_image_new(ee);
1574 if (!win->img_obj) break;
1575 win->ee = ecore_evas_object_ecore_evas_get(win->img_obj);
1578 _win_inlined_image_set(win);
1581 evas_object_del(win->img_obj);
1582 win->img_obj = NULL;
1586 case ELM_WIN_SOCKET_IMAGE:
1587 win->ee = ecore_evas_extn_socket_new(1, 1);
1591 if (ENGINE_COMPARE(ELM_SOFTWARE_X11))
1593 win->ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
1594 #ifdef HAVE_ELEMENTARY_X
1595 win->client_message_handler = ecore_event_handler_add
1596 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1598 FALLBACK_TRY("Sofware X11");
1600 else if (ENGINE_COMPARE(ELM_SOFTWARE_FB))
1602 win->ee = ecore_evas_fb_new(NULL, 0, 1, 1);
1603 FALLBACK_TRY("Sofware FB");
1605 else if (ENGINE_COMPARE(ELM_SOFTWARE_DIRECTFB))
1607 win->ee = ecore_evas_directfb_new(NULL, 1, 0, 0, 1, 1);
1608 FALLBACK_TRY("Sofware DirectFB");
1610 else if (ENGINE_COMPARE(ELM_SOFTWARE_16_X11))
1612 win->ee = ecore_evas_software_x11_16_new(NULL, 0, 0, 0, 1, 1);
1613 FALLBACK_TRY("Sofware-16");
1614 #ifdef HAVE_ELEMENTARY_X
1615 win->client_message_handler = ecore_event_handler_add
1616 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1619 else if (ENGINE_COMPARE(ELM_SOFTWARE_8_X11))
1621 win->ee = ecore_evas_software_x11_8_new(NULL, 0, 0, 0, 1, 1);
1622 FALLBACK_TRY("Sofware-8");
1623 #ifdef HAVE_ELEMENTARY_X
1624 win->client_message_handler = ecore_event_handler_add
1625 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1629 else if (ENGINE_COMPARE(ELM_XRENDER_X11))
1631 win->ee = ecore_evas_xrender_x11_new(NULL, 0, 0, 0, 1, 1);
1632 FALLBACK_TRY("XRender");
1633 #ifdef HAVE_ELEMENTARY_X
1634 win->client_message_handler = ecore_event_handler_add
1635 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1639 else if (ENGINE_COMPARE(ELM_OPENGL_X11))
1644 if (_elm_config->vsync)
1646 opt[opt_i] = ECORE_EVAS_GL_X11_OPT_VSYNC;
1652 win->ee = ecore_evas_gl_x11_options_new(NULL, 0, 0, 0, 1, 1, opt);
1654 win->ee = ecore_evas_gl_x11_new(NULL, 0, 0, 0, 1, 1);
1655 FALLBACK_TRY("OpenGL");
1656 #ifdef HAVE_ELEMENTARY_X
1657 win->client_message_handler = ecore_event_handler_add
1658 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1661 else if (ENGINE_COMPARE(ELM_SOFTWARE_WIN32))
1663 win->ee = ecore_evas_software_gdi_new(NULL, 0, 0, 1, 1);
1664 FALLBACK_TRY("Sofware Win32");
1666 else if (ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE))
1668 win->ee = ecore_evas_software_wince_gdi_new(NULL, 0, 0, 1, 1);
1669 FALLBACK_TRY("Sofware-16-WinCE");
1671 else if (ENGINE_COMPARE(ELM_SOFTWARE_PSL1GHT))
1673 win->ee = ecore_evas_psl1ght_new(NULL, 1, 1);
1674 FALLBACK_TRY("PSL1GHT");
1676 else if (ENGINE_COMPARE(ELM_SOFTWARE_SDL))
1678 win->ee = ecore_evas_sdl_new(NULL, 0, 0, 0, 0, 0, 1);
1679 FALLBACK_TRY("Sofware SDL");
1681 else if (ENGINE_COMPARE(ELM_SOFTWARE_16_SDL))
1683 win->ee = ecore_evas_sdl16_new(NULL, 0, 0, 0, 0, 0, 1);
1684 FALLBACK_TRY("Sofware-16-SDL");
1686 else if (ENGINE_COMPARE(ELM_OPENGL_SDL))
1688 win->ee = ecore_evas_gl_sdl_new(NULL, 1, 1, 0, 0);
1689 FALLBACK_TRY("OpenGL SDL");
1691 else if (ENGINE_COMPARE(ELM_OPENGL_COCOA))
1693 win->ee = ecore_evas_cocoa_new(NULL, 1, 1, 0, 0);
1694 FALLBACK_TRY("OpenGL Cocoa");
1696 else if (ENGINE_COMPARE(ELM_BUFFER))
1698 win->ee = ecore_evas_buffer_new(1, 1);
1700 else if (ENGINE_COMPARE(ELM_EWS))
1702 win->ee = ecore_evas_ews_new(0, 0, 1, 1);
1704 else if (ENGINE_COMPARE(ELM_WAYLAND_SHM))
1706 win->ee = ecore_evas_wayland_shm_new(NULL, 0, 0, 1, 1, 0);
1708 _elm_win_frame_add(win, "default");
1709 _elm_win_pointer_add(win, "default");
1711 else if (ENGINE_COMPARE(ELM_WAYLAND_EGL))
1713 win->ee = ecore_evas_wayland_egl_new(NULL, 0, 0, 1, 1, 0);
1715 _elm_win_frame_add(win, "default");
1716 _elm_win_pointer_add(win, "default");
1718 else if (!strncmp(_elm_config->engine, "shot:", 5))
1720 win->ee = ecore_evas_buffer_new(1, 1);
1721 ecore_evas_manual_render_set(win->ee, EINA_TRUE);
1722 win->shot.info = eina_stringshare_add(_elm_config->engine + 5);
1731 ERR("Cannot create window.");
1735 #ifdef HAVE_ELEMENTARY_X
1736 _elm_win_xwindow_get(win);
1738 if ((_elm_config->bgpixmap) && (!_elm_config->compositing))
1739 ecore_evas_avoid_damage_set(win->ee, ECORE_EVAS_AVOID_DAMAGE_EXPOSE);
1740 // bg pixmap done by x - has other issues like can be redrawn by x before it
1741 // is filled/ready by app
1742 // ecore_evas_avoid_damage_set(win->ee, ECORE_EVAS_AVOID_DAMAGE_BUILT_IN);
1745 win->parent = parent;
1747 evas_object_event_callback_add(win->parent, EVAS_CALLBACK_DEL,
1748 _elm_win_obj_callback_parent_del, win);
1750 win->evas = ecore_evas_get(win->ee);
1751 win->win_obj = elm_widget_add(win->evas);
1752 elm_widget_type_set(win->win_obj, "win");
1753 ELM_SET_WIDTYPE(widtype, "win");
1754 elm_widget_data_set(win->win_obj, win);
1755 elm_widget_event_hook_set(win->win_obj, _elm_win_event_cb);
1756 elm_widget_on_focus_hook_set(win->win_obj, _elm_win_on_focus_hook, NULL);
1757 elm_widget_can_focus_set(win->win_obj, EINA_TRUE);
1758 elm_widget_highlight_ignore_set(win->win_obj, EINA_TRUE);
1759 elm_widget_focus_next_hook_set(win->win_obj, _elm_win_focus_next_hook);
1760 evas_object_color_set(win->win_obj, 0, 0, 0, 0);
1761 evas_object_move(win->win_obj, 0, 0);
1762 evas_object_resize(win->win_obj, 1, 1);
1763 evas_object_layer_set(win->win_obj, 50);
1764 evas_object_pass_events_set(win->win_obj, EINA_TRUE);
1768 // evas_object_clip_set(win->win_obj, win->frame_obj);
1769 evas_object_stack_below(win->frame_obj, win->win_obj);
1772 if (type == ELM_WIN_INLINED_IMAGE)
1773 elm_widget_parent2_set(win->win_obj, parent);
1774 ecore_evas_object_associate(win->ee, win->win_obj,
1775 ECORE_EVAS_OBJECT_ASSOCIATE_BASE |
1776 ECORE_EVAS_OBJECT_ASSOCIATE_STACK |
1777 ECORE_EVAS_OBJECT_ASSOCIATE_LAYER);
1778 evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_SHOW,
1779 _elm_win_obj_callback_show, win);
1780 evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_HIDE,
1781 _elm_win_obj_callback_hide, win);
1782 evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_DEL,
1783 _elm_win_obj_callback_del, win);
1784 evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_MOVE,
1785 _elm_win_obj_callback_move, win);
1786 evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_RESIZE,
1787 _elm_win_obj_callback_resize, win);
1789 evas_object_intercept_move_callback_add(win->win_obj,
1790 _elm_win_obj_intercept_move, win);
1791 evas_object_intercept_show_callback_add(win->win_obj,
1792 _elm_win_obj_intercept_show, win);
1794 evas_object_smart_callback_add(win->win_obj, "sub-object-del", (Evas_Smart_Cb)_subobj_del, win);
1795 ecore_evas_name_class_set(win->ee, name, _elm_appname);
1796 ecore_evas_callback_delete_request_set(win->ee, _elm_win_delete_request);
1797 ecore_evas_callback_resize_set(win->ee, _elm_win_resize);
1798 ecore_evas_callback_mouse_in_set(win->ee, _elm_win_mouse_in);
1799 ecore_evas_callback_focus_in_set(win->ee, _elm_win_focus_in);
1800 ecore_evas_callback_focus_out_set(win->ee, _elm_win_focus_out);
1801 ecore_evas_callback_move_set(win->ee, _elm_win_move);
1802 evas_image_cache_set(win->evas, (_elm_config->image_cache * 1024));
1803 evas_font_cache_set(win->evas, (_elm_config->font_cache * 1024));
1804 EINA_LIST_FOREACH(_elm_config->font_dirs, l, fontpath)
1805 evas_font_path_append(win->evas, fontpath);
1806 if (!_elm_config->font_hinting)
1807 evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_NONE);
1808 else if (_elm_config->font_hinting == 1)
1809 evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_AUTO);
1810 else if (_elm_config->font_hinting == 2)
1811 evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_BYTECODE);
1813 #ifdef HAVE_ELEMENTARY_X
1814 _elm_win_xwin_update(win);
1817 _elm_win_list = eina_list_append(_elm_win_list, win->win_obj);
1819 if (ENGINE_COMPARE(ELM_SOFTWARE_FB))
1821 ecore_evas_fullscreen_set(win->ee, 1);
1823 #undef ENGINE_COMPARE
1825 if (_elm_config->focus_highlight_enable)
1826 elm_win_focus_highlight_enabled_set(win->win_obj, EINA_TRUE);
1829 Evas_Modifier_Mask mask = evas_key_modifier_mask_get(win->evas, "Control");
1830 evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_KEY_DOWN,
1831 _debug_key_down, win);
1833 Eina_Bool ret = evas_object_key_grab(win->win_obj, "F12", mask, 0,
1835 printf("Ctrl+F12 key combination exclusive for dot tree generation\n");
1838 evas_object_smart_callbacks_descriptions_set(win->win_obj, _signals);
1840 return win->win_obj;
1844 elm_win_util_standard_add(const char *name, const char *title)
1846 Evas_Object *win, *bg;
1848 win = elm_win_add(NULL, name, ELM_WIN_BASIC);
1849 if (!win) return NULL;
1850 elm_win_title_set(win, title);
1851 bg = elm_bg_add(win);
1854 evas_object_del(win);
1857 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1858 elm_win_resize_object_add(win, bg);
1859 evas_object_show(bg);
1864 elm_win_resize_object_add(Evas_Object *obj, Evas_Object *subobj)
1868 ELM_CHECK_WIDTYPE(obj, widtype);
1869 win = elm_widget_data_get(obj);
1871 if (eina_list_data_find(win->subobjs, subobj)) return;
1872 win->subobjs = eina_list_append(win->subobjs, subobj);
1873 elm_widget_sub_object_add(obj, subobj);
1874 evas_object_event_callback_add(subobj, EVAS_CALLBACK_DEL,
1875 _elm_win_subobj_callback_del, obj);
1876 evas_object_event_callback_add(subobj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1877 _elm_win_subobj_callback_changed_size_hints,
1879 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
1880 evas_object_move(subobj, 0, 0);
1881 evas_object_resize(subobj, w, h);
1882 _elm_win_eval_subobjs(obj);
1886 elm_win_resize_object_del(Evas_Object *obj, Evas_Object *subobj)
1889 ELM_CHECK_WIDTYPE(obj, widtype);
1890 win = elm_widget_data_get(obj);
1892 evas_object_event_callback_del_full(subobj,
1893 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1894 _elm_win_subobj_callback_changed_size_hints,
1896 evas_object_event_callback_del_full(subobj, EVAS_CALLBACK_DEL,
1897 _elm_win_subobj_callback_del, obj);
1898 win->subobjs = eina_list_remove(win->subobjs, subobj);
1899 elm_widget_sub_object_del(obj, subobj);
1900 _elm_win_eval_subobjs(obj);
1904 elm_win_title_set(Evas_Object *obj, const char *title)
1907 ELM_CHECK_WIDTYPE(obj, widtype);
1908 win = elm_widget_data_get(obj);
1909 if (!win || !title) return;
1910 ecore_evas_title_set(win->ee, title);
1912 edje_object_part_text_set(win->frame_obj, "elm.text.title", title);
1916 elm_win_title_get(const Evas_Object *obj)
1919 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1920 win = elm_widget_data_get(obj);
1921 if (!win) return NULL;
1922 return ecore_evas_title_get(win->ee);
1926 elm_win_autodel_set(Evas_Object *obj, Eina_Bool autodel)
1929 ELM_CHECK_WIDTYPE(obj, widtype);
1930 win = elm_widget_data_get(obj);
1932 win->autodel = autodel;
1936 elm_win_autodel_get(const Evas_Object *obj)
1939 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1940 win = elm_widget_data_get(obj);
1941 if (!win) return EINA_FALSE;
1942 return win->autodel;
1946 elm_win_activate(Evas_Object *obj)
1949 ELM_CHECK_WIDTYPE(obj, widtype);
1950 win = elm_widget_data_get(obj);
1952 ecore_evas_activate(win->ee);
1956 elm_win_lower(Evas_Object *obj)
1959 ELM_CHECK_WIDTYPE(obj, widtype);
1960 win = elm_widget_data_get(obj);
1962 ecore_evas_lower(win->ee);
1966 elm_win_raise(Evas_Object *obj)
1969 ELM_CHECK_WIDTYPE(obj, widtype);
1970 win = elm_widget_data_get(obj);
1972 ecore_evas_raise(win->ee);
1976 elm_win_center(Evas_Object *obj, Eina_Bool h, Eina_Bool v)
1979 int win_w, win_h, screen_w, screen_h, nx, ny;
1980 ELM_CHECK_WIDTYPE(obj, widtype);
1981 win = elm_widget_data_get(obj);
1983 ecore_evas_screen_geometry_get(win->ee, NULL, NULL, &screen_w, &screen_h);
1984 if ((!screen_w) || (!screen_h)) return;
1985 evas_object_geometry_get(obj, NULL, NULL, &win_w, &win_h);
1986 if ((!win_w) || (!win_h)) return;
1987 if (h) nx = win_w >= screen_w ? 0 : (screen_w / 2) - (win_w / 2);
1988 else nx = win->screen.x;
1989 if (v) ny = win_h >= screen_h ? 0 : (screen_h / 2) - (win_h / 2);
1990 else ny = win->screen.y;
1993 evas_object_move(obj, nx, ny);
1997 elm_win_borderless_set(Evas_Object *obj, Eina_Bool borderless)
2000 ELM_CHECK_WIDTYPE(obj, widtype);
2001 win = elm_widget_data_get(obj);
2003 ecore_evas_borderless_set(win->ee, borderless);
2004 #ifdef HAVE_ELEMENTARY_X
2005 _elm_win_xwin_update(win);
2010 elm_win_borderless_get(const Evas_Object *obj)
2013 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2014 win = elm_widget_data_get(obj);
2015 if (!win) return EINA_FALSE;
2016 return ecore_evas_borderless_get(win->ee);
2020 elm_win_shaped_set(Evas_Object *obj, Eina_Bool shaped)
2023 ELM_CHECK_WIDTYPE(obj, widtype);
2024 win = elm_widget_data_get(obj);
2026 ecore_evas_shaped_set(win->ee, shaped);
2027 #ifdef HAVE_ELEMENTARY_X
2028 _elm_win_xwin_update(win);
2033 elm_win_shaped_get(const Evas_Object *obj)
2036 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2037 win = elm_widget_data_get(obj);
2038 if (!win) return EINA_FALSE;
2039 return ecore_evas_shaped_get(win->ee);
2043 elm_win_alpha_set(Evas_Object *obj, Eina_Bool alpha)
2046 ELM_CHECK_WIDTYPE(obj, widtype);
2047 win = elm_widget_data_get(obj);
2052 else if (win->img_obj)
2054 evas_object_image_alpha_set(win->img_obj, alpha);
2055 ecore_evas_alpha_set(win->ee, alpha);
2059 #ifdef HAVE_ELEMENTARY_X
2064 if (!_elm_config->compositing)
2065 elm_win_shaped_set(obj, alpha);
2067 ecore_evas_alpha_set(win->ee, alpha);
2070 ecore_evas_alpha_set(win->ee, alpha);
2071 _elm_win_xwin_update(win);
2075 ecore_evas_alpha_set(win->ee, alpha);
2080 elm_win_alpha_get(const Evas_Object *obj)
2083 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2084 win = elm_widget_data_get(obj);
2085 if (!win) return EINA_FALSE;
2089 else if (win->img_obj)
2091 return evas_object_image_alpha_get(win->img_obj);
2093 return ecore_evas_alpha_get(win->ee);
2097 elm_win_transparent_set(Evas_Object *obj, Eina_Bool transparent)
2100 ELM_CHECK_WIDTYPE(obj, widtype);
2101 win = elm_widget_data_get(obj);
2107 else if (win->img_obj)
2109 evas_object_image_alpha_set(win->img_obj, transparent);
2113 #ifdef HAVE_ELEMENTARY_X
2116 ecore_evas_transparent_set(win->ee, transparent);
2117 _elm_win_xwin_update(win);
2121 ecore_evas_transparent_set(win->ee, transparent);
2126 elm_win_transparent_get(const Evas_Object *obj)
2129 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2130 win = elm_widget_data_get(obj);
2131 if (!win) return EINA_FALSE;
2133 return ecore_evas_transparent_get(win->ee);
2137 elm_win_override_set(Evas_Object *obj, Eina_Bool override)
2140 ELM_CHECK_WIDTYPE(obj, widtype);
2141 win = elm_widget_data_get(obj);
2143 ecore_evas_override_set(win->ee, override);
2144 #ifdef HAVE_ELEMENTARY_X
2145 _elm_win_xwin_update(win);
2150 elm_win_override_get(const Evas_Object *obj)
2153 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2154 win = elm_widget_data_get(obj);
2155 if (!win) return EINA_FALSE;
2156 return ecore_evas_override_get(win->ee);
2160 elm_win_fullscreen_set(Evas_Object *obj, Eina_Bool fullscreen)
2163 ELM_CHECK_WIDTYPE(obj, widtype);
2164 win = elm_widget_data_get(obj);
2167 // YYY: handle if win->img_obj
2168 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
2169 if (ENGINE_COMPARE(ELM_SOFTWARE_FB) ||
2170 ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE))
2172 // these engines... can ONLY be fullscreen
2177 ecore_evas_fullscreen_set(win->ee, fullscreen);
2178 #ifdef HAVE_ELEMENTARY_X
2179 _elm_win_xwin_update(win);
2182 #undef ENGINE_COMPARE
2186 elm_win_fullscreen_get(const Evas_Object *obj)
2189 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2190 win = elm_widget_data_get(obj);
2191 if (!win) return EINA_FALSE;
2193 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
2194 if (ENGINE_COMPARE(ELM_SOFTWARE_FB) ||
2195 ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE))
2197 // these engines... can ONLY be fullscreen
2202 return ecore_evas_fullscreen_get(win->ee);
2204 #undef ENGINE_COMPARE
2208 elm_win_maximized_set(Evas_Object *obj, Eina_Bool maximized)
2211 ELM_CHECK_WIDTYPE(obj, widtype);
2212 win = elm_widget_data_get(obj);
2214 // YYY: handle if win->img_obj
2215 ecore_evas_maximized_set(win->ee, maximized);
2216 #ifdef HAVE_ELEMENTARY_X
2217 _elm_win_xwin_update(win);
2222 elm_win_maximized_get(const Evas_Object *obj)
2225 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2226 win = elm_widget_data_get(obj);
2227 if (!win) return EINA_FALSE;
2228 return ecore_evas_maximized_get(win->ee);
2232 elm_win_iconified_set(Evas_Object *obj, Eina_Bool iconified)
2235 ELM_CHECK_WIDTYPE(obj, widtype);
2236 win = elm_widget_data_get(obj);
2238 ecore_evas_iconified_set(win->ee, iconified);
2239 #ifdef HAVE_ELEMENTARY_X
2240 _elm_win_xwin_update(win);
2245 elm_win_iconified_get(const Evas_Object *obj)
2248 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2249 win = elm_widget_data_get(obj);
2250 if (!win) return EINA_FALSE;
2251 return ecore_evas_iconified_get(win->ee);
2255 elm_win_layer_set(Evas_Object *obj, int layer)
2258 ELM_CHECK_WIDTYPE(obj, widtype);
2259 win = elm_widget_data_get(obj);
2261 ecore_evas_layer_set(win->ee, layer);
2262 #ifdef HAVE_ELEMENTARY_X
2263 _elm_win_xwin_update(win);
2268 elm_win_layer_get(const Evas_Object *obj)
2271 ELM_CHECK_WIDTYPE(obj, widtype) -1;
2272 win = elm_widget_data_get(obj);
2273 if (!win) return -1;
2274 return ecore_evas_layer_get(win->ee);
2278 elm_win_rotation_set(Evas_Object *obj, int rotation)
2281 ELM_CHECK_WIDTYPE(obj, widtype);
2282 win = elm_widget_data_get(obj);
2284 if (win->rot == rotation) return;
2285 win->rot = rotation;
2286 ecore_evas_rotation_set(win->ee, rotation);
2287 evas_object_size_hint_min_set(obj, -1, -1);
2288 evas_object_size_hint_max_set(obj, -1, -1);
2289 _elm_win_eval_subobjs(obj);
2290 #ifdef HAVE_ELEMENTARY_X
2291 _elm_win_xwin_update(win);
2296 elm_win_rotation_with_resize_set(Evas_Object *obj, int rotation)
2299 ELM_CHECK_WIDTYPE(obj, widtype);
2300 win = elm_widget_data_get(obj);
2302 if (win->rot == rotation) return;
2303 win->rot = rotation;
2304 ecore_evas_rotation_with_resize_set(win->ee, rotation);
2305 evas_object_size_hint_min_set(obj, -1, -1);
2306 evas_object_size_hint_max_set(obj, -1, -1);
2307 _elm_win_eval_subobjs(obj);
2308 #ifdef HAVE_ELEMENTARY_X
2309 _elm_win_xwin_update(win);
2314 elm_win_rotation_get(const Evas_Object *obj)
2317 ELM_CHECK_WIDTYPE(obj, widtype) -1;
2318 win = elm_widget_data_get(obj);
2319 if (!win) return -1;
2324 elm_win_sticky_set(Evas_Object *obj, Eina_Bool sticky)
2327 ELM_CHECK_WIDTYPE(obj, widtype);
2328 win = elm_widget_data_get(obj);
2330 ecore_evas_sticky_set(win->ee, sticky);
2331 #ifdef HAVE_ELEMENTARY_X
2332 _elm_win_xwin_update(win);
2337 elm_win_sticky_get(const Evas_Object *obj)
2340 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2341 win = elm_widget_data_get(obj);
2342 if (!win) return EINA_FALSE;
2343 return ecore_evas_sticky_get(win->ee);
2347 elm_win_keyboard_mode_set(Evas_Object *obj, Elm_Win_Keyboard_Mode mode)
2350 ELM_CHECK_WIDTYPE(obj, widtype);
2351 win = elm_widget_data_get(obj);
2353 if (mode == win->kbdmode) return;
2354 #ifdef HAVE_ELEMENTARY_X
2355 _elm_win_xwindow_get(win);
2357 win->kbdmode = mode;
2358 #ifdef HAVE_ELEMENTARY_X
2360 ecore_x_e_virtual_keyboard_state_set
2361 (win->xwin, (Ecore_X_Virtual_Keyboard_State)win->kbdmode);
2365 EAPI Elm_Win_Keyboard_Mode
2366 elm_win_keyboard_mode_get(const Evas_Object *obj)
2369 ELM_CHECK_WIDTYPE(obj, widtype) ELM_WIN_KEYBOARD_UNKNOWN;
2370 win = elm_widget_data_get(obj);
2371 if (!win) return ELM_WIN_KEYBOARD_UNKNOWN;
2372 return win->kbdmode;
2376 elm_win_keyboard_win_set(Evas_Object *obj, Eina_Bool is_keyboard)
2379 ELM_CHECK_WIDTYPE(obj, widtype);
2380 win = elm_widget_data_get(obj);
2382 #ifdef HAVE_ELEMENTARY_X
2383 _elm_win_xwindow_get(win);
2385 ecore_x_e_virtual_keyboard_set(win->xwin, is_keyboard);
2392 elm_win_keyboard_win_get(const Evas_Object *obj)
2395 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2396 win = elm_widget_data_get(obj);
2397 if (!win) return EINA_FALSE;
2398 #ifdef HAVE_ELEMENTARY_X
2399 _elm_win_xwindow_get(win);
2401 return ecore_x_e_virtual_keyboard_get(win->xwin);
2407 elm_win_screen_position_get(const Evas_Object *obj, int *x, int *y)
2410 ELM_CHECK_WIDTYPE(obj, widtype);
2411 win = elm_widget_data_get(obj);
2413 if (x) *x = win->screen.x;
2414 if (y) *y = win->screen.y;
2418 elm_win_focus_get(const Evas_Object *obj)
2421 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2422 win = elm_widget_data_get(obj);
2423 if (!win) return EINA_FALSE;
2424 return ecore_evas_focus_get(win->ee);
2428 elm_win_screen_constrain_set(Evas_Object *obj, Eina_Bool constrain)
2431 ELM_CHECK_WIDTYPE(obj, widtype);
2432 win = elm_widget_data_get(obj);
2434 win->constrain = !!constrain;
2438 elm_win_screen_constrain_get(Evas_Object *obj)
2441 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2442 win = elm_widget_data_get(obj);
2443 if (!win) return EINA_FALSE;
2444 return win->constrain;
2448 elm_win_screen_size_get(const Evas_Object *obj, int *x, int *y, int *w, int *h)
2451 ELM_CHECK_WIDTYPE(obj, widtype);
2452 win = elm_widget_data_get(obj);
2454 ecore_evas_screen_geometry_get(win->ee, x, y, w, h);
2458 elm_win_conformant_set(Evas_Object *obj, Eina_Bool conformant)
2461 ELM_CHECK_WIDTYPE(obj, widtype);
2462 win = elm_widget_data_get(obj);
2464 #ifdef HAVE_ELEMENTARY_X
2465 _elm_win_xwindow_get(win);
2467 ecore_x_e_illume_conformant_set(win->xwin, conformant);
2474 elm_win_conformant_get(const Evas_Object *obj)
2477 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2478 win = elm_widget_data_get(obj);
2479 if (!win) return EINA_FALSE;
2480 #ifdef HAVE_ELEMENTARY_X
2481 _elm_win_xwindow_get(win);
2483 return ecore_x_e_illume_conformant_get(win->xwin);
2489 elm_win_quickpanel_set(Evas_Object *obj, Eina_Bool quickpanel)
2492 ELM_CHECK_WIDTYPE(obj, widtype);
2493 win = elm_widget_data_get(obj);
2495 #ifdef HAVE_ELEMENTARY_X
2496 _elm_win_xwindow_get(win);
2499 ecore_x_e_illume_quickpanel_set(win->xwin, quickpanel);
2502 Ecore_X_Window_State states[2];
2504 states[0] = ECORE_X_WINDOW_STATE_SKIP_TASKBAR;
2505 states[1] = ECORE_X_WINDOW_STATE_SKIP_PAGER;
2506 ecore_x_netwm_window_state_set(win->xwin, states, 2);
2507 ecore_x_icccm_hints_set(win->xwin, 0, 0, 0, 0, 0, 0, 0);
2516 elm_win_quickpanel_get(const Evas_Object *obj)
2519 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2520 win = elm_widget_data_get(obj);
2521 if (!win) return EINA_FALSE;
2522 #ifdef HAVE_ELEMENTARY_X
2523 _elm_win_xwindow_get(win);
2525 return ecore_x_e_illume_quickpanel_get(win->xwin);
2531 elm_win_quickpanel_priority_major_set(Evas_Object *obj, int priority)
2534 ELM_CHECK_WIDTYPE(obj, widtype);
2535 win = elm_widget_data_get(obj);
2537 #ifdef HAVE_ELEMENTARY_X
2538 _elm_win_xwindow_get(win);
2540 ecore_x_e_illume_quickpanel_priority_major_set(win->xwin, priority);
2547 elm_win_quickpanel_priority_major_get(const Evas_Object *obj)
2550 ELM_CHECK_WIDTYPE(obj, widtype) -1;
2551 win = elm_widget_data_get(obj);
2552 if (!win) return -1;
2553 #ifdef HAVE_ELEMENTARY_X
2554 _elm_win_xwindow_get(win);
2556 return ecore_x_e_illume_quickpanel_priority_major_get(win->xwin);
2562 elm_win_quickpanel_priority_minor_set(Evas_Object *obj, int priority)
2565 ELM_CHECK_WIDTYPE(obj, widtype);
2566 win = elm_widget_data_get(obj);
2568 #ifdef HAVE_ELEMENTARY_X
2569 _elm_win_xwindow_get(win);
2571 ecore_x_e_illume_quickpanel_priority_minor_set(win->xwin, priority);
2578 elm_win_quickpanel_priority_minor_get(const Evas_Object *obj)
2581 ELM_CHECK_WIDTYPE(obj, widtype) -1;
2582 win = elm_widget_data_get(obj);
2583 if (!win) return -1;
2584 #ifdef HAVE_ELEMENTARY_X
2585 _elm_win_xwindow_get(win);
2587 return ecore_x_e_illume_quickpanel_priority_minor_get(win->xwin);
2593 elm_win_quickpanel_zone_set(Evas_Object *obj, int zone)
2596 ELM_CHECK_WIDTYPE(obj, widtype);
2597 win = elm_widget_data_get(obj);
2599 #ifdef HAVE_ELEMENTARY_X
2600 _elm_win_xwindow_get(win);
2602 ecore_x_e_illume_quickpanel_zone_set(win->xwin, zone);
2609 elm_win_quickpanel_zone_get(const Evas_Object *obj)
2612 ELM_CHECK_WIDTYPE(obj, widtype) 0;
2613 win = elm_widget_data_get(obj);
2615 #ifdef HAVE_ELEMENTARY_X
2616 _elm_win_xwindow_get(win);
2618 return ecore_x_e_illume_quickpanel_zone_get(win->xwin);
2624 elm_win_prop_focus_skip_set(Evas_Object *obj, Eina_Bool skip)
2627 ELM_CHECK_WIDTYPE(obj, widtype);
2628 win = elm_widget_data_get(obj);
2630 #ifdef HAVE_ELEMENTARY_X
2631 _elm_win_xwindow_get(win);
2636 Ecore_X_Window_State states[2];
2638 ecore_x_icccm_hints_set(win->xwin, 0, 0, 0, 0, 0, 0, 0);
2639 states[0] = ECORE_X_WINDOW_STATE_SKIP_TASKBAR;
2640 states[1] = ECORE_X_WINDOW_STATE_SKIP_PAGER;
2641 ecore_x_netwm_window_state_set(win->xwin, states, 2);
2650 elm_win_illume_command_send(Evas_Object *obj, Elm_Illume_Command command, void *params __UNUSED__)
2653 ELM_CHECK_WIDTYPE(obj, widtype);
2654 win = elm_widget_data_get(obj);
2656 #ifdef HAVE_ELEMENTARY_X
2657 _elm_win_xwindow_get(win);
2662 case ELM_ILLUME_COMMAND_FOCUS_BACK:
2663 ecore_x_e_illume_focus_back_send(win->xwin);
2665 case ELM_ILLUME_COMMAND_FOCUS_FORWARD:
2666 ecore_x_e_illume_focus_forward_send(win->xwin);
2668 case ELM_ILLUME_COMMAND_FOCUS_HOME:
2669 ecore_x_e_illume_focus_home_send(win->xwin);
2671 case ELM_ILLUME_COMMAND_CLOSE:
2672 ecore_x_e_illume_close_send(win->xwin);
2684 elm_win_inlined_image_object_get(Evas_Object *obj)
2687 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2688 win = elm_widget_data_get(obj);
2689 if (!win) return NULL;
2690 return win->img_obj;
2694 elm_win_focus_highlight_enabled_set(Evas_Object *obj, Eina_Bool enabled)
2698 ELM_CHECK_WIDTYPE(obj, widtype);
2700 win = elm_widget_data_get(obj);
2701 enabled = !!enabled;
2702 if (win->focus_highlight.enabled == enabled)
2705 win->focus_highlight.enabled = enabled;
2707 if (win->focus_highlight.enabled)
2708 _elm_win_focus_highlight_init(win);
2710 _elm_win_focus_highlight_shutdown(win);
2714 elm_win_focus_highlight_enabled_get(const Evas_Object *obj)
2718 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2720 win = elm_widget_data_get(obj);
2721 return win->focus_highlight.enabled;
2725 elm_win_focus_highlight_style_set(Evas_Object *obj, const char *style)
2729 ELM_CHECK_WIDTYPE(obj, widtype);
2731 win = elm_widget_data_get(obj);
2732 eina_stringshare_replace(&win->focus_highlight.style, style);
2733 win->focus_highlight.changed_theme = EINA_TRUE;
2734 _elm_win_focus_highlight_reconfigure_job_start(win);
2738 elm_win_focus_highlight_style_get(const Evas_Object *obj)
2742 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2744 win = elm_widget_data_get(obj);
2745 return win->focus_highlight.style;
2748 typedef struct _Widget_Data Widget_Data;
2753 Evas_Object *content;
2756 static void _del_hook(Evas_Object *obj);
2757 static void _theme_hook(Evas_Object *obj);
2758 static void _sizing_eval(Evas_Object *obj);
2759 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
2760 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
2762 static const char *widtype2 = NULL;
2765 _del_hook(Evas_Object *obj)
2767 Widget_Data *wd = elm_widget_data_get(obj);
2773 _theme_hook(Evas_Object *obj)
2775 Widget_Data *wd = elm_widget_data_get(obj);
2776 _elm_theme_object_set(obj, wd->frm, "win", "inwin", elm_widget_style_get(obj));
2778 edje_object_part_swallow(wd->frm, "elm.swallow.content", wd->content);
2781 evas_object_smart_callback_call(obj, SIG_THEME_CHANGED, NULL);
2785 _elm_inwin_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
2787 Widget_Data *wd = elm_widget_data_get(obj);
2792 /* Try Focus cycle in subitem */
2795 elm_widget_focus_next_get(wd->content, dir, next);
2800 *next = (Evas_Object *)obj;
2805 _elm_inwin_text_set_hook(Evas_Object *obj, const char *item, const char *text)
2807 Widget_Data *wd = elm_widget_data_get(obj);
2809 if (!wd || !item) return;
2810 edje_object_part_text_set(wd->frm, item, text);
2815 _elm_inwin_text_get_hook(const Evas_Object *obj, const char *item)
2817 Widget_Data *wd = elm_widget_data_get(obj);
2819 if (!item || !wd || !wd->frm) return NULL;
2820 return edje_object_part_text_get(wd->frm, item);
2824 _sizing_eval(Evas_Object *obj)
2826 Widget_Data *wd = elm_widget_data_get(obj);
2827 Evas_Coord minw = -1, minh = -1;
2829 evas_object_size_hint_min_get(wd->content, &minw, &minh);
2830 edje_object_size_min_calc(wd->frm, &minw, &minh);
2831 evas_object_size_hint_min_set(obj, minw, minh);
2832 evas_object_size_hint_max_set(obj, -1, -1);
2836 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2842 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
2844 Widget_Data *wd = elm_widget_data_get(obj);
2845 Evas_Object *sub = event_info;
2846 if (sub == wd->content)
2848 evas_object_event_callback_del_full
2849 (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
2856 elm_win_inwin_add(Evas_Object *obj)
2862 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2863 win = elm_widget_data_get(obj);
2864 if (!win) return NULL;
2865 wd = ELM_NEW(Widget_Data);
2866 obj2 = elm_widget_add(win->evas);
2867 elm_widget_type_set(obj2, "inwin");
2868 ELM_SET_WIDTYPE(widtype2, "inwin");
2869 elm_widget_sub_object_add(obj, obj2);
2870 evas_object_size_hint_weight_set(obj2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2871 evas_object_size_hint_align_set(obj2, EVAS_HINT_FILL, EVAS_HINT_FILL);
2872 elm_win_resize_object_add(obj, obj2);
2874 elm_widget_data_set(obj2, wd);
2875 elm_widget_del_hook_set(obj2, _del_hook);
2876 elm_widget_theme_hook_set(obj2, _theme_hook);
2877 elm_widget_focus_next_hook_set(obj2, _elm_inwin_focus_next_hook);
2878 elm_widget_text_set_hook_set(obj2, _elm_inwin_text_set_hook);
2879 elm_widget_text_get_hook_set(obj2, _elm_inwin_text_get_hook);
2880 elm_widget_can_focus_set(obj2, EINA_TRUE);
2881 elm_widget_highlight_ignore_set(obj2, EINA_TRUE);
2883 wd->frm = edje_object_add(win->evas);
2884 _elm_theme_object_set(obj, wd->frm, "win", "inwin", "default");
2885 elm_widget_resize_object_set(obj2, wd->frm);
2887 evas_object_smart_callback_add(obj2, "sub-object-del", _sub_del, obj2);
2894 elm_win_inwin_activate(Evas_Object *obj)
2896 ELM_CHECK_WIDTYPE(obj, widtype2);
2897 Widget_Data *wd = elm_widget_data_get(obj);
2899 evas_object_raise(obj);
2900 evas_object_show(obj);
2901 edje_object_signal_emit(wd->frm, "elm,action,show", "elm");
2902 elm_object_focus_set(obj, EINA_TRUE);
2906 elm_win_inwin_content_set(Evas_Object *obj, Evas_Object *content)
2908 ELM_CHECK_WIDTYPE(obj, widtype2);
2909 Widget_Data *wd = elm_widget_data_get(obj);
2911 if (wd->content == content) return;
2912 if (wd->content) evas_object_del(wd->content);
2913 wd->content = content;
2916 elm_widget_sub_object_add(obj, content);
2917 evas_object_event_callback_add(content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
2918 _changed_size_hints, obj);
2919 edje_object_part_swallow(wd->frm, "elm.swallow.content", content);
2925 elm_win_inwin_content_get(const Evas_Object *obj)
2927 ELM_CHECK_WIDTYPE(obj, widtype2) NULL;
2928 Widget_Data *wd = elm_widget_data_get(obj);
2929 if (!wd) return NULL;
2934 elm_win_inwin_content_unset(Evas_Object *obj)
2936 ELM_CHECK_WIDTYPE(obj, widtype2) NULL;
2937 Widget_Data *wd = elm_widget_data_get(obj);
2938 if (!wd) return NULL;
2939 if (!wd->content) return NULL;
2940 Evas_Object *content = wd->content;
2941 elm_widget_sub_object_del(obj, wd->content);
2942 evas_object_event_callback_del_full(wd->content,
2943 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
2944 _changed_size_hints, obj);
2945 edje_object_part_unswallow(wd->frm, wd->content);
2951 elm_win_socket_listen(Evas_Object *obj, const char *svcname, int svcnum, Eina_Bool svcsys)
2956 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2957 win = elm_widget_data_get(obj);
2958 if (!win) return EINA_FALSE;
2959 if (!win->ee) return EINA_FALSE;
2961 if(!ecore_evas_extn_socket_listen(win->ee, svcname, svcnum, svcsys))
2967 /* windowing spcific calls - shall we do this differently? */
2969 static Ecore_X_Window
2970 _elm_ee_win_get(const Evas_Object *obj)
2973 #ifdef HAVE_ELEMENTARY_X
2974 Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
2975 if (ee) return (Ecore_X_Window)ecore_evas_window_get(ee);
2981 elm_win_xwindow_get(const Evas_Object *obj)
2987 type = elm_widget_type_get(obj);
2988 if ((!type) || (type != widtype)) return _elm_ee_win_get(obj);
2989 win = elm_widget_data_get(obj);
2991 #ifdef HAVE_ELEMENTARY_X
2992 if (win->xwin) return win->xwin;
2993 if (win->parent) return elm_win_xwindow_get(win->parent);