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;
21 Elm_Win_Indicator_Mode indmode;
28 Eina_Bool autodel : 1;
29 Eina_Bool constrain : 1;
30 Eina_Bool resizing : 1;
32 int *autodel_clear, rot;
41 Evas_Object *obj, *hot_obj;
49 Eina_Bool visible : 1;
50 Eina_Bool handled : 1;
54 Ecore_Job *reconf_job;
56 Eina_Bool enabled : 1;
57 Eina_Bool changed_theme : 1;
58 Eina_Bool top_animate : 1;
59 Eina_Bool geometry_changed : 1;
63 static const char *widtype = NULL;
64 static void _elm_win_obj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
65 static void _elm_win_obj_callback_img_obj_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
66 static void _elm_win_obj_callback_parent_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
67 static void _elm_win_obj_intercept_move(void *data, Evas_Object *obj, Evas_Coord x, Evas_Coord y);
68 static void _elm_win_obj_intercept_show(void *data, Evas_Object *obj);
69 static void _elm_win_move(Ecore_Evas *ee);
70 static void _elm_win_resize(Ecore_Evas *ee);
71 static void _elm_win_delete_request(Ecore_Evas *ee);
72 static void _elm_win_resize_job(void *data);
73 #ifdef HAVE_ELEMENTARY_X
74 static void _elm_win_xwin_update(Elm_Win *win);
76 static void _elm_win_eval_subobjs(Evas_Object *obj);
77 static void _elm_win_subobj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
78 static void _elm_win_subobj_callback_changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
79 static void _elm_win_focus_highlight_init(Elm_Win *win);
80 static void _elm_win_focus_highlight_shutdown(Elm_Win *win);
81 static void _elm_win_focus_highlight_visible_set(Elm_Win *win, Eina_Bool visible);
82 static void _elm_win_focus_highlight_reconfigure_job_start(Elm_Win *win);
83 static void _elm_win_focus_highlight_reconfigure_job_stop(Elm_Win *win);
84 static void _elm_win_focus_highlight_anim_end(void *data, Evas_Object *obj, const char *emission, const char *source);
85 static void _elm_win_focus_highlight_reconfigure(Elm_Win *win);
87 static void _elm_win_frame_add(Elm_Win *win, const char *style);
88 static void _elm_win_frame_cb_move_start(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__);
89 static void _elm_win_frame_cb_resize_start(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source);
90 static void _elm_win_frame_cb_minimize(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__);
91 static void _elm_win_frame_cb_maximize(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__);
92 static void _elm_win_frame_cb_close(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__);
94 static void _elm_win_pointer_add(Elm_Win *win, const char *style);
96 static const char SIG_DELETE_REQUEST[] = "delete,request";
97 static const char SIG_FOCUS_OUT[] = "focus,out";
98 static const char SIG_FOCUS_IN[] = "focus,in";
99 static const char SIG_MOVED[] = "moved";
100 static const char SIG_THEME_CHANGED[] = "theme,changed";
102 static const Evas_Smart_Cb_Description _signals[] = {
103 {SIG_DELETE_REQUEST, ""},
112 Eina_List *_elm_win_list = NULL;
113 int _elm_win_deferred_free = 0;
115 // exmaple shot spec (wait 0.1 sec then save as my-window.png):
116 // ELM_ENGINE="shot:delay=0.1:file=my-window.png"
119 _shot_delay_get(Elm_Win *win)
122 char *d = strdup(win->shot.info);
125 for (p = (char *)win->shot.info; *p; p++)
127 if (!strncmp(p, "delay=", 6))
131 for (pd = d, p += 6; (*p) && (*p != ':'); p++, pd++)
146 _shot_file_get(Elm_Win *win)
149 char *tmp = strdup(win->shot.info);
150 char *repname = NULL;
152 if (!tmp) return NULL;
154 for (p = (char *)win->shot.info; *p; p++)
156 if (!strncmp(p, "file=", 5))
159 if (!win->shot.repeat_count) return tmp;
162 char *dotptr = strrchr(tmp, '.');
165 size_t size = sizeof(char)*(strlen(tmp) + 16);
166 repname = malloc(size);
167 strncpy(repname, tmp, dotptr - tmp);
168 snprintf(repname + (dotptr - tmp), size - (dotptr - tmp), "%03i",
169 win->shot.shot_counter + 1);
170 strcat(repname, dotptr);
178 if (!win->shot.repeat_count) return strdup("out.png");
180 repname = malloc(sizeof(char) * 24);
181 snprintf(repname, sizeof(char) * 24, "out%03i.png", win->shot.shot_counter + 1);
186 _shot_repeat_count_get(Elm_Win *win)
189 char *d = strdup(win->shot.info);
192 for (p = (char *)win->shot.info; *p; p++)
194 if (!strncmp(p, "repeat=", 7))
198 for (pd = d, p += 7; (*p) && (*p != ':'); p++, pd++)
205 if (v > 1000) v = 999;
215 _shot_key_get(Elm_Win *win __UNUSED__)
221 _shot_flags_get(Elm_Win *win __UNUSED__)
227 _shot_do(Elm_Win *win)
231 unsigned int *pixels;
233 char *file, *key, *flags;
235 ecore_evas_manual_render(win->ee);
236 pixels = (void *)ecore_evas_buffer_pixels_get(win->ee);
238 ecore_evas_geometry_get(win->ee, NULL, NULL, &w, &h);
239 if ((w < 1) || (h < 1)) return;
240 file = _shot_file_get(win);
242 key = _shot_key_get(win);
243 flags = _shot_flags_get(win);
244 ee = ecore_evas_buffer_new(1, 1);
245 o = evas_object_image_add(ecore_evas_get(ee));
246 evas_object_image_alpha_set(o, ecore_evas_alpha_get(win->ee));
247 evas_object_image_size_set(o, w, h);
248 evas_object_image_data_set(o, pixels);
249 if (!evas_object_image_save(o, file, key, flags))
251 ERR("Cannot save window to '%s' (key '%s', flags '%s')",
256 if (flags) free(flags);
258 if (win->shot.repeat_count) win->shot.shot_counter++;
262 _shot_delay(void *data)
266 if (win->shot.repeat_count)
268 int remainshot = (win->shot.repeat_count - win->shot.shot_counter);
269 if (remainshot > 0) return EINA_TRUE;
271 win->shot.timer = NULL;
277 _shot_init(Elm_Win *win)
279 if (!win->shot.info) return;
280 win->shot.repeat_count = _shot_repeat_count_get(win);
281 win->shot.shot_counter = 0;
285 _shot_handle(Elm_Win *win)
287 if (!win->shot.info) return;
288 win->shot.timer = ecore_timer_add(_shot_delay_get(win), _shot_delay, win);
292 _elm_win_move(Ecore_Evas *ee)
294 Evas_Object *obj = ecore_evas_object_associate_get(ee);
299 win = elm_widget_data_get(obj);
301 ecore_evas_geometry_get(ee, &x, &y, NULL, NULL);
304 evas_object_smart_callback_call(win->win_obj, SIG_MOVED, NULL);
308 _elm_win_resize(Ecore_Evas *ee)
310 Evas_Object *obj = ecore_evas_object_associate_get(ee);
314 win = elm_widget_data_get(obj);
316 if (win->deferred_resize_job) ecore_job_del(win->deferred_resize_job);
317 win->deferred_resize_job = ecore_job_add(_elm_win_resize_job, win);
321 _elm_win_mouse_in(Ecore_Evas *ee)
326 if (!(obj = ecore_evas_object_associate_get(ee))) return;
327 if (!(win = elm_widget_data_get(obj))) return;
328 if (win->resizing) win->resizing = EINA_FALSE;
332 _elm_win_focus_in(Ecore_Evas *ee)
334 Evas_Object *obj = ecore_evas_object_associate_get(ee);
338 win = elm_widget_data_get(obj);
340 _elm_widget_top_win_focused_set(win->win_obj, EINA_TRUE);
341 if (!elm_widget_focus_order_get(obj))
343 elm_widget_focus_steal(win->win_obj);
347 elm_widget_focus_restore(win->win_obj);
348 evas_object_smart_callback_call(win->win_obj, SIG_FOCUS_IN, NULL);
349 win->focus_highlight.cur.visible = EINA_TRUE;
350 _elm_win_focus_highlight_reconfigure_job_start(win);
353 edje_object_signal_emit(win->frame_obj, "elm,action,focus", "elm");
355 else if (win->img_obj)
362 _elm_win_focus_out(Ecore_Evas *ee)
364 Evas_Object *obj = ecore_evas_object_associate_get(ee);
368 win = elm_widget_data_get(obj);
370 elm_object_focus_set(win->win_obj, EINA_FALSE);
371 _elm_widget_top_win_focused_set(win->win_obj, EINA_FALSE);
372 evas_object_smart_callback_call(win->win_obj, SIG_FOCUS_OUT, NULL);
373 win->focus_highlight.cur.visible = EINA_FALSE;
374 _elm_win_focus_highlight_reconfigure_job_start(win);
377 edje_object_signal_emit(win->frame_obj, "elm,action,unfocus", "elm");
379 else if (win->img_obj)
386 _elm_win_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
388 Elm_Win *wd = elm_widget_data_get(obj);
389 const Eina_List *items;
390 void *(*list_data_get) (const Eina_List *list);
398 if (!(items = elm_widget_focus_custom_chain_get(obj)))
404 list_data_get = eina_list_data_get;
406 elm_widget_focus_list_next_get(obj, items, list_data_get, dir, next);
412 *next = (Evas_Object *)obj;
417 _elm_win_on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
419 Elm_Win *win = elm_widget_data_get(obj);
423 evas_object_focus_set(win->img_obj, elm_widget_focus_get(obj));
425 evas_object_focus_set(obj, elm_widget_focus_get(obj));
429 _elm_win_event_cb(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
431 if (type == EVAS_CALLBACK_KEY_DOWN)
433 Evas_Event_Key_Down *ev = event_info;
434 if (!strcmp(ev->keyname, "Tab"))
436 if (evas_key_modifier_is_set(ev->modifiers, "Shift"))
437 elm_widget_focus_cycle(obj, ELM_FOCUS_PREVIOUS);
439 elm_widget_focus_cycle(obj, ELM_FOCUS_NEXT);
440 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
443 else if ((!strcmp(ev->keyname, "Left")) ||
444 (!strcmp(ev->keyname, "KP_Left")))
446 //TODO : woohyun jung
448 else if ((!strcmp(ev->keyname, "Right")) ||
449 (!strcmp(ev->keyname, "KP_Right")))
451 //TODO : woohyun jung
453 else if ((!strcmp(ev->keyname, "Up")) ||
454 (!strcmp(ev->keyname, "KP_Up")))
456 //TODO : woohyun jung
458 else if ((!strcmp(ev->keyname, "Down")) ||
459 (!strcmp(ev->keyname, "KP_Down")))
461 //TODO : woohyun jung
469 _deferred_ecore_evas_free(void *data)
471 ecore_evas_free(data);
472 _elm_win_deferred_free--;
476 _elm_win_obj_callback_show(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
480 if (!win->show_count) win->show_count++;
481 if (win->shot.info) _shot_handle(win);
485 _elm_win_obj_callback_hide(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
491 evas_object_hide(win->frame_obj);
493 else if (win->img_obj)
495 evas_object_hide(win->img_obj);
497 if (win->pointer.obj)
499 evas_object_hide(win->pointer.obj);
500 ecore_evas_hide(win->pointer.ee);
505 _elm_win_obj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info __UNUSED__)
512 evas_object_event_callback_del_full(win->parent, EVAS_CALLBACK_DEL,
513 _elm_win_obj_callback_parent_del, win);
516 if (win->autodel_clear) *(win->autodel_clear) = -1;
517 _elm_win_list = eina_list_remove(_elm_win_list, win->win_obj);
518 while (win->subobjs) elm_win_resize_object_del(obj, win->subobjs->data);
521 ecore_evas_callback_delete_request_set(win->ee, NULL);
522 ecore_evas_callback_resize_set(win->ee, NULL);
524 if (win->deferred_resize_job) ecore_job_del(win->deferred_resize_job);
525 if (win->deferred_child_eval_job) ecore_job_del(win->deferred_child_eval_job);
526 if (win->shot.info) eina_stringshare_del(win->shot.info);
527 if (win->shot.timer) ecore_timer_del(win->shot.timer);
528 evas_object_event_callback_del_full(win->win_obj, EVAS_CALLBACK_DEL,
529 _elm_win_obj_callback_del, win);
530 while (((child = evas_object_bottom_get(win->evas))) &&
533 evas_object_del(child);
535 while (((child = evas_object_top_get(win->evas))) &&
538 evas_object_del(child);
540 #ifdef HAVE_ELEMENTARY_X
541 if (win->client_message_handler)
542 ecore_event_handler_del(win->client_message_handler);
544 // FIXME: Why are we flushing edje on every window destroy ??
545 // edje_file_cache_flush();
546 // edje_collection_cache_flush();
547 // evas_image_cache_flush(win->evas);
548 // evas_font_cache_flush(win->evas);
549 // FIXME: we are in the del handler for the object and delete the canvas
550 // that lives under it from the handler... nasty. deferring doesn't help either
560 ecore_job_add(_deferred_ecore_evas_free, win->ee);
561 _elm_win_deferred_free++;
565 _elm_win_focus_highlight_shutdown(win);
566 eina_stringshare_del(win->focus_highlight.style);
570 if ((!_elm_win_list) &&
571 (elm_policy_get(ELM_POLICY_QUIT) == ELM_POLICY_QUIT_LAST_WINDOW_CLOSED))
573 edje_file_cache_flush();
574 edje_collection_cache_flush();
575 evas_image_cache_flush(e);
576 evas_font_cache_flush(e);
582 _elm_win_obj_callback_img_obj_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
585 if (!win->img_obj) return;
586 evas_object_event_callback_del_full
587 (win->img_obj, EVAS_CALLBACK_DEL, _elm_win_obj_callback_img_obj_del, win);
588 evas_object_del(win->img_obj);
592 _elm_win_obj_callback_parent_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
595 if (obj == win->parent) win->parent = NULL;
599 _elm_win_obj_intercept_move(void *data, Evas_Object *obj, Evas_Coord x, Evas_Coord y)
605 if ((x != win->screen.x) || (y != win->screen.y))
609 evas_object_smart_callback_call(win->win_obj, SIG_MOVED, NULL);
614 evas_object_move(obj, x, y);
619 _elm_win_obj_intercept_show(void *data, Evas_Object *obj)
622 // this is called to make sure all smart containers have calculated their
623 // sizes BEFORE we show the window to make sure it initially appears at
624 // our desired size (ie min size is known first)
625 evas_smart_objects_calculate(evas_object_evas_get(obj));
628 evas_object_show(win->frame_obj);
630 else if (win->img_obj)
632 evas_object_show(win->img_obj);
634 if (win->pointer.obj)
636 ecore_evas_show(win->pointer.ee);
637 evas_object_show(win->pointer.obj);
638 ecore_evas_wayland_pointer_set(win->pointer.ee, 10, 10);
640 evas_object_show(obj);
644 _elm_win_obj_callback_move(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
648 if (ecore_evas_override_get(win->ee))
652 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
655 evas_object_smart_callback_call(win->win_obj, SIG_MOVED, NULL);
661 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
665 else if (win->img_obj)
669 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
672 // evas_object_move(win->img_obj, x, y);
677 _elm_win_obj_callback_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
684 else if (win->img_obj)
686 Evas_Coord w = 1, h = 1;
688 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
692 ecore_evas_screen_geometry_get(win->ee, NULL, NULL, &sw, &sh);
698 evas_object_image_size_set(win->img_obj, w, h);
703 _elm_win_delete_request(Ecore_Evas *ee)
705 Evas_Object *obj = ecore_evas_object_associate_get(ee);
707 if (strcmp(elm_widget_type_get(obj), "win")) return;
709 win = elm_widget_data_get(obj);
711 int autodel = win->autodel;
712 win->autodel_clear = &autodel;
713 evas_object_ref(win->win_obj);
714 evas_object_smart_callback_call(win->win_obj, SIG_DELETE_REQUEST, NULL);
715 // FIXME: if above callback deletes - then the below will be invalid
716 if (autodel) evas_object_del(win->win_obj);
717 else win->autodel_clear = NULL;
718 evas_object_unref(win->win_obj);
722 _elm_win_resize_job(void *data)
729 win->deferred_resize_job = NULL;
730 ecore_evas_request_geometry_get(win->ee, NULL, NULL, &w, &h);
734 ecore_evas_screen_geometry_get(win->ee, NULL, NULL, &sw, &sh);
740 evas_object_resize(win->frame_obj, w, h);
742 else if (win->img_obj)
745 evas_object_resize(win->win_obj, w, h);
746 EINA_LIST_FOREACH(win->subobjs, l, obj)
748 evas_object_move(obj, 0, 0);
749 evas_object_resize(obj, w, h);
753 #ifdef HAVE_ELEMENTARY_X
755 _elm_win_xwindow_get(Elm_Win *win)
759 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
760 if (ENGINE_COMPARE(ELM_SOFTWARE_X11))
762 if (win->ee) win->xwin = ecore_evas_software_x11_window_get(win->ee);
764 else if (ENGINE_COMPARE(ELM_SOFTWARE_X11) ||
765 ENGINE_COMPARE(ELM_SOFTWARE_FB) ||
766 ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE) ||
767 ENGINE_COMPARE(ELM_SOFTWARE_SDL) ||
768 ENGINE_COMPARE(ELM_SOFTWARE_16_SDL) ||
769 ENGINE_COMPARE(ELM_OPENGL_SDL) ||
770 ENGINE_COMPARE(ELM_OPENGL_COCOA))
773 else if (ENGINE_COMPARE(ELM_SOFTWARE_16_X11))
775 if (win->ee) win->xwin = ecore_evas_software_x11_16_window_get(win->ee);
777 else if (ENGINE_COMPARE(ELM_SOFTWARE_8_X11))
779 if (win->ee) win->xwin = ecore_evas_software_x11_8_window_get(win->ee);
782 else if (ENGINE_COMPARE(ELM_XRENDER_X11))
784 if (win->ee) win->xwin = ecore_evas_xrender_x11_window_get(win->ee);
787 else if (ENGINE_COMPARE(ELM_OPENGL_X11))
789 if (win->ee) win->xwin = ecore_evas_gl_x11_window_get(win->ee);
791 else if (ENGINE_COMPARE(ELM_SOFTWARE_WIN32))
793 if (win->ee) win->xwin = (long)ecore_evas_win32_window_get(win->ee);
795 #undef ENGINE_COMPARE
799 #ifdef HAVE_ELEMENTARY_X
801 _elm_win_xwin_update(Elm_Win *win)
803 _elm_win_xwindow_get(win);
808 win2 = elm_widget_data_get(win->parent);
812 ecore_x_icccm_transient_for_set(win->xwin, win2->xwin);
816 if (!win->xwin) return; /* nothing more to do */
821 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_NORMAL);
823 case ELM_WIN_DIALOG_BASIC:
824 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DIALOG);
826 case ELM_WIN_DESKTOP:
827 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DESKTOP);
830 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DOCK);
832 case ELM_WIN_TOOLBAR:
833 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_TOOLBAR);
836 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_MENU);
838 case ELM_WIN_UTILITY:
839 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_UTILITY);
842 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_SPLASH);
844 case ELM_WIN_DROPDOWN_MENU:
845 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DROPDOWN_MENU);
847 case ELM_WIN_POPUP_MENU:
848 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_POPUP_MENU);
850 case ELM_WIN_TOOLTIP:
851 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_TOOLTIP);
853 case ELM_WIN_NOTIFICATION:
854 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_NOTIFICATION);
857 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_COMBO);
860 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DND);
865 ecore_x_e_virtual_keyboard_state_set
866 (win->xwin, (Ecore_X_Virtual_Keyboard_State)win->kbdmode);
867 if (win->indmode == ELM_WIN_INDICATOR_SHOW)
868 ecore_x_e_illume_indicator_state_set
869 (win->xwin, ECORE_X_ILLUME_INDICATOR_STATE_ON);
870 else if (win->indmode == ELM_WIN_INDICATOR_HIDE)
871 ecore_x_e_illume_indicator_state_set
872 (win->xwin, ECORE_X_ILLUME_INDICATOR_STATE_OFF);
877 _elm_win_eval_subobjs(Evas_Object *obj)
880 const Evas_Object *child;
882 Elm_Win *win = elm_widget_data_get(obj);
883 Evas_Coord w, h, minw = -1, minh = -1, maxw = -1, maxh = -1;
887 EINA_LIST_FOREACH(win->subobjs, l, child)
889 evas_object_size_hint_weight_get(child, &wx, &wy);
890 if (wx == 0.0) xx = 0;
891 if (wy == 0.0) xy = 0;
893 evas_object_size_hint_min_get(child, &w, &h);
896 if (w > minw) minw = w;
897 if (h > minh) minh = h;
899 evas_object_size_hint_max_get(child, &w, &h);
902 if (maxw == -1) maxw = w;
903 else if ((w > 0) && (w < maxw)) maxw = w;
904 if (maxh == -1) maxh = h;
905 else if ((h > 0) && (h < maxh)) maxh = h;
907 if (!xx) maxw = minw;
909 if (!xy) maxh = minh;
911 evas_object_size_hint_min_set(obj, minw, minh);
912 evas_object_size_hint_max_set(obj, maxw, maxh);
913 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
914 if (w < minw) w = minw;
915 if (h < minh) h = minh;
916 if ((maxw >= 0) && (w > maxw)) w = maxw;
917 if ((maxh >= 0) && (h > maxh)) h = maxh;
918 evas_object_resize(obj, w, h);
922 _elm_win_subobj_callback_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
924 Elm_Win *win = elm_widget_data_get(data);
925 win->subobjs = eina_list_remove(win->subobjs, obj);
926 _elm_win_eval_subobjs(win->win_obj);
930 _elm_win_subobj_callback_changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
932 _elm_win_eval_subobjs(data);
936 _elm_win_shutdown(void)
938 while (_elm_win_list)
939 evas_object_del(_elm_win_list->data);
943 _elm_win_rescale(Elm_Theme *th, Eina_Bool use_theme)
950 EINA_LIST_FOREACH(_elm_win_list, l, obj)
951 elm_widget_theme(obj);
955 EINA_LIST_FOREACH(_elm_win_list, l, obj)
956 elm_widget_theme_specific(obj, th, EINA_FALSE);
961 _elm_win_translate(void)
966 EINA_LIST_FOREACH(_elm_win_list, l, obj)
967 elm_widget_translate(obj);
970 #ifdef HAVE_ELEMENTARY_X
972 _elm_win_client_message(void *data, int type __UNUSED__, void *event)
975 Ecore_X_Event_Client_Message *e = event;
977 if (e->format != 32) return ECORE_CALLBACK_PASS_ON;
978 if (e->message_type == ECORE_X_ATOM_E_COMP_FLUSH)
980 if ((unsigned)e->data.l[0] == win->xwin)
982 Evas *evas = evas_object_evas_get(win->win_obj);
985 edje_file_cache_flush();
986 edje_collection_cache_flush();
987 evas_image_cache_flush(evas);
988 evas_font_cache_flush(evas);
992 else if (e->message_type == ECORE_X_ATOM_E_COMP_DUMP)
994 if ((unsigned)e->data.l[0] == win->xwin)
996 Evas *evas = evas_object_evas_get(win->win_obj);
999 edje_file_cache_flush();
1000 edje_collection_cache_flush();
1001 evas_image_cache_flush(evas);
1002 evas_font_cache_flush(evas);
1003 evas_render_dump(evas);
1007 return ECORE_CALLBACK_PASS_ON;
1012 _elm_win_focus_target_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1014 Elm_Win *win = data;
1016 win->focus_highlight.geometry_changed = EINA_TRUE;
1017 _elm_win_focus_highlight_reconfigure_job_start(win);
1021 _elm_win_focus_target_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1023 Elm_Win *win = data;
1025 win->focus_highlight.geometry_changed = EINA_TRUE;
1026 _elm_win_focus_highlight_reconfigure_job_start(win);
1030 _elm_win_focus_target_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1032 Elm_Win *win = data;
1034 win->focus_highlight.cur.target = NULL;
1036 _elm_win_focus_highlight_reconfigure_job_start(win);
1040 _elm_win_focus_target_callbacks_add(Elm_Win *win)
1042 Evas_Object *obj = win->focus_highlight.cur.target;
1044 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE,
1045 _elm_win_focus_target_move, win);
1046 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE,
1047 _elm_win_focus_target_resize, win);
1048 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
1049 _elm_win_focus_target_del, win);
1053 _elm_win_focus_target_callbacks_del(Elm_Win *win)
1055 Evas_Object *obj = win->focus_highlight.cur.target;
1057 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_MOVE,
1058 _elm_win_focus_target_move, win);
1059 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_RESIZE,
1060 _elm_win_focus_target_resize, win);
1061 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL,
1062 _elm_win_focus_target_del, win);
1065 static Evas_Object *
1066 _elm_win_focus_target_get(Evas_Object *obj)
1068 Evas_Object *o = obj;
1072 if (elm_widget_is(o))
1074 if (!elm_widget_highlight_ignore_get(o))
1076 o = elm_widget_parent_get(o);
1078 o = evas_object_smart_parent_get(o);
1082 o = elm_widget_parent_widget_get(o);
1084 o = evas_object_smart_parent_get(o);
1093 _elm_win_object_focus_in(void *data, Evas *e __UNUSED__, void *event_info)
1095 Evas_Object *obj = event_info, *target;
1096 Elm_Win *win = data;
1098 if (win->focus_highlight.cur.target == obj)
1101 target = _elm_win_focus_target_get(obj);
1102 win->focus_highlight.cur.target = target;
1103 if (elm_widget_highlight_in_theme_get(target))
1104 win->focus_highlight.cur.handled = EINA_TRUE;
1106 _elm_win_focus_target_callbacks_add(win);
1108 _elm_win_focus_highlight_reconfigure_job_start(win);
1112 _elm_win_object_focus_out(void *data, Evas *e __UNUSED__, void *event_info __UNUSED__)
1114 Elm_Win *win = data;
1116 if (!win->focus_highlight.cur.target)
1119 if (!win->focus_highlight.cur.handled)
1120 _elm_win_focus_target_callbacks_del(win);
1121 win->focus_highlight.cur.target = NULL;
1122 win->focus_highlight.cur.handled = EINA_FALSE;
1124 _elm_win_focus_highlight_reconfigure_job_start(win);
1128 _elm_win_focus_highlight_hide(void *data __UNUSED__, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
1130 evas_object_hide(obj);
1134 _elm_win_focus_highlight_init(Elm_Win *win)
1136 evas_event_callback_add(win->evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
1137 _elm_win_object_focus_in, win);
1138 evas_event_callback_add(win->evas,
1139 EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
1140 _elm_win_object_focus_out, win);
1142 win->focus_highlight.cur.target = evas_focus_get(win->evas);
1144 win->focus_highlight.top = edje_object_add(win->evas);
1145 win->focus_highlight.changed_theme = EINA_TRUE;
1146 edje_object_signal_callback_add(win->focus_highlight.top,
1147 "elm,action,focus,hide,end", "",
1148 _elm_win_focus_highlight_hide, NULL);
1149 edje_object_signal_callback_add(win->focus_highlight.top,
1150 "elm,action,focus,anim,end", "",
1151 _elm_win_focus_highlight_anim_end, win);
1152 _elm_win_focus_highlight_reconfigure_job_start(win);
1156 _elm_win_focus_highlight_shutdown(Elm_Win *win)
1158 _elm_win_focus_highlight_reconfigure_job_stop(win);
1159 if (win->focus_highlight.cur.target)
1161 _elm_win_focus_target_callbacks_del(win);
1162 win->focus_highlight.cur.target = NULL;
1164 if (win->focus_highlight.top)
1166 evas_object_del(win->focus_highlight.top);
1167 win->focus_highlight.top = NULL;
1170 evas_event_callback_del_full(win->evas,
1171 EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
1172 _elm_win_object_focus_in, win);
1173 evas_event_callback_del_full(win->evas,
1174 EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
1175 _elm_win_object_focus_out, win);
1179 _elm_win_focus_highlight_visible_set(Elm_Win *win, Eina_Bool visible)
1183 top = win->focus_highlight.top;
1188 evas_object_show(top);
1189 edje_object_signal_emit(top, "elm,action,focus,show", "elm");
1195 edje_object_signal_emit(top, "elm,action,focus,hide", "elm");
1200 _elm_win_focus_highlight_reconfigure_job(void *data)
1202 _elm_win_focus_highlight_reconfigure((Elm_Win *)data);
1206 _elm_win_focus_highlight_reconfigure_job_start(Elm_Win *win)
1208 if (win->focus_highlight.reconf_job)
1209 ecore_job_del(win->focus_highlight.reconf_job);
1210 win->focus_highlight.reconf_job = ecore_job_add(
1211 _elm_win_focus_highlight_reconfigure_job, win);
1215 _elm_win_focus_highlight_reconfigure_job_stop(Elm_Win *win)
1217 if (win->focus_highlight.reconf_job)
1218 ecore_job_del(win->focus_highlight.reconf_job);
1219 win->focus_highlight.reconf_job = NULL;
1223 _elm_win_focus_highlight_simple_setup(Elm_Win *win, Evas_Object *obj)
1225 Evas_Object *clip, *target = win->focus_highlight.cur.target;
1226 Evas_Coord x, y, w, h;
1228 clip = evas_object_clip_get(target);
1229 evas_object_geometry_get(target, &x, &y, &w, &h);
1231 evas_object_move(obj, x, y);
1232 evas_object_resize(obj, w, h);
1233 evas_object_clip_set(obj, clip);
1237 _elm_win_focus_highlight_anim_setup(Elm_Win *win, Evas_Object *obj)
1239 Evas_Coord tx, ty, tw, th;
1240 Evas_Coord w, h, px, py, pw, ph;
1241 Edje_Message_Int_Set *m;
1242 Evas_Object *previous = win->focus_highlight.prev.target;
1243 Evas_Object *target = win->focus_highlight.cur.target;
1245 evas_object_geometry_get(win->win_obj, NULL, NULL, &w, &h);
1246 evas_object_geometry_get(target, &tx, &ty, &tw, &th);
1247 evas_object_geometry_get(previous, &px, &py, &pw, &ph);
1248 evas_object_move(obj, 0, 0);
1249 evas_object_resize(obj, tw, th);
1250 evas_object_clip_unset(obj);
1252 m = alloca(sizeof(*m) + (sizeof(int) * 8));
1262 edje_object_message_send(obj, EDJE_MESSAGE_INT_SET, 1, m);
1266 _elm_win_focus_highlight_anim_end(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
1268 Elm_Win *win = data;
1269 _elm_win_focus_highlight_simple_setup(win, obj);
1273 _elm_win_focus_highlight_reconfigure(Elm_Win *win)
1275 Evas_Object *target = win->focus_highlight.cur.target;
1276 Evas_Object *previous = win->focus_highlight.prev.target;
1277 Evas_Object *top = win->focus_highlight.top;
1278 Eina_Bool visible_changed;
1279 Eina_Bool common_visible;
1280 const char *sig = NULL;
1282 _elm_win_focus_highlight_reconfigure_job_stop(win);
1284 visible_changed = (win->focus_highlight.cur.visible !=
1285 win->focus_highlight.prev.visible);
1287 if ((target == previous) && (!visible_changed) &&
1288 (!win->focus_highlight.geometry_changed))
1291 if ((previous) && (win->focus_highlight.prev.handled))
1292 elm_widget_signal_emit(previous, "elm,action,focus_highlight,hide", "elm");
1295 common_visible = EINA_FALSE;
1296 else if (win->focus_highlight.cur.handled)
1298 common_visible = EINA_FALSE;
1299 if (win->focus_highlight.cur.visible)
1300 sig = "elm,action,focus_highlight,show";
1302 sig = "elm,action,focus_highlight,hide";
1305 common_visible = win->focus_highlight.cur.visible;
1307 _elm_win_focus_highlight_visible_set(win, common_visible);
1309 elm_widget_signal_emit(target, sig, "elm");
1311 if ((!target) || (!common_visible) || (win->focus_highlight.cur.handled))
1314 if (win->focus_highlight.changed_theme)
1317 if (win->focus_highlight.style)
1318 str = win->focus_highlight.style;
1321 _elm_theme_object_set(win->win_obj, top, "focus_highlight", "top",
1323 win->focus_highlight.changed_theme = EINA_FALSE;
1325 if (_elm_config->focus_highlight_animate)
1327 str = edje_object_data_get(win->focus_highlight.top, "animate");
1328 win->focus_highlight.top_animate = ((str) && (!strcmp(str, "on")));
1332 if ((win->focus_highlight.top_animate) && (previous) &&
1333 (!win->focus_highlight.prev.handled))
1334 _elm_win_focus_highlight_anim_setup(win, top);
1336 _elm_win_focus_highlight_simple_setup(win, top);
1337 evas_object_raise(top);
1340 win->focus_highlight.geometry_changed = EINA_FALSE;
1341 win->focus_highlight.prev = win->focus_highlight.cur;
1345 _elm_win_frame_add(Elm_Win *win, const char *style)
1347 evas_output_framespace_set(win->evas, 0, 22, 0, 26);
1349 win->frame_obj = edje_object_add(win->evas);
1350 _elm_theme_set(NULL, win->frame_obj, "border", "base", style);
1351 evas_object_is_frame_object_set(win->frame_obj, EINA_TRUE);
1352 evas_object_move(win->frame_obj, 0, 0);
1353 evas_object_resize(win->frame_obj, 1, 1);
1355 edje_object_signal_callback_add(win->frame_obj, "elm,action,move,start",
1356 "elm", _elm_win_frame_cb_move_start, win);
1357 edje_object_signal_callback_add(win->frame_obj, "elm,action,resize,start",
1358 "*", _elm_win_frame_cb_resize_start, win);
1359 edje_object_signal_callback_add(win->frame_obj, "elm,action,minimize",
1360 "elm", _elm_win_frame_cb_minimize, win);
1361 edje_object_signal_callback_add(win->frame_obj, "elm,action,maximize",
1362 "elm", _elm_win_frame_cb_maximize, win);
1363 edje_object_signal_callback_add(win->frame_obj, "elm,action,close",
1364 "elm", _elm_win_frame_cb_close, win);
1368 _elm_win_frame_cb_move_start(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__)
1372 if (!(win = data)) return;
1373 /* FIXME: Change mouse pointer */
1375 /* NB: 0,0 are dummy values. Wayland handles the move by itself */
1376 ecore_evas_move(win->ee, 0, 0);
1380 _elm_win_frame_cb_resize_start(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source)
1384 if (!(win = data)) return;
1385 if (win->resizing) return;
1386 win->resizing = EINA_TRUE;
1388 /* FIXME: Change mouse pointer */
1390 if (!strcmp(source, "elm.event.resize.t"))
1391 win->resize_location = 1;
1392 else if (!strcmp(source, "elm.event.resize.b"))
1393 win->resize_location = 2;
1394 else if (!strcmp(source, "elm.event.resize.l"))
1395 win->resize_location = 4;
1396 else if (!strcmp(source, "elm.event.resize.r"))
1397 win->resize_location = 8;
1398 else if (!strcmp(source, "elm.event.resize.tl"))
1399 win->resize_location = 5;
1400 else if (!strcmp(source, "elm.event.resize.tr"))
1401 win->resize_location = 9;
1402 else if (!strcmp(source, "elm.event.resize.bl"))
1403 win->resize_location = 6;
1404 else if (!strcmp(source, "elm.event.resize.br"))
1405 win->resize_location = 10;
1407 win->resize_location = 0;
1409 if (win->resize_location > 0)
1410 ecore_evas_wayland_resize(win->ee, win->resize_location);
1414 _elm_win_frame_cb_minimize(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__)
1418 if (!(win = data)) return;
1419 ecore_evas_iconified_set(win->ee, EINA_TRUE);
1423 _elm_win_frame_cb_maximize(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__)
1427 if (!(win = data)) return;
1428 ecore_evas_maximized_set(win->ee, EINA_TRUE);
1432 _elm_win_frame_cb_close(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__)
1436 if (!(win = data)) return;
1437 evas_object_del(win->win_obj);
1441 _elm_win_pointer_add(Elm_Win *win, const char *style)
1445 win->pointer.ee = ecore_evas_wayland_shm_new(NULL, 0, 0, 32, 32, 0);
1446 ecore_evas_resize(win->pointer.ee, 32, 32);
1448 win->pointer.evas = ecore_evas_get(win->ee);
1450 win->pointer.obj = edje_object_add(win->pointer.evas);
1451 _elm_theme_set(NULL, win->pointer.obj, "pointer", "base", style);
1452 edje_object_size_min_calc(win->pointer.obj, &mw, &mh);
1453 printf("ELM Win Pointer Size: %d %d\n", mw, mh);
1454 evas_object_move(win->pointer.obj, 0, 0);
1455 evas_object_resize(win->pointer.obj, 32, 32);
1456 evas_object_show(win->pointer.obj);
1461 _debug_key_down(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
1463 Evas_Event_Key_Down *ev = event_info;
1465 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1468 if ((strcmp(ev->keyname, "F12")) ||
1469 (!evas_key_modifier_is_set(ev->modifiers, "Control")))
1472 printf("Tree graph generated.\n");
1473 elm_object_tree_dot_dump(obj, "./dump.dot");
1478 _win_img_hide(void *data,
1480 Evas_Object *obj __UNUSED__,
1481 void *event_info __UNUSED__)
1483 Elm_Win *win = data;
1485 elm_widget_focus_hide_handle(win->win_obj);
1489 _win_img_mouse_up(void *data,
1491 Evas_Object *obj __UNUSED__,
1494 Elm_Win *win = data;
1495 Evas_Event_Mouse_Up *ev = event_info;
1496 if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD))
1497 elm_widget_focus_mouse_up_handle(win->win_obj);
1501 _win_img_focus_in(void *data,
1503 Evas_Object *obj __UNUSED__,
1504 void *event_info __UNUSED__)
1506 Elm_Win *win = data;
1507 elm_widget_focus_steal(win->win_obj);
1511 _win_img_focus_out(void *data,
1513 Evas_Object *obj __UNUSED__,
1514 void *event_info __UNUSED__)
1516 Elm_Win *win = data;
1517 elm_widget_focused_object_clear(win->win_obj);
1521 _win_inlined_image_set(Elm_Win *win)
1523 evas_object_image_alpha_set(win->img_obj, EINA_FALSE);
1524 evas_object_image_filled_set(win->img_obj, EINA_TRUE);
1525 evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_DEL,
1526 _elm_win_obj_callback_img_obj_del, win);
1528 evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_HIDE,
1529 _win_img_hide, win);
1530 evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_MOUSE_UP,
1531 _win_img_mouse_up, win);
1532 evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_FOCUS_IN,
1533 _win_img_focus_in, win);
1534 evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_FOCUS_OUT,
1535 _win_img_focus_out, win);
1539 _subobj_del(Elm_Win *win, Evas_Object *obj, Evas_Object *subobj)
1541 evas_object_event_callback_del_full(subobj,
1542 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1543 _elm_win_subobj_callback_changed_size_hints,
1545 evas_object_event_callback_del_full(subobj, EVAS_CALLBACK_DEL,
1546 _elm_win_subobj_callback_del, obj);
1547 win->subobjs = eina_list_remove(win->subobjs, subobj);
1548 _elm_win_eval_subobjs(obj);
1552 elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type)
1556 const char *fontpath;
1558 win = ELM_NEW(Elm_Win);
1560 #define FALLBACK_TRY(engine) \
1563 CRITICAL(engine " engine creation failed. Trying default."); \
1564 win->ee = ecore_evas_new(NULL, 0, 0, 1, 1, NULL); \
1566 elm_engine_set(ecore_evas_engine_name_get(win->ee)); \
1568 #define ENGINE_COMPARE(name) (_elm_config->engine && !strcmp(_elm_config->engine, name))
1570 win->kbdmode = ELM_WIN_KEYBOARD_UNKNOWN;
1571 win->indmode = ELM_WIN_INDICATOR_UNKNOWN;
1575 case ELM_WIN_INLINED_IMAGE:
1578 Evas *e = evas_object_evas_get(parent);
1581 ee = ecore_evas_ecore_evas_get(e);
1583 win->img_obj = ecore_evas_object_image_new(ee);
1584 if (!win->img_obj) break;
1585 win->ee = ecore_evas_object_ecore_evas_get(win->img_obj);
1588 _win_inlined_image_set(win);
1591 evas_object_del(win->img_obj);
1592 win->img_obj = NULL;
1596 case ELM_WIN_SOCKET_IMAGE:
1597 win->ee = ecore_evas_extn_socket_new(1, 1);
1601 if (ENGINE_COMPARE(ELM_SOFTWARE_X11))
1603 win->ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
1604 #ifdef HAVE_ELEMENTARY_X
1605 win->client_message_handler = ecore_event_handler_add
1606 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1608 FALLBACK_TRY("Sofware X11");
1610 else if (ENGINE_COMPARE(ELM_SOFTWARE_FB))
1612 win->ee = ecore_evas_fb_new(NULL, 0, 1, 1);
1613 FALLBACK_TRY("Sofware FB");
1615 else if (ENGINE_COMPARE(ELM_SOFTWARE_DIRECTFB))
1617 win->ee = ecore_evas_directfb_new(NULL, 1, 0, 0, 1, 1);
1618 FALLBACK_TRY("Sofware DirectFB");
1620 else if (ENGINE_COMPARE(ELM_SOFTWARE_16_X11))
1622 win->ee = ecore_evas_software_x11_16_new(NULL, 0, 0, 0, 1, 1);
1623 FALLBACK_TRY("Sofware-16");
1624 #ifdef HAVE_ELEMENTARY_X
1625 win->client_message_handler = ecore_event_handler_add
1626 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1629 else if (ENGINE_COMPARE(ELM_SOFTWARE_8_X11))
1631 win->ee = ecore_evas_software_x11_8_new(NULL, 0, 0, 0, 1, 1);
1632 FALLBACK_TRY("Sofware-8");
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_XRENDER_X11))
1641 win->ee = ecore_evas_xrender_x11_new(NULL, 0, 0, 0, 1, 1);
1642 FALLBACK_TRY("XRender");
1643 #ifdef HAVE_ELEMENTARY_X
1644 win->client_message_handler = ecore_event_handler_add
1645 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1649 else if (ENGINE_COMPARE(ELM_OPENGL_X11))
1654 if (_elm_config->vsync)
1656 opt[opt_i] = ECORE_EVAS_GL_X11_OPT_VSYNC;
1662 win->ee = ecore_evas_gl_x11_options_new(NULL, 0, 0, 0, 1, 1, opt);
1664 win->ee = ecore_evas_gl_x11_new(NULL, 0, 0, 0, 1, 1);
1665 FALLBACK_TRY("OpenGL");
1666 #ifdef HAVE_ELEMENTARY_X
1667 win->client_message_handler = ecore_event_handler_add
1668 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1671 else if (ENGINE_COMPARE(ELM_SOFTWARE_WIN32))
1673 win->ee = ecore_evas_software_gdi_new(NULL, 0, 0, 1, 1);
1674 FALLBACK_TRY("Sofware Win32");
1676 else if (ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE))
1678 win->ee = ecore_evas_software_wince_gdi_new(NULL, 0, 0, 1, 1);
1679 FALLBACK_TRY("Sofware-16-WinCE");
1681 else if (ENGINE_COMPARE(ELM_SOFTWARE_PSL1GHT))
1683 win->ee = ecore_evas_psl1ght_new(NULL, 1, 1);
1684 FALLBACK_TRY("PSL1GHT");
1686 else if (ENGINE_COMPARE(ELM_SOFTWARE_SDL))
1688 win->ee = ecore_evas_sdl_new(NULL, 0, 0, 0, 0, 0, 1);
1689 FALLBACK_TRY("Sofware SDL");
1691 else if (ENGINE_COMPARE(ELM_SOFTWARE_16_SDL))
1693 win->ee = ecore_evas_sdl16_new(NULL, 0, 0, 0, 0, 0, 1);
1694 FALLBACK_TRY("Sofware-16-SDL");
1696 else if (ENGINE_COMPARE(ELM_OPENGL_SDL))
1698 win->ee = ecore_evas_gl_sdl_new(NULL, 1, 1, 0, 0);
1699 FALLBACK_TRY("OpenGL SDL");
1701 else if (ENGINE_COMPARE(ELM_OPENGL_COCOA))
1703 win->ee = ecore_evas_cocoa_new(NULL, 1, 1, 0, 0);
1704 FALLBACK_TRY("OpenGL Cocoa");
1706 else if (ENGINE_COMPARE(ELM_BUFFER))
1708 win->ee = ecore_evas_buffer_new(1, 1);
1710 else if (ENGINE_COMPARE(ELM_EWS))
1712 win->ee = ecore_evas_ews_new(0, 0, 1, 1);
1714 else if (ENGINE_COMPARE(ELM_WAYLAND_SHM))
1716 win->ee = ecore_evas_wayland_shm_new(NULL, 0, 0, 1, 1, 0);
1717 win->evas = ecore_evas_get(win->ee);
1719 _elm_win_frame_add(win, "default");
1720 _elm_win_pointer_add(win, "default");
1722 else if (ENGINE_COMPARE(ELM_WAYLAND_EGL))
1724 win->ee = ecore_evas_wayland_egl_new(NULL, 0, 0, 1, 1, 0);
1725 win->evas = ecore_evas_get(win->ee);
1727 _elm_win_frame_add(win, "default");
1728 _elm_win_pointer_add(win, "default");
1730 else if (!strncmp(_elm_config->engine, "shot:", 5))
1732 win->ee = ecore_evas_buffer_new(1, 1);
1733 ecore_evas_manual_render_set(win->ee, EINA_TRUE);
1734 win->shot.info = eina_stringshare_add(_elm_config->engine + 5);
1743 ERR("Cannot create window.");
1747 #ifdef HAVE_ELEMENTARY_X
1748 _elm_win_xwindow_get(win);
1750 if ((_elm_config->bgpixmap) && (!_elm_config->compositing))
1751 ecore_evas_avoid_damage_set(win->ee, ECORE_EVAS_AVOID_DAMAGE_EXPOSE);
1752 // bg pixmap done by x - has other issues like can be redrawn by x before it
1753 // is filled/ready by app
1754 // ecore_evas_avoid_damage_set(win->ee, ECORE_EVAS_AVOID_DAMAGE_BUILT_IN);
1757 win->parent = parent;
1759 evas_object_event_callback_add(win->parent, EVAS_CALLBACK_DEL,
1760 _elm_win_obj_callback_parent_del, win);
1762 win->evas = ecore_evas_get(win->ee);
1763 win->win_obj = elm_widget_add(win->evas);
1764 elm_widget_type_set(win->win_obj, "win");
1765 ELM_SET_WIDTYPE(widtype, "win");
1766 elm_widget_data_set(win->win_obj, win);
1767 elm_widget_event_hook_set(win->win_obj, _elm_win_event_cb);
1768 elm_widget_on_focus_hook_set(win->win_obj, _elm_win_on_focus_hook, NULL);
1769 elm_widget_can_focus_set(win->win_obj, EINA_TRUE);
1770 elm_widget_highlight_ignore_set(win->win_obj, EINA_TRUE);
1771 elm_widget_focus_next_hook_set(win->win_obj, _elm_win_focus_next_hook);
1772 evas_object_color_set(win->win_obj, 0, 0, 0, 0);
1773 evas_object_move(win->win_obj, 0, 0);
1774 evas_object_resize(win->win_obj, 1, 1);
1775 evas_object_layer_set(win->win_obj, 50);
1776 evas_object_pass_events_set(win->win_obj, EINA_TRUE);
1780 // evas_object_clip_set(win->win_obj, win->frame_obj);
1781 evas_object_stack_below(win->frame_obj, win->win_obj);
1784 if (type == ELM_WIN_INLINED_IMAGE)
1785 elm_widget_parent2_set(win->win_obj, parent);
1786 ecore_evas_object_associate(win->ee, win->win_obj,
1787 ECORE_EVAS_OBJECT_ASSOCIATE_BASE |
1788 ECORE_EVAS_OBJECT_ASSOCIATE_STACK |
1789 ECORE_EVAS_OBJECT_ASSOCIATE_LAYER);
1790 evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_SHOW,
1791 _elm_win_obj_callback_show, win);
1792 evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_HIDE,
1793 _elm_win_obj_callback_hide, win);
1794 evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_DEL,
1795 _elm_win_obj_callback_del, win);
1796 evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_MOVE,
1797 _elm_win_obj_callback_move, win);
1798 evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_RESIZE,
1799 _elm_win_obj_callback_resize, win);
1801 evas_object_intercept_move_callback_add(win->win_obj,
1802 _elm_win_obj_intercept_move, win);
1803 evas_object_intercept_show_callback_add(win->win_obj,
1804 _elm_win_obj_intercept_show, win);
1806 evas_object_smart_callback_add(win->win_obj, "sub-object-del", (Evas_Smart_Cb)_subobj_del, win);
1807 ecore_evas_name_class_set(win->ee, name, _elm_appname);
1808 ecore_evas_callback_delete_request_set(win->ee, _elm_win_delete_request);
1809 ecore_evas_callback_resize_set(win->ee, _elm_win_resize);
1810 ecore_evas_callback_mouse_in_set(win->ee, _elm_win_mouse_in);
1811 ecore_evas_callback_focus_in_set(win->ee, _elm_win_focus_in);
1812 ecore_evas_callback_focus_out_set(win->ee, _elm_win_focus_out);
1813 ecore_evas_callback_move_set(win->ee, _elm_win_move);
1814 evas_image_cache_set(win->evas, (_elm_config->image_cache * 1024));
1815 evas_font_cache_set(win->evas, (_elm_config->font_cache * 1024));
1816 EINA_LIST_FOREACH(_elm_config->font_dirs, l, fontpath)
1817 evas_font_path_append(win->evas, fontpath);
1818 if (!_elm_config->font_hinting)
1819 evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_NONE);
1820 else if (_elm_config->font_hinting == 1)
1821 evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_AUTO);
1822 else if (_elm_config->font_hinting == 2)
1823 evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_BYTECODE);
1825 #ifdef HAVE_ELEMENTARY_X
1826 _elm_win_xwin_update(win);
1829 _elm_win_list = eina_list_append(_elm_win_list, win->win_obj);
1831 if (ENGINE_COMPARE(ELM_SOFTWARE_FB))
1833 ecore_evas_fullscreen_set(win->ee, 1);
1835 #undef ENGINE_COMPARE
1837 if (_elm_config->focus_highlight_enable)
1838 elm_win_focus_highlight_enabled_set(win->win_obj, EINA_TRUE);
1841 Evas_Modifier_Mask mask = evas_key_modifier_mask_get(win->evas, "Control");
1842 evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_KEY_DOWN,
1843 _debug_key_down, win);
1845 Eina_Bool ret = evas_object_key_grab(win->win_obj, "F12", mask, 0,
1847 printf("Ctrl+F12 key combination exclusive for dot tree generation\n");
1850 evas_object_smart_callbacks_descriptions_set(win->win_obj, _signals);
1852 return win->win_obj;
1856 elm_win_util_standard_add(const char *name, const char *title)
1858 Evas_Object *win, *bg;
1860 win = elm_win_add(NULL, name, ELM_WIN_BASIC);
1861 if (!win) return NULL;
1862 elm_win_title_set(win, title);
1863 bg = elm_bg_add(win);
1866 evas_object_del(win);
1869 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1870 elm_win_resize_object_add(win, bg);
1871 evas_object_show(bg);
1876 elm_win_resize_object_add(Evas_Object *obj, Evas_Object *subobj)
1880 ELM_CHECK_WIDTYPE(obj, widtype);
1881 win = elm_widget_data_get(obj);
1883 if (eina_list_data_find(win->subobjs, subobj)) return;
1884 win->subobjs = eina_list_append(win->subobjs, subobj);
1885 elm_widget_sub_object_add(obj, subobj);
1886 evas_object_event_callback_add(subobj, EVAS_CALLBACK_DEL,
1887 _elm_win_subobj_callback_del, obj);
1888 evas_object_event_callback_add(subobj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1889 _elm_win_subobj_callback_changed_size_hints,
1891 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
1892 evas_object_move(subobj, 0, 0);
1893 evas_object_resize(subobj, w, h);
1894 _elm_win_eval_subobjs(obj);
1898 elm_win_resize_object_del(Evas_Object *obj, Evas_Object *subobj)
1901 ELM_CHECK_WIDTYPE(obj, widtype);
1902 win = elm_widget_data_get(obj);
1904 evas_object_event_callback_del_full(subobj,
1905 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1906 _elm_win_subobj_callback_changed_size_hints,
1908 evas_object_event_callback_del_full(subobj, EVAS_CALLBACK_DEL,
1909 _elm_win_subobj_callback_del, obj);
1910 win->subobjs = eina_list_remove(win->subobjs, subobj);
1911 elm_widget_sub_object_del(obj, subobj);
1912 _elm_win_eval_subobjs(obj);
1916 elm_win_title_set(Evas_Object *obj, const char *title)
1919 ELM_CHECK_WIDTYPE(obj, widtype);
1920 win = elm_widget_data_get(obj);
1921 if (!win || !title) return;
1922 ecore_evas_title_set(win->ee, title);
1924 edje_object_part_text_set(win->frame_obj, "elm.text.title", title);
1928 elm_win_title_get(const Evas_Object *obj)
1931 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1932 win = elm_widget_data_get(obj);
1933 if (!win) return NULL;
1934 return ecore_evas_title_get(win->ee);
1938 elm_win_autodel_set(Evas_Object *obj, Eina_Bool autodel)
1941 ELM_CHECK_WIDTYPE(obj, widtype);
1942 win = elm_widget_data_get(obj);
1944 win->autodel = autodel;
1948 elm_win_autodel_get(const Evas_Object *obj)
1951 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1952 win = elm_widget_data_get(obj);
1953 if (!win) return EINA_FALSE;
1954 return win->autodel;
1958 elm_win_activate(Evas_Object *obj)
1961 ELM_CHECK_WIDTYPE(obj, widtype);
1962 win = elm_widget_data_get(obj);
1964 ecore_evas_activate(win->ee);
1968 elm_win_lower(Evas_Object *obj)
1971 ELM_CHECK_WIDTYPE(obj, widtype);
1972 win = elm_widget_data_get(obj);
1974 ecore_evas_lower(win->ee);
1978 elm_win_raise(Evas_Object *obj)
1981 ELM_CHECK_WIDTYPE(obj, widtype);
1982 win = elm_widget_data_get(obj);
1984 ecore_evas_raise(win->ee);
1988 elm_win_center(Evas_Object *obj, Eina_Bool h, Eina_Bool v)
1991 int win_w, win_h, screen_w, screen_h, nx, ny;
1992 ELM_CHECK_WIDTYPE(obj, widtype);
1993 win = elm_widget_data_get(obj);
1995 ecore_evas_screen_geometry_get(win->ee, NULL, NULL, &screen_w, &screen_h);
1996 if ((!screen_w) || (!screen_h)) return;
1997 evas_object_geometry_get(obj, NULL, NULL, &win_w, &win_h);
1998 if ((!win_w) || (!win_h)) return;
1999 if (h) nx = win_w >= screen_w ? 0 : (screen_w / 2) - (win_w / 2);
2000 else nx = win->screen.x;
2001 if (v) ny = win_h >= screen_h ? 0 : (screen_h / 2) - (win_h / 2);
2002 else ny = win->screen.y;
2005 evas_object_move(obj, nx, ny);
2009 elm_win_borderless_set(Evas_Object *obj, Eina_Bool borderless)
2012 ELM_CHECK_WIDTYPE(obj, widtype);
2013 win = elm_widget_data_get(obj);
2015 ecore_evas_borderless_set(win->ee, borderless);
2016 #ifdef HAVE_ELEMENTARY_X
2017 _elm_win_xwin_update(win);
2022 elm_win_borderless_get(const Evas_Object *obj)
2025 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2026 win = elm_widget_data_get(obj);
2027 if (!win) return EINA_FALSE;
2028 return ecore_evas_borderless_get(win->ee);
2032 elm_win_shaped_set(Evas_Object *obj, Eina_Bool shaped)
2035 ELM_CHECK_WIDTYPE(obj, widtype);
2036 win = elm_widget_data_get(obj);
2038 ecore_evas_shaped_set(win->ee, shaped);
2039 #ifdef HAVE_ELEMENTARY_X
2040 _elm_win_xwin_update(win);
2045 elm_win_shaped_get(const Evas_Object *obj)
2048 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2049 win = elm_widget_data_get(obj);
2050 if (!win) return EINA_FALSE;
2051 return ecore_evas_shaped_get(win->ee);
2055 elm_win_alpha_set(Evas_Object *obj, Eina_Bool alpha)
2058 ELM_CHECK_WIDTYPE(obj, widtype);
2059 win = elm_widget_data_get(obj);
2064 else if (win->img_obj)
2066 evas_object_image_alpha_set(win->img_obj, alpha);
2067 ecore_evas_alpha_set(win->ee, alpha);
2071 #ifdef HAVE_ELEMENTARY_X
2076 if (!_elm_config->compositing)
2077 elm_win_shaped_set(obj, alpha);
2079 ecore_evas_alpha_set(win->ee, alpha);
2082 ecore_evas_alpha_set(win->ee, alpha);
2083 _elm_win_xwin_update(win);
2087 ecore_evas_alpha_set(win->ee, alpha);
2092 elm_win_alpha_get(const Evas_Object *obj)
2095 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2096 win = elm_widget_data_get(obj);
2097 if (!win) return EINA_FALSE;
2101 else if (win->img_obj)
2103 return evas_object_image_alpha_get(win->img_obj);
2105 return ecore_evas_alpha_get(win->ee);
2109 elm_win_transparent_set(Evas_Object *obj, Eina_Bool transparent)
2112 ELM_CHECK_WIDTYPE(obj, widtype);
2113 win = elm_widget_data_get(obj);
2119 else if (win->img_obj)
2121 evas_object_image_alpha_set(win->img_obj, transparent);
2125 #ifdef HAVE_ELEMENTARY_X
2128 ecore_evas_transparent_set(win->ee, transparent);
2129 _elm_win_xwin_update(win);
2133 ecore_evas_transparent_set(win->ee, transparent);
2138 elm_win_transparent_get(const Evas_Object *obj)
2141 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2142 win = elm_widget_data_get(obj);
2143 if (!win) return EINA_FALSE;
2145 return ecore_evas_transparent_get(win->ee);
2149 elm_win_override_set(Evas_Object *obj, Eina_Bool override)
2152 ELM_CHECK_WIDTYPE(obj, widtype);
2153 win = elm_widget_data_get(obj);
2155 ecore_evas_override_set(win->ee, override);
2156 #ifdef HAVE_ELEMENTARY_X
2157 _elm_win_xwin_update(win);
2162 elm_win_override_get(const Evas_Object *obj)
2165 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2166 win = elm_widget_data_get(obj);
2167 if (!win) return EINA_FALSE;
2168 return ecore_evas_override_get(win->ee);
2172 elm_win_fullscreen_set(Evas_Object *obj, Eina_Bool fullscreen)
2175 ELM_CHECK_WIDTYPE(obj, widtype);
2176 win = elm_widget_data_get(obj);
2179 // YYY: handle if win->img_obj
2180 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
2181 if (ENGINE_COMPARE(ELM_SOFTWARE_FB) ||
2182 ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE))
2184 // these engines... can ONLY be fullscreen
2189 ecore_evas_fullscreen_set(win->ee, fullscreen);
2190 #ifdef HAVE_ELEMENTARY_X
2191 _elm_win_xwin_update(win);
2194 #undef ENGINE_COMPARE
2198 elm_win_fullscreen_get(const Evas_Object *obj)
2201 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2202 win = elm_widget_data_get(obj);
2203 if (!win) return EINA_FALSE;
2205 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
2206 if (ENGINE_COMPARE(ELM_SOFTWARE_FB) ||
2207 ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE))
2209 // these engines... can ONLY be fullscreen
2214 return ecore_evas_fullscreen_get(win->ee);
2216 #undef ENGINE_COMPARE
2220 elm_win_maximized_set(Evas_Object *obj, Eina_Bool maximized)
2223 ELM_CHECK_WIDTYPE(obj, widtype);
2224 win = elm_widget_data_get(obj);
2226 // YYY: handle if win->img_obj
2227 ecore_evas_maximized_set(win->ee, maximized);
2228 #ifdef HAVE_ELEMENTARY_X
2229 _elm_win_xwin_update(win);
2234 elm_win_maximized_get(const Evas_Object *obj)
2237 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2238 win = elm_widget_data_get(obj);
2239 if (!win) return EINA_FALSE;
2240 return ecore_evas_maximized_get(win->ee);
2244 elm_win_iconified_set(Evas_Object *obj, Eina_Bool iconified)
2247 ELM_CHECK_WIDTYPE(obj, widtype);
2248 win = elm_widget_data_get(obj);
2250 ecore_evas_iconified_set(win->ee, iconified);
2251 #ifdef HAVE_ELEMENTARY_X
2252 _elm_win_xwin_update(win);
2257 elm_win_iconified_get(const Evas_Object *obj)
2260 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2261 win = elm_widget_data_get(obj);
2262 if (!win) return EINA_FALSE;
2263 return ecore_evas_iconified_get(win->ee);
2267 elm_win_layer_set(Evas_Object *obj, int layer)
2270 ELM_CHECK_WIDTYPE(obj, widtype);
2271 win = elm_widget_data_get(obj);
2273 ecore_evas_layer_set(win->ee, layer);
2274 #ifdef HAVE_ELEMENTARY_X
2275 _elm_win_xwin_update(win);
2280 elm_win_layer_get(const Evas_Object *obj)
2283 ELM_CHECK_WIDTYPE(obj, widtype) -1;
2284 win = elm_widget_data_get(obj);
2285 if (!win) return -1;
2286 return ecore_evas_layer_get(win->ee);
2290 elm_win_rotation_set(Evas_Object *obj, int rotation)
2293 ELM_CHECK_WIDTYPE(obj, widtype);
2294 win = elm_widget_data_get(obj);
2296 if (win->rot == rotation) return;
2297 win->rot = rotation;
2298 ecore_evas_rotation_set(win->ee, rotation);
2299 evas_object_size_hint_min_set(obj, -1, -1);
2300 evas_object_size_hint_max_set(obj, -1, -1);
2301 _elm_win_eval_subobjs(obj);
2302 #ifdef HAVE_ELEMENTARY_X
2303 _elm_win_xwin_update(win);
2308 elm_win_rotation_with_resize_set(Evas_Object *obj, int rotation)
2311 ELM_CHECK_WIDTYPE(obj, widtype);
2312 win = elm_widget_data_get(obj);
2314 if (win->rot == rotation) return;
2315 win->rot = rotation;
2316 ecore_evas_rotation_with_resize_set(win->ee, rotation);
2317 evas_object_size_hint_min_set(obj, -1, -1);
2318 evas_object_size_hint_max_set(obj, -1, -1);
2319 _elm_win_eval_subobjs(obj);
2320 #ifdef HAVE_ELEMENTARY_X
2321 _elm_win_xwin_update(win);
2326 elm_win_rotation_get(const Evas_Object *obj)
2329 ELM_CHECK_WIDTYPE(obj, widtype) -1;
2330 win = elm_widget_data_get(obj);
2331 if (!win) return -1;
2336 elm_win_sticky_set(Evas_Object *obj, Eina_Bool sticky)
2339 ELM_CHECK_WIDTYPE(obj, widtype);
2340 win = elm_widget_data_get(obj);
2342 ecore_evas_sticky_set(win->ee, sticky);
2343 #ifdef HAVE_ELEMENTARY_X
2344 _elm_win_xwin_update(win);
2349 elm_win_sticky_get(const Evas_Object *obj)
2352 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2353 win = elm_widget_data_get(obj);
2354 if (!win) return EINA_FALSE;
2355 return ecore_evas_sticky_get(win->ee);
2359 elm_win_keyboard_mode_set(Evas_Object *obj, Elm_Win_Keyboard_Mode mode)
2362 ELM_CHECK_WIDTYPE(obj, widtype);
2363 win = elm_widget_data_get(obj);
2365 if (mode == win->kbdmode) return;
2366 #ifdef HAVE_ELEMENTARY_X
2367 _elm_win_xwindow_get(win);
2369 win->kbdmode = mode;
2370 #ifdef HAVE_ELEMENTARY_X
2372 ecore_x_e_virtual_keyboard_state_set
2373 (win->xwin, (Ecore_X_Virtual_Keyboard_State)win->kbdmode);
2377 EAPI Elm_Win_Keyboard_Mode
2378 elm_win_keyboard_mode_get(const Evas_Object *obj)
2381 ELM_CHECK_WIDTYPE(obj, widtype) ELM_WIN_KEYBOARD_UNKNOWN;
2382 win = elm_widget_data_get(obj);
2383 if (!win) return ELM_WIN_KEYBOARD_UNKNOWN;
2384 return win->kbdmode;
2388 elm_win_keyboard_win_set(Evas_Object *obj, Eina_Bool is_keyboard)
2391 ELM_CHECK_WIDTYPE(obj, widtype);
2392 win = elm_widget_data_get(obj);
2394 #ifdef HAVE_ELEMENTARY_X
2395 _elm_win_xwindow_get(win);
2397 ecore_x_e_virtual_keyboard_set(win->xwin, is_keyboard);
2404 elm_win_keyboard_win_get(const Evas_Object *obj)
2407 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2408 win = elm_widget_data_get(obj);
2409 if (!win) return EINA_FALSE;
2410 #ifdef HAVE_ELEMENTARY_X
2411 _elm_win_xwindow_get(win);
2413 return ecore_x_e_virtual_keyboard_get(win->xwin);
2419 elm_win_indicator_mode_set(Evas_Object *obj, Elm_Win_Indicator_Mode mode)
2422 ELM_CHECK_WIDTYPE(obj, widtype);
2423 win = elm_widget_data_get(obj);
2425 if (mode == win->indmode) return;
2426 #ifdef HAVE_ELEMENTARY_X
2427 _elm_win_xwindow_get(win);
2429 win->indmode = mode;
2430 #ifdef HAVE_ELEMENTARY_X
2433 if (win->indmode == ELM_WIN_INDICATOR_SHOW)
2434 ecore_x_e_illume_indicator_state_set
2435 (win->xwin, ECORE_X_ILLUME_INDICATOR_STATE_ON);
2436 else if (win->indmode == ELM_WIN_INDICATOR_HIDE)
2437 ecore_x_e_illume_indicator_state_set
2438 (win->xwin, ECORE_X_ILLUME_INDICATOR_STATE_OFF);
2443 EAPI Elm_Win_Indicator_Mode
2444 elm_win_indicator_mode_get(const Evas_Object *obj)
2447 ELM_CHECK_WIDTYPE(obj, widtype) ELM_WIN_INDICATOR_UNKNOWN;
2448 win = elm_widget_data_get(obj);
2449 if (!win) return ELM_WIN_INDICATOR_UNKNOWN;
2450 return win->indmode;
2454 elm_win_screen_position_get(const Evas_Object *obj, int *x, int *y)
2457 ELM_CHECK_WIDTYPE(obj, widtype);
2458 win = elm_widget_data_get(obj);
2460 if (x) *x = win->screen.x;
2461 if (y) *y = win->screen.y;
2465 elm_win_focus_get(const Evas_Object *obj)
2468 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2469 win = elm_widget_data_get(obj);
2470 if (!win) return EINA_FALSE;
2471 return ecore_evas_focus_get(win->ee);
2475 elm_win_screen_constrain_set(Evas_Object *obj, Eina_Bool constrain)
2478 ELM_CHECK_WIDTYPE(obj, widtype);
2479 win = elm_widget_data_get(obj);
2481 win->constrain = !!constrain;
2485 elm_win_screen_constrain_get(Evas_Object *obj)
2488 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2489 win = elm_widget_data_get(obj);
2490 if (!win) return EINA_FALSE;
2491 return win->constrain;
2495 elm_win_screen_size_get(const Evas_Object *obj, int *x, int *y, int *w, int *h)
2498 ELM_CHECK_WIDTYPE(obj, widtype);
2499 win = elm_widget_data_get(obj);
2501 ecore_evas_screen_geometry_get(win->ee, x, y, w, h);
2505 elm_win_conformant_set(Evas_Object *obj, Eina_Bool conformant)
2508 ELM_CHECK_WIDTYPE(obj, widtype);
2509 win = elm_widget_data_get(obj);
2511 #ifdef HAVE_ELEMENTARY_X
2512 _elm_win_xwindow_get(win);
2514 ecore_x_e_illume_conformant_set(win->xwin, conformant);
2521 elm_win_conformant_get(const Evas_Object *obj)
2524 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2525 win = elm_widget_data_get(obj);
2526 if (!win) return EINA_FALSE;
2527 #ifdef HAVE_ELEMENTARY_X
2528 _elm_win_xwindow_get(win);
2530 return ecore_x_e_illume_conformant_get(win->xwin);
2536 elm_win_quickpanel_set(Evas_Object *obj, Eina_Bool quickpanel)
2539 ELM_CHECK_WIDTYPE(obj, widtype);
2540 win = elm_widget_data_get(obj);
2542 #ifdef HAVE_ELEMENTARY_X
2543 _elm_win_xwindow_get(win);
2546 ecore_x_e_illume_quickpanel_set(win->xwin, quickpanel);
2549 Ecore_X_Window_State states[2];
2551 states[0] = ECORE_X_WINDOW_STATE_SKIP_TASKBAR;
2552 states[1] = ECORE_X_WINDOW_STATE_SKIP_PAGER;
2553 ecore_x_netwm_window_state_set(win->xwin, states, 2);
2554 ecore_x_icccm_hints_set(win->xwin, 0, 0, 0, 0, 0, 0, 0);
2563 elm_win_quickpanel_get(const Evas_Object *obj)
2566 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2567 win = elm_widget_data_get(obj);
2568 if (!win) return EINA_FALSE;
2569 #ifdef HAVE_ELEMENTARY_X
2570 _elm_win_xwindow_get(win);
2572 return ecore_x_e_illume_quickpanel_get(win->xwin);
2578 elm_win_quickpanel_priority_major_set(Evas_Object *obj, int priority)
2581 ELM_CHECK_WIDTYPE(obj, widtype);
2582 win = elm_widget_data_get(obj);
2584 #ifdef HAVE_ELEMENTARY_X
2585 _elm_win_xwindow_get(win);
2587 ecore_x_e_illume_quickpanel_priority_major_set(win->xwin, priority);
2594 elm_win_quickpanel_priority_major_get(const Evas_Object *obj)
2597 ELM_CHECK_WIDTYPE(obj, widtype) -1;
2598 win = elm_widget_data_get(obj);
2599 if (!win) return -1;
2600 #ifdef HAVE_ELEMENTARY_X
2601 _elm_win_xwindow_get(win);
2603 return ecore_x_e_illume_quickpanel_priority_major_get(win->xwin);
2609 elm_win_quickpanel_priority_minor_set(Evas_Object *obj, int priority)
2612 ELM_CHECK_WIDTYPE(obj, widtype);
2613 win = elm_widget_data_get(obj);
2615 #ifdef HAVE_ELEMENTARY_X
2616 _elm_win_xwindow_get(win);
2618 ecore_x_e_illume_quickpanel_priority_minor_set(win->xwin, priority);
2625 elm_win_quickpanel_priority_minor_get(const Evas_Object *obj)
2628 ELM_CHECK_WIDTYPE(obj, widtype) -1;
2629 win = elm_widget_data_get(obj);
2630 if (!win) return -1;
2631 #ifdef HAVE_ELEMENTARY_X
2632 _elm_win_xwindow_get(win);
2634 return ecore_x_e_illume_quickpanel_priority_minor_get(win->xwin);
2640 elm_win_quickpanel_zone_set(Evas_Object *obj, int zone)
2643 ELM_CHECK_WIDTYPE(obj, widtype);
2644 win = elm_widget_data_get(obj);
2646 #ifdef HAVE_ELEMENTARY_X
2647 _elm_win_xwindow_get(win);
2649 ecore_x_e_illume_quickpanel_zone_set(win->xwin, zone);
2656 elm_win_quickpanel_zone_get(const Evas_Object *obj)
2659 ELM_CHECK_WIDTYPE(obj, widtype) 0;
2660 win = elm_widget_data_get(obj);
2662 #ifdef HAVE_ELEMENTARY_X
2663 _elm_win_xwindow_get(win);
2665 return ecore_x_e_illume_quickpanel_zone_get(win->xwin);
2671 elm_win_prop_focus_skip_set(Evas_Object *obj, Eina_Bool skip)
2674 ELM_CHECK_WIDTYPE(obj, widtype);
2675 win = elm_widget_data_get(obj);
2677 #ifdef HAVE_ELEMENTARY_X
2678 _elm_win_xwindow_get(win);
2683 Ecore_X_Window_State states[2];
2685 ecore_x_icccm_hints_set(win->xwin, 0, 0, 0, 0, 0, 0, 0);
2686 states[0] = ECORE_X_WINDOW_STATE_SKIP_TASKBAR;
2687 states[1] = ECORE_X_WINDOW_STATE_SKIP_PAGER;
2688 ecore_x_netwm_window_state_set(win->xwin, states, 2);
2697 elm_win_illume_command_send(Evas_Object *obj, Elm_Illume_Command command, void *params __UNUSED__)
2700 ELM_CHECK_WIDTYPE(obj, widtype);
2701 win = elm_widget_data_get(obj);
2703 #ifdef HAVE_ELEMENTARY_X
2704 _elm_win_xwindow_get(win);
2709 case ELM_ILLUME_COMMAND_FOCUS_BACK:
2710 ecore_x_e_illume_focus_back_send(win->xwin);
2712 case ELM_ILLUME_COMMAND_FOCUS_FORWARD:
2713 ecore_x_e_illume_focus_forward_send(win->xwin);
2715 case ELM_ILLUME_COMMAND_FOCUS_HOME:
2716 ecore_x_e_illume_focus_home_send(win->xwin);
2718 case ELM_ILLUME_COMMAND_CLOSE:
2719 ecore_x_e_illume_close_send(win->xwin);
2731 elm_win_inlined_image_object_get(Evas_Object *obj)
2734 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2735 win = elm_widget_data_get(obj);
2736 if (!win) return NULL;
2737 return win->img_obj;
2741 elm_win_focus_highlight_enabled_set(Evas_Object *obj, Eina_Bool enabled)
2745 ELM_CHECK_WIDTYPE(obj, widtype);
2747 win = elm_widget_data_get(obj);
2748 enabled = !!enabled;
2749 if (win->focus_highlight.enabled == enabled)
2752 win->focus_highlight.enabled = enabled;
2754 if (win->focus_highlight.enabled)
2755 _elm_win_focus_highlight_init(win);
2757 _elm_win_focus_highlight_shutdown(win);
2761 elm_win_focus_highlight_enabled_get(const Evas_Object *obj)
2765 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2767 win = elm_widget_data_get(obj);
2768 return win->focus_highlight.enabled;
2772 elm_win_focus_highlight_style_set(Evas_Object *obj, const char *style)
2776 ELM_CHECK_WIDTYPE(obj, widtype);
2778 win = elm_widget_data_get(obj);
2779 eina_stringshare_replace(&win->focus_highlight.style, style);
2780 win->focus_highlight.changed_theme = EINA_TRUE;
2781 _elm_win_focus_highlight_reconfigure_job_start(win);
2785 elm_win_focus_highlight_style_get(const Evas_Object *obj)
2789 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2791 win = elm_widget_data_get(obj);
2792 return win->focus_highlight.style;
2795 typedef struct _Widget_Data Widget_Data;
2800 Evas_Object *content;
2803 static void _del_hook(Evas_Object *obj);
2804 static void _theme_hook(Evas_Object *obj);
2805 static void _sizing_eval(Evas_Object *obj);
2806 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
2807 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
2809 static const char *widtype2 = NULL;
2812 _del_hook(Evas_Object *obj)
2814 Widget_Data *wd = elm_widget_data_get(obj);
2820 _theme_hook(Evas_Object *obj)
2822 Widget_Data *wd = elm_widget_data_get(obj);
2823 _elm_theme_object_set(obj, wd->frm, "win", "inwin", elm_widget_style_get(obj));
2825 edje_object_part_swallow(wd->frm, "elm.swallow.content", wd->content);
2828 evas_object_smart_callback_call(obj, SIG_THEME_CHANGED, NULL);
2832 _elm_inwin_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
2834 Widget_Data *wd = elm_widget_data_get(obj);
2839 /* Try Focus cycle in subitem */
2842 elm_widget_focus_next_get(wd->content, dir, next);
2847 *next = (Evas_Object *)obj;
2852 _elm_inwin_text_set_hook(Evas_Object *obj, const char *item, const char *text)
2854 Widget_Data *wd = elm_widget_data_get(obj);
2856 if (!wd || !item) return;
2857 edje_object_part_text_set(wd->frm, item, text);
2862 _elm_inwin_text_get_hook(const Evas_Object *obj, const char *item)
2864 Widget_Data *wd = elm_widget_data_get(obj);
2866 if (!item || !wd || !wd->frm) return NULL;
2867 return edje_object_part_text_get(wd->frm, item);
2871 _sizing_eval(Evas_Object *obj)
2873 Widget_Data *wd = elm_widget_data_get(obj);
2874 Evas_Coord minw = -1, minh = -1;
2876 evas_object_size_hint_min_get(wd->content, &minw, &minh);
2877 edje_object_size_min_calc(wd->frm, &minw, &minh);
2878 evas_object_size_hint_min_set(obj, minw, minh);
2879 evas_object_size_hint_max_set(obj, -1, -1);
2883 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2889 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
2891 Widget_Data *wd = elm_widget_data_get(obj);
2892 Evas_Object *sub = event_info;
2893 if (sub == wd->content)
2895 evas_object_event_callback_del_full
2896 (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
2903 elm_win_inwin_add(Evas_Object *obj)
2909 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2910 win = elm_widget_data_get(obj);
2911 if (!win) return NULL;
2912 wd = ELM_NEW(Widget_Data);
2913 obj2 = elm_widget_add(win->evas);
2914 elm_widget_type_set(obj2, "inwin");
2915 ELM_SET_WIDTYPE(widtype2, "inwin");
2916 elm_widget_sub_object_add(obj, obj2);
2917 evas_object_size_hint_weight_set(obj2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2918 evas_object_size_hint_align_set(obj2, EVAS_HINT_FILL, EVAS_HINT_FILL);
2919 elm_win_resize_object_add(obj, obj2);
2921 elm_widget_data_set(obj2, wd);
2922 elm_widget_del_hook_set(obj2, _del_hook);
2923 elm_widget_theme_hook_set(obj2, _theme_hook);
2924 elm_widget_focus_next_hook_set(obj2, _elm_inwin_focus_next_hook);
2925 elm_widget_text_set_hook_set(obj2, _elm_inwin_text_set_hook);
2926 elm_widget_text_get_hook_set(obj2, _elm_inwin_text_get_hook);
2927 elm_widget_can_focus_set(obj2, EINA_TRUE);
2928 elm_widget_highlight_ignore_set(obj2, EINA_TRUE);
2930 wd->frm = edje_object_add(win->evas);
2931 _elm_theme_object_set(obj, wd->frm, "win", "inwin", "default");
2932 elm_widget_resize_object_set(obj2, wd->frm);
2934 evas_object_smart_callback_add(obj2, "sub-object-del", _sub_del, obj2);
2941 elm_win_inwin_activate(Evas_Object *obj)
2943 ELM_CHECK_WIDTYPE(obj, widtype2);
2944 Widget_Data *wd = elm_widget_data_get(obj);
2946 evas_object_raise(obj);
2947 evas_object_show(obj);
2948 edje_object_signal_emit(wd->frm, "elm,action,show", "elm");
2949 elm_object_focus_set(obj, EINA_TRUE);
2953 elm_win_inwin_content_set(Evas_Object *obj, Evas_Object *content)
2955 ELM_CHECK_WIDTYPE(obj, widtype2);
2956 Widget_Data *wd = elm_widget_data_get(obj);
2958 if (wd->content == content) return;
2959 if (wd->content) evas_object_del(wd->content);
2960 wd->content = content;
2963 elm_widget_sub_object_add(obj, content);
2964 evas_object_event_callback_add(content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
2965 _changed_size_hints, obj);
2966 edje_object_part_swallow(wd->frm, "elm.swallow.content", content);
2972 elm_win_inwin_content_get(const Evas_Object *obj)
2974 ELM_CHECK_WIDTYPE(obj, widtype2) NULL;
2975 Widget_Data *wd = elm_widget_data_get(obj);
2976 if (!wd) return NULL;
2981 elm_win_inwin_content_unset(Evas_Object *obj)
2983 ELM_CHECK_WIDTYPE(obj, widtype2) NULL;
2984 Widget_Data *wd = elm_widget_data_get(obj);
2985 if (!wd) return NULL;
2986 if (!wd->content) return NULL;
2987 Evas_Object *content = wd->content;
2988 elm_widget_sub_object_del(obj, wd->content);
2989 evas_object_event_callback_del_full(wd->content,
2990 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
2991 _changed_size_hints, obj);
2992 edje_object_part_unswallow(wd->frm, wd->content);
2998 elm_win_socket_listen(Evas_Object *obj, const char *svcname, int svcnum, Eina_Bool svcsys)
3003 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3004 win = elm_widget_data_get(obj);
3005 if (!win) return EINA_FALSE;
3006 if (!win->ee) return EINA_FALSE;
3008 if(!ecore_evas_extn_socket_listen(win->ee, svcname, svcnum, svcsys))
3014 /* windowing spcific calls - shall we do this differently? */
3016 static Ecore_X_Window
3017 _elm_ee_win_get(const Evas_Object *obj)
3020 #ifdef HAVE_ELEMENTARY_X
3021 Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
3022 if (ee) return (Ecore_X_Window)ecore_evas_window_get(ee);
3028 elm_win_xwindow_get(const Evas_Object *obj)
3034 type = elm_widget_type_get(obj);
3035 if ((!type) || (type != widtype)) return _elm_ee_win_get(obj);
3036 win = elm_widget_data_get(obj);
3038 #ifdef HAVE_ELEMENTARY_X
3039 if (win->xwin) return win->xwin;
3040 if (win->parent) return elm_win_xwindow_get(win->parent);