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