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;
35 static const char *widtype = NULL;
36 static void _elm_win_obj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
37 static void _elm_win_obj_callback_parent_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
38 static void _elm_win_obj_intercept_show(void *data, Evas_Object *obj);
39 static void _elm_win_move(Ecore_Evas *ee);
40 static void _elm_win_resize(Ecore_Evas *ee);
41 static void _elm_win_delete_request(Ecore_Evas *ee);
42 static void _elm_win_resize_job(void *data);
43 #ifdef HAVE_ELEMENTARY_X
44 static void _elm_win_xwin_update(Elm_Win *win);
46 static void _elm_win_eval_subobjs(Evas_Object *obj);
47 static void _elm_win_subobj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
48 static void _elm_win_subobj_callback_changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
50 Eina_List *_elm_win_list = NULL;
53 _elm_win_move(Ecore_Evas *ee)
55 Evas_Object *obj = ecore_evas_object_associate_get(ee);
60 win = elm_widget_data_get(obj);
62 ecore_evas_geometry_get(ee, &x, &y, NULL, NULL);
65 evas_object_smart_callback_call(win->win_obj, "moved", NULL);
69 _elm_win_resize(Ecore_Evas *ee)
71 Evas_Object *obj = ecore_evas_object_associate_get(ee);
75 win = elm_widget_data_get(obj);
77 if (win->deferred_resize_job) ecore_job_del(win->deferred_resize_job);
78 win->deferred_resize_job = ecore_job_add(_elm_win_resize_job, win);
82 _elm_win_focus_in(Ecore_Evas *ee)
84 Evas_Object *obj = ecore_evas_object_associate_get(ee);
88 win = elm_widget_data_get(obj);
90 /*NB: Why two different "focus signals" here ??? */
91 evas_object_smart_callback_call(win->win_obj, "focus-in", NULL); // FIXME: remove me
92 evas_object_smart_callback_call(win->win_obj, "focus,in", NULL);
96 _elm_win_focus_out(Ecore_Evas *ee)
98 Evas_Object *obj = ecore_evas_object_associate_get(ee);
102 win = elm_widget_data_get(obj);
104 evas_object_smart_callback_call(win->win_obj, "focus-out", NULL); // FIXME: remove me
105 evas_object_smart_callback_call(win->win_obj, "focus,out", NULL);
109 _deferred_ecore_evas_free(void *data)
111 ecore_evas_free(data);
115 _elm_win_obj_callback_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
122 evas_object_event_callback_del_full(win->parent, EVAS_CALLBACK_DEL,
123 _elm_win_obj_callback_parent_del, win);
126 if (win->autodel_clear) *(win->autodel_clear) = -1;
127 _elm_win_list = eina_list_remove(_elm_win_list, win->win_obj);
128 while (win->subobjs) elm_win_resize_object_del(obj, win->subobjs->data);
129 ecore_evas_callback_delete_request_set(win->ee, NULL);
130 ecore_evas_callback_resize_set(win->ee, NULL);
131 if (win->deferred_resize_job) ecore_job_del(win->deferred_resize_job);
132 if (win->deferred_child_eval_job) ecore_job_del(win->deferred_child_eval_job);
133 while (((child = evas_object_bottom_get(win->evas)) != NULL) &&
136 evas_object_del(child);
138 while (((child = evas_object_top_get(win->evas)) != NULL) &&
141 evas_object_del(child);
143 #ifdef HAVE_ELEMENTARY_X
144 if (win->client_message_handler)
145 ecore_event_handler_del(win->client_message_handler);
147 // FIXME: Why are we flushing edje on every window destroy ??
148 // evas_image_cache_flush(win->evas);
149 // evas_font_cache_flush(win->evas);
150 // edje_file_cache_flush();
151 // edje_collection_cache_flush();
152 // FIXME: we are in the del handler for the object and delete the canvas
153 // that lives under it from the handler... nasty. deferring doesnt help either
154 ecore_job_add(_deferred_ecore_evas_free, win->ee);
155 // ecore_evas_free(win->ee);
158 if ((!_elm_win_list) &&
159 (elm_policy_get(ELM_POLICY_QUIT) == ELM_POLICY_QUIT_LAST_WINDOW_CLOSED))
161 evas_image_cache_flush(e);
162 evas_font_cache_flush(e);
163 edje_file_cache_flush();
164 edje_collection_cache_flush();
170 _elm_win_obj_callback_parent_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
173 if (obj == win->parent) win->parent = NULL;
177 _elm_win_obj_intercept_show(void *data __UNUSED__, Evas_Object *obj)
179 // this is called to make sure all smart containers have calculated their
180 // sizes BEFORE we show the window to make sure it initially appears at
181 // our desired size (ie min size is known first)
182 evas_smart_objects_calculate(evas_object_evas_get(obj));
183 evas_object_show(obj);
187 _elm_win_delete_request(Ecore_Evas *ee)
189 Evas_Object *obj = ecore_evas_object_associate_get(ee);
191 if (strcmp(elm_widget_type_get(obj), "win")) return;
193 win = elm_widget_data_get(obj);
195 int autodel = win->autodel;
196 win->autodel_clear = &autodel;
197 evas_object_smart_callback_call(win->win_obj, "delete-request", NULL); // FIXME: remove me
198 evas_object_smart_callback_call(win->win_obj, "delete,request", NULL);
199 // FIXME: if above callback deletes - then the below will be invalid
200 if (autodel) evas_object_del(win->win_obj);
201 else win->autodel_clear = NULL;
205 _elm_win_resize_job(void *data)
212 win->deferred_resize_job = NULL;
213 ecore_evas_geometry_get(win->ee, NULL, NULL, &w, &h);
214 evas_object_resize(win->win_obj, w, h);
215 EINA_LIST_FOREACH(win->subobjs, l, obj)
217 evas_object_move(obj, 0, 0);
218 evas_object_resize(obj, w, h);
222 #ifdef HAVE_ELEMENTARY_X
224 _elm_win_xwindow_get(Elm_Win *win)
227 switch (_elm_config->engine)
229 case ELM_SOFTWARE_X11:
230 if (win->ee) win->xwin = ecore_evas_software_x11_window_get(win->ee);
232 case ELM_SOFTWARE_FB:
233 case ELM_SOFTWARE_DIRECTFB:
234 case ELM_SOFTWARE_16_WINCE:
235 case ELM_SOFTWARE_SDL:
236 case ELM_SOFTWARE_16_SDL:
239 case ELM_SOFTWARE_16_X11:
240 if (win->ee) win->xwin = ecore_evas_software_x11_16_window_get(win->ee);
242 case ELM_XRENDER_X11:
243 if (win->ee) win->xwin = ecore_evas_xrender_x11_window_get(win->ee);
246 if (win->ee) win->xwin = ecore_evas_gl_x11_window_get(win->ee);
248 case ELM_SOFTWARE_WIN32:
249 if (win->ee) win->xwin = (long)ecore_evas_win32_window_get(win->ee);
257 #ifdef HAVE_ELEMENTARY_X
259 _elm_win_xwin_update(Elm_Win *win)
261 _elm_win_xwindow_get(win);
266 win2 = elm_widget_data_get(win->parent);
270 ecore_x_icccm_transient_for_set(win->xwin, win2->xwin);
274 if (!win->xwin) return; /* nothing more to do */
279 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_NORMAL);
281 case ELM_WIN_DIALOG_BASIC:
282 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DIALOG);
284 case ELM_WIN_DESKTOP:
285 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DESKTOP);
288 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DOCK);
290 case ELM_WIN_TOOLBAR:
291 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_TOOLBAR);
294 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_MENU);
296 case ELM_WIN_UTILITY:
297 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_UTILITY);
300 ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_SPLASH);
305 ecore_x_e_virtual_keyboard_state_set
306 (win->xwin, (Ecore_X_Virtual_Keyboard_State)win->kbdmode);
311 _elm_win_eval_subobjs(Evas_Object *obj)
314 const Evas_Object *child;
316 Elm_Win *win = elm_widget_data_get(obj);
317 Evas_Coord w, h, minw = -1, minh = -1, maxw = -1, maxh = -1;
321 EINA_LIST_FOREACH(win->subobjs, l, child)
323 evas_object_size_hint_weight_get(child, &wx, &wy);
324 if (wx == 0.0) xx = 0;
325 if (wy == 0.0) xy = 0;
327 evas_object_size_hint_min_get(child, &w, &h);
330 if (w > minw) minw = w;
331 if (h > minh) minh = h;
333 evas_object_size_hint_max_get(child, &w, &h);
336 if (maxw == -1) maxw = w;
337 else if ((w > 0) && (w < maxw)) maxw = w;
338 if (maxh == -1) maxh = h;
339 else if ((h > 0) && (h < maxh)) maxh = h;
341 if ((maxw >= 0) && (maxw < minw)) maxw = minw;
342 if ((maxh >= 0) && (maxh < minh)) maxh = minh;
343 if (!xx) maxw = minw;
345 if (!xy) maxh = minh;
347 evas_object_size_hint_min_set(obj, minw, minh);
348 evas_object_size_hint_max_set(obj, maxw, maxh);
349 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
350 if (w < minw) w = minw;
351 if (h < minh) h = minh;
352 if ((maxw >= 0) && (w > maxw)) w = maxw;
353 if ((maxh >= 0) && (h > maxh)) h = maxh;
354 evas_object_resize(obj, w, h);
358 _elm_win_subobj_callback_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
360 elm_win_resize_object_del(data, obj);
364 _elm_win_subobj_callback_changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
366 _elm_win_eval_subobjs(data);
370 _elm_win_shutdown(void)
372 while (_elm_win_list)
373 evas_object_del(_elm_win_list->data);
377 _elm_win_rescale(void)
382 EINA_LIST_FOREACH(_elm_win_list, l, obj)
383 elm_widget_theme(obj);
386 #ifdef HAVE_ELEMENTARY_X
388 _elm_win_client_message(void *data, int type __UNUSED__, void *event)
391 Ecore_X_Event_Client_Message *e = event;
393 if (e->format != 32) return 1;
394 if (e->message_type == ECORE_X_ATOM_E_COMP_FLUSH)
396 if (e->data.l[0] == win->xwin)
398 Evas *evas = evas_object_evas_get(win->win_obj);
401 edje_file_cache_flush();
402 edje_collection_cache_flush();
403 evas_image_cache_flush(evas);
404 evas_font_cache_flush(evas);
408 else if (e->message_type == ECORE_X_ATOM_E_COMP_DUMP)
410 if (e->data.l[0] == win->xwin)
412 Evas *evas = evas_object_evas_get(win->win_obj);
415 edje_file_cache_flush();
416 edje_collection_cache_flush();
417 evas_image_cache_flush(evas);
418 evas_font_cache_flush(evas);
419 evas_render_dump(evas);
428 * Adds a window object. If this is the first window created, pass NULL as
431 * @param parent Parent object to add the window to, or NULL
432 * @param name The name of the window
433 * @param type The window type, one of the following:
435 * ELM_WIN_DIALOG_BASIC
443 * @return The created object, or NULL on failure
448 elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type)
452 const char *fontpath;
454 win = ELM_NEW(Elm_Win);
455 switch (_elm_config->engine)
457 case ELM_SOFTWARE_X11:
458 win->ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
459 #ifdef HAVE_ELEMENTARY_X
460 win->client_message_handler = ecore_event_handler_add
461 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
464 case ELM_SOFTWARE_FB:
465 win->ee = ecore_evas_fb_new(NULL, 0, 1, 1);
467 case ELM_SOFTWARE_DIRECTFB:
468 win->ee = ecore_evas_directfb_new(NULL, 1, 0, 0, 1, 1);
470 case ELM_SOFTWARE_16_X11:
471 win->ee = ecore_evas_software_x11_16_new(NULL, 0, 0, 0, 1, 1);
474 CRITICAL("Software-16 engine create failed. Try software.");
475 win->ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
477 #ifdef HAVE_ELEMENTARY_X
478 win->client_message_handler = ecore_event_handler_add
479 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
482 case ELM_XRENDER_X11:
483 win->ee = ecore_evas_xrender_x11_new(NULL, 0, 0, 0, 1, 1);
486 CRITICAL("XRender engine create failed. Try software.");
487 win->ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
489 #ifdef HAVE_ELEMENTARY_X
490 win->client_message_handler = ecore_event_handler_add
491 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
495 win->ee = ecore_evas_gl_x11_new(NULL, 0, 0, 0, 1, 1);
498 CRITICAL("OpenGL engine create failed. Try software.");
499 win->ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
501 #ifdef HAVE_ELEMENTARY_X
502 win->client_message_handler = ecore_event_handler_add
503 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
506 case ELM_SOFTWARE_WIN32:
507 win->ee = ecore_evas_software_gdi_new(NULL, 0, 0, 1, 1);
509 case ELM_SOFTWARE_16_WINCE:
510 win->ee = ecore_evas_software_wince_gdi_new(NULL, 0, 0, 1, 1);
512 case ELM_SOFTWARE_SDL:
513 win->ee = ecore_evas_sdl_new(NULL, 0, 0, 0, 0, 0, 1);
516 CRITICAL("Software SDL engine create failed. Try software.");
517 win->ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
520 case ELM_SOFTWARE_16_SDL:
521 win->ee = ecore_evas_sdl16_new(NULL, 0, 0, 0, 0, 0, 1);
524 CRITICAL("Sofware-16-SDL engine create failed. Try software.");
525 win->ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
529 win->ee = ecore_evas_gl_sdl_new(NULL, 1, 1, 0, 0);
532 CRITICAL("OpenGL SDL engine create failed. Try software.");
533 win->ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
541 ERR("Cannot create window.");
545 #ifdef HAVE_ELEMENTARY_X
546 _elm_win_xwindow_get(win);
548 if ((_elm_config->bgpixmap) && (!_elm_config->compositing))
549 ecore_evas_avoid_damage_set(win->ee, ECORE_EVAS_AVOID_DAMAGE_EXPOSE);
550 // bg pixmap done by x - has other issues like can be redrawn by x before it
551 // is filled/ready by app
552 // ecore_evas_avoid_damage_set(win->ee, ECORE_EVAS_AVOID_DAMAGE_BUILT_IN);
555 win->parent = parent;
557 evas_object_event_callback_add(win->parent, EVAS_CALLBACK_DEL,
558 _elm_win_obj_callback_parent_del, win);
560 win->evas = ecore_evas_get(win->ee);
561 win->win_obj = elm_widget_add(win->evas);
562 elm_widget_type_set(win->win_obj, "win");
563 ELM_SET_WIDTYPE(widtype, "win");
564 elm_widget_data_set(win->win_obj, win);
565 evas_object_color_set(win->win_obj, 0, 0, 0, 0);
566 evas_object_move(win->win_obj, 0, 0);
567 evas_object_resize(win->win_obj, 1, 1);
568 evas_object_layer_set(win->win_obj, 50);
569 evas_object_pass_events_set(win->win_obj, 1);
571 evas_object_intercept_show_callback_add(win->win_obj,
572 _elm_win_obj_intercept_show, win);
573 ecore_evas_object_associate(win->ee, win->win_obj,
574 ECORE_EVAS_OBJECT_ASSOCIATE_BASE |
575 ECORE_EVAS_OBJECT_ASSOCIATE_STACK |
576 ECORE_EVAS_OBJECT_ASSOCIATE_LAYER);
577 evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_DEL,
578 _elm_win_obj_callback_del, win);
580 ecore_evas_name_class_set(win->ee, name, _elm_appname);
581 ecore_evas_callback_delete_request_set(win->ee, _elm_win_delete_request);
582 ecore_evas_callback_resize_set(win->ee, _elm_win_resize);
583 ecore_evas_callback_focus_in_set(win->ee, _elm_win_focus_in);
584 ecore_evas_callback_focus_out_set(win->ee, _elm_win_focus_out);
585 ecore_evas_callback_move_set(win->ee, _elm_win_move);
586 evas_image_cache_set(win->evas, (_elm_config->image_cache * 1024));
587 evas_font_cache_set(win->evas, (_elm_config->font_cache * 1024));
588 EINA_LIST_FOREACH(_elm_config->font_dirs, l, fontpath)
589 evas_font_path_append(win->evas, fontpath);
590 if (_elm_config->font_hinting == 0)
591 evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_NONE);
592 else if (_elm_config->font_hinting == 1)
593 evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_AUTO);
594 else if (_elm_config->font_hinting == 2)
595 evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_BYTECODE);
597 #ifdef HAVE_ELEMENTARY_X
598 _elm_win_xwin_update(win);
601 _elm_win_list = eina_list_append(_elm_win_list, win->win_obj);
603 switch (_elm_config->engine)
605 case ELM_SOFTWARE_16_WINCE:
606 case ELM_SOFTWARE_FB:
607 ecore_evas_fullscreen_set(win->ee, 1);
609 case ELM_SOFTWARE_X11:
610 case ELM_SOFTWARE_16_X11:
611 case ELM_XRENDER_X11:
613 case ELM_SOFTWARE_WIN32:
614 case ELM_SOFTWARE_SDL:
615 case ELM_SOFTWARE_16_SDL:
625 * Add @p subobj as a resize object of window @p obj.
627 * @param obj The window object
628 * @param subobj The resize object to add
633 elm_win_resize_object_add(Evas_Object *obj, Evas_Object *subobj)
637 ELM_CHECK_WIDTYPE(obj, widtype);
638 win = elm_widget_data_get(obj);
640 win->subobjs = eina_list_append(win->subobjs, subobj);
641 elm_widget_sub_object_add(obj, subobj);
642 evas_object_event_callback_add(subobj, EVAS_CALLBACK_DEL,
643 _elm_win_subobj_callback_del, obj);
644 evas_object_event_callback_add(subobj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
645 _elm_win_subobj_callback_changed_size_hints,
647 ecore_evas_geometry_get(win->ee, NULL, NULL, &w, &h);
648 evas_object_move(subobj, 0, 0);
649 evas_object_resize(subobj, w, h);
650 _elm_win_eval_subobjs(obj);
654 * Delete @p subobj as a resize object of window @p obj.
656 * @param obj The window object
657 * @param subobj The resize object to add
662 elm_win_resize_object_del(Evas_Object *obj, Evas_Object *subobj)
665 ELM_CHECK_WIDTYPE(obj, widtype);
666 win = elm_widget_data_get(obj);
668 evas_object_event_callback_del_full(subobj,
669 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
670 _elm_win_subobj_callback_changed_size_hints,
672 evas_object_event_callback_del_full(subobj, EVAS_CALLBACK_DEL,
673 _elm_win_subobj_callback_del, obj);
674 win->subobjs = eina_list_remove(win->subobjs, subobj);
675 elm_widget_sub_object_del(obj, subobj);
676 _elm_win_eval_subobjs(obj);
680 * Set the title of the window
682 * @param obj The window object
683 * @param title The title to set
688 elm_win_title_set(Evas_Object *obj, const char *title)
691 ELM_CHECK_WIDTYPE(obj, widtype);
692 win = elm_widget_data_get(obj);
694 ecore_evas_title_set(win->ee, title);
698 * Set the window's autodel state.
700 * @param obj The window object
701 * @param autodel If true, the window will automatically delete itself when closed
706 elm_win_autodel_set(Evas_Object *obj, Eina_Bool autodel)
709 ELM_CHECK_WIDTYPE(obj, widtype);
710 win = elm_widget_data_get(obj);
712 win->autodel = autodel;
716 * Activate a window object.
718 * @param obj The window object
723 elm_win_activate(Evas_Object *obj)
726 ELM_CHECK_WIDTYPE(obj, widtype);
727 win = elm_widget_data_get(obj);
729 ecore_evas_activate(win->ee);
733 * Lower a window object.
735 * @param obj The window object
740 elm_win_lower(Evas_Object *obj)
743 ELM_CHECK_WIDTYPE(obj, widtype);
744 win = elm_widget_data_get(obj);
746 ecore_evas_lower(win->ee);
750 * Raise a window object.
752 * @param obj The window object
757 elm_win_raise(Evas_Object *obj)
760 ELM_CHECK_WIDTYPE(obj, widtype);
761 win = elm_widget_data_get(obj);
763 ecore_evas_raise(win->ee);
767 * Set the borderless state of a window.
769 * @param obj The window object
770 * @param borderless If true, the window is borderless
775 elm_win_borderless_set(Evas_Object *obj, Eina_Bool borderless)
778 ELM_CHECK_WIDTYPE(obj, widtype);
779 win = elm_widget_data_get(obj);
781 ecore_evas_borderless_set(win->ee, borderless);
782 #ifdef HAVE_ELEMENTARY_X
783 _elm_win_xwin_update(win);
788 * Get the borderless state of a window.
790 * @param obj The window object
791 * @return If true, the window is borderless
796 elm_win_borderless_get(const Evas_Object *obj)
799 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
800 win = elm_widget_data_get(obj);
801 if (!win) return EINA_FALSE;
802 return ecore_evas_borderless_get(win->ee);
806 * Set the shaped state of a window.
808 * @param obj The window object
809 * @param shaped If true, the window is shaped
814 elm_win_shaped_set(Evas_Object *obj, Eina_Bool shaped)
817 ELM_CHECK_WIDTYPE(obj, widtype);
818 win = elm_widget_data_get(obj);
820 ecore_evas_shaped_set(win->ee, shaped);
821 #ifdef HAVE_ELEMENTARY_X
822 _elm_win_xwin_update(win);
827 * Get the shaped state of a window.
829 * @param obj The window object
830 * @return If true, the window is shaped
835 elm_win_shaped_get(const Evas_Object *obj)
838 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
839 win = elm_widget_data_get(obj);
840 if (!win) return EINA_FALSE;
841 return ecore_evas_shaped_get(win->ee);
845 * Set the alpha channel state of a window.
847 * @param obj The window object
848 * @param alpha If true, the window has an alpha channel
853 elm_win_alpha_set(Evas_Object *obj, Eina_Bool alpha)
856 ELM_CHECK_WIDTYPE(obj, widtype);
857 win = elm_widget_data_get(obj);
859 #ifdef HAVE_ELEMENTARY_X
864 if (!_elm_config->compositing)
865 elm_win_shaped_set(obj, alpha);
867 ecore_evas_alpha_set(win->ee, alpha);
870 ecore_evas_alpha_set(win->ee, alpha);
871 _elm_win_xwin_update(win);
875 ecore_evas_alpha_set(win->ee, alpha);
879 * Get the alpha channel state of a window.
881 * @param obj The window object
882 * @return If true, the window has an alpha channel
887 elm_win_alpha_get(const Evas_Object *obj)
890 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
891 win = elm_widget_data_get(obj);
892 if (!win) return EINA_FALSE;
893 return ecore_evas_alpha_get(win->ee);
897 * Set the transparency state of a window.
899 * @param obj The window object
900 * @param transparent If true, the window is transparent
905 elm_win_transparent_set(Evas_Object *obj, Eina_Bool transparent)
908 ELM_CHECK_WIDTYPE(obj, widtype);
909 win = elm_widget_data_get(obj);
912 #ifdef HAVE_ELEMENTARY_X
915 ecore_evas_transparent_set(win->ee, transparent);
916 _elm_win_xwin_update(win);
920 ecore_evas_transparent_set(win->ee, transparent);
924 * Get the transparency state of a window.
926 * @param obj The window object
927 * @return If true, the window is transparent
932 elm_win_transparent_get(const Evas_Object *obj)
935 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
936 win = elm_widget_data_get(obj);
937 if (!win) return EINA_FALSE;
939 return ecore_evas_transparent_get(win->ee);
943 * Set the override state of a window.
945 * @param obj The window object
946 * @param override If true, the window is overridden
951 elm_win_override_set(Evas_Object *obj, Eina_Bool override)
954 ELM_CHECK_WIDTYPE(obj, widtype);
955 win = elm_widget_data_get(obj);
957 ecore_evas_override_set(win->ee, override);
958 #ifdef HAVE_ELEMENTARY_X
959 _elm_win_xwin_update(win);
964 * Get the override state of a window.
966 * @param obj The window object
967 * @return If true, the window is overridden
972 elm_win_override_get(const Evas_Object *obj)
975 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
976 win = elm_widget_data_get(obj);
977 if (!win) return EINA_FALSE;
978 return ecore_evas_override_get(win->ee);
982 * Set the fullscreen state of a window.
984 * @param obj The window object
985 * @param fullscreen If true, the window is fullscreen
990 elm_win_fullscreen_set(Evas_Object *obj, Eina_Bool fullscreen)
993 ELM_CHECK_WIDTYPE(obj, widtype);
994 win = elm_widget_data_get(obj);
996 switch (_elm_config->engine)
998 case ELM_SOFTWARE_16_WINCE:
999 case ELM_SOFTWARE_FB:
1000 // these engines... can ONLY be fullscreen
1003 ecore_evas_fullscreen_set(win->ee, fullscreen);
1004 #ifdef HAVE_ELEMENTARY_X
1005 _elm_win_xwin_update(win);
1012 * Get the fullscreen state of a window.
1014 * @param obj The window object
1015 * @return If true, the window is fullscreen
1020 elm_win_fullscreen_get(const Evas_Object *obj)
1023 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1024 win = elm_widget_data_get(obj);
1025 if (!win) return EINA_FALSE;
1026 switch (_elm_config->engine)
1028 case ELM_SOFTWARE_16_WINCE:
1029 case ELM_SOFTWARE_FB:
1030 // these engines... can ONLY be fullscreen
1034 return ecore_evas_fullscreen_get(win->ee);
1041 * Set the maximized state of a window.
1043 * @param obj The window object
1044 * @param maximized If true, the window is maximized
1049 elm_win_maximized_set(Evas_Object *obj, Eina_Bool maximized)
1052 ELM_CHECK_WIDTYPE(obj, widtype);
1053 win = elm_widget_data_get(obj);
1055 ecore_evas_maximized_set(win->ee, maximized);
1056 #ifdef HAVE_ELEMENTARY_X
1057 _elm_win_xwin_update(win);
1062 * Get the maximized state of a window.
1064 * @param obj The window object
1065 * @return If true, the window is maximized
1070 elm_win_maximized_get(const Evas_Object *obj)
1073 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1074 win = elm_widget_data_get(obj);
1075 if (!win) return EINA_FALSE;
1076 return ecore_evas_maximized_get(win->ee);
1080 * Set the iconified state of a window.
1082 * @param obj The window object
1083 * @param iconified If true, the window is iconified
1088 elm_win_iconified_set(Evas_Object *obj, Eina_Bool iconified)
1091 ELM_CHECK_WIDTYPE(obj, widtype);
1092 win = elm_widget_data_get(obj);
1094 ecore_evas_iconified_set(win->ee, iconified);
1095 #ifdef HAVE_ELEMENTARY_X
1096 _elm_win_xwin_update(win);
1101 * Get the iconified state of a window.
1103 * @param obj The window object
1104 * @return If true, the window is iconified
1109 elm_win_iconified_get(const Evas_Object *obj)
1112 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1113 win = elm_widget_data_get(obj);
1114 if (!win) return EINA_FALSE;
1115 return ecore_evas_iconified_get(win->ee);
1119 * Set the layer of the window.
1121 * @param obj The window object
1122 * @param layer The layer of the window
1127 elm_win_layer_set(Evas_Object *obj, int layer)
1130 ELM_CHECK_WIDTYPE(obj, widtype);
1131 win = elm_widget_data_get(obj);
1133 ecore_evas_layer_set(win->ee, layer);
1134 #ifdef HAVE_ELEMENTARY_X
1135 _elm_win_xwin_update(win);
1140 * Get the layer of the window.
1142 * @param obj The window object
1143 * @return The layer of the window
1148 elm_win_layer_get(const Evas_Object *obj)
1151 ELM_CHECK_WIDTYPE(obj, widtype) -1;
1152 win = elm_widget_data_get(obj);
1153 if (!win) return -1;
1154 return ecore_evas_layer_get(win->ee);
1158 * Set the rotation of the window.
1160 * @param obj The window object
1161 * @param rotation The rotation of the window, in degrees (0-360)
1166 elm_win_rotation_set(Evas_Object *obj, int rotation)
1169 ELM_CHECK_WIDTYPE(obj, widtype);
1170 win = elm_widget_data_get(obj);
1172 if (win->rot == rotation) return;
1173 win->rot = rotation;
1174 ecore_evas_rotation_set(win->ee, rotation);
1175 evas_object_size_hint_min_set(obj, -1, -1);
1176 evas_object_size_hint_max_set(obj, -1, -1);
1177 _elm_win_eval_subobjs(obj);
1178 #ifdef HAVE_ELEMENTARY_X
1179 _elm_win_xwin_update(win);
1184 * Rotates the window and resizes it
1186 * @param obj The window object
1187 * @param layer The rotation of the window in degrees (0-360)
1192 elm_win_rotation_with_resize_set(Evas_Object *obj, int rotation)
1195 ELM_CHECK_WIDTYPE(obj, widtype);
1196 win = elm_widget_data_get(obj);
1198 if (win->rot == rotation) return;
1199 win->rot = rotation;
1200 ecore_evas_rotation_with_resize_set(win->ee, rotation);
1201 evas_object_size_hint_min_set(obj, -1, -1);
1202 evas_object_size_hint_max_set(obj, -1, -1);
1203 _elm_win_eval_subobjs(obj);
1204 #ifdef HAVE_ELEMENTARY_X
1205 _elm_win_xwin_update(win);
1210 * Get the rotation of the window.
1212 * @param obj The window object
1213 * @return The rotation of the window in degrees (0-360)
1218 elm_win_rotation_get(const Evas_Object *obj)
1221 ELM_CHECK_WIDTYPE(obj, widtype) -1;
1222 win = elm_widget_data_get(obj);
1223 if (!win) return -1;
1228 * Set the sticky state of the window.
1230 * @param obj The window object
1231 * @param sticky If true, the window's sticky state is enabled
1236 elm_win_sticky_set(Evas_Object *obj, Eina_Bool sticky)
1239 ELM_CHECK_WIDTYPE(obj, widtype);
1240 win = elm_widget_data_get(obj);
1242 ecore_evas_sticky_set(win->ee, sticky);
1243 #ifdef HAVE_ELEMENTARY_X
1244 _elm_win_xwin_update(win);
1249 * Get the sticky state of the window.
1251 * @param obj The window object
1252 * @return If true, the window's sticky state is enabled
1257 elm_win_sticky_get(const Evas_Object *obj)
1260 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1261 win = elm_widget_data_get(obj);
1262 if (!win) return EINA_FALSE;
1263 return ecore_evas_sticky_get(win->ee);
1267 * Sets the keyboard mode of the window.
1269 * @param obj The window object
1270 * @param mode The mode to set; one of:
1271 * ELM_WIN_KEYBOARD_UNKNOWN
1272 * ELM_WIN_KEYBOARD_OFF
1273 * ELM_WIN_KEYBOARD_ON
1274 * ELM_WIN_KEYBOARD_ALPHA
1275 * ELM_WIN_KEYBOARD_NUMERIC
1276 * ELM_WIN_KEYBOARD_PIN
1277 * ELM_WIN_KEYBOARD_PHONE_NUMBER
1278 * ELM_WIN_KEYBOARD_HEX
1279 * ELM_WIN_KEYBOARD_TERMINAL
1280 * ELM_WIN_KEYBOARD_PASSWORD
1281 * ELM_WIN_KEYBOARD_IP
1282 * ELM_WIN_KEYBOARD_HOST
1283 * ELM_WIN_KEYBOARD_FILE
1284 * ELM_WIN_KEYBOARD_URL
1285 * ELM_WIN_KEYBOARD_KEYPAD
1286 * ELM_WIN_KEYBOARD_J2ME
1291 elm_win_keyboard_mode_set(Evas_Object *obj, Elm_Win_Keyboard_Mode mode)
1294 ELM_CHECK_WIDTYPE(obj, widtype);
1295 win = elm_widget_data_get(obj);
1297 if (mode == win->kbdmode) return;
1298 #ifdef HAVE_ELEMENTARY_X
1299 _elm_win_xwindow_get(win);
1301 win->kbdmode = mode;
1302 #ifdef HAVE_ELEMENTARY_X
1304 ecore_x_e_virtual_keyboard_state_set
1305 (win->xwin, (Ecore_X_Virtual_Keyboard_State)win->kbdmode);
1310 * Sets whether the window is a keyboard.
1312 * @param obj The window object
1313 * @param is_keyboard If true, the window is a virtual keyboard
1318 elm_win_keyboard_win_set(Evas_Object *obj, Eina_Bool is_keyboard)
1321 ELM_CHECK_WIDTYPE(obj, widtype);
1322 win = elm_widget_data_get(obj);
1324 #ifdef HAVE_ELEMENTARY_X
1325 _elm_win_xwindow_get(win);
1327 ecore_x_e_virtual_keyboard_set(win->xwin, is_keyboard);
1332 * Get the screen position of a window.
1334 * @param obj The window object
1335 * @param x The int to store the x coordinate to
1336 * @param y The int to store the y coordinate to
1341 elm_win_screen_position_get(const Evas_Object *obj, int *x, int *y)
1344 ELM_CHECK_WIDTYPE(obj, widtype);
1345 win = elm_widget_data_get(obj);
1347 if (x) *x = win->screen.x;
1348 if (y) *y = win->screen.y;
1352 * Set if this window is an illume conformant window
1354 * @param obj The window object
1355 * @param conformant The conformant flag (1 = conformant, 0 = non-conformant)
1360 elm_win_conformant_set(Evas_Object *obj, Eina_Bool conformant)
1363 ELM_CHECK_WIDTYPE(obj, widtype);
1364 win = elm_widget_data_get(obj);
1366 #ifdef HAVE_ELEMENTARY_X
1367 _elm_win_xwindow_get(win);
1369 ecore_x_e_illume_conformant_set(win->xwin, conformant);
1374 * Get if this window is an illume conformant window
1376 * @param obj The window object
1377 * @return A boolean if this window is illume conformant or not
1382 elm_win_conformant_get(const Evas_Object *obj)
1385 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1386 win = elm_widget_data_get(obj);
1387 if (!win) return EINA_FALSE;
1388 #ifdef HAVE_ELEMENTARY_X
1389 _elm_win_xwindow_get(win);
1391 return ecore_x_e_illume_conformant_get(win->xwin);
1397 * Set a window to be an illume quickpanel window
1399 * By default window objects are not quickpanel windows.
1401 * @param obj The window object
1402 * @param quickpanel The quickpanel flag (1 = quickpanel, 0 = normal window)
1407 elm_win_quickpanel_set(Evas_Object *obj, Eina_Bool quickpanel)
1410 ELM_CHECK_WIDTYPE(obj, widtype);
1411 win = elm_widget_data_get(obj);
1413 #ifdef HAVE_ELEMENTARY_X
1414 _elm_win_xwindow_get(win);
1417 ecore_x_e_illume_quickpanel_set(win->xwin, quickpanel);
1420 Ecore_X_Window_State states[2];
1422 states[0] = ECORE_X_WINDOW_STATE_SKIP_TASKBAR;
1423 states[1] = ECORE_X_WINDOW_STATE_SKIP_PAGER;
1424 ecore_x_netwm_window_state_set(win->xwin, states, 2);
1425 ecore_x_icccm_hints_set(win->xwin, 0, 0, 0, 0, 0, 0, 0);
1432 * Get if this window is a quickpanel or not
1434 * @param obj The window object
1435 * @return A boolean if this window is a quickpanel or not
1440 elm_win_quickpanel_get(const Evas_Object *obj)
1443 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1444 win = elm_widget_data_get(obj);
1445 if (!win) return EINA_FALSE;
1446 #ifdef HAVE_ELEMENTARY_X
1447 _elm_win_xwindow_get(win);
1449 return ecore_x_e_illume_quickpanel_get(win->xwin);
1455 * Set the major priority of a quickpanel window
1457 * @param obj The window object
1458 * @param priority The major priority for this quickpanel
1463 elm_win_quickpanel_priority_major_set(Evas_Object *obj, int priority)
1466 ELM_CHECK_WIDTYPE(obj, widtype);
1467 win = elm_widget_data_get(obj);
1469 #ifdef HAVE_ELEMENTARY_X
1470 _elm_win_xwindow_get(win);
1472 ecore_x_e_illume_quickpanel_priority_major_set(win->xwin, priority);
1477 * Get the major priority of a quickpanel window
1479 * @param obj The window object
1480 * @return The major priority of this quickpanel
1485 elm_win_quickpanel_priority_major_get(const Evas_Object *obj)
1488 ELM_CHECK_WIDTYPE(obj, widtype) -1;
1489 win = elm_widget_data_get(obj);
1490 if (!win) return -1;
1491 #ifdef HAVE_ELEMENTARY_X
1492 _elm_win_xwindow_get(win);
1494 return ecore_x_e_illume_quickpanel_priority_major_get(win->xwin);
1500 * Set the minor priority of a quickpanel window
1502 * @param obj The window object
1503 * @param priority The minor priority for this quickpanel
1508 elm_win_quickpanel_priority_minor_set(Evas_Object *obj, int priority)
1511 ELM_CHECK_WIDTYPE(obj, widtype);
1512 win = elm_widget_data_get(obj);
1514 #ifdef HAVE_ELEMENTARY_X
1515 _elm_win_xwindow_get(win);
1517 ecore_x_e_illume_quickpanel_priority_minor_set(win->xwin, priority);
1522 * Get the minor priority of a quickpanel window
1524 * @param obj The window object
1525 * @return The minor priority of this quickpanel
1530 elm_win_quickpanel_priority_minor_get(const Evas_Object *obj)
1533 ELM_CHECK_WIDTYPE(obj, widtype) -1;
1534 win = elm_widget_data_get(obj);
1535 if (!win) return -1;
1536 #ifdef HAVE_ELEMENTARY_X
1537 _elm_win_xwindow_get(win);
1539 return ecore_x_e_illume_quickpanel_priority_minor_get(win->xwin);
1545 * Set which zone this quickpanel should appear in
1547 * @param obj The window object
1548 * @param zone The requested zone for this quickpanel
1553 elm_win_quickpanel_zone_set(Evas_Object *obj, int zone)
1556 ELM_CHECK_WIDTYPE(obj, widtype);
1557 win = elm_widget_data_get(obj);
1559 #ifdef HAVE_ELEMENTARY_X
1560 _elm_win_xwindow_get(win);
1562 ecore_x_e_illume_quickpanel_zone_set(win->xwin, zone);
1566 typedef struct _Widget_Data Widget_Data;
1571 Evas_Object *content;
1574 static void _del_hook(Evas_Object *obj);
1575 static void _theme_hook(Evas_Object *obj);
1576 static void _sizing_eval(Evas_Object *obj);
1577 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
1578 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
1580 static const char *widtype2 = NULL;
1583 _del_hook(Evas_Object *obj)
1585 Widget_Data *wd = elm_widget_data_get(obj);
1590 _theme_hook(Evas_Object *obj)
1592 Widget_Data *wd = elm_widget_data_get(obj);
1593 _elm_theme_object_set(obj, wd->frm, "win", "inwin", elm_widget_style_get(obj));
1595 edje_object_part_swallow(wd->frm, "elm.swallow.content", wd->content);
1600 _sizing_eval(Evas_Object *obj)
1602 Widget_Data *wd = elm_widget_data_get(obj);
1603 Evas_Coord minw = -1, minh = -1;
1605 evas_object_size_hint_min_get(wd->content, &minw, &minh);
1606 edje_object_size_min_calc(wd->frm, &minw, &minh);
1607 evas_object_size_hint_min_set(obj, minw, minh);
1608 evas_object_size_hint_max_set(obj, -1, -1);
1612 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1618 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
1620 Widget_Data *wd = elm_widget_data_get(obj);
1621 Evas_Object *sub = event_info;
1622 if (sub == wd->content)
1624 evas_object_event_callback_del_full
1625 (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
1632 * @defgroup Inwin Inwin
1634 * An inwin is a window inside a window that is useful for a quick popup. It does not hover.
1637 elm_win_inwin_add(Evas_Object *obj)
1643 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1644 win = elm_widget_data_get(obj);
1645 if (!win) return NULL;
1646 wd = ELM_NEW(Widget_Data);
1647 obj2 = elm_widget_add(win->evas);
1648 elm_widget_type_set(obj2, "inwin");
1649 ELM_SET_WIDTYPE(widtype2, "inwin");
1650 elm_widget_sub_object_add(obj, obj2);
1651 evas_object_size_hint_weight_set(obj2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1652 evas_object_size_hint_align_set(obj2, EVAS_HINT_FILL, EVAS_HINT_FILL);
1653 elm_win_resize_object_add(obj, obj2);
1655 elm_widget_data_set(obj2, wd);
1656 elm_widget_del_hook_set(obj2, _del_hook);
1657 elm_widget_theme_hook_set(obj2, _theme_hook);
1659 wd->frm = edje_object_add(win->evas);
1660 _elm_theme_object_set(obj, wd->frm, "win", "inwin", "default");
1661 elm_widget_resize_object_set(obj2, wd->frm);
1663 evas_object_smart_callback_add(obj2, "sub-object-del", _sub_del, obj2);
1670 * Activates an inwin object
1672 * @param obj The inwin to activate
1677 elm_win_inwin_activate(Evas_Object *obj)
1679 ELM_CHECK_WIDTYPE(obj, widtype2);
1680 Widget_Data *wd = elm_widget_data_get(obj);
1682 evas_object_raise(obj);
1683 evas_object_show(obj);
1684 edje_object_signal_emit(wd->frm, "elm,action,show", "elm");
1685 elm_widget_focused_object_clear(elm_widget_parent_get(obj));
1689 * Set the content of an inwin object.
1691 * @param obj The inwin object
1692 * @param content The object to set as content
1697 elm_win_inwin_content_set(Evas_Object *obj, Evas_Object *content)
1699 ELM_CHECK_WIDTYPE(obj, widtype2);
1700 Widget_Data *wd = elm_widget_data_get(obj);
1702 if ((wd->content) && (wd->content != content))
1703 elm_widget_sub_object_del(obj, wd->content);
1704 wd->content = content;
1707 elm_widget_sub_object_add(obj, content);
1708 evas_object_event_callback_add(content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1709 _changed_size_hints, obj);
1710 edje_object_part_swallow(wd->frm, "elm.swallow.content", content);
1715 /* windowing spcific calls - shall we do this differently? */
1717 * Get the Ecore_X_Window of an Evas_Object
1719 * @param obj The object
1721 * @return The Ecore_X_Window of @p obj
1726 elm_win_xwindow_get(const Evas_Object *obj)
1728 Ecore_X_Window xwin = 0;
1729 Ecore_Evas *ee = NULL;
1731 #ifdef HAVE_ELEMENTARY_X
1732 ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
1733 if (ee) xwin = (Ecore_X_Window)ecore_evas_window_get(ee);