1 #include <Elementary.h>
8 * The window class of Elementary. Contains functions to manipulate
12 typedef struct _Elm_Win Elm_Win;
18 Evas_Object *parent, *win_obj;
20 #ifdef HAVE_ELEMENTARY_X
22 Ecore_Event_Handler *client_message_handler;
24 Ecore_Job *deferred_resize_job;
25 Ecore_Job *deferred_child_eval_job;
28 Elm_Win_Keyboard_Mode kbdmode;
29 Eina_Bool autodel : 1;
30 int *autodel_clear, rot;
40 Eina_Bool visible : 1;
41 Eina_Bool handled : 1;
45 Ecore_Job *reconf_job;
47 Eina_Bool enabled : 1;
48 Eina_Bool changed_theme : 1;
49 Eina_Bool top_animate : 1;
50 Eina_Bool geometry_changed : 1;
54 static const char *widtype = NULL;
55 static void _elm_win_obj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
56 static void _elm_win_obj_callback_parent_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
57 static void _elm_win_obj_intercept_show(void *data, Evas_Object *obj);
58 static void _elm_win_move(Ecore_Evas *ee);
59 static void _elm_win_resize(Ecore_Evas *ee);
60 static void _elm_win_delete_request(Ecore_Evas *ee);
61 static void _elm_win_resize_job(void *data);
62 #ifdef HAVE_ELEMENTARY_X
63 static void _elm_win_xwin_update(Elm_Win *win);
65 static void _elm_win_eval_subobjs(Evas_Object *obj);
66 static void _elm_win_subobj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
67 static void _elm_win_subobj_callback_changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
68 static void _elm_win_focus_highlight_init(Elm_Win *win);
69 static void _elm_win_focus_highlight_shutdown(Elm_Win *win);
70 static void _elm_win_focus_highlight_visible_set(Elm_Win *win, Eina_Bool visible);
71 static void _elm_win_focus_highlight_reconfigure_job_start(Elm_Win *win);
72 static void _elm_win_focus_highlight_reconfigure_job_stop(Elm_Win *win);
73 static void _elm_win_focus_highlight_anim_end(void *data, Evas_Object *obj, const char *emission, const char *source);
74 static void _elm_win_focus_highlight_reconfigure(Elm_Win *win);
76 Eina_List *_elm_win_list = NULL;
79 _elm_win_move(Ecore_Evas *ee)
81 Evas_Object *obj = ecore_evas_object_associate_get(ee);
86 win = elm_widget_data_get(obj);
88 ecore_evas_geometry_get(ee, &x, &y, NULL, NULL);
91 evas_object_smart_callback_call(win->win_obj, "moved", NULL);
95 _elm_win_resize(Ecore_Evas *ee)
97 Evas_Object *obj = ecore_evas_object_associate_get(ee);
101 win = elm_widget_data_get(obj);
103 if (win->deferred_resize_job) ecore_job_del(win->deferred_resize_job);
104 win->deferred_resize_job = ecore_job_add(_elm_win_resize_job, win);
108 _elm_win_focus_in(Ecore_Evas *ee)
110 Evas_Object *obj = ecore_evas_object_associate_get(ee);
114 win = elm_widget_data_get(obj);
116 /*NB: Why two different "focus signals" here ??? */
117 evas_object_smart_callback_call(win->win_obj, "focus-in", NULL); // FIXME: remove me
118 evas_object_smart_callback_call(win->win_obj, "focus,in", NULL);
119 win->focus_highlight.cur.visible = EINA_TRUE;
120 _elm_win_focus_highlight_reconfigure_job_start(win);
124 _elm_win_focus_out(Ecore_Evas *ee)
126 Evas_Object *obj = ecore_evas_object_associate_get(ee);
130 win = elm_widget_data_get(obj);
132 evas_object_smart_callback_call(win->win_obj, "focus-out", NULL); // FIXME: remove me
133 evas_object_smart_callback_call(win->win_obj, "focus,out", NULL);
134 win->focus_highlight.cur.visible = EINA_FALSE;
135 _elm_win_focus_highlight_reconfigure_job_start(win);
139 _elm_win_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
141 Elm_Win *wd = elm_widget_data_get(obj);
142 const Eina_List *items;
143 void *(*list_data_get) (const Eina_List *list);
151 if (!(items = elm_widget_focus_custom_chain_get(obj)))
157 list_data_get = eina_list_data_get;
159 elm_widget_focus_list_next_get(obj, items, list_data_get, dir, next);
165 *next = (Evas_Object *)obj;
170 _elm_win_on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
172 if (elm_widget_focus_get(obj))
173 evas_object_focus_set(obj, EINA_TRUE);
175 evas_object_focus_set(obj, EINA_FALSE);
179 _elm_win_event_cb(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
181 if (type == EVAS_CALLBACK_KEY_DOWN)
183 Evas_Event_Key_Down *ev = event_info;
184 if (!strcmp(ev->keyname, "Tab"))
186 if(evas_key_modifier_is_set(ev->modifiers, "Shift"))
187 elm_widget_focus_cycle(obj, ELM_FOCUS_PREVIOUS);
189 elm_widget_focus_cycle(obj, ELM_FOCUS_NEXT);
190 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
199 _deferred_ecore_evas_free(void *data)
201 ecore_evas_free(data);
205 _elm_win_obj_callback_show(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
207 elm_object_focus(obj);
211 _elm_win_obj_callback_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
218 evas_object_event_callback_del_full(win->parent, EVAS_CALLBACK_DEL,
219 _elm_win_obj_callback_parent_del, win);
222 if (win->autodel_clear) *(win->autodel_clear) = -1;
223 _elm_win_list = eina_list_remove(_elm_win_list, win->win_obj);
224 while (win->subobjs) elm_win_resize_object_del(obj, win->subobjs->data);
225 ecore_evas_callback_delete_request_set(win->ee, NULL);
226 ecore_evas_callback_resize_set(win->ee, NULL);
227 if (win->deferred_resize_job) ecore_job_del(win->deferred_resize_job);
228 if (win->deferred_child_eval_job) ecore_job_del(win->deferred_child_eval_job);
229 while (((child = evas_object_bottom_get(win->evas))) &&
232 evas_object_del(child);
234 while (((child = evas_object_top_get(win->evas))) &&
237 evas_object_del(child);
239 #ifdef HAVE_ELEMENTARY_X
240 if (win->client_message_handler)
241 ecore_event_handler_del(win->client_message_handler);
243 // FIXME: Why are we flushing edje on every window destroy ??
244 // edje_file_cache_flush();
245 // edje_collection_cache_flush();
246 // evas_image_cache_flush(win->evas);
247 // evas_font_cache_flush(win->evas);
248 // FIXME: we are in the del handler for the object and delete the canvas
249 // that lives under it from the handler... nasty. deferring doesn't help either
250 ecore_job_add(_deferred_ecore_evas_free, win->ee);
251 // ecore_evas_free(win->ee);
253 _elm_win_focus_highlight_shutdown(win);
254 eina_stringshare_del(win->focus_highlight.style);
258 if ((!_elm_win_list) &&
259 (elm_policy_get(ELM_POLICY_QUIT) == ELM_POLICY_QUIT_LAST_WINDOW_CLOSED))
261 edje_file_cache_flush();
262 edje_collection_cache_flush();
263 evas_image_cache_flush(e);
264 evas_font_cache_flush(e);
270 _elm_win_obj_callback_parent_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
273 if (obj == win->parent) win->parent = NULL;
277 _elm_win_obj_intercept_show(void *data __UNUSED__, Evas_Object *obj)
279 // this is called to make sure all smart containers have calculated their
280 // sizes BEFORE we show the window to make sure it initially appears at
281 // our desired size (ie min size is known first)
282 evas_smart_objects_calculate(evas_object_evas_get(obj));
283 evas_object_show(obj);
287 _elm_win_delete_request(Ecore_Evas *ee)
289 Evas_Object *obj = ecore_evas_object_associate_get(ee);
291 if (strcmp(elm_widget_type_get(obj), "win")) return;
293 win = elm_widget_data_get(obj);
295 int autodel = win->autodel;
296 win->autodel_clear = &autodel;
297 evas_object_smart_callback_call(win->win_obj, "delete-request", NULL); // FIXME: remove me
298 evas_object_smart_callback_call(win->win_obj, "delete,request", NULL);
299 // FIXME: if above callback deletes - then the below will be invalid
300 if (autodel) evas_object_del(win->win_obj);
301 else win->autodel_clear = NULL;
305 _elm_win_resize_job(void *data)
312 win->deferred_resize_job = NULL;
313 ecore_evas_geometry_get(win->ee, NULL, NULL, &w, &h);
314 evas_object_resize(win->win_obj, w, h);
315 EINA_LIST_FOREACH(win->subobjs, l, obj)
317 evas_object_move(obj, 0, 0);
318 evas_object_resize(obj, w, h);
322 #ifdef HAVE_ELEMENTARY_X
324 _elm_win_xwindow_get(Elm_Win *win)
328 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
329 if (ENGINE_COMPARE(ELM_SOFTWARE_X11))
331 if (win->ee) win->xwin = ecore_evas_software_x11_window_get(win->ee);
333 else if (ENGINE_COMPARE(ELM_SOFTWARE_X11) ||
334 ENGINE_COMPARE(ELM_SOFTWARE_FB) ||
335 ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE) ||
336 ENGINE_COMPARE(ELM_SOFTWARE_SDL) ||
337 ENGINE_COMPARE(ELM_SOFTWARE_16_SDL) ||
338 ENGINE_COMPARE(ELM_OPENGL_SDL))
341 else if (ENGINE_COMPARE(ELM_SOFTWARE_16_X11))
343 if (win->ee) win->xwin = ecore_evas_software_x11_16_window_get(win->ee);
345 else if (ENGINE_COMPARE(ELM_SOFTWARE_8_X11))
347 if (win->ee) win->xwin = ecore_evas_software_x11_8_window_get(win->ee);
349 else if (ENGINE_COMPARE(ELM_XRENDER_X11))
351 if (win->ee) win->xwin = ecore_evas_xrender_x11_window_get(win->ee);
353 else if (ENGINE_COMPARE(ELM_OPENGL_X11))
355 if (win->ee) win->xwin = ecore_evas_gl_x11_window_get(win->ee);
357 else if (ENGINE_COMPARE(ELM_SOFTWARE_WIN32))
359 if (win->ee) win->xwin = (long)ecore_evas_win32_window_get(win->ee);
361 #undef ENGINE_COMPARE
365 #ifdef HAVE_ELEMENTARY_X
367 _elm_win_xwin_update(Elm_Win *win)
369 _elm_win_xwindow_get(win);
374 win2 = elm_widget_data_get(win->parent);
378 ecore_x_icccm_transient_for_set(win->xwin, win2->xwin);
382 if (!win->xwin) return; /* nothing more to do */
387 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_NORMAL);
389 case ELM_WIN_DIALOG_BASIC:
390 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DIALOG);
392 case ELM_WIN_DESKTOP:
393 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DESKTOP);
396 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DOCK);
398 case ELM_WIN_TOOLBAR:
399 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_TOOLBAR);
402 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_MENU);
404 case ELM_WIN_UTILITY:
405 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_UTILITY);
408 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_SPLASH);
413 ecore_x_e_virtual_keyboard_state_set
414 (win->xwin, (Ecore_X_Virtual_Keyboard_State)win->kbdmode);
419 _elm_win_eval_subobjs(Evas_Object *obj)
422 const Evas_Object *child;
424 Elm_Win *win = elm_widget_data_get(obj);
425 Evas_Coord w, h, minw = -1, minh = -1, maxw = -1, maxh = -1;
429 EINA_LIST_FOREACH(win->subobjs, l, child)
431 evas_object_size_hint_weight_get(child, &wx, &wy);
432 if (wx == 0.0) xx = 0;
433 if (wy == 0.0) xy = 0;
435 evas_object_size_hint_min_get(child, &w, &h);
438 if (w > minw) minw = w;
439 if (h > minh) minh = h;
441 evas_object_size_hint_max_get(child, &w, &h);
444 if (maxw == -1) maxw = w;
445 else if ((w > 0) && (w < maxw)) maxw = w;
446 if (maxh == -1) maxh = h;
447 else if ((h > 0) && (h < maxh)) maxh = h;
449 if (!xx) maxw = minw;
451 if (!xy) maxh = minh;
453 evas_object_size_hint_min_set(obj, minw, minh);
454 evas_object_size_hint_max_set(obj, maxw, maxh);
455 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
456 if (w < minw) w = minw;
457 if (h < minh) h = minh;
458 if ((maxw >= 0) && (w > maxw)) w = maxw;
459 if ((maxh >= 0) && (h > maxh)) h = maxh;
460 evas_object_resize(obj, w, h);
464 _elm_win_subobj_callback_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
466 Elm_Win *win = elm_widget_data_get(data);
467 win->subobjs = eina_list_remove(win->subobjs, obj);
468 _elm_win_eval_subobjs(win->win_obj);
472 _elm_win_subobj_callback_changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
474 _elm_win_eval_subobjs(data);
478 _elm_win_shutdown(void)
480 while (_elm_win_list)
481 evas_object_del(_elm_win_list->data);
485 _elm_win_rescale(Elm_Theme *th, Eina_Bool use_theme)
492 EINA_LIST_FOREACH(_elm_win_list, l, obj)
493 elm_widget_theme(obj);
497 EINA_LIST_FOREACH(_elm_win_list, l, obj)
498 elm_widget_theme_specific(obj, th, EINA_FALSE);
502 #ifdef HAVE_ELEMENTARY_X
504 _elm_win_client_message(void *data, int type __UNUSED__, void *event)
507 Ecore_X_Event_Client_Message *e = event;
509 if (e->format != 32) return ECORE_CALLBACK_PASS_ON;
510 if (e->message_type == ECORE_X_ATOM_E_COMP_FLUSH)
512 if ((unsigned)e->data.l[0] == win->xwin)
514 Evas *evas = evas_object_evas_get(win->win_obj);
517 edje_file_cache_flush();
518 edje_collection_cache_flush();
519 evas_image_cache_flush(evas);
520 evas_font_cache_flush(evas);
524 else if (e->message_type == ECORE_X_ATOM_E_COMP_DUMP)
526 if ((unsigned)e->data.l[0] == win->xwin)
528 Evas *evas = evas_object_evas_get(win->win_obj);
531 edje_file_cache_flush();
532 edje_collection_cache_flush();
533 evas_image_cache_flush(evas);
534 evas_font_cache_flush(evas);
535 evas_render_dump(evas);
539 return ECORE_CALLBACK_PASS_ON;
544 _elm_win_focus_target_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
548 win->focus_highlight.geometry_changed = EINA_TRUE;
549 _elm_win_focus_highlight_reconfigure_job_start(win);
553 _elm_win_focus_target_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
557 win->focus_highlight.geometry_changed = EINA_TRUE;
558 _elm_win_focus_highlight_reconfigure_job_start(win);
562 _elm_win_focus_target_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
566 win->focus_highlight.cur.target = NULL;
568 _elm_win_focus_highlight_reconfigure_job_start(win);
572 _elm_win_focus_target_callbacks_add(Elm_Win *win)
574 Evas_Object *obj = win->focus_highlight.cur.target;
576 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE,
577 _elm_win_focus_target_move, win);
578 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE,
579 _elm_win_focus_target_resize, win);
580 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
581 _elm_win_focus_target_del, win);
585 _elm_win_focus_target_callbacks_del(Elm_Win *win)
587 Evas_Object *obj = win->focus_highlight.cur.target;
589 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_MOVE,
590 _elm_win_focus_target_move, win);
591 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_RESIZE,
592 _elm_win_focus_target_resize, win);
593 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL,
594 _elm_win_focus_target_del, win);
598 _elm_win_focus_target_get(Evas_Object *obj)
600 Evas_Object *o = obj;
604 if (elm_widget_is(o))
606 if (!elm_widget_highlight_ignore_get(o))
608 o = elm_widget_parent_get(o);
610 o = evas_object_smart_parent_get(o);
614 o = elm_widget_parent_widget_get(o);
616 o = evas_object_smart_parent_get(o);
625 _elm_win_object_focus_in(void *data, Evas *e __UNUSED__, void *event_info)
627 Evas_Object *obj = event_info, *target;
630 if (win->focus_highlight.cur.target == obj)
633 target = _elm_win_focus_target_get(obj);
634 win->focus_highlight.cur.target = target;
635 if (elm_widget_highlight_in_theme_get(target))
636 win->focus_highlight.cur.handled = EINA_TRUE;
638 _elm_win_focus_target_callbacks_add(win);
640 _elm_win_focus_highlight_reconfigure_job_start(win);
644 _elm_win_object_focus_out(void *data, Evas *e __UNUSED__, void *event_info __UNUSED__)
648 if (!win->focus_highlight.cur.target)
651 if (!win->focus_highlight.cur.handled)
652 _elm_win_focus_target_callbacks_del(win);
653 win->focus_highlight.cur.target = NULL;
654 win->focus_highlight.cur.handled = EINA_FALSE;
656 _elm_win_focus_highlight_reconfigure_job_start(win);
660 _elm_win_focus_highlight_hide(void *data __UNUSED__, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
662 evas_object_hide(obj);
666 _elm_win_focus_highlight_init(Elm_Win *win)
668 evas_event_callback_add(win->evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
669 _elm_win_object_focus_in, win);
670 evas_event_callback_add(win->evas,
671 EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
672 _elm_win_object_focus_out, win);
674 win->focus_highlight.cur.target = evas_focus_get(win->evas);
676 win->focus_highlight.top = edje_object_add(win->evas);
677 win->focus_highlight.changed_theme = EINA_TRUE;
678 edje_object_signal_callback_add(win->focus_highlight.top,
679 "elm,action,focus,hide,end", "",
680 _elm_win_focus_highlight_hide, NULL);
681 edje_object_signal_callback_add(win->focus_highlight.top,
682 "elm,action,focus,anim,end", "",
683 _elm_win_focus_highlight_anim_end, win);
684 _elm_win_focus_highlight_reconfigure_job_start(win);
688 _elm_win_focus_highlight_shutdown(Elm_Win *win)
690 _elm_win_focus_highlight_reconfigure_job_stop(win);
691 if (win->focus_highlight.cur.target)
693 _elm_win_focus_target_callbacks_del(win);
694 win->focus_highlight.cur.target = NULL;
696 if (win->focus_highlight.top)
698 evas_object_del(win->focus_highlight.top);
699 win->focus_highlight.top = NULL;
702 evas_event_callback_del_full(win->evas,
703 EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
704 _elm_win_object_focus_in, win);
705 evas_event_callback_del_full(win->evas,
706 EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
707 _elm_win_object_focus_out, win);
711 _elm_win_focus_highlight_visible_set(Elm_Win *win, Eina_Bool visible)
715 top = win->focus_highlight.top;
720 evas_object_show(top);
721 edje_object_signal_emit(top, "elm,action,focus,show", "elm");
727 edje_object_signal_emit(top, "elm,action,focus,hide", "elm");
732 _elm_win_focus_highlight_reconfigure_job(void *data)
734 _elm_win_focus_highlight_reconfigure((Elm_Win *)data);
738 _elm_win_focus_highlight_reconfigure_job_start(Elm_Win *win)
740 if (win->focus_highlight.reconf_job)
741 ecore_job_del(win->focus_highlight.reconf_job);
742 win->focus_highlight.reconf_job = ecore_job_add(
743 _elm_win_focus_highlight_reconfigure_job, win);
747 _elm_win_focus_highlight_reconfigure_job_stop(Elm_Win *win)
749 if (win->focus_highlight.reconf_job)
750 ecore_job_del(win->focus_highlight.reconf_job);
751 win->focus_highlight.reconf_job = NULL;
755 _elm_win_focus_highlight_simple_setup(Elm_Win *win, Evas_Object *obj)
757 Evas_Object *clip, *target = win->focus_highlight.cur.target;
758 Evas_Coord x, y, w, h;
760 clip = evas_object_clip_get(target);
761 evas_object_geometry_get(target, &x, &y, &w, &h);
763 evas_object_move(obj, x, y);
764 evas_object_resize(obj, w, h);
765 evas_object_clip_set(obj, clip);
769 _elm_win_focus_highlight_anim_setup(Elm_Win *win, Evas_Object *obj)
771 Evas_Coord tx, ty, tw, th;
772 Evas_Coord w, h, px, py, pw, ph;
773 Edje_Message_Int_Set *m;
774 Evas_Object *previous = win->focus_highlight.prev.target;
775 Evas_Object *target = win->focus_highlight.cur.target;
777 evas_object_geometry_get(win->win_obj, NULL, NULL, &w, &h);
778 evas_object_geometry_get(target, &tx, &ty, &tw, &th);
779 evas_object_geometry_get(previous, &px, &py, &pw, &ph);
780 evas_object_move(obj, 0, 0);
781 evas_object_resize(obj, tw, th);
782 evas_object_clip_unset(obj);
784 m = alloca(sizeof(*m) + (sizeof(int) * 8));
794 edje_object_message_send(obj, EDJE_MESSAGE_INT_SET, 1, m);
798 _elm_win_focus_highlight_anim_end(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
801 _elm_win_focus_highlight_simple_setup(win, obj);
805 _elm_win_focus_highlight_reconfigure(Elm_Win *win)
807 Evas_Object *target = win->focus_highlight.cur.target;
808 Evas_Object *previous = win->focus_highlight.prev.target;
809 Evas_Object *top = win->focus_highlight.top;
810 Eina_Bool visible_changed;
811 Eina_Bool common_visible;
812 const char *sig = NULL;
814 _elm_win_focus_highlight_reconfigure_job_stop(win);
816 visible_changed = (win->focus_highlight.cur.visible !=
817 win->focus_highlight.prev.visible);
819 if ((target == previous) && (!visible_changed) &&
820 (!win->focus_highlight.geometry_changed))
823 if ((previous) && (win->focus_highlight.prev.handled))
824 elm_widget_signal_emit(previous, "elm,action,focus_highlight,hide", "elm");
827 common_visible = EINA_FALSE;
828 else if (win->focus_highlight.cur.handled)
830 common_visible = EINA_FALSE;
831 if (win->focus_highlight.cur.visible)
832 sig = "elm,action,focus_highlight,show";
834 sig = "elm,action,focus_highlight,hide";
837 common_visible = win->focus_highlight.cur.visible;
839 _elm_win_focus_highlight_visible_set(win, common_visible);
841 elm_widget_signal_emit(target, sig, "elm");
843 if ((!target) || (!common_visible) || (win->focus_highlight.cur.handled))
846 if (win->focus_highlight.changed_theme)
849 if (win->focus_highlight.style)
850 str = win->focus_highlight.style;
853 _elm_theme_object_set(win->win_obj, top, "focus_highlight", "top",
855 win->focus_highlight.changed_theme = EINA_FALSE;
857 if (_elm_config->focus_highlight_animate)
859 str = edje_object_data_get(win->focus_highlight.top, "animate");
860 win->focus_highlight.top_animate = ((str) && (!strcmp(str, "on")));
864 if ((win->focus_highlight.top_animate) && (previous) &&
865 (!win->focus_highlight.prev.handled))
866 _elm_win_focus_highlight_anim_setup(win, top);
868 _elm_win_focus_highlight_simple_setup(win, top);
869 evas_object_raise(top);
872 win->focus_highlight.geometry_changed = EINA_FALSE;
873 win->focus_highlight.prev = win->focus_highlight.cur;
878 _debug_key_down(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
880 Evas_Event_Key_Down *ev = event_info;
882 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
886 if ((strcmp(ev->keyname, "F12")) ||
887 (!evas_key_modifier_is_set(ev->modifiers, "Control")))
890 printf("Tree graph generated.\n");
891 elm_object_tree_dot_dump(obj, "./dump.dot");
896 * Adds a window object. If this is the first window created, pass NULL as
899 * @param parent Parent object to add the window to, or NULL
900 * @param name The name of the window
901 * @param type The window type, one of the following:
903 * ELM_WIN_DIALOG_BASIC
911 * @return The created object, or NULL on failure
916 elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type)
920 const char *fontpath;
922 win = ELM_NEW(Elm_Win);
924 #define FALLBACK_TRY(engine) \
927 CRITICAL(engine " engine creation failed. Trying software X11."); \
928 win->ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1); \
931 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
932 if (ENGINE_COMPARE(ELM_SOFTWARE_X11))
934 win->ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
935 #ifdef HAVE_ELEMENTARY_X
936 win->client_message_handler = ecore_event_handler_add
937 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
940 else if (ENGINE_COMPARE(ELM_SOFTWARE_FB))
942 win->ee = ecore_evas_fb_new(NULL, 0, 1, 1);
943 FALLBACK_TRY("Sofware FB");
945 else if (ENGINE_COMPARE(ELM_SOFTWARE_DIRECTFB))
947 win->ee = ecore_evas_directfb_new(NULL, 1, 0, 0, 1, 1);
948 FALLBACK_TRY("Sofware DirectFB");
950 else if (ENGINE_COMPARE(ELM_SOFTWARE_16_X11))
952 win->ee = ecore_evas_software_x11_16_new(NULL, 0, 0, 0, 1, 1);
953 FALLBACK_TRY("Sofware-16");
954 #ifdef HAVE_ELEMENTARY_X
955 win->client_message_handler = ecore_event_handler_add
956 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
959 else if (ENGINE_COMPARE(ELM_SOFTWARE_8_X11))
961 win->ee = ecore_evas_software_x11_8_new(NULL, 0, 0, 0, 1, 1);
962 FALLBACK_TRY("Sofware-8");
963 #ifdef HAVE_ELEMENTARY_X
964 win->client_message_handler = ecore_event_handler_add
965 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
968 else if (ENGINE_COMPARE(ELM_XRENDER_X11))
970 win->ee = ecore_evas_xrender_x11_new(NULL, 0, 0, 0, 1, 1);
971 FALLBACK_TRY("XRender");
972 #ifdef HAVE_ELEMENTARY_X
973 win->client_message_handler = ecore_event_handler_add
974 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
977 else if (ENGINE_COMPARE(ELM_OPENGL_X11))
979 win->ee = ecore_evas_gl_x11_new(NULL, 0, 0, 0, 1, 1);
980 FALLBACK_TRY("OpenGL");
981 #ifdef HAVE_ELEMENTARY_X
982 win->client_message_handler = ecore_event_handler_add
983 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
986 else if (ENGINE_COMPARE(ELM_SOFTWARE_WIN32))
988 win->ee = ecore_evas_software_gdi_new(NULL, 0, 0, 1, 1);
989 FALLBACK_TRY("Sofware Win32");
991 else if (ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE))
993 win->ee = ecore_evas_software_wince_gdi_new(NULL, 0, 0, 1, 1);
994 FALLBACK_TRY("Sofware-16-WinCE");
996 else if (ENGINE_COMPARE(ELM_SOFTWARE_SDL))
998 win->ee = ecore_evas_sdl_new(NULL, 0, 0, 0, 0, 0, 1);
999 FALLBACK_TRY("Sofware SDL");
1001 else if (ENGINE_COMPARE(ELM_SOFTWARE_16_SDL))
1003 win->ee = ecore_evas_sdl16_new(NULL, 0, 0, 0, 0, 0, 1);
1004 FALLBACK_TRY("Sofware-16-SDL");
1006 else if (ENGINE_COMPARE(ELM_OPENGL_SDL))
1008 win->ee = ecore_evas_gl_sdl_new(NULL, 1, 1, 0, 0);
1009 FALLBACK_TRY("OpenGL SDL");
1015 ERR("Cannot create window.");
1019 #ifdef HAVE_ELEMENTARY_X
1020 _elm_win_xwindow_get(win);
1022 if ((_elm_config->bgpixmap) && (!_elm_config->compositing))
1023 ecore_evas_avoid_damage_set(win->ee, ECORE_EVAS_AVOID_DAMAGE_EXPOSE);
1024 // bg pixmap done by x - has other issues like can be redrawn by x before it
1025 // is filled/ready by app
1026 // ecore_evas_avoid_damage_set(win->ee, ECORE_EVAS_AVOID_DAMAGE_BUILT_IN);
1029 win->parent = parent;
1031 evas_object_event_callback_add(win->parent, EVAS_CALLBACK_DEL,
1032 _elm_win_obj_callback_parent_del, win);
1034 win->evas = ecore_evas_get(win->ee);
1035 win->win_obj = elm_widget_add(win->evas);
1036 elm_widget_type_set(win->win_obj, "win");
1037 ELM_SET_WIDTYPE(widtype, "win");
1038 elm_widget_data_set(win->win_obj, win);
1039 elm_widget_event_hook_set(win->win_obj, _elm_win_event_cb);
1040 elm_widget_on_focus_hook_set(win->win_obj, _elm_win_on_focus_hook, NULL);
1041 elm_widget_can_focus_set(win->win_obj, EINA_TRUE);
1042 elm_widget_highlight_ignore_set(win->win_obj, EINA_TRUE);
1043 elm_widget_focus_next_hook_set(win->win_obj, _elm_win_focus_next_hook);
1044 evas_object_color_set(win->win_obj, 0, 0, 0, 0);
1045 evas_object_move(win->win_obj, 0, 0);
1046 evas_object_resize(win->win_obj, 1, 1);
1047 evas_object_layer_set(win->win_obj, 50);
1048 evas_object_pass_events_set(win->win_obj, EINA_TRUE);
1050 evas_object_intercept_show_callback_add(win->win_obj,
1051 _elm_win_obj_intercept_show, win);
1052 ecore_evas_object_associate(win->ee, win->win_obj,
1053 ECORE_EVAS_OBJECT_ASSOCIATE_BASE |
1054 ECORE_EVAS_OBJECT_ASSOCIATE_STACK |
1055 ECORE_EVAS_OBJECT_ASSOCIATE_LAYER);
1056 evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_SHOW,
1057 _elm_win_obj_callback_show, win);
1058 evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_DEL,
1059 _elm_win_obj_callback_del, win);
1061 ecore_evas_name_class_set(win->ee, name, _elm_appname);
1062 ecore_evas_callback_delete_request_set(win->ee, _elm_win_delete_request);
1063 ecore_evas_callback_resize_set(win->ee, _elm_win_resize);
1064 ecore_evas_callback_focus_in_set(win->ee, _elm_win_focus_in);
1065 ecore_evas_callback_focus_out_set(win->ee, _elm_win_focus_out);
1066 ecore_evas_callback_move_set(win->ee, _elm_win_move);
1067 evas_image_cache_set(win->evas, (_elm_config->image_cache * 1024));
1068 evas_font_cache_set(win->evas, (_elm_config->font_cache * 1024));
1069 EINA_LIST_FOREACH(_elm_config->font_dirs, l, fontpath)
1070 evas_font_path_append(win->evas, fontpath);
1071 if (!_elm_config->font_hinting)
1072 evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_NONE);
1073 else if (_elm_config->font_hinting == 1)
1074 evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_AUTO);
1075 else if (_elm_config->font_hinting == 2)
1076 evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_BYTECODE);
1078 #ifdef HAVE_ELEMENTARY_X
1079 _elm_win_xwin_update(win);
1082 _elm_win_list = eina_list_append(_elm_win_list, win->win_obj);
1084 if (ENGINE_COMPARE(ELM_SOFTWARE_FB))
1086 ecore_evas_fullscreen_set(win->ee, 1);
1088 #undef ENGINE_COMPARE
1090 if (_elm_config->focus_highlight_enable)
1091 elm_win_focus_highlight_enabled_set(win->win_obj, EINA_TRUE);
1094 Evas_Modifier_Mask mask = evas_key_modifier_mask_get(win->evas, "Control");
1095 evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_KEY_DOWN,
1096 _debug_key_down, win);
1097 Eina_Bool ret = evas_object_key_grab(win->win_obj, "F12", mask, 0, EINA_TRUE);
1098 printf("Key F12 exclusive for dot tree generation. (%d)\n", ret);
1100 return win->win_obj;
1104 * Add @p subobj as a resize object of window @p obj.
1106 * @param obj The window object
1107 * @param subobj The resize object to add
1112 elm_win_resize_object_add(Evas_Object *obj, Evas_Object *subobj)
1116 ELM_CHECK_WIDTYPE(obj, widtype);
1117 win = elm_widget_data_get(obj);
1119 win->subobjs = eina_list_append(win->subobjs, subobj);
1120 elm_widget_sub_object_add(obj, subobj);
1121 evas_object_event_callback_add(subobj, EVAS_CALLBACK_DEL,
1122 _elm_win_subobj_callback_del, obj);
1123 evas_object_event_callback_add(subobj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1124 _elm_win_subobj_callback_changed_size_hints,
1126 ecore_evas_geometry_get(win->ee, NULL, NULL, &w, &h);
1127 evas_object_move(subobj, 0, 0);
1128 evas_object_resize(subobj, w, h);
1129 _elm_win_eval_subobjs(obj);
1133 * Delete @p subobj as a resize object of window @p obj.
1135 * @param obj The window object
1136 * @param subobj The resize object to add
1141 elm_win_resize_object_del(Evas_Object *obj, Evas_Object *subobj)
1144 ELM_CHECK_WIDTYPE(obj, widtype);
1145 win = elm_widget_data_get(obj);
1147 evas_object_event_callback_del_full(subobj,
1148 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1149 _elm_win_subobj_callback_changed_size_hints,
1151 evas_object_event_callback_del_full(subobj, EVAS_CALLBACK_DEL,
1152 _elm_win_subobj_callback_del, obj);
1153 win->subobjs = eina_list_remove(win->subobjs, subobj);
1154 elm_widget_sub_object_del(obj, subobj);
1155 _elm_win_eval_subobjs(obj);
1159 * Set the title of the window
1161 * @param obj The window object
1162 * @param title The title to set
1167 elm_win_title_set(Evas_Object *obj, const char *title)
1170 ELM_CHECK_WIDTYPE(obj, widtype);
1171 win = elm_widget_data_get(obj);
1173 ecore_evas_title_set(win->ee, title);
1177 * Get the title of the window
1179 * @param obj The window object
1185 elm_win_title_get(const Evas_Object *obj)
1188 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1189 win = elm_widget_data_get(obj);
1190 if (!win) return NULL;
1191 return ecore_evas_title_get(win->ee);
1195 * Set the window's autodel state.
1197 * @param obj The window object
1198 * @param autodel If true, the window will automatically delete itself when closed
1203 elm_win_autodel_set(Evas_Object *obj, Eina_Bool autodel)
1206 ELM_CHECK_WIDTYPE(obj, widtype);
1207 win = elm_widget_data_get(obj);
1209 win->autodel = autodel;
1213 * Get the window's autodel state.
1215 * @param obj The window object
1216 * @return If the window will automatically delete itself when closed
1221 elm_win_autodel_get(const Evas_Object *obj)
1224 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1225 win = elm_widget_data_get(obj);
1226 if (!win) return EINA_FALSE;
1227 return win->autodel;
1231 * Activate a window object.
1233 * @param obj The window object
1238 elm_win_activate(Evas_Object *obj)
1241 ELM_CHECK_WIDTYPE(obj, widtype);
1242 win = elm_widget_data_get(obj);
1244 ecore_evas_activate(win->ee);
1248 * Lower a window object.
1250 * @param obj The window object
1255 elm_win_lower(Evas_Object *obj)
1258 ELM_CHECK_WIDTYPE(obj, widtype);
1259 win = elm_widget_data_get(obj);
1261 ecore_evas_lower(win->ee);
1265 * Raise a window object.
1267 * @param obj The window object
1272 elm_win_raise(Evas_Object *obj)
1275 ELM_CHECK_WIDTYPE(obj, widtype);
1276 win = elm_widget_data_get(obj);
1278 ecore_evas_raise(win->ee);
1282 * Set the borderless state of a window.
1284 * @param obj The window object
1285 * @param borderless If true, the window is borderless
1290 elm_win_borderless_set(Evas_Object *obj, Eina_Bool borderless)
1293 ELM_CHECK_WIDTYPE(obj, widtype);
1294 win = elm_widget_data_get(obj);
1296 ecore_evas_borderless_set(win->ee, borderless);
1297 #ifdef HAVE_ELEMENTARY_X
1298 _elm_win_xwin_update(win);
1303 * Get the borderless state of a window.
1305 * @param obj The window object
1306 * @return If true, the window is borderless
1311 elm_win_borderless_get(const Evas_Object *obj)
1314 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1315 win = elm_widget_data_get(obj);
1316 if (!win) return EINA_FALSE;
1317 return ecore_evas_borderless_get(win->ee);
1321 * Set the shaped state of a window.
1323 * @param obj The window object
1324 * @param shaped If true, the window is shaped
1329 elm_win_shaped_set(Evas_Object *obj, Eina_Bool shaped)
1332 ELM_CHECK_WIDTYPE(obj, widtype);
1333 win = elm_widget_data_get(obj);
1335 ecore_evas_shaped_set(win->ee, shaped);
1336 #ifdef HAVE_ELEMENTARY_X
1337 _elm_win_xwin_update(win);
1342 * Get the shaped state of a window.
1344 * @param obj The window object
1345 * @return If true, the window is shaped
1350 elm_win_shaped_get(const Evas_Object *obj)
1353 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1354 win = elm_widget_data_get(obj);
1355 if (!win) return EINA_FALSE;
1356 return ecore_evas_shaped_get(win->ee);
1360 * Set the alpha channel state of a window.
1362 * @param obj The window object
1363 * @param alpha If true, the window has an alpha channel
1368 elm_win_alpha_set(Evas_Object *obj, Eina_Bool alpha)
1371 ELM_CHECK_WIDTYPE(obj, widtype);
1372 win = elm_widget_data_get(obj);
1374 #ifdef HAVE_ELEMENTARY_X
1379 if (!_elm_config->compositing)
1380 elm_win_shaped_set(obj, alpha);
1382 ecore_evas_alpha_set(win->ee, alpha);
1385 ecore_evas_alpha_set(win->ee, alpha);
1386 _elm_win_xwin_update(win);
1390 ecore_evas_alpha_set(win->ee, alpha);
1394 * Get the alpha channel state of a window.
1396 * @param obj The window object
1397 * @return If true, the window has an alpha channel
1402 elm_win_alpha_get(const Evas_Object *obj)
1405 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1406 win = elm_widget_data_get(obj);
1407 if (!win) return EINA_FALSE;
1408 return ecore_evas_alpha_get(win->ee);
1412 * Set the transparency state of a window.
1414 * @param obj The window object
1415 * @param transparent If true, the window is transparent
1420 elm_win_transparent_set(Evas_Object *obj, Eina_Bool transparent)
1423 ELM_CHECK_WIDTYPE(obj, widtype);
1424 win = elm_widget_data_get(obj);
1427 #ifdef HAVE_ELEMENTARY_X
1430 ecore_evas_transparent_set(win->ee, transparent);
1431 _elm_win_xwin_update(win);
1435 ecore_evas_transparent_set(win->ee, transparent);
1439 * Get the transparency state of a window.
1441 * @param obj The window object
1442 * @return If true, the window is transparent
1447 elm_win_transparent_get(const Evas_Object *obj)
1450 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1451 win = elm_widget_data_get(obj);
1452 if (!win) return EINA_FALSE;
1454 return ecore_evas_transparent_get(win->ee);
1458 * Set the override state of a window.
1460 * @param obj The window object
1461 * @param override If true, the window is overridden
1466 elm_win_override_set(Evas_Object *obj, Eina_Bool override)
1469 ELM_CHECK_WIDTYPE(obj, widtype);
1470 win = elm_widget_data_get(obj);
1472 ecore_evas_override_set(win->ee, override);
1473 #ifdef HAVE_ELEMENTARY_X
1474 _elm_win_xwin_update(win);
1479 * Get the override state of a window.
1481 * @param obj The window object
1482 * @return If true, the window is overridden
1487 elm_win_override_get(const Evas_Object *obj)
1490 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1491 win = elm_widget_data_get(obj);
1492 if (!win) return EINA_FALSE;
1493 return ecore_evas_override_get(win->ee);
1497 * Set the fullscreen state of a window.
1499 * @param obj The window object
1500 * @param fullscreen If true, the window is fullscreen
1505 elm_win_fullscreen_set(Evas_Object *obj, Eina_Bool fullscreen)
1508 ELM_CHECK_WIDTYPE(obj, widtype);
1509 win = elm_widget_data_get(obj);
1512 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
1513 if (ENGINE_COMPARE(ELM_SOFTWARE_FB) ||
1514 ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE))
1516 // these engines... can ONLY be fullscreen
1521 ecore_evas_fullscreen_set(win->ee, fullscreen);
1522 #ifdef HAVE_ELEMENTARY_X
1523 _elm_win_xwin_update(win);
1526 #undef ENGINE_COMPARE
1530 * Get the fullscreen state of a window.
1532 * @param obj The window object
1533 * @return If true, the window is fullscreen
1538 elm_win_fullscreen_get(const Evas_Object *obj)
1541 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1542 win = elm_widget_data_get(obj);
1543 if (!win) return EINA_FALSE;
1545 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
1546 if (ENGINE_COMPARE(ELM_SOFTWARE_FB) ||
1547 ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE))
1549 // these engines... can ONLY be fullscreen
1554 return ecore_evas_fullscreen_get(win->ee);
1556 #undef ENGINE_COMPARE
1560 * Set the maximized state of a window.
1562 * @param obj The window object
1563 * @param maximized If true, the window is maximized
1568 elm_win_maximized_set(Evas_Object *obj, Eina_Bool maximized)
1571 ELM_CHECK_WIDTYPE(obj, widtype);
1572 win = elm_widget_data_get(obj);
1574 ecore_evas_maximized_set(win->ee, maximized);
1575 #ifdef HAVE_ELEMENTARY_X
1576 _elm_win_xwin_update(win);
1581 * Get the maximized state of a window.
1583 * @param obj The window object
1584 * @return If true, the window is maximized
1589 elm_win_maximized_get(const Evas_Object *obj)
1592 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1593 win = elm_widget_data_get(obj);
1594 if (!win) return EINA_FALSE;
1595 return ecore_evas_maximized_get(win->ee);
1599 * Set the iconified state of a window.
1601 * @param obj The window object
1602 * @param iconified If true, the window is iconified
1607 elm_win_iconified_set(Evas_Object *obj, Eina_Bool iconified)
1610 ELM_CHECK_WIDTYPE(obj, widtype);
1611 win = elm_widget_data_get(obj);
1613 ecore_evas_iconified_set(win->ee, iconified);
1614 #ifdef HAVE_ELEMENTARY_X
1615 _elm_win_xwin_update(win);
1620 * Get the iconified state of a window.
1622 * @param obj The window object
1623 * @return If true, the window is iconified
1628 elm_win_iconified_get(const Evas_Object *obj)
1631 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1632 win = elm_widget_data_get(obj);
1633 if (!win) return EINA_FALSE;
1634 return ecore_evas_iconified_get(win->ee);
1638 * Set the layer of the window.
1640 * @param obj The window object
1641 * @param layer The layer of the window
1646 elm_win_layer_set(Evas_Object *obj, int layer)
1649 ELM_CHECK_WIDTYPE(obj, widtype);
1650 win = elm_widget_data_get(obj);
1652 ecore_evas_layer_set(win->ee, layer);
1653 #ifdef HAVE_ELEMENTARY_X
1654 _elm_win_xwin_update(win);
1659 * Get the layer of the window.
1661 * @param obj The window object
1662 * @return The layer of the window
1667 elm_win_layer_get(const Evas_Object *obj)
1670 ELM_CHECK_WIDTYPE(obj, widtype) -1;
1671 win = elm_widget_data_get(obj);
1672 if (!win) return -1;
1673 return ecore_evas_layer_get(win->ee);
1677 * Set the rotation of the window.
1679 * @param obj The window object
1680 * @param rotation The rotation of the window, in degrees (0-360)
1685 elm_win_rotation_set(Evas_Object *obj, int rotation)
1688 ELM_CHECK_WIDTYPE(obj, widtype);
1689 win = elm_widget_data_get(obj);
1691 if (win->rot == rotation) return;
1692 win->rot = rotation;
1693 ecore_evas_rotation_set(win->ee, rotation);
1694 evas_object_size_hint_min_set(obj, -1, -1);
1695 evas_object_size_hint_max_set(obj, -1, -1);
1696 _elm_win_eval_subobjs(obj);
1697 #ifdef HAVE_ELEMENTARY_X
1698 _elm_win_xwin_update(win);
1703 * Rotates the window and resizes it
1705 * @param obj The window object
1706 * @param layer The rotation of the window in degrees (0-360)
1711 elm_win_rotation_with_resize_set(Evas_Object *obj, int rotation)
1714 ELM_CHECK_WIDTYPE(obj, widtype);
1715 win = elm_widget_data_get(obj);
1717 if (win->rot == rotation) return;
1718 win->rot = rotation;
1719 ecore_evas_rotation_with_resize_set(win->ee, rotation);
1720 evas_object_size_hint_min_set(obj, -1, -1);
1721 evas_object_size_hint_max_set(obj, -1, -1);
1722 _elm_win_eval_subobjs(obj);
1723 #ifdef HAVE_ELEMENTARY_X
1724 _elm_win_xwin_update(win);
1729 * Get the rotation of the window.
1731 * @param obj The window object
1732 * @return The rotation of the window in degrees (0-360)
1737 elm_win_rotation_get(const Evas_Object *obj)
1740 ELM_CHECK_WIDTYPE(obj, widtype) -1;
1741 win = elm_widget_data_get(obj);
1742 if (!win) return -1;
1747 * Set the sticky state of the window.
1749 * @param obj The window object
1750 * @param sticky If true, the window's sticky state is enabled
1755 elm_win_sticky_set(Evas_Object *obj, Eina_Bool sticky)
1758 ELM_CHECK_WIDTYPE(obj, widtype);
1759 win = elm_widget_data_get(obj);
1761 ecore_evas_sticky_set(win->ee, sticky);
1762 #ifdef HAVE_ELEMENTARY_X
1763 _elm_win_xwin_update(win);
1768 * Get the sticky state of the window.
1770 * @param obj The window object
1771 * @return If true, the window's sticky state is enabled
1776 elm_win_sticky_get(const Evas_Object *obj)
1779 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1780 win = elm_widget_data_get(obj);
1781 if (!win) return EINA_FALSE;
1782 return ecore_evas_sticky_get(win->ee);
1786 * Sets the keyboard mode of the window.
1788 * @param obj The window object
1789 * @param mode The mode to set; one of:
1790 * ELM_WIN_KEYBOARD_UNKNOWN
1791 * ELM_WIN_KEYBOARD_OFF
1792 * ELM_WIN_KEYBOARD_ON
1793 * ELM_WIN_KEYBOARD_ALPHA
1794 * ELM_WIN_KEYBOARD_NUMERIC
1795 * ELM_WIN_KEYBOARD_PIN
1796 * ELM_WIN_KEYBOARD_PHONE_NUMBER
1797 * ELM_WIN_KEYBOARD_HEX
1798 * ELM_WIN_KEYBOARD_TERMINAL
1799 * ELM_WIN_KEYBOARD_PASSWORD
1800 * ELM_WIN_KEYBOARD_IP
1801 * ELM_WIN_KEYBOARD_HOST
1802 * ELM_WIN_KEYBOARD_FILE
1803 * ELM_WIN_KEYBOARD_URL
1804 * ELM_WIN_KEYBOARD_KEYPAD
1805 * ELM_WIN_KEYBOARD_J2ME
1810 elm_win_keyboard_mode_set(Evas_Object *obj, Elm_Win_Keyboard_Mode mode)
1813 ELM_CHECK_WIDTYPE(obj, widtype);
1814 win = elm_widget_data_get(obj);
1816 if (mode == win->kbdmode) return;
1817 #ifdef HAVE_ELEMENTARY_X
1818 _elm_win_xwindow_get(win);
1820 win->kbdmode = mode;
1821 #ifdef HAVE_ELEMENTARY_X
1823 ecore_x_e_virtual_keyboard_state_set
1824 (win->xwin, (Ecore_X_Virtual_Keyboard_State)win->kbdmode);
1829 * Gets the keyboard mode of the window.
1831 * @param obj The window object
1832 * @return The mode; one of:
1833 * ELM_WIN_KEYBOARD_UNKNOWN
1834 * ELM_WIN_KEYBOARD_OFF
1835 * ELM_WIN_KEYBOARD_ON
1836 * ELM_WIN_KEYBOARD_ALPHA
1837 * ELM_WIN_KEYBOARD_NUMERIC
1838 * ELM_WIN_KEYBOARD_PIN
1839 * ELM_WIN_KEYBOARD_PHONE_NUMBER
1840 * ELM_WIN_KEYBOARD_HEX
1841 * ELM_WIN_KEYBOARD_TERMINAL
1842 * ELM_WIN_KEYBOARD_PASSWORD
1843 * ELM_WIN_KEYBOARD_IP
1844 * ELM_WIN_KEYBOARD_HOST
1845 * ELM_WIN_KEYBOARD_FILE
1846 * ELM_WIN_KEYBOARD_URL
1847 * ELM_WIN_KEYBOARD_KEYPAD
1848 * ELM_WIN_KEYBOARD_J2ME
1852 EAPI Elm_Win_Keyboard_Mode
1853 elm_win_keyboard_mode_get(const Evas_Object *obj)
1856 ELM_CHECK_WIDTYPE(obj, widtype) ELM_WIN_KEYBOARD_UNKNOWN;
1857 win = elm_widget_data_get(obj);
1858 if (!win) return ELM_WIN_KEYBOARD_UNKNOWN;
1859 return win->kbdmode;
1863 * Sets whether the window is a keyboard.
1865 * @param obj The window object
1866 * @param is_keyboard If true, the window is a virtual keyboard
1871 elm_win_keyboard_win_set(Evas_Object *obj, Eina_Bool is_keyboard)
1874 ELM_CHECK_WIDTYPE(obj, widtype);
1875 win = elm_widget_data_get(obj);
1877 #ifdef HAVE_ELEMENTARY_X
1878 _elm_win_xwindow_get(win);
1880 ecore_x_e_virtual_keyboard_set(win->xwin, is_keyboard);
1885 * Gets whether the window is a keyboard.
1887 * @param obj The window object
1888 * @return If the window is a virtual keyboard
1893 elm_win_keyboard_win_get(const Evas_Object *obj)
1896 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1897 win = elm_widget_data_get(obj);
1898 if (!win) return EINA_FALSE;
1899 #ifdef HAVE_ELEMENTARY_X
1900 _elm_win_xwindow_get(win);
1902 return ecore_x_e_virtual_keyboard_get(win->xwin);
1908 * Get the screen position of a window.
1910 * @param obj The window object
1911 * @param x The int to store the x coordinate to
1912 * @param y The int to store the y coordinate to
1917 elm_win_screen_position_get(const Evas_Object *obj, int *x, int *y)
1920 ELM_CHECK_WIDTYPE(obj, widtype);
1921 win = elm_widget_data_get(obj);
1923 if (x) *x = win->screen.x;
1924 if (y) *y = win->screen.y;
1928 * Set if this window is an illume conformant window
1930 * @param obj The window object
1931 * @param conformant The conformant flag (1 = conformant, 0 = non-conformant)
1936 elm_win_conformant_set(Evas_Object *obj, Eina_Bool conformant)
1939 ELM_CHECK_WIDTYPE(obj, widtype);
1940 win = elm_widget_data_get(obj);
1942 #ifdef HAVE_ELEMENTARY_X
1943 _elm_win_xwindow_get(win);
1945 ecore_x_e_illume_conformant_set(win->xwin, conformant);
1950 * Get if this window is an illume conformant window
1952 * @param obj The window object
1953 * @return A boolean if this window is illume conformant or not
1958 elm_win_conformant_get(const Evas_Object *obj)
1961 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1962 win = elm_widget_data_get(obj);
1963 if (!win) return EINA_FALSE;
1964 #ifdef HAVE_ELEMENTARY_X
1965 _elm_win_xwindow_get(win);
1967 return ecore_x_e_illume_conformant_get(win->xwin);
1973 * Set a window to be an illume quickpanel window
1975 * By default window objects are not quickpanel windows.
1977 * @param obj The window object
1978 * @param quickpanel The quickpanel flag (1 = quickpanel, 0 = normal window)
1983 elm_win_quickpanel_set(Evas_Object *obj, Eina_Bool quickpanel)
1986 ELM_CHECK_WIDTYPE(obj, widtype);
1987 win = elm_widget_data_get(obj);
1989 #ifdef HAVE_ELEMENTARY_X
1990 _elm_win_xwindow_get(win);
1993 ecore_x_e_illume_quickpanel_set(win->xwin, quickpanel);
1996 Ecore_X_Window_State states[2];
1998 states[0] = ECORE_X_WINDOW_STATE_SKIP_TASKBAR;
1999 states[1] = ECORE_X_WINDOW_STATE_SKIP_PAGER;
2000 ecore_x_netwm_window_state_set(win->xwin, states, 2);
2001 ecore_x_icccm_hints_set(win->xwin, 0, 0, 0, 0, 0, 0, 0);
2008 * Get if this window is a quickpanel or not
2010 * @param obj The window object
2011 * @return A boolean if this window is a quickpanel or not
2016 elm_win_quickpanel_get(const Evas_Object *obj)
2019 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2020 win = elm_widget_data_get(obj);
2021 if (!win) return EINA_FALSE;
2022 #ifdef HAVE_ELEMENTARY_X
2023 _elm_win_xwindow_get(win);
2025 return ecore_x_e_illume_quickpanel_get(win->xwin);
2031 * Set the major priority of a quickpanel window
2033 * @param obj The window object
2034 * @param priority The major priority for this quickpanel
2039 elm_win_quickpanel_priority_major_set(Evas_Object *obj, int priority)
2042 ELM_CHECK_WIDTYPE(obj, widtype);
2043 win = elm_widget_data_get(obj);
2045 #ifdef HAVE_ELEMENTARY_X
2046 _elm_win_xwindow_get(win);
2048 ecore_x_e_illume_quickpanel_priority_major_set(win->xwin, priority);
2053 * Get the major priority of a quickpanel window
2055 * @param obj The window object
2056 * @return The major priority of this quickpanel
2061 elm_win_quickpanel_priority_major_get(const Evas_Object *obj)
2064 ELM_CHECK_WIDTYPE(obj, widtype) -1;
2065 win = elm_widget_data_get(obj);
2066 if (!win) return -1;
2067 #ifdef HAVE_ELEMENTARY_X
2068 _elm_win_xwindow_get(win);
2070 return ecore_x_e_illume_quickpanel_priority_major_get(win->xwin);
2076 * Set the minor priority of a quickpanel window
2078 * @param obj The window object
2079 * @param priority The minor priority for this quickpanel
2084 elm_win_quickpanel_priority_minor_set(Evas_Object *obj, int priority)
2087 ELM_CHECK_WIDTYPE(obj, widtype);
2088 win = elm_widget_data_get(obj);
2090 #ifdef HAVE_ELEMENTARY_X
2091 _elm_win_xwindow_get(win);
2093 ecore_x_e_illume_quickpanel_priority_minor_set(win->xwin, priority);
2098 * Get the minor priority of a quickpanel window
2100 * @param obj The window object
2101 * @return The minor priority of this quickpanel
2106 elm_win_quickpanel_priority_minor_get(const Evas_Object *obj)
2109 ELM_CHECK_WIDTYPE(obj, widtype) -1;
2110 win = elm_widget_data_get(obj);
2111 if (!win) return -1;
2112 #ifdef HAVE_ELEMENTARY_X
2113 _elm_win_xwindow_get(win);
2115 return ecore_x_e_illume_quickpanel_priority_minor_get(win->xwin);
2121 * Set which zone this quickpanel should appear in
2123 * @param obj The window object
2124 * @param zone The requested zone for this quickpanel
2129 elm_win_quickpanel_zone_set(Evas_Object *obj, int zone)
2132 ELM_CHECK_WIDTYPE(obj, widtype);
2133 win = elm_widget_data_get(obj);
2135 #ifdef HAVE_ELEMENTARY_X
2136 _elm_win_xwindow_get(win);
2138 ecore_x_e_illume_quickpanel_zone_set(win->xwin, zone);
2143 * Get which zone this quickpanel should appear in
2145 * @param obj The window object
2146 * @return The requested zone for this quickpanel
2151 elm_win_quickpanel_zone_get(const Evas_Object *obj)
2154 ELM_CHECK_WIDTYPE(obj, widtype) 0;
2155 win = elm_widget_data_get(obj);
2157 #ifdef HAVE_ELEMENTARY_X
2158 _elm_win_xwindow_get(win);
2160 return ecore_x_e_illume_quickpanel_zone_get(win->xwin);
2166 * Set the enabled status for the focus highlight in a window
2168 * This function will enable or disable the focus highlight only for the
2169 * given window, regardless of the global setting for it
2171 * @param obj The window where to enable the highlight
2172 * @param enabled The enabled value for the highlight
2177 elm_win_focus_highlight_enabled_set(Evas_Object *obj, Eina_Bool enabled)
2181 ELM_CHECK_WIDTYPE(obj, widtype);
2183 win = elm_widget_data_get(obj);
2184 enabled = !!enabled;
2185 if (win->focus_highlight.enabled == enabled)
2188 win->focus_highlight.enabled = enabled;
2190 if (win->focus_highlight.enabled)
2191 _elm_win_focus_highlight_init(win);
2193 _elm_win_focus_highlight_shutdown(win);
2197 * Get the enabled value of the focus highlight for this window
2199 * @param obj The window in which to check if the focus highlight is enabled
2201 * @return EINA_TRUE if enabled, EINA_FALSE otherwise
2206 elm_win_focus_highlight_enabled_get(const Evas_Object *obj)
2210 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2212 win = elm_widget_data_get(obj);
2213 return win->focus_highlight.enabled;
2217 * Set the style for the focus highlight on this window
2219 * Sets the style to use for theming the highlight of focused objects on
2220 * the given window. If @p style is NULL, the default will be used.
2222 * @param obj The window where to set the style
2223 * @param style The style to set
2228 elm_win_focus_highlight_style_set(Evas_Object *obj, const char *style)
2232 ELM_CHECK_WIDTYPE(obj, widtype);
2234 win = elm_widget_data_get(obj);
2235 eina_stringshare_replace(&win->focus_highlight.style, style);
2236 win->focus_highlight.changed_theme = EINA_TRUE;
2237 _elm_win_focus_highlight_reconfigure_job_start(win);
2241 * Get the style set for the focus highlight object
2243 * Gets the style set for this windows highilght object, or NULL if none
2246 * @param obj The window to retrieve the highlights style from
2248 * @return The style set or NULL if none was. Default is used in that case.
2253 elm_win_focus_highlight_style_get(const Evas_Object *obj)
2257 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2259 win = elm_widget_data_get(obj);
2260 return win->focus_highlight.style;
2264 elm_win_indicator_state_set(Evas_Object *obj, int show_state)
2267 if (strcmp(elm_widget_type_get(obj), "win")) return;
2268 win = elm_widget_data_get(obj);
2270 _elm_win_xwindow_get(win);
2271 #ifdef HAVE_ELEMENTARY_X
2273 return ecore_x_window_prop_property_set (win->xwin,
2274 ECORE_X_ATOM_E_ILLUME_INDICATOR_STATE, ECORE_X_ATOM_CARDINAL, 32, &show_state, 1);
2280 elm_win_indicator_state_get(Evas_Object *obj)
2283 if (strcmp(elm_widget_type_get(obj), "win")) return -1;
2284 win = elm_widget_data_get(obj);
2285 if (!win) return -1;
2286 _elm_win_xwindow_get(win);
2287 #ifdef HAVE_ELEMENTARY_X
2293 unsigned int *prop_data = NULL;
2295 ret = ecore_x_window_prop_property_get (win->xwin,
2296 ECORE_X_ATOM_E_ILLUME_INDICATOR_STATE, ECORE_X_ATOM_CARDINAL, 32, &prop_data, &count);
2297 if( ret && prop_data )
2298 memcpy (&show, prop_data, sizeof (int));
2300 if (prop_data) free (prop_data);
2309 typedef struct _Widget_Data Widget_Data;
2314 Evas_Object *content;
2317 static void _del_hook(Evas_Object *obj);
2318 static void _theme_hook(Evas_Object *obj);
2319 static void _sizing_eval(Evas_Object *obj);
2320 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
2321 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
2323 static const char *widtype2 = NULL;
2326 _del_hook(Evas_Object *obj)
2328 Widget_Data *wd = elm_widget_data_get(obj);
2334 _theme_hook(Evas_Object *obj)
2336 Widget_Data *wd = elm_widget_data_get(obj);
2337 _elm_theme_object_set(obj, wd->frm, "win", "inwin", elm_widget_style_get(obj));
2339 edje_object_part_swallow(wd->frm, "elm.swallow.content", wd->content);
2344 _elm_inwin_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
2346 Widget_Data *wd = elm_widget_data_get(obj);
2351 /* Try Focus cycle in subitem */
2354 elm_widget_focus_next_get(wd->content, dir, next);
2359 *next = (Evas_Object *)obj;
2364 _sizing_eval(Evas_Object *obj)
2366 Widget_Data *wd = elm_widget_data_get(obj);
2367 Evas_Coord minw = -1, minh = -1;
2369 evas_object_size_hint_min_get(wd->content, &minw, &minh);
2370 edje_object_size_min_calc(wd->frm, &minw, &minh);
2371 evas_object_size_hint_min_set(obj, minw, minh);
2372 evas_object_size_hint_max_set(obj, -1, -1);
2376 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2382 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
2384 Widget_Data *wd = elm_widget_data_get(obj);
2385 Evas_Object *sub = event_info;
2386 if (sub == wd->content)
2388 evas_object_event_callback_del_full
2389 (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
2396 * @defgroup Inwin Inwin
2398 * An inwin is a window inside a window that is useful for a quick popup. It does not hover.
2401 elm_win_inwin_add(Evas_Object *obj)
2407 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2408 win = elm_widget_data_get(obj);
2409 if (!win) return NULL;
2410 wd = ELM_NEW(Widget_Data);
2411 obj2 = elm_widget_add(win->evas);
2412 elm_widget_type_set(obj2, "inwin");
2413 ELM_SET_WIDTYPE(widtype2, "inwin");
2414 elm_widget_sub_object_add(obj, obj2);
2415 evas_object_size_hint_weight_set(obj2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2416 evas_object_size_hint_align_set(obj2, EVAS_HINT_FILL, EVAS_HINT_FILL);
2417 elm_win_resize_object_add(obj, obj2);
2419 elm_widget_data_set(obj2, wd);
2420 elm_widget_del_hook_set(obj2, _del_hook);
2421 elm_widget_theme_hook_set(obj2, _theme_hook);
2422 elm_widget_focus_next_hook_set(obj2, _elm_inwin_focus_next_hook);
2423 elm_widget_can_focus_set(obj2, EINA_TRUE);
2424 elm_widget_highlight_ignore_set(obj2, EINA_TRUE);
2426 wd->frm = edje_object_add(win->evas);
2427 _elm_theme_object_set(obj, wd->frm, "win", "inwin", "default");
2428 elm_widget_resize_object_set(obj2, wd->frm);
2430 evas_object_smart_callback_add(obj2, "sub-object-del", _sub_del, obj2);
2437 * Activates an inwin object
2439 * @param obj The inwin to activate
2444 elm_win_inwin_activate(Evas_Object *obj)
2446 ELM_CHECK_WIDTYPE(obj, widtype2);
2447 Widget_Data *wd = elm_widget_data_get(obj);
2449 evas_object_raise(obj);
2450 evas_object_show(obj);
2451 edje_object_signal_emit(wd->frm, "elm,action,show", "elm");
2452 elm_object_focus(obj);
2456 * Set the content of an inwin object.
2458 * Once the content object is set, a previously set one will be deleted.
2459 * If you want to keep that old content object, use the
2460 * elm_win_inwin_content_unset() function.
2462 * @param obj The inwin object
2463 * @param content The object to set as content
2468 elm_win_inwin_content_set(Evas_Object *obj, Evas_Object *content)
2470 ELM_CHECK_WIDTYPE(obj, widtype2);
2471 Widget_Data *wd = elm_widget_data_get(obj);
2473 if (wd->content == content) return;
2474 if (wd->content) evas_object_del(wd->content);
2475 wd->content = content;
2478 elm_widget_sub_object_add(obj, content);
2479 evas_object_event_callback_add(content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
2480 _changed_size_hints, obj);
2481 edje_object_part_swallow(wd->frm, "elm.swallow.content", content);
2487 * Get the content of an inwin object.
2489 * Return the content object which is set for this widget.
2491 * @param obj The inwin object
2492 * @return The content that is being used
2497 elm_win_inwin_content_get(const Evas_Object *obj)
2499 ELM_CHECK_WIDTYPE(obj, widtype2) NULL;
2500 Widget_Data *wd = elm_widget_data_get(obj);
2501 if (!wd) return NULL;
2506 * Unset the content of an inwin object.
2508 * Unparent and return the content object which was set for this widget.
2510 * @param obj The inwin object
2511 * @return The content that was being used
2516 elm_win_inwin_content_unset(Evas_Object *obj)
2518 ELM_CHECK_WIDTYPE(obj, widtype2) NULL;
2519 Widget_Data *wd = elm_widget_data_get(obj);
2520 if (!wd) return NULL;
2521 if (!wd->content) return NULL;
2522 Evas_Object *content = wd->content;
2523 elm_widget_sub_object_del(obj, wd->content);
2524 edje_object_part_unswallow(wd->frm, wd->content);
2529 /* windowing spcific calls - shall we do this differently? */
2531 * Get the Ecore_X_Window of an Evas_Object
2533 * @param obj The object
2535 * @return The Ecore_X_Window of @p obj
2540 elm_win_xwindow_get(const Evas_Object *obj)
2542 Ecore_X_Window xwin = 0;
2543 Ecore_Evas *ee = NULL;
2545 #ifdef HAVE_ELEMENTARY_X
2546 ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
2547 if (ee) xwin = (Ecore_X_Window)ecore_evas_window_get(ee);