1 #include <Elementary.h>
7 * The window class of Elementary. Contains functions to manipulate
11 typedef struct _Elm_Win Elm_Win;
17 Evas_Object *parent, *win_obj;
19 #ifdef HAVE_ELEMENTARY_X
21 Ecore_Event_Handler *client_message_handler;
23 Ecore_Job *deferred_resize_job;
24 Ecore_Job *deferred_child_eval_job;
27 Elm_Win_Keyboard_Mode kbdmode;
28 Eina_Bool autodel : 1;
29 int *autodel_clear, rot;
39 Eina_Bool visible : 1;
40 Eina_Bool handled : 1;
44 Ecore_Job *reconf_job;
46 Eina_Bool enabled : 1;
47 Eina_Bool changed_theme : 1;
48 Eina_Bool top_animate : 1;
49 Eina_Bool geometry_changed : 1;
53 static const char *widtype = NULL;
54 static void _elm_win_obj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
55 static void _elm_win_obj_callback_parent_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
56 static void _elm_win_obj_intercept_show(void *data, Evas_Object *obj);
57 static void _elm_win_move(Ecore_Evas *ee);
58 static void _elm_win_resize(Ecore_Evas *ee);
59 static void _elm_win_delete_request(Ecore_Evas *ee);
60 static void _elm_win_resize_job(void *data);
61 #ifdef HAVE_ELEMENTARY_X
62 static void _elm_win_xwin_update(Elm_Win *win);
64 static void _elm_win_eval_subobjs(Evas_Object *obj);
65 static void _elm_win_subobj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
66 static void _elm_win_subobj_callback_changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
67 static void _elm_win_focus_highlight_init(Elm_Win *win);
68 static void _elm_win_focus_highlight_shutdown(Elm_Win *win);
69 static void _elm_win_focus_highlight_visible_set(Elm_Win *win, Eina_Bool visible);
70 static void _elm_win_focus_highlight_reconfigure_job_start(Elm_Win *win);
71 static void _elm_win_focus_highlight_reconfigure_job_stop(Elm_Win *win);
72 static void _elm_win_focus_highlight_anim_end(void *data, Evas_Object *obj, const char *emission, const char *source);
73 static void _elm_win_focus_highlight_reconfigure(Elm_Win *win);
75 Eina_List *_elm_win_list = NULL;
78 _elm_win_move(Ecore_Evas *ee)
80 Evas_Object *obj = ecore_evas_object_associate_get(ee);
85 win = elm_widget_data_get(obj);
87 ecore_evas_geometry_get(ee, &x, &y, NULL, NULL);
90 evas_object_smart_callback_call(win->win_obj, "moved", NULL);
94 _elm_win_resize(Ecore_Evas *ee)
96 Evas_Object *obj = ecore_evas_object_associate_get(ee);
100 win = elm_widget_data_get(obj);
102 if (win->deferred_resize_job) ecore_job_del(win->deferred_resize_job);
103 win->deferred_resize_job = ecore_job_add(_elm_win_resize_job, win);
107 _elm_win_focus_in(Ecore_Evas *ee)
109 Evas_Object *obj = ecore_evas_object_associate_get(ee);
113 win = elm_widget_data_get(obj);
115 /*NB: Why two different "focus signals" here ??? */
116 evas_object_smart_callback_call(win->win_obj, "focus-in", NULL); // FIXME: remove me
117 evas_object_smart_callback_call(win->win_obj, "focus,in", NULL);
118 win->focus_highlight.cur.visible = EINA_TRUE;
119 _elm_win_focus_highlight_reconfigure_job_start(win);
123 _elm_win_focus_out(Ecore_Evas *ee)
125 Evas_Object *obj = ecore_evas_object_associate_get(ee);
129 win = elm_widget_data_get(obj);
131 evas_object_smart_callback_call(win->win_obj, "focus-out", NULL); // FIXME: remove me
132 evas_object_smart_callback_call(win->win_obj, "focus,out", NULL);
133 win->focus_highlight.cur.visible = EINA_FALSE;
134 _elm_win_focus_highlight_reconfigure_job_start(win);
138 _elm_win_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
140 Elm_Win *wd = elm_widget_data_get(obj);
141 const Eina_List *items;
142 void *(*list_data_get) (const Eina_List *list);
150 if (!(items = elm_widget_focus_custom_chain_get(obj)))
156 list_data_get = eina_list_data_get;
158 elm_widget_focus_list_next_get(obj, items, list_data_get, dir, next);
164 *next = (Evas_Object *)obj;
169 _elm_win_on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
171 if (elm_widget_focus_get(obj))
172 evas_object_focus_set(obj, EINA_TRUE);
174 evas_object_focus_set(obj, EINA_FALSE);
178 _elm_win_event_cb(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
180 if (type == EVAS_CALLBACK_KEY_DOWN)
182 Evas_Event_Key_Down *ev = event_info;
183 if (!strcmp(ev->keyname, "Tab"))
185 if(evas_key_modifier_is_set(ev->modifiers, "Shift"))
186 elm_widget_focus_cycle(obj, ELM_FOCUS_PREVIOUS);
188 elm_widget_focus_cycle(obj, ELM_FOCUS_NEXT);
189 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
198 _deferred_ecore_evas_free(void *data)
200 ecore_evas_free(data);
204 _elm_win_obj_callback_show(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
206 elm_object_focus(obj);
210 _elm_win_obj_callback_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
217 evas_object_event_callback_del_full(win->parent, EVAS_CALLBACK_DEL,
218 _elm_win_obj_callback_parent_del, win);
221 if (win->autodel_clear) *(win->autodel_clear) = -1;
222 _elm_win_list = eina_list_remove(_elm_win_list, win->win_obj);
223 while (win->subobjs) elm_win_resize_object_del(obj, win->subobjs->data);
224 ecore_evas_callback_delete_request_set(win->ee, NULL);
225 ecore_evas_callback_resize_set(win->ee, NULL);
226 if (win->deferred_resize_job) ecore_job_del(win->deferred_resize_job);
227 if (win->deferred_child_eval_job) ecore_job_del(win->deferred_child_eval_job);
228 while (((child = evas_object_bottom_get(win->evas))) &&
231 evas_object_del(child);
233 while (((child = evas_object_top_get(win->evas))) &&
236 evas_object_del(child);
238 #ifdef HAVE_ELEMENTARY_X
239 if (win->client_message_handler)
240 ecore_event_handler_del(win->client_message_handler);
242 // FIXME: Why are we flushing edje on every window destroy ??
243 // edje_file_cache_flush();
244 // edje_collection_cache_flush();
245 // evas_image_cache_flush(win->evas);
246 // evas_font_cache_flush(win->evas);
247 // FIXME: we are in the del handler for the object and delete the canvas
248 // that lives under it from the handler... nasty. deferring doesn't help either
249 ecore_job_add(_deferred_ecore_evas_free, win->ee);
250 // ecore_evas_free(win->ee);
252 _elm_win_focus_highlight_shutdown(win);
253 eina_stringshare_del(win->focus_highlight.style);
257 if ((!_elm_win_list) &&
258 (elm_policy_get(ELM_POLICY_QUIT) == ELM_POLICY_QUIT_LAST_WINDOW_CLOSED))
260 edje_file_cache_flush();
261 edje_collection_cache_flush();
262 evas_image_cache_flush(e);
263 evas_font_cache_flush(e);
269 _elm_win_obj_callback_parent_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
272 if (obj == win->parent) win->parent = NULL;
276 _elm_win_obj_intercept_show(void *data __UNUSED__, Evas_Object *obj)
278 // this is called to make sure all smart containers have calculated their
279 // sizes BEFORE we show the window to make sure it initially appears at
280 // our desired size (ie min size is known first)
281 evas_smart_objects_calculate(evas_object_evas_get(obj));
282 evas_object_show(obj);
286 _elm_win_delete_request(Ecore_Evas *ee)
288 Evas_Object *obj = ecore_evas_object_associate_get(ee);
290 if (strcmp(elm_widget_type_get(obj), "win")) return;
292 win = elm_widget_data_get(obj);
294 int autodel = win->autodel;
295 win->autodel_clear = &autodel;
296 evas_object_smart_callback_call(win->win_obj, "delete-request", NULL); // FIXME: remove me
297 evas_object_smart_callback_call(win->win_obj, "delete,request", NULL);
298 // FIXME: if above callback deletes - then the below will be invalid
299 if (autodel) evas_object_del(win->win_obj);
300 else win->autodel_clear = NULL;
304 _elm_win_resize_job(void *data)
311 win->deferred_resize_job = NULL;
312 ecore_evas_geometry_get(win->ee, NULL, NULL, &w, &h);
313 evas_object_resize(win->win_obj, w, h);
314 EINA_LIST_FOREACH(win->subobjs, l, obj)
316 evas_object_move(obj, 0, 0);
317 evas_object_resize(obj, w, h);
321 #ifdef HAVE_ELEMENTARY_X
323 _elm_win_xwindow_get(Elm_Win *win)
327 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
328 if (ENGINE_COMPARE(ELM_SOFTWARE_X11))
330 if (win->ee) win->xwin = ecore_evas_software_x11_window_get(win->ee);
332 else if (ENGINE_COMPARE(ELM_SOFTWARE_X11) ||
333 ENGINE_COMPARE(ELM_SOFTWARE_FB) ||
334 ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE) ||
335 ENGINE_COMPARE(ELM_SOFTWARE_SDL) ||
336 ENGINE_COMPARE(ELM_SOFTWARE_16_SDL) ||
337 ENGINE_COMPARE(ELM_OPENGL_SDL))
340 else if (ENGINE_COMPARE(ELM_SOFTWARE_16_X11))
342 if (win->ee) win->xwin = ecore_evas_software_x11_16_window_get(win->ee);
344 else if (ENGINE_COMPARE(ELM_SOFTWARE_8_X11))
346 if (win->ee) win->xwin = ecore_evas_software_x11_8_window_get(win->ee);
348 else if (ENGINE_COMPARE(ELM_XRENDER_X11))
350 if (win->ee) win->xwin = ecore_evas_xrender_x11_window_get(win->ee);
352 else if (ENGINE_COMPARE(ELM_OPENGL_X11))
354 if (win->ee) win->xwin = ecore_evas_gl_x11_window_get(win->ee);
356 else if (ENGINE_COMPARE(ELM_SOFTWARE_WIN32))
358 if (win->ee) win->xwin = (long)ecore_evas_win32_window_get(win->ee);
360 #undef ENGINE_COMPARE
364 #ifdef HAVE_ELEMENTARY_X
366 _elm_win_xwin_update(Elm_Win *win)
368 _elm_win_xwindow_get(win);
373 win2 = elm_widget_data_get(win->parent);
377 ecore_x_icccm_transient_for_set(win->xwin, win2->xwin);
381 if (!win->xwin) return; /* nothing more to do */
386 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_NORMAL);
388 case ELM_WIN_DIALOG_BASIC:
389 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DIALOG);
391 case ELM_WIN_DESKTOP:
392 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DESKTOP);
395 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DOCK);
397 case ELM_WIN_TOOLBAR:
398 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_TOOLBAR);
401 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_MENU);
403 case ELM_WIN_UTILITY:
404 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_UTILITY);
407 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_SPLASH);
412 ecore_x_e_virtual_keyboard_state_set
413 (win->xwin, (Ecore_X_Virtual_Keyboard_State)win->kbdmode);
418 _elm_win_eval_subobjs(Evas_Object *obj)
421 const Evas_Object *child;
423 Elm_Win *win = elm_widget_data_get(obj);
424 Evas_Coord w, h, minw = -1, minh = -1, maxw = -1, maxh = -1;
428 EINA_LIST_FOREACH(win->subobjs, l, child)
430 evas_object_size_hint_weight_get(child, &wx, &wy);
431 if (wx == 0.0) xx = 0;
432 if (wy == 0.0) xy = 0;
434 evas_object_size_hint_min_get(child, &w, &h);
437 if (w > minw) minw = w;
438 if (h > minh) minh = h;
440 evas_object_size_hint_max_get(child, &w, &h);
443 if (maxw == -1) maxw = w;
444 else if ((w > 0) && (w < maxw)) maxw = w;
445 if (maxh == -1) maxh = h;
446 else if ((h > 0) && (h < maxh)) maxh = h;
448 if (!xx) maxw = minw;
450 if (!xy) maxh = minh;
452 evas_object_size_hint_min_set(obj, minw, minh);
453 evas_object_size_hint_max_set(obj, maxw, maxh);
454 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
455 if (w < minw) w = minw;
456 if (h < minh) h = minh;
457 if ((maxw >= 0) && (w > maxw)) w = maxw;
458 if ((maxh >= 0) && (h > maxh)) h = maxh;
459 evas_object_resize(obj, w, h);
463 _elm_win_subobj_callback_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
465 Elm_Win *win = elm_widget_data_get(data);
466 win->subobjs = eina_list_remove(win->subobjs, obj);
467 _elm_win_eval_subobjs(win->win_obj);
471 _elm_win_subobj_callback_changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
473 _elm_win_eval_subobjs(data);
477 _elm_win_shutdown(void)
479 while (_elm_win_list)
480 evas_object_del(_elm_win_list->data);
484 _elm_win_rescale(Elm_Theme *th, Eina_Bool use_theme)
491 EINA_LIST_FOREACH(_elm_win_list, l, obj)
492 elm_widget_theme(obj);
496 EINA_LIST_FOREACH(_elm_win_list, l, obj)
497 elm_widget_theme_specific(obj, th, EINA_FALSE);
501 #ifdef HAVE_ELEMENTARY_X
503 _elm_win_client_message(void *data, int type __UNUSED__, void *event)
506 Ecore_X_Event_Client_Message *e = event;
508 if (e->format != 32) return ECORE_CALLBACK_PASS_ON;
509 if (e->message_type == ECORE_X_ATOM_E_COMP_FLUSH)
511 if ((unsigned)e->data.l[0] == win->xwin)
513 Evas *evas = evas_object_evas_get(win->win_obj);
516 edje_file_cache_flush();
517 edje_collection_cache_flush();
518 evas_image_cache_flush(evas);
519 evas_font_cache_flush(evas);
523 else if (e->message_type == ECORE_X_ATOM_E_COMP_DUMP)
525 if ((unsigned)e->data.l[0] == win->xwin)
527 Evas *evas = evas_object_evas_get(win->win_obj);
530 edje_file_cache_flush();
531 edje_collection_cache_flush();
532 evas_image_cache_flush(evas);
533 evas_font_cache_flush(evas);
534 evas_render_dump(evas);
538 return ECORE_CALLBACK_PASS_ON;
543 _elm_win_focus_target_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
547 win->focus_highlight.geometry_changed = EINA_TRUE;
548 _elm_win_focus_highlight_reconfigure_job_start(win);
552 _elm_win_focus_target_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
556 win->focus_highlight.geometry_changed = EINA_TRUE;
557 _elm_win_focus_highlight_reconfigure_job_start(win);
561 _elm_win_focus_target_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
565 win->focus_highlight.cur.target = NULL;
567 _elm_win_focus_highlight_reconfigure_job_start(win);
571 _elm_win_focus_target_callbacks_add(Elm_Win *win)
573 Evas_Object *obj = win->focus_highlight.cur.target;
575 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE,
576 _elm_win_focus_target_move, win);
577 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE,
578 _elm_win_focus_target_resize, win);
579 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
580 _elm_win_focus_target_del, win);
584 _elm_win_focus_target_callbacks_del(Elm_Win *win)
586 Evas_Object *obj = win->focus_highlight.cur.target;
588 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_MOVE,
589 _elm_win_focus_target_move, win);
590 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_RESIZE,
591 _elm_win_focus_target_resize, win);
592 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL,
593 _elm_win_focus_target_del, win);
597 _elm_win_focus_target_get(Evas_Object *obj)
599 Evas_Object *o = obj;
603 if (elm_widget_is(o))
605 if (!elm_widget_highlight_ignore_get(o))
607 o = elm_widget_parent_get(o);
609 o = evas_object_smart_parent_get(o);
613 o = elm_widget_parent_widget_get(o);
615 o = evas_object_smart_parent_get(o);
624 _elm_win_object_focus_in(void *data, Evas *e __UNUSED__, void *event_info)
626 Evas_Object *obj = event_info, *target;
629 if (win->focus_highlight.cur.target == obj)
632 target = _elm_win_focus_target_get(obj);
633 win->focus_highlight.cur.target = target;
634 if (elm_widget_highlight_in_theme_get(target))
635 win->focus_highlight.cur.handled = EINA_TRUE;
637 _elm_win_focus_target_callbacks_add(win);
639 _elm_win_focus_highlight_reconfigure_job_start(win);
643 _elm_win_object_focus_out(void *data, Evas *e __UNUSED__, void *event_info __UNUSED__)
647 if (!win->focus_highlight.cur.target)
650 if (!win->focus_highlight.cur.handled)
651 _elm_win_focus_target_callbacks_del(win);
652 win->focus_highlight.cur.target = NULL;
653 win->focus_highlight.cur.handled = EINA_FALSE;
655 _elm_win_focus_highlight_reconfigure_job_start(win);
659 _elm_win_focus_highlight_hide(void *data __UNUSED__, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
661 evas_object_hide(obj);
665 _elm_win_focus_highlight_init(Elm_Win *win)
667 evas_event_callback_add(win->evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
668 _elm_win_object_focus_in, win);
669 evas_event_callback_add(win->evas,
670 EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
671 _elm_win_object_focus_out, win);
673 win->focus_highlight.cur.target = evas_focus_get(win->evas);
675 win->focus_highlight.top = edje_object_add(win->evas);
676 win->focus_highlight.changed_theme = EINA_TRUE;
677 edje_object_signal_callback_add(win->focus_highlight.top,
678 "elm,action,focus,hide,end", "",
679 _elm_win_focus_highlight_hide, NULL);
680 edje_object_signal_callback_add(win->focus_highlight.top,
681 "elm,action,focus,anim,end", "",
682 _elm_win_focus_highlight_anim_end, win);
683 _elm_win_focus_highlight_reconfigure_job_start(win);
687 _elm_win_focus_highlight_shutdown(Elm_Win *win)
689 _elm_win_focus_highlight_reconfigure_job_stop(win);
690 if (win->focus_highlight.cur.target)
692 _elm_win_focus_target_callbacks_del(win);
693 win->focus_highlight.cur.target = NULL;
695 if (win->focus_highlight.top)
697 evas_object_del(win->focus_highlight.top);
698 win->focus_highlight.top = NULL;
701 evas_event_callback_del_full(win->evas,
702 EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
703 _elm_win_object_focus_in, win);
704 evas_event_callback_del_full(win->evas,
705 EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
706 _elm_win_object_focus_out, win);
710 _elm_win_focus_highlight_visible_set(Elm_Win *win, Eina_Bool visible)
714 top = win->focus_highlight.top;
719 evas_object_show(top);
720 edje_object_signal_emit(top, "elm,action,focus,show", "elm");
726 edje_object_signal_emit(top, "elm,action,focus,hide", "elm");
731 _elm_win_focus_highlight_reconfigure_job(void *data)
733 _elm_win_focus_highlight_reconfigure((Elm_Win *)data);
737 _elm_win_focus_highlight_reconfigure_job_start(Elm_Win *win)
739 if (win->focus_highlight.reconf_job)
740 ecore_job_del(win->focus_highlight.reconf_job);
741 win->focus_highlight.reconf_job = ecore_job_add(
742 _elm_win_focus_highlight_reconfigure_job, win);
746 _elm_win_focus_highlight_reconfigure_job_stop(Elm_Win *win)
748 if (win->focus_highlight.reconf_job)
749 ecore_job_del(win->focus_highlight.reconf_job);
750 win->focus_highlight.reconf_job = NULL;
754 _elm_win_focus_highlight_simple_setup(Elm_Win *win, Evas_Object *obj)
756 Evas_Object *clip, *target = win->focus_highlight.cur.target;
757 Evas_Coord x, y, w, h;
759 clip = evas_object_clip_get(target);
760 evas_object_geometry_get(target, &x, &y, &w, &h);
762 evas_object_move(obj, x, y);
763 evas_object_resize(obj, w, h);
764 evas_object_clip_set(obj, clip);
768 _elm_win_focus_highlight_anim_setup(Elm_Win *win, Evas_Object *obj)
770 Evas_Coord tx, ty, tw, th;
771 Evas_Coord w, h, px, py, pw, ph;
772 Edje_Message_Int_Set *m;
773 Evas_Object *previous = win->focus_highlight.prev.target;
774 Evas_Object *target = win->focus_highlight.cur.target;
776 evas_object_geometry_get(win->win_obj, NULL, NULL, &w, &h);
777 evas_object_geometry_get(target, &tx, &ty, &tw, &th);
778 evas_object_geometry_get(previous, &px, &py, &pw, &ph);
779 evas_object_move(obj, 0, 0);
780 evas_object_resize(obj, tw, th);
781 evas_object_clip_unset(obj);
783 m = alloca(sizeof(*m) + (sizeof(int) * 8));
793 edje_object_message_send(obj, EDJE_MESSAGE_INT_SET, 1, m);
797 _elm_win_focus_highlight_anim_end(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
800 _elm_win_focus_highlight_simple_setup(win, obj);
804 _elm_win_focus_highlight_reconfigure(Elm_Win *win)
806 Evas_Object *target = win->focus_highlight.cur.target;
807 Evas_Object *previous = win->focus_highlight.prev.target;
808 Evas_Object *top = win->focus_highlight.top;
809 Eina_Bool visible_changed;
810 Eina_Bool common_visible;
811 const char *sig = NULL;
813 _elm_win_focus_highlight_reconfigure_job_stop(win);
815 visible_changed = (win->focus_highlight.cur.visible !=
816 win->focus_highlight.prev.visible);
818 if ((target == previous) && (!visible_changed) &&
819 (!win->focus_highlight.geometry_changed))
822 if ((previous) && (win->focus_highlight.prev.handled))
823 elm_widget_signal_emit(previous, "elm,action,focus_highlight,hide", "elm");
826 common_visible = EINA_FALSE;
827 else if (win->focus_highlight.cur.handled)
829 common_visible = EINA_FALSE;
830 if (win->focus_highlight.cur.visible)
831 sig = "elm,action,focus_highlight,show";
833 sig = "elm,action,focus_highlight,hide";
836 common_visible = win->focus_highlight.cur.visible;
838 _elm_win_focus_highlight_visible_set(win, common_visible);
840 elm_widget_signal_emit(target, sig, "elm");
842 if ((!target) || (!common_visible) || (win->focus_highlight.cur.handled))
845 if (win->focus_highlight.changed_theme)
848 if (win->focus_highlight.style)
849 str = win->focus_highlight.style;
852 _elm_theme_object_set(win->win_obj, top, "focus_highlight", "top",
854 win->focus_highlight.changed_theme = EINA_FALSE;
856 if (_elm_config->focus_highlight_animate)
858 str = edje_object_data_get(win->focus_highlight.top, "animate");
859 win->focus_highlight.top_animate = ((str) && (!strcmp(str, "on")));
863 if ((win->focus_highlight.top_animate) && (previous) &&
864 (!win->focus_highlight.prev.handled))
865 _elm_win_focus_highlight_anim_setup(win, top);
867 _elm_win_focus_highlight_simple_setup(win, top);
868 evas_object_raise(top);
871 win->focus_highlight.geometry_changed = EINA_FALSE;
872 win->focus_highlight.prev = win->focus_highlight.cur;
877 _debug_key_down(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
879 Evas_Event_Key_Down *ev = event_info;
881 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
885 if ((strcmp(ev->keyname, "F12")) ||
886 (!evas_key_modifier_is_set(ev->modifiers, "Control")))
889 printf("Tree graph generated.\n");
890 elm_object_tree_dot_dump(obj, "./dump.dot");
895 * Adds a window object. If this is the first window created, pass NULL as
898 * @param parent Parent object to add the window to, or NULL
899 * @param name The name of the window
900 * @param type The window type, one of the following:
902 * ELM_WIN_DIALOG_BASIC
910 * @return The created object, or NULL on failure
915 elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type)
919 const char *fontpath;
921 win = ELM_NEW(Elm_Win);
923 #define FALLBACK_TRY(engine) \
926 CRITICAL(engine " engine creation failed. Trying software X11."); \
927 win->ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1); \
930 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
931 if (ENGINE_COMPARE(ELM_SOFTWARE_X11))
933 win->ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
934 #ifdef HAVE_ELEMENTARY_X
935 win->client_message_handler = ecore_event_handler_add
936 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
939 else if (ENGINE_COMPARE(ELM_SOFTWARE_FB))
941 win->ee = ecore_evas_fb_new(NULL, 0, 1, 1);
942 FALLBACK_TRY("Sofware FB");
944 else if (ENGINE_COMPARE(ELM_SOFTWARE_DIRECTFB))
946 win->ee = ecore_evas_directfb_new(NULL, 1, 0, 0, 1, 1);
947 FALLBACK_TRY("Sofware DirectFB");
949 else if (ENGINE_COMPARE(ELM_SOFTWARE_16_X11))
951 win->ee = ecore_evas_software_x11_16_new(NULL, 0, 0, 0, 1, 1);
952 FALLBACK_TRY("Sofware-16");
953 #ifdef HAVE_ELEMENTARY_X
954 win->client_message_handler = ecore_event_handler_add
955 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
958 else if (ENGINE_COMPARE(ELM_SOFTWARE_8_X11))
960 win->ee = ecore_evas_software_x11_8_new(NULL, 0, 0, 0, 1, 1);
961 FALLBACK_TRY("Sofware-8");
962 #ifdef HAVE_ELEMENTARY_X
963 win->client_message_handler = ecore_event_handler_add
964 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
967 else if (ENGINE_COMPARE(ELM_XRENDER_X11))
969 win->ee = ecore_evas_xrender_x11_new(NULL, 0, 0, 0, 1, 1);
970 FALLBACK_TRY("XRender");
971 #ifdef HAVE_ELEMENTARY_X
972 win->client_message_handler = ecore_event_handler_add
973 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
976 else if (ENGINE_COMPARE(ELM_OPENGL_X11))
978 win->ee = ecore_evas_gl_x11_new(NULL, 0, 0, 0, 1, 1);
979 FALLBACK_TRY("OpenGL");
980 #ifdef HAVE_ELEMENTARY_X
981 win->client_message_handler = ecore_event_handler_add
982 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
985 else if (ENGINE_COMPARE(ELM_SOFTWARE_WIN32))
987 win->ee = ecore_evas_software_gdi_new(NULL, 0, 0, 1, 1);
988 FALLBACK_TRY("Sofware Win32");
990 else if (ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE))
992 win->ee = ecore_evas_software_wince_gdi_new(NULL, 0, 0, 1, 1);
993 FALLBACK_TRY("Sofware-16-WinCE");
995 else if (ENGINE_COMPARE(ELM_SOFTWARE_SDL))
997 win->ee = ecore_evas_sdl_new(NULL, 0, 0, 0, 0, 0, 1);
998 FALLBACK_TRY("Sofware SDL");
1000 else if (ENGINE_COMPARE(ELM_SOFTWARE_16_SDL))
1002 win->ee = ecore_evas_sdl16_new(NULL, 0, 0, 0, 0, 0, 1);
1003 FALLBACK_TRY("Sofware-16-SDL");
1005 else if (ENGINE_COMPARE(ELM_OPENGL_SDL))
1007 win->ee = ecore_evas_gl_sdl_new(NULL, 1, 1, 0, 0);
1008 FALLBACK_TRY("OpenGL SDL");
1014 ERR("Cannot create window.");
1018 #ifdef HAVE_ELEMENTARY_X
1019 _elm_win_xwindow_get(win);
1021 if ((_elm_config->bgpixmap) && (!_elm_config->compositing))
1022 ecore_evas_avoid_damage_set(win->ee, ECORE_EVAS_AVOID_DAMAGE_EXPOSE);
1023 // bg pixmap done by x - has other issues like can be redrawn by x before it
1024 // is filled/ready by app
1025 // ecore_evas_avoid_damage_set(win->ee, ECORE_EVAS_AVOID_DAMAGE_BUILT_IN);
1028 win->parent = parent;
1030 evas_object_event_callback_add(win->parent, EVAS_CALLBACK_DEL,
1031 _elm_win_obj_callback_parent_del, win);
1033 win->evas = ecore_evas_get(win->ee);
1034 win->win_obj = elm_widget_add(win->evas);
1035 elm_widget_type_set(win->win_obj, "win");
1036 ELM_SET_WIDTYPE(widtype, "win");
1037 elm_widget_data_set(win->win_obj, win);
1038 elm_widget_event_hook_set(win->win_obj, _elm_win_event_cb);
1039 elm_widget_on_focus_hook_set(win->win_obj, _elm_win_on_focus_hook, NULL);
1040 elm_widget_can_focus_set(win->win_obj, EINA_TRUE);
1041 elm_widget_highlight_ignore_set(win->win_obj, EINA_TRUE);
1042 elm_widget_focus_next_hook_set(win->win_obj, _elm_win_focus_next_hook);
1043 evas_object_color_set(win->win_obj, 0, 0, 0, 0);
1044 evas_object_move(win->win_obj, 0, 0);
1045 evas_object_resize(win->win_obj, 1, 1);
1046 evas_object_layer_set(win->win_obj, 50);
1047 evas_object_pass_events_set(win->win_obj, EINA_TRUE);
1049 evas_object_intercept_show_callback_add(win->win_obj,
1050 _elm_win_obj_intercept_show, win);
1051 ecore_evas_object_associate(win->ee, win->win_obj,
1052 ECORE_EVAS_OBJECT_ASSOCIATE_BASE |
1053 ECORE_EVAS_OBJECT_ASSOCIATE_STACK |
1054 ECORE_EVAS_OBJECT_ASSOCIATE_LAYER);
1055 evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_SHOW,
1056 _elm_win_obj_callback_show, win);
1057 evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_DEL,
1058 _elm_win_obj_callback_del, win);
1060 ecore_evas_name_class_set(win->ee, name, _elm_appname);
1061 ecore_evas_callback_delete_request_set(win->ee, _elm_win_delete_request);
1062 ecore_evas_callback_resize_set(win->ee, _elm_win_resize);
1063 ecore_evas_callback_focus_in_set(win->ee, _elm_win_focus_in);
1064 ecore_evas_callback_focus_out_set(win->ee, _elm_win_focus_out);
1065 ecore_evas_callback_move_set(win->ee, _elm_win_move);
1066 evas_image_cache_set(win->evas, (_elm_config->image_cache * 1024));
1067 evas_font_cache_set(win->evas, (_elm_config->font_cache * 1024));
1068 EINA_LIST_FOREACH(_elm_config->font_dirs, l, fontpath)
1069 evas_font_path_append(win->evas, fontpath);
1070 if (!_elm_config->font_hinting)
1071 evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_NONE);
1072 else if (_elm_config->font_hinting == 1)
1073 evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_AUTO);
1074 else if (_elm_config->font_hinting == 2)
1075 evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_BYTECODE);
1077 #ifdef HAVE_ELEMENTARY_X
1078 _elm_win_xwin_update(win);
1081 _elm_win_list = eina_list_append(_elm_win_list, win->win_obj);
1083 if (ENGINE_COMPARE(ELM_SOFTWARE_FB))
1085 ecore_evas_fullscreen_set(win->ee, 1);
1087 #undef ENGINE_COMPARE
1089 if (_elm_config->focus_highlight_enable)
1090 elm_win_focus_highlight_enabled_set(win->win_obj, EINA_TRUE);
1093 Evas_Modifier_Mask mask = evas_key_modifier_mask_get(win->evas, "Control");
1094 evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_KEY_DOWN,
1095 _debug_key_down, win);
1096 Eina_Bool ret = evas_object_key_grab(win->win_obj, "F12", mask, 0, EINA_TRUE);
1097 printf("Key F12 exclusive for dot tree generation. (%d)\n", ret);
1099 return win->win_obj;
1103 * Add @p subobj as a resize object of window @p obj.
1105 * @param obj The window object
1106 * @param subobj The resize object to add
1111 elm_win_resize_object_add(Evas_Object *obj, Evas_Object *subobj)
1115 ELM_CHECK_WIDTYPE(obj, widtype);
1116 win = elm_widget_data_get(obj);
1118 win->subobjs = eina_list_append(win->subobjs, subobj);
1119 elm_widget_sub_object_add(obj, subobj);
1120 evas_object_event_callback_add(subobj, EVAS_CALLBACK_DEL,
1121 _elm_win_subobj_callback_del, obj);
1122 evas_object_event_callback_add(subobj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1123 _elm_win_subobj_callback_changed_size_hints,
1125 ecore_evas_geometry_get(win->ee, NULL, NULL, &w, &h);
1126 evas_object_move(subobj, 0, 0);
1127 evas_object_resize(subobj, w, h);
1128 _elm_win_eval_subobjs(obj);
1132 * Delete @p subobj as a resize object of window @p obj.
1134 * @param obj The window object
1135 * @param subobj The resize object to add
1140 elm_win_resize_object_del(Evas_Object *obj, Evas_Object *subobj)
1143 ELM_CHECK_WIDTYPE(obj, widtype);
1144 win = elm_widget_data_get(obj);
1146 evas_object_event_callback_del_full(subobj,
1147 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1148 _elm_win_subobj_callback_changed_size_hints,
1150 evas_object_event_callback_del_full(subobj, EVAS_CALLBACK_DEL,
1151 _elm_win_subobj_callback_del, obj);
1152 win->subobjs = eina_list_remove(win->subobjs, subobj);
1153 elm_widget_sub_object_del(obj, subobj);
1154 _elm_win_eval_subobjs(obj);
1158 * Set the title of the window
1160 * @param obj The window object
1161 * @param title The title to set
1166 elm_win_title_set(Evas_Object *obj, const char *title)
1169 ELM_CHECK_WIDTYPE(obj, widtype);
1170 win = elm_widget_data_get(obj);
1172 ecore_evas_title_set(win->ee, title);
1176 * Get the title of the window
1178 * @param obj The window object
1184 elm_win_title_get(const Evas_Object *obj)
1187 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1188 win = elm_widget_data_get(obj);
1189 if (!win) return NULL;
1190 return ecore_evas_title_get(win->ee);
1194 * Set the window's autodel state.
1196 * @param obj The window object
1197 * @param autodel If true, the window will automatically delete itself when closed
1202 elm_win_autodel_set(Evas_Object *obj, Eina_Bool autodel)
1205 ELM_CHECK_WIDTYPE(obj, widtype);
1206 win = elm_widget_data_get(obj);
1208 win->autodel = autodel;
1212 * Get the window's autodel state.
1214 * @param obj The window object
1215 * @return If the window will automatically delete itself when closed
1220 elm_win_autodel_get(const Evas_Object *obj)
1223 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1224 win = elm_widget_data_get(obj);
1225 if (!win) return EINA_FALSE;
1226 return win->autodel;
1230 * Activate a window object.
1232 * @param obj The window object
1237 elm_win_activate(Evas_Object *obj)
1240 ELM_CHECK_WIDTYPE(obj, widtype);
1241 win = elm_widget_data_get(obj);
1243 ecore_evas_activate(win->ee);
1247 * Lower a window object.
1249 * @param obj The window object
1254 elm_win_lower(Evas_Object *obj)
1257 ELM_CHECK_WIDTYPE(obj, widtype);
1258 win = elm_widget_data_get(obj);
1260 ecore_evas_lower(win->ee);
1264 * Raise a window object.
1266 * @param obj The window object
1271 elm_win_raise(Evas_Object *obj)
1274 ELM_CHECK_WIDTYPE(obj, widtype);
1275 win = elm_widget_data_get(obj);
1277 ecore_evas_raise(win->ee);
1281 * Set the borderless state of a window.
1283 * @param obj The window object
1284 * @param borderless If true, the window is borderless
1289 elm_win_borderless_set(Evas_Object *obj, Eina_Bool borderless)
1292 ELM_CHECK_WIDTYPE(obj, widtype);
1293 win = elm_widget_data_get(obj);
1295 ecore_evas_borderless_set(win->ee, borderless);
1296 #ifdef HAVE_ELEMENTARY_X
1297 _elm_win_xwin_update(win);
1302 * Get the borderless state of a window.
1304 * @param obj The window object
1305 * @return If true, the window is borderless
1310 elm_win_borderless_get(const Evas_Object *obj)
1313 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1314 win = elm_widget_data_get(obj);
1315 if (!win) return EINA_FALSE;
1316 return ecore_evas_borderless_get(win->ee);
1320 * Set the shaped state of a window.
1322 * @param obj The window object
1323 * @param shaped If true, the window is shaped
1328 elm_win_shaped_set(Evas_Object *obj, Eina_Bool shaped)
1331 ELM_CHECK_WIDTYPE(obj, widtype);
1332 win = elm_widget_data_get(obj);
1334 ecore_evas_shaped_set(win->ee, shaped);
1335 #ifdef HAVE_ELEMENTARY_X
1336 _elm_win_xwin_update(win);
1341 * Get the shaped state of a window.
1343 * @param obj The window object
1344 * @return If true, the window is shaped
1349 elm_win_shaped_get(const Evas_Object *obj)
1352 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1353 win = elm_widget_data_get(obj);
1354 if (!win) return EINA_FALSE;
1355 return ecore_evas_shaped_get(win->ee);
1359 * Set the alpha channel state of a window.
1361 * @param obj The window object
1362 * @param alpha If true, the window has an alpha channel
1367 elm_win_alpha_set(Evas_Object *obj, Eina_Bool alpha)
1370 ELM_CHECK_WIDTYPE(obj, widtype);
1371 win = elm_widget_data_get(obj);
1373 #ifdef HAVE_ELEMENTARY_X
1378 if (!_elm_config->compositing)
1379 elm_win_shaped_set(obj, alpha);
1381 ecore_evas_alpha_set(win->ee, alpha);
1384 ecore_evas_alpha_set(win->ee, alpha);
1385 _elm_win_xwin_update(win);
1389 ecore_evas_alpha_set(win->ee, alpha);
1393 * Get the alpha channel state of a window.
1395 * @param obj The window object
1396 * @return If true, the window has an alpha channel
1401 elm_win_alpha_get(const Evas_Object *obj)
1404 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1405 win = elm_widget_data_get(obj);
1406 if (!win) return EINA_FALSE;
1407 return ecore_evas_alpha_get(win->ee);
1411 * Set the transparency state of a window.
1413 * @param obj The window object
1414 * @param transparent If true, the window is transparent
1419 elm_win_transparent_set(Evas_Object *obj, Eina_Bool transparent)
1422 ELM_CHECK_WIDTYPE(obj, widtype);
1423 win = elm_widget_data_get(obj);
1426 #ifdef HAVE_ELEMENTARY_X
1429 ecore_evas_transparent_set(win->ee, transparent);
1430 _elm_win_xwin_update(win);
1434 ecore_evas_transparent_set(win->ee, transparent);
1438 * Get the transparency state of a window.
1440 * @param obj The window object
1441 * @return If true, the window is transparent
1446 elm_win_transparent_get(const Evas_Object *obj)
1449 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1450 win = elm_widget_data_get(obj);
1451 if (!win) return EINA_FALSE;
1453 return ecore_evas_transparent_get(win->ee);
1457 * Set the override state of a window.
1459 * @param obj The window object
1460 * @param override If true, the window is overridden
1465 elm_win_override_set(Evas_Object *obj, Eina_Bool override)
1468 ELM_CHECK_WIDTYPE(obj, widtype);
1469 win = elm_widget_data_get(obj);
1471 ecore_evas_override_set(win->ee, override);
1472 #ifdef HAVE_ELEMENTARY_X
1473 _elm_win_xwin_update(win);
1478 * Get the override state of a window.
1480 * @param obj The window object
1481 * @return If true, the window is overridden
1486 elm_win_override_get(const Evas_Object *obj)
1489 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1490 win = elm_widget_data_get(obj);
1491 if (!win) return EINA_FALSE;
1492 return ecore_evas_override_get(win->ee);
1496 * Set the fullscreen state of a window.
1498 * @param obj The window object
1499 * @param fullscreen If true, the window is fullscreen
1504 elm_win_fullscreen_set(Evas_Object *obj, Eina_Bool fullscreen)
1507 ELM_CHECK_WIDTYPE(obj, widtype);
1508 win = elm_widget_data_get(obj);
1511 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
1512 if (ENGINE_COMPARE(ELM_SOFTWARE_FB) ||
1513 ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE))
1515 // these engines... can ONLY be fullscreen
1520 ecore_evas_fullscreen_set(win->ee, fullscreen);
1521 #ifdef HAVE_ELEMENTARY_X
1522 _elm_win_xwin_update(win);
1525 #undef ENGINE_COMPARE
1529 * Get the fullscreen state of a window.
1531 * @param obj The window object
1532 * @return If true, the window is fullscreen
1537 elm_win_fullscreen_get(const Evas_Object *obj)
1540 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1541 win = elm_widget_data_get(obj);
1542 if (!win) return EINA_FALSE;
1544 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
1545 if (ENGINE_COMPARE(ELM_SOFTWARE_FB) ||
1546 ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE))
1548 // these engines... can ONLY be fullscreen
1553 return ecore_evas_fullscreen_get(win->ee);
1555 #undef ENGINE_COMPARE
1559 * Set the maximized state of a window.
1561 * @param obj The window object
1562 * @param maximized If true, the window is maximized
1567 elm_win_maximized_set(Evas_Object *obj, Eina_Bool maximized)
1570 ELM_CHECK_WIDTYPE(obj, widtype);
1571 win = elm_widget_data_get(obj);
1573 ecore_evas_maximized_set(win->ee, maximized);
1574 #ifdef HAVE_ELEMENTARY_X
1575 _elm_win_xwin_update(win);
1580 * Get the maximized state of a window.
1582 * @param obj The window object
1583 * @return If true, the window is maximized
1588 elm_win_maximized_get(const Evas_Object *obj)
1591 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1592 win = elm_widget_data_get(obj);
1593 if (!win) return EINA_FALSE;
1594 return ecore_evas_maximized_get(win->ee);
1598 * Set the iconified state of a window.
1600 * @param obj The window object
1601 * @param iconified If true, the window is iconified
1606 elm_win_iconified_set(Evas_Object *obj, Eina_Bool iconified)
1609 ELM_CHECK_WIDTYPE(obj, widtype);
1610 win = elm_widget_data_get(obj);
1612 ecore_evas_iconified_set(win->ee, iconified);
1613 #ifdef HAVE_ELEMENTARY_X
1614 _elm_win_xwin_update(win);
1619 * Get the iconified state of a window.
1621 * @param obj The window object
1622 * @return If true, the window is iconified
1627 elm_win_iconified_get(const Evas_Object *obj)
1630 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1631 win = elm_widget_data_get(obj);
1632 if (!win) return EINA_FALSE;
1633 return ecore_evas_iconified_get(win->ee);
1637 * Set the layer of the window.
1639 * @param obj The window object
1640 * @param layer The layer of the window
1645 elm_win_layer_set(Evas_Object *obj, int layer)
1648 ELM_CHECK_WIDTYPE(obj, widtype);
1649 win = elm_widget_data_get(obj);
1651 ecore_evas_layer_set(win->ee, layer);
1652 #ifdef HAVE_ELEMENTARY_X
1653 _elm_win_xwin_update(win);
1658 * Get the layer of the window.
1660 * @param obj The window object
1661 * @return The layer of the window
1666 elm_win_layer_get(const Evas_Object *obj)
1669 ELM_CHECK_WIDTYPE(obj, widtype) -1;
1670 win = elm_widget_data_get(obj);
1671 if (!win) return -1;
1672 return ecore_evas_layer_get(win->ee);
1676 * Set the rotation of the window.
1678 * @param obj The window object
1679 * @param rotation The rotation of the window, in degrees (0-360)
1684 elm_win_rotation_set(Evas_Object *obj, int rotation)
1687 ELM_CHECK_WIDTYPE(obj, widtype);
1688 win = elm_widget_data_get(obj);
1690 if (win->rot == rotation) return;
1691 win->rot = rotation;
1692 ecore_evas_rotation_set(win->ee, rotation);
1693 evas_object_size_hint_min_set(obj, -1, -1);
1694 evas_object_size_hint_max_set(obj, -1, -1);
1695 _elm_win_eval_subobjs(obj);
1696 #ifdef HAVE_ELEMENTARY_X
1697 _elm_win_xwin_update(win);
1702 * Rotates the window and resizes it
1704 * @param obj The window object
1705 * @param layer The rotation of the window in degrees (0-360)
1710 elm_win_rotation_with_resize_set(Evas_Object *obj, int rotation)
1713 ELM_CHECK_WIDTYPE(obj, widtype);
1714 win = elm_widget_data_get(obj);
1716 if (win->rot == rotation) return;
1717 win->rot = rotation;
1718 ecore_evas_rotation_with_resize_set(win->ee, rotation);
1719 evas_object_size_hint_min_set(obj, -1, -1);
1720 evas_object_size_hint_max_set(obj, -1, -1);
1721 _elm_win_eval_subobjs(obj);
1722 #ifdef HAVE_ELEMENTARY_X
1723 _elm_win_xwin_update(win);
1728 * Get the rotation of the window.
1730 * @param obj The window object
1731 * @return The rotation of the window in degrees (0-360)
1736 elm_win_rotation_get(const Evas_Object *obj)
1739 ELM_CHECK_WIDTYPE(obj, widtype) -1;
1740 win = elm_widget_data_get(obj);
1741 if (!win) return -1;
1746 * Set the sticky state of the window.
1748 * @param obj The window object
1749 * @param sticky If true, the window's sticky state is enabled
1754 elm_win_sticky_set(Evas_Object *obj, Eina_Bool sticky)
1757 ELM_CHECK_WIDTYPE(obj, widtype);
1758 win = elm_widget_data_get(obj);
1760 ecore_evas_sticky_set(win->ee, sticky);
1761 #ifdef HAVE_ELEMENTARY_X
1762 _elm_win_xwin_update(win);
1767 * Get the sticky state of the window.
1769 * @param obj The window object
1770 * @return If true, the window's sticky state is enabled
1775 elm_win_sticky_get(const Evas_Object *obj)
1778 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1779 win = elm_widget_data_get(obj);
1780 if (!win) return EINA_FALSE;
1781 return ecore_evas_sticky_get(win->ee);
1785 * Sets the keyboard mode of the window.
1787 * @param obj The window object
1788 * @param mode The mode to set; one of:
1789 * ELM_WIN_KEYBOARD_UNKNOWN
1790 * ELM_WIN_KEYBOARD_OFF
1791 * ELM_WIN_KEYBOARD_ON
1792 * ELM_WIN_KEYBOARD_ALPHA
1793 * ELM_WIN_KEYBOARD_NUMERIC
1794 * ELM_WIN_KEYBOARD_PIN
1795 * ELM_WIN_KEYBOARD_PHONE_NUMBER
1796 * ELM_WIN_KEYBOARD_HEX
1797 * ELM_WIN_KEYBOARD_TERMINAL
1798 * ELM_WIN_KEYBOARD_PASSWORD
1799 * ELM_WIN_KEYBOARD_IP
1800 * ELM_WIN_KEYBOARD_HOST
1801 * ELM_WIN_KEYBOARD_FILE
1802 * ELM_WIN_KEYBOARD_URL
1803 * ELM_WIN_KEYBOARD_KEYPAD
1804 * ELM_WIN_KEYBOARD_J2ME
1809 elm_win_keyboard_mode_set(Evas_Object *obj, Elm_Win_Keyboard_Mode mode)
1812 ELM_CHECK_WIDTYPE(obj, widtype);
1813 win = elm_widget_data_get(obj);
1815 if (mode == win->kbdmode) return;
1816 #ifdef HAVE_ELEMENTARY_X
1817 _elm_win_xwindow_get(win);
1819 win->kbdmode = mode;
1820 #ifdef HAVE_ELEMENTARY_X
1822 ecore_x_e_virtual_keyboard_state_set
1823 (win->xwin, (Ecore_X_Virtual_Keyboard_State)win->kbdmode);
1828 * Gets the keyboard mode of the window.
1830 * @param obj The window object
1831 * @return The mode; one of:
1832 * ELM_WIN_KEYBOARD_UNKNOWN
1833 * ELM_WIN_KEYBOARD_OFF
1834 * ELM_WIN_KEYBOARD_ON
1835 * ELM_WIN_KEYBOARD_ALPHA
1836 * ELM_WIN_KEYBOARD_NUMERIC
1837 * ELM_WIN_KEYBOARD_PIN
1838 * ELM_WIN_KEYBOARD_PHONE_NUMBER
1839 * ELM_WIN_KEYBOARD_HEX
1840 * ELM_WIN_KEYBOARD_TERMINAL
1841 * ELM_WIN_KEYBOARD_PASSWORD
1842 * ELM_WIN_KEYBOARD_IP
1843 * ELM_WIN_KEYBOARD_HOST
1844 * ELM_WIN_KEYBOARD_FILE
1845 * ELM_WIN_KEYBOARD_URL
1846 * ELM_WIN_KEYBOARD_KEYPAD
1847 * ELM_WIN_KEYBOARD_J2ME
1851 EAPI Elm_Win_Keyboard_Mode
1852 elm_win_keyboard_mode_get(const Evas_Object *obj)
1855 ELM_CHECK_WIDTYPE(obj, widtype) ELM_WIN_KEYBOARD_UNKNOWN;
1856 win = elm_widget_data_get(obj);
1857 if (!win) return ELM_WIN_KEYBOARD_UNKNOWN;
1858 return win->kbdmode;
1862 * Sets whether the window is a keyboard.
1864 * @param obj The window object
1865 * @param is_keyboard If true, the window is a virtual keyboard
1870 elm_win_keyboard_win_set(Evas_Object *obj, Eina_Bool is_keyboard)
1873 ELM_CHECK_WIDTYPE(obj, widtype);
1874 win = elm_widget_data_get(obj);
1876 #ifdef HAVE_ELEMENTARY_X
1877 _elm_win_xwindow_get(win);
1879 ecore_x_e_virtual_keyboard_set(win->xwin, is_keyboard);
1884 * Gets whether the window is a keyboard.
1886 * @param obj The window object
1887 * @return If the window is a virtual keyboard
1892 elm_win_keyboard_win_get(const Evas_Object *obj)
1895 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1896 win = elm_widget_data_get(obj);
1897 if (!win) return EINA_FALSE;
1898 #ifdef HAVE_ELEMENTARY_X
1899 _elm_win_xwindow_get(win);
1901 return ecore_x_e_virtual_keyboard_get(win->xwin);
1907 * Get the screen position of a window.
1909 * @param obj The window object
1910 * @param x The int to store the x coordinate to
1911 * @param y The int to store the y coordinate to
1916 elm_win_screen_position_get(const Evas_Object *obj, int *x, int *y)
1919 ELM_CHECK_WIDTYPE(obj, widtype);
1920 win = elm_widget_data_get(obj);
1922 if (x) *x = win->screen.x;
1923 if (y) *y = win->screen.y;
1927 * Set if this window is an illume conformant window
1929 * @param obj The window object
1930 * @param conformant The conformant flag (1 = conformant, 0 = non-conformant)
1935 elm_win_conformant_set(Evas_Object *obj, Eina_Bool conformant)
1938 ELM_CHECK_WIDTYPE(obj, widtype);
1939 win = elm_widget_data_get(obj);
1941 #ifdef HAVE_ELEMENTARY_X
1942 _elm_win_xwindow_get(win);
1944 ecore_x_e_illume_conformant_set(win->xwin, conformant);
1949 * Get if this window is an illume conformant window
1951 * @param obj The window object
1952 * @return A boolean if this window is illume conformant or not
1957 elm_win_conformant_get(const Evas_Object *obj)
1960 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1961 win = elm_widget_data_get(obj);
1962 if (!win) return EINA_FALSE;
1963 #ifdef HAVE_ELEMENTARY_X
1964 _elm_win_xwindow_get(win);
1966 return ecore_x_e_illume_conformant_get(win->xwin);
1972 * Set a window to be an illume quickpanel window
1974 * By default window objects are not quickpanel windows.
1976 * @param obj The window object
1977 * @param quickpanel The quickpanel flag (1 = quickpanel, 0 = normal window)
1982 elm_win_quickpanel_set(Evas_Object *obj, Eina_Bool quickpanel)
1985 ELM_CHECK_WIDTYPE(obj, widtype);
1986 win = elm_widget_data_get(obj);
1988 #ifdef HAVE_ELEMENTARY_X
1989 _elm_win_xwindow_get(win);
1992 ecore_x_e_illume_quickpanel_set(win->xwin, quickpanel);
1995 Ecore_X_Window_State states[2];
1997 states[0] = ECORE_X_WINDOW_STATE_SKIP_TASKBAR;
1998 states[1] = ECORE_X_WINDOW_STATE_SKIP_PAGER;
1999 ecore_x_netwm_window_state_set(win->xwin, states, 2);
2000 ecore_x_icccm_hints_set(win->xwin, 0, 0, 0, 0, 0, 0, 0);
2007 * Get if this window is a quickpanel or not
2009 * @param obj The window object
2010 * @return A boolean if this window is a quickpanel or not
2015 elm_win_quickpanel_get(const Evas_Object *obj)
2018 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2019 win = elm_widget_data_get(obj);
2020 if (!win) return EINA_FALSE;
2021 #ifdef HAVE_ELEMENTARY_X
2022 _elm_win_xwindow_get(win);
2024 return ecore_x_e_illume_quickpanel_get(win->xwin);
2030 * Set the major priority of a quickpanel window
2032 * @param obj The window object
2033 * @param priority The major priority for this quickpanel
2038 elm_win_quickpanel_priority_major_set(Evas_Object *obj, int priority)
2041 ELM_CHECK_WIDTYPE(obj, widtype);
2042 win = elm_widget_data_get(obj);
2044 #ifdef HAVE_ELEMENTARY_X
2045 _elm_win_xwindow_get(win);
2047 ecore_x_e_illume_quickpanel_priority_major_set(win->xwin, priority);
2052 * Get the major priority of a quickpanel window
2054 * @param obj The window object
2055 * @return The major priority of this quickpanel
2060 elm_win_quickpanel_priority_major_get(const Evas_Object *obj)
2063 ELM_CHECK_WIDTYPE(obj, widtype) -1;
2064 win = elm_widget_data_get(obj);
2065 if (!win) return -1;
2066 #ifdef HAVE_ELEMENTARY_X
2067 _elm_win_xwindow_get(win);
2069 return ecore_x_e_illume_quickpanel_priority_major_get(win->xwin);
2075 * Set the minor priority of a quickpanel window
2077 * @param obj The window object
2078 * @param priority The minor priority for this quickpanel
2083 elm_win_quickpanel_priority_minor_set(Evas_Object *obj, int priority)
2086 ELM_CHECK_WIDTYPE(obj, widtype);
2087 win = elm_widget_data_get(obj);
2089 #ifdef HAVE_ELEMENTARY_X
2090 _elm_win_xwindow_get(win);
2092 ecore_x_e_illume_quickpanel_priority_minor_set(win->xwin, priority);
2097 * Get the minor priority of a quickpanel window
2099 * @param obj The window object
2100 * @return The minor priority of this quickpanel
2105 elm_win_quickpanel_priority_minor_get(const Evas_Object *obj)
2108 ELM_CHECK_WIDTYPE(obj, widtype) -1;
2109 win = elm_widget_data_get(obj);
2110 if (!win) return -1;
2111 #ifdef HAVE_ELEMENTARY_X
2112 _elm_win_xwindow_get(win);
2114 return ecore_x_e_illume_quickpanel_priority_minor_get(win->xwin);
2120 * Set which zone this quickpanel should appear in
2122 * @param obj The window object
2123 * @param zone The requested zone for this quickpanel
2128 elm_win_quickpanel_zone_set(Evas_Object *obj, int zone)
2131 ELM_CHECK_WIDTYPE(obj, widtype);
2132 win = elm_widget_data_get(obj);
2134 #ifdef HAVE_ELEMENTARY_X
2135 _elm_win_xwindow_get(win);
2137 ecore_x_e_illume_quickpanel_zone_set(win->xwin, zone);
2142 * Get which zone this quickpanel should appear in
2144 * @param obj The window object
2145 * @return The requested zone for this quickpanel
2150 elm_win_quickpanel_zone_get(const Evas_Object *obj)
2153 ELM_CHECK_WIDTYPE(obj, widtype) 0;
2154 win = elm_widget_data_get(obj);
2156 #ifdef HAVE_ELEMENTARY_X
2157 _elm_win_xwindow_get(win);
2159 return ecore_x_e_illume_quickpanel_zone_get(win->xwin);
2165 * Set the enabled status for the focus highlight in a window
2167 * This function will enable or disable the focus highlight only for the
2168 * given window, regardless of the global setting for it
2170 * @param obj The window where to enable the highlight
2171 * @param enabled The enabled value for the highlight
2176 elm_win_focus_highlight_enabled_set(Evas_Object *obj, Eina_Bool enabled)
2180 ELM_CHECK_WIDTYPE(obj, widtype);
2182 win = elm_widget_data_get(obj);
2183 enabled = !!enabled;
2184 if (win->focus_highlight.enabled == enabled)
2187 win->focus_highlight.enabled = enabled;
2189 if (win->focus_highlight.enabled)
2190 _elm_win_focus_highlight_init(win);
2192 _elm_win_focus_highlight_shutdown(win);
2196 * Get the enabled value of the focus highlight for this window
2198 * @param obj The window in which to check if the focus highlight is enabled
2200 * @return EINA_TRUE if enabled, EINA_FALSE otherwise
2205 elm_win_focus_highlight_enabled_get(const Evas_Object *obj)
2209 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2211 win = elm_widget_data_get(obj);
2212 return win->focus_highlight.enabled;
2216 * Set the style for the focus highlight on this window
2218 * Sets the style to use for theming the highlight of focused objects on
2219 * the given window. If @p style is NULL, the default will be used.
2221 * @param obj The window where to set the style
2222 * @param style The style to set
2227 elm_win_focus_highlight_style_set(Evas_Object *obj, const char *style)
2231 ELM_CHECK_WIDTYPE(obj, widtype);
2233 win = elm_widget_data_get(obj);
2234 eina_stringshare_replace(&win->focus_highlight.style, style);
2235 win->focus_highlight.changed_theme = EINA_TRUE;
2236 _elm_win_focus_highlight_reconfigure_job_start(win);
2240 * Get the style set for the focus highlight object
2242 * Gets the style set for this windows highilght object, or NULL if none
2245 * @param obj The window to retrieve the highlights style from
2247 * @return The style set or NULL if none was. Default is used in that case.
2252 elm_win_focus_highlight_style_get(const Evas_Object *obj)
2256 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2258 win = elm_widget_data_get(obj);
2259 return win->focus_highlight.style;
2262 typedef struct _Widget_Data Widget_Data;
2267 Evas_Object *content;
2270 static void _del_hook(Evas_Object *obj);
2271 static void _theme_hook(Evas_Object *obj);
2272 static void _sizing_eval(Evas_Object *obj);
2273 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
2274 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
2276 static const char *widtype2 = NULL;
2279 _del_hook(Evas_Object *obj)
2281 Widget_Data *wd = elm_widget_data_get(obj);
2287 _theme_hook(Evas_Object *obj)
2289 Widget_Data *wd = elm_widget_data_get(obj);
2290 _elm_theme_object_set(obj, wd->frm, "win", "inwin", elm_widget_style_get(obj));
2292 edje_object_part_swallow(wd->frm, "elm.swallow.content", wd->content);
2297 _elm_inwin_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
2299 Widget_Data *wd = elm_widget_data_get(obj);
2304 /* Try Focus cycle in subitem */
2307 elm_widget_focus_next_get(wd->content, dir, next);
2312 *next = (Evas_Object *)obj;
2317 _sizing_eval(Evas_Object *obj)
2319 Widget_Data *wd = elm_widget_data_get(obj);
2320 Evas_Coord minw = -1, minh = -1;
2322 evas_object_size_hint_min_get(wd->content, &minw, &minh);
2323 edje_object_size_min_calc(wd->frm, &minw, &minh);
2324 evas_object_size_hint_min_set(obj, minw, minh);
2325 evas_object_size_hint_max_set(obj, -1, -1);
2329 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2335 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
2337 Widget_Data *wd = elm_widget_data_get(obj);
2338 Evas_Object *sub = event_info;
2339 if (sub == wd->content)
2341 evas_object_event_callback_del_full
2342 (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
2349 * @defgroup Inwin Inwin
2351 * An inwin is a window inside a window that is useful for a quick popup. It does not hover.
2354 elm_win_inwin_add(Evas_Object *obj)
2360 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2361 win = elm_widget_data_get(obj);
2362 if (!win) return NULL;
2363 wd = ELM_NEW(Widget_Data);
2364 obj2 = elm_widget_add(win->evas);
2365 elm_widget_type_set(obj2, "inwin");
2366 ELM_SET_WIDTYPE(widtype2, "inwin");
2367 elm_widget_sub_object_add(obj, obj2);
2368 evas_object_size_hint_weight_set(obj2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2369 evas_object_size_hint_align_set(obj2, EVAS_HINT_FILL, EVAS_HINT_FILL);
2370 elm_win_resize_object_add(obj, obj2);
2372 elm_widget_data_set(obj2, wd);
2373 elm_widget_del_hook_set(obj2, _del_hook);
2374 elm_widget_theme_hook_set(obj2, _theme_hook);
2375 elm_widget_focus_next_hook_set(obj2, _elm_inwin_focus_next_hook);
2376 elm_widget_can_focus_set(obj2, EINA_TRUE);
2377 elm_widget_highlight_ignore_set(obj2, EINA_TRUE);
2379 wd->frm = edje_object_add(win->evas);
2380 _elm_theme_object_set(obj, wd->frm, "win", "inwin", "default");
2381 elm_widget_resize_object_set(obj2, wd->frm);
2383 evas_object_smart_callback_add(obj2, "sub-object-del", _sub_del, obj2);
2390 * Activates an inwin object
2392 * @param obj The inwin to activate
2397 elm_win_inwin_activate(Evas_Object *obj)
2399 ELM_CHECK_WIDTYPE(obj, widtype2);
2400 Widget_Data *wd = elm_widget_data_get(obj);
2402 evas_object_raise(obj);
2403 evas_object_show(obj);
2404 edje_object_signal_emit(wd->frm, "elm,action,show", "elm");
2405 elm_object_focus(obj);
2409 * Set the content of an inwin object.
2411 * Once the content object is set, a previously set one will be deleted.
2412 * If you want to keep that old content object, use the
2413 * elm_win_inwin_content_unset() function.
2415 * @param obj The inwin object
2416 * @param content The object to set as content
2421 elm_win_inwin_content_set(Evas_Object *obj, Evas_Object *content)
2423 ELM_CHECK_WIDTYPE(obj, widtype2);
2424 Widget_Data *wd = elm_widget_data_get(obj);
2426 if (wd->content == content) return;
2427 if (wd->content) evas_object_del(wd->content);
2428 wd->content = content;
2431 elm_widget_sub_object_add(obj, content);
2432 evas_object_event_callback_add(content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
2433 _changed_size_hints, obj);
2434 edje_object_part_swallow(wd->frm, "elm.swallow.content", content);
2440 * Get the content of an inwin object.
2442 * Return the content object which is set for this widget.
2444 * @param obj The inwin object
2445 * @return The content that is being used
2450 elm_win_inwin_content_get(const Evas_Object *obj)
2452 ELM_CHECK_WIDTYPE(obj, widtype2) NULL;
2453 Widget_Data *wd = elm_widget_data_get(obj);
2454 if (!wd) return NULL;
2459 * Unset the content of an inwin object.
2461 * Unparent and return the content object which was set for this widget.
2463 * @param obj The inwin object
2464 * @return The content that was being used
2469 elm_win_inwin_content_unset(Evas_Object *obj)
2471 ELM_CHECK_WIDTYPE(obj, widtype2) NULL;
2472 Widget_Data *wd = elm_widget_data_get(obj);
2473 if (!wd) return NULL;
2474 if (!wd->content) return NULL;
2475 Evas_Object *content = wd->content;
2476 elm_widget_sub_object_del(obj, wd->content);
2477 edje_object_part_unswallow(wd->frm, wd->content);
2482 /* windowing spcific calls - shall we do this differently? */
2484 * Get the Ecore_X_Window of an Evas_Object
2486 * @param obj The object
2488 * @return The Ecore_X_Window of @p obj
2493 elm_win_xwindow_get(const Evas_Object *obj)
2495 Ecore_X_Window xwin = 0;
2496 Ecore_Evas *ee = NULL;
2498 #ifdef HAVE_ELEMENTARY_X
2499 ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
2500 if (ee) xwin = (Ecore_X_Window)ecore_evas_window_get(ee);