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;
42 Eina_Bool visible : 1;
43 Eina_Bool handled : 1;
47 Ecore_Job *reconf_job;
49 Eina_Bool enabled : 1;
50 Eina_Bool changed_theme : 1;
51 Eina_Bool top_animate : 1;
52 Eina_Bool geometry_changed : 1;
56 static const char *widtype = NULL;
57 static void _elm_win_obj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
58 static void _elm_win_obj_callback_img_obj_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
59 static void _elm_win_obj_callback_parent_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
60 static void _elm_win_obj_intercept_move(void *data, Evas_Object *obj, Evas_Coord x, Evas_Coord y);
61 static void _elm_win_obj_intercept_show(void *data, Evas_Object *obj);
62 static void _elm_win_move(Ecore_Evas *ee);
63 static void _elm_win_resize(Ecore_Evas *ee);
64 static void _elm_win_delete_request(Ecore_Evas *ee);
65 static void _elm_win_resize_job(void *data);
66 #ifdef HAVE_ELEMENTARY_X
67 static void _elm_win_xwin_update(Elm_Win *win);
69 static void _elm_win_eval_subobjs(Evas_Object *obj);
70 static void _elm_win_subobj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
71 static void _elm_win_subobj_callback_changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
72 static void _elm_win_focus_highlight_init(Elm_Win *win);
73 static void _elm_win_focus_highlight_shutdown(Elm_Win *win);
74 static void _elm_win_focus_highlight_visible_set(Elm_Win *win, Eina_Bool visible);
75 static void _elm_win_focus_highlight_reconfigure_job_start(Elm_Win *win);
76 static void _elm_win_focus_highlight_reconfigure_job_stop(Elm_Win *win);
77 static void _elm_win_focus_highlight_anim_end(void *data, Evas_Object *obj, const char *emission, const char *source);
78 static void _elm_win_focus_highlight_reconfigure(Elm_Win *win);
80 static void _elm_win_frame_add(Elm_Win *win, const char *style);
81 static void _elm_win_frame_cb_move_start(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__);
82 static void _elm_win_frame_cb_resize_start(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source);
83 static void _elm_win_frame_cb_minimize(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__);
84 static void _elm_win_frame_cb_maximize(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__);
85 static void _elm_win_frame_cb_close(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__);
87 static const char SIG_DELETE_REQUEST[] = "delete,request";
88 static const char SIG_FOCUS_OUT[] = "focus,out";
89 static const char SIG_FOCUS_IN[] = "focus,in";
90 static const char SIG_MOVED[] = "moved";
91 static const char SIG_THEME_CHANGED[] = "theme,changed";
93 static const Evas_Smart_Cb_Description _signals[] = {
94 {SIG_DELETE_REQUEST, ""},
103 Eina_List *_elm_win_list = NULL;
104 int _elm_win_deferred_free = 0;
106 // exmaple shot spec (wait 0.1 sec then save as my-window.png):
107 // ELM_ENGINE="shot:delay=0.1:file=my-window.png"
110 _shot_delay_get(Elm_Win *win)
113 char *d = strdup(win->shot.info);
116 for (p = (char *)win->shot.info; *p; p++)
118 if (!strncmp(p, "delay=", 6))
122 for (pd = d, p += 6; (*p) && (*p != ':'); p++, pd++)
137 _shot_file_get(Elm_Win *win)
140 char *tmp = strdup(win->shot.info);
141 char *repname = NULL;
143 if (!tmp) return NULL;
145 for (p = (char *)win->shot.info; *p; p++)
147 if (!strncmp(p, "file=", 5))
150 if (!win->shot.repeat_count) return tmp;
153 char *dotptr = strrchr(tmp, '.');
156 size_t size = sizeof(char)*(strlen(tmp) + 16);
157 repname = malloc(size);
158 strncpy(repname, tmp, dotptr - tmp);
159 snprintf(repname + (dotptr - tmp), size - (dotptr - tmp), "%03i",
160 win->shot.shot_counter + 1);
161 strcat(repname, dotptr);
169 if (!win->shot.repeat_count) return strdup("out.png");
171 repname = malloc(sizeof(char) * 24);
172 snprintf(repname, sizeof(char) * 24, "out%03i.png", win->shot.shot_counter + 1);
177 _shot_repeat_count_get(Elm_Win *win)
180 char *d = strdup(win->shot.info);
183 for (p = (char *)win->shot.info; *p; p++)
185 if (!strncmp(p, "repeat=", 7))
189 for (pd = d, p += 7; (*p) && (*p != ':'); p++, pd++)
196 if (v > 1000) v = 999;
206 _shot_key_get(Elm_Win *win __UNUSED__)
212 _shot_flags_get(Elm_Win *win __UNUSED__)
218 _shot_do(Elm_Win *win)
222 unsigned int *pixels;
224 char *file, *key, *flags;
226 ecore_evas_manual_render(win->ee);
227 pixels = (void *)ecore_evas_buffer_pixels_get(win->ee);
229 ecore_evas_geometry_get(win->ee, NULL, NULL, &w, &h);
230 if ((w < 1) || (h < 1)) return;
231 file = _shot_file_get(win);
233 key = _shot_key_get(win);
234 flags = _shot_flags_get(win);
235 ee = ecore_evas_buffer_new(1, 1);
236 o = evas_object_image_add(ecore_evas_get(ee));
237 evas_object_image_alpha_set(o, ecore_evas_alpha_get(win->ee));
238 evas_object_image_size_set(o, w, h);
239 evas_object_image_data_set(o, pixels);
240 if (!evas_object_image_save(o, file, key, flags))
242 ERR("Cannot save window to '%s' (key '%s', flags '%s')",
247 if (flags) free(flags);
249 if (win->shot.repeat_count) win->shot.shot_counter++;
253 _shot_delay(void *data)
257 if (win->shot.repeat_count)
259 int remainshot = (win->shot.repeat_count - win->shot.shot_counter);
260 if (remainshot > 0) return EINA_TRUE;
262 win->shot.timer = NULL;
268 _shot_init(Elm_Win *win)
270 if (!win->shot.info) return;
271 win->shot.repeat_count = _shot_repeat_count_get(win);
272 win->shot.shot_counter = 0;
276 _shot_handle(Elm_Win *win)
278 if (!win->shot.info) return;
279 win->shot.timer = ecore_timer_add(_shot_delay_get(win), _shot_delay, win);
283 _elm_win_move(Ecore_Evas *ee)
285 Evas_Object *obj = ecore_evas_object_associate_get(ee);
290 win = elm_widget_data_get(obj);
292 ecore_evas_geometry_get(ee, &x, &y, NULL, NULL);
295 evas_object_smart_callback_call(win->win_obj, SIG_MOVED, NULL);
299 _elm_win_resize(Ecore_Evas *ee)
301 Evas_Object *obj = ecore_evas_object_associate_get(ee);
305 win = elm_widget_data_get(obj);
307 if (win->deferred_resize_job) ecore_job_del(win->deferred_resize_job);
308 win->deferred_resize_job = ecore_job_add(_elm_win_resize_job, win);
312 _elm_win_mouse_in(Ecore_Evas *ee)
317 if (!(obj = ecore_evas_object_associate_get(ee))) return;
318 if (!(win = elm_widget_data_get(obj))) return;
319 if (win->resizing) win->resizing = EINA_FALSE;
323 _elm_win_focus_in(Ecore_Evas *ee)
325 Evas_Object *obj = ecore_evas_object_associate_get(ee);
329 win = elm_widget_data_get(obj);
331 _elm_widget_top_win_focused_set(win->win_obj, EINA_TRUE);
332 if (win->show_count == 1)
334 elm_widget_focus_steal(win->win_obj);
338 elm_widget_focus_restore(win->win_obj);
339 evas_object_smart_callback_call(win->win_obj, SIG_FOCUS_IN, NULL);
340 win->focus_highlight.cur.visible = EINA_TRUE;
341 _elm_win_focus_highlight_reconfigure_job_start(win);
344 edje_object_signal_emit(win->frame_obj, "elm,action,focus", "elm");
346 else if (win->img_obj)
353 _elm_win_focus_out(Ecore_Evas *ee)
355 Evas_Object *obj = ecore_evas_object_associate_get(ee);
359 win = elm_widget_data_get(obj);
361 elm_object_focus_set(win->win_obj, EINA_FALSE);
362 _elm_widget_top_win_focused_set(win->win_obj, EINA_FALSE);
363 evas_object_smart_callback_call(win->win_obj, SIG_FOCUS_OUT, NULL);
364 win->focus_highlight.cur.visible = EINA_FALSE;
365 _elm_win_focus_highlight_reconfigure_job_start(win);
368 edje_object_signal_emit(win->frame_obj, "elm,action,unfocus", "elm");
370 else if (win->img_obj)
377 _elm_win_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
379 Elm_Win *wd = elm_widget_data_get(obj);
380 const Eina_List *items;
381 void *(*list_data_get) (const Eina_List *list);
389 if (!(items = elm_widget_focus_custom_chain_get(obj)))
395 list_data_get = eina_list_data_get;
397 elm_widget_focus_list_next_get(obj, items, list_data_get, dir, next);
403 *next = (Evas_Object *)obj;
408 _elm_win_on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
410 Elm_Win *win = elm_widget_data_get(obj);
414 evas_object_focus_set(win->img_obj, elm_widget_focus_get(obj));
416 evas_object_focus_set(obj, elm_widget_focus_get(obj));
420 _elm_win_event_cb(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
422 if (type == EVAS_CALLBACK_KEY_DOWN)
424 Evas_Event_Key_Down *ev = event_info;
425 if (!strcmp(ev->keyname, "Tab"))
427 if (evas_key_modifier_is_set(ev->modifiers, "Shift"))
428 elm_widget_focus_cycle(obj, ELM_FOCUS_PREVIOUS);
430 elm_widget_focus_cycle(obj, ELM_FOCUS_NEXT);
431 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
434 else if ((!strcmp(ev->keyname, "Left")) ||
435 (!strcmp(ev->keyname, "KP_Left")))
437 //TODO : woohyun jung
439 else if ((!strcmp(ev->keyname, "Right")) ||
440 (!strcmp(ev->keyname, "KP_Right")))
442 //TODO : woohyun jung
444 else if ((!strcmp(ev->keyname, "Up")) ||
445 (!strcmp(ev->keyname, "KP_Up")))
447 //TODO : woohyun jung
449 else if ((!strcmp(ev->keyname, "Down")) ||
450 (!strcmp(ev->keyname, "KP_Down")))
452 //TODO : woohyun jung
460 _deferred_ecore_evas_free(void *data)
462 ecore_evas_free(data);
463 _elm_win_deferred_free--;
467 _elm_win_obj_callback_show(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
471 if (!win->show_count) win->show_count++;
472 if (win->shot.info) _shot_handle(win);
476 _elm_win_obj_callback_hide(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
482 evas_object_hide(win->frame_obj);
484 else if (win->img_obj)
486 evas_object_hide(win->img_obj);
491 _elm_win_obj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info __UNUSED__)
498 evas_object_event_callback_del_full(win->parent, EVAS_CALLBACK_DEL,
499 _elm_win_obj_callback_parent_del, win);
502 if (win->autodel_clear) *(win->autodel_clear) = -1;
503 _elm_win_list = eina_list_remove(_elm_win_list, win->win_obj);
504 while (win->subobjs) elm_win_resize_object_del(obj, win->subobjs->data);
507 ecore_evas_callback_delete_request_set(win->ee, NULL);
508 ecore_evas_callback_resize_set(win->ee, NULL);
510 if (win->deferred_resize_job) ecore_job_del(win->deferred_resize_job);
511 if (win->deferred_child_eval_job) ecore_job_del(win->deferred_child_eval_job);
512 if (win->shot.info) eina_stringshare_del(win->shot.info);
513 if (win->shot.timer) ecore_timer_del(win->shot.timer);
514 evas_object_event_callback_del_full(win->win_obj, EVAS_CALLBACK_DEL,
515 _elm_win_obj_callback_del, win);
516 while (((child = evas_object_bottom_get(win->evas))) &&
519 evas_object_del(child);
521 while (((child = evas_object_top_get(win->evas))) &&
524 evas_object_del(child);
526 #ifdef HAVE_ELEMENTARY_X
527 if (win->client_message_handler)
528 ecore_event_handler_del(win->client_message_handler);
530 // FIXME: Why are we flushing edje on every window destroy ??
531 // edje_file_cache_flush();
532 // edje_collection_cache_flush();
533 // evas_image_cache_flush(win->evas);
534 // evas_font_cache_flush(win->evas);
535 // FIXME: we are in the del handler for the object and delete the canvas
536 // that lives under it from the handler... nasty. deferring doesn't help either
546 ecore_job_add(_deferred_ecore_evas_free, win->ee);
547 _elm_win_deferred_free++;
551 _elm_win_focus_highlight_shutdown(win);
552 eina_stringshare_del(win->focus_highlight.style);
556 if ((!_elm_win_list) &&
557 (elm_policy_get(ELM_POLICY_QUIT) == ELM_POLICY_QUIT_LAST_WINDOW_CLOSED))
559 edje_file_cache_flush();
560 edje_collection_cache_flush();
561 evas_image_cache_flush(e);
562 evas_font_cache_flush(e);
568 _elm_win_obj_callback_img_obj_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
571 if (!win->img_obj) return;
572 evas_object_event_callback_del_full
573 (win->img_obj, EVAS_CALLBACK_DEL, _elm_win_obj_callback_img_obj_del, win);
574 evas_object_del(win->img_obj);
578 _elm_win_obj_callback_parent_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
581 if (obj == win->parent) win->parent = NULL;
585 _elm_win_obj_intercept_move(void *data, Evas_Object *obj, Evas_Coord x, Evas_Coord y)
591 if ((x != win->screen.x) || (y != win->screen.y))
595 evas_object_smart_callback_call(win->win_obj, SIG_MOVED, NULL);
600 evas_object_move(obj, x, y);
605 _elm_win_obj_intercept_show(void *data, Evas_Object *obj)
608 // this is called to make sure all smart containers have calculated their
609 // sizes BEFORE we show the window to make sure it initially appears at
610 // our desired size (ie min size is known first)
611 evas_smart_objects_calculate(evas_object_evas_get(obj));
614 evas_object_show(win->frame_obj);
616 else if (win->img_obj)
618 evas_object_show(win->img_obj);
620 evas_object_show(obj);
624 _elm_win_obj_callback_move(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
628 if (ecore_evas_override_get(win->ee))
632 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
635 evas_object_smart_callback_call(win->win_obj, SIG_MOVED, NULL);
641 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
645 else if (win->img_obj)
649 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
652 // evas_object_move(win->img_obj, x, y);
657 _elm_win_obj_callback_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
664 else if (win->img_obj)
666 Evas_Coord w = 1, h = 1;
668 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
672 ecore_evas_screen_geometry_get(win->ee, NULL, NULL, &sw, &sh);
678 evas_object_image_size_set(win->img_obj, w, h);
683 _elm_win_delete_request(Ecore_Evas *ee)
685 Evas_Object *obj = ecore_evas_object_associate_get(ee);
687 if (strcmp(elm_widget_type_get(obj), "win")) return;
689 win = elm_widget_data_get(obj);
691 int autodel = win->autodel;
692 win->autodel_clear = &autodel;
693 evas_object_ref(win->win_obj);
694 evas_object_smart_callback_call(win->win_obj, SIG_DELETE_REQUEST, NULL);
695 // FIXME: if above callback deletes - then the below will be invalid
696 if (autodel) evas_object_del(win->win_obj);
697 else win->autodel_clear = NULL;
698 evas_object_unref(win->win_obj);
702 _elm_win_resize_job(void *data)
709 win->deferred_resize_job = NULL;
710 ecore_evas_request_geometry_get(win->ee, NULL, NULL, &w, &h);
714 ecore_evas_screen_geometry_get(win->ee, NULL, NULL, &sw, &sh);
720 evas_object_resize(win->frame_obj, w, h);
722 else if (win->img_obj)
725 evas_object_resize(win->win_obj, w, h);
726 EINA_LIST_FOREACH(win->subobjs, l, obj)
728 evas_object_move(obj, 0, 0);
729 evas_object_resize(obj, w, h);
733 #ifdef HAVE_ELEMENTARY_X
735 _elm_win_xwindow_get(Elm_Win *win)
739 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
740 if (ENGINE_COMPARE(ELM_SOFTWARE_X11))
742 if (win->ee) win->xwin = ecore_evas_software_x11_window_get(win->ee);
744 else if (ENGINE_COMPARE(ELM_SOFTWARE_X11) ||
745 ENGINE_COMPARE(ELM_SOFTWARE_FB) ||
746 ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE) ||
747 ENGINE_COMPARE(ELM_SOFTWARE_SDL) ||
748 ENGINE_COMPARE(ELM_SOFTWARE_16_SDL) ||
749 ENGINE_COMPARE(ELM_OPENGL_SDL) ||
750 ENGINE_COMPARE(ELM_OPENGL_COCOA))
753 else if (ENGINE_COMPARE(ELM_SOFTWARE_16_X11))
755 if (win->ee) win->xwin = ecore_evas_software_x11_16_window_get(win->ee);
757 else if (ENGINE_COMPARE(ELM_SOFTWARE_8_X11))
759 if (win->ee) win->xwin = ecore_evas_software_x11_8_window_get(win->ee);
762 else if (ENGINE_COMPARE(ELM_XRENDER_X11))
764 if (win->ee) win->xwin = ecore_evas_xrender_x11_window_get(win->ee);
767 else if (ENGINE_COMPARE(ELM_OPENGL_X11))
769 if (win->ee) win->xwin = ecore_evas_gl_x11_window_get(win->ee);
771 else if (ENGINE_COMPARE(ELM_SOFTWARE_WIN32))
773 if (win->ee) win->xwin = (long)ecore_evas_win32_window_get(win->ee);
775 #undef ENGINE_COMPARE
779 #ifdef HAVE_ELEMENTARY_X
781 _elm_win_xwin_update(Elm_Win *win)
783 _elm_win_xwindow_get(win);
788 win2 = elm_widget_data_get(win->parent);
792 ecore_x_icccm_transient_for_set(win->xwin, win2->xwin);
796 if (!win->xwin) return; /* nothing more to do */
801 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_NORMAL);
803 case ELM_WIN_DIALOG_BASIC:
804 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DIALOG);
806 case ELM_WIN_DESKTOP:
807 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DESKTOP);
810 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DOCK);
812 case ELM_WIN_TOOLBAR:
813 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_TOOLBAR);
816 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_MENU);
818 case ELM_WIN_UTILITY:
819 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_UTILITY);
822 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_SPLASH);
824 case ELM_WIN_DROPDOWN_MENU:
825 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DROPDOWN_MENU);
827 case ELM_WIN_POPUP_MENU:
828 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_POPUP_MENU);
830 case ELM_WIN_TOOLTIP:
831 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_TOOLTIP);
833 case ELM_WIN_NOTIFICATION:
834 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_NOTIFICATION);
837 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_COMBO);
840 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DND);
845 ecore_x_e_virtual_keyboard_state_set
846 (win->xwin, (Ecore_X_Virtual_Keyboard_State)win->kbdmode);
851 _elm_win_eval_subobjs(Evas_Object *obj)
854 const Evas_Object *child;
856 Elm_Win *win = elm_widget_data_get(obj);
857 Evas_Coord w, h, minw = -1, minh = -1, maxw = -1, maxh = -1;
861 EINA_LIST_FOREACH(win->subobjs, l, child)
863 evas_object_size_hint_weight_get(child, &wx, &wy);
864 if (wx == 0.0) xx = 0;
865 if (wy == 0.0) xy = 0;
867 evas_object_size_hint_min_get(child, &w, &h);
870 if (w > minw) minw = w;
871 if (h > minh) minh = h;
873 evas_object_size_hint_max_get(child, &w, &h);
876 if (maxw == -1) maxw = w;
877 else if ((w > 0) && (w < maxw)) maxw = w;
878 if (maxh == -1) maxh = h;
879 else if ((h > 0) && (h < maxh)) maxh = h;
881 if (!xx) maxw = minw;
883 if (!xy) maxh = minh;
885 evas_object_size_hint_min_set(obj, minw, minh);
886 evas_object_size_hint_max_set(obj, maxw, maxh);
887 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
888 if (w < minw) w = minw;
889 if (h < minh) h = minh;
890 if ((maxw >= 0) && (w > maxw)) w = maxw;
891 if ((maxh >= 0) && (h > maxh)) h = maxh;
892 evas_object_resize(obj, w, h);
896 _elm_win_subobj_callback_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
898 Elm_Win *win = elm_widget_data_get(data);
899 win->subobjs = eina_list_remove(win->subobjs, obj);
900 _elm_win_eval_subobjs(win->win_obj);
904 _elm_win_subobj_callback_changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
906 _elm_win_eval_subobjs(data);
910 _elm_win_shutdown(void)
912 while (_elm_win_list)
913 evas_object_del(_elm_win_list->data);
917 _elm_win_rescale(Elm_Theme *th, Eina_Bool use_theme)
924 EINA_LIST_FOREACH(_elm_win_list, l, obj)
925 elm_widget_theme(obj);
929 EINA_LIST_FOREACH(_elm_win_list, l, obj)
930 elm_widget_theme_specific(obj, th, EINA_FALSE);
935 _elm_win_translate(void)
940 EINA_LIST_FOREACH(_elm_win_list, l, obj)
941 elm_widget_translate(obj);
944 #ifdef HAVE_ELEMENTARY_X
946 _elm_win_client_message(void *data, int type __UNUSED__, void *event)
949 Ecore_X_Event_Client_Message *e = event;
951 if (e->format != 32) return ECORE_CALLBACK_PASS_ON;
952 if (e->message_type == ECORE_X_ATOM_E_COMP_FLUSH)
954 if ((unsigned)e->data.l[0] == win->xwin)
956 Evas *evas = evas_object_evas_get(win->win_obj);
959 edje_file_cache_flush();
960 edje_collection_cache_flush();
961 evas_image_cache_flush(evas);
962 evas_font_cache_flush(evas);
966 else if (e->message_type == ECORE_X_ATOM_E_COMP_DUMP)
968 if ((unsigned)e->data.l[0] == win->xwin)
970 Evas *evas = evas_object_evas_get(win->win_obj);
973 edje_file_cache_flush();
974 edje_collection_cache_flush();
975 evas_image_cache_flush(evas);
976 evas_font_cache_flush(evas);
977 evas_render_dump(evas);
981 return ECORE_CALLBACK_PASS_ON;
986 _elm_win_focus_target_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
990 win->focus_highlight.geometry_changed = EINA_TRUE;
991 _elm_win_focus_highlight_reconfigure_job_start(win);
995 _elm_win_focus_target_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
999 win->focus_highlight.geometry_changed = EINA_TRUE;
1000 _elm_win_focus_highlight_reconfigure_job_start(win);
1004 _elm_win_focus_target_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1006 Elm_Win *win = data;
1008 win->focus_highlight.cur.target = NULL;
1010 _elm_win_focus_highlight_reconfigure_job_start(win);
1014 _elm_win_focus_target_callbacks_add(Elm_Win *win)
1016 Evas_Object *obj = win->focus_highlight.cur.target;
1018 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE,
1019 _elm_win_focus_target_move, win);
1020 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE,
1021 _elm_win_focus_target_resize, win);
1022 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
1023 _elm_win_focus_target_del, win);
1027 _elm_win_focus_target_callbacks_del(Elm_Win *win)
1029 Evas_Object *obj = win->focus_highlight.cur.target;
1031 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_MOVE,
1032 _elm_win_focus_target_move, win);
1033 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_RESIZE,
1034 _elm_win_focus_target_resize, win);
1035 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL,
1036 _elm_win_focus_target_del, win);
1039 static Evas_Object *
1040 _elm_win_focus_target_get(Evas_Object *obj)
1042 Evas_Object *o = obj;
1046 if (elm_widget_is(o))
1048 if (!elm_widget_highlight_ignore_get(o))
1050 o = elm_widget_parent_get(o);
1052 o = evas_object_smart_parent_get(o);
1056 o = elm_widget_parent_widget_get(o);
1058 o = evas_object_smart_parent_get(o);
1067 _elm_win_object_focus_in(void *data, Evas *e __UNUSED__, void *event_info)
1069 Evas_Object *obj = event_info, *target;
1070 Elm_Win *win = data;
1072 if (win->focus_highlight.cur.target == obj)
1075 target = _elm_win_focus_target_get(obj);
1076 win->focus_highlight.cur.target = target;
1077 if (elm_widget_highlight_in_theme_get(target))
1078 win->focus_highlight.cur.handled = EINA_TRUE;
1080 _elm_win_focus_target_callbacks_add(win);
1082 _elm_win_focus_highlight_reconfigure_job_start(win);
1086 _elm_win_object_focus_out(void *data, Evas *e __UNUSED__, void *event_info __UNUSED__)
1088 Elm_Win *win = data;
1090 if (!win->focus_highlight.cur.target)
1093 if (!win->focus_highlight.cur.handled)
1094 _elm_win_focus_target_callbacks_del(win);
1095 win->focus_highlight.cur.target = NULL;
1096 win->focus_highlight.cur.handled = EINA_FALSE;
1098 _elm_win_focus_highlight_reconfigure_job_start(win);
1102 _elm_win_focus_highlight_hide(void *data __UNUSED__, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
1104 evas_object_hide(obj);
1108 _elm_win_focus_highlight_init(Elm_Win *win)
1110 evas_event_callback_add(win->evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
1111 _elm_win_object_focus_in, win);
1112 evas_event_callback_add(win->evas,
1113 EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
1114 _elm_win_object_focus_out, win);
1116 win->focus_highlight.cur.target = evas_focus_get(win->evas);
1118 win->focus_highlight.top = edje_object_add(win->evas);
1119 win->focus_highlight.changed_theme = EINA_TRUE;
1120 edje_object_signal_callback_add(win->focus_highlight.top,
1121 "elm,action,focus,hide,end", "",
1122 _elm_win_focus_highlight_hide, NULL);
1123 edje_object_signal_callback_add(win->focus_highlight.top,
1124 "elm,action,focus,anim,end", "",
1125 _elm_win_focus_highlight_anim_end, win);
1126 _elm_win_focus_highlight_reconfigure_job_start(win);
1130 _elm_win_focus_highlight_shutdown(Elm_Win *win)
1132 _elm_win_focus_highlight_reconfigure_job_stop(win);
1133 if (win->focus_highlight.cur.target)
1135 _elm_win_focus_target_callbacks_del(win);
1136 win->focus_highlight.cur.target = NULL;
1138 if (win->focus_highlight.top)
1140 evas_object_del(win->focus_highlight.top);
1141 win->focus_highlight.top = NULL;
1144 evas_event_callback_del_full(win->evas,
1145 EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
1146 _elm_win_object_focus_in, win);
1147 evas_event_callback_del_full(win->evas,
1148 EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
1149 _elm_win_object_focus_out, win);
1153 _elm_win_focus_highlight_visible_set(Elm_Win *win, Eina_Bool visible)
1157 top = win->focus_highlight.top;
1162 evas_object_show(top);
1163 edje_object_signal_emit(top, "elm,action,focus,show", "elm");
1169 edje_object_signal_emit(top, "elm,action,focus,hide", "elm");
1174 _elm_win_focus_highlight_reconfigure_job(void *data)
1176 _elm_win_focus_highlight_reconfigure((Elm_Win *)data);
1180 _elm_win_focus_highlight_reconfigure_job_start(Elm_Win *win)
1182 if (win->focus_highlight.reconf_job)
1183 ecore_job_del(win->focus_highlight.reconf_job);
1184 win->focus_highlight.reconf_job = ecore_job_add(
1185 _elm_win_focus_highlight_reconfigure_job, win);
1189 _elm_win_focus_highlight_reconfigure_job_stop(Elm_Win *win)
1191 if (win->focus_highlight.reconf_job)
1192 ecore_job_del(win->focus_highlight.reconf_job);
1193 win->focus_highlight.reconf_job = NULL;
1197 _elm_win_focus_highlight_simple_setup(Elm_Win *win, Evas_Object *obj)
1199 Evas_Object *clip, *target = win->focus_highlight.cur.target;
1200 Evas_Coord x, y, w, h;
1202 clip = evas_object_clip_get(target);
1203 evas_object_geometry_get(target, &x, &y, &w, &h);
1205 evas_object_move(obj, x, y);
1206 evas_object_resize(obj, w, h);
1207 evas_object_clip_set(obj, clip);
1211 _elm_win_focus_highlight_anim_setup(Elm_Win *win, Evas_Object *obj)
1213 Evas_Coord tx, ty, tw, th;
1214 Evas_Coord w, h, px, py, pw, ph;
1215 Edje_Message_Int_Set *m;
1216 Evas_Object *previous = win->focus_highlight.prev.target;
1217 Evas_Object *target = win->focus_highlight.cur.target;
1219 evas_object_geometry_get(win->win_obj, NULL, NULL, &w, &h);
1220 evas_object_geometry_get(target, &tx, &ty, &tw, &th);
1221 evas_object_geometry_get(previous, &px, &py, &pw, &ph);
1222 evas_object_move(obj, 0, 0);
1223 evas_object_resize(obj, tw, th);
1224 evas_object_clip_unset(obj);
1226 m = alloca(sizeof(*m) + (sizeof(int) * 8));
1236 edje_object_message_send(obj, EDJE_MESSAGE_INT_SET, 1, m);
1240 _elm_win_focus_highlight_anim_end(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
1242 Elm_Win *win = data;
1243 _elm_win_focus_highlight_simple_setup(win, obj);
1247 _elm_win_focus_highlight_reconfigure(Elm_Win *win)
1249 Evas_Object *target = win->focus_highlight.cur.target;
1250 Evas_Object *previous = win->focus_highlight.prev.target;
1251 Evas_Object *top = win->focus_highlight.top;
1252 Eina_Bool visible_changed;
1253 Eina_Bool common_visible;
1254 const char *sig = NULL;
1256 _elm_win_focus_highlight_reconfigure_job_stop(win);
1258 visible_changed = (win->focus_highlight.cur.visible !=
1259 win->focus_highlight.prev.visible);
1261 if ((target == previous) && (!visible_changed) &&
1262 (!win->focus_highlight.geometry_changed))
1265 if ((previous) && (win->focus_highlight.prev.handled))
1266 elm_widget_signal_emit(previous, "elm,action,focus_highlight,hide", "elm");
1269 common_visible = EINA_FALSE;
1270 else if (win->focus_highlight.cur.handled)
1272 common_visible = EINA_FALSE;
1273 if (win->focus_highlight.cur.visible)
1274 sig = "elm,action,focus_highlight,show";
1276 sig = "elm,action,focus_highlight,hide";
1279 common_visible = win->focus_highlight.cur.visible;
1281 _elm_win_focus_highlight_visible_set(win, common_visible);
1283 elm_widget_signal_emit(target, sig, "elm");
1285 if ((!target) || (!common_visible) || (win->focus_highlight.cur.handled))
1288 if (win->focus_highlight.changed_theme)
1291 if (win->focus_highlight.style)
1292 str = win->focus_highlight.style;
1295 _elm_theme_object_set(win->win_obj, top, "focus_highlight", "top",
1297 win->focus_highlight.changed_theme = EINA_FALSE;
1299 if (_elm_config->focus_highlight_animate)
1301 str = edje_object_data_get(win->focus_highlight.top, "animate");
1302 win->focus_highlight.top_animate = ((str) && (!strcmp(str, "on")));
1306 if ((win->focus_highlight.top_animate) && (previous) &&
1307 (!win->focus_highlight.prev.handled))
1308 _elm_win_focus_highlight_anim_setup(win, top);
1310 _elm_win_focus_highlight_simple_setup(win, top);
1311 evas_object_raise(top);
1314 win->focus_highlight.geometry_changed = EINA_FALSE;
1315 win->focus_highlight.prev = win->focus_highlight.cur;
1319 _elm_win_frame_add(Elm_Win *win, const char *style)
1321 evas_output_framespace_set(win->evas, 0, 22, 0, 26);
1323 win->frame_obj = edje_object_add(win->evas);
1324 _elm_theme_set(NULL, win->frame_obj, "border", "base", style);
1325 evas_object_is_frame_object_set(win->frame_obj, EINA_TRUE);
1326 evas_object_move(win->frame_obj, 0, 0);
1327 evas_object_resize(win->frame_obj, 1, 1);
1329 edje_object_signal_callback_add(win->frame_obj, "elm,action,move,start",
1330 "elm", _elm_win_frame_cb_move_start, win);
1331 edje_object_signal_callback_add(win->frame_obj, "elm,action,resize,start",
1332 "*", _elm_win_frame_cb_resize_start, win);
1333 edje_object_signal_callback_add(win->frame_obj, "elm,action,minimize",
1334 "elm", _elm_win_frame_cb_minimize, win);
1335 edje_object_signal_callback_add(win->frame_obj, "elm,action,maximize",
1336 "elm", _elm_win_frame_cb_maximize, win);
1337 edje_object_signal_callback_add(win->frame_obj, "elm,action,close",
1338 "elm", _elm_win_frame_cb_close, win);
1342 _elm_win_frame_cb_move_start(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__)
1346 if (!(win = data)) return;
1347 /* FIXME: Change mouse pointer */
1349 /* NB: 0,0 are dummy values. Wayland handles the move by itself */
1350 ecore_evas_move(win->ee, 0, 0);
1354 _elm_win_frame_cb_resize_start(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source)
1358 if (!(win = data)) return;
1359 if (win->resizing) return;
1360 win->resizing = EINA_TRUE;
1362 /* FIXME: Change mouse pointer */
1364 if (!strcmp(source, "elm.event.resize.t"))
1365 win->resize_location = 1;
1366 else if (!strcmp(source, "elm.event.resize.b"))
1367 win->resize_location = 2;
1368 else if (!strcmp(source, "elm.event.resize.l"))
1369 win->resize_location = 4;
1370 else if (!strcmp(source, "elm.event.resize.r"))
1371 win->resize_location = 8;
1372 else if (!strcmp(source, "elm.event.resize.tl"))
1373 win->resize_location = 5;
1374 else if (!strcmp(source, "elm.event.resize.tr"))
1375 win->resize_location = 9;
1376 else if (!strcmp(source, "elm.event.resize.bl"))
1377 win->resize_location = 6;
1378 else if (!strcmp(source, "elm.event.resize.br"))
1379 win->resize_location = 10;
1381 win->resize_location = 0;
1383 /* FIXME: Change to more generic wayland resize function */
1384 if (win->resize_location > 0)
1385 ecore_evas_wayland_resize(win->ee, win->resize_location);
1389 _elm_win_frame_cb_minimize(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__)
1393 if (!(win = data)) return;
1394 ecore_evas_iconified_set(win->ee, EINA_TRUE);
1398 _elm_win_frame_cb_maximize(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__)
1402 if (!(win = data)) return;
1403 ecore_evas_maximized_set(win->ee, EINA_TRUE);
1407 _elm_win_frame_cb_close(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__)
1411 if (!(win = data)) return;
1412 evas_object_del(win->win_obj);
1417 _debug_key_down(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
1419 Evas_Event_Key_Down *ev = event_info;
1421 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1424 if ((strcmp(ev->keyname, "F12")) ||
1425 (!evas_key_modifier_is_set(ev->modifiers, "Control")))
1428 printf("Tree graph generated.\n");
1429 elm_object_tree_dot_dump(obj, "./dump.dot");
1434 _win_img_hide(void *data,
1436 Evas_Object *obj __UNUSED__,
1437 void *event_info __UNUSED__)
1439 Elm_Win *win = data;
1441 elm_widget_focus_hide_handle(win->win_obj);
1445 _win_img_mouse_up(void *data,
1447 Evas_Object *obj __UNUSED__,
1450 Elm_Win *win = data;
1451 Evas_Event_Mouse_Up *ev = event_info;
1452 if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD))
1453 elm_widget_focus_mouse_up_handle(win->win_obj);
1457 _win_img_focus_in(void *data,
1459 Evas_Object *obj __UNUSED__,
1460 void *event_info __UNUSED__)
1462 Elm_Win *win = data;
1463 elm_widget_focus_steal(win->win_obj);
1467 _win_img_focus_out(void *data,
1469 Evas_Object *obj __UNUSED__,
1470 void *event_info __UNUSED__)
1472 Elm_Win *win = data;
1473 elm_widget_focused_object_clear(win->win_obj);
1477 _win_inlined_image_set(Elm_Win *win)
1479 evas_object_image_alpha_set(win->img_obj, EINA_FALSE);
1480 evas_object_image_filled_set(win->img_obj, EINA_TRUE);
1481 evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_DEL,
1482 _elm_win_obj_callback_img_obj_del, win);
1484 evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_HIDE,
1485 _win_img_hide, win);
1486 evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_MOUSE_UP,
1487 _win_img_mouse_up, win);
1488 evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_FOCUS_IN,
1489 _win_img_focus_in, win);
1490 evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_FOCUS_OUT,
1491 _win_img_focus_out, win);
1495 _subobj_del(Elm_Win *win, Evas_Object *obj, Evas_Object *subobj)
1497 evas_object_event_callback_del_full(subobj,
1498 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1499 _elm_win_subobj_callback_changed_size_hints,
1501 evas_object_event_callback_del_full(subobj, EVAS_CALLBACK_DEL,
1502 _elm_win_subobj_callback_del, obj);
1503 win->subobjs = eina_list_remove(win->subobjs, subobj);
1504 _elm_win_eval_subobjs(obj);
1508 elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type)
1512 const char *fontpath;
1514 win = ELM_NEW(Elm_Win);
1516 #define FALLBACK_TRY(engine) \
1519 CRITICAL(engine " engine creation failed. Trying default."); \
1520 win->ee = ecore_evas_new(NULL, 0, 0, 1, 1, NULL); \
1522 elm_engine_set(ecore_evas_engine_name_get(win->ee)); \
1524 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
1528 case ELM_WIN_INLINED_IMAGE:
1531 Evas *e = evas_object_evas_get(parent);
1534 ee = ecore_evas_ecore_evas_get(e);
1536 win->img_obj = ecore_evas_object_image_new(ee);
1537 if (!win->img_obj) break;
1538 win->ee = ecore_evas_object_ecore_evas_get(win->img_obj);
1541 _win_inlined_image_set(win);
1544 evas_object_del(win->img_obj);
1545 win->img_obj = NULL;
1549 case ELM_WIN_SOCKET_IMAGE:
1550 win->ee = ecore_evas_extn_socket_new(1, 1);
1554 if (ENGINE_COMPARE(ELM_SOFTWARE_X11))
1556 win->ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
1557 #ifdef HAVE_ELEMENTARY_X
1558 win->client_message_handler = ecore_event_handler_add
1559 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1561 FALLBACK_TRY("Sofware X11");
1563 else if (ENGINE_COMPARE(ELM_SOFTWARE_FB))
1565 win->ee = ecore_evas_fb_new(NULL, 0, 1, 1);
1566 FALLBACK_TRY("Sofware FB");
1568 else if (ENGINE_COMPARE(ELM_SOFTWARE_DIRECTFB))
1570 win->ee = ecore_evas_directfb_new(NULL, 1, 0, 0, 1, 1);
1571 FALLBACK_TRY("Sofware DirectFB");
1573 else if (ENGINE_COMPARE(ELM_SOFTWARE_16_X11))
1575 win->ee = ecore_evas_software_x11_16_new(NULL, 0, 0, 0, 1, 1);
1576 FALLBACK_TRY("Sofware-16");
1577 #ifdef HAVE_ELEMENTARY_X
1578 win->client_message_handler = ecore_event_handler_add
1579 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1582 else if (ENGINE_COMPARE(ELM_SOFTWARE_8_X11))
1584 win->ee = ecore_evas_software_x11_8_new(NULL, 0, 0, 0, 1, 1);
1585 FALLBACK_TRY("Sofware-8");
1586 #ifdef HAVE_ELEMENTARY_X
1587 win->client_message_handler = ecore_event_handler_add
1588 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1592 else if (ENGINE_COMPARE(ELM_XRENDER_X11))
1594 win->ee = ecore_evas_xrender_x11_new(NULL, 0, 0, 0, 1, 1);
1595 FALLBACK_TRY("XRender");
1596 #ifdef HAVE_ELEMENTARY_X
1597 win->client_message_handler = ecore_event_handler_add
1598 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1602 else if (ENGINE_COMPARE(ELM_OPENGL_X11))
1607 if (_elm_config->vsync)
1609 opt[opt_i] = ECORE_EVAS_GL_X11_OPT_VSYNC;
1615 win->ee = ecore_evas_gl_x11_options_new(NULL, 0, 0, 0, 1, 1, opt);
1617 win->ee = ecore_evas_gl_x11_new(NULL, 0, 0, 0, 1, 1);
1618 FALLBACK_TRY("OpenGL");
1619 #ifdef HAVE_ELEMENTARY_X
1620 win->client_message_handler = ecore_event_handler_add
1621 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1624 else if (ENGINE_COMPARE(ELM_SOFTWARE_WIN32))
1626 win->ee = ecore_evas_software_gdi_new(NULL, 0, 0, 1, 1);
1627 FALLBACK_TRY("Sofware Win32");
1629 else if (ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE))
1631 win->ee = ecore_evas_software_wince_gdi_new(NULL, 0, 0, 1, 1);
1632 FALLBACK_TRY("Sofware-16-WinCE");
1634 else if (ENGINE_COMPARE(ELM_SOFTWARE_PSL1GHT))
1636 win->ee = ecore_evas_psl1ght_new(NULL, 1, 1);
1637 FALLBACK_TRY("PSL1GHT");
1639 else if (ENGINE_COMPARE(ELM_SOFTWARE_SDL))
1641 win->ee = ecore_evas_sdl_new(NULL, 0, 0, 0, 0, 0, 1);
1642 FALLBACK_TRY("Sofware SDL");
1644 else if (ENGINE_COMPARE(ELM_SOFTWARE_16_SDL))
1646 win->ee = ecore_evas_sdl16_new(NULL, 0, 0, 0, 0, 0, 1);
1647 FALLBACK_TRY("Sofware-16-SDL");
1649 else if (ENGINE_COMPARE(ELM_OPENGL_SDL))
1651 win->ee = ecore_evas_gl_sdl_new(NULL, 1, 1, 0, 0);
1652 FALLBACK_TRY("OpenGL SDL");
1654 else if (ENGINE_COMPARE(ELM_OPENGL_COCOA))
1656 win->ee = ecore_evas_cocoa_new(NULL, 1, 1, 0, 0);
1657 FALLBACK_TRY("OpenGL Cocoa");
1659 else if (ENGINE_COMPARE(ELM_BUFFER))
1661 win->ee = ecore_evas_buffer_new(1, 1);
1663 else if (ENGINE_COMPARE(ELM_EWS))
1665 win->ee = ecore_evas_ews_new(0, 0, 1, 1);
1667 else if (ENGINE_COMPARE(ELM_WAYLAND_SHM))
1669 win->ee = ecore_evas_wayland_shm_new(NULL, 0, 0, 0, 1, 1, 0);
1670 win->evas = ecore_evas_get(win->ee);
1672 _elm_win_frame_add(win, "default");
1674 else if (ENGINE_COMPARE(ELM_WAYLAND_EGL))
1676 win->ee = ecore_evas_wayland_egl_new(NULL, 0, 0, 0, 1, 1, 0);
1677 win->evas = ecore_evas_get(win->ee);
1679 _elm_win_frame_add(win, "default");
1681 else if (!strncmp(_elm_config->engine, "shot:", 5))
1683 win->ee = ecore_evas_buffer_new(1, 1);
1684 ecore_evas_manual_render_set(win->ee, EINA_TRUE);
1685 win->shot.info = eina_stringshare_add(_elm_config->engine + 5);
1694 ERR("Cannot create window.");
1698 #ifdef HAVE_ELEMENTARY_X
1699 _elm_win_xwindow_get(win);
1701 if ((_elm_config->bgpixmap) && (!_elm_config->compositing))
1702 ecore_evas_avoid_damage_set(win->ee, ECORE_EVAS_AVOID_DAMAGE_EXPOSE);
1703 // bg pixmap done by x - has other issues like can be redrawn by x before it
1704 // is filled/ready by app
1705 // ecore_evas_avoid_damage_set(win->ee, ECORE_EVAS_AVOID_DAMAGE_BUILT_IN);
1708 win->parent = parent;
1710 evas_object_event_callback_add(win->parent, EVAS_CALLBACK_DEL,
1711 _elm_win_obj_callback_parent_del, win);
1713 win->evas = ecore_evas_get(win->ee);
1714 win->win_obj = elm_widget_add(win->evas);
1715 elm_widget_type_set(win->win_obj, "win");
1716 ELM_SET_WIDTYPE(widtype, "win");
1717 elm_widget_data_set(win->win_obj, win);
1718 elm_widget_event_hook_set(win->win_obj, _elm_win_event_cb);
1719 elm_widget_on_focus_hook_set(win->win_obj, _elm_win_on_focus_hook, NULL);
1720 elm_widget_can_focus_set(win->win_obj, EINA_TRUE);
1721 elm_widget_highlight_ignore_set(win->win_obj, EINA_TRUE);
1722 elm_widget_focus_next_hook_set(win->win_obj, _elm_win_focus_next_hook);
1723 evas_object_color_set(win->win_obj, 0, 0, 0, 0);
1724 evas_object_move(win->win_obj, 0, 0);
1725 evas_object_resize(win->win_obj, 1, 1);
1726 evas_object_layer_set(win->win_obj, 50);
1727 evas_object_pass_events_set(win->win_obj, EINA_TRUE);
1731 // evas_object_clip_set(win->win_obj, win->frame_obj);
1732 evas_object_stack_below(win->frame_obj, win->win_obj);
1735 if (type == ELM_WIN_INLINED_IMAGE)
1736 elm_widget_parent2_set(win->win_obj, parent);
1737 ecore_evas_object_associate(win->ee, win->win_obj,
1738 ECORE_EVAS_OBJECT_ASSOCIATE_BASE |
1739 ECORE_EVAS_OBJECT_ASSOCIATE_STACK |
1740 ECORE_EVAS_OBJECT_ASSOCIATE_LAYER);
1741 evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_SHOW,
1742 _elm_win_obj_callback_show, win);
1743 evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_HIDE,
1744 _elm_win_obj_callback_hide, win);
1745 evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_DEL,
1746 _elm_win_obj_callback_del, win);
1747 evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_MOVE,
1748 _elm_win_obj_callback_move, win);
1749 evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_RESIZE,
1750 _elm_win_obj_callback_resize, win);
1752 evas_object_intercept_move_callback_add(win->win_obj,
1753 _elm_win_obj_intercept_move, win);
1754 evas_object_intercept_show_callback_add(win->win_obj,
1755 _elm_win_obj_intercept_show, win);
1757 evas_object_smart_callback_add(win->win_obj, "sub-object-del", (Evas_Smart_Cb)_subobj_del, win);
1758 ecore_evas_name_class_set(win->ee, name, _elm_appname);
1759 ecore_evas_callback_delete_request_set(win->ee, _elm_win_delete_request);
1760 ecore_evas_callback_resize_set(win->ee, _elm_win_resize);
1761 ecore_evas_callback_mouse_in_set(win->ee, _elm_win_mouse_in);
1762 ecore_evas_callback_focus_in_set(win->ee, _elm_win_focus_in);
1763 ecore_evas_callback_focus_out_set(win->ee, _elm_win_focus_out);
1764 ecore_evas_callback_move_set(win->ee, _elm_win_move);
1765 evas_image_cache_set(win->evas, (_elm_config->image_cache * 1024));
1766 evas_font_cache_set(win->evas, (_elm_config->font_cache * 1024));
1767 EINA_LIST_FOREACH(_elm_config->font_dirs, l, fontpath)
1768 evas_font_path_append(win->evas, fontpath);
1769 if (!_elm_config->font_hinting)
1770 evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_NONE);
1771 else if (_elm_config->font_hinting == 1)
1772 evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_AUTO);
1773 else if (_elm_config->font_hinting == 2)
1774 evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_BYTECODE);
1776 #ifdef HAVE_ELEMENTARY_X
1777 _elm_win_xwin_update(win);
1780 _elm_win_list = eina_list_append(_elm_win_list, win->win_obj);
1782 if (ENGINE_COMPARE(ELM_SOFTWARE_FB))
1784 ecore_evas_fullscreen_set(win->ee, 1);
1786 #undef ENGINE_COMPARE
1788 if (_elm_config->focus_highlight_enable)
1789 elm_win_focus_highlight_enabled_set(win->win_obj, EINA_TRUE);
1792 Evas_Modifier_Mask mask = evas_key_modifier_mask_get(win->evas, "Control");
1793 evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_KEY_DOWN,
1794 _debug_key_down, win);
1796 Eina_Bool ret = evas_object_key_grab(win->win_obj, "F12", mask, 0,
1798 printf("Ctrl+F12 key combination exclusive for dot tree generation\n");
1801 evas_object_smart_callbacks_descriptions_set(win->win_obj, _signals);
1803 return win->win_obj;
1807 elm_win_util_standard_add(const char *name, const char *title)
1809 Evas_Object *win, *bg;
1811 win = elm_win_add(NULL, name, ELM_WIN_BASIC);
1812 if (!win) return NULL;
1813 elm_win_title_set(win, title);
1814 bg = elm_bg_add(win);
1817 evas_object_del(win);
1820 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1821 elm_win_resize_object_add(win, bg);
1822 evas_object_show(bg);
1827 elm_win_resize_object_add(Evas_Object *obj, Evas_Object *subobj)
1831 ELM_CHECK_WIDTYPE(obj, widtype);
1832 win = elm_widget_data_get(obj);
1834 if (eina_list_data_find(win->subobjs, subobj)) return;
1835 win->subobjs = eina_list_append(win->subobjs, subobj);
1836 elm_widget_sub_object_add(obj, subobj);
1837 evas_object_event_callback_add(subobj, EVAS_CALLBACK_DEL,
1838 _elm_win_subobj_callback_del, obj);
1839 evas_object_event_callback_add(subobj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1840 _elm_win_subobj_callback_changed_size_hints,
1842 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
1843 evas_object_move(subobj, 0, 0);
1844 evas_object_resize(subobj, w, h);
1845 _elm_win_eval_subobjs(obj);
1849 elm_win_resize_object_del(Evas_Object *obj, Evas_Object *subobj)
1852 ELM_CHECK_WIDTYPE(obj, widtype);
1853 win = elm_widget_data_get(obj);
1855 evas_object_event_callback_del_full(subobj,
1856 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1857 _elm_win_subobj_callback_changed_size_hints,
1859 evas_object_event_callback_del_full(subobj, EVAS_CALLBACK_DEL,
1860 _elm_win_subobj_callback_del, obj);
1861 win->subobjs = eina_list_remove(win->subobjs, subobj);
1862 elm_widget_sub_object_del(obj, subobj);
1863 _elm_win_eval_subobjs(obj);
1867 elm_win_title_set(Evas_Object *obj, const char *title)
1870 ELM_CHECK_WIDTYPE(obj, widtype);
1871 win = elm_widget_data_get(obj);
1873 ecore_evas_title_set(win->ee, title);
1875 edje_object_part_text_set(win->frame_obj, "elm.text.title", title);
1879 elm_win_title_get(const Evas_Object *obj)
1882 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1883 win = elm_widget_data_get(obj);
1884 if (!win) return NULL;
1885 return ecore_evas_title_get(win->ee);
1889 elm_win_autodel_set(Evas_Object *obj, Eina_Bool autodel)
1892 ELM_CHECK_WIDTYPE(obj, widtype);
1893 win = elm_widget_data_get(obj);
1895 win->autodel = autodel;
1899 elm_win_autodel_get(const Evas_Object *obj)
1902 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1903 win = elm_widget_data_get(obj);
1904 if (!win) return EINA_FALSE;
1905 return win->autodel;
1909 elm_win_activate(Evas_Object *obj)
1912 ELM_CHECK_WIDTYPE(obj, widtype);
1913 win = elm_widget_data_get(obj);
1915 ecore_evas_activate(win->ee);
1919 elm_win_lower(Evas_Object *obj)
1922 ELM_CHECK_WIDTYPE(obj, widtype);
1923 win = elm_widget_data_get(obj);
1925 ecore_evas_lower(win->ee);
1929 elm_win_raise(Evas_Object *obj)
1932 ELM_CHECK_WIDTYPE(obj, widtype);
1933 win = elm_widget_data_get(obj);
1935 ecore_evas_raise(win->ee);
1939 elm_win_center(Evas_Object *obj, Eina_Bool h, Eina_Bool v)
1942 int win_w, win_h, screen_w, screen_h, nx, ny;
1943 ELM_CHECK_WIDTYPE(obj, widtype);
1944 win = elm_widget_data_get(obj);
1946 ecore_evas_screen_geometry_get(win->ee, NULL, NULL, &screen_w, &screen_h);
1947 if ((!screen_w) || (!screen_h)) return;
1948 evas_object_geometry_get(obj, NULL, NULL, &win_w, &win_h);
1949 if ((!win_w) || (!win_h)) return;
1950 if (h) nx = win_w >= screen_w ? 0 : (screen_w / 2) - (win_w / 2);
1951 else nx = win->screen.x;
1952 if (v) ny = win_h >= screen_h ? 0 : (screen_h / 2) - (win_h / 2);
1953 else ny = win->screen.y;
1956 evas_object_move(obj, nx, ny);
1960 elm_win_borderless_set(Evas_Object *obj, Eina_Bool borderless)
1963 ELM_CHECK_WIDTYPE(obj, widtype);
1964 win = elm_widget_data_get(obj);
1966 ecore_evas_borderless_set(win->ee, borderless);
1967 #ifdef HAVE_ELEMENTARY_X
1968 _elm_win_xwin_update(win);
1973 elm_win_borderless_get(const Evas_Object *obj)
1976 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1977 win = elm_widget_data_get(obj);
1978 if (!win) return EINA_FALSE;
1979 return ecore_evas_borderless_get(win->ee);
1983 elm_win_shaped_set(Evas_Object *obj, Eina_Bool shaped)
1986 ELM_CHECK_WIDTYPE(obj, widtype);
1987 win = elm_widget_data_get(obj);
1989 ecore_evas_shaped_set(win->ee, shaped);
1990 #ifdef HAVE_ELEMENTARY_X
1991 _elm_win_xwin_update(win);
1996 elm_win_shaped_get(const Evas_Object *obj)
1999 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2000 win = elm_widget_data_get(obj);
2001 if (!win) return EINA_FALSE;
2002 return ecore_evas_shaped_get(win->ee);
2006 elm_win_alpha_set(Evas_Object *obj, Eina_Bool alpha)
2009 ELM_CHECK_WIDTYPE(obj, widtype);
2010 win = elm_widget_data_get(obj);
2015 else if (win->img_obj)
2017 evas_object_image_alpha_set(win->img_obj, alpha);
2018 ecore_evas_alpha_set(win->ee, alpha);
2022 #ifdef HAVE_ELEMENTARY_X
2027 if (!_elm_config->compositing)
2028 elm_win_shaped_set(obj, alpha);
2030 ecore_evas_alpha_set(win->ee, alpha);
2033 ecore_evas_alpha_set(win->ee, alpha);
2034 _elm_win_xwin_update(win);
2038 ecore_evas_alpha_set(win->ee, alpha);
2043 elm_win_alpha_get(const Evas_Object *obj)
2046 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2047 win = elm_widget_data_get(obj);
2048 if (!win) return EINA_FALSE;
2052 else if (win->img_obj)
2054 return evas_object_image_alpha_get(win->img_obj);
2056 return ecore_evas_alpha_get(win->ee);
2060 elm_win_transparent_set(Evas_Object *obj, Eina_Bool transparent)
2063 ELM_CHECK_WIDTYPE(obj, widtype);
2064 win = elm_widget_data_get(obj);
2070 else if (win->img_obj)
2072 evas_object_image_alpha_set(win->img_obj, transparent);
2076 #ifdef HAVE_ELEMENTARY_X
2079 ecore_evas_transparent_set(win->ee, transparent);
2080 _elm_win_xwin_update(win);
2084 ecore_evas_transparent_set(win->ee, transparent);
2089 elm_win_transparent_get(const Evas_Object *obj)
2092 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2093 win = elm_widget_data_get(obj);
2094 if (!win) return EINA_FALSE;
2096 return ecore_evas_transparent_get(win->ee);
2100 elm_win_override_set(Evas_Object *obj, Eina_Bool override)
2103 ELM_CHECK_WIDTYPE(obj, widtype);
2104 win = elm_widget_data_get(obj);
2106 ecore_evas_override_set(win->ee, override);
2107 #ifdef HAVE_ELEMENTARY_X
2108 _elm_win_xwin_update(win);
2113 elm_win_override_get(const Evas_Object *obj)
2116 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2117 win = elm_widget_data_get(obj);
2118 if (!win) return EINA_FALSE;
2119 return ecore_evas_override_get(win->ee);
2123 elm_win_fullscreen_set(Evas_Object *obj, Eina_Bool fullscreen)
2126 ELM_CHECK_WIDTYPE(obj, widtype);
2127 win = elm_widget_data_get(obj);
2130 // YYY: handle if win->img_obj
2131 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
2132 if (ENGINE_COMPARE(ELM_SOFTWARE_FB) ||
2133 ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE))
2135 // these engines... can ONLY be fullscreen
2140 ecore_evas_fullscreen_set(win->ee, fullscreen);
2141 #ifdef HAVE_ELEMENTARY_X
2142 _elm_win_xwin_update(win);
2145 #undef ENGINE_COMPARE
2149 elm_win_fullscreen_get(const Evas_Object *obj)
2152 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2153 win = elm_widget_data_get(obj);
2154 if (!win) return EINA_FALSE;
2156 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
2157 if (ENGINE_COMPARE(ELM_SOFTWARE_FB) ||
2158 ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE))
2160 // these engines... can ONLY be fullscreen
2165 return ecore_evas_fullscreen_get(win->ee);
2167 #undef ENGINE_COMPARE
2171 elm_win_maximized_set(Evas_Object *obj, Eina_Bool maximized)
2174 ELM_CHECK_WIDTYPE(obj, widtype);
2175 win = elm_widget_data_get(obj);
2177 // YYY: handle if win->img_obj
2178 ecore_evas_maximized_set(win->ee, maximized);
2179 #ifdef HAVE_ELEMENTARY_X
2180 _elm_win_xwin_update(win);
2185 elm_win_maximized_get(const Evas_Object *obj)
2188 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2189 win = elm_widget_data_get(obj);
2190 if (!win) return EINA_FALSE;
2191 return ecore_evas_maximized_get(win->ee);
2195 elm_win_iconified_set(Evas_Object *obj, Eina_Bool iconified)
2198 ELM_CHECK_WIDTYPE(obj, widtype);
2199 win = elm_widget_data_get(obj);
2201 ecore_evas_iconified_set(win->ee, iconified);
2202 #ifdef HAVE_ELEMENTARY_X
2203 _elm_win_xwin_update(win);
2208 elm_win_iconified_get(const Evas_Object *obj)
2211 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2212 win = elm_widget_data_get(obj);
2213 if (!win) return EINA_FALSE;
2214 return ecore_evas_iconified_get(win->ee);
2218 elm_win_layer_set(Evas_Object *obj, int layer)
2221 ELM_CHECK_WIDTYPE(obj, widtype);
2222 win = elm_widget_data_get(obj);
2224 ecore_evas_layer_set(win->ee, layer);
2225 #ifdef HAVE_ELEMENTARY_X
2226 _elm_win_xwin_update(win);
2231 elm_win_layer_get(const Evas_Object *obj)
2234 ELM_CHECK_WIDTYPE(obj, widtype) -1;
2235 win = elm_widget_data_get(obj);
2236 if (!win) return -1;
2237 return ecore_evas_layer_get(win->ee);
2241 elm_win_rotation_set(Evas_Object *obj, int rotation)
2244 ELM_CHECK_WIDTYPE(obj, widtype);
2245 win = elm_widget_data_get(obj);
2247 if (win->rot == rotation) return;
2248 win->rot = rotation;
2249 ecore_evas_rotation_set(win->ee, rotation);
2250 evas_object_size_hint_min_set(obj, -1, -1);
2251 evas_object_size_hint_max_set(obj, -1, -1);
2252 _elm_win_eval_subobjs(obj);
2253 #ifdef HAVE_ELEMENTARY_X
2254 _elm_win_xwin_update(win);
2259 elm_win_rotation_with_resize_set(Evas_Object *obj, int rotation)
2262 ELM_CHECK_WIDTYPE(obj, widtype);
2263 win = elm_widget_data_get(obj);
2265 if (win->rot == rotation) return;
2266 win->rot = rotation;
2267 ecore_evas_rotation_with_resize_set(win->ee, rotation);
2268 evas_object_size_hint_min_set(obj, -1, -1);
2269 evas_object_size_hint_max_set(obj, -1, -1);
2270 _elm_win_eval_subobjs(obj);
2271 #ifdef HAVE_ELEMENTARY_X
2272 _elm_win_xwin_update(win);
2277 elm_win_rotation_get(const Evas_Object *obj)
2280 ELM_CHECK_WIDTYPE(obj, widtype) -1;
2281 win = elm_widget_data_get(obj);
2282 if (!win) return -1;
2287 elm_win_sticky_set(Evas_Object *obj, Eina_Bool sticky)
2290 ELM_CHECK_WIDTYPE(obj, widtype);
2291 win = elm_widget_data_get(obj);
2293 ecore_evas_sticky_set(win->ee, sticky);
2294 #ifdef HAVE_ELEMENTARY_X
2295 _elm_win_xwin_update(win);
2300 elm_win_sticky_get(const Evas_Object *obj)
2303 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2304 win = elm_widget_data_get(obj);
2305 if (!win) return EINA_FALSE;
2306 return ecore_evas_sticky_get(win->ee);
2310 elm_win_keyboard_mode_set(Evas_Object *obj, Elm_Win_Keyboard_Mode mode)
2313 ELM_CHECK_WIDTYPE(obj, widtype);
2314 win = elm_widget_data_get(obj);
2316 if (mode == win->kbdmode) return;
2317 #ifdef HAVE_ELEMENTARY_X
2318 _elm_win_xwindow_get(win);
2320 win->kbdmode = mode;
2321 #ifdef HAVE_ELEMENTARY_X
2323 ecore_x_e_virtual_keyboard_state_set
2324 (win->xwin, (Ecore_X_Virtual_Keyboard_State)win->kbdmode);
2328 EAPI Elm_Win_Keyboard_Mode
2329 elm_win_keyboard_mode_get(const Evas_Object *obj)
2332 ELM_CHECK_WIDTYPE(obj, widtype) ELM_WIN_KEYBOARD_UNKNOWN;
2333 win = elm_widget_data_get(obj);
2334 if (!win) return ELM_WIN_KEYBOARD_UNKNOWN;
2335 return win->kbdmode;
2339 elm_win_keyboard_win_set(Evas_Object *obj, Eina_Bool is_keyboard)
2342 ELM_CHECK_WIDTYPE(obj, widtype);
2343 win = elm_widget_data_get(obj);
2345 #ifdef HAVE_ELEMENTARY_X
2346 _elm_win_xwindow_get(win);
2348 ecore_x_e_virtual_keyboard_set(win->xwin, is_keyboard);
2355 elm_win_keyboard_win_get(const Evas_Object *obj)
2358 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2359 win = elm_widget_data_get(obj);
2360 if (!win) return EINA_FALSE;
2361 #ifdef HAVE_ELEMENTARY_X
2362 _elm_win_xwindow_get(win);
2364 return ecore_x_e_virtual_keyboard_get(win->xwin);
2370 elm_win_screen_position_get(const Evas_Object *obj, int *x, int *y)
2373 ELM_CHECK_WIDTYPE(obj, widtype);
2374 win = elm_widget_data_get(obj);
2376 if (x) *x = win->screen.x;
2377 if (y) *y = win->screen.y;
2381 elm_win_focus_get(const Evas_Object *obj)
2384 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2385 win = elm_widget_data_get(obj);
2386 if (!win) return EINA_FALSE;
2387 return ecore_evas_focus_get(win->ee);
2391 elm_win_screen_constrain_set(Evas_Object *obj, Eina_Bool constrain)
2394 ELM_CHECK_WIDTYPE(obj, widtype);
2395 win = elm_widget_data_get(obj);
2397 win->constrain = !!constrain;
2401 elm_win_screen_constrain_get(Evas_Object *obj)
2404 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2405 win = elm_widget_data_get(obj);
2406 if (!win) return EINA_FALSE;
2407 return win->constrain;
2411 elm_win_screen_size_get(const Evas_Object *obj, int *x, int *y, int *w, int *h)
2414 ELM_CHECK_WIDTYPE(obj, widtype);
2415 win = elm_widget_data_get(obj);
2417 ecore_evas_screen_geometry_get(win->ee, x, y, w, h);
2421 elm_win_conformant_set(Evas_Object *obj, Eina_Bool conformant)
2424 ELM_CHECK_WIDTYPE(obj, widtype);
2425 win = elm_widget_data_get(obj);
2427 #ifdef HAVE_ELEMENTARY_X
2428 _elm_win_xwindow_get(win);
2430 ecore_x_e_illume_conformant_set(win->xwin, conformant);
2437 elm_win_conformant_get(const Evas_Object *obj)
2440 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2441 win = elm_widget_data_get(obj);
2442 if (!win) return EINA_FALSE;
2443 #ifdef HAVE_ELEMENTARY_X
2444 _elm_win_xwindow_get(win);
2446 return ecore_x_e_illume_conformant_get(win->xwin);
2452 elm_win_quickpanel_set(Evas_Object *obj, Eina_Bool quickpanel)
2455 ELM_CHECK_WIDTYPE(obj, widtype);
2456 win = elm_widget_data_get(obj);
2458 #ifdef HAVE_ELEMENTARY_X
2459 _elm_win_xwindow_get(win);
2462 ecore_x_e_illume_quickpanel_set(win->xwin, quickpanel);
2465 Ecore_X_Window_State states[2];
2467 states[0] = ECORE_X_WINDOW_STATE_SKIP_TASKBAR;
2468 states[1] = ECORE_X_WINDOW_STATE_SKIP_PAGER;
2469 ecore_x_netwm_window_state_set(win->xwin, states, 2);
2470 ecore_x_icccm_hints_set(win->xwin, 0, 0, 0, 0, 0, 0, 0);
2479 elm_win_quickpanel_get(const Evas_Object *obj)
2482 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2483 win = elm_widget_data_get(obj);
2484 if (!win) return EINA_FALSE;
2485 #ifdef HAVE_ELEMENTARY_X
2486 _elm_win_xwindow_get(win);
2488 return ecore_x_e_illume_quickpanel_get(win->xwin);
2494 elm_win_quickpanel_priority_major_set(Evas_Object *obj, int priority)
2497 ELM_CHECK_WIDTYPE(obj, widtype);
2498 win = elm_widget_data_get(obj);
2500 #ifdef HAVE_ELEMENTARY_X
2501 _elm_win_xwindow_get(win);
2503 ecore_x_e_illume_quickpanel_priority_major_set(win->xwin, priority);
2510 elm_win_quickpanel_priority_major_get(const Evas_Object *obj)
2513 ELM_CHECK_WIDTYPE(obj, widtype) -1;
2514 win = elm_widget_data_get(obj);
2515 if (!win) return -1;
2516 #ifdef HAVE_ELEMENTARY_X
2517 _elm_win_xwindow_get(win);
2519 return ecore_x_e_illume_quickpanel_priority_major_get(win->xwin);
2525 elm_win_quickpanel_priority_minor_set(Evas_Object *obj, int priority)
2528 ELM_CHECK_WIDTYPE(obj, widtype);
2529 win = elm_widget_data_get(obj);
2531 #ifdef HAVE_ELEMENTARY_X
2532 _elm_win_xwindow_get(win);
2534 ecore_x_e_illume_quickpanel_priority_minor_set(win->xwin, priority);
2541 elm_win_quickpanel_priority_minor_get(const Evas_Object *obj)
2544 ELM_CHECK_WIDTYPE(obj, widtype) -1;
2545 win = elm_widget_data_get(obj);
2546 if (!win) return -1;
2547 #ifdef HAVE_ELEMENTARY_X
2548 _elm_win_xwindow_get(win);
2550 return ecore_x_e_illume_quickpanel_priority_minor_get(win->xwin);
2556 elm_win_quickpanel_zone_set(Evas_Object *obj, int zone)
2559 ELM_CHECK_WIDTYPE(obj, widtype);
2560 win = elm_widget_data_get(obj);
2562 #ifdef HAVE_ELEMENTARY_X
2563 _elm_win_xwindow_get(win);
2565 ecore_x_e_illume_quickpanel_zone_set(win->xwin, zone);
2572 elm_win_quickpanel_zone_get(const Evas_Object *obj)
2575 ELM_CHECK_WIDTYPE(obj, widtype) 0;
2576 win = elm_widget_data_get(obj);
2578 #ifdef HAVE_ELEMENTARY_X
2579 _elm_win_xwindow_get(win);
2581 return ecore_x_e_illume_quickpanel_zone_get(win->xwin);
2587 elm_win_prop_focus_skip_set(Evas_Object *obj, Eina_Bool skip)
2590 ELM_CHECK_WIDTYPE(obj, widtype);
2591 win = elm_widget_data_get(obj);
2593 #ifdef HAVE_ELEMENTARY_X
2594 _elm_win_xwindow_get(win);
2599 Ecore_X_Window_State states[2];
2601 ecore_x_icccm_hints_set(win->xwin, 0, 0, 0, 0, 0, 0, 0);
2602 states[0] = ECORE_X_WINDOW_STATE_SKIP_TASKBAR;
2603 states[1] = ECORE_X_WINDOW_STATE_SKIP_PAGER;
2604 ecore_x_netwm_window_state_set(win->xwin, states, 2);
2613 elm_win_illume_command_send(Evas_Object *obj, Elm_Illume_Command command, void *params __UNUSED__)
2616 ELM_CHECK_WIDTYPE(obj, widtype);
2617 win = elm_widget_data_get(obj);
2619 #ifdef HAVE_ELEMENTARY_X
2620 _elm_win_xwindow_get(win);
2625 case ELM_ILLUME_COMMAND_FOCUS_BACK:
2626 ecore_x_e_illume_focus_back_send(win->xwin);
2628 case ELM_ILLUME_COMMAND_FOCUS_FORWARD:
2629 ecore_x_e_illume_focus_forward_send(win->xwin);
2631 case ELM_ILLUME_COMMAND_FOCUS_HOME:
2632 ecore_x_e_illume_focus_home_send(win->xwin);
2634 case ELM_ILLUME_COMMAND_CLOSE:
2635 ecore_x_e_illume_close_send(win->xwin);
2647 elm_win_inlined_image_object_get(Evas_Object *obj)
2650 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2651 win = elm_widget_data_get(obj);
2652 if (!win) return NULL;
2653 return win->img_obj;
2657 elm_win_focus_highlight_enabled_set(Evas_Object *obj, Eina_Bool enabled)
2661 ELM_CHECK_WIDTYPE(obj, widtype);
2663 win = elm_widget_data_get(obj);
2664 enabled = !!enabled;
2665 if (win->focus_highlight.enabled == enabled)
2668 win->focus_highlight.enabled = enabled;
2670 if (win->focus_highlight.enabled)
2671 _elm_win_focus_highlight_init(win);
2673 _elm_win_focus_highlight_shutdown(win);
2677 elm_win_focus_highlight_enabled_get(const Evas_Object *obj)
2681 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2683 win = elm_widget_data_get(obj);
2684 return win->focus_highlight.enabled;
2688 elm_win_focus_highlight_style_set(Evas_Object *obj, const char *style)
2692 ELM_CHECK_WIDTYPE(obj, widtype);
2694 win = elm_widget_data_get(obj);
2695 eina_stringshare_replace(&win->focus_highlight.style, style);
2696 win->focus_highlight.changed_theme = EINA_TRUE;
2697 _elm_win_focus_highlight_reconfigure_job_start(win);
2701 elm_win_focus_highlight_style_get(const Evas_Object *obj)
2705 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2707 win = elm_widget_data_get(obj);
2708 return win->focus_highlight.style;
2712 elm_win_indicator_state_set(Evas_Object *obj, int show_state)
2715 if (strcmp(elm_widget_type_get(obj), "win")) return;
2716 win = elm_widget_data_get(obj);
2718 #ifdef HAVE_ELEMENTARY_X
2719 _elm_win_xwindow_get(win);
2721 return ecore_x_window_prop_property_set (win->xwin,
2722 ECORE_X_ATOM_E_ILLUME_INDICATOR_STATE, ECORE_X_ATOM_CARDINAL, 32, &show_state, 1);
2728 elm_win_indicator_state_get(Evas_Object *obj)
2731 if (strcmp(elm_widget_type_get(obj), "win")) return -1;
2732 win = elm_widget_data_get(obj);
2733 if (!win) return -1;
2734 #ifdef HAVE_ELEMENTARY_X
2735 _elm_win_xwindow_get(win);
2741 unsigned int *prop_data = NULL;
2743 ret = ecore_x_window_prop_property_get (win->xwin,
2744 ECORE_X_ATOM_E_ILLUME_INDICATOR_STATE, ECORE_X_ATOM_CARDINAL, 32, (void *)&prop_data, &count);
2745 if( ret && prop_data )
2746 memcpy (&show, prop_data, sizeof (int));
2748 if (prop_data) free (prop_data);
2757 typedef struct _Widget_Data Widget_Data;
2762 Evas_Object *content;
2765 static void _del_hook(Evas_Object *obj);
2766 static void _theme_hook(Evas_Object *obj);
2767 static void _sizing_eval(Evas_Object *obj);
2768 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
2769 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
2771 static const char *widtype2 = NULL;
2774 _del_hook(Evas_Object *obj)
2776 Widget_Data *wd = elm_widget_data_get(obj);
2782 _theme_hook(Evas_Object *obj)
2784 Widget_Data *wd = elm_widget_data_get(obj);
2785 _elm_theme_object_set(obj, wd->frm, "win", "inwin", elm_widget_style_get(obj));
2787 edje_object_part_swallow(wd->frm, "elm.swallow.content", wd->content);
2790 evas_object_smart_callback_call(obj, SIG_THEME_CHANGED, NULL);
2794 _elm_inwin_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
2796 Widget_Data *wd = elm_widget_data_get(obj);
2801 /* Try Focus cycle in subitem */
2804 elm_widget_focus_next_get(wd->content, dir, next);
2809 *next = (Evas_Object *)obj;
2814 _sizing_eval(Evas_Object *obj)
2816 Widget_Data *wd = elm_widget_data_get(obj);
2817 Evas_Coord minw = -1, minh = -1;
2819 evas_object_size_hint_min_get(wd->content, &minw, &minh);
2820 edje_object_size_min_calc(wd->frm, &minw, &minh);
2821 evas_object_size_hint_min_set(obj, minw, minh);
2822 evas_object_size_hint_max_set(obj, -1, -1);
2826 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2832 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
2834 Widget_Data *wd = elm_widget_data_get(obj);
2835 Evas_Object *sub = event_info;
2836 if (sub == wd->content)
2838 evas_object_event_callback_del_full
2839 (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
2846 elm_win_inwin_add(Evas_Object *obj)
2852 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2853 win = elm_widget_data_get(obj);
2854 if (!win) return NULL;
2855 wd = ELM_NEW(Widget_Data);
2856 obj2 = elm_widget_add(win->evas);
2857 elm_widget_type_set(obj2, "inwin");
2858 ELM_SET_WIDTYPE(widtype2, "inwin");
2859 elm_widget_sub_object_add(obj, obj2);
2860 evas_object_size_hint_weight_set(obj2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2861 evas_object_size_hint_align_set(obj2, EVAS_HINT_FILL, EVAS_HINT_FILL);
2862 elm_win_resize_object_add(obj, obj2);
2864 elm_widget_data_set(obj2, wd);
2865 elm_widget_del_hook_set(obj2, _del_hook);
2866 elm_widget_theme_hook_set(obj2, _theme_hook);
2867 elm_widget_focus_next_hook_set(obj2, _elm_inwin_focus_next_hook);
2868 elm_widget_can_focus_set(obj2, EINA_TRUE);
2869 elm_widget_highlight_ignore_set(obj2, EINA_TRUE);
2871 wd->frm = edje_object_add(win->evas);
2872 _elm_theme_object_set(obj, wd->frm, "win", "inwin", "default");
2873 elm_widget_resize_object_set(obj2, wd->frm);
2875 evas_object_smart_callback_add(obj2, "sub-object-del", _sub_del, obj2);
2882 elm_win_inwin_activate(Evas_Object *obj)
2884 ELM_CHECK_WIDTYPE(obj, widtype2);
2885 Widget_Data *wd = elm_widget_data_get(obj);
2887 evas_object_raise(obj);
2888 evas_object_show(obj);
2889 edje_object_signal_emit(wd->frm, "elm,action,show", "elm");
2890 elm_object_focus_set(obj, EINA_TRUE);
2894 elm_win_inwin_content_set(Evas_Object *obj, Evas_Object *content)
2896 ELM_CHECK_WIDTYPE(obj, widtype2);
2897 Widget_Data *wd = elm_widget_data_get(obj);
2899 if (wd->content == content) return;
2900 if (wd->content) evas_object_del(wd->content);
2901 wd->content = content;
2904 elm_widget_sub_object_add(obj, content);
2905 evas_object_event_callback_add(content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
2906 _changed_size_hints, obj);
2907 edje_object_part_swallow(wd->frm, "elm.swallow.content", content);
2913 elm_win_inwin_content_get(const Evas_Object *obj)
2915 ELM_CHECK_WIDTYPE(obj, widtype2) NULL;
2916 Widget_Data *wd = elm_widget_data_get(obj);
2917 if (!wd) return NULL;
2922 elm_win_inwin_content_unset(Evas_Object *obj)
2924 ELM_CHECK_WIDTYPE(obj, widtype2) NULL;
2925 Widget_Data *wd = elm_widget_data_get(obj);
2926 if (!wd) return NULL;
2927 if (!wd->content) return NULL;
2928 Evas_Object *content = wd->content;
2929 elm_widget_sub_object_del(obj, wd->content);
2930 evas_object_event_callback_del_full(wd->content,
2931 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
2932 _changed_size_hints, obj);
2933 edje_object_part_unswallow(wd->frm, wd->content);
2939 elm_win_socket_listen(Evas_Object *obj, const char *svcname, int svcnum, Eina_Bool svcsys)
2944 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2945 win = elm_widget_data_get(obj);
2946 if (!win) return EINA_FALSE;
2947 if (!win->ee) return EINA_FALSE;
2949 if(!ecore_evas_extn_socket_listen(win->ee, svcname, svcnum, svcsys))
2955 /* windowing spcific calls - shall we do this differently? */
2957 static Ecore_X_Window
2958 _elm_ee_win_get(const Evas_Object *obj)
2961 #ifdef HAVE_ELEMENTARY_X
2962 Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
2963 if (ee) return (Ecore_X_Window)ecore_evas_window_get(ee);
2969 elm_win_xwindow_get(const Evas_Object *obj)
2975 type = elm_widget_type_get(obj);
2976 if ((!type) || (type != widtype)) return _elm_ee_win_get(obj);
2977 win = elm_widget_data_get(obj);
2979 #ifdef HAVE_ELEMENTARY_X
2980 if (win->xwin) return win->xwin;
2981 if (win->parent) return elm_win_xwindow_get(win->parent);