5c44bbce6628e9f2c8916209bde66bd2c015c93c
[framework/uifw/elementary.git] / src / lib / elm_win.c
1 #include <Elementary.h>
2 #include "elm_priv.h"
3
4 /**
5  * @defgroup Win Win
6  * @ingroup Elementary
7  *
8  * The window class of Elementary.  Contains functions to manipulate
9  * windows.
10  *
11  * Signals that you can add callbacks for are:
12  *
13  * "delete,request" - the user requested to delete the window
14  * "focus,in" - window got focus
15  * "focus,out" - window lost focus
16  * "moved" - window that holds the canvas was moved
17  */
18
19 typedef struct _Elm_Win Elm_Win;
20
21 struct _Elm_Win
22 {
23    Ecore_Evas *ee;
24    Evas *evas;
25    Evas_Object *parent, *win_obj;
26    Eina_List *subobjs;
27 #ifdef HAVE_ELEMENTARY_X
28    Ecore_X_Window xwin;
29    Ecore_Event_Handler *client_message_handler;
30 #endif
31    Ecore_Job *deferred_resize_job;
32    Ecore_Job *deferred_child_eval_job;
33
34    Elm_Win_Type type;
35    Elm_Win_Keyboard_Mode kbdmode;
36    Eina_Bool autodel : 1;
37    int *autodel_clear, rot;
38    struct {
39       int x, y;
40    } screen;
41
42    struct {
43       Evas_Object *top;
44
45       struct {
46          Evas_Object *target;
47          Eina_Bool visible : 1;
48          Eina_Bool handled : 1;
49       } cur, prev;
50
51       const char *style;
52       Ecore_Job *reconf_job;
53
54       Eina_Bool enabled : 1;
55       Eina_Bool changed_theme : 1;
56       Eina_Bool top_animate : 1;
57       Eina_Bool geometry_changed : 1;
58    } focus_highlight;
59 };
60
61 static const char *widtype = NULL;
62 static void _elm_win_obj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
63 static void _elm_win_obj_callback_parent_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
64 static void _elm_win_obj_intercept_show(void *data, Evas_Object *obj);
65 static void _elm_win_move(Ecore_Evas *ee);
66 static void _elm_win_resize(Ecore_Evas *ee);
67 static void _elm_win_delete_request(Ecore_Evas *ee);
68 static void _elm_win_resize_job(void *data);
69 #ifdef HAVE_ELEMENTARY_X
70 static void _elm_win_xwin_update(Elm_Win *win);
71 #endif
72 static void _elm_win_eval_subobjs(Evas_Object *obj);
73 static void _elm_win_subobj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
74 static void _elm_win_subobj_callback_changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
75 static void _elm_win_focus_highlight_init(Elm_Win *win);
76 static void _elm_win_focus_highlight_shutdown(Elm_Win *win);
77 static void _elm_win_focus_highlight_visible_set(Elm_Win *win, Eina_Bool visible);
78 static void _elm_win_focus_highlight_reconfigure_job_start(Elm_Win *win);
79 static void _elm_win_focus_highlight_reconfigure_job_stop(Elm_Win *win);
80 static void _elm_win_focus_highlight_anim_end(void *data, Evas_Object *obj, const char *emission, const char *source);
81 static void _elm_win_focus_highlight_reconfigure(Elm_Win *win);
82
83 Eina_List *_elm_win_list = NULL;
84 int _elm_win_deferred_free = 0;
85
86 static void
87 _elm_win_move(Ecore_Evas *ee)
88 {
89    Evas_Object *obj = ecore_evas_object_associate_get(ee);
90    Elm_Win *win;
91    int x, y;
92
93    if (!obj) return;
94    win = elm_widget_data_get(obj);
95    if (!win) return;
96    ecore_evas_geometry_get(ee, &x, &y, NULL, NULL);
97    win->screen.x = x;
98    win->screen.y = y;
99    evas_object_smart_callback_call(win->win_obj, "moved", NULL);
100 }
101
102 static void
103 _elm_win_resize(Ecore_Evas *ee)
104 {
105    Evas_Object *obj = ecore_evas_object_associate_get(ee);
106    Elm_Win *win;
107
108    if (!obj) return;
109    win = elm_widget_data_get(obj);
110    if (!win) return;
111    if (win->deferred_resize_job) ecore_job_del(win->deferred_resize_job);
112    win->deferred_resize_job = ecore_job_add(_elm_win_resize_job, win);
113 }
114
115 static void
116 _elm_win_focus_in(Ecore_Evas *ee)
117 {
118    Evas_Object *obj = ecore_evas_object_associate_get(ee);
119    Elm_Win *win;
120
121    if (!obj) return;
122    win = elm_widget_data_get(obj);
123    if (!win) return;
124    /*NB: Why two different "focus signals" here ??? */
125    evas_object_smart_callback_call(win->win_obj, "focus-in", NULL); // FIXME: remove me
126    evas_object_smart_callback_call(win->win_obj, "focus,in", NULL);
127    win->focus_highlight.cur.visible = EINA_TRUE;
128    _elm_win_focus_highlight_reconfigure_job_start(win);
129 }
130
131 static void
132 _elm_win_focus_out(Ecore_Evas *ee)
133 {
134    Evas_Object *obj = ecore_evas_object_associate_get(ee);
135    Elm_Win *win;
136
137    if (!obj) return;
138    win = elm_widget_data_get(obj);
139    if (!win) return;
140    evas_object_smart_callback_call(win->win_obj, "focus-out", NULL); // FIXME: remove me
141    evas_object_smart_callback_call(win->win_obj, "focus,out", NULL);
142    win->focus_highlight.cur.visible = EINA_FALSE;
143    _elm_win_focus_highlight_reconfigure_job_start(win);
144 }
145
146 static Eina_Bool
147 _elm_win_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
148 {
149    Elm_Win *wd = elm_widget_data_get(obj);
150    const Eina_List *items;
151    void *(*list_data_get) (const Eina_List *list);
152
153    if (!wd)
154      return EINA_FALSE;
155
156    /* Focus chain */
157    if (wd->subobjs)
158      {
159         if (!(items = elm_widget_focus_custom_chain_get(obj)))
160           {
161              items = wd->subobjs;
162              if (!items)
163                return EINA_FALSE;
164           }
165         list_data_get = eina_list_data_get;
166
167         elm_widget_focus_list_next_get(obj, items, list_data_get, dir, next);
168
169         if (*next)
170           return EINA_TRUE;
171      }
172
173    *next = (Evas_Object *)obj;
174    return EINA_FALSE;
175 }
176
177 static void
178 _elm_win_on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
179 {
180    if (elm_widget_focus_get(obj))
181      evas_object_focus_set(obj, EINA_TRUE);
182    else
183      evas_object_focus_set(obj, EINA_FALSE);
184 }
185
186 static Eina_Bool
187 _elm_win_event_cb(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
188 {
189    if (type == EVAS_CALLBACK_KEY_DOWN)
190      {
191         Evas_Event_Key_Down *ev = event_info;
192         if (!strcmp(ev->keyname, "Tab"))
193           {
194              if(evas_key_modifier_is_set(ev->modifiers, "Shift"))
195                elm_widget_focus_cycle(obj, ELM_FOCUS_PREVIOUS);
196              else
197                elm_widget_focus_cycle(obj, ELM_FOCUS_NEXT);
198              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
199              return EINA_TRUE;
200           }
201      }
202
203    return EINA_FALSE;
204 }
205
206 static void
207 _deferred_ecore_evas_free(void *data)
208 {
209    ecore_evas_free(data);
210    _elm_win_deferred_free--;
211 }
212
213 static void
214 _elm_win_obj_callback_show(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
215 {
216    elm_object_focus(obj);
217 }
218
219 static void
220 _elm_win_obj_callback_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
221 {
222    Elm_Win *win = data;
223    Evas_Object *child;
224
225    if (win->parent)
226      {
227         evas_object_event_callback_del_full(win->parent, EVAS_CALLBACK_DEL,
228                                             _elm_win_obj_callback_parent_del, win);
229         win->parent = NULL;
230      }
231    if (win->autodel_clear) *(win->autodel_clear) = -1;
232    _elm_win_list = eina_list_remove(_elm_win_list, win->win_obj);
233    while (win->subobjs) elm_win_resize_object_del(obj, win->subobjs->data);
234    ecore_evas_callback_delete_request_set(win->ee, NULL);
235    ecore_evas_callback_resize_set(win->ee, NULL);
236    if (win->deferred_resize_job) ecore_job_del(win->deferred_resize_job);
237    if (win->deferred_child_eval_job) ecore_job_del(win->deferred_child_eval_job);
238    while (((child = evas_object_bottom_get(win->evas))) &&
239           (child != obj))
240      {
241         evas_object_del(child);
242      }
243    while (((child = evas_object_top_get(win->evas))) &&
244           (child != obj))
245      {
246         evas_object_del(child);
247      }
248 #ifdef HAVE_ELEMENTARY_X
249    if (win->client_message_handler)
250      ecore_event_handler_del(win->client_message_handler);
251 #endif
252    // FIXME: Why are we flushing edje on every window destroy ??
253    //   edje_file_cache_flush();
254    //   edje_collection_cache_flush();
255    //   evas_image_cache_flush(win->evas);
256    //   evas_font_cache_flush(win->evas);
257    // FIXME: we are in the del handler for the object and delete the canvas
258    // that lives under it from the handler... nasty. deferring doesn't help either
259
260    ecore_job_add(_deferred_ecore_evas_free, win->ee);
261    _elm_win_deferred_free++;
262    //   ecore_evas_free(win->ee);
263
264    _elm_win_focus_highlight_shutdown(win);
265    eina_stringshare_del(win->focus_highlight.style);
266
267    free(win);
268
269    if ((!_elm_win_list) &&
270        (elm_policy_get(ELM_POLICY_QUIT) == ELM_POLICY_QUIT_LAST_WINDOW_CLOSED))
271      {
272         edje_file_cache_flush();
273         edje_collection_cache_flush();
274         evas_image_cache_flush(e);
275         evas_font_cache_flush(e);
276         elm_exit();
277      }
278 }
279
280 static void
281 _elm_win_obj_callback_parent_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
282 {
283    Elm_Win *win = data;
284    if (obj == win->parent) win->parent = NULL;
285 }
286
287 static void
288 _elm_win_obj_intercept_show(void *data __UNUSED__, Evas_Object *obj)
289 {
290    // this is called to make sure all smart containers have calculated their
291    // sizes BEFORE we show the window to make sure it initially appears at
292    // our desired size (ie min size is known first)
293    evas_smart_objects_calculate(evas_object_evas_get(obj));
294    evas_object_show(obj);
295 }
296
297 static void
298 _elm_win_obj_callback_move(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
299 {
300    Elm_Win *win = data;
301
302    if (ecore_evas_override_get(win->ee))
303      {
304         Evas_Coord x, y;
305
306         evas_object_geometry_get(obj, &x, &y, NULL, NULL);
307         win->screen.x = x;
308         win->screen.y = y;
309         evas_object_smart_callback_call(win->win_obj, "moved", NULL);
310      }
311 }
312
313 static void
314 _elm_win_delete_request(Ecore_Evas *ee)
315 {
316    Evas_Object *obj = ecore_evas_object_associate_get(ee);
317    Elm_Win *win;
318    if (strcmp(elm_widget_type_get(obj), "win")) return;
319
320    win = elm_widget_data_get(obj);
321    if (!win) return;
322    int autodel = win->autodel;
323    win->autodel_clear = &autodel;
324    evas_object_smart_callback_call(win->win_obj, "delete-request", NULL); // FIXME: remove me
325    evas_object_smart_callback_call(win->win_obj, "delete,request", NULL);
326    // FIXME: if above callback deletes - then the below will be invalid
327    if (autodel) evas_object_del(win->win_obj);
328    else win->autodel_clear = NULL;
329 }
330
331 static void
332 _elm_win_resize_job(void *data)
333 {
334    Elm_Win *win = data;
335    const Eina_List *l;
336    Evas_Object *obj;
337    int w, h;
338
339    win->deferred_resize_job = NULL;
340    ecore_evas_geometry_get(win->ee, NULL, NULL, &w, &h);
341    evas_object_resize(win->win_obj, w, h);
342    EINA_LIST_FOREACH(win->subobjs, l, obj)
343      {
344         evas_object_move(obj, 0, 0);
345         evas_object_resize(obj, w, h);
346      }
347 }
348
349 #ifdef HAVE_ELEMENTARY_X
350 static void
351 _elm_win_xwindow_get(Elm_Win *win)
352 {
353    win->xwin = 0;
354
355 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
356    if (ENGINE_COMPARE(ELM_SOFTWARE_X11))
357      {
358        if (win->ee) win->xwin = ecore_evas_software_x11_window_get(win->ee);
359      }
360    else if (ENGINE_COMPARE(ELM_SOFTWARE_X11) ||
361             ENGINE_COMPARE(ELM_SOFTWARE_FB) ||
362             ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE) ||
363             ENGINE_COMPARE(ELM_SOFTWARE_SDL) ||
364             ENGINE_COMPARE(ELM_SOFTWARE_16_SDL) ||
365             ENGINE_COMPARE(ELM_OPENGL_SDL))
366      {
367      }
368    else if (ENGINE_COMPARE(ELM_SOFTWARE_16_X11))
369      {
370         if (win->ee) win->xwin = ecore_evas_software_x11_16_window_get(win->ee);
371      }
372    else if (ENGINE_COMPARE(ELM_SOFTWARE_8_X11))
373      {
374         if (win->ee) win->xwin = ecore_evas_software_x11_8_window_get(win->ee);
375      }
376    else if (ENGINE_COMPARE(ELM_XRENDER_X11))
377      {
378         if (win->ee) win->xwin = ecore_evas_xrender_x11_window_get(win->ee);
379      }
380    else if (ENGINE_COMPARE(ELM_OPENGL_X11))
381      {
382         if (win->ee) win->xwin = ecore_evas_gl_x11_window_get(win->ee);
383      }
384    else if (ENGINE_COMPARE(ELM_SOFTWARE_WIN32))
385      {
386         if (win->ee) win->xwin = (long)ecore_evas_win32_window_get(win->ee);
387      }
388 #undef ENGINE_COMPARE
389 }
390 #endif
391
392 #ifdef HAVE_ELEMENTARY_X
393 static void
394 _elm_win_xwin_update(Elm_Win *win)
395 {
396    _elm_win_xwindow_get(win);
397    if (win->parent)
398      {
399         Elm_Win *win2;
400
401         win2 = elm_widget_data_get(win->parent);
402         if (win2)
403           {
404              if (win->xwin)
405                ecore_x_icccm_transient_for_set(win->xwin, win2->xwin);
406           }
407      }
408
409    if (!win->xwin) return; /* nothing more to do */
410
411    switch (win->type)
412      {
413       case ELM_WIN_BASIC:
414          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_NORMAL);
415          break;
416       case ELM_WIN_DIALOG_BASIC:
417          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DIALOG);
418          break;
419       case ELM_WIN_DESKTOP:
420          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DESKTOP);
421          break;
422       case ELM_WIN_DOCK:
423          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DOCK);
424          break;
425       case ELM_WIN_TOOLBAR:
426          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_TOOLBAR);
427          break;
428       case ELM_WIN_MENU:
429          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_MENU);
430          break;
431       case ELM_WIN_UTILITY:
432          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_UTILITY);
433          break;
434       case ELM_WIN_SPLASH:
435          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_SPLASH);
436          break;
437       case ELM_WIN_DROPDOWN_MENU:
438          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DROPDOWN_MENU);
439          break;
440       case ELM_WIN_POPUP_MENU:
441          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_POPUP_MENU);
442          break;
443       case ELM_WIN_TOOLTIP:
444          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_TOOLTIP);
445          break;
446       case ELM_WIN_NOTIFICATION:
447          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_NOTIFICATION);
448          break;
449       case ELM_WIN_COMBO:
450          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_COMBO);
451          break;
452       case ELM_WIN_DND:
453          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DND);
454          break;
455       default:
456          break;
457      }
458    ecore_x_e_virtual_keyboard_state_set
459       (win->xwin, (Ecore_X_Virtual_Keyboard_State)win->kbdmode);
460 }
461 #endif
462
463 static void
464 _elm_win_eval_subobjs(Evas_Object *obj)
465 {
466    const Eina_List *l;
467    const Evas_Object *child;
468
469    Elm_Win *win = elm_widget_data_get(obj);
470    Evas_Coord w, h, minw = -1, minh = -1, maxw = -1, maxh = -1;
471    int xx = 1, xy = 1;
472    double wx, wy;
473
474    EINA_LIST_FOREACH(win->subobjs, l, child)
475      {
476         evas_object_size_hint_weight_get(child, &wx, &wy);
477         if (wx == 0.0) xx = 0;
478         if (wy == 0.0) xy = 0;
479
480         evas_object_size_hint_min_get(child, &w, &h);
481         if (w < 1) w = -1;
482         if (h < 1) h = -1;
483         if (w > minw) minw = w;
484         if (h > minh) minh = h;
485
486         evas_object_size_hint_max_get(child, &w, &h);
487         if (w < 1) w = -1;
488         if (h < 1) h = -1;
489         if (maxw == -1) maxw = w;
490         else if ((w > 0) && (w < maxw)) maxw = w;
491         if (maxh == -1) maxh = h;
492         else if ((h > 0) && (h < maxh)) maxh = h;
493      }
494    if (!xx) maxw = minw;
495    else maxw = 32767;
496    if (!xy) maxh = minh;
497    else maxh = 32767;
498    evas_object_size_hint_min_set(obj, minw, minh);
499    evas_object_size_hint_max_set(obj, maxw, maxh);
500    evas_object_geometry_get(obj, NULL, NULL, &w, &h);
501    if (w < minw) w = minw;
502    if (h < minh) h = minh;
503    if ((maxw >= 0) && (w > maxw)) w = maxw;
504    if ((maxh >= 0) && (h > maxh)) h = maxh;
505    evas_object_resize(obj, w, h);
506 }
507
508 static void
509 _elm_win_subobj_callback_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
510 {
511    Elm_Win *win = elm_widget_data_get(data);
512    win->subobjs = eina_list_remove(win->subobjs, obj);
513    _elm_win_eval_subobjs(win->win_obj);
514 }
515
516 static void
517 _elm_win_subobj_callback_changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
518 {
519    _elm_win_eval_subobjs(data);
520 }
521
522 void
523 _elm_win_shutdown(void)
524 {
525    while (_elm_win_list)
526      evas_object_del(_elm_win_list->data);
527 }
528
529 void
530 _elm_win_rescale(Elm_Theme *th, Eina_Bool use_theme)
531 {
532    const Eina_List *l;
533    Evas_Object *obj;
534
535    if (!use_theme)
536      {
537         EINA_LIST_FOREACH(_elm_win_list, l, obj)
538           elm_widget_theme(obj);
539      }
540    else
541      {
542         EINA_LIST_FOREACH(_elm_win_list, l, obj)
543           elm_widget_theme_specific(obj, th, EINA_FALSE);
544      }
545 }
546
547 #ifdef HAVE_ELEMENTARY_X
548 static Eina_Bool
549 _elm_win_client_message(void *data, int type __UNUSED__, void *event)
550 {
551    Elm_Win *win = data;
552    Ecore_X_Event_Client_Message *e = event;
553
554    if (e->format != 32) return ECORE_CALLBACK_PASS_ON;
555    if (e->message_type == ECORE_X_ATOM_E_COMP_FLUSH)
556      {
557         if ((unsigned)e->data.l[0] == win->xwin)
558           {
559              Evas *evas = evas_object_evas_get(win->win_obj);
560              if (evas)
561                {
562                   edje_file_cache_flush();
563                   edje_collection_cache_flush();
564                   evas_image_cache_flush(evas);
565                   evas_font_cache_flush(evas);
566                }
567           }
568      }
569    else if (e->message_type == ECORE_X_ATOM_E_COMP_DUMP)
570      {
571         if ((unsigned)e->data.l[0] == win->xwin)
572           {
573              Evas *evas = evas_object_evas_get(win->win_obj);
574              if (evas)
575                {
576                   edje_file_cache_flush();
577                   edje_collection_cache_flush();
578                   evas_image_cache_flush(evas);
579                   evas_font_cache_flush(evas);
580                   evas_render_dump(evas);
581                }
582           }
583      }
584    return ECORE_CALLBACK_PASS_ON;
585 }
586 #endif
587
588 static void
589 _elm_win_focus_target_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
590 {
591    Elm_Win *win = data;
592
593    win->focus_highlight.geometry_changed = EINA_TRUE;
594    _elm_win_focus_highlight_reconfigure_job_start(win);
595 }
596
597 static void
598 _elm_win_focus_target_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
599 {
600    Elm_Win *win = data;
601
602    win->focus_highlight.geometry_changed = EINA_TRUE;
603    _elm_win_focus_highlight_reconfigure_job_start(win);
604 }
605
606 static void
607 _elm_win_focus_target_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
608 {
609    Elm_Win *win = data;
610
611    win->focus_highlight.cur.target = NULL;
612
613    _elm_win_focus_highlight_reconfigure_job_start(win);
614 }
615
616 static void
617 _elm_win_focus_target_callbacks_add(Elm_Win *win)
618 {
619    Evas_Object *obj = win->focus_highlight.cur.target;
620
621    evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE,
622                                   _elm_win_focus_target_move, win);
623    evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE,
624                                   _elm_win_focus_target_resize, win);
625    evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
626                                   _elm_win_focus_target_del, win);
627 }
628
629 static void
630 _elm_win_focus_target_callbacks_del(Elm_Win *win)
631 {
632    Evas_Object *obj = win->focus_highlight.cur.target;
633
634    evas_object_event_callback_del_full(obj, EVAS_CALLBACK_MOVE,
635                                        _elm_win_focus_target_move, win);
636    evas_object_event_callback_del_full(obj, EVAS_CALLBACK_RESIZE,
637                                        _elm_win_focus_target_resize, win);
638    evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL,
639                                        _elm_win_focus_target_del, win);
640 }
641
642 static Evas_Object *
643 _elm_win_focus_target_get(Evas_Object *obj)
644 {
645    Evas_Object *o = obj;
646
647    do
648      {
649         if (elm_widget_is(o))
650           {
651              if (!elm_widget_highlight_ignore_get(o))
652                break;
653              o = elm_widget_parent_get(o);
654              if (!o)
655                o = evas_object_smart_parent_get(o);
656           }
657         else
658           {
659              o = elm_widget_parent_widget_get(o);
660              if (!o)
661                o = evas_object_smart_parent_get(o);
662           }
663      }
664    while (o);
665
666    return o;
667 }
668
669 static void
670 _elm_win_object_focus_in(void *data, Evas *e __UNUSED__, void *event_info)
671 {
672    Evas_Object *obj = event_info, *target;
673    Elm_Win *win = data;
674
675    if (win->focus_highlight.cur.target == obj)
676      return;
677
678    target = _elm_win_focus_target_get(obj);
679    win->focus_highlight.cur.target = target;
680    if (elm_widget_highlight_in_theme_get(target))
681      win->focus_highlight.cur.handled = EINA_TRUE;
682    else
683      _elm_win_focus_target_callbacks_add(win);
684
685    _elm_win_focus_highlight_reconfigure_job_start(win);
686 }
687
688 static void
689 _elm_win_object_focus_out(void *data, Evas *e __UNUSED__, void *event_info __UNUSED__)
690 {
691    Elm_Win *win = data;
692
693    if (!win->focus_highlight.cur.target)
694      return;
695
696    if (!win->focus_highlight.cur.handled)
697      _elm_win_focus_target_callbacks_del(win);
698    win->focus_highlight.cur.target = NULL;
699    win->focus_highlight.cur.handled = EINA_FALSE;
700
701    _elm_win_focus_highlight_reconfigure_job_start(win);
702 }
703
704 static void
705 _elm_win_focus_highlight_hide(void *data __UNUSED__, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
706 {
707    evas_object_hide(obj);
708 }
709
710 static void
711 _elm_win_focus_highlight_init(Elm_Win *win)
712 {
713    evas_event_callback_add(win->evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
714                            _elm_win_object_focus_in, win);
715    evas_event_callback_add(win->evas,
716                            EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
717                            _elm_win_object_focus_out, win);
718
719    win->focus_highlight.cur.target = evas_focus_get(win->evas);
720
721    win->focus_highlight.top = edje_object_add(win->evas);
722    win->focus_highlight.changed_theme = EINA_TRUE;
723    edje_object_signal_callback_add(win->focus_highlight.top,
724                                    "elm,action,focus,hide,end", "",
725                                    _elm_win_focus_highlight_hide, NULL);
726    edje_object_signal_callback_add(win->focus_highlight.top,
727                                    "elm,action,focus,anim,end", "",
728                                    _elm_win_focus_highlight_anim_end, win);
729    _elm_win_focus_highlight_reconfigure_job_start(win);
730 }
731
732 static void
733 _elm_win_focus_highlight_shutdown(Elm_Win *win)
734 {
735    _elm_win_focus_highlight_reconfigure_job_stop(win);
736    if (win->focus_highlight.cur.target)
737      {
738         _elm_win_focus_target_callbacks_del(win);
739         win->focus_highlight.cur.target = NULL;
740      }
741    if (win->focus_highlight.top)
742      {
743         evas_object_del(win->focus_highlight.top);
744         win->focus_highlight.top = NULL;
745      }
746
747    evas_event_callback_del_full(win->evas,
748                                 EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
749                                 _elm_win_object_focus_in, win);
750    evas_event_callback_del_full(win->evas,
751                                 EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
752                                 _elm_win_object_focus_out, win);
753 }
754
755 static void
756 _elm_win_focus_highlight_visible_set(Elm_Win *win, Eina_Bool visible)
757 {
758    Evas_Object *top;
759
760    top = win->focus_highlight.top;
761    if (visible)
762      {
763         if (top)
764           {
765              evas_object_show(top);
766              edje_object_signal_emit(top, "elm,action,focus,show", "elm");
767           }
768      }
769    else
770      {
771         if (top)
772           edje_object_signal_emit(top, "elm,action,focus,hide", "elm");
773      }
774 }
775
776 static void
777 _elm_win_focus_highlight_reconfigure_job(void *data)
778 {
779    _elm_win_focus_highlight_reconfigure((Elm_Win *)data);
780 }
781
782 static void
783 _elm_win_focus_highlight_reconfigure_job_start(Elm_Win *win)
784 {
785    if (win->focus_highlight.reconf_job)
786      ecore_job_del(win->focus_highlight.reconf_job);
787    win->focus_highlight.reconf_job = ecore_job_add(
788       _elm_win_focus_highlight_reconfigure_job, win);
789 }
790
791 static void
792 _elm_win_focus_highlight_reconfigure_job_stop(Elm_Win *win)
793 {
794    if (win->focus_highlight.reconf_job)
795      ecore_job_del(win->focus_highlight.reconf_job);
796    win->focus_highlight.reconf_job = NULL;
797 }
798
799 static void
800 _elm_win_focus_highlight_simple_setup(Elm_Win *win, Evas_Object *obj)
801 {
802    Evas_Object *clip, *target = win->focus_highlight.cur.target;
803    Evas_Coord x, y, w, h;
804
805    clip = evas_object_clip_get(target);
806    evas_object_geometry_get(target, &x, &y, &w, &h);
807
808    evas_object_move(obj, x, y);
809    evas_object_resize(obj, w, h);
810    evas_object_clip_set(obj, clip);
811 }
812
813 static void
814 _elm_win_focus_highlight_anim_setup(Elm_Win *win, Evas_Object *obj)
815 {
816    Evas_Coord tx, ty, tw, th;
817    Evas_Coord w, h, px, py, pw, ph;
818    Edje_Message_Int_Set *m;
819    Evas_Object *previous = win->focus_highlight.prev.target;
820    Evas_Object *target = win->focus_highlight.cur.target;
821
822    evas_object_geometry_get(win->win_obj, NULL, NULL, &w, &h);
823    evas_object_geometry_get(target, &tx, &ty, &tw, &th);
824    evas_object_geometry_get(previous, &px, &py, &pw, &ph);
825    evas_object_move(obj, 0, 0);
826    evas_object_resize(obj, tw, th);
827    evas_object_clip_unset(obj);
828
829    m = alloca(sizeof(*m) + (sizeof(int) * 8));
830    m->count = 8;
831    m->val[0] = px;
832    m->val[1] = py;
833    m->val[2] = pw;
834    m->val[3] = ph;
835    m->val[4] = tx;
836    m->val[5] = ty;
837    m->val[6] = tw;
838    m->val[7] = th;
839    edje_object_message_send(obj, EDJE_MESSAGE_INT_SET, 1, m);
840 }
841
842 static void
843 _elm_win_focus_highlight_anim_end(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
844 {
845    Elm_Win *win = data;
846    _elm_win_focus_highlight_simple_setup(win, obj);
847 }
848
849 static void
850 _elm_win_focus_highlight_reconfigure(Elm_Win *win)
851 {
852    Evas_Object *target = win->focus_highlight.cur.target;
853    Evas_Object *previous = win->focus_highlight.prev.target;
854    Evas_Object *top = win->focus_highlight.top;
855    Eina_Bool visible_changed;
856    Eina_Bool common_visible;
857    const char *sig = NULL;
858
859    _elm_win_focus_highlight_reconfigure_job_stop(win);
860
861    visible_changed = (win->focus_highlight.cur.visible !=
862                       win->focus_highlight.prev.visible);
863
864    if ((target == previous) && (!visible_changed) &&
865        (!win->focus_highlight.geometry_changed))
866      return;
867
868    if ((previous) && (win->focus_highlight.prev.handled))
869      elm_widget_signal_emit(previous, "elm,action,focus_highlight,hide", "elm");
870
871    if (!target)
872      common_visible = EINA_FALSE;
873    else if (win->focus_highlight.cur.handled)
874      {
875         common_visible = EINA_FALSE;
876         if (win->focus_highlight.cur.visible)
877           sig = "elm,action,focus_highlight,show";
878         else
879           sig = "elm,action,focus_highlight,hide";
880      }
881    else
882      common_visible = win->focus_highlight.cur.visible;
883
884    _elm_win_focus_highlight_visible_set(win, common_visible);
885    if (sig)
886      elm_widget_signal_emit(target, sig, "elm");
887
888    if ((!target) || (!common_visible) || (win->focus_highlight.cur.handled))
889      goto the_end;
890
891    if (win->focus_highlight.changed_theme)
892      {
893         const char *str;
894         if (win->focus_highlight.style)
895           str = win->focus_highlight.style;
896         else
897           str = "default";
898         _elm_theme_object_set(win->win_obj, top, "focus_highlight", "top",
899                               str);
900         win->focus_highlight.changed_theme = EINA_FALSE;
901
902         if (_elm_config->focus_highlight_animate)
903           {
904              str = edje_object_data_get(win->focus_highlight.top, "animate");
905              win->focus_highlight.top_animate = ((str) && (!strcmp(str, "on")));
906           }
907      }
908
909    if ((win->focus_highlight.top_animate) && (previous) &&
910        (!win->focus_highlight.prev.handled))
911      _elm_win_focus_highlight_anim_setup(win, top);
912    else
913      _elm_win_focus_highlight_simple_setup(win, top);
914    evas_object_raise(top);
915
916 the_end:
917    win->focus_highlight.geometry_changed = EINA_FALSE;
918    win->focus_highlight.prev = win->focus_highlight.cur;
919 }
920
921 #ifdef ELM_DEBUG
922 static void
923 _debug_key_down(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
924 {
925    Evas_Event_Key_Down *ev = event_info;
926
927    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
928      return;
929
930
931    if ((strcmp(ev->keyname, "F12")) ||
932        (!evas_key_modifier_is_set(ev->modifiers, "Control")))
933      return;
934
935    printf("Tree graph generated.\n");
936    elm_object_tree_dot_dump(obj, "./dump.dot");
937 }
938 #endif
939
940 /**
941  * Adds a window object. If this is the first window created, pass NULL as
942  * @p parent.
943  *
944  * @param parent Parent object to add the window to, or NULL
945  * @param name The name of the window
946  * @param type The window type, one of the following:
947  * ELM_WIN_BASIC
948  * ELM_WIN_DIALOG_BASIC
949  * ELM_WIN_DESKTOP
950  * ELM_WIN_DOCK
951  * ELM_WIN_TOOLBAR
952  * ELM_WIN_MENU
953  * ELM_WIN_UTILITY
954  * ELM_WIN_SPLASH
955  *
956  * @return The created object, or NULL on failure
957  *
958  * @ingroup Win
959  */
960 EAPI Evas_Object *
961 elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type)
962 {
963    Elm_Win *win;
964    const Eina_List *l;
965    const char *fontpath;
966
967    win = ELM_NEW(Elm_Win);
968
969 #define FALLBACK_TRY(engine)                                            \
970    if (!win->ee)                                                        \
971    do {                                                               \
972         CRITICAL(engine " engine creation failed. Trying software X11."); \
973         win->ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);      \
974    } while (0)
975
976 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
977    if (ENGINE_COMPARE(ELM_SOFTWARE_X11))
978      {
979         win->ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
980 #ifdef HAVE_ELEMENTARY_X
981         win->client_message_handler = ecore_event_handler_add
982            (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
983 #endif
984      }
985    else if (ENGINE_COMPARE(ELM_SOFTWARE_FB))
986      {
987         win->ee = ecore_evas_fb_new(NULL, 0, 1, 1);
988         FALLBACK_TRY("Sofware FB");
989      }
990    else if (ENGINE_COMPARE(ELM_SOFTWARE_DIRECTFB))
991      {
992         win->ee = ecore_evas_directfb_new(NULL, 1, 0, 0, 1, 1);
993         FALLBACK_TRY("Sofware DirectFB");
994      }
995    else if (ENGINE_COMPARE(ELM_SOFTWARE_16_X11))
996      {
997         win->ee = ecore_evas_software_x11_16_new(NULL, 0, 0, 0, 1, 1);
998         FALLBACK_TRY("Sofware-16");
999 #ifdef HAVE_ELEMENTARY_X
1000         win->client_message_handler = ecore_event_handler_add
1001            (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1002 #endif
1003      }
1004    else if (ENGINE_COMPARE(ELM_SOFTWARE_8_X11))
1005      {
1006         win->ee = ecore_evas_software_x11_8_new(NULL, 0, 0, 0, 1, 1);
1007         FALLBACK_TRY("Sofware-8");
1008 #ifdef HAVE_ELEMENTARY_X
1009         win->client_message_handler = ecore_event_handler_add
1010            (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1011 #endif
1012      }
1013    else if (ENGINE_COMPARE(ELM_XRENDER_X11))
1014      {
1015         win->ee = ecore_evas_xrender_x11_new(NULL, 0, 0, 0, 1, 1);
1016         FALLBACK_TRY("XRender");
1017 #ifdef HAVE_ELEMENTARY_X
1018         win->client_message_handler = ecore_event_handler_add
1019            (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1020 #endif
1021      }
1022    else if (ENGINE_COMPARE(ELM_OPENGL_X11))
1023      {
1024         int opt[10];
1025         int opt_i = 0;
1026         
1027         if (_elm_config->vsync)
1028           {
1029              opt[opt_i] = ECORE_EVAS_GL_X11_OPT_VSYNC;
1030              opt_i++;
1031              opt[opt_i] = 1;
1032              opt_i++;
1033           }
1034         if (opt_i > 0)
1035            win->ee = ecore_evas_gl_x11_options_new(NULL, 0, 0, 0, 1, 1, opt);
1036         else
1037            win->ee = ecore_evas_gl_x11_new(NULL, 0, 0, 0, 1, 1);
1038         FALLBACK_TRY("OpenGL");
1039 #ifdef HAVE_ELEMENTARY_X
1040         win->client_message_handler = ecore_event_handler_add
1041            (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1042 #endif
1043      }
1044    else if (ENGINE_COMPARE(ELM_SOFTWARE_WIN32))
1045      {
1046         win->ee = ecore_evas_software_gdi_new(NULL, 0, 0, 1, 1);
1047         FALLBACK_TRY("Sofware Win32");
1048      }
1049    else if (ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE))
1050      {
1051         win->ee = ecore_evas_software_wince_gdi_new(NULL, 0, 0, 1, 1);
1052         FALLBACK_TRY("Sofware-16-WinCE");
1053      }
1054    else if (ENGINE_COMPARE(ELM_SOFTWARE_SDL))
1055      {
1056         win->ee = ecore_evas_sdl_new(NULL, 0, 0, 0, 0, 0, 1);
1057         FALLBACK_TRY("Sofware SDL");
1058      }
1059    else if (ENGINE_COMPARE(ELM_SOFTWARE_16_SDL))
1060      {
1061         win->ee = ecore_evas_sdl16_new(NULL, 0, 0, 0, 0, 0, 1);
1062         FALLBACK_TRY("Sofware-16-SDL");
1063      }
1064    else if (ENGINE_COMPARE(ELM_OPENGL_SDL))
1065      {
1066         win->ee = ecore_evas_gl_sdl_new(NULL, 1, 1, 0, 0);
1067         FALLBACK_TRY("OpenGL SDL");
1068      }
1069 #undef FALLBACK_TRY
1070
1071    if (!win->ee)
1072      {
1073         ERR("Cannot create window.");
1074         free(win);
1075         return NULL;
1076      }
1077 #ifdef HAVE_ELEMENTARY_X
1078    _elm_win_xwindow_get(win);
1079 #endif
1080    if ((_elm_config->bgpixmap) && (!_elm_config->compositing))
1081      ecore_evas_avoid_damage_set(win->ee, ECORE_EVAS_AVOID_DAMAGE_EXPOSE);
1082    // bg pixmap done by x - has other issues like can be redrawn by x before it
1083    // is filled/ready by app
1084    //     ecore_evas_avoid_damage_set(win->ee, ECORE_EVAS_AVOID_DAMAGE_BUILT_IN);
1085
1086    win->type = type;
1087    win->parent = parent;
1088    if (win->parent)
1089      evas_object_event_callback_add(win->parent, EVAS_CALLBACK_DEL,
1090                                     _elm_win_obj_callback_parent_del, win);
1091
1092    win->evas = ecore_evas_get(win->ee);
1093    win->win_obj = elm_widget_add(win->evas);
1094    elm_widget_type_set(win->win_obj, "win");
1095    ELM_SET_WIDTYPE(widtype, "win");
1096    elm_widget_data_set(win->win_obj, win);
1097    elm_widget_event_hook_set(win->win_obj, _elm_win_event_cb);
1098    elm_widget_on_focus_hook_set(win->win_obj, _elm_win_on_focus_hook, NULL);
1099    elm_widget_can_focus_set(win->win_obj, EINA_TRUE);
1100    elm_widget_highlight_ignore_set(win->win_obj, EINA_TRUE);
1101    elm_widget_focus_next_hook_set(win->win_obj, _elm_win_focus_next_hook);
1102    evas_object_color_set(win->win_obj, 0, 0, 0, 0);
1103    evas_object_move(win->win_obj, 0, 0);
1104    evas_object_resize(win->win_obj, 1, 1);
1105    evas_object_layer_set(win->win_obj, 50);
1106    evas_object_pass_events_set(win->win_obj, EINA_TRUE);
1107
1108    evas_object_intercept_show_callback_add(win->win_obj,
1109                                            _elm_win_obj_intercept_show, win);
1110    ecore_evas_object_associate(win->ee, win->win_obj,
1111                                ECORE_EVAS_OBJECT_ASSOCIATE_BASE |
1112                                ECORE_EVAS_OBJECT_ASSOCIATE_STACK |
1113                                ECORE_EVAS_OBJECT_ASSOCIATE_LAYER);
1114    evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_SHOW,
1115                                   _elm_win_obj_callback_show, win);
1116    evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_DEL,
1117                                   _elm_win_obj_callback_del, win);
1118    evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_MOVE,
1119                                   _elm_win_obj_callback_move, win);
1120
1121    ecore_evas_name_class_set(win->ee, name, _elm_appname);
1122    ecore_evas_callback_delete_request_set(win->ee, _elm_win_delete_request);
1123    ecore_evas_callback_resize_set(win->ee, _elm_win_resize);
1124    ecore_evas_callback_focus_in_set(win->ee, _elm_win_focus_in);
1125    ecore_evas_callback_focus_out_set(win->ee, _elm_win_focus_out);
1126    ecore_evas_callback_move_set(win->ee, _elm_win_move);
1127    evas_image_cache_set(win->evas, (_elm_config->image_cache * 1024));
1128    evas_font_cache_set(win->evas, (_elm_config->font_cache * 1024));
1129    EINA_LIST_FOREACH(_elm_config->font_dirs, l, fontpath)
1130       evas_font_path_append(win->evas, fontpath);
1131    if (!_elm_config->font_hinting)
1132      evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_NONE);
1133    else if (_elm_config->font_hinting == 1)
1134      evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_AUTO);
1135    else if (_elm_config->font_hinting == 2)
1136      evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_BYTECODE);
1137
1138 #ifdef HAVE_ELEMENTARY_X
1139    _elm_win_xwin_update(win);
1140 #endif
1141
1142    _elm_win_list = eina_list_append(_elm_win_list, win->win_obj);
1143
1144    if (ENGINE_COMPARE(ELM_SOFTWARE_FB))
1145      {
1146         ecore_evas_fullscreen_set(win->ee, 1);
1147      }
1148 #undef ENGINE_COMPARE
1149
1150    if (_elm_config->focus_highlight_enable)
1151      elm_win_focus_highlight_enabled_set(win->win_obj, EINA_TRUE);
1152
1153 #ifdef ELM_DEBUG
1154    Evas_Modifier_Mask mask = evas_key_modifier_mask_get(win->evas, "Control");
1155    evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_KEY_DOWN,
1156                                   _debug_key_down, win);
1157    Eina_Bool ret = evas_object_key_grab(win->win_obj, "F12", mask, 0, EINA_TRUE);
1158    printf("Key F12 exclusive for dot tree generation. (%d)\n", ret);
1159 #endif
1160    return win->win_obj;
1161 }
1162
1163 /**
1164  * Add @p subobj as a resize object of window @p obj.
1165  *
1166  * @param obj The window object
1167  * @param subobj The resize object to add
1168  *
1169  * @ingroup Win
1170  */
1171 EAPI void
1172 elm_win_resize_object_add(Evas_Object *obj, Evas_Object *subobj)
1173 {
1174    Evas_Coord w, h;
1175    Elm_Win *win;
1176    ELM_CHECK_WIDTYPE(obj, widtype);
1177    win = elm_widget_data_get(obj);
1178    if (!win) return;
1179    win->subobjs = eina_list_append(win->subobjs, subobj);
1180    elm_widget_sub_object_add(obj, subobj);
1181    evas_object_event_callback_add(subobj, EVAS_CALLBACK_DEL,
1182                                   _elm_win_subobj_callback_del, obj);
1183    evas_object_event_callback_add(subobj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1184                                   _elm_win_subobj_callback_changed_size_hints,
1185                                   obj);
1186    ecore_evas_geometry_get(win->ee, NULL, NULL, &w, &h);
1187    evas_object_move(subobj, 0, 0);
1188    evas_object_resize(subobj, w, h);
1189    _elm_win_eval_subobjs(obj);
1190 }
1191
1192 /**
1193  * Delete @p subobj as a resize object of window @p obj.
1194  *
1195  * @param obj The window object
1196  * @param subobj The resize object to add
1197  *
1198  * @ingroup Win
1199  */
1200 EAPI void
1201 elm_win_resize_object_del(Evas_Object *obj, Evas_Object *subobj)
1202 {
1203    Elm_Win *win;
1204    ELM_CHECK_WIDTYPE(obj, widtype);
1205    win = elm_widget_data_get(obj);
1206    if (!win) return;
1207    evas_object_event_callback_del_full(subobj,
1208                                        EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1209                                        _elm_win_subobj_callback_changed_size_hints,
1210                                        obj);
1211    evas_object_event_callback_del_full(subobj, EVAS_CALLBACK_DEL,
1212                                        _elm_win_subobj_callback_del, obj);
1213    win->subobjs = eina_list_remove(win->subobjs, subobj);
1214    elm_widget_sub_object_del(obj, subobj);
1215    _elm_win_eval_subobjs(obj);
1216 }
1217
1218 /**
1219  * Set the title of the window
1220  *
1221  * @param obj The window object
1222  * @param title The title to set
1223  *
1224  * @ingroup Win
1225  */
1226 EAPI void
1227 elm_win_title_set(Evas_Object *obj, const char *title)
1228 {
1229    Elm_Win *win;
1230    ELM_CHECK_WIDTYPE(obj, widtype);
1231    win = elm_widget_data_get(obj);
1232    if (!win) return;
1233    ecore_evas_title_set(win->ee, title);
1234 }
1235
1236 /**
1237  * Get the title of the window
1238  *
1239  * @param obj The window object
1240  * @return The title
1241  *
1242  * @ingroup Win
1243  */
1244 EAPI const char *
1245 elm_win_title_get(const Evas_Object *obj)
1246 {
1247    Elm_Win *win;
1248    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1249    win = elm_widget_data_get(obj);
1250    if (!win) return NULL;
1251    return ecore_evas_title_get(win->ee);
1252 }
1253
1254 /**
1255  * Set the window's autodel state.
1256  *
1257  * @param obj The window object
1258  * @param autodel If true, the window will automatically delete itself when closed
1259  *
1260  * @ingroup Win
1261  */
1262 EAPI void
1263 elm_win_autodel_set(Evas_Object *obj, Eina_Bool autodel)
1264 {
1265    Elm_Win *win;
1266    ELM_CHECK_WIDTYPE(obj, widtype);
1267    win = elm_widget_data_get(obj);
1268    if (!win) return;
1269    win->autodel = autodel;
1270 }
1271
1272 /**
1273  * Get the window's autodel state.
1274  *
1275  * @param obj The window object
1276  * @return If the window will automatically delete itself when closed
1277  *
1278  * @ingroup Win
1279  */
1280 EAPI Eina_Bool
1281 elm_win_autodel_get(const Evas_Object *obj)
1282 {
1283    Elm_Win *win;
1284    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1285    win = elm_widget_data_get(obj);
1286    if (!win) return EINA_FALSE;
1287    return win->autodel;
1288 }
1289
1290 /**
1291  * Activate a window object.
1292  *
1293  * @param obj The window object
1294  *
1295  * @ingroup Win
1296  */
1297 EAPI void
1298 elm_win_activate(Evas_Object *obj)
1299 {
1300    Elm_Win *win;
1301    ELM_CHECK_WIDTYPE(obj, widtype);
1302    win = elm_widget_data_get(obj);
1303    if (!win) return;
1304    ecore_evas_activate(win->ee);
1305 }
1306
1307 /**
1308  * Lower a window object.
1309  *
1310  * @param obj The window object
1311  *
1312  * @ingroup Win
1313  */
1314 EAPI void
1315 elm_win_lower(Evas_Object *obj)
1316 {
1317    Elm_Win *win;
1318    ELM_CHECK_WIDTYPE(obj, widtype);
1319    win = elm_widget_data_get(obj);
1320    if (!win) return;
1321    ecore_evas_lower(win->ee);
1322 }
1323
1324 /**
1325  * Raise a window object.
1326  *
1327  * @param obj The window object
1328  *
1329  * @ingroup Win
1330  */
1331 EAPI void
1332 elm_win_raise(Evas_Object *obj)
1333 {
1334    Elm_Win *win;
1335    ELM_CHECK_WIDTYPE(obj, widtype);
1336    win = elm_widget_data_get(obj);
1337    if (!win) return;
1338    ecore_evas_raise(win->ee);
1339 }
1340
1341 /**
1342  * Set the borderless state of a window.
1343  *
1344  * @param obj The window object
1345  * @param borderless If true, the window is borderless
1346  *
1347  * @ingroup Win
1348  */
1349 EAPI void
1350 elm_win_borderless_set(Evas_Object *obj, Eina_Bool borderless)
1351 {
1352    Elm_Win *win;
1353    ELM_CHECK_WIDTYPE(obj, widtype);
1354    win = elm_widget_data_get(obj);
1355    if (!win) return;
1356    ecore_evas_borderless_set(win->ee, borderless);
1357 #ifdef HAVE_ELEMENTARY_X
1358    _elm_win_xwin_update(win);
1359 #endif
1360 }
1361
1362 /**
1363  * Get the borderless state of a window.
1364  *
1365  * @param obj The window object
1366  * @return If true, the window is borderless
1367  *
1368  * @ingroup Win
1369  */
1370 EAPI Eina_Bool
1371 elm_win_borderless_get(const Evas_Object *obj)
1372 {
1373    Elm_Win *win;
1374    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1375    win = elm_widget_data_get(obj);
1376    if (!win) return EINA_FALSE;
1377    return ecore_evas_borderless_get(win->ee);
1378 }
1379
1380 /**
1381  * Set the shaped state of a window.
1382  *
1383  * @param obj The window object
1384  * @param shaped If true, the window is shaped
1385  *
1386  * @ingroup Win
1387  */
1388 EAPI void
1389 elm_win_shaped_set(Evas_Object *obj, Eina_Bool shaped)
1390 {
1391    Elm_Win *win;
1392    ELM_CHECK_WIDTYPE(obj, widtype);
1393    win = elm_widget_data_get(obj);
1394    if (!win) return;
1395    ecore_evas_shaped_set(win->ee, shaped);
1396 #ifdef HAVE_ELEMENTARY_X
1397    _elm_win_xwin_update(win);
1398 #endif
1399 }
1400
1401 /**
1402  * Get the shaped state of a window.
1403  *
1404  * @param obj The window object
1405  * @return If true, the window is shaped
1406  *
1407  * @ingroup Win
1408  */
1409 EAPI Eina_Bool
1410 elm_win_shaped_get(const Evas_Object *obj)
1411 {
1412    Elm_Win *win;
1413    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1414    win = elm_widget_data_get(obj);
1415    if (!win) return EINA_FALSE;
1416    return ecore_evas_shaped_get(win->ee);
1417 }
1418
1419 /**
1420  * Set the alpha channel state of a window.
1421  *
1422  * @param obj The window object
1423  * @param alpha If true, the window has an alpha channel
1424  *
1425  * @ingroup Win
1426  */
1427 EAPI void
1428 elm_win_alpha_set(Evas_Object *obj, Eina_Bool alpha)
1429 {
1430    Elm_Win *win;
1431    ELM_CHECK_WIDTYPE(obj, widtype);
1432    win = elm_widget_data_get(obj);
1433    if (!win) return;
1434 #ifdef HAVE_ELEMENTARY_X
1435    if (win->xwin)
1436      {
1437         if (alpha)
1438           {
1439              if (!_elm_config->compositing)
1440                elm_win_shaped_set(obj, alpha);
1441              else
1442                ecore_evas_alpha_set(win->ee, alpha);
1443           }
1444         else
1445           ecore_evas_alpha_set(win->ee, alpha);
1446         _elm_win_xwin_update(win);
1447      }
1448    else
1449 #endif
1450      ecore_evas_alpha_set(win->ee, alpha);
1451 }
1452
1453 /**
1454  * Get the alpha channel state of a window.
1455  *
1456  * @param obj The window object
1457  * @return If true, the window has an alpha channel
1458  *
1459  * @ingroup Win
1460  */
1461 EAPI Eina_Bool
1462 elm_win_alpha_get(const Evas_Object *obj)
1463 {
1464    Elm_Win *win;
1465    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1466    win = elm_widget_data_get(obj);
1467    if (!win) return EINA_FALSE;
1468    return ecore_evas_alpha_get(win->ee);
1469 }
1470
1471 /**
1472  * Set the transparency state of a window.
1473  *
1474  * @param obj The window object
1475  * @param transparent If true, the window is transparent
1476  *
1477  * @ingroup Win
1478  */
1479 EAPI void
1480 elm_win_transparent_set(Evas_Object *obj, Eina_Bool transparent)
1481 {
1482    Elm_Win *win;
1483    ELM_CHECK_WIDTYPE(obj, widtype);
1484    win = elm_widget_data_get(obj);
1485    if (!win) return;
1486
1487 #ifdef HAVE_ELEMENTARY_X
1488    if (win->xwin)
1489      {
1490         ecore_evas_transparent_set(win->ee, transparent);
1491         _elm_win_xwin_update(win);
1492      }
1493    else
1494 #endif
1495      ecore_evas_transparent_set(win->ee, transparent);
1496 }
1497
1498 /**
1499  * Get the transparency state of a window.
1500  *
1501  * @param obj The window object
1502  * @return If true, the window is transparent
1503  *
1504  * @ingroup Win
1505  */
1506 EAPI Eina_Bool
1507 elm_win_transparent_get(const Evas_Object *obj)
1508 {
1509    Elm_Win *win;
1510    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1511    win = elm_widget_data_get(obj);
1512    if (!win) return EINA_FALSE;
1513
1514    return ecore_evas_transparent_get(win->ee);
1515 }
1516
1517 /**
1518  * Set the override state of a window.
1519  *
1520  * @param obj The window object
1521  * @param override If true, the window is overridden
1522  *
1523  * @ingroup Win
1524  */
1525 EAPI void
1526 elm_win_override_set(Evas_Object *obj, Eina_Bool override)
1527 {
1528    Elm_Win *win;
1529    ELM_CHECK_WIDTYPE(obj, widtype);
1530    win = elm_widget_data_get(obj);
1531    if (!win) return;
1532    ecore_evas_override_set(win->ee, override);
1533 #ifdef HAVE_ELEMENTARY_X
1534    _elm_win_xwin_update(win);
1535 #endif
1536 }
1537
1538 /**
1539  * Get the override state of a window.
1540  *
1541  * @param obj The window object
1542  * @return If true, the window is overridden
1543  *
1544  * @ingroup Win
1545  */
1546 EAPI Eina_Bool
1547 elm_win_override_get(const Evas_Object *obj)
1548 {
1549    Elm_Win *win;
1550    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1551    win = elm_widget_data_get(obj);
1552    if (!win) return EINA_FALSE;
1553    return ecore_evas_override_get(win->ee);
1554 }
1555
1556 /**
1557  * Set the fullscreen state of a window.
1558  *
1559  * @param obj The window object
1560  * @param fullscreen If true, the window is fullscreen
1561  *
1562  * @ingroup Win
1563  */
1564 EAPI void
1565 elm_win_fullscreen_set(Evas_Object *obj, Eina_Bool fullscreen)
1566 {
1567    Elm_Win *win;
1568    ELM_CHECK_WIDTYPE(obj, widtype);
1569    win = elm_widget_data_get(obj);
1570    if (!win) return;
1571
1572 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
1573    if (ENGINE_COMPARE(ELM_SOFTWARE_FB) ||
1574        ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE))
1575      {
1576         // these engines... can ONLY be fullscreen
1577         return;
1578      }
1579    else
1580      {
1581         ecore_evas_fullscreen_set(win->ee, fullscreen);
1582 #ifdef HAVE_ELEMENTARY_X
1583         _elm_win_xwin_update(win);
1584 #endif
1585      }
1586 #undef ENGINE_COMPARE
1587 }
1588
1589 /**
1590  * Get the fullscreen state of a window.
1591  *
1592  * @param obj The window object
1593  * @return If true, the window is fullscreen
1594  *
1595  * @ingroup Win
1596  */
1597 EAPI Eina_Bool
1598 elm_win_fullscreen_get(const Evas_Object *obj)
1599 {
1600    Elm_Win *win;
1601    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1602    win = elm_widget_data_get(obj);
1603    if (!win) return EINA_FALSE;
1604
1605 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
1606    if (ENGINE_COMPARE(ELM_SOFTWARE_FB) ||
1607        ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE))
1608      {
1609         // these engines... can ONLY be fullscreen
1610         return EINA_TRUE;
1611      }
1612    else
1613      {
1614         return ecore_evas_fullscreen_get(win->ee);
1615      }
1616 #undef ENGINE_COMPARE
1617 }
1618
1619 /**
1620  * Set the maximized state of a window.
1621  *
1622  * @param obj The window object
1623  * @param maximized If true, the window is maximized
1624  *
1625  * @ingroup Win
1626  */
1627 EAPI void
1628 elm_win_maximized_set(Evas_Object *obj, Eina_Bool maximized)
1629 {
1630    Elm_Win *win;
1631    ELM_CHECK_WIDTYPE(obj, widtype);
1632    win = elm_widget_data_get(obj);
1633    if (!win) return;
1634    ecore_evas_maximized_set(win->ee, maximized);
1635 #ifdef HAVE_ELEMENTARY_X
1636    _elm_win_xwin_update(win);
1637 #endif
1638 }
1639
1640 /**
1641  * Get the maximized state of a window.
1642  *
1643  * @param obj The window object
1644  * @return If true, the window is maximized
1645  *
1646  * @ingroup Win
1647  */
1648 EAPI Eina_Bool
1649 elm_win_maximized_get(const Evas_Object *obj)
1650 {
1651    Elm_Win *win;
1652    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1653    win = elm_widget_data_get(obj);
1654    if (!win) return EINA_FALSE;
1655    return ecore_evas_maximized_get(win->ee);
1656 }
1657
1658 /**
1659  * Set the iconified state of a window.
1660  *
1661  * @param obj The window object
1662  * @param iconified If true, the window is iconified
1663  *
1664  * @ingroup Win
1665  */
1666 EAPI void
1667 elm_win_iconified_set(Evas_Object *obj, Eina_Bool iconified)
1668 {
1669    Elm_Win *win;
1670    ELM_CHECK_WIDTYPE(obj, widtype);
1671    win = elm_widget_data_get(obj);
1672    if (!win) return;
1673    ecore_evas_iconified_set(win->ee, iconified);
1674 #ifdef HAVE_ELEMENTARY_X
1675    _elm_win_xwin_update(win);
1676 #endif
1677 }
1678
1679 /**
1680  * Get the iconified state of a window.
1681  *
1682  * @param obj The window object
1683  * @return If true, the window is iconified
1684  *
1685  * @ingroup Win
1686  */
1687 EAPI Eina_Bool
1688 elm_win_iconified_get(const Evas_Object *obj)
1689 {
1690    Elm_Win *win;
1691    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1692    win = elm_widget_data_get(obj);
1693    if (!win) return EINA_FALSE;
1694    return ecore_evas_iconified_get(win->ee);
1695 }
1696
1697 /**
1698  * Set the layer of the window.
1699  *
1700  * @param obj The window object
1701  * @param layer The layer of the window
1702  *
1703  * @ingroup Win
1704  */
1705 EAPI void
1706 elm_win_layer_set(Evas_Object *obj, int layer)
1707 {
1708    Elm_Win *win;
1709    ELM_CHECK_WIDTYPE(obj, widtype);
1710    win = elm_widget_data_get(obj);
1711    if (!win) return;
1712    ecore_evas_layer_set(win->ee, layer);
1713 #ifdef HAVE_ELEMENTARY_X
1714    _elm_win_xwin_update(win);
1715 #endif
1716 }
1717
1718 /**
1719  * Get the layer of the window.
1720  *
1721  * @param obj The window object
1722  * @return The layer of the window
1723  *
1724  * @ingroup Win
1725  */
1726 EAPI int
1727 elm_win_layer_get(const Evas_Object *obj)
1728 {
1729    Elm_Win *win;
1730    ELM_CHECK_WIDTYPE(obj, widtype) -1;
1731    win = elm_widget_data_get(obj);
1732    if (!win) return -1;
1733    return ecore_evas_layer_get(win->ee);
1734 }
1735
1736 /**
1737  * Set the rotation of the window.
1738  *
1739  * @param obj The window object
1740  * @param rotation The rotation of the window, in degrees (0-360)
1741  *
1742  * @ingroup Win
1743  */
1744 EAPI void
1745 elm_win_rotation_set(Evas_Object *obj, int rotation)
1746 {
1747    Elm_Win *win;
1748    ELM_CHECK_WIDTYPE(obj, widtype);
1749    win = elm_widget_data_get(obj);
1750    if (!win) return;
1751    if (win->rot == rotation) return;
1752    win->rot = rotation;
1753    ecore_evas_rotation_set(win->ee, rotation);
1754    evas_object_size_hint_min_set(obj, -1, -1);
1755    evas_object_size_hint_max_set(obj, -1, -1);
1756    _elm_win_eval_subobjs(obj);
1757 #ifdef HAVE_ELEMENTARY_X
1758    _elm_win_xwin_update(win);
1759 #endif
1760 }
1761
1762 /**
1763  * Rotates the window and resizes it
1764  *
1765  * @param obj The window object
1766  * @param layer The rotation of the window in degrees (0-360)
1767  *
1768  * @ingroup Win
1769  */
1770 EAPI void
1771 elm_win_rotation_with_resize_set(Evas_Object *obj, int rotation)
1772 {
1773    Elm_Win *win;
1774    ELM_CHECK_WIDTYPE(obj, widtype);
1775    win = elm_widget_data_get(obj);
1776    if (!win) return;
1777    if (win->rot == rotation) return;
1778    win->rot = rotation;
1779    ecore_evas_rotation_with_resize_set(win->ee, rotation);
1780    evas_object_size_hint_min_set(obj, -1, -1);
1781    evas_object_size_hint_max_set(obj, -1, -1);
1782    _elm_win_eval_subobjs(obj);
1783 #ifdef HAVE_ELEMENTARY_X
1784    _elm_win_xwin_update(win);
1785 #endif
1786 }
1787
1788 /**
1789  * Get the rotation of the window.
1790  *
1791  * @param obj The window object
1792  * @return The rotation of the window in degrees (0-360)
1793  *
1794  * @ingroup Win
1795  */
1796 EAPI int
1797 elm_win_rotation_get(const Evas_Object *obj)
1798 {
1799    Elm_Win *win;
1800    ELM_CHECK_WIDTYPE(obj, widtype) -1;
1801    win = elm_widget_data_get(obj);
1802    if (!win) return -1;
1803    return win->rot;
1804 }
1805
1806 /**
1807  * Set the sticky state of the window.
1808  *
1809  * @param obj The window object
1810  * @param sticky If true, the window's sticky state is enabled
1811  *
1812  * @ingroup Win
1813  */
1814 EAPI void
1815 elm_win_sticky_set(Evas_Object *obj, Eina_Bool sticky)
1816 {
1817    Elm_Win *win;
1818    ELM_CHECK_WIDTYPE(obj, widtype);
1819    win = elm_widget_data_get(obj);
1820    if (!win) return;
1821    ecore_evas_sticky_set(win->ee, sticky);
1822 #ifdef HAVE_ELEMENTARY_X
1823    _elm_win_xwin_update(win);
1824 #endif
1825 }
1826
1827 /**
1828  * Get the sticky state of the window.
1829  *
1830  * @param obj The window object
1831  * @return If true, the window's sticky state is enabled
1832  *
1833  * @ingroup Win
1834  */
1835 EAPI Eina_Bool
1836 elm_win_sticky_get(const Evas_Object *obj)
1837 {
1838    Elm_Win *win;
1839    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1840    win = elm_widget_data_get(obj);
1841    if (!win) return EINA_FALSE;
1842    return ecore_evas_sticky_get(win->ee);
1843 }
1844
1845 /**
1846  * Sets the keyboard mode of the window.
1847  *
1848  * @param obj The window object
1849  * @param mode The mode to set; one of:
1850  * ELM_WIN_KEYBOARD_UNKNOWN
1851  * ELM_WIN_KEYBOARD_OFF
1852  * ELM_WIN_KEYBOARD_ON
1853  * ELM_WIN_KEYBOARD_ALPHA
1854  * ELM_WIN_KEYBOARD_NUMERIC
1855  * ELM_WIN_KEYBOARD_PIN
1856  * ELM_WIN_KEYBOARD_PHONE_NUMBER
1857  * ELM_WIN_KEYBOARD_HEX
1858  * ELM_WIN_KEYBOARD_TERMINAL
1859  * ELM_WIN_KEYBOARD_PASSWORD
1860  * ELM_WIN_KEYBOARD_IP
1861  * ELM_WIN_KEYBOARD_HOST
1862  * ELM_WIN_KEYBOARD_FILE
1863  * ELM_WIN_KEYBOARD_URL
1864  * ELM_WIN_KEYBOARD_KEYPAD
1865  * ELM_WIN_KEYBOARD_J2ME
1866  *
1867  * @ingroup Win
1868  */
1869 EAPI void
1870 elm_win_keyboard_mode_set(Evas_Object *obj, Elm_Win_Keyboard_Mode mode)
1871 {
1872    Elm_Win *win;
1873    ELM_CHECK_WIDTYPE(obj, widtype);
1874    win = elm_widget_data_get(obj);
1875    if (!win) return;
1876    if (mode == win->kbdmode) return;
1877 #ifdef HAVE_ELEMENTARY_X
1878    _elm_win_xwindow_get(win);
1879 #endif
1880    win->kbdmode = mode;
1881 #ifdef HAVE_ELEMENTARY_X
1882    if (win->xwin)
1883      ecore_x_e_virtual_keyboard_state_set
1884         (win->xwin, (Ecore_X_Virtual_Keyboard_State)win->kbdmode);
1885 #endif
1886 }
1887
1888 /**
1889  * Gets the keyboard mode of the window.
1890  *
1891  * @param obj The window object
1892  * @return The mode; one of:
1893  * ELM_WIN_KEYBOARD_UNKNOWN
1894  * ELM_WIN_KEYBOARD_OFF
1895  * ELM_WIN_KEYBOARD_ON
1896  * ELM_WIN_KEYBOARD_ALPHA
1897  * ELM_WIN_KEYBOARD_NUMERIC
1898  * ELM_WIN_KEYBOARD_PIN
1899  * ELM_WIN_KEYBOARD_PHONE_NUMBER
1900  * ELM_WIN_KEYBOARD_HEX
1901  * ELM_WIN_KEYBOARD_TERMINAL
1902  * ELM_WIN_KEYBOARD_PASSWORD
1903  * ELM_WIN_KEYBOARD_IP
1904  * ELM_WIN_KEYBOARD_HOST
1905  * ELM_WIN_KEYBOARD_FILE
1906  * ELM_WIN_KEYBOARD_URL
1907  * ELM_WIN_KEYBOARD_KEYPAD
1908  * ELM_WIN_KEYBOARD_J2ME
1909  *
1910  * @ingroup Win
1911  */
1912 EAPI Elm_Win_Keyboard_Mode
1913 elm_win_keyboard_mode_get(const Evas_Object *obj)
1914 {
1915    Elm_Win *win;
1916    ELM_CHECK_WIDTYPE(obj, widtype) ELM_WIN_KEYBOARD_UNKNOWN;
1917    win = elm_widget_data_get(obj);
1918    if (!win) return ELM_WIN_KEYBOARD_UNKNOWN;
1919    return win->kbdmode;
1920 }
1921
1922 /**
1923  * Sets whether the window is a keyboard.
1924  *
1925  * @param obj The window object
1926  * @param is_keyboard If true, the window is a virtual keyboard
1927  *
1928  * @ingroup Win
1929  */
1930 EAPI void
1931 elm_win_keyboard_win_set(Evas_Object *obj, Eina_Bool is_keyboard)
1932 {
1933    Elm_Win *win;
1934    ELM_CHECK_WIDTYPE(obj, widtype);
1935    win = elm_widget_data_get(obj);
1936    if (!win) return;
1937 #ifdef HAVE_ELEMENTARY_X
1938    _elm_win_xwindow_get(win);
1939    if (win->xwin)
1940      ecore_x_e_virtual_keyboard_set(win->xwin, is_keyboard);
1941 #endif
1942 }
1943
1944 /**
1945  * Gets whether the window is a keyboard.
1946  *
1947  * @param obj The window object
1948  * @return If the window is a virtual keyboard
1949  *
1950  * @ingroup Win
1951  */
1952 EAPI Eina_Bool
1953 elm_win_keyboard_win_get(const Evas_Object *obj)
1954 {
1955    Elm_Win *win;
1956    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1957    win = elm_widget_data_get(obj);
1958    if (!win) return EINA_FALSE;
1959 #ifdef HAVE_ELEMENTARY_X
1960    _elm_win_xwindow_get(win);
1961    if (win->xwin)
1962      return ecore_x_e_virtual_keyboard_get(win->xwin);
1963 #endif
1964    return EINA_FALSE;
1965 }
1966
1967 /**
1968  * Get the screen position of a window.
1969  *
1970  * @param obj The window object
1971  * @param x The int to store the x coordinate to
1972  * @param y The int to store the y coordinate to
1973  *
1974  * @ingroup Win
1975  */
1976 EAPI void
1977 elm_win_screen_position_get(const Evas_Object *obj, int *x, int *y)
1978 {
1979    Elm_Win *win;
1980    ELM_CHECK_WIDTYPE(obj, widtype);
1981    win = elm_widget_data_get(obj);
1982    if (!win) return;
1983    if (x) *x = win->screen.x;
1984    if (y) *y = win->screen.y;
1985 }
1986
1987 /**
1988  * Set if this window is an illume conformant window
1989  *
1990  * @param obj The window object
1991  * @param conformant The conformant flag (1 = conformant, 0 = non-conformant)
1992  *
1993  * @ingroup Win
1994  */
1995 EAPI void
1996 elm_win_conformant_set(Evas_Object *obj, Eina_Bool conformant)
1997 {
1998    Elm_Win *win;
1999    ELM_CHECK_WIDTYPE(obj, widtype);
2000    win = elm_widget_data_get(obj);
2001    if (!win) return;
2002 #ifdef HAVE_ELEMENTARY_X
2003    _elm_win_xwindow_get(win);
2004    if (win->xwin)
2005      ecore_x_e_illume_conformant_set(win->xwin, conformant);
2006 #endif
2007 }
2008
2009 /**
2010  * Get if this window is an illume conformant window
2011  *
2012  * @param obj The window object
2013  * @return A boolean if this window is illume conformant or not
2014  *
2015  * @ingroup Win
2016  */
2017 EAPI Eina_Bool
2018 elm_win_conformant_get(const Evas_Object *obj)
2019 {
2020    Elm_Win *win;
2021    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2022    win = elm_widget_data_get(obj);
2023    if (!win) return EINA_FALSE;
2024 #ifdef HAVE_ELEMENTARY_X
2025    _elm_win_xwindow_get(win);
2026    if (win->xwin)
2027      return ecore_x_e_illume_conformant_get(win->xwin);
2028 #endif
2029    return EINA_FALSE;
2030 }
2031
2032 /**
2033  * Set a window to be an illume quickpanel window
2034  *
2035  * By default window objects are not quickpanel windows.
2036  *
2037  * @param obj The window object
2038  * @param quickpanel The quickpanel flag (1 = quickpanel, 0 = normal window)
2039  *
2040  * @ingroup Win
2041  */
2042 EAPI void
2043 elm_win_quickpanel_set(Evas_Object *obj, Eina_Bool quickpanel)
2044 {
2045    Elm_Win *win;
2046    ELM_CHECK_WIDTYPE(obj, widtype);
2047    win = elm_widget_data_get(obj);
2048    if (!win) return;
2049 #ifdef HAVE_ELEMENTARY_X
2050    _elm_win_xwindow_get(win);
2051    if (win->xwin)
2052      {
2053         ecore_x_e_illume_quickpanel_set(win->xwin, quickpanel);
2054         if (quickpanel)
2055           {
2056              Ecore_X_Window_State states[2];
2057
2058              states[0] = ECORE_X_WINDOW_STATE_SKIP_TASKBAR;
2059              states[1] = ECORE_X_WINDOW_STATE_SKIP_PAGER;
2060              ecore_x_netwm_window_state_set(win->xwin, states, 2);
2061              ecore_x_icccm_hints_set(win->xwin, 0, 0, 0, 0, 0, 0, 0);
2062           }
2063      }
2064 #endif
2065 }
2066
2067 /**
2068  * Get if this window is a quickpanel or not
2069  *
2070  * @param obj The window object
2071  * @return A boolean if this window is a quickpanel or not
2072  *
2073  * @ingroup Win
2074  */
2075 EAPI Eina_Bool
2076 elm_win_quickpanel_get(const Evas_Object *obj)
2077 {
2078    Elm_Win *win;
2079    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2080    win = elm_widget_data_get(obj);
2081    if (!win) return EINA_FALSE;
2082 #ifdef HAVE_ELEMENTARY_X
2083    _elm_win_xwindow_get(win);
2084    if (win->xwin)
2085      return ecore_x_e_illume_quickpanel_get(win->xwin);
2086 #endif
2087    return EINA_FALSE;
2088 }
2089
2090 /**
2091  * Set the major priority of a quickpanel window
2092  *
2093  * @param obj The window object
2094  * @param priority The major priority for this quickpanel
2095  *
2096  * @ingroup Win
2097  */
2098 EAPI void
2099 elm_win_quickpanel_priority_major_set(Evas_Object *obj, int priority)
2100 {
2101    Elm_Win *win;
2102    ELM_CHECK_WIDTYPE(obj, widtype);
2103    win = elm_widget_data_get(obj);
2104    if (!win) return;
2105 #ifdef HAVE_ELEMENTARY_X
2106    _elm_win_xwindow_get(win);
2107    if (win->xwin)
2108      ecore_x_e_illume_quickpanel_priority_major_set(win->xwin, priority);
2109 #endif
2110 }
2111
2112 /**
2113  * Get the major priority of a quickpanel window
2114  *
2115  * @param obj The window object
2116  * @return The major priority of this quickpanel
2117  *
2118  * @ingroup Win
2119  */
2120 EAPI int
2121 elm_win_quickpanel_priority_major_get(const Evas_Object *obj)
2122 {
2123    Elm_Win *win;
2124    ELM_CHECK_WIDTYPE(obj, widtype) -1;
2125    win = elm_widget_data_get(obj);
2126    if (!win) return -1;
2127 #ifdef HAVE_ELEMENTARY_X
2128    _elm_win_xwindow_get(win);
2129    if (win->xwin)
2130      return ecore_x_e_illume_quickpanel_priority_major_get(win->xwin);
2131 #endif
2132    return -1;
2133 }
2134
2135 /**
2136  * Set the minor priority of a quickpanel window
2137  *
2138  * @param obj The window object
2139  * @param priority The minor priority for this quickpanel
2140  *
2141  * @ingroup Win
2142  */
2143 EAPI void
2144 elm_win_quickpanel_priority_minor_set(Evas_Object *obj, int priority)
2145 {
2146    Elm_Win *win;
2147    ELM_CHECK_WIDTYPE(obj, widtype);
2148    win = elm_widget_data_get(obj);
2149    if (!win) return;
2150 #ifdef HAVE_ELEMENTARY_X
2151    _elm_win_xwindow_get(win);
2152    if (win->xwin)
2153      ecore_x_e_illume_quickpanel_priority_minor_set(win->xwin, priority);
2154 #endif
2155 }
2156
2157 /**
2158  * Get the minor priority of a quickpanel window
2159  *
2160  * @param obj The window object
2161  * @return The minor priority of this quickpanel
2162  *
2163  * @ingroup Win
2164  */
2165 EAPI int
2166 elm_win_quickpanel_priority_minor_get(const Evas_Object *obj)
2167 {
2168    Elm_Win *win;
2169    ELM_CHECK_WIDTYPE(obj, widtype) -1;
2170    win = elm_widget_data_get(obj);
2171    if (!win) return -1;
2172 #ifdef HAVE_ELEMENTARY_X
2173    _elm_win_xwindow_get(win);
2174    if (win->xwin)
2175      return ecore_x_e_illume_quickpanel_priority_minor_get(win->xwin);
2176 #endif
2177    return -1;
2178 }
2179
2180 /**
2181  * Set which zone this quickpanel should appear in
2182  *
2183  * @param obj The window object
2184  * @param zone The requested zone for this quickpanel
2185  *
2186  * @ingroup Win
2187  */
2188 EAPI void
2189 elm_win_quickpanel_zone_set(Evas_Object *obj, int zone)
2190 {
2191    Elm_Win *win;
2192    ELM_CHECK_WIDTYPE(obj, widtype);
2193    win = elm_widget_data_get(obj);
2194    if (!win) return;
2195 #ifdef HAVE_ELEMENTARY_X
2196    _elm_win_xwindow_get(win);
2197    if (win->xwin)
2198      ecore_x_e_illume_quickpanel_zone_set(win->xwin, zone);
2199 #endif
2200 }
2201
2202 /**
2203  * Get which zone this quickpanel should appear in
2204  *
2205  * @param obj The window object
2206  * @return The requested zone for this quickpanel
2207  *
2208  * @ingroup Win
2209  */
2210 EAPI int
2211 elm_win_quickpanel_zone_get(const Evas_Object *obj)
2212 {
2213    Elm_Win *win;
2214    ELM_CHECK_WIDTYPE(obj, widtype) 0;
2215    win = elm_widget_data_get(obj);
2216    if (!win) return 0;
2217 #ifdef HAVE_ELEMENTARY_X
2218    _elm_win_xwindow_get(win);
2219    if (win->xwin)
2220      return ecore_x_e_illume_quickpanel_zone_get(win->xwin);
2221 #endif
2222    return 0;
2223 }
2224
2225 /**
2226  * Set the window to be skipped by keyboard focus
2227  *
2228  * This sets the window to be skipped by normal keyboard input. This means
2229  * a window manager will be asked to not focus this window as well as omit
2230  * it from things like the taskbar, pager, "alt-tab" list etc. etc.
2231  *
2232  * Call this and enable it on a window BEFORE you show it for the first time,
2233  * otherwise it may have no effect.
2234  *
2235  * Use this for windows that have only output information or might only be
2236  * interacted with by the mouse or fingers, and never for typing input.
2237  * Be careful that this may have side-effects like making the window
2238  * non-accessible in some cases unless the window is specially handled. Use
2239  * this with care.
2240  *
2241  * @param obj The window object
2242  * @param skip The skip flag state (EINA_TRUE if it is to be skipped)
2243  *
2244  * @ingroup Win
2245  */
2246 EAPI void
2247 elm_win_prop_focus_skip_set(Evas_Object *obj, Eina_Bool skip)
2248 {
2249    Elm_Win *win;
2250    ELM_CHECK_WIDTYPE(obj, widtype);
2251    win = elm_widget_data_get(obj);
2252    if (!win) return;
2253 #ifdef HAVE_ELEMENTARY_X
2254    _elm_win_xwindow_get(win);
2255    if (skip)
2256      {
2257         if (win->xwin)
2258           {
2259              Ecore_X_Window_State states[2];
2260
2261              ecore_x_icccm_hints_set(win->xwin, 0, 0, 0, 0, 0, 0, 0);
2262              states[0] = ECORE_X_WINDOW_STATE_SKIP_TASKBAR;
2263              states[1] = ECORE_X_WINDOW_STATE_SKIP_PAGER;
2264              ecore_x_netwm_window_state_set(win->xwin, states, 2);
2265           }
2266      }
2267 #endif
2268 }
2269
2270 /**
2271  * Send a command to the windowing environment
2272  *
2273  * This is intended to work in touchscreen or small screen device environments
2274  * where there is a more simplistic window management policy in place. This
2275  * uses the window object indicated to select which part of the environment
2276  * to control (the part that this window lives in), and provides a command
2277  * and an optional parameter structure (use NULL for this if not needed).
2278  *
2279  * @param obj The window object that lives in the environment to control
2280  * @param command The command to send
2281  * @param params Optional parameters for the command
2282  *
2283  * @ingroup Win
2284  */
2285 EAPI void
2286 elm_win_illume_command_send(Evas_Object *obj, Elm_Illume_Command command, void *params __UNUSED__)
2287 {
2288    Elm_Win *win;
2289    ELM_CHECK_WIDTYPE(obj, widtype);
2290    win = elm_widget_data_get(obj);
2291    if (!win) return;
2292 #ifdef HAVE_ELEMENTARY_X
2293    _elm_win_xwindow_get(win);
2294    if (win->xwin)
2295      {
2296         switch (command)
2297           {
2298            case ELM_ILLUME_COMMAND_FOCUS_BACK:
2299               ecore_x_e_illume_focus_back_send(win->xwin);
2300               break;
2301            case ELM_ILLUME_COMMAND_FOCUS_FORWARD:
2302               ecore_x_e_illume_focus_forward_send(win->xwin);
2303               break;
2304            case ELM_ILLUME_COMMAND_FOCUS_HOME:
2305               ecore_x_e_illume_focus_home_send(win->xwin);
2306               break;
2307            case ELM_ILLUME_COMMAND_CLOSE:
2308               ecore_x_e_illume_close_send(win->xwin);
2309               break;
2310            default:
2311               break;
2312           }
2313      }
2314 #endif
2315 }
2316
2317 /**
2318  * Set the enabled status for the focus highlight in a window
2319  *
2320  * This function will enable or disable the focus highlight only for the
2321  * given window, regardless of the global setting for it
2322  *
2323  * @param obj The window where to enable the highlight
2324  * @param enabled The enabled value for the highlight
2325  *
2326  * @ingroup Win
2327  */
2328 EAPI void
2329 elm_win_focus_highlight_enabled_set(Evas_Object *obj, Eina_Bool enabled)
2330 {
2331    Elm_Win *win;
2332
2333    ELM_CHECK_WIDTYPE(obj, widtype);
2334
2335    win = elm_widget_data_get(obj);
2336    enabled = !!enabled;
2337    if (win->focus_highlight.enabled == enabled)
2338      return;
2339
2340    win->focus_highlight.enabled = enabled;
2341
2342    if (win->focus_highlight.enabled)
2343      _elm_win_focus_highlight_init(win);
2344    else
2345      _elm_win_focus_highlight_shutdown(win);
2346 }
2347
2348 /**
2349  * Get the enabled value of the focus highlight for this window
2350  *
2351  * @param obj The window in which to check if the focus highlight is enabled
2352  *
2353  * @return EINA_TRUE if enabled, EINA_FALSE otherwise
2354  *
2355  * @ingroup Win
2356  */
2357 EAPI Eina_Bool
2358 elm_win_focus_highlight_enabled_get(const Evas_Object *obj)
2359 {
2360    Elm_Win *win;
2361
2362    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2363
2364    win = elm_widget_data_get(obj);
2365    return win->focus_highlight.enabled;
2366 }
2367
2368 /**
2369  * Set the style for the focus highlight on this window
2370  *
2371  * Sets the style to use for theming the highlight of focused objects on
2372  * the given window. If @p style is NULL, the default will be used.
2373  *
2374  * @param obj The window where to set the style
2375  * @param style The style to set
2376  *
2377  * @ingroup Win
2378  */
2379 EAPI void
2380 elm_win_focus_highlight_style_set(Evas_Object *obj, const char *style)
2381 {
2382    Elm_Win *win;
2383
2384    ELM_CHECK_WIDTYPE(obj, widtype);
2385
2386    win = elm_widget_data_get(obj);
2387    eina_stringshare_replace(&win->focus_highlight.style, style);
2388    win->focus_highlight.changed_theme = EINA_TRUE;
2389    _elm_win_focus_highlight_reconfigure_job_start(win);
2390 }
2391
2392 /**
2393  * Get the style set for the focus highlight object
2394  *
2395  * Gets the style set for this windows highilght object, or NULL if none
2396  * is set.
2397  *
2398  * @param obj The window to retrieve the highlights style from
2399  *
2400  * @return The style set or NULL if none was. Default is used in that case.
2401  *
2402  * @ingroup Win
2403  */
2404 EAPI const char *
2405 elm_win_focus_highlight_style_get(const Evas_Object *obj)
2406 {
2407    Elm_Win *win;
2408
2409    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2410
2411    win = elm_widget_data_get(obj);
2412    return win->focus_highlight.style;
2413 }
2414
2415 EAPI void
2416 elm_win_indicator_state_set(Evas_Object *obj, int show_state)
2417 {
2418    Elm_Win *win;
2419    if (strcmp(elm_widget_type_get(obj), "win")) return;
2420    win = elm_widget_data_get(obj);
2421    if (!win) return;
2422    _elm_win_xwindow_get(win);
2423 #ifdef HAVE_ELEMENTARY_X
2424    if (win->xwin)
2425       return ecore_x_window_prop_property_set (win->xwin,
2426                    ECORE_X_ATOM_E_ILLUME_INDICATOR_STATE, ECORE_X_ATOM_CARDINAL, 32, &show_state, 1);
2427 #endif
2428    return;
2429 }
2430
2431 EAPI int
2432 elm_win_indicator_state_get(Evas_Object *obj)
2433 {
2434    Elm_Win *win;
2435    if (strcmp(elm_widget_type_get(obj), "win")) return -1;
2436    win = elm_widget_data_get(obj);
2437    if (!win) return -1;
2438    _elm_win_xwindow_get(win);
2439 #ifdef HAVE_ELEMENTARY_X
2440    if (win->xwin)
2441      {
2442         int ret;
2443         int count;
2444         int show = -1;
2445         unsigned int *prop_data = NULL;
2446
2447         ret = ecore_x_window_prop_property_get (win->xwin,
2448                     ECORE_X_ATOM_E_ILLUME_INDICATOR_STATE, ECORE_X_ATOM_CARDINAL, 32, (void *)&prop_data, &count);
2449         if( ret && prop_data )
2450            memcpy (&show, prop_data, sizeof (int));
2451
2452         if (prop_data) free (prop_data);
2453
2454         return show;
2455      }
2456 #endif
2457    return -1;
2458 }
2459
2460
2461 typedef struct _Widget_Data Widget_Data;
2462
2463 struct _Widget_Data
2464 {
2465    Evas_Object *frm;
2466    Evas_Object *content;
2467 };
2468
2469 static void _del_hook(Evas_Object *obj);
2470 static void _theme_hook(Evas_Object *obj);
2471 static void _sizing_eval(Evas_Object *obj);
2472 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
2473 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
2474
2475 static const char *widtype2 = NULL;
2476
2477 static void
2478 _del_hook(Evas_Object *obj)
2479 {
2480    Widget_Data *wd = elm_widget_data_get(obj);
2481    if (!wd) return;
2482    free(wd);
2483 }
2484
2485 static void
2486 _theme_hook(Evas_Object *obj)
2487 {
2488    Widget_Data *wd = elm_widget_data_get(obj);
2489    _elm_theme_object_set(obj, wd->frm, "win", "inwin", elm_widget_style_get(obj));
2490    if (wd->content)
2491      edje_object_part_swallow(wd->frm, "elm.swallow.content", wd->content);
2492    _sizing_eval(obj);
2493 }
2494
2495 static Eina_Bool
2496 _elm_inwin_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
2497 {
2498    Widget_Data *wd = elm_widget_data_get(obj);
2499
2500    if (!wd)
2501      return EINA_FALSE;
2502
2503    /* Try Focus cycle in subitem */
2504    if (wd->content)
2505      {
2506         elm_widget_focus_next_get(wd->content, dir, next);
2507         if (*next)
2508           return EINA_TRUE;
2509      }
2510
2511    *next = (Evas_Object *)obj;
2512    return EINA_FALSE;
2513 }
2514
2515 static void
2516 _sizing_eval(Evas_Object *obj)
2517 {
2518    Widget_Data *wd = elm_widget_data_get(obj);
2519    Evas_Coord minw = -1, minh = -1;
2520
2521    evas_object_size_hint_min_get(wd->content, &minw, &minh);
2522    edje_object_size_min_calc(wd->frm, &minw, &minh);
2523    evas_object_size_hint_min_set(obj, minw, minh);
2524    evas_object_size_hint_max_set(obj, -1, -1);
2525 }
2526
2527 static void
2528 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2529 {
2530    _sizing_eval(data);
2531 }
2532
2533 static void
2534 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
2535 {
2536    Widget_Data *wd = elm_widget_data_get(obj);
2537    Evas_Object *sub = event_info;
2538    if (sub == wd->content)
2539      {
2540         evas_object_event_callback_del_full
2541            (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
2542         wd->content = NULL;
2543         _sizing_eval(obj);
2544      }
2545 }
2546
2547 /**
2548  * @defgroup Inwin Inwin
2549  *
2550  * An inwin is a window inside a window that is useful for a quick popup.  It does not hover.
2551  */
2552 EAPI Evas_Object *
2553 elm_win_inwin_add(Evas_Object *obj)
2554 {
2555    Evas_Object *obj2;
2556    Widget_Data *wd;
2557    Elm_Win *win;
2558
2559    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2560    win = elm_widget_data_get(obj);
2561    if (!win) return NULL;
2562    wd = ELM_NEW(Widget_Data);
2563    obj2 = elm_widget_add(win->evas);
2564    elm_widget_type_set(obj2, "inwin");
2565    ELM_SET_WIDTYPE(widtype2, "inwin");
2566    elm_widget_sub_object_add(obj, obj2);
2567    evas_object_size_hint_weight_set(obj2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2568    evas_object_size_hint_align_set(obj2, EVAS_HINT_FILL, EVAS_HINT_FILL);
2569    elm_win_resize_object_add(obj, obj2);
2570
2571    elm_widget_data_set(obj2, wd);
2572    elm_widget_del_hook_set(obj2, _del_hook);
2573    elm_widget_theme_hook_set(obj2, _theme_hook);
2574    elm_widget_focus_next_hook_set(obj2, _elm_inwin_focus_next_hook);
2575    elm_widget_can_focus_set(obj2, EINA_TRUE);
2576    elm_widget_highlight_ignore_set(obj2, EINA_TRUE);
2577
2578    wd->frm = edje_object_add(win->evas);
2579    _elm_theme_object_set(obj, wd->frm, "win", "inwin", "default");
2580    elm_widget_resize_object_set(obj2, wd->frm);
2581
2582    evas_object_smart_callback_add(obj2, "sub-object-del", _sub_del, obj2);
2583
2584    _sizing_eval(obj2);
2585    return obj2;
2586 }
2587
2588 /**
2589  * Activates an inwin object
2590  *
2591  * @param obj The inwin to activate
2592  *
2593  * @ingroup Inwin
2594  */
2595 EAPI void
2596 elm_win_inwin_activate(Evas_Object *obj)
2597 {
2598    ELM_CHECK_WIDTYPE(obj, widtype2);
2599    Widget_Data *wd = elm_widget_data_get(obj);
2600    if (!wd) return;
2601    evas_object_raise(obj);
2602    evas_object_show(obj);
2603    edje_object_signal_emit(wd->frm, "elm,action,show", "elm");
2604    elm_object_focus(obj);
2605 }
2606
2607 /**
2608  * Set the content of an inwin object.
2609  *
2610  * Once the content object is set, a previously set one will be deleted.
2611  * If you want to keep that old content object, use the
2612  * elm_win_inwin_content_unset() function.
2613  *
2614  * @param obj The inwin object
2615  * @param content The object to set as content
2616  *
2617  * @ingroup Inwin
2618  */
2619 EAPI void
2620 elm_win_inwin_content_set(Evas_Object *obj, Evas_Object *content)
2621 {
2622    ELM_CHECK_WIDTYPE(obj, widtype2);
2623    Widget_Data *wd = elm_widget_data_get(obj);
2624    if (!wd) return;
2625    if (wd->content == content) return;
2626    if (wd->content) evas_object_del(wd->content);
2627    wd->content = content;
2628    if (content)
2629      {
2630         elm_widget_sub_object_add(obj, content);
2631         evas_object_event_callback_add(content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
2632                                        _changed_size_hints, obj);
2633         edje_object_part_swallow(wd->frm, "elm.swallow.content", content);
2634      }
2635    _sizing_eval(obj);
2636 }
2637
2638 /**
2639  * Get the content of an inwin object.
2640  *
2641  * Return the content object which is set for this widget.
2642  *
2643  * @param obj The inwin object
2644  * @return The content that is being used
2645  *
2646  * @ingroup Inwin
2647  */
2648 EAPI Evas_Object *
2649 elm_win_inwin_content_get(const Evas_Object *obj)
2650 {
2651    ELM_CHECK_WIDTYPE(obj, widtype2) NULL;
2652    Widget_Data *wd = elm_widget_data_get(obj);
2653    if (!wd) return NULL;
2654    return wd->content;
2655 }
2656
2657 /**
2658  * Unset the content of an inwin object.
2659  *
2660  * Unparent and return the content object which was set for this widget.
2661  *
2662  * @param obj The inwin object
2663  * @return The content that was being used
2664  *
2665  * @ingroup Inwin
2666  */
2667 EAPI Evas_Object *
2668 elm_win_inwin_content_unset(Evas_Object *obj)
2669 {
2670    ELM_CHECK_WIDTYPE(obj, widtype2) NULL;
2671    Widget_Data *wd = elm_widget_data_get(obj);
2672    if (!wd) return NULL;
2673    if (!wd->content) return NULL;
2674    Evas_Object *content = wd->content;
2675    elm_widget_sub_object_del(obj, wd->content);
2676    edje_object_part_unswallow(wd->frm, wd->content);
2677    wd->content = NULL;
2678    return content;
2679 }
2680
2681 /* windowing spcific calls - shall we do this differently? */
2682 /**
2683  * Get the Ecore_X_Window of an Evas_Object
2684  *
2685  * @param obj The object
2686  *
2687  * @return The Ecore_X_Window of @p obj
2688  *
2689  * @ingroup Win
2690  */
2691 EAPI Ecore_X_Window
2692 elm_win_xwindow_get(const Evas_Object *obj)
2693 {
2694    Ecore_X_Window xwin = 0;
2695    Ecore_Evas *ee = NULL;
2696    if (!obj) return 0;
2697 #ifdef HAVE_ELEMENTARY_X
2698    ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
2699    if (ee) xwin = (Ecore_X_Window)ecore_evas_window_get(ee);
2700    return xwin;
2701 #else
2702    return 0;
2703 #endif
2704 }