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