hmm conflict not merged right. fix.
[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_ref(win->win_obj);
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    evas_object_unref(win->win_obj);
629 }
630
631 static void
632 _elm_win_resize_job(void *data)
633 {
634    Elm_Win *win = data;
635    const Eina_List *l;
636    Evas_Object *obj;
637    int w, h;
638
639    win->deferred_resize_job = NULL;
640    ecore_evas_geometry_get(win->ee, NULL, NULL, &w, &h);
641    evas_object_resize(win->win_obj, w, h);
642    if (win->frame_obj)
643      {
644      }
645    else if (win->img_obj)
646      {
647      }
648    EINA_LIST_FOREACH(win->subobjs, l, obj)
649      {
650         evas_object_move(obj, 0, 0);
651         evas_object_resize(obj, w, h);
652      }
653 }
654
655 #ifdef HAVE_ELEMENTARY_X
656 static void
657 _elm_win_xwindow_get(Elm_Win *win)
658 {
659    win->xwin = 0;
660
661 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
662    if (ENGINE_COMPARE(ELM_SOFTWARE_X11))
663      {
664        if (win->ee) win->xwin = ecore_evas_software_x11_window_get(win->ee);
665      }
666    else if (ENGINE_COMPARE(ELM_SOFTWARE_X11) ||
667             ENGINE_COMPARE(ELM_SOFTWARE_FB) ||
668             ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE) ||
669             ENGINE_COMPARE(ELM_SOFTWARE_SDL) ||
670             ENGINE_COMPARE(ELM_SOFTWARE_16_SDL) ||
671             ENGINE_COMPARE(ELM_OPENGL_SDL))
672      {
673      }
674    else if (ENGINE_COMPARE(ELM_SOFTWARE_16_X11))
675      {
676         if (win->ee) win->xwin = ecore_evas_software_x11_16_window_get(win->ee);
677      }
678    else if (ENGINE_COMPARE(ELM_SOFTWARE_8_X11))
679      {
680         if (win->ee) win->xwin = ecore_evas_software_x11_8_window_get(win->ee);
681      }
682 /* killed
683    else if (ENGINE_COMPARE(ELM_XRENDER_X11))
684      {
685         if (win->ee) win->xwin = ecore_evas_xrender_x11_window_get(win->ee);
686      }
687  */
688    else if (ENGINE_COMPARE(ELM_OPENGL_X11))
689      {
690         if (win->ee) win->xwin = ecore_evas_gl_x11_window_get(win->ee);
691      }
692    else if (ENGINE_COMPARE(ELM_SOFTWARE_WIN32))
693      {
694         if (win->ee) win->xwin = (long)ecore_evas_win32_window_get(win->ee);
695      }
696 #undef ENGINE_COMPARE
697 }
698 #endif
699
700 #ifdef HAVE_ELEMENTARY_X
701 static void
702 _elm_win_xwin_update(Elm_Win *win)
703 {
704    _elm_win_xwindow_get(win);
705    if (win->parent)
706      {
707         Elm_Win *win2;
708
709         win2 = elm_widget_data_get(win->parent);
710         if (win2)
711           {
712              if (win->xwin)
713                ecore_x_icccm_transient_for_set(win->xwin, win2->xwin);
714           }
715      }
716
717    if (!win->xwin) return; /* nothing more to do */
718
719    switch (win->type)
720      {
721       case ELM_WIN_BASIC:
722          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_NORMAL);
723          break;
724       case ELM_WIN_DIALOG_BASIC:
725          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DIALOG);
726          break;
727       case ELM_WIN_DESKTOP:
728          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DESKTOP);
729          break;
730       case ELM_WIN_DOCK:
731          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DOCK);
732          break;
733       case ELM_WIN_TOOLBAR:
734          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_TOOLBAR);
735          break;
736       case ELM_WIN_MENU:
737          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_MENU);
738          break;
739       case ELM_WIN_UTILITY:
740          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_UTILITY);
741          break;
742       case ELM_WIN_SPLASH:
743          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_SPLASH);
744          break;
745       case ELM_WIN_DROPDOWN_MENU:
746          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DROPDOWN_MENU);
747          break;
748       case ELM_WIN_POPUP_MENU:
749          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_POPUP_MENU);
750          break;
751       case ELM_WIN_TOOLTIP:
752          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_TOOLTIP);
753          break;
754       case ELM_WIN_NOTIFICATION:
755          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_NOTIFICATION);
756          break;
757       case ELM_WIN_COMBO:
758          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_COMBO);
759          break;
760       case ELM_WIN_DND:
761          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DND);
762          break;
763       default:
764          break;
765      }
766    ecore_x_e_virtual_keyboard_state_set
767       (win->xwin, (Ecore_X_Virtual_Keyboard_State)win->kbdmode);
768 }
769 #endif
770
771 static void
772 _elm_win_eval_subobjs(Evas_Object *obj)
773 {
774    const Eina_List *l;
775    const Evas_Object *child;
776
777    Elm_Win *win = elm_widget_data_get(obj);
778    Evas_Coord w, h, minw = -1, minh = -1, maxw = -1, maxh = -1;
779    int xx = 1, xy = 1;
780    double wx, wy;
781
782    EINA_LIST_FOREACH(win->subobjs, l, child)
783      {
784         evas_object_size_hint_weight_get(child, &wx, &wy);
785         if (wx == 0.0) xx = 0;
786         if (wy == 0.0) xy = 0;
787
788         evas_object_size_hint_min_get(child, &w, &h);
789         if (w < 1) w = -1;
790         if (h < 1) h = -1;
791         if (w > minw) minw = w;
792         if (h > minh) minh = h;
793
794         evas_object_size_hint_max_get(child, &w, &h);
795         if (w < 1) w = -1;
796         if (h < 1) h = -1;
797         if (maxw == -1) maxw = w;
798         else if ((w > 0) && (w < maxw)) maxw = w;
799         if (maxh == -1) maxh = h;
800         else if ((h > 0) && (h < maxh)) maxh = h;
801      }
802    if (!xx) maxw = minw;
803    else maxw = 32767;
804    if (!xy) maxh = minh;
805    else maxh = 32767;
806    evas_object_size_hint_min_set(obj, minw, minh);
807    evas_object_size_hint_max_set(obj, maxw, maxh);
808    evas_object_geometry_get(obj, NULL, NULL, &w, &h);
809    if (w < minw) w = minw;
810    if (h < minh) h = minh;
811    if ((maxw >= 0) && (w > maxw)) w = maxw;
812    if ((maxh >= 0) && (h > maxh)) h = maxh;
813    evas_object_resize(obj, w, h);
814 }
815
816 static void
817 _elm_win_subobj_callback_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
818 {
819    Elm_Win *win = elm_widget_data_get(data);
820    win->subobjs = eina_list_remove(win->subobjs, obj);
821    _elm_win_eval_subobjs(win->win_obj);
822 }
823
824 static void
825 _elm_win_subobj_callback_changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
826 {
827    _elm_win_eval_subobjs(data);
828 }
829
830 void
831 _elm_win_shutdown(void)
832 {
833    while (_elm_win_list)
834      evas_object_del(_elm_win_list->data);
835 }
836
837 void
838 _elm_win_rescale(Elm_Theme *th, Eina_Bool use_theme)
839 {
840    const Eina_List *l;
841    Evas_Object *obj;
842
843    if (!use_theme)
844      {
845         EINA_LIST_FOREACH(_elm_win_list, l, obj)
846           elm_widget_theme(obj);
847      }
848    else
849      {
850         EINA_LIST_FOREACH(_elm_win_list, l, obj)
851           elm_widget_theme_specific(obj, th, EINA_FALSE);
852      }
853 }
854
855 #ifdef HAVE_ELEMENTARY_X
856 static Eina_Bool
857 _elm_win_client_message(void *data, int type __UNUSED__, void *event)
858 {
859    Elm_Win *win = data;
860    Ecore_X_Event_Client_Message *e = event;
861
862    if (e->format != 32) return ECORE_CALLBACK_PASS_ON;
863    if (e->message_type == ECORE_X_ATOM_E_COMP_FLUSH)
864      {
865         if ((unsigned)e->data.l[0] == win->xwin)
866           {
867              Evas *evas = evas_object_evas_get(win->win_obj);
868              if (evas)
869                {
870                   edje_file_cache_flush();
871                   edje_collection_cache_flush();
872                   evas_image_cache_flush(evas);
873                   evas_font_cache_flush(evas);
874                }
875           }
876      }
877    else if (e->message_type == ECORE_X_ATOM_E_COMP_DUMP)
878      {
879         if ((unsigned)e->data.l[0] == win->xwin)
880           {
881              Evas *evas = evas_object_evas_get(win->win_obj);
882              if (evas)
883                {
884                   edje_file_cache_flush();
885                   edje_collection_cache_flush();
886                   evas_image_cache_flush(evas);
887                   evas_font_cache_flush(evas);
888                   evas_render_dump(evas);
889                }
890           }
891      }
892    return ECORE_CALLBACK_PASS_ON;
893 }
894 #endif
895
896 static void
897 _elm_win_focus_target_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
898 {
899    Elm_Win *win = data;
900
901    win->focus_highlight.geometry_changed = EINA_TRUE;
902    _elm_win_focus_highlight_reconfigure_job_start(win);
903 }
904
905 static void
906 _elm_win_focus_target_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
907 {
908    Elm_Win *win = data;
909
910    win->focus_highlight.geometry_changed = EINA_TRUE;
911    _elm_win_focus_highlight_reconfigure_job_start(win);
912 }
913
914 static void
915 _elm_win_focus_target_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
916 {
917    Elm_Win *win = data;
918
919    win->focus_highlight.cur.target = NULL;
920
921    _elm_win_focus_highlight_reconfigure_job_start(win);
922 }
923
924 static void
925 _elm_win_focus_target_callbacks_add(Elm_Win *win)
926 {
927    Evas_Object *obj = win->focus_highlight.cur.target;
928
929    evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE,
930                                   _elm_win_focus_target_move, win);
931    evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE,
932                                   _elm_win_focus_target_resize, win);
933    evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
934                                   _elm_win_focus_target_del, win);
935 }
936
937 static void
938 _elm_win_focus_target_callbacks_del(Elm_Win *win)
939 {
940    Evas_Object *obj = win->focus_highlight.cur.target;
941
942    evas_object_event_callback_del_full(obj, EVAS_CALLBACK_MOVE,
943                                        _elm_win_focus_target_move, win);
944    evas_object_event_callback_del_full(obj, EVAS_CALLBACK_RESIZE,
945                                        _elm_win_focus_target_resize, win);
946    evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL,
947                                        _elm_win_focus_target_del, win);
948 }
949
950 static Evas_Object *
951 _elm_win_focus_target_get(Evas_Object *obj)
952 {
953    Evas_Object *o = obj;
954
955    do
956      {
957         if (elm_widget_is(o))
958           {
959              if (!elm_widget_highlight_ignore_get(o))
960                break;
961              o = elm_widget_parent_get(o);
962              if (!o)
963                o = evas_object_smart_parent_get(o);
964           }
965         else
966           {
967              o = elm_widget_parent_widget_get(o);
968              if (!o)
969                o = evas_object_smart_parent_get(o);
970           }
971      }
972    while (o);
973
974    return o;
975 }
976
977 static void
978 _elm_win_object_focus_in(void *data, Evas *e __UNUSED__, void *event_info)
979 {
980    Evas_Object *obj = event_info, *target;
981    Elm_Win *win = data;
982
983    if (win->focus_highlight.cur.target == obj)
984      return;
985
986    target = _elm_win_focus_target_get(obj);
987    win->focus_highlight.cur.target = target;
988    if (elm_widget_highlight_in_theme_get(target))
989      win->focus_highlight.cur.handled = EINA_TRUE;
990    else
991      _elm_win_focus_target_callbacks_add(win);
992
993    _elm_win_focus_highlight_reconfigure_job_start(win);
994 }
995
996 static void
997 _elm_win_object_focus_out(void *data, Evas *e __UNUSED__, void *event_info __UNUSED__)
998 {
999    Elm_Win *win = data;
1000
1001    if (!win->focus_highlight.cur.target)
1002      return;
1003
1004    if (!win->focus_highlight.cur.handled)
1005      _elm_win_focus_target_callbacks_del(win);
1006    win->focus_highlight.cur.target = NULL;
1007    win->focus_highlight.cur.handled = EINA_FALSE;
1008
1009    _elm_win_focus_highlight_reconfigure_job_start(win);
1010 }
1011
1012 static void
1013 _elm_win_focus_highlight_hide(void *data __UNUSED__, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
1014 {
1015    evas_object_hide(obj);
1016 }
1017
1018 static void
1019 _elm_win_focus_highlight_init(Elm_Win *win)
1020 {
1021    evas_event_callback_add(win->evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
1022                            _elm_win_object_focus_in, win);
1023    evas_event_callback_add(win->evas,
1024                            EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
1025                            _elm_win_object_focus_out, win);
1026
1027    win->focus_highlight.cur.target = evas_focus_get(win->evas);
1028
1029    win->focus_highlight.top = edje_object_add(win->evas);
1030    win->focus_highlight.changed_theme = EINA_TRUE;
1031    edje_object_signal_callback_add(win->focus_highlight.top,
1032                                    "elm,action,focus,hide,end", "",
1033                                    _elm_win_focus_highlight_hide, NULL);
1034    edje_object_signal_callback_add(win->focus_highlight.top,
1035                                    "elm,action,focus,anim,end", "",
1036                                    _elm_win_focus_highlight_anim_end, win);
1037    _elm_win_focus_highlight_reconfigure_job_start(win);
1038 }
1039
1040 static void
1041 _elm_win_focus_highlight_shutdown(Elm_Win *win)
1042 {
1043    _elm_win_focus_highlight_reconfigure_job_stop(win);
1044    if (win->focus_highlight.cur.target)
1045      {
1046         _elm_win_focus_target_callbacks_del(win);
1047         win->focus_highlight.cur.target = NULL;
1048      }
1049    if (win->focus_highlight.top)
1050      {
1051         evas_object_del(win->focus_highlight.top);
1052         win->focus_highlight.top = NULL;
1053      }
1054
1055    evas_event_callback_del_full(win->evas,
1056                                 EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
1057                                 _elm_win_object_focus_in, win);
1058    evas_event_callback_del_full(win->evas,
1059                                 EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
1060                                 _elm_win_object_focus_out, win);
1061 }
1062
1063 static void
1064 _elm_win_focus_highlight_visible_set(Elm_Win *win, Eina_Bool visible)
1065 {
1066    Evas_Object *top;
1067
1068    top = win->focus_highlight.top;
1069    if (visible)
1070      {
1071         if (top)
1072           {
1073              evas_object_show(top);
1074              edje_object_signal_emit(top, "elm,action,focus,show", "elm");
1075           }
1076      }
1077    else
1078      {
1079         if (top)
1080           edje_object_signal_emit(top, "elm,action,focus,hide", "elm");
1081      }
1082 }
1083
1084 static void
1085 _elm_win_focus_highlight_reconfigure_job(void *data)
1086 {
1087    _elm_win_focus_highlight_reconfigure((Elm_Win *)data);
1088 }
1089
1090 static void
1091 _elm_win_focus_highlight_reconfigure_job_start(Elm_Win *win)
1092 {
1093    if (win->focus_highlight.reconf_job)
1094      ecore_job_del(win->focus_highlight.reconf_job);
1095    win->focus_highlight.reconf_job = ecore_job_add(
1096       _elm_win_focus_highlight_reconfigure_job, win);
1097 }
1098
1099 static void
1100 _elm_win_focus_highlight_reconfigure_job_stop(Elm_Win *win)
1101 {
1102    if (win->focus_highlight.reconf_job)
1103      ecore_job_del(win->focus_highlight.reconf_job);
1104    win->focus_highlight.reconf_job = NULL;
1105 }
1106
1107 static void
1108 _elm_win_focus_highlight_simple_setup(Elm_Win *win, Evas_Object *obj)
1109 {
1110    Evas_Object *clip, *target = win->focus_highlight.cur.target;
1111    Evas_Coord x, y, w, h;
1112
1113    clip = evas_object_clip_get(target);
1114    evas_object_geometry_get(target, &x, &y, &w, &h);
1115
1116    evas_object_move(obj, x, y);
1117    evas_object_resize(obj, w, h);
1118    evas_object_clip_set(obj, clip);
1119 }
1120
1121 static void
1122 _elm_win_focus_highlight_anim_setup(Elm_Win *win, Evas_Object *obj)
1123 {
1124    Evas_Coord tx, ty, tw, th;
1125    Evas_Coord w, h, px, py, pw, ph;
1126    Edje_Message_Int_Set *m;
1127    Evas_Object *previous = win->focus_highlight.prev.target;
1128    Evas_Object *target = win->focus_highlight.cur.target;
1129
1130    evas_object_geometry_get(win->win_obj, NULL, NULL, &w, &h);
1131    evas_object_geometry_get(target, &tx, &ty, &tw, &th);
1132    evas_object_geometry_get(previous, &px, &py, &pw, &ph);
1133    evas_object_move(obj, 0, 0);
1134    evas_object_resize(obj, tw, th);
1135    evas_object_clip_unset(obj);
1136
1137    m = alloca(sizeof(*m) + (sizeof(int) * 8));
1138    m->count = 8;
1139    m->val[0] = px;
1140    m->val[1] = py;
1141    m->val[2] = pw;
1142    m->val[3] = ph;
1143    m->val[4] = tx;
1144    m->val[5] = ty;
1145    m->val[6] = tw;
1146    m->val[7] = th;
1147    edje_object_message_send(obj, EDJE_MESSAGE_INT_SET, 1, m);
1148 }
1149
1150 static void
1151 _elm_win_focus_highlight_anim_end(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
1152 {
1153    Elm_Win *win = data;
1154    _elm_win_focus_highlight_simple_setup(win, obj);
1155 }
1156
1157 static void
1158 _elm_win_focus_highlight_reconfigure(Elm_Win *win)
1159 {
1160    Evas_Object *target = win->focus_highlight.cur.target;
1161    Evas_Object *previous = win->focus_highlight.prev.target;
1162    Evas_Object *top = win->focus_highlight.top;
1163    Eina_Bool visible_changed;
1164    Eina_Bool common_visible;
1165    const char *sig = NULL;
1166
1167    _elm_win_focus_highlight_reconfigure_job_stop(win);
1168
1169    visible_changed = (win->focus_highlight.cur.visible !=
1170                       win->focus_highlight.prev.visible);
1171
1172    if ((target == previous) && (!visible_changed) &&
1173        (!win->focus_highlight.geometry_changed))
1174      return;
1175
1176    if ((previous) && (win->focus_highlight.prev.handled))
1177      elm_widget_signal_emit(previous, "elm,action,focus_highlight,hide", "elm");
1178
1179    if (!target)
1180      common_visible = EINA_FALSE;
1181    else if (win->focus_highlight.cur.handled)
1182      {
1183         common_visible = EINA_FALSE;
1184         if (win->focus_highlight.cur.visible)
1185           sig = "elm,action,focus_highlight,show";
1186         else
1187           sig = "elm,action,focus_highlight,hide";
1188      }
1189    else
1190      common_visible = win->focus_highlight.cur.visible;
1191
1192    _elm_win_focus_highlight_visible_set(win, common_visible);
1193    if (sig)
1194      elm_widget_signal_emit(target, sig, "elm");
1195
1196    if ((!target) || (!common_visible) || (win->focus_highlight.cur.handled))
1197      goto the_end;
1198
1199    if (win->focus_highlight.changed_theme)
1200      {
1201         const char *str;
1202         if (win->focus_highlight.style)
1203           str = win->focus_highlight.style;
1204         else
1205           str = "default";
1206         _elm_theme_object_set(win->win_obj, top, "focus_highlight", "top",
1207                               str);
1208         win->focus_highlight.changed_theme = EINA_FALSE;
1209
1210         if (_elm_config->focus_highlight_animate)
1211           {
1212              str = edje_object_data_get(win->focus_highlight.top, "animate");
1213              win->focus_highlight.top_animate = ((str) && (!strcmp(str, "on")));
1214           }
1215      }
1216
1217    if ((win->focus_highlight.top_animate) && (previous) &&
1218        (!win->focus_highlight.prev.handled))
1219      _elm_win_focus_highlight_anim_setup(win, top);
1220    else
1221      _elm_win_focus_highlight_simple_setup(win, top);
1222    evas_object_raise(top);
1223
1224 the_end:
1225    win->focus_highlight.geometry_changed = EINA_FALSE;
1226    win->focus_highlight.prev = win->focus_highlight.cur;
1227 }
1228
1229 #ifdef ELM_DEBUG
1230 static void
1231 _debug_key_down(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
1232 {
1233    Evas_Event_Key_Down *ev = event_info;
1234
1235    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1236      return;
1237
1238
1239    if ((strcmp(ev->keyname, "F12")) ||
1240        (!evas_key_modifier_is_set(ev->modifiers, "Control")))
1241      return;
1242
1243    printf("Tree graph generated.\n");
1244    elm_object_tree_dot_dump(obj, "./dump.dot");
1245 }
1246 #endif
1247
1248 static void
1249 _win_img_hide(void        *data,
1250               Evas        *e __UNUSED__,
1251               Evas_Object *obj __UNUSED__,
1252               void        *event_info __UNUSED__)
1253 {
1254    Elm_Win *win = data;
1255
1256    elm_widget_focus_hide_handle(win->win_obj);
1257 }
1258
1259 static void
1260 _win_img_mouse_down(void        *data,
1261                     Evas        *e __UNUSED__,
1262                     Evas_Object *obj __UNUSED__,
1263                     void        *event_info __UNUSED__)
1264 {
1265    Elm_Win *win = data;
1266    elm_widget_focus_mouse_down_handle(win->win_obj);
1267 }
1268
1269 static void
1270 _win_img_focus_in(void        *data,
1271                   Evas        *e __UNUSED__,
1272                   Evas_Object *obj __UNUSED__,
1273                   void        *event_info __UNUSED__)
1274 {
1275    Elm_Win *win = data;
1276    elm_widget_focus_steal(win->win_obj);
1277 }
1278
1279 static void
1280 _win_img_focus_out(void        *data,
1281                    Evas        *e __UNUSED__,
1282                    Evas_Object *obj __UNUSED__,
1283                    void        *event_info __UNUSED__)
1284 {
1285    Elm_Win *win = data;
1286    elm_widget_focused_object_clear(win->win_obj);
1287 }
1288
1289 static void
1290 _win_inlined_image_set(Elm_Win *win)
1291 {
1292    evas_object_image_alpha_set(win->img_obj, EINA_FALSE);
1293    evas_object_image_filled_set(win->img_obj, EINA_TRUE);
1294    evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_DEL,
1295                                   _elm_win_obj_callback_img_obj_del, win);
1296
1297    evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_HIDE,
1298                                   _win_img_hide, win);
1299    evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_MOUSE_DOWN,
1300                                   _win_img_mouse_down, win);
1301    evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_FOCUS_IN,
1302                                   _win_img_focus_in, win);
1303    evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_FOCUS_OUT,
1304                                   _win_img_focus_out, win);
1305 }
1306
1307 /**
1308  * Adds a window object. If this is the first window created, pass NULL as
1309  * @p parent.
1310  *
1311  * @param parent Parent object to add the window to, or NULL
1312  * @param name The name of the window
1313  * @param type The window type, one of the following:
1314  * ELM_WIN_BASIC
1315  * ELM_WIN_DIALOG_BASIC
1316  * ELM_WIN_DESKTOP
1317  * ELM_WIN_DOCK
1318  * ELM_WIN_TOOLBAR
1319  * ELM_WIN_MENU
1320  * ELM_WIN_UTILITY
1321  * ELM_WIN_SPLASH
1322  *
1323  * @return The created object, or NULL on failure
1324  *
1325  * @ingroup Win
1326  */
1327 EAPI Evas_Object *
1328 elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type)
1329 {
1330    Elm_Win *win;
1331    const Eina_List *l;
1332    const char *fontpath;
1333
1334    win = ELM_NEW(Elm_Win);
1335
1336 #define FALLBACK_TRY(engine)                                            \
1337    if (!win->ee)                                                        \
1338    do {                                                               \
1339         CRITICAL(engine " engine creation failed. Trying software X11."); \
1340         win->ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);      \
1341    } while (0)
1342 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
1343
1344    switch (type)
1345      {
1346       case ELM_WIN_INLINED_IMAGE:
1347           {
1348              if (parent)
1349                {
1350                   Evas *e = evas_object_evas_get(parent);
1351                   if (e)
1352                     {
1353                        Ecore_Evas *ee = ecore_evas_ecore_evas_get(e);
1354                        if (ee)
1355                          {
1356                             win->img_obj = ecore_evas_object_image_new(ee);
1357                             if (win->img_obj)
1358                               {
1359                                  win->ee = ecore_evas_object_ecore_evas_get(win->img_obj);
1360                                  if (win->ee)
1361                                    {
1362                                       _win_inlined_image_set(win);
1363                                    }
1364                                  else
1365                                    {
1366                                       evas_object_del(win->img_obj);
1367                                       win->img_obj = NULL;
1368                                    }
1369                               }
1370                          }
1371                     }
1372                }
1373           }
1374         break;
1375       default:
1376         if (ENGINE_COMPARE(ELM_SOFTWARE_X11))
1377           {
1378              win->ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
1379 #ifdef HAVE_ELEMENTARY_X
1380              win->client_message_handler = ecore_event_handler_add
1381                 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1382 #endif
1383           }
1384         else if (ENGINE_COMPARE(ELM_SOFTWARE_FB))
1385           {
1386              win->ee = ecore_evas_fb_new(NULL, 0, 1, 1);
1387              FALLBACK_TRY("Sofware FB");
1388           }
1389         else if (ENGINE_COMPARE(ELM_SOFTWARE_DIRECTFB))
1390           {
1391              win->ee = ecore_evas_directfb_new(NULL, 1, 0, 0, 1, 1);
1392              FALLBACK_TRY("Sofware DirectFB");
1393           }
1394         else if (ENGINE_COMPARE(ELM_SOFTWARE_16_X11))
1395           {
1396              win->ee = ecore_evas_software_x11_16_new(NULL, 0, 0, 0, 1, 1);
1397              FALLBACK_TRY("Sofware-16");
1398 #ifdef HAVE_ELEMENTARY_X
1399              win->client_message_handler = ecore_event_handler_add
1400                 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1401 #endif
1402      }
1403         else if (ENGINE_COMPARE(ELM_SOFTWARE_8_X11))
1404           {
1405              win->ee = ecore_evas_software_x11_8_new(NULL, 0, 0, 0, 1, 1);
1406              FALLBACK_TRY("Sofware-8");
1407 #ifdef HAVE_ELEMENTARY_X
1408              win->client_message_handler = ecore_event_handler_add
1409                 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1410 #endif
1411           }
1412 /* killed
1413         else if (ENGINE_COMPARE(ELM_XRENDER_X11))
1414           {
1415              win->ee = ecore_evas_xrender_x11_new(NULL, 0, 0, 0, 1, 1);
1416              FALLBACK_TRY("XRender");
1417 #ifdef HAVE_ELEMENTARY_X
1418              win->client_message_handler = ecore_event_handler_add
1419                 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1420 #endif
1421           }
1422  */
1423         else if (ENGINE_COMPARE(ELM_OPENGL_X11))
1424           {
1425              int opt[10];
1426              int opt_i = 0;
1427
1428              if (_elm_config->vsync)
1429                {
1430                   opt[opt_i] = ECORE_EVAS_GL_X11_OPT_VSYNC;
1431                   opt_i++;
1432                   opt[opt_i] = 1;
1433                   opt_i++;
1434                }
1435              if (opt_i > 0)
1436                 win->ee = ecore_evas_gl_x11_options_new(NULL, 0, 0, 0, 1, 1, opt);
1437              else
1438                 win->ee = ecore_evas_gl_x11_new(NULL, 0, 0, 0, 1, 1);
1439              FALLBACK_TRY("OpenGL");
1440 #ifdef HAVE_ELEMENTARY_X
1441              win->client_message_handler = ecore_event_handler_add
1442                 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1443 #endif
1444           }
1445         else if (ENGINE_COMPARE(ELM_SOFTWARE_WIN32))
1446           {
1447              win->ee = ecore_evas_software_gdi_new(NULL, 0, 0, 1, 1);
1448              FALLBACK_TRY("Sofware Win32");
1449           }
1450         else if (ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE))
1451           {
1452              win->ee = ecore_evas_software_wince_gdi_new(NULL, 0, 0, 1, 1);
1453              FALLBACK_TRY("Sofware-16-WinCE");
1454           }
1455         else if (ENGINE_COMPARE(ELM_SOFTWARE_SDL))
1456           {
1457              win->ee = ecore_evas_sdl_new(NULL, 0, 0, 0, 0, 0, 1);
1458              FALLBACK_TRY("Sofware SDL");
1459           }
1460         else if (ENGINE_COMPARE(ELM_SOFTWARE_16_SDL))
1461           {
1462              win->ee = ecore_evas_sdl16_new(NULL, 0, 0, 0, 0, 0, 1);
1463              FALLBACK_TRY("Sofware-16-SDL");
1464           }
1465         else if (ENGINE_COMPARE(ELM_OPENGL_SDL))
1466           {
1467              win->ee = ecore_evas_gl_sdl_new(NULL, 1, 1, 0, 0);
1468              FALLBACK_TRY("OpenGL SDL");
1469           }
1470         else if (!strncmp(_elm_config->engine, "shot:", 5))
1471           {
1472              win->ee = ecore_evas_buffer_new(1, 1);
1473              ecore_evas_manual_render_set(win->ee, EINA_TRUE);
1474              win->shot.info = eina_stringshare_add(_elm_config->engine + 5);
1475           }
1476 #undef FALLBACK_TRY
1477         break;
1478      }
1479
1480    if (!win->ee)
1481      {
1482         ERR("Cannot create window.");
1483         free(win);
1484         return NULL;
1485      }
1486 #ifdef HAVE_ELEMENTARY_X
1487    _elm_win_xwindow_get(win);
1488 #endif
1489    if ((_elm_config->bgpixmap) && (!_elm_config->compositing))
1490      ecore_evas_avoid_damage_set(win->ee, ECORE_EVAS_AVOID_DAMAGE_EXPOSE);
1491    // bg pixmap done by x - has other issues like can be redrawn by x before it
1492    // is filled/ready by app
1493    //     ecore_evas_avoid_damage_set(win->ee, ECORE_EVAS_AVOID_DAMAGE_BUILT_IN);
1494
1495    win->type = type;
1496    win->parent = parent;
1497    if (win->parent)
1498      evas_object_event_callback_add(win->parent, EVAS_CALLBACK_DEL,
1499                                     _elm_win_obj_callback_parent_del, win);
1500
1501    win->evas = ecore_evas_get(win->ee);
1502    win->win_obj = elm_widget_add(win->evas);
1503    elm_widget_type_set(win->win_obj, "win");
1504    ELM_SET_WIDTYPE(widtype, "win");
1505    elm_widget_data_set(win->win_obj, win);
1506    elm_widget_event_hook_set(win->win_obj, _elm_win_event_cb);
1507    elm_widget_on_focus_hook_set(win->win_obj, _elm_win_on_focus_hook, NULL);
1508    elm_widget_can_focus_set(win->win_obj, EINA_TRUE);
1509    elm_widget_highlight_ignore_set(win->win_obj, EINA_TRUE);
1510    elm_widget_focus_next_hook_set(win->win_obj, _elm_win_focus_next_hook);
1511    evas_object_color_set(win->win_obj, 0, 0, 0, 0);
1512    evas_object_move(win->win_obj, 0, 0);
1513    evas_object_resize(win->win_obj, 1, 1);
1514    evas_object_layer_set(win->win_obj, 50);
1515    evas_object_pass_events_set(win->win_obj, EINA_TRUE);
1516
1517    ecore_evas_object_associate(win->ee, win->win_obj,
1518                                ECORE_EVAS_OBJECT_ASSOCIATE_BASE |
1519                                ECORE_EVAS_OBJECT_ASSOCIATE_STACK |
1520                                ECORE_EVAS_OBJECT_ASSOCIATE_LAYER);
1521    evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_SHOW,
1522                                   _elm_win_obj_callback_show, win);
1523    evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_HIDE,
1524                                   _elm_win_obj_callback_hide, win);
1525    evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_DEL,
1526                                   _elm_win_obj_callback_del, win);
1527    evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_MOVE,
1528                                   _elm_win_obj_callback_move, win);
1529    evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_RESIZE,
1530                                   _elm_win_obj_callback_resize, win);
1531    if (win->img_obj)
1532       evas_object_intercept_move_callback_add(win->win_obj,
1533                                               _elm_win_obj_intercept_move, win);
1534    evas_object_intercept_show_callback_add(win->win_obj,
1535                                            _elm_win_obj_intercept_show, win);
1536
1537    ecore_evas_name_class_set(win->ee, name, _elm_appname);
1538    ecore_evas_callback_delete_request_set(win->ee, _elm_win_delete_request);
1539    ecore_evas_callback_resize_set(win->ee, _elm_win_resize);
1540    ecore_evas_callback_focus_in_set(win->ee, _elm_win_focus_in);
1541    ecore_evas_callback_focus_out_set(win->ee, _elm_win_focus_out);
1542    ecore_evas_callback_move_set(win->ee, _elm_win_move);
1543    evas_image_cache_set(win->evas, (_elm_config->image_cache * 1024));
1544    evas_font_cache_set(win->evas, (_elm_config->font_cache * 1024));
1545    EINA_LIST_FOREACH(_elm_config->font_dirs, l, fontpath)
1546       evas_font_path_append(win->evas, fontpath);
1547    if (!_elm_config->font_hinting)
1548      evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_NONE);
1549    else if (_elm_config->font_hinting == 1)
1550      evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_AUTO);
1551    else if (_elm_config->font_hinting == 2)
1552      evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_BYTECODE);
1553
1554 #ifdef HAVE_ELEMENTARY_X
1555    _elm_win_xwin_update(win);
1556 #endif
1557
1558    _elm_win_list = eina_list_append(_elm_win_list, win->win_obj);
1559
1560    if (ENGINE_COMPARE(ELM_SOFTWARE_FB))
1561      {
1562         ecore_evas_fullscreen_set(win->ee, 1);
1563      }
1564 #undef ENGINE_COMPARE
1565
1566    if (_elm_config->focus_highlight_enable)
1567      elm_win_focus_highlight_enabled_set(win->win_obj, EINA_TRUE);
1568
1569 #ifdef ELM_DEBUG
1570    Evas_Modifier_Mask mask = evas_key_modifier_mask_get(win->evas, "Control");
1571    evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_KEY_DOWN,
1572                                   _debug_key_down, win);
1573
1574    Eina_Bool ret = evas_object_key_grab(win->win_obj, "F12", mask, 0,
1575                                         EINA_TRUE);
1576    printf("Key F12 exclusive for dot tree generation. (%d)\n", ret);
1577 #endif
1578
1579    evas_object_smart_callbacks_descriptions_set(win->win_obj, _signals);
1580
1581    return win->win_obj;
1582 }
1583
1584 /**
1585  * Add @p subobj as a resize object of window @p obj.
1586  *
1587  * @param obj The window object
1588  * @param subobj The resize object to add
1589  *
1590  * @ingroup Win
1591  */
1592 EAPI void
1593 elm_win_resize_object_add(Evas_Object *obj, Evas_Object *subobj)
1594 {
1595    Evas_Coord w, h;
1596    Elm_Win *win;
1597    ELM_CHECK_WIDTYPE(obj, widtype);
1598    win = elm_widget_data_get(obj);
1599    if (!win) return;
1600    if (eina_list_data_find(win->subobjs, subobj)) return;
1601    win->subobjs = eina_list_append(win->subobjs, subobj);
1602    elm_widget_sub_object_add(obj, subobj);
1603    evas_object_event_callback_add(subobj, EVAS_CALLBACK_DEL,
1604                                   _elm_win_subobj_callback_del, obj);
1605    evas_object_event_callback_add(subobj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1606                                   _elm_win_subobj_callback_changed_size_hints,
1607                                   obj);
1608    ecore_evas_geometry_get(win->ee, NULL, NULL, &w, &h);
1609    evas_object_move(subobj, 0, 0);
1610    evas_object_resize(subobj, w, h);
1611    _elm_win_eval_subobjs(obj);
1612 }
1613
1614 /**
1615  * Delete @p subobj as a resize object of window @p obj.
1616  *
1617  * @param obj The window object
1618  * @param subobj The resize object to add
1619  *
1620  * @ingroup Win
1621  */
1622 EAPI void
1623 elm_win_resize_object_del(Evas_Object *obj, Evas_Object *subobj)
1624 {
1625    Elm_Win *win;
1626    ELM_CHECK_WIDTYPE(obj, widtype);
1627    win = elm_widget_data_get(obj);
1628    if (!win) return;
1629    evas_object_event_callback_del_full(subobj,
1630                                        EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1631                                        _elm_win_subobj_callback_changed_size_hints,
1632                                        obj);
1633    evas_object_event_callback_del_full(subobj, EVAS_CALLBACK_DEL,
1634                                        _elm_win_subobj_callback_del, obj);
1635    win->subobjs = eina_list_remove(win->subobjs, subobj);
1636    elm_widget_sub_object_del(obj, subobj);
1637    _elm_win_eval_subobjs(obj);
1638 }
1639
1640 /**
1641  * Set the title of the window
1642  *
1643  * @param obj The window object
1644  * @param title The title to set
1645  *
1646  * @ingroup Win
1647  */
1648 EAPI void
1649 elm_win_title_set(Evas_Object *obj, const char *title)
1650 {
1651    Elm_Win *win;
1652    ELM_CHECK_WIDTYPE(obj, widtype);
1653    win = elm_widget_data_get(obj);
1654    if (!win) return;
1655    ecore_evas_title_set(win->ee, title);
1656 }
1657
1658 /**
1659  * Get the title of the window
1660  *
1661  * @param obj The window object
1662  * @return The title
1663  *
1664  * @ingroup Win
1665  */
1666 EAPI const char *
1667 elm_win_title_get(const Evas_Object *obj)
1668 {
1669    Elm_Win *win;
1670    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1671    win = elm_widget_data_get(obj);
1672    if (!win) return NULL;
1673    return ecore_evas_title_get(win->ee);
1674 }
1675
1676 /**
1677  * Set the window's autodel state.
1678  *
1679  * @param obj The window object
1680  * @param autodel If true, the window will automatically delete itself when closed
1681  *
1682  * @ingroup Win
1683  */
1684 EAPI void
1685 elm_win_autodel_set(Evas_Object *obj, Eina_Bool autodel)
1686 {
1687    Elm_Win *win;
1688    ELM_CHECK_WIDTYPE(obj, widtype);
1689    win = elm_widget_data_get(obj);
1690    if (!win) return;
1691    win->autodel = autodel;
1692 }
1693
1694 /**
1695  * Get the window's autodel state.
1696  *
1697  * @param obj The window object
1698  * @return If the window will automatically delete itself when closed
1699  *
1700  * @ingroup Win
1701  */
1702 EAPI Eina_Bool
1703 elm_win_autodel_get(const Evas_Object *obj)
1704 {
1705    Elm_Win *win;
1706    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1707    win = elm_widget_data_get(obj);
1708    if (!win) return EINA_FALSE;
1709    return win->autodel;
1710 }
1711
1712 /**
1713  * Activate a window object.
1714  *
1715  * @param obj The window object
1716  *
1717  * @ingroup Win
1718  */
1719 EAPI void
1720 elm_win_activate(Evas_Object *obj)
1721 {
1722    Elm_Win *win;
1723    ELM_CHECK_WIDTYPE(obj, widtype);
1724    win = elm_widget_data_get(obj);
1725    if (!win) return;
1726    ecore_evas_activate(win->ee);
1727 }
1728
1729 /**
1730  * Lower a window object.
1731  *
1732  * @param obj The window object
1733  *
1734  * @ingroup Win
1735  */
1736 EAPI void
1737 elm_win_lower(Evas_Object *obj)
1738 {
1739    Elm_Win *win;
1740    ELM_CHECK_WIDTYPE(obj, widtype);
1741    win = elm_widget_data_get(obj);
1742    if (!win) return;
1743    ecore_evas_lower(win->ee);
1744 }
1745
1746 /**
1747  * Raise a window object.
1748  *
1749  * @param obj The window object
1750  *
1751  * @ingroup Win
1752  */
1753 EAPI void
1754 elm_win_raise(Evas_Object *obj)
1755 {
1756    Elm_Win *win;
1757    ELM_CHECK_WIDTYPE(obj, widtype);
1758    win = elm_widget_data_get(obj);
1759    if (!win) return;
1760    ecore_evas_raise(win->ee);
1761 }
1762
1763 /**
1764  * Set the borderless state of a window.
1765  *
1766  * @param obj The window object
1767  * @param borderless If true, the window is borderless
1768  *
1769  * @ingroup Win
1770  */
1771 EAPI void
1772 elm_win_borderless_set(Evas_Object *obj, Eina_Bool borderless)
1773 {
1774    Elm_Win *win;
1775    ELM_CHECK_WIDTYPE(obj, widtype);
1776    win = elm_widget_data_get(obj);
1777    if (!win) return;
1778    ecore_evas_borderless_set(win->ee, borderless);
1779 #ifdef HAVE_ELEMENTARY_X
1780    _elm_win_xwin_update(win);
1781 #endif
1782 }
1783
1784 /**
1785  * Get the borderless state of a window.
1786  *
1787  * @param obj The window object
1788  * @return If true, the window is borderless
1789  *
1790  * @ingroup Win
1791  */
1792 EAPI Eina_Bool
1793 elm_win_borderless_get(const Evas_Object *obj)
1794 {
1795    Elm_Win *win;
1796    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1797    win = elm_widget_data_get(obj);
1798    if (!win) return EINA_FALSE;
1799    return ecore_evas_borderless_get(win->ee);
1800 }
1801
1802 /**
1803  * Set the shaped state of a window.
1804  *
1805  * @param obj The window object
1806  * @param shaped If true, the window is shaped
1807  *
1808  * @ingroup Win
1809  */
1810 EAPI void
1811 elm_win_shaped_set(Evas_Object *obj, Eina_Bool shaped)
1812 {
1813    Elm_Win *win;
1814    ELM_CHECK_WIDTYPE(obj, widtype);
1815    win = elm_widget_data_get(obj);
1816    if (!win) return;
1817    ecore_evas_shaped_set(win->ee, shaped);
1818 #ifdef HAVE_ELEMENTARY_X
1819    _elm_win_xwin_update(win);
1820 #endif
1821 }
1822
1823 /**
1824  * Get the shaped state of a window.
1825  *
1826  * @param obj The window object
1827  * @return If true, the window is shaped
1828  *
1829  * @ingroup Win
1830  */
1831 EAPI Eina_Bool
1832 elm_win_shaped_get(const Evas_Object *obj)
1833 {
1834    Elm_Win *win;
1835    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1836    win = elm_widget_data_get(obj);
1837    if (!win) return EINA_FALSE;
1838    return ecore_evas_shaped_get(win->ee);
1839 }
1840
1841 /**
1842  * Set the alpha channel state of a window.
1843  *
1844  * @param obj The window object
1845  * @param alpha If true, the window has an alpha channel
1846  *
1847  * @ingroup Win
1848  */
1849 EAPI void
1850 elm_win_alpha_set(Evas_Object *obj, Eina_Bool alpha)
1851 {
1852    Elm_Win *win;
1853    ELM_CHECK_WIDTYPE(obj, widtype);
1854    win = elm_widget_data_get(obj);
1855    if (!win) return;
1856    if (win->frame_obj)
1857      {
1858      }
1859    else if (win->img_obj)
1860      {
1861         evas_object_image_alpha_set(win->img_obj, alpha);
1862      }
1863    else
1864      {
1865 #ifdef HAVE_ELEMENTARY_X
1866         if (win->xwin)
1867           {
1868              if (alpha)
1869                {
1870                   if (!_elm_config->compositing)
1871                      elm_win_shaped_set(obj, alpha);
1872                   else
1873                      ecore_evas_alpha_set(win->ee, alpha);
1874                }
1875              else
1876                 ecore_evas_alpha_set(win->ee, alpha);
1877              _elm_win_xwin_update(win);
1878           }
1879         else
1880 #endif
1881            ecore_evas_alpha_set(win->ee, alpha);
1882      }
1883 }
1884
1885 /**
1886  * Get the alpha channel state of a window.
1887  *
1888  * @param obj The window object
1889  * @return If true, the window has an alpha channel
1890  *
1891  * @ingroup Win
1892  */
1893 EAPI Eina_Bool
1894 elm_win_alpha_get(const Evas_Object *obj)
1895 {
1896    Elm_Win *win;
1897    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1898    win = elm_widget_data_get(obj);
1899    if (!win) return EINA_FALSE;
1900    return ecore_evas_alpha_get(win->ee);
1901 }
1902
1903 /**
1904  * Set the transparency state of a window.
1905  *
1906  * @param obj The window object
1907  * @param transparent If true, the window is transparent
1908  *
1909  * @ingroup Win
1910  */
1911 EAPI void
1912 elm_win_transparent_set(Evas_Object *obj, Eina_Bool transparent)
1913 {
1914    Elm_Win *win;
1915    ELM_CHECK_WIDTYPE(obj, widtype);
1916    win = elm_widget_data_get(obj);
1917    if (!win) return;
1918
1919    if (win->frame_obj)
1920      {
1921      }
1922    else if (win->img_obj)
1923      {
1924         evas_object_image_alpha_set(win->img_obj, transparent);
1925      }
1926    else
1927      {
1928 #ifdef HAVE_ELEMENTARY_X
1929         if (win->xwin)
1930           {
1931              ecore_evas_transparent_set(win->ee, transparent);
1932              _elm_win_xwin_update(win);
1933           }
1934         else
1935 #endif
1936            ecore_evas_transparent_set(win->ee, transparent);
1937      }
1938 }
1939
1940 /**
1941  * Get the transparency state of a window.
1942  *
1943  * @param obj The window object
1944  * @return If true, the window is transparent
1945  *
1946  * @ingroup Win
1947  */
1948 EAPI Eina_Bool
1949 elm_win_transparent_get(const Evas_Object *obj)
1950 {
1951    Elm_Win *win;
1952    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1953    win = elm_widget_data_get(obj);
1954    if (!win) return EINA_FALSE;
1955
1956    return ecore_evas_transparent_get(win->ee);
1957 }
1958
1959 /**
1960  * Set the override state of a window.
1961  *
1962  * @param obj The window object
1963  * @param override If true, the window is overridden
1964  *
1965  * @ingroup Win
1966  */
1967 EAPI void
1968 elm_win_override_set(Evas_Object *obj, Eina_Bool override)
1969 {
1970    Elm_Win *win;
1971    ELM_CHECK_WIDTYPE(obj, widtype);
1972    win = elm_widget_data_get(obj);
1973    if (!win) return;
1974    ecore_evas_override_set(win->ee, override);
1975 #ifdef HAVE_ELEMENTARY_X
1976    _elm_win_xwin_update(win);
1977 #endif
1978 }
1979
1980 /**
1981  * Get the override state of a window.
1982  *
1983  * @param obj The window object
1984  * @return If true, the window is overridden
1985  *
1986  * @ingroup Win
1987  */
1988 EAPI Eina_Bool
1989 elm_win_override_get(const Evas_Object *obj)
1990 {
1991    Elm_Win *win;
1992    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1993    win = elm_widget_data_get(obj);
1994    if (!win) return EINA_FALSE;
1995    return ecore_evas_override_get(win->ee);
1996 }
1997
1998 /**
1999  * Set the fullscreen state of a window.
2000  *
2001  * @param obj The window object
2002  * @param fullscreen If true, the window is fullscreen
2003  *
2004  * @ingroup Win
2005  */
2006 EAPI void
2007 elm_win_fullscreen_set(Evas_Object *obj, Eina_Bool fullscreen)
2008 {
2009    Elm_Win *win;
2010    ELM_CHECK_WIDTYPE(obj, widtype);
2011    win = elm_widget_data_get(obj);
2012    if (!win) return;
2013
2014    // YYY: handle if win->img_obj
2015 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
2016    if (ENGINE_COMPARE(ELM_SOFTWARE_FB) ||
2017        ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE))
2018      {
2019         // these engines... can ONLY be fullscreen
2020         return;
2021      }
2022    else
2023      {
2024         ecore_evas_fullscreen_set(win->ee, fullscreen);
2025 #ifdef HAVE_ELEMENTARY_X
2026         _elm_win_xwin_update(win);
2027 #endif
2028      }
2029 #undef ENGINE_COMPARE
2030 }
2031
2032 /**
2033  * Get the fullscreen state of a window.
2034  *
2035  * @param obj The window object
2036  * @return If true, the window is fullscreen
2037  *
2038  * @ingroup Win
2039  */
2040 EAPI Eina_Bool
2041 elm_win_fullscreen_get(const Evas_Object *obj)
2042 {
2043    Elm_Win *win;
2044    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2045    win = elm_widget_data_get(obj);
2046    if (!win) return EINA_FALSE;
2047
2048 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
2049    if (ENGINE_COMPARE(ELM_SOFTWARE_FB) ||
2050        ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE))
2051      {
2052         // these engines... can ONLY be fullscreen
2053         return EINA_TRUE;
2054      }
2055    else
2056      {
2057         return ecore_evas_fullscreen_get(win->ee);
2058      }
2059 #undef ENGINE_COMPARE
2060 }
2061
2062 /**
2063  * Set the maximized state of a window.
2064  *
2065  * @param obj The window object
2066  * @param maximized If true, the window is maximized
2067  *
2068  * @ingroup Win
2069  */
2070 EAPI void
2071 elm_win_maximized_set(Evas_Object *obj, Eina_Bool maximized)
2072 {
2073    Elm_Win *win;
2074    ELM_CHECK_WIDTYPE(obj, widtype);
2075    win = elm_widget_data_get(obj);
2076    if (!win) return;
2077    // YYY: handle if win->img_obj
2078    ecore_evas_maximized_set(win->ee, maximized);
2079 #ifdef HAVE_ELEMENTARY_X
2080    _elm_win_xwin_update(win);
2081 #endif
2082 }
2083
2084 /**
2085  * Get the maximized state of a window.
2086  *
2087  * @param obj The window object
2088  * @return If true, the window is maximized
2089  *
2090  * @ingroup Win
2091  */
2092 EAPI Eina_Bool
2093 elm_win_maximized_get(const Evas_Object *obj)
2094 {
2095    Elm_Win *win;
2096    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2097    win = elm_widget_data_get(obj);
2098    if (!win) return EINA_FALSE;
2099    return ecore_evas_maximized_get(win->ee);
2100 }
2101
2102 /**
2103  * Set the iconified state of a window.
2104  *
2105  * @param obj The window object
2106  * @param iconified If true, the window is iconified
2107  *
2108  * @ingroup Win
2109  */
2110 EAPI void
2111 elm_win_iconified_set(Evas_Object *obj, Eina_Bool iconified)
2112 {
2113    Elm_Win *win;
2114    ELM_CHECK_WIDTYPE(obj, widtype);
2115    win = elm_widget_data_get(obj);
2116    if (!win) return;
2117    ecore_evas_iconified_set(win->ee, iconified);
2118 #ifdef HAVE_ELEMENTARY_X
2119    _elm_win_xwin_update(win);
2120 #endif
2121 }
2122
2123 /**
2124  * Get the iconified state of a window.
2125  *
2126  * @param obj The window object
2127  * @return If true, the window is iconified
2128  *
2129  * @ingroup Win
2130  */
2131 EAPI Eina_Bool
2132 elm_win_iconified_get(const Evas_Object *obj)
2133 {
2134    Elm_Win *win;
2135    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2136    win = elm_widget_data_get(obj);
2137    if (!win) return EINA_FALSE;
2138    return ecore_evas_iconified_get(win->ee);
2139 }
2140
2141 /**
2142  * Set the layer of the window.
2143  *
2144  * @param obj The window object
2145  * @param layer The layer of the window
2146  *
2147  * @ingroup Win
2148  */
2149 EAPI void
2150 elm_win_layer_set(Evas_Object *obj, int layer)
2151 {
2152    Elm_Win *win;
2153    ELM_CHECK_WIDTYPE(obj, widtype);
2154    win = elm_widget_data_get(obj);
2155    if (!win) return;
2156    ecore_evas_layer_set(win->ee, layer);
2157 #ifdef HAVE_ELEMENTARY_X
2158    _elm_win_xwin_update(win);
2159 #endif
2160 }
2161
2162 /**
2163  * Get the layer of the window.
2164  *
2165  * @param obj The window object
2166  * @return The layer of the window
2167  *
2168  * @ingroup Win
2169  */
2170 EAPI int
2171 elm_win_layer_get(const Evas_Object *obj)
2172 {
2173    Elm_Win *win;
2174    ELM_CHECK_WIDTYPE(obj, widtype) -1;
2175    win = elm_widget_data_get(obj);
2176    if (!win) return -1;
2177    return ecore_evas_layer_get(win->ee);
2178 }
2179
2180 /**
2181  * Set the rotation of the window.
2182  *
2183  * @param obj The window object
2184  * @param rotation The rotation of the window, in degrees (0-360)
2185  *
2186  * @ingroup Win
2187  */
2188 EAPI void
2189 elm_win_rotation_set(Evas_Object *obj, int rotation)
2190 {
2191    Elm_Win *win;
2192    ELM_CHECK_WIDTYPE(obj, widtype);
2193    win = elm_widget_data_get(obj);
2194    if (!win) return;
2195    if (win->rot == rotation) return;
2196    win->rot = rotation;
2197    ecore_evas_rotation_set(win->ee, rotation);
2198    evas_object_size_hint_min_set(obj, -1, -1);
2199    evas_object_size_hint_max_set(obj, -1, -1);
2200    _elm_win_eval_subobjs(obj);
2201 #ifdef HAVE_ELEMENTARY_X
2202    _elm_win_xwin_update(win);
2203 #endif
2204 }
2205
2206 /**
2207  * Rotates the window and resizes it
2208  *
2209  * @param obj The window object
2210  * @param layer The rotation of the window in degrees (0-360)
2211  *
2212  * @ingroup Win
2213  */
2214 EAPI void
2215 elm_win_rotation_with_resize_set(Evas_Object *obj, int rotation)
2216 {
2217    Elm_Win *win;
2218    ELM_CHECK_WIDTYPE(obj, widtype);
2219    win = elm_widget_data_get(obj);
2220    if (!win) return;
2221    if (win->rot == rotation) return;
2222    win->rot = rotation;
2223    ecore_evas_rotation_with_resize_set(win->ee, rotation);
2224    evas_object_size_hint_min_set(obj, -1, -1);
2225    evas_object_size_hint_max_set(obj, -1, -1);
2226    _elm_win_eval_subobjs(obj);
2227 #ifdef HAVE_ELEMENTARY_X
2228    _elm_win_xwin_update(win);
2229 #endif
2230 }
2231
2232 /**
2233  * Get the rotation of the window.
2234  *
2235  * @param obj The window object
2236  * @return The rotation of the window in degrees (0-360)
2237  *
2238  * @ingroup Win
2239  */
2240 EAPI int
2241 elm_win_rotation_get(const Evas_Object *obj)
2242 {
2243    Elm_Win *win;
2244    ELM_CHECK_WIDTYPE(obj, widtype) -1;
2245    win = elm_widget_data_get(obj);
2246    if (!win) return -1;
2247    return win->rot;
2248 }
2249
2250 /**
2251  * Set the sticky state of the window.
2252  *
2253  * @param obj The window object
2254  * @param sticky If true, the window's sticky state is enabled
2255  *
2256  * @ingroup Win
2257  */
2258 EAPI void
2259 elm_win_sticky_set(Evas_Object *obj, Eina_Bool sticky)
2260 {
2261    Elm_Win *win;
2262    ELM_CHECK_WIDTYPE(obj, widtype);
2263    win = elm_widget_data_get(obj);
2264    if (!win) return;
2265    ecore_evas_sticky_set(win->ee, sticky);
2266 #ifdef HAVE_ELEMENTARY_X
2267    _elm_win_xwin_update(win);
2268 #endif
2269 }
2270
2271 /**
2272  * Get the sticky state of the window.
2273  *
2274  * @param obj The window object
2275  * @return If true, the window's sticky state is enabled
2276  *
2277  * @ingroup Win
2278  */
2279 EAPI Eina_Bool
2280 elm_win_sticky_get(const Evas_Object *obj)
2281 {
2282    Elm_Win *win;
2283    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2284    win = elm_widget_data_get(obj);
2285    if (!win) return EINA_FALSE;
2286    return ecore_evas_sticky_get(win->ee);
2287 }
2288
2289 /**
2290  * Sets the keyboard mode of the window.
2291  *
2292  * @param obj The window object
2293  * @param mode The mode to set; one of:
2294  * ELM_WIN_KEYBOARD_UNKNOWN
2295  * ELM_WIN_KEYBOARD_OFF
2296  * ELM_WIN_KEYBOARD_ON
2297  * ELM_WIN_KEYBOARD_ALPHA
2298  * ELM_WIN_KEYBOARD_NUMERIC
2299  * ELM_WIN_KEYBOARD_PIN
2300  * ELM_WIN_KEYBOARD_PHONE_NUMBER
2301  * ELM_WIN_KEYBOARD_HEX
2302  * ELM_WIN_KEYBOARD_TERMINAL
2303  * ELM_WIN_KEYBOARD_PASSWORD
2304  * ELM_WIN_KEYBOARD_IP
2305  * ELM_WIN_KEYBOARD_HOST
2306  * ELM_WIN_KEYBOARD_FILE
2307  * ELM_WIN_KEYBOARD_URL
2308  * ELM_WIN_KEYBOARD_KEYPAD
2309  * ELM_WIN_KEYBOARD_J2ME
2310  *
2311  * @ingroup Win
2312  */
2313 EAPI void
2314 elm_win_keyboard_mode_set(Evas_Object *obj, Elm_Win_Keyboard_Mode mode)
2315 {
2316    Elm_Win *win;
2317    ELM_CHECK_WIDTYPE(obj, widtype);
2318    win = elm_widget_data_get(obj);
2319    if (!win) return;
2320    if (mode == win->kbdmode) return;
2321 #ifdef HAVE_ELEMENTARY_X
2322    _elm_win_xwindow_get(win);
2323 #endif
2324    win->kbdmode = mode;
2325 #ifdef HAVE_ELEMENTARY_X
2326    if (win->xwin)
2327      ecore_x_e_virtual_keyboard_state_set
2328         (win->xwin, (Ecore_X_Virtual_Keyboard_State)win->kbdmode);
2329 #endif
2330 }
2331
2332 /**
2333  * Gets the keyboard mode of the window.
2334  *
2335  * @param obj The window object
2336  * @return The mode; one of:
2337  * ELM_WIN_KEYBOARD_UNKNOWN
2338  * ELM_WIN_KEYBOARD_OFF
2339  * ELM_WIN_KEYBOARD_ON
2340  * ELM_WIN_KEYBOARD_ALPHA
2341  * ELM_WIN_KEYBOARD_NUMERIC
2342  * ELM_WIN_KEYBOARD_PIN
2343  * ELM_WIN_KEYBOARD_PHONE_NUMBER
2344  * ELM_WIN_KEYBOARD_HEX
2345  * ELM_WIN_KEYBOARD_TERMINAL
2346  * ELM_WIN_KEYBOARD_PASSWORD
2347  * ELM_WIN_KEYBOARD_IP
2348  * ELM_WIN_KEYBOARD_HOST
2349  * ELM_WIN_KEYBOARD_FILE
2350  * ELM_WIN_KEYBOARD_URL
2351  * ELM_WIN_KEYBOARD_KEYPAD
2352  * ELM_WIN_KEYBOARD_J2ME
2353  *
2354  * @ingroup Win
2355  */
2356 EAPI Elm_Win_Keyboard_Mode
2357 elm_win_keyboard_mode_get(const Evas_Object *obj)
2358 {
2359    Elm_Win *win;
2360    ELM_CHECK_WIDTYPE(obj, widtype) ELM_WIN_KEYBOARD_UNKNOWN;
2361    win = elm_widget_data_get(obj);
2362    if (!win) return ELM_WIN_KEYBOARD_UNKNOWN;
2363    return win->kbdmode;
2364 }
2365
2366 /**
2367  * Sets whether the window is a keyboard.
2368  *
2369  * @param obj The window object
2370  * @param is_keyboard If true, the window is a virtual keyboard
2371  *
2372  * @ingroup Win
2373  */
2374 EAPI void
2375 elm_win_keyboard_win_set(Evas_Object *obj, Eina_Bool is_keyboard)
2376 {
2377    Elm_Win *win;
2378    ELM_CHECK_WIDTYPE(obj, widtype);
2379    win = elm_widget_data_get(obj);
2380    if (!win) return;
2381 #ifdef HAVE_ELEMENTARY_X
2382    _elm_win_xwindow_get(win);
2383    if (win->xwin)
2384      ecore_x_e_virtual_keyboard_set(win->xwin, is_keyboard);
2385 #endif
2386 }
2387
2388 /**
2389  * Gets whether the window is a keyboard.
2390  *
2391  * @param obj The window object
2392  * @return If the window is a virtual keyboard
2393  *
2394  * @ingroup Win
2395  */
2396 EAPI Eina_Bool
2397 elm_win_keyboard_win_get(const Evas_Object *obj)
2398 {
2399    Elm_Win *win;
2400    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2401    win = elm_widget_data_get(obj);
2402    if (!win) return EINA_FALSE;
2403 #ifdef HAVE_ELEMENTARY_X
2404    _elm_win_xwindow_get(win);
2405    if (win->xwin)
2406      return ecore_x_e_virtual_keyboard_get(win->xwin);
2407 #endif
2408    return EINA_FALSE;
2409 }
2410
2411 /**
2412  * Get the screen position of a window.
2413  *
2414  * @param obj The window object
2415  * @param x The int to store the x coordinate to
2416  * @param y The int to store the y coordinate to
2417  *
2418  * @ingroup Win
2419  */
2420 EAPI void
2421 elm_win_screen_position_get(const Evas_Object *obj, int *x, int *y)
2422 {
2423    Elm_Win *win;
2424    ELM_CHECK_WIDTYPE(obj, widtype);
2425    win = elm_widget_data_get(obj);
2426    if (!win) return;
2427    if (x) *x = win->screen.x;
2428    if (y) *y = win->screen.y;
2429 }
2430
2431 /**
2432  * Set if this window is an illume conformant window
2433  *
2434  * @param obj The window object
2435  * @param conformant The conformant flag (1 = conformant, 0 = non-conformant)
2436  *
2437  * @ingroup Win
2438  */
2439 EAPI void
2440 elm_win_conformant_set(Evas_Object *obj, Eina_Bool conformant)
2441 {
2442    Elm_Win *win;
2443    ELM_CHECK_WIDTYPE(obj, widtype);
2444    win = elm_widget_data_get(obj);
2445    if (!win) return;
2446 #ifdef HAVE_ELEMENTARY_X
2447    _elm_win_xwindow_get(win);
2448    if (win->xwin)
2449      ecore_x_e_illume_conformant_set(win->xwin, conformant);
2450 #endif
2451 }
2452
2453 /**
2454  * Get if this window is an illume conformant window
2455  *
2456  * @param obj The window object
2457  * @return A boolean if this window is illume conformant or not
2458  *
2459  * @ingroup Win
2460  */
2461 EAPI Eina_Bool
2462 elm_win_conformant_get(const Evas_Object *obj)
2463 {
2464    Elm_Win *win;
2465    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2466    win = elm_widget_data_get(obj);
2467    if (!win) return EINA_FALSE;
2468 #ifdef HAVE_ELEMENTARY_X
2469    _elm_win_xwindow_get(win);
2470    if (win->xwin)
2471      return ecore_x_e_illume_conformant_get(win->xwin);
2472 #endif
2473    return EINA_FALSE;
2474 }
2475
2476 /**
2477  * Set a window to be an illume quickpanel window
2478  *
2479  * By default window objects are not quickpanel windows.
2480  *
2481  * @param obj The window object
2482  * @param quickpanel The quickpanel flag (1 = quickpanel, 0 = normal window)
2483  *
2484  * @ingroup Win
2485  */
2486 EAPI void
2487 elm_win_quickpanel_set(Evas_Object *obj, Eina_Bool quickpanel)
2488 {
2489    Elm_Win *win;
2490    ELM_CHECK_WIDTYPE(obj, widtype);
2491    win = elm_widget_data_get(obj);
2492    if (!win) return;
2493 #ifdef HAVE_ELEMENTARY_X
2494    _elm_win_xwindow_get(win);
2495    if (win->xwin)
2496      {
2497         ecore_x_e_illume_quickpanel_set(win->xwin, quickpanel);
2498         if (quickpanel)
2499           {
2500              Ecore_X_Window_State states[2];
2501
2502              states[0] = ECORE_X_WINDOW_STATE_SKIP_TASKBAR;
2503              states[1] = ECORE_X_WINDOW_STATE_SKIP_PAGER;
2504              ecore_x_netwm_window_state_set(win->xwin, states, 2);
2505              ecore_x_icccm_hints_set(win->xwin, 0, 0, 0, 0, 0, 0, 0);
2506           }
2507      }
2508 #endif
2509 }
2510
2511 /**
2512  * Get if this window is a quickpanel or not
2513  *
2514  * @param obj The window object
2515  * @return A boolean if this window is a quickpanel or not
2516  *
2517  * @ingroup Win
2518  */
2519 EAPI Eina_Bool
2520 elm_win_quickpanel_get(const Evas_Object *obj)
2521 {
2522    Elm_Win *win;
2523    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2524    win = elm_widget_data_get(obj);
2525    if (!win) return EINA_FALSE;
2526 #ifdef HAVE_ELEMENTARY_X
2527    _elm_win_xwindow_get(win);
2528    if (win->xwin)
2529      return ecore_x_e_illume_quickpanel_get(win->xwin);
2530 #endif
2531    return EINA_FALSE;
2532 }
2533
2534 /**
2535  * Set the major priority of a quickpanel window
2536  *
2537  * @param obj The window object
2538  * @param priority The major priority for this quickpanel
2539  *
2540  * @ingroup Win
2541  */
2542 EAPI void
2543 elm_win_quickpanel_priority_major_set(Evas_Object *obj, int priority)
2544 {
2545    Elm_Win *win;
2546    ELM_CHECK_WIDTYPE(obj, widtype);
2547    win = elm_widget_data_get(obj);
2548    if (!win) return;
2549 #ifdef HAVE_ELEMENTARY_X
2550    _elm_win_xwindow_get(win);
2551    if (win->xwin)
2552      ecore_x_e_illume_quickpanel_priority_major_set(win->xwin, priority);
2553 #endif
2554 }
2555
2556 /**
2557  * Get the major priority of a quickpanel window
2558  *
2559  * @param obj The window object
2560  * @return The major priority of this quickpanel
2561  *
2562  * @ingroup Win
2563  */
2564 EAPI int
2565 elm_win_quickpanel_priority_major_get(const Evas_Object *obj)
2566 {
2567    Elm_Win *win;
2568    ELM_CHECK_WIDTYPE(obj, widtype) -1;
2569    win = elm_widget_data_get(obj);
2570    if (!win) return -1;
2571 #ifdef HAVE_ELEMENTARY_X
2572    _elm_win_xwindow_get(win);
2573    if (win->xwin)
2574      return ecore_x_e_illume_quickpanel_priority_major_get(win->xwin);
2575 #endif
2576    return -1;
2577 }
2578
2579 /**
2580  * Set the minor priority of a quickpanel window
2581  *
2582  * @param obj The window object
2583  * @param priority The minor priority for this quickpanel
2584  *
2585  * @ingroup Win
2586  */
2587 EAPI void
2588 elm_win_quickpanel_priority_minor_set(Evas_Object *obj, int priority)
2589 {
2590    Elm_Win *win;
2591    ELM_CHECK_WIDTYPE(obj, widtype);
2592    win = elm_widget_data_get(obj);
2593    if (!win) return;
2594 #ifdef HAVE_ELEMENTARY_X
2595    _elm_win_xwindow_get(win);
2596    if (win->xwin)
2597      ecore_x_e_illume_quickpanel_priority_minor_set(win->xwin, priority);
2598 #endif
2599 }
2600
2601 /**
2602  * Get the minor priority of a quickpanel window
2603  *
2604  * @param obj The window object
2605  * @return The minor priority of this quickpanel
2606  *
2607  * @ingroup Win
2608  */
2609 EAPI int
2610 elm_win_quickpanel_priority_minor_get(const Evas_Object *obj)
2611 {
2612    Elm_Win *win;
2613    ELM_CHECK_WIDTYPE(obj, widtype) -1;
2614    win = elm_widget_data_get(obj);
2615    if (!win) return -1;
2616 #ifdef HAVE_ELEMENTARY_X
2617    _elm_win_xwindow_get(win);
2618    if (win->xwin)
2619      return ecore_x_e_illume_quickpanel_priority_minor_get(win->xwin);
2620 #endif
2621    return -1;
2622 }
2623
2624 /**
2625  * Set which zone this quickpanel should appear in
2626  *
2627  * @param obj The window object
2628  * @param zone The requested zone for this quickpanel
2629  *
2630  * @ingroup Win
2631  */
2632 EAPI void
2633 elm_win_quickpanel_zone_set(Evas_Object *obj, int zone)
2634 {
2635    Elm_Win *win;
2636    ELM_CHECK_WIDTYPE(obj, widtype);
2637    win = elm_widget_data_get(obj);
2638    if (!win) return;
2639 #ifdef HAVE_ELEMENTARY_X
2640    _elm_win_xwindow_get(win);
2641    if (win->xwin)
2642      ecore_x_e_illume_quickpanel_zone_set(win->xwin, zone);
2643 #endif
2644 }
2645
2646 /**
2647  * Get which zone this quickpanel should appear in
2648  *
2649  * @param obj The window object
2650  * @return The requested zone for this quickpanel
2651  *
2652  * @ingroup Win
2653  */
2654 EAPI int
2655 elm_win_quickpanel_zone_get(const Evas_Object *obj)
2656 {
2657    Elm_Win *win;
2658    ELM_CHECK_WIDTYPE(obj, widtype) 0;
2659    win = elm_widget_data_get(obj);
2660    if (!win) return 0;
2661 #ifdef HAVE_ELEMENTARY_X
2662    _elm_win_xwindow_get(win);
2663    if (win->xwin)
2664      return ecore_x_e_illume_quickpanel_zone_get(win->xwin);
2665 #endif
2666    return 0;
2667 }
2668
2669 /**
2670  * Set the window to be skipped by keyboard focus
2671  *
2672  * This sets the window to be skipped by normal keyboard input. This means
2673  * a window manager will be asked to not focus this window as well as omit
2674  * it from things like the taskbar, pager, "alt-tab" list etc. etc.
2675  *
2676  * Call this and enable it on a window BEFORE you show it for the first time,
2677  * otherwise it may have no effect.
2678  *
2679  * Use this for windows that have only output information or might only be
2680  * interacted with by the mouse or fingers, and never for typing input.
2681  * Be careful that this may have side-effects like making the window
2682  * non-accessible in some cases unless the window is specially handled. Use
2683  * this with care.
2684  *
2685  * @param obj The window object
2686  * @param skip The skip flag state (EINA_TRUE if it is to be skipped)
2687  *
2688  * @ingroup Win
2689  */
2690 EAPI void
2691 elm_win_prop_focus_skip_set(Evas_Object *obj, Eina_Bool skip)
2692 {
2693    Elm_Win *win;
2694    ELM_CHECK_WIDTYPE(obj, widtype);
2695    win = elm_widget_data_get(obj);
2696    if (!win) return;
2697 #ifdef HAVE_ELEMENTARY_X
2698    _elm_win_xwindow_get(win);
2699    if (skip)
2700      {
2701         if (win->xwin)
2702           {
2703              Ecore_X_Window_State states[2];
2704
2705              ecore_x_icccm_hints_set(win->xwin, 0, 0, 0, 0, 0, 0, 0);
2706              states[0] = ECORE_X_WINDOW_STATE_SKIP_TASKBAR;
2707              states[1] = ECORE_X_WINDOW_STATE_SKIP_PAGER;
2708              ecore_x_netwm_window_state_set(win->xwin, states, 2);
2709           }
2710      }
2711 #endif
2712 }
2713
2714 /**
2715  * Send a command to the windowing environment
2716  *
2717  * This is intended to work in touchscreen or small screen device environments
2718  * where there is a more simplistic window management policy in place. This
2719  * uses the window object indicated to select which part of the environment
2720  * to control (the part that this window lives in), and provides a command
2721  * and an optional parameter structure (use NULL for this if not needed).
2722  *
2723  * @param obj The window object that lives in the environment to control
2724  * @param command The command to send
2725  * @param params Optional parameters for the command
2726  *
2727  * @ingroup Win
2728  */
2729 EAPI void
2730 elm_win_illume_command_send(Evas_Object *obj, Elm_Illume_Command command, void *params __UNUSED__)
2731 {
2732    Elm_Win *win;
2733    ELM_CHECK_WIDTYPE(obj, widtype);
2734    win = elm_widget_data_get(obj);
2735    if (!win) return;
2736 #ifdef HAVE_ELEMENTARY_X
2737    _elm_win_xwindow_get(win);
2738    if (win->xwin)
2739      {
2740         switch (command)
2741           {
2742            case ELM_ILLUME_COMMAND_FOCUS_BACK:
2743               ecore_x_e_illume_focus_back_send(win->xwin);
2744               break;
2745            case ELM_ILLUME_COMMAND_FOCUS_FORWARD:
2746               ecore_x_e_illume_focus_forward_send(win->xwin);
2747               break;
2748            case ELM_ILLUME_COMMAND_FOCUS_HOME:
2749               ecore_x_e_illume_focus_home_send(win->xwin);
2750               break;
2751            case ELM_ILLUME_COMMAND_CLOSE:
2752               ecore_x_e_illume_close_send(win->xwin);
2753               break;
2754            default:
2755               break;
2756           }
2757      }
2758 #endif
2759 }
2760
2761 /**
2762  * Get the inlined image object handle
2763  *
2764  * When you create a window with elm_win_add() of type ELM_WIN_INLINED_IMAGE,
2765  * then the window is in fact an evas image object inlined in the parent
2766  * canvas. You can get this object (be careful to not manipulate it as it
2767  * is under control of elementary), and use it to do things like get pixel
2768  * data, save the image to a file, etc.
2769  *
2770  * @param obj The window object to get the inlined image from
2771  * @return The inlined image object, or NULL if none exists
2772  *
2773  * @ingroup Win
2774  */
2775 EAPI Evas_Object *
2776 elm_win_inlined_image_object_get(Evas_Object *obj)
2777 {
2778    Elm_Win *win;
2779    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2780    win = elm_widget_data_get(obj);
2781    if (!win) return NULL;
2782    return win->img_obj;
2783 }
2784
2785 /**
2786  * Set the enabled status for the focus highlight in a window
2787  *
2788  * This function will enable or disable the focus highlight only for the
2789  * given window, regardless of the global setting for it
2790  *
2791  * @param obj The window where to enable the highlight
2792  * @param enabled The enabled value for the highlight
2793  *
2794  * @ingroup Win
2795  */
2796 EAPI void
2797 elm_win_focus_highlight_enabled_set(Evas_Object *obj, Eina_Bool enabled)
2798 {
2799    Elm_Win *win;
2800
2801    ELM_CHECK_WIDTYPE(obj, widtype);
2802
2803    win = elm_widget_data_get(obj);
2804    enabled = !!enabled;
2805    if (win->focus_highlight.enabled == enabled)
2806      return;
2807
2808    win->focus_highlight.enabled = enabled;
2809
2810    if (win->focus_highlight.enabled)
2811      _elm_win_focus_highlight_init(win);
2812    else
2813      _elm_win_focus_highlight_shutdown(win);
2814 }
2815
2816 /**
2817  * Get the enabled value of the focus highlight for this window
2818  *
2819  * @param obj The window in which to check if the focus highlight is enabled
2820  *
2821  * @return EINA_TRUE if enabled, EINA_FALSE otherwise
2822  *
2823  * @ingroup Win
2824  */
2825 EAPI Eina_Bool
2826 elm_win_focus_highlight_enabled_get(const Evas_Object *obj)
2827 {
2828    Elm_Win *win;
2829
2830    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2831
2832    win = elm_widget_data_get(obj);
2833    return win->focus_highlight.enabled;
2834 }
2835
2836 /**
2837  * Set the style for the focus highlight on this window
2838  *
2839  * Sets the style to use for theming the highlight of focused objects on
2840  * the given window. If @p style is NULL, the default will be used.
2841  *
2842  * @param obj The window where to set the style
2843  * @param style The style to set
2844  *
2845  * @ingroup Win
2846  */
2847 EAPI void
2848 elm_win_focus_highlight_style_set(Evas_Object *obj, const char *style)
2849 {
2850    Elm_Win *win;
2851
2852    ELM_CHECK_WIDTYPE(obj, widtype);
2853
2854    win = elm_widget_data_get(obj);
2855    eina_stringshare_replace(&win->focus_highlight.style, style);
2856    win->focus_highlight.changed_theme = EINA_TRUE;
2857    _elm_win_focus_highlight_reconfigure_job_start(win);
2858 }
2859
2860 /**
2861  * Get the style set for the focus highlight object
2862  *
2863  * Gets the style set for this windows highilght object, or NULL if none
2864  * is set.
2865  *
2866  * @param obj The window to retrieve the highlights style from
2867  *
2868  * @return The style set or NULL if none was. Default is used in that case.
2869  *
2870  * @ingroup Win
2871  */
2872 EAPI const char *
2873 elm_win_focus_highlight_style_get(const Evas_Object *obj)
2874 {
2875    Elm_Win *win;
2876
2877    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2878
2879    win = elm_widget_data_get(obj);
2880    return win->focus_highlight.style;
2881 }
2882
2883 typedef struct _Widget_Data Widget_Data;
2884
2885 struct _Widget_Data
2886 {
2887    Evas_Object *frm;
2888    Evas_Object *content;
2889 };
2890
2891 static void _del_hook(Evas_Object *obj);
2892 static void _theme_hook(Evas_Object *obj);
2893 static void _sizing_eval(Evas_Object *obj);
2894 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
2895 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
2896
2897 static const char *widtype2 = NULL;
2898
2899 static void
2900 _del_hook(Evas_Object *obj)
2901 {
2902    Widget_Data *wd = elm_widget_data_get(obj);
2903    if (!wd) return;
2904    free(wd);
2905 }
2906
2907 static void
2908 _theme_hook(Evas_Object *obj)
2909 {
2910    Widget_Data *wd = elm_widget_data_get(obj);
2911    _elm_theme_object_set(obj, wd->frm, "win", "inwin", elm_widget_style_get(obj));
2912    if (wd->content)
2913      edje_object_part_swallow(wd->frm, "elm.swallow.content", wd->content);
2914    _sizing_eval(obj);
2915 }
2916
2917 static Eina_Bool
2918 _elm_inwin_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
2919 {
2920    Widget_Data *wd = elm_widget_data_get(obj);
2921
2922    if (!wd)
2923      return EINA_FALSE;
2924
2925    /* Try Focus cycle in subitem */
2926    if (wd->content)
2927      {
2928         elm_widget_focus_next_get(wd->content, dir, next);
2929         if (*next)
2930           return EINA_TRUE;
2931      }
2932
2933    *next = (Evas_Object *)obj;
2934    return EINA_FALSE;
2935 }
2936
2937 static void
2938 _sizing_eval(Evas_Object *obj)
2939 {
2940    Widget_Data *wd = elm_widget_data_get(obj);
2941    Evas_Coord minw = -1, minh = -1;
2942
2943    evas_object_size_hint_min_get(wd->content, &minw, &minh);
2944    edje_object_size_min_calc(wd->frm, &minw, &minh);
2945    evas_object_size_hint_min_set(obj, minw, minh);
2946    evas_object_size_hint_max_set(obj, -1, -1);
2947 }
2948
2949 static void
2950 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
2951 {
2952    _sizing_eval(data);
2953 }
2954
2955 static void
2956 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
2957 {
2958    Widget_Data *wd = elm_widget_data_get(obj);
2959    Evas_Object *sub = event_info;
2960    if (sub == wd->content)
2961      {
2962         evas_object_event_callback_del_full
2963            (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
2964         wd->content = NULL;
2965         _sizing_eval(obj);
2966      }
2967 }
2968
2969 /**
2970  * @defgroup Inwin Inwin
2971  *
2972  * An inwin is a window inside a window that is useful for a quick popup.  It does not hover.
2973  */
2974 EAPI Evas_Object *
2975 elm_win_inwin_add(Evas_Object *obj)
2976 {
2977    Evas_Object *obj2;
2978    Widget_Data *wd;
2979    Elm_Win *win;
2980
2981    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2982    win = elm_widget_data_get(obj);
2983    if (!win) return NULL;
2984    wd = ELM_NEW(Widget_Data);
2985    obj2 = elm_widget_add(win->evas);
2986    elm_widget_type_set(obj2, "inwin");
2987    ELM_SET_WIDTYPE(widtype2, "inwin");
2988    elm_widget_sub_object_add(obj, obj2);
2989    evas_object_size_hint_weight_set(obj2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2990    evas_object_size_hint_align_set(obj2, EVAS_HINT_FILL, EVAS_HINT_FILL);
2991    elm_win_resize_object_add(obj, obj2);
2992
2993    elm_widget_data_set(obj2, wd);
2994    elm_widget_del_hook_set(obj2, _del_hook);
2995    elm_widget_theme_hook_set(obj2, _theme_hook);
2996    elm_widget_focus_next_hook_set(obj2, _elm_inwin_focus_next_hook);
2997    elm_widget_can_focus_set(obj2, EINA_TRUE);
2998    elm_widget_highlight_ignore_set(obj2, EINA_TRUE);
2999
3000    wd->frm = edje_object_add(win->evas);
3001    _elm_theme_object_set(obj, wd->frm, "win", "inwin", "default");
3002    elm_widget_resize_object_set(obj2, wd->frm);
3003
3004    evas_object_smart_callback_add(obj2, "sub-object-del", _sub_del, obj2);
3005
3006    _sizing_eval(obj2);
3007    return obj2;
3008 }
3009
3010 /**
3011  * Activates an inwin object
3012  *
3013  * @param obj The inwin to activate
3014  *
3015  * @ingroup Inwin
3016  */
3017 EAPI void
3018 elm_win_inwin_activate(Evas_Object *obj)
3019 {
3020    ELM_CHECK_WIDTYPE(obj, widtype2);
3021    Widget_Data *wd = elm_widget_data_get(obj);
3022    if (!wd) return;
3023    evas_object_raise(obj);
3024    evas_object_show(obj);
3025    edje_object_signal_emit(wd->frm, "elm,action,show", "elm");
3026    elm_object_focus(obj);
3027 }
3028
3029 /**
3030  * Set the content of an inwin object.
3031  *
3032  * Once the content object is set, a previously set one will be deleted.
3033  * If you want to keep that old content object, use the
3034  * elm_win_inwin_content_unset() function.
3035  *
3036  * @param obj The inwin object
3037  * @param content The object to set as content
3038  *
3039  * @ingroup Inwin
3040  */
3041 EAPI void
3042 elm_win_inwin_content_set(Evas_Object *obj, Evas_Object *content)
3043 {
3044    ELM_CHECK_WIDTYPE(obj, widtype2);
3045    Widget_Data *wd = elm_widget_data_get(obj);
3046    if (!wd) return;
3047    if (wd->content == content) return;
3048    if (wd->content) evas_object_del(wd->content);
3049    wd->content = content;
3050    if (content)
3051      {
3052         elm_widget_sub_object_add(obj, content);
3053         evas_object_event_callback_add(content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
3054                                        _changed_size_hints, obj);
3055         edje_object_part_swallow(wd->frm, "elm.swallow.content", content);
3056      }
3057    _sizing_eval(obj);
3058 }
3059
3060 /**
3061  * Get the content of an inwin object.
3062  *
3063  * Return the content object which is set for this widget.
3064  *
3065  * @param obj The inwin object
3066  * @return The content that is being used
3067  *
3068  * @ingroup Inwin
3069  */
3070 EAPI Evas_Object *
3071 elm_win_inwin_content_get(const Evas_Object *obj)
3072 {
3073    ELM_CHECK_WIDTYPE(obj, widtype2) NULL;
3074    Widget_Data *wd = elm_widget_data_get(obj);
3075    if (!wd) return NULL;
3076    return wd->content;
3077 }
3078
3079 /**
3080  * Unset the content of an inwin object.
3081  *
3082  * Unparent and return the content object which was set for this widget.
3083  *
3084  * @param obj The inwin object
3085  * @return The content that was being used
3086  *
3087  * @ingroup Inwin
3088  */
3089 EAPI Evas_Object *
3090 elm_win_inwin_content_unset(Evas_Object *obj)
3091 {
3092    ELM_CHECK_WIDTYPE(obj, widtype2) NULL;
3093    Widget_Data *wd = elm_widget_data_get(obj);
3094    if (!wd) return NULL;
3095    if (!wd->content) return NULL;
3096    Evas_Object *content = wd->content;
3097    elm_widget_sub_object_del(obj, wd->content);
3098    edje_object_part_unswallow(wd->frm, wd->content);
3099    wd->content = NULL;
3100    return content;
3101 }
3102
3103 /* windowing spcific calls - shall we do this differently? */
3104
3105 static Ecore_X_Window
3106 _elm_ee_win_get(const Evas_Object *obj)
3107 {
3108    if (!obj) return 0;
3109 #ifdef HAVE_ELEMENTARY_X
3110    Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
3111    if (ee) return (Ecore_X_Window)ecore_evas_window_get(ee);
3112 #endif
3113    return 0;
3114 }
3115
3116 /**
3117  * Get the Ecore_X_Window of an Evas_Object
3118  *
3119  * @param obj The object
3120  *
3121  * @return The Ecore_X_Window of @p obj
3122  *
3123  * @ingroup Win
3124  */
3125 EAPI Ecore_X_Window
3126 elm_win_xwindow_get(const Evas_Object *obj)
3127 {
3128    Ecore_X_Window xwin = 0;
3129    Elm_Win *win;
3130    const char *type;
3131
3132    if (!obj) return 0;
3133    type = elm_widget_type_get(obj);
3134    if (!type) return 0;
3135    if (type != widtype) return _elm_ee_win_get(obj);
3136 #ifdef HAVE_ELEMENTARY_X
3137    win = elm_widget_data_get(obj);
3138    if (!win) return xwin;
3139    if (win->xwin) return win->xwin;
3140    if (win->parent) return elm_win_xwindow_get(win->parent);
3141 #endif
3142    return xwin;
3143    win = NULL;
3144 }