Merge remote-tracking branch 'remotes/origin/upstream'
[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 <<<<<<< HEAD
22 =======
23    Elm_Win_Indicator_Mode indmode;
24    Elm_Win_Indicator_Opacity_Mode ind_o_mode;
25 >>>>>>> remotes/origin/upstream
26    struct {
27       const char *info;
28       Ecore_Timer *timer;
29       int repeat_count;
30       int shot_counter;
31    } shot;
32 <<<<<<< HEAD
33    Eina_Bool autodel : 1;
34    Eina_Bool constrain : 1;
35    Eina_Bool resizing : 1;
36 =======
37 >>>>>>> remotes/origin/upstream
38    int resize_location;
39    int *autodel_clear, rot;
40    int show_count;
41    struct {
42       int x, y;
43    } screen;
44 <<<<<<< HEAD
45
46 =======
47    struct 
48      {
49         Ecore_Evas *ee;
50         Evas *evas;
51         Evas_Object *obj, *hot_obj;
52         int hot_x, hot_y;
53      } pointer;
54 >>>>>>> remotes/origin/upstream
55    struct {
56       Evas_Object *top;
57
58       struct {
59          Evas_Object *target;
60          Eina_Bool visible : 1;
61          Eina_Bool handled : 1;
62       } cur, prev;
63
64       const char *style;
65       Ecore_Job *reconf_job;
66
67       Eina_Bool enabled : 1;
68       Eina_Bool changed_theme : 1;
69       Eina_Bool top_animate : 1;
70       Eina_Bool geometry_changed : 1;
71    } focus_highlight;
72 <<<<<<< HEAD
73 =======
74
75    Evas_Object *icon;
76    const char *title;
77    const char *icon_name;
78    const char *role;
79    
80    double aspect;
81    Eina_Bool urgent : 1;
82    Eina_Bool modal : 1;
83    Eina_Bool demand_attention : 1;
84    Eina_Bool autodel : 1;
85    Eina_Bool constrain : 1;
86    Eina_Bool resizing : 1;
87    Eina_Bool iconified : 1;
88    Eina_Bool withdrawn : 1;
89    Eina_Bool sticky : 1;
90    Eina_Bool fullscreen : 1;
91    Eina_Bool maximized : 1;
92    Eina_Bool skip_focus : 1;
93 >>>>>>> remotes/origin/upstream
94 };
95
96 static const char *widtype = NULL;
97 static void _elm_win_obj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
98 static void _elm_win_obj_callback_img_obj_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
99 static void _elm_win_obj_callback_parent_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
100 static void _elm_win_obj_intercept_move(void *data, Evas_Object *obj, Evas_Coord x, Evas_Coord y);
101 static void _elm_win_obj_intercept_show(void *data, Evas_Object *obj);
102 static void _elm_win_move(Ecore_Evas *ee);
103 static void _elm_win_resize(Ecore_Evas *ee);
104 static void _elm_win_delete_request(Ecore_Evas *ee);
105 static void _elm_win_resize_job(void *data);
106 #ifdef HAVE_ELEMENTARY_X
107 static void _elm_win_xwin_update(Elm_Win *win);
108 #endif
109 static void _elm_win_eval_subobjs(Evas_Object *obj);
110 static void _elm_win_subobj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
111 static void _elm_win_subobj_callback_changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
112 static void _elm_win_focus_highlight_init(Elm_Win *win);
113 static void _elm_win_focus_highlight_shutdown(Elm_Win *win);
114 static void _elm_win_focus_highlight_visible_set(Elm_Win *win, Eina_Bool visible);
115 static void _elm_win_focus_highlight_reconfigure_job_start(Elm_Win *win);
116 static void _elm_win_focus_highlight_reconfigure_job_stop(Elm_Win *win);
117 static void _elm_win_focus_highlight_anim_end(void *data, Evas_Object *obj, const char *emission, const char *source);
118 static void _elm_win_focus_highlight_reconfigure(Elm_Win *win);
119
120 static void _elm_win_frame_add(Elm_Win *win, const char *style);
121 static void _elm_win_frame_cb_move_start(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__);
122 static void _elm_win_frame_cb_resize_start(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source);
123 static void _elm_win_frame_cb_minimize(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__);
124 static void _elm_win_frame_cb_maximize(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__);
125 static void _elm_win_frame_cb_close(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__);
126
127 <<<<<<< HEAD
128 =======
129 //static void _elm_win_pointer_add(Elm_Win *win, const char *style);
130
131 >>>>>>> remotes/origin/upstream
132 static const char SIG_DELETE_REQUEST[] = "delete,request";
133 static const char SIG_FOCUS_OUT[] = "focus,out";
134 static const char SIG_FOCUS_IN[] = "focus,in";
135 static const char SIG_MOVED[] = "moved";
136 static const char SIG_THEME_CHANGED[] = "theme,changed";
137 <<<<<<< HEAD
138 =======
139 static const char SIG_WITHDRAWN[] = "withdrawn";
140 static const char SIG_ICONIFIED[] = "iconified";
141 static const char SIG_NORMAL[] = "normal";
142 static const char SIG_STICK[] = "stick";
143 static const char SIG_UNSTICK[] = "unstick";
144 static const char SIG_FULLSCREEN[] = "fullscreen";
145 static const char SIG_UNFULLSCREEN[] = "unfullscreen";
146 static const char SIG_MAXIMIZED[] = "maximized";
147 static const char SIG_UNMAXIMIZED[] = "unmaximized";
148 >>>>>>> remotes/origin/upstream
149
150 static const Evas_Smart_Cb_Description _signals[] = {
151    {SIG_DELETE_REQUEST, ""},
152    {SIG_FOCUS_OUT, ""},
153    {SIG_FOCUS_IN, ""},
154    {SIG_MOVED, ""},
155 <<<<<<< HEAD
156 =======
157    {SIG_WITHDRAWN, ""},
158    {SIG_ICONIFIED, ""},
159    {SIG_NORMAL, ""},
160    {SIG_STICK, ""},
161    {SIG_UNSTICK, ""},
162    {SIG_FULLSCREEN, ""},
163    {SIG_UNFULLSCREEN, ""},
164    {SIG_MAXIMIZED, ""},
165    {SIG_UNMAXIMIZED, ""},
166 >>>>>>> remotes/origin/upstream
167    {NULL, NULL}
168 };
169
170
171
172 Eina_List *_elm_win_list = NULL;
173 int _elm_win_deferred_free = 0;
174
175 // exmaple shot spec (wait 0.1 sec then save as my-window.png):
176 // ELM_ENGINE="shot:delay=0.1:file=my-window.png"
177
178 static double
179 _shot_delay_get(Elm_Win *win)
180 {
181    char *p, *pd;
182    char *d = strdup(win->shot.info);
183
184    if (!d) return 0.5;
185    for (p = (char *)win->shot.info; *p; p++)
186      {
187         if (!strncmp(p, "delay=", 6))
188           {
189              double v;
190
191              for (pd = d, p += 6; (*p) && (*p != ':'); p++, pd++)
192                {
193                   *pd = *p;
194                }
195              *pd = 0;
196              v = atof(d);
197              free(d);
198              return v;
199           }
200      }
201    free(d);
202    return 0.5;
203 }
204
205 static char *
206 _shot_file_get(Elm_Win *win)
207 {
208    char *p;
209    char *tmp = strdup(win->shot.info);
210    char *repname = NULL;
211
212    if (!tmp) return NULL;
213
214    for (p = (char *)win->shot.info; *p; p++)
215      {
216         if (!strncmp(p, "file=", 5))
217           {
218              strcpy(tmp, p + 5);
219              if (!win->shot.repeat_count) return tmp;
220              else
221                {
222                   char *dotptr = strrchr(tmp, '.');
223                   if (dotptr)
224                     {
225                        size_t size = sizeof(char)*(strlen(tmp) + 16);
226                        repname = malloc(size);
227                        strncpy(repname, tmp, dotptr - tmp);
228                        snprintf(repname + (dotptr - tmp), size - (dotptr - tmp), "%03i",
229                                win->shot.shot_counter + 1);
230                        strcat(repname, dotptr);
231                        free(tmp);
232                        return repname;
233                     }
234                }
235           }
236      }
237    free(tmp);
238    if (!win->shot.repeat_count) return strdup("out.png");
239
240    repname = malloc(sizeof(char) * 24);
241    snprintf(repname, sizeof(char) * 24, "out%03i.png", win->shot.shot_counter + 1);
242    return repname;
243 }
244
245 static int
246 _shot_repeat_count_get(Elm_Win *win)
247 {
248    char *p, *pd;
249    char *d = strdup(win->shot.info);
250
251    if (!d) return 0;
252    for (p = (char *)win->shot.info; *p; p++)
253      {
254         if (!strncmp(p, "repeat=", 7))
255           {
256              int v;
257
258              for (pd = d, p += 7; (*p) && (*p != ':'); p++, pd++)
259                {
260                   *pd = *p;
261                }
262              *pd = 0;
263              v = atoi(d);
264              if (v < 0) v = 0;
265              if (v > 1000) v = 999;
266              free(d);
267              return v;
268           }
269      }
270    free(d);
271    return 0;
272 }
273
274 static char *
275 _shot_key_get(Elm_Win *win __UNUSED__)
276 {
277    return NULL;
278 }
279
280 static char *
281 _shot_flags_get(Elm_Win *win __UNUSED__)
282 {
283    return NULL;
284 }
285
286 static void
287 _shot_do(Elm_Win *win)
288 {
289    Ecore_Evas *ee;
290    Evas_Object *o;
291    unsigned int *pixels;
292    int w, h;
293    char *file, *key, *flags;
294
295    ecore_evas_manual_render(win->ee);
296    pixels = (void *)ecore_evas_buffer_pixels_get(win->ee);
297    if (!pixels) return;
298    ecore_evas_geometry_get(win->ee, NULL, NULL, &w, &h);
299    if ((w < 1) || (h < 1)) return;
300    file = _shot_file_get(win);
301    if (!file) return;
302    key = _shot_key_get(win);
303    flags = _shot_flags_get(win);
304    ee = ecore_evas_buffer_new(1, 1);
305    o = evas_object_image_add(ecore_evas_get(ee));
306    evas_object_image_alpha_set(o, ecore_evas_alpha_get(win->ee));
307    evas_object_image_size_set(o, w, h);
308    evas_object_image_data_set(o, pixels);
309    if (!evas_object_image_save(o, file, key, flags))
310      {
311         ERR("Cannot save window to '%s' (key '%s', flags '%s')",
312             file, key, flags);
313      }
314    free(file);
315    if (key) free(key);
316    if (flags) free(flags);
317    ecore_evas_free(ee);
318    if (win->shot.repeat_count) win->shot.shot_counter++;
319 }
320
321 static Eina_Bool
322 _shot_delay(void *data)
323 {
324    Elm_Win *win = data;
325    _shot_do(win);
326    if (win->shot.repeat_count)
327      {
328         int remainshot = (win->shot.repeat_count - win->shot.shot_counter);
329         if (remainshot > 0) return EINA_TRUE;
330      }
331    win->shot.timer = NULL;
332    elm_exit();
333    return EINA_FALSE;
334 }
335
336 static void
337 _shot_init(Elm_Win *win)
338 {
339    if (!win->shot.info) return;
340    win->shot.repeat_count = _shot_repeat_count_get(win);
341    win->shot.shot_counter = 0;
342 }
343
344 static void
345 _shot_handle(Elm_Win *win)
346 {
347    if (!win->shot.info) return;
348    win->shot.timer = ecore_timer_add(_shot_delay_get(win), _shot_delay, win);
349 }
350
351 static void
352 _elm_win_move(Ecore_Evas *ee)
353 {
354    Evas_Object *obj = ecore_evas_object_associate_get(ee);
355    Elm_Win *win;
356    int x, y;
357
358    if (!obj) return;
359    win = elm_widget_data_get(obj);
360    if (!win) return;
361    ecore_evas_geometry_get(ee, &x, &y, NULL, NULL);
362    win->screen.x = x;
363    win->screen.y = y;
364    evas_object_smart_callback_call(win->win_obj, SIG_MOVED, NULL);
365 }
366
367 static void
368 _elm_win_resize(Ecore_Evas *ee)
369 {
370    Evas_Object *obj = ecore_evas_object_associate_get(ee);
371    Elm_Win *win;
372
373    if (!obj) return;
374    win = elm_widget_data_get(obj);
375    if (!win) return;
376    if (win->deferred_resize_job) ecore_job_del(win->deferred_resize_job);
377    win->deferred_resize_job = ecore_job_add(_elm_win_resize_job, win);
378 }
379
380 static void 
381 _elm_win_mouse_in(Ecore_Evas *ee)
382 {
383    Evas_Object *obj;
384    Elm_Win *win;
385
386    if (!(obj = ecore_evas_object_associate_get(ee))) return;
387    if (!(win = elm_widget_data_get(obj))) return;
388    if (win->resizing) win->resizing = EINA_FALSE;
389 }
390
391 static void
392 _elm_win_focus_in(Ecore_Evas *ee)
393 {
394    Evas_Object *obj = ecore_evas_object_associate_get(ee);
395    Elm_Win *win;
396
397    if (!obj) return;
398    win = elm_widget_data_get(obj);
399    if (!win) return;
400    _elm_widget_top_win_focused_set(win->win_obj, EINA_TRUE);
401 <<<<<<< HEAD
402    if (win->show_count == 1)
403 =======
404    if (!elm_widget_focus_order_get(obj))
405 >>>>>>> remotes/origin/upstream
406      {
407         elm_widget_focus_steal(win->win_obj);
408         win->show_count++;
409      }
410    else
411      elm_widget_focus_restore(win->win_obj);
412    evas_object_smart_callback_call(win->win_obj, SIG_FOCUS_IN, NULL);
413    win->focus_highlight.cur.visible = EINA_TRUE;
414    _elm_win_focus_highlight_reconfigure_job_start(win);
415    if (win->frame_obj)
416      {
417         edje_object_signal_emit(win->frame_obj, "elm,action,focus", "elm");
418      }
419    else if (win->img_obj)
420      {
421         /* do nothing */
422      }
423 }
424
425 static void
426 _elm_win_focus_out(Ecore_Evas *ee)
427 {
428    Evas_Object *obj = ecore_evas_object_associate_get(ee);
429    Elm_Win *win;
430
431    if (!obj) return;
432    win = elm_widget_data_get(obj);
433    if (!win) return;
434    elm_object_focus_set(win->win_obj, EINA_FALSE);
435    _elm_widget_top_win_focused_set(win->win_obj, EINA_FALSE);
436    evas_object_smart_callback_call(win->win_obj, SIG_FOCUS_OUT, NULL);
437    win->focus_highlight.cur.visible = EINA_FALSE;
438    _elm_win_focus_highlight_reconfigure_job_start(win);
439    if (win->frame_obj)
440      {
441         edje_object_signal_emit(win->frame_obj, "elm,action,unfocus", "elm");
442      }
443    else if (win->img_obj)
444      {
445         /* do nothing */
446      }
447 }
448
449 <<<<<<< HEAD
450 =======
451 static void 
452 _elm_win_state_change(Ecore_Evas *ee)
453 {
454    Evas_Object *obj;
455    Elm_Win *win;
456    Eina_Bool ch_withdrawn = EINA_FALSE;
457    Eina_Bool ch_sticky = EINA_FALSE;
458    Eina_Bool ch_iconified = EINA_FALSE;
459    Eina_Bool ch_fullscreen = EINA_FALSE;
460    Eina_Bool ch_maximized = EINA_FALSE;
461
462    if (!(obj = ecore_evas_object_associate_get(ee))) return;
463    
464    if (!(win = elm_widget_data_get(obj))) return;
465
466    if (win->withdrawn != ecore_evas_withdrawn_get(win->ee))
467      {
468         win->withdrawn = ecore_evas_withdrawn_get(win->ee);
469         ch_withdrawn = EINA_TRUE;
470      }
471    if (win->sticky != ecore_evas_sticky_get(win->ee))
472      {
473         win->sticky = ecore_evas_sticky_get(win->ee);
474         ch_sticky = EINA_TRUE;
475      }
476    if (win->iconified != ecore_evas_iconified_get(win->ee))
477      {
478         win->iconified = ecore_evas_iconified_get(win->ee);
479         ch_iconified = EINA_TRUE;
480      }
481    if (win->fullscreen != ecore_evas_fullscreen_get(win->ee))
482      {
483         win->fullscreen = ecore_evas_fullscreen_get(win->ee);
484         ch_fullscreen = EINA_TRUE;
485      }
486    if (win->maximized != ecore_evas_maximized_get(win->ee))
487      {
488         win->maximized = ecore_evas_maximized_get(win->ee);
489         ch_maximized = EINA_TRUE;
490      }
491    if ((ch_withdrawn) || (ch_iconified))
492      {
493         if (win->withdrawn)
494           evas_object_smart_callback_call(win->win_obj, SIG_WITHDRAWN, NULL);
495         else if (win->iconified)
496           evas_object_smart_callback_call(win->win_obj, SIG_ICONIFIED, NULL);
497         else
498           evas_object_smart_callback_call(win->win_obj, SIG_NORMAL, NULL);
499      }
500    if (ch_sticky)
501      {
502         if (win->sticky)
503           evas_object_smart_callback_call(win->win_obj, SIG_STICK, NULL);
504         else
505           evas_object_smart_callback_call(win->win_obj, SIG_UNSTICK, NULL);
506      }
507    if (ch_fullscreen)
508      {
509         if (win->fullscreen)
510           evas_object_smart_callback_call(win->win_obj, SIG_FULLSCREEN, NULL);
511         else
512           evas_object_smart_callback_call(win->win_obj, SIG_UNFULLSCREEN, NULL);
513      }
514    if (ch_maximized)
515      {
516         if (win->maximized)
517           evas_object_smart_callback_call(win->win_obj, SIG_MAXIMIZED, NULL);
518         else
519           evas_object_smart_callback_call(win->win_obj, SIG_UNMAXIMIZED, NULL);
520      }
521 }
522
523 >>>>>>> remotes/origin/upstream
524 static Eina_Bool
525 _elm_win_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
526 {
527    Elm_Win *wd = elm_widget_data_get(obj);
528    const Eina_List *items;
529    void *(*list_data_get) (const Eina_List *list);
530
531    if (!wd)
532      return EINA_FALSE;
533
534    /* Focus chain */
535    if (wd->subobjs)
536      {
537         if (!(items = elm_widget_focus_custom_chain_get(obj)))
538           {
539              items = wd->subobjs;
540              if (!items)
541                return EINA_FALSE;
542           }
543         list_data_get = eina_list_data_get;
544
545         elm_widget_focus_list_next_get(obj, items, list_data_get, dir, next);
546
547         if (*next)
548           return EINA_TRUE;
549      }
550
551    *next = (Evas_Object *)obj;
552    return EINA_FALSE;
553 }
554
555 static void
556 _elm_win_on_focus_hook(void *data __UNUSED__, Evas_Object *obj)
557 {
558    Elm_Win *win = elm_widget_data_get(obj);
559    if (!win) return;
560
561    if (win->img_obj)
562       evas_object_focus_set(win->img_obj, elm_widget_focus_get(obj));
563    else
564       evas_object_focus_set(obj, elm_widget_focus_get(obj));
565 }
566
567 static Eina_Bool
568 _elm_win_event_cb(Evas_Object *obj, Evas_Object *src __UNUSED__, Evas_Callback_Type type, void *event_info)
569 {
570    if (type == EVAS_CALLBACK_KEY_DOWN)
571      {
572         Evas_Event_Key_Down *ev = event_info;
573         if (!strcmp(ev->keyname, "Tab"))
574           {
575              if (evas_key_modifier_is_set(ev->modifiers, "Shift"))
576                elm_widget_focus_cycle(obj, ELM_FOCUS_PREVIOUS);
577              else
578                elm_widget_focus_cycle(obj, ELM_FOCUS_NEXT);
579              ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
580              return EINA_TRUE;
581           }
582         else if ((!strcmp(ev->keyname, "Left")) ||
583                  (!strcmp(ev->keyname, "KP_Left")))
584           {
585              //TODO : woohyun jung
586           }
587         else if ((!strcmp(ev->keyname, "Right")) ||
588                  (!strcmp(ev->keyname, "KP_Right")))
589           {
590              //TODO : woohyun jung
591           }
592         else if ((!strcmp(ev->keyname, "Up")) ||
593                  (!strcmp(ev->keyname, "KP_Up")))
594           {
595              //TODO : woohyun jung
596           }
597         else if ((!strcmp(ev->keyname, "Down")) ||
598                  (!strcmp(ev->keyname, "KP_Down")))
599           {
600              //TODO : woohyun jung
601           }
602      }
603
604    return EINA_FALSE;
605 }
606
607 static void
608 _deferred_ecore_evas_free(void *data)
609 {
610    ecore_evas_free(data);
611    _elm_win_deferred_free--;
612 }
613
614 static void
615 _elm_win_obj_callback_show(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
616 {
617    Elm_Win *win = data;
618
619    if (!win->show_count) win->show_count++;
620    if (win->shot.info) _shot_handle(win);
621 }
622
623 static void
624 _elm_win_obj_callback_hide(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
625 {
626    Elm_Win *win = data;
627
628    if (win->frame_obj)
629      {
630         evas_object_hide(win->frame_obj);
631      }
632    else if (win->img_obj)
633      {
634         evas_object_hide(win->img_obj);
635      }
636 <<<<<<< HEAD
637 =======
638    if (win->pointer.obj)
639      {
640         evas_object_hide(win->pointer.obj);
641         ecore_evas_hide(win->pointer.ee);
642      }
643 >>>>>>> remotes/origin/upstream
644 }
645
646 static void
647 _elm_win_obj_callback_del(void *data, Evas *e, Evas_Object *obj, void *event_info __UNUSED__)
648 {
649    Elm_Win *win = data;
650    Evas_Object *child;
651
652    if (win->parent)
653      {
654         evas_object_event_callback_del_full(win->parent, EVAS_CALLBACK_DEL,
655                                             _elm_win_obj_callback_parent_del, win);
656         win->parent = NULL;
657      }
658    if (win->autodel_clear) *(win->autodel_clear) = -1;
659    _elm_win_list = eina_list_remove(_elm_win_list, win->win_obj);
660    while (win->subobjs) elm_win_resize_object_del(obj, win->subobjs->data);
661    if (win->ee)
662      {
663         ecore_evas_callback_delete_request_set(win->ee, NULL);
664         ecore_evas_callback_resize_set(win->ee, NULL);
665      }
666    if (win->deferred_resize_job) ecore_job_del(win->deferred_resize_job);
667    if (win->deferred_child_eval_job) ecore_job_del(win->deferred_child_eval_job);
668    if (win->shot.info) eina_stringshare_del(win->shot.info);
669    if (win->shot.timer) ecore_timer_del(win->shot.timer);
670    evas_object_event_callback_del_full(win->win_obj, EVAS_CALLBACK_DEL,
671                                        _elm_win_obj_callback_del, win);
672    while (((child = evas_object_bottom_get(win->evas))) &&
673           (child != obj))
674      {
675         evas_object_del(child);
676      }
677    while (((child = evas_object_top_get(win->evas))) &&
678           (child != obj))
679      {
680         evas_object_del(child);
681      }
682 #ifdef HAVE_ELEMENTARY_X
683    if (win->client_message_handler)
684      ecore_event_handler_del(win->client_message_handler);
685 #endif
686    // FIXME: Why are we flushing edje on every window destroy ??
687    //   edje_file_cache_flush();
688    //   edje_collection_cache_flush();
689    //   evas_image_cache_flush(win->evas);
690    //   evas_font_cache_flush(win->evas);
691    // FIXME: we are in the del handler for the object and delete the canvas
692    // that lives under it from the handler... nasty. deferring doesn't help either
693
694    if (win->img_obj)
695      {
696         win->img_obj = NULL;
697      }
698    else
699      {
700         if (win->ee)
701           {
702              ecore_job_add(_deferred_ecore_evas_free, win->ee);
703              _elm_win_deferred_free++;
704           }
705      }
706
707    _elm_win_focus_highlight_shutdown(win);
708    eina_stringshare_del(win->focus_highlight.style);
709
710 <<<<<<< HEAD
711 =======
712    if (win->title) eina_stringshare_del(win->title);
713    if (win->icon_name) eina_stringshare_del(win->icon_name);
714    if (win->role) eina_stringshare_del(win->role);
715    if (win->icon) evas_object_del(win->icon);
716    
717 >>>>>>> remotes/origin/upstream
718    free(win);
719
720    if ((!_elm_win_list) &&
721        (elm_policy_get(ELM_POLICY_QUIT) == ELM_POLICY_QUIT_LAST_WINDOW_CLOSED))
722      {
723         edje_file_cache_flush();
724         edje_collection_cache_flush();
725         evas_image_cache_flush(e);
726         evas_font_cache_flush(e);
727         elm_exit();
728      }
729 }
730
731 static void
732 _elm_win_obj_callback_img_obj_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
733 {
734    Elm_Win *win = data;
735    if (!win->img_obj) return;
736    evas_object_event_callback_del_full
737       (win->img_obj, EVAS_CALLBACK_DEL, _elm_win_obj_callback_img_obj_del, win);
738    evas_object_del(win->img_obj);
739 }
740
741 static void
742 _elm_win_obj_callback_parent_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
743 {
744    Elm_Win *win = data;
745    if (obj == win->parent) win->parent = NULL;
746 }
747
748 static void
749 _elm_win_obj_intercept_move(void *data, Evas_Object *obj, Evas_Coord x, Evas_Coord y)
750 {
751    Elm_Win *win = data;
752
753    if (win->img_obj)
754      {
755         if ((x != win->screen.x) || (y != win->screen.y))
756           {
757              win->screen.x = x;
758              win->screen.y = y;
759              evas_object_smart_callback_call(win->win_obj, SIG_MOVED, NULL);
760           }
761      }
762    else
763      {
764         evas_object_move(obj, x, y);
765      }
766 }
767
768 static void
769 _elm_win_obj_intercept_show(void *data, Evas_Object *obj)
770 {
771    Elm_Win *win = data;
772    // this is called to make sure all smart containers have calculated their
773    // sizes BEFORE we show the window to make sure it initially appears at
774    // our desired size (ie min size is known first)
775    evas_smart_objects_calculate(evas_object_evas_get(obj));
776    if (win->frame_obj)
777      {
778         evas_object_show(win->frame_obj);
779      }
780    else if (win->img_obj)
781      {
782         evas_object_show(win->img_obj);
783      }
784 <<<<<<< HEAD
785 =======
786    if (win->pointer.obj)
787      {
788         ecore_evas_show(win->pointer.ee);
789         evas_object_show(win->pointer.obj);
790         /* ecore_evas_wayland_pointer_set(win->pointer.ee, 10, 10); */
791      }
792 >>>>>>> remotes/origin/upstream
793    evas_object_show(obj);
794 }
795
796 static void
797 _elm_win_obj_callback_move(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
798 {
799    Elm_Win *win = data;
800
801    if (ecore_evas_override_get(win->ee))
802      {
803         Evas_Coord x, y;
804
805         evas_object_geometry_get(obj, &x, &y, NULL, NULL);
806         win->screen.x = x;
807         win->screen.y = y;
808         evas_object_smart_callback_call(win->win_obj, SIG_MOVED, NULL);
809      }
810    if (win->frame_obj)
811      {
812         Evas_Coord x, y;
813
814         evas_object_geometry_get(obj, &x, &y, NULL, NULL);
815         win->screen.x = x;
816         win->screen.y = y;
817      }
818    else if (win->img_obj)
819      {
820         Evas_Coord x, y;
821
822         evas_object_geometry_get(obj, &x, &y, NULL, NULL);
823         win->screen.x = x;
824         win->screen.y = y;
825 //        evas_object_move(win->img_obj, x, y);
826      }
827 }
828
829 static void
830 _elm_win_obj_callback_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
831 {
832    Elm_Win *win = data;
833
834    if (win->frame_obj)
835      {
836      }
837    else if (win->img_obj)
838      {
839         Evas_Coord w = 1, h = 1;
840
841         evas_object_geometry_get(obj, NULL, NULL, &w, &h);
842         if (win->constrain)
843           {
844              int sw, sh;
845              ecore_evas_screen_geometry_get(win->ee, NULL, NULL, &sw, &sh);
846              w = MIN(w, sw);
847              h = MIN(h, sh);
848           }
849         if (w < 1) w = 1;
850         if (h < 1) h = 1;
851         evas_object_image_size_set(win->img_obj, w, h);
852      }
853 }
854
855 static void
856 _elm_win_delete_request(Ecore_Evas *ee)
857 {
858    Evas_Object *obj = ecore_evas_object_associate_get(ee);
859    Elm_Win *win;
860    if (strcmp(elm_widget_type_get(obj), "win")) return;
861
862    win = elm_widget_data_get(obj);
863    if (!win) return;
864    int autodel = win->autodel;
865    win->autodel_clear = &autodel;
866    evas_object_ref(win->win_obj);
867    evas_object_smart_callback_call(win->win_obj, SIG_DELETE_REQUEST, NULL);
868    // FIXME: if above callback deletes - then the below will be invalid
869    if (autodel) evas_object_del(win->win_obj);
870    else win->autodel_clear = NULL;
871    evas_object_unref(win->win_obj);
872 }
873
874 static void
875 _elm_win_resize_job(void *data)
876 {
877    Elm_Win *win = data;
878    const Eina_List *l;
879    Evas_Object *obj;
880    int w, h;
881
882    win->deferred_resize_job = NULL;
883    ecore_evas_request_geometry_get(win->ee, NULL, NULL, &w, &h);
884    if (win->constrain)
885      {
886         int sw, sh;
887         ecore_evas_screen_geometry_get(win->ee, NULL, NULL, &sw, &sh);
888         w = MIN(w, sw);
889         h = MIN(h, sh);
890      }
891    if (win->frame_obj)
892      {
893         evas_object_resize(win->frame_obj, w, h);
894      }
895    else if (win->img_obj)
896      {
897      }
898    evas_object_resize(win->win_obj, w, h);
899    EINA_LIST_FOREACH(win->subobjs, l, obj)
900      {
901         evas_object_move(obj, 0, 0);
902         evas_object_resize(obj, w, h);
903      }
904 }
905
906 #ifdef HAVE_ELEMENTARY_X
907 static void
908 _elm_win_xwindow_get(Elm_Win *win)
909 {
910    win->xwin = 0;
911
912 <<<<<<< HEAD
913 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
914 =======
915 #define ENGINE_COMPARE(name) (!strcmp(_elm_preferred_engine, name))
916 >>>>>>> remotes/origin/upstream
917    if (ENGINE_COMPARE(ELM_SOFTWARE_X11))
918      {
919        if (win->ee) win->xwin = ecore_evas_software_x11_window_get(win->ee);
920      }
921    else if (ENGINE_COMPARE(ELM_SOFTWARE_X11) ||
922             ENGINE_COMPARE(ELM_SOFTWARE_FB) ||
923             ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE) ||
924             ENGINE_COMPARE(ELM_SOFTWARE_SDL) ||
925             ENGINE_COMPARE(ELM_SOFTWARE_16_SDL) ||
926             ENGINE_COMPARE(ELM_OPENGL_SDL) ||
927             ENGINE_COMPARE(ELM_OPENGL_COCOA))
928      {
929      }
930    else if (ENGINE_COMPARE(ELM_SOFTWARE_16_X11))
931      {
932         if (win->ee) win->xwin = ecore_evas_software_x11_16_window_get(win->ee);
933      }
934    else if (ENGINE_COMPARE(ELM_SOFTWARE_8_X11))
935      {
936         if (win->ee) win->xwin = ecore_evas_software_x11_8_window_get(win->ee);
937      }
938 /* killed
939    else if (ENGINE_COMPARE(ELM_XRENDER_X11))
940      {
941         if (win->ee) win->xwin = ecore_evas_xrender_x11_window_get(win->ee);
942      }
943  */
944    else if (ENGINE_COMPARE(ELM_OPENGL_X11))
945      {
946         if (win->ee) win->xwin = ecore_evas_gl_x11_window_get(win->ee);
947      }
948    else if (ENGINE_COMPARE(ELM_SOFTWARE_WIN32))
949      {
950         if (win->ee) win->xwin = (long)ecore_evas_win32_window_get(win->ee);
951      }
952 #undef ENGINE_COMPARE
953 }
954 #endif
955
956 #ifdef HAVE_ELEMENTARY_X
957 static void
958 _elm_win_xwin_update(Elm_Win *win)
959 {
960 <<<<<<< HEAD
961 =======
962    const char *s;
963    
964 >>>>>>> remotes/origin/upstream
965    _elm_win_xwindow_get(win);
966    if (win->parent)
967      {
968         Elm_Win *win2;
969
970         win2 = elm_widget_data_get(win->parent);
971         if (win2)
972           {
973              if (win->xwin)
974                ecore_x_icccm_transient_for_set(win->xwin, win2->xwin);
975           }
976      }
977
978    if (!win->xwin) return; /* nothing more to do */
979
980 <<<<<<< HEAD
981 =======
982    s = win->title;
983    if (!s) s = _elm_appname;
984    if (!s) s = "";
985    if (win->icon_name) s = win->icon_name;
986    ecore_x_icccm_icon_name_set(win->xwin, s);
987    ecore_x_netwm_icon_name_set(win->xwin, s);
988
989    s = win->role;
990    if (s) ecore_x_icccm_window_role_set(win->xwin, s);
991    
992    // set window icon
993    if (win->icon)
994      {
995         void *data;
996
997         data = evas_object_image_data_get(win->icon, EINA_FALSE);
998         if (data)
999           {
1000              Ecore_X_Icon ic;
1001              int w = 0, h = 0, stride, x, y;
1002              unsigned char *p;
1003              unsigned int *p2;
1004              
1005              evas_object_image_size_get(win->icon, &w, &h);
1006              stride = evas_object_image_stride_get(win->icon);
1007              if ((w > 0) && (h > 0) && 
1008                  (stride >= (int)(w * sizeof(unsigned int))))
1009                {
1010                   ic.width = w;
1011                   ic.height = h;
1012                   ic.data = malloc(w * h * sizeof(unsigned int));
1013                   
1014                   if (ic.data)
1015                     {
1016                        p = (unsigned char *)data;
1017                        p2 = (unsigned int *)ic.data;
1018                        for (y = 0; y < h; y++)
1019                          {
1020                             for (x = 0; x < w; x++)
1021                               {
1022                                  *p2 = *((unsigned int *)p);
1023                                  p += sizeof(unsigned int);
1024                                  p2++;
1025                               }
1026                             p += (stride - (w * sizeof(unsigned int))); 
1027                          }
1028                        ecore_x_netwm_icons_set(win->xwin, &ic, 1);
1029                        free(ic.data);
1030                     }
1031                }
1032              evas_object_image_data_set(win->icon, data);
1033           }
1034      }
1035    
1036 >>>>>>> remotes/origin/upstream
1037    switch (win->type)
1038      {
1039       case ELM_WIN_BASIC:
1040          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_NORMAL);
1041          break;
1042       case ELM_WIN_DIALOG_BASIC:
1043          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DIALOG);
1044          break;
1045       case ELM_WIN_DESKTOP:
1046          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DESKTOP);
1047          break;
1048       case ELM_WIN_DOCK:
1049          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DOCK);
1050          break;
1051       case ELM_WIN_TOOLBAR:
1052          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_TOOLBAR);
1053          break;
1054       case ELM_WIN_MENU:
1055          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_MENU);
1056          break;
1057       case ELM_WIN_UTILITY:
1058          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_UTILITY);
1059          break;
1060       case ELM_WIN_SPLASH:
1061          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_SPLASH);
1062          break;
1063       case ELM_WIN_DROPDOWN_MENU:
1064          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DROPDOWN_MENU);
1065          break;
1066       case ELM_WIN_POPUP_MENU:
1067          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_POPUP_MENU);
1068          break;
1069       case ELM_WIN_TOOLTIP:
1070          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_TOOLTIP);
1071          break;
1072       case ELM_WIN_NOTIFICATION:
1073          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_NOTIFICATION);
1074          break;
1075       case ELM_WIN_COMBO:
1076          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_COMBO);
1077          break;
1078       case ELM_WIN_DND:
1079          ecore_x_netwm_window_type_set(win->xwin, ECORE_X_WINDOW_TYPE_DND);
1080          break;
1081       default:
1082          break;
1083      }
1084    ecore_x_e_virtual_keyboard_state_set
1085       (win->xwin, (Ecore_X_Virtual_Keyboard_State)win->kbdmode);
1086 <<<<<<< HEAD
1087 =======
1088    if (win->indmode == ELM_WIN_INDICATOR_SHOW)
1089      ecore_x_e_illume_indicator_state_set
1090      (win->xwin, ECORE_X_ILLUME_INDICATOR_STATE_ON);
1091    else if (win->indmode == ELM_WIN_INDICATOR_HIDE)
1092      ecore_x_e_illume_indicator_state_set
1093      (win->xwin, ECORE_X_ILLUME_INDICATOR_STATE_OFF);
1094 >>>>>>> remotes/origin/upstream
1095 }
1096 #endif
1097
1098 static void
1099 _elm_win_eval_subobjs(Evas_Object *obj)
1100 {
1101    const Eina_List *l;
1102    const Evas_Object *child;
1103
1104    Elm_Win *win = elm_widget_data_get(obj);
1105    Evas_Coord w, h, minw = -1, minh = -1, maxw = -1, maxh = -1;
1106    int xx = 1, xy = 1;
1107    double wx, wy;
1108
1109    EINA_LIST_FOREACH(win->subobjs, l, child)
1110      {
1111         evas_object_size_hint_weight_get(child, &wx, &wy);
1112         if (wx == 0.0) xx = 0;
1113         if (wy == 0.0) xy = 0;
1114
1115         evas_object_size_hint_min_get(child, &w, &h);
1116         if (w < 1) w = 1;
1117         if (h < 1) h = 1;
1118         if (w > minw) minw = w;
1119         if (h > minh) minh = h;
1120
1121         evas_object_size_hint_max_get(child, &w, &h);
1122         if (w < 1) w = -1;
1123         if (h < 1) h = -1;
1124         if (maxw == -1) maxw = w;
1125         else if ((w > 0) && (w < maxw)) maxw = w;
1126         if (maxh == -1) maxh = h;
1127         else if ((h > 0) && (h < maxh)) maxh = h;
1128      }
1129    if (!xx) maxw = minw;
1130    else maxw = 32767;
1131    if (!xy) maxh = minh;
1132    else maxh = 32767;
1133    evas_object_size_hint_min_set(obj, minw, minh);
1134    evas_object_size_hint_max_set(obj, maxw, maxh);
1135    evas_object_geometry_get(obj, NULL, NULL, &w, &h);
1136    if (w < minw) w = minw;
1137    if (h < minh) h = minh;
1138    if ((maxw >= 0) && (w > maxw)) w = maxw;
1139    if ((maxh >= 0) && (h > maxh)) h = maxh;
1140    evas_object_resize(obj, w, h);
1141 }
1142
1143 static void
1144 _elm_win_subobj_callback_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1145 {
1146    Elm_Win *win = elm_widget_data_get(data);
1147    win->subobjs = eina_list_remove(win->subobjs, obj);
1148    _elm_win_eval_subobjs(win->win_obj);
1149 }
1150
1151 static void
1152 _elm_win_subobj_callback_changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1153 {
1154    _elm_win_eval_subobjs(data);
1155 }
1156
1157 void
1158 _elm_win_shutdown(void)
1159 {
1160    while (_elm_win_list)
1161      evas_object_del(_elm_win_list->data);
1162 }
1163
1164 void
1165 _elm_win_rescale(Elm_Theme *th, Eina_Bool use_theme)
1166 {
1167    const Eina_List *l;
1168    Evas_Object *obj;
1169
1170    if (!use_theme)
1171      {
1172         EINA_LIST_FOREACH(_elm_win_list, l, obj)
1173           elm_widget_theme(obj);
1174      }
1175    else
1176      {
1177         EINA_LIST_FOREACH(_elm_win_list, l, obj)
1178           elm_widget_theme_specific(obj, th, EINA_FALSE);
1179      }
1180 }
1181
1182 void
1183 _elm_win_translate(void)
1184 {
1185    const Eina_List *l;
1186    Evas_Object *obj;
1187
1188    EINA_LIST_FOREACH(_elm_win_list, l, obj)
1189       elm_widget_translate(obj);
1190 }
1191
1192 #ifdef HAVE_ELEMENTARY_X
1193 static Eina_Bool
1194 _elm_win_client_message(void *data, int type __UNUSED__, void *event)
1195 {
1196    Elm_Win *win = data;
1197    Ecore_X_Event_Client_Message *e = event;
1198
1199    if (e->format != 32) return ECORE_CALLBACK_PASS_ON;
1200    if (e->message_type == ECORE_X_ATOM_E_COMP_FLUSH)
1201      {
1202         if ((unsigned)e->data.l[0] == win->xwin)
1203           {
1204              Evas *evas = evas_object_evas_get(win->win_obj);
1205              if (evas)
1206                {
1207                   edje_file_cache_flush();
1208                   edje_collection_cache_flush();
1209                   evas_image_cache_flush(evas);
1210                   evas_font_cache_flush(evas);
1211                }
1212           }
1213      }
1214    else if (e->message_type == ECORE_X_ATOM_E_COMP_DUMP)
1215      {
1216         if ((unsigned)e->data.l[0] == win->xwin)
1217           {
1218              Evas *evas = evas_object_evas_get(win->win_obj);
1219              if (evas)
1220                {
1221                   edje_file_cache_flush();
1222                   edje_collection_cache_flush();
1223                   evas_image_cache_flush(evas);
1224                   evas_font_cache_flush(evas);
1225                   evas_render_dump(evas);
1226                }
1227           }
1228      }
1229    return ECORE_CALLBACK_PASS_ON;
1230 }
1231 #endif
1232
1233 static void
1234 _elm_win_focus_target_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1235 {
1236    Elm_Win *win = data;
1237
1238    win->focus_highlight.geometry_changed = EINA_TRUE;
1239    _elm_win_focus_highlight_reconfigure_job_start(win);
1240 }
1241
1242 static void
1243 _elm_win_focus_target_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1244 {
1245    Elm_Win *win = data;
1246
1247    win->focus_highlight.geometry_changed = EINA_TRUE;
1248    _elm_win_focus_highlight_reconfigure_job_start(win);
1249 }
1250
1251 static void
1252 _elm_win_focus_target_del(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
1253 {
1254    Elm_Win *win = data;
1255
1256    win->focus_highlight.cur.target = NULL;
1257
1258    _elm_win_focus_highlight_reconfigure_job_start(win);
1259 }
1260
1261 static void
1262 _elm_win_focus_target_callbacks_add(Elm_Win *win)
1263 {
1264    Evas_Object *obj = win->focus_highlight.cur.target;
1265
1266    evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE,
1267                                   _elm_win_focus_target_move, win);
1268    evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE,
1269                                   _elm_win_focus_target_resize, win);
1270    evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
1271                                   _elm_win_focus_target_del, win);
1272 }
1273
1274 static void
1275 _elm_win_focus_target_callbacks_del(Elm_Win *win)
1276 {
1277    Evas_Object *obj = win->focus_highlight.cur.target;
1278
1279    evas_object_event_callback_del_full(obj, EVAS_CALLBACK_MOVE,
1280                                        _elm_win_focus_target_move, win);
1281    evas_object_event_callback_del_full(obj, EVAS_CALLBACK_RESIZE,
1282                                        _elm_win_focus_target_resize, win);
1283    evas_object_event_callback_del_full(obj, EVAS_CALLBACK_DEL,
1284                                        _elm_win_focus_target_del, win);
1285 }
1286
1287 static Evas_Object *
1288 _elm_win_focus_target_get(Evas_Object *obj)
1289 {
1290    Evas_Object *o = obj;
1291
1292    do
1293      {
1294         if (elm_widget_is(o))
1295           {
1296              if (!elm_widget_highlight_ignore_get(o))
1297                break;
1298              o = elm_widget_parent_get(o);
1299              if (!o)
1300                o = evas_object_smart_parent_get(o);
1301           }
1302         else
1303           {
1304              o = elm_widget_parent_widget_get(o);
1305              if (!o)
1306                o = evas_object_smart_parent_get(o);
1307           }
1308      }
1309    while (o);
1310
1311    return o;
1312 }
1313
1314 static void
1315 _elm_win_object_focus_in(void *data, Evas *e __UNUSED__, void *event_info)
1316 {
1317    Evas_Object *obj = event_info, *target;
1318    Elm_Win *win = data;
1319
1320    if (win->focus_highlight.cur.target == obj)
1321      return;
1322
1323    target = _elm_win_focus_target_get(obj);
1324    win->focus_highlight.cur.target = target;
1325    if (elm_widget_highlight_in_theme_get(target))
1326      win->focus_highlight.cur.handled = EINA_TRUE;
1327    else
1328      _elm_win_focus_target_callbacks_add(win);
1329
1330    _elm_win_focus_highlight_reconfigure_job_start(win);
1331 }
1332
1333 static void
1334 _elm_win_object_focus_out(void *data, Evas *e __UNUSED__, void *event_info __UNUSED__)
1335 {
1336    Elm_Win *win = data;
1337
1338    if (!win->focus_highlight.cur.target)
1339      return;
1340
1341    if (!win->focus_highlight.cur.handled)
1342      _elm_win_focus_target_callbacks_del(win);
1343    win->focus_highlight.cur.target = NULL;
1344    win->focus_highlight.cur.handled = EINA_FALSE;
1345
1346    _elm_win_focus_highlight_reconfigure_job_start(win);
1347 }
1348
1349 static void
1350 _elm_win_focus_highlight_hide(void *data __UNUSED__, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
1351 {
1352    evas_object_hide(obj);
1353 }
1354
1355 static void
1356 _elm_win_focus_highlight_init(Elm_Win *win)
1357 {
1358    evas_event_callback_add(win->evas, EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
1359                            _elm_win_object_focus_in, win);
1360    evas_event_callback_add(win->evas,
1361                            EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
1362                            _elm_win_object_focus_out, win);
1363
1364    win->focus_highlight.cur.target = evas_focus_get(win->evas);
1365
1366    win->focus_highlight.top = edje_object_add(win->evas);
1367    win->focus_highlight.changed_theme = EINA_TRUE;
1368    edje_object_signal_callback_add(win->focus_highlight.top,
1369                                    "elm,action,focus,hide,end", "",
1370                                    _elm_win_focus_highlight_hide, NULL);
1371    edje_object_signal_callback_add(win->focus_highlight.top,
1372                                    "elm,action,focus,anim,end", "",
1373                                    _elm_win_focus_highlight_anim_end, win);
1374    _elm_win_focus_highlight_reconfigure_job_start(win);
1375 }
1376
1377 static void
1378 _elm_win_focus_highlight_shutdown(Elm_Win *win)
1379 {
1380    _elm_win_focus_highlight_reconfigure_job_stop(win);
1381    if (win->focus_highlight.cur.target)
1382      {
1383         _elm_win_focus_target_callbacks_del(win);
1384         win->focus_highlight.cur.target = NULL;
1385      }
1386    if (win->focus_highlight.top)
1387      {
1388         evas_object_del(win->focus_highlight.top);
1389         win->focus_highlight.top = NULL;
1390      }
1391
1392    evas_event_callback_del_full(win->evas,
1393                                 EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_IN,
1394                                 _elm_win_object_focus_in, win);
1395    evas_event_callback_del_full(win->evas,
1396                                 EVAS_CALLBACK_CANVAS_OBJECT_FOCUS_OUT,
1397                                 _elm_win_object_focus_out, win);
1398 }
1399
1400 static void
1401 _elm_win_focus_highlight_visible_set(Elm_Win *win, Eina_Bool visible)
1402 {
1403    Evas_Object *top;
1404
1405    top = win->focus_highlight.top;
1406    if (visible)
1407      {
1408         if (top)
1409           {
1410              evas_object_show(top);
1411              edje_object_signal_emit(top, "elm,action,focus,show", "elm");
1412           }
1413      }
1414    else
1415      {
1416         if (top)
1417           edje_object_signal_emit(top, "elm,action,focus,hide", "elm");
1418      }
1419 }
1420
1421 static void
1422 _elm_win_focus_highlight_reconfigure_job(void *data)
1423 {
1424    _elm_win_focus_highlight_reconfigure((Elm_Win *)data);
1425 }
1426
1427 static void
1428 _elm_win_focus_highlight_reconfigure_job_start(Elm_Win *win)
1429 {
1430    if (win->focus_highlight.reconf_job)
1431      ecore_job_del(win->focus_highlight.reconf_job);
1432    win->focus_highlight.reconf_job = ecore_job_add(
1433       _elm_win_focus_highlight_reconfigure_job, win);
1434 }
1435
1436 static void
1437 _elm_win_focus_highlight_reconfigure_job_stop(Elm_Win *win)
1438 {
1439    if (win->focus_highlight.reconf_job)
1440      ecore_job_del(win->focus_highlight.reconf_job);
1441    win->focus_highlight.reconf_job = NULL;
1442 }
1443
1444 static void
1445 _elm_win_focus_highlight_simple_setup(Elm_Win *win, Evas_Object *obj)
1446 {
1447    Evas_Object *clip, *target = win->focus_highlight.cur.target;
1448    Evas_Coord x, y, w, h;
1449
1450    clip = evas_object_clip_get(target);
1451    evas_object_geometry_get(target, &x, &y, &w, &h);
1452
1453    evas_object_move(obj, x, y);
1454    evas_object_resize(obj, w, h);
1455    evas_object_clip_set(obj, clip);
1456 }
1457
1458 static void
1459 _elm_win_focus_highlight_anim_setup(Elm_Win *win, Evas_Object *obj)
1460 {
1461    Evas_Coord tx, ty, tw, th;
1462    Evas_Coord w, h, px, py, pw, ph;
1463    Edje_Message_Int_Set *m;
1464    Evas_Object *previous = win->focus_highlight.prev.target;
1465    Evas_Object *target = win->focus_highlight.cur.target;
1466
1467    evas_object_geometry_get(win->win_obj, NULL, NULL, &w, &h);
1468    evas_object_geometry_get(target, &tx, &ty, &tw, &th);
1469    evas_object_geometry_get(previous, &px, &py, &pw, &ph);
1470    evas_object_move(obj, 0, 0);
1471    evas_object_resize(obj, tw, th);
1472    evas_object_clip_unset(obj);
1473
1474    m = alloca(sizeof(*m) + (sizeof(int) * 8));
1475    m->count = 8;
1476    m->val[0] = px;
1477    m->val[1] = py;
1478    m->val[2] = pw;
1479    m->val[3] = ph;
1480    m->val[4] = tx;
1481    m->val[5] = ty;
1482    m->val[6] = tw;
1483    m->val[7] = th;
1484    edje_object_message_send(obj, EDJE_MESSAGE_INT_SET, 1, m);
1485 }
1486
1487 static void
1488 _elm_win_focus_highlight_anim_end(void *data, Evas_Object *obj, const char *emission __UNUSED__, const char *source __UNUSED__)
1489 {
1490    Elm_Win *win = data;
1491    _elm_win_focus_highlight_simple_setup(win, obj);
1492 }
1493
1494 static void
1495 _elm_win_focus_highlight_reconfigure(Elm_Win *win)
1496 {
1497    Evas_Object *target = win->focus_highlight.cur.target;
1498    Evas_Object *previous = win->focus_highlight.prev.target;
1499    Evas_Object *top = win->focus_highlight.top;
1500    Eina_Bool visible_changed;
1501    Eina_Bool common_visible;
1502    const char *sig = NULL;
1503
1504    _elm_win_focus_highlight_reconfigure_job_stop(win);
1505
1506    visible_changed = (win->focus_highlight.cur.visible !=
1507                       win->focus_highlight.prev.visible);
1508
1509    if ((target == previous) && (!visible_changed) &&
1510        (!win->focus_highlight.geometry_changed))
1511      return;
1512
1513    if ((previous) && (win->focus_highlight.prev.handled))
1514      elm_widget_signal_emit(previous, "elm,action,focus_highlight,hide", "elm");
1515
1516    if (!target)
1517      common_visible = EINA_FALSE;
1518    else if (win->focus_highlight.cur.handled)
1519      {
1520         common_visible = EINA_FALSE;
1521         if (win->focus_highlight.cur.visible)
1522           sig = "elm,action,focus_highlight,show";
1523         else
1524           sig = "elm,action,focus_highlight,hide";
1525      }
1526    else
1527      common_visible = win->focus_highlight.cur.visible;
1528
1529    _elm_win_focus_highlight_visible_set(win, common_visible);
1530    if (sig)
1531      elm_widget_signal_emit(target, sig, "elm");
1532
1533    if ((!target) || (!common_visible) || (win->focus_highlight.cur.handled))
1534      goto the_end;
1535
1536    if (win->focus_highlight.changed_theme)
1537      {
1538         const char *str;
1539         if (win->focus_highlight.style)
1540           str = win->focus_highlight.style;
1541         else
1542           str = "default";
1543         _elm_theme_object_set(win->win_obj, top, "focus_highlight", "top",
1544                               str);
1545         win->focus_highlight.changed_theme = EINA_FALSE;
1546
1547         if (_elm_config->focus_highlight_animate)
1548           {
1549              str = edje_object_data_get(win->focus_highlight.top, "animate");
1550              win->focus_highlight.top_animate = ((str) && (!strcmp(str, "on")));
1551           }
1552      }
1553
1554    if ((win->focus_highlight.top_animate) && (previous) &&
1555        (!win->focus_highlight.prev.handled))
1556      _elm_win_focus_highlight_anim_setup(win, top);
1557    else
1558      _elm_win_focus_highlight_simple_setup(win, top);
1559    evas_object_raise(top);
1560
1561 the_end:
1562    win->focus_highlight.geometry_changed = EINA_FALSE;
1563    win->focus_highlight.prev = win->focus_highlight.cur;
1564 }
1565
1566 static void 
1567 _elm_win_frame_add(Elm_Win *win, const char *style)
1568 {
1569    evas_output_framespace_set(win->evas, 0, 22, 0, 26);
1570
1571    win->frame_obj = edje_object_add(win->evas);
1572    _elm_theme_set(NULL, win->frame_obj, "border", "base", style);
1573    evas_object_is_frame_object_set(win->frame_obj, EINA_TRUE);
1574    evas_object_move(win->frame_obj, 0, 0);
1575    evas_object_resize(win->frame_obj, 1, 1);
1576
1577    edje_object_signal_callback_add(win->frame_obj, "elm,action,move,start", 
1578                                    "elm", _elm_win_frame_cb_move_start, win);
1579    edje_object_signal_callback_add(win->frame_obj, "elm,action,resize,start", 
1580                                    "*", _elm_win_frame_cb_resize_start, win);
1581    edje_object_signal_callback_add(win->frame_obj, "elm,action,minimize", 
1582                                    "elm", _elm_win_frame_cb_minimize, win);
1583    edje_object_signal_callback_add(win->frame_obj, "elm,action,maximize", 
1584                                    "elm", _elm_win_frame_cb_maximize, win);
1585    edje_object_signal_callback_add(win->frame_obj, "elm,action,close", 
1586                                    "elm", _elm_win_frame_cb_close, win);
1587 }
1588
1589 static void 
1590 _elm_win_frame_cb_move_start(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__)
1591 {
1592    Elm_Win *win;
1593
1594    if (!(win = data)) return;
1595    /* FIXME: Change mouse pointer */
1596
1597    /* NB: 0,0 are dummy values. Wayland handles the move by itself */
1598    ecore_evas_move(win->ee, 0, 0);
1599 }
1600
1601 static void 
1602 _elm_win_frame_cb_resize_start(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source)
1603 {
1604    Elm_Win *win;
1605
1606    if (!(win = data)) return;
1607    if (win->resizing) return;
1608    win->resizing = EINA_TRUE;
1609
1610    /* FIXME: Change mouse pointer */
1611
1612    if (!strcmp(source, "elm.event.resize.t"))
1613      win->resize_location = 1;
1614    else if (!strcmp(source, "elm.event.resize.b"))
1615      win->resize_location = 2;
1616    else if (!strcmp(source, "elm.event.resize.l"))
1617      win->resize_location = 4;
1618    else if (!strcmp(source, "elm.event.resize.r"))
1619      win->resize_location = 8;
1620    else if (!strcmp(source, "elm.event.resize.tl"))
1621      win->resize_location = 5;
1622    else if (!strcmp(source, "elm.event.resize.tr"))
1623      win->resize_location = 9;
1624    else if (!strcmp(source, "elm.event.resize.bl"))
1625      win->resize_location = 6;
1626    else if (!strcmp(source, "elm.event.resize.br"))
1627      win->resize_location = 10;
1628    else
1629      win->resize_location = 0;
1630
1631 <<<<<<< HEAD
1632    /* FIXME: Change to more generic wayland resize function */
1633 =======
1634 >>>>>>> remotes/origin/upstream
1635    if (win->resize_location > 0)
1636      ecore_evas_wayland_resize(win->ee, win->resize_location);
1637 }
1638
1639 static void 
1640 _elm_win_frame_cb_minimize(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__)
1641 {
1642    Elm_Win *win;
1643
1644    if (!(win = data)) return;
1645 <<<<<<< HEAD
1646 =======
1647    win->iconified = EINA_TRUE;
1648 >>>>>>> remotes/origin/upstream
1649    ecore_evas_iconified_set(win->ee, EINA_TRUE);
1650 }
1651
1652 static void 
1653 _elm_win_frame_cb_maximize(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__)
1654 {
1655    Elm_Win *win;
1656
1657    if (!(win = data)) return;
1658 <<<<<<< HEAD
1659    ecore_evas_maximized_set(win->ee, EINA_TRUE);
1660 =======
1661    if (win->maximized) win->maximized = EINA_FALSE;
1662    else win->maximized = EINA_TRUE;
1663    ecore_evas_maximized_set(win->ee, win->maximized);
1664 >>>>>>> remotes/origin/upstream
1665 }
1666
1667 static void 
1668 _elm_win_frame_cb_close(void *data, Evas_Object *obj __UNUSED__, const char *sig __UNUSED__, const char *source __UNUSED__)
1669 {
1670    Elm_Win *win;
1671
1672    if (!(win = data)) return;
1673    evas_object_del(win->win_obj);
1674 }
1675
1676 <<<<<<< HEAD
1677 =======
1678 /*
1679 static void 
1680 _elm_win_pointer_add(Elm_Win *win, const char *style)
1681 {
1682    int mw, mh;
1683
1684    return;
1685
1686    win->pointer.ee = ecore_evas_wayland_shm_new(NULL, 0, 0, 0, 32, 32, 0);
1687    ecore_evas_resize(win->pointer.ee, 32, 32);
1688
1689    win->pointer.evas = ecore_evas_get(win->ee);
1690
1691    win->pointer.obj = edje_object_add(win->pointer.evas);
1692    _elm_theme_set(NULL, win->pointer.obj, "pointer", "base", style);
1693    edje_object_size_min_calc(win->pointer.obj, &mw, &mh);
1694    evas_object_move(win->pointer.obj, 0, 0);
1695    evas_object_resize(win->pointer.obj, 32, 32);
1696    evas_object_show(win->pointer.obj);
1697 }
1698 */
1699
1700 >>>>>>> remotes/origin/upstream
1701 #ifdef ELM_DEBUG
1702 static void
1703 _debug_key_down(void *data __UNUSED__, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
1704 {
1705    Evas_Event_Key_Down *ev = event_info;
1706
1707    if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD)
1708      return;
1709
1710    if ((strcmp(ev->keyname, "F12")) ||
1711        (!evas_key_modifier_is_set(ev->modifiers, "Control")))
1712      return;
1713
1714    printf("Tree graph generated.\n");
1715    elm_object_tree_dot_dump(obj, "./dump.dot");
1716 }
1717 #endif
1718
1719 static void
1720 _win_img_hide(void        *data,
1721               Evas        *e __UNUSED__,
1722               Evas_Object *obj __UNUSED__,
1723               void        *event_info __UNUSED__)
1724 {
1725    Elm_Win *win = data;
1726
1727    elm_widget_focus_hide_handle(win->win_obj);
1728 }
1729
1730 static void
1731 _win_img_mouse_up(void        *data,
1732                   Evas        *e __UNUSED__,
1733                   Evas_Object *obj __UNUSED__,
1734                   void        *event_info)
1735 {
1736    Elm_Win *win = data;
1737    Evas_Event_Mouse_Up *ev = event_info;
1738    if (!(ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD))
1739       elm_widget_focus_mouse_up_handle(win->win_obj);
1740 }
1741
1742 static void
1743 _win_img_focus_in(void        *data,
1744                   Evas        *e __UNUSED__,
1745                   Evas_Object *obj __UNUSED__,
1746                   void        *event_info __UNUSED__)
1747 {
1748    Elm_Win *win = data;
1749    elm_widget_focus_steal(win->win_obj);
1750 }
1751
1752 static void
1753 _win_img_focus_out(void        *data,
1754                    Evas        *e __UNUSED__,
1755                    Evas_Object *obj __UNUSED__,
1756                    void        *event_info __UNUSED__)
1757 {
1758    Elm_Win *win = data;
1759    elm_widget_focused_object_clear(win->win_obj);
1760 }
1761
1762 static void
1763 _win_inlined_image_set(Elm_Win *win)
1764 {
1765    evas_object_image_alpha_set(win->img_obj, EINA_FALSE);
1766    evas_object_image_filled_set(win->img_obj, EINA_TRUE);
1767    evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_DEL,
1768                                   _elm_win_obj_callback_img_obj_del, win);
1769
1770    evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_HIDE,
1771                                   _win_img_hide, win);
1772    evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_MOUSE_UP,
1773                                   _win_img_mouse_up, win);
1774    evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_FOCUS_IN,
1775                                   _win_img_focus_in, win);
1776    evas_object_event_callback_add(win->img_obj, EVAS_CALLBACK_FOCUS_OUT,
1777                                   _win_img_focus_out, win);
1778 }
1779
1780 static void
1781 _subobj_del(Elm_Win *win, Evas_Object *obj, Evas_Object *subobj)
1782 {
1783    evas_object_event_callback_del_full(subobj,
1784                                        EVAS_CALLBACK_CHANGED_SIZE_HINTS,
1785                                        _elm_win_subobj_callback_changed_size_hints,
1786                                        obj);
1787    evas_object_event_callback_del_full(subobj, EVAS_CALLBACK_DEL,
1788                                        _elm_win_subobj_callback_del, obj);
1789    win->subobjs = eina_list_remove(win->subobjs, subobj);
1790    _elm_win_eval_subobjs(obj);
1791 }
1792
1793 <<<<<<< HEAD
1794 =======
1795 static void
1796 _elm_win_obj_icon_callback_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1797 {
1798    Elm_Win *win = data;
1799    if (win->icon == obj) win->icon = NULL;
1800 }
1801
1802 >>>>>>> remotes/origin/upstream
1803 EAPI Evas_Object *
1804 elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type)
1805 {
1806    Elm_Win *win;
1807    const Eina_List *l;
1808    const char *fontpath;
1809
1810    win = ELM_NEW(Elm_Win);
1811
1812 #define FALLBACK_TRY(engine)                                            \
1813    if (!win->ee)                                                        \
1814       do {                                                              \
1815          CRITICAL(engine " engine creation failed. Trying default.");   \
1816          win->ee = ecore_evas_new(NULL, 0, 0, 1, 1, NULL);              \
1817          if (win->ee)                                                   \
1818 <<<<<<< HEAD
1819             elm_engine_set(ecore_evas_engine_name_get(win->ee));        \
1820    } while (0)
1821 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
1822
1823 =======
1824             elm_config_preferred_engine_set(ecore_evas_engine_name_get(win->ee)); \
1825    } while (0)
1826 #define ENGINE_COMPARE(name) (_elm_preferred_engine && !strcmp(_elm_preferred_engine, name))
1827
1828    win->kbdmode = ELM_WIN_KEYBOARD_UNKNOWN;
1829    win->indmode = ELM_WIN_INDICATOR_UNKNOWN;
1830    
1831 >>>>>>> remotes/origin/upstream
1832    switch (type)
1833      {
1834       case ELM_WIN_INLINED_IMAGE:
1835         if (!parent) break;
1836         {
1837            Evas *e = evas_object_evas_get(parent);
1838            Ecore_Evas *ee;
1839            if (!e) break;
1840            ee = ecore_evas_ecore_evas_get(e);
1841            if (!ee) break;
1842            win->img_obj = ecore_evas_object_image_new(ee);
1843            if (!win->img_obj) break;
1844            win->ee = ecore_evas_object_ecore_evas_get(win->img_obj);
1845            if (win->ee)
1846              {
1847                 _win_inlined_image_set(win);
1848                 break;
1849              }
1850            evas_object_del(win->img_obj);
1851            win->img_obj = NULL;
1852         }
1853         break;
1854
1855       case ELM_WIN_SOCKET_IMAGE:
1856         win->ee = ecore_evas_extn_socket_new(1, 1);
1857         break;
1858
1859       default:
1860         if (ENGINE_COMPARE(ELM_SOFTWARE_X11))
1861           {
1862              win->ee = ecore_evas_software_x11_new(NULL, 0, 0, 0, 1, 1);
1863 #ifdef HAVE_ELEMENTARY_X
1864              win->client_message_handler = ecore_event_handler_add
1865                 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1866 #endif
1867              FALLBACK_TRY("Sofware X11");
1868           }
1869         else if (ENGINE_COMPARE(ELM_SOFTWARE_FB))
1870           {
1871              win->ee = ecore_evas_fb_new(NULL, 0, 1, 1);
1872              FALLBACK_TRY("Sofware FB");
1873           }
1874         else if (ENGINE_COMPARE(ELM_SOFTWARE_DIRECTFB))
1875           {
1876              win->ee = ecore_evas_directfb_new(NULL, 1, 0, 0, 1, 1);
1877              FALLBACK_TRY("Sofware DirectFB");
1878           }
1879         else if (ENGINE_COMPARE(ELM_SOFTWARE_16_X11))
1880           {
1881              win->ee = ecore_evas_software_x11_16_new(NULL, 0, 0, 0, 1, 1);
1882              FALLBACK_TRY("Sofware-16");
1883 #ifdef HAVE_ELEMENTARY_X
1884              win->client_message_handler = ecore_event_handler_add
1885                 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1886 #endif
1887      }
1888         else if (ENGINE_COMPARE(ELM_SOFTWARE_8_X11))
1889           {
1890              win->ee = ecore_evas_software_x11_8_new(NULL, 0, 0, 0, 1, 1);
1891              FALLBACK_TRY("Sofware-8");
1892 #ifdef HAVE_ELEMENTARY_X
1893              win->client_message_handler = ecore_event_handler_add
1894                 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1895 #endif
1896           }
1897 /* killed
1898         else if (ENGINE_COMPARE(ELM_XRENDER_X11))
1899           {
1900              win->ee = ecore_evas_xrender_x11_new(NULL, 0, 0, 0, 1, 1);
1901              FALLBACK_TRY("XRender");
1902 #ifdef HAVE_ELEMENTARY_X
1903              win->client_message_handler = ecore_event_handler_add
1904                 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1905 #endif
1906           }
1907  */
1908         else if (ENGINE_COMPARE(ELM_OPENGL_X11))
1909           {
1910              int opt[10];
1911              int opt_i = 0;
1912
1913              if (_elm_config->vsync)
1914                {
1915                   opt[opt_i] = ECORE_EVAS_GL_X11_OPT_VSYNC;
1916                   opt_i++;
1917                   opt[opt_i] = 1;
1918                   opt_i++;
1919                }
1920              if (opt_i > 0)
1921                 win->ee = ecore_evas_gl_x11_options_new(NULL, 0, 0, 0, 1, 1, opt);
1922              else
1923                 win->ee = ecore_evas_gl_x11_new(NULL, 0, 0, 0, 1, 1);
1924              FALLBACK_TRY("OpenGL");
1925 #ifdef HAVE_ELEMENTARY_X
1926              win->client_message_handler = ecore_event_handler_add
1927                 (ECORE_X_EVENT_CLIENT_MESSAGE, _elm_win_client_message, win);
1928 #endif
1929           }
1930         else if (ENGINE_COMPARE(ELM_SOFTWARE_WIN32))
1931           {
1932              win->ee = ecore_evas_software_gdi_new(NULL, 0, 0, 1, 1);
1933              FALLBACK_TRY("Sofware Win32");
1934           }
1935         else if (ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE))
1936           {
1937              win->ee = ecore_evas_software_wince_gdi_new(NULL, 0, 0, 1, 1);
1938              FALLBACK_TRY("Sofware-16-WinCE");
1939           }
1940         else if (ENGINE_COMPARE(ELM_SOFTWARE_PSL1GHT))
1941           {
1942              win->ee = ecore_evas_psl1ght_new(NULL, 1, 1);
1943              FALLBACK_TRY("PSL1GHT");
1944           }
1945         else if (ENGINE_COMPARE(ELM_SOFTWARE_SDL))
1946           {
1947              win->ee = ecore_evas_sdl_new(NULL, 0, 0, 0, 0, 0, 1);
1948              FALLBACK_TRY("Sofware SDL");
1949           }
1950         else if (ENGINE_COMPARE(ELM_SOFTWARE_16_SDL))
1951           {
1952              win->ee = ecore_evas_sdl16_new(NULL, 0, 0, 0, 0, 0, 1);
1953              FALLBACK_TRY("Sofware-16-SDL");
1954           }
1955         else if (ENGINE_COMPARE(ELM_OPENGL_SDL))
1956           {
1957              win->ee = ecore_evas_gl_sdl_new(NULL, 1, 1, 0, 0);
1958              FALLBACK_TRY("OpenGL SDL");
1959           }
1960         else if (ENGINE_COMPARE(ELM_OPENGL_COCOA))
1961           {
1962              win->ee = ecore_evas_cocoa_new(NULL, 1, 1, 0, 0);
1963              FALLBACK_TRY("OpenGL Cocoa");
1964           }
1965         else if (ENGINE_COMPARE(ELM_BUFFER))
1966           {
1967              win->ee = ecore_evas_buffer_new(1, 1);
1968           }
1969         else if (ENGINE_COMPARE(ELM_EWS))
1970           {
1971              win->ee = ecore_evas_ews_new(0, 0, 1, 1);
1972           }
1973         else if (ENGINE_COMPARE(ELM_WAYLAND_SHM)) 
1974           {
1975              win->ee = ecore_evas_wayland_shm_new(NULL, 0, 0, 0, 1, 1, 0);
1976 <<<<<<< HEAD
1977              win->evas = ecore_evas_get(win->ee);
1978
1979              _elm_win_frame_add(win, "default");
1980 =======
1981              win->evas = ecore_evas_get(win->ee);
1982
1983              _elm_win_frame_add(win, "default");
1984 //             _elm_win_pointer_add(win, "default");
1985 >>>>>>> remotes/origin/upstream
1986           }
1987         else if (ENGINE_COMPARE(ELM_WAYLAND_EGL)) 
1988           {
1989              win->ee = ecore_evas_wayland_egl_new(NULL, 0, 0, 0, 1, 1, 0);
1990 <<<<<<< HEAD
1991              win->evas = ecore_evas_get(win->ee);
1992
1993              _elm_win_frame_add(win, "default");
1994           }
1995         else if (!strncmp(_elm_config->engine, "shot:", 5))
1996           {
1997              win->ee = ecore_evas_buffer_new(1, 1);
1998              ecore_evas_manual_render_set(win->ee, EINA_TRUE);
1999              win->shot.info = eina_stringshare_add(_elm_config->engine + 5);
2000 =======
2001              win->evas = ecore_evas_get(win->ee);
2002
2003              _elm_win_frame_add(win, "default");
2004 //             _elm_win_pointer_add(win, "default");
2005           }
2006         else if (!strncmp(_elm_preferred_engine, "shot:", 5))
2007           {
2008              win->ee = ecore_evas_buffer_new(1, 1);
2009              ecore_evas_manual_render_set(win->ee, EINA_TRUE);
2010              win->shot.info = eina_stringshare_add(_elm_preferred_engine + 5);
2011 >>>>>>> remotes/origin/upstream
2012              _shot_init(win);
2013           }
2014 #undef FALLBACK_TRY
2015         break;
2016      }
2017
2018    if (!win->ee)
2019      {
2020         ERR("Cannot create window.");
2021         free(win);
2022         return NULL;
2023      }
2024 #ifdef HAVE_ELEMENTARY_X
2025    _elm_win_xwindow_get(win);
2026 #endif
2027    if ((_elm_config->bgpixmap) && (!_elm_config->compositing))
2028      ecore_evas_avoid_damage_set(win->ee, ECORE_EVAS_AVOID_DAMAGE_EXPOSE);
2029    // bg pixmap done by x - has other issues like can be redrawn by x before it
2030    // is filled/ready by app
2031    //     ecore_evas_avoid_damage_set(win->ee, ECORE_EVAS_AVOID_DAMAGE_BUILT_IN);
2032
2033    win->type = type;
2034    win->parent = parent;
2035    if (win->parent)
2036      evas_object_event_callback_add(win->parent, EVAS_CALLBACK_DEL,
2037                                     _elm_win_obj_callback_parent_del, win);
2038
2039    win->evas = ecore_evas_get(win->ee);
2040    win->win_obj = elm_widget_add(win->evas);
2041    elm_widget_type_set(win->win_obj, "win");
2042    ELM_SET_WIDTYPE(widtype, "win");
2043    elm_widget_data_set(win->win_obj, win);
2044    elm_widget_event_hook_set(win->win_obj, _elm_win_event_cb);
2045    elm_widget_on_focus_hook_set(win->win_obj, _elm_win_on_focus_hook, NULL);
2046    elm_widget_can_focus_set(win->win_obj, EINA_TRUE);
2047    elm_widget_highlight_ignore_set(win->win_obj, EINA_TRUE);
2048    elm_widget_focus_next_hook_set(win->win_obj, _elm_win_focus_next_hook);
2049    evas_object_color_set(win->win_obj, 0, 0, 0, 0);
2050    evas_object_move(win->win_obj, 0, 0);
2051    evas_object_resize(win->win_obj, 1, 1);
2052    evas_object_layer_set(win->win_obj, 50);
2053    evas_object_pass_events_set(win->win_obj, EINA_TRUE);
2054
2055    if (win->frame_obj) 
2056      {
2057 <<<<<<< HEAD
2058 //        evas_object_clip_set(win->win_obj, win->frame_obj);
2059 =======
2060         evas_object_clip_set(win->win_obj, win->frame_obj);
2061 >>>>>>> remotes/origin/upstream
2062         evas_object_stack_below(win->frame_obj, win->win_obj);
2063      }
2064
2065    if (type == ELM_WIN_INLINED_IMAGE)
2066      elm_widget_parent2_set(win->win_obj, parent);
2067    ecore_evas_object_associate(win->ee, win->win_obj,
2068                                ECORE_EVAS_OBJECT_ASSOCIATE_BASE |
2069                                ECORE_EVAS_OBJECT_ASSOCIATE_STACK |
2070                                ECORE_EVAS_OBJECT_ASSOCIATE_LAYER);
2071    evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_SHOW,
2072                                   _elm_win_obj_callback_show, win);
2073    evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_HIDE,
2074                                   _elm_win_obj_callback_hide, win);
2075    evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_DEL,
2076                                   _elm_win_obj_callback_del, win);
2077    evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_MOVE,
2078                                   _elm_win_obj_callback_move, win);
2079    evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_RESIZE,
2080                                   _elm_win_obj_callback_resize, win);
2081    if (win->img_obj)
2082      evas_object_intercept_move_callback_add(win->win_obj,
2083                                              _elm_win_obj_intercept_move, win);
2084    evas_object_intercept_show_callback_add(win->win_obj,
2085                                            _elm_win_obj_intercept_show, win);
2086
2087    evas_object_smart_callback_add(win->win_obj, "sub-object-del", (Evas_Smart_Cb)_subobj_del, win);
2088    ecore_evas_name_class_set(win->ee, name, _elm_appname);
2089    ecore_evas_callback_delete_request_set(win->ee, _elm_win_delete_request);
2090    ecore_evas_callback_resize_set(win->ee, _elm_win_resize);
2091    ecore_evas_callback_mouse_in_set(win->ee, _elm_win_mouse_in);
2092    ecore_evas_callback_focus_in_set(win->ee, _elm_win_focus_in);
2093    ecore_evas_callback_focus_out_set(win->ee, _elm_win_focus_out);
2094    ecore_evas_callback_move_set(win->ee, _elm_win_move);
2095 <<<<<<< HEAD
2096 =======
2097    ecore_evas_callback_state_change_set(win->ee, _elm_win_state_change);
2098 >>>>>>> remotes/origin/upstream
2099    evas_image_cache_set(win->evas, (_elm_config->image_cache * 1024));
2100    evas_font_cache_set(win->evas, (_elm_config->font_cache * 1024));
2101    EINA_LIST_FOREACH(_elm_config->font_dirs, l, fontpath)
2102      evas_font_path_append(win->evas, fontpath);
2103    if (!_elm_config->font_hinting)
2104      evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_NONE);
2105    else if (_elm_config->font_hinting == 1)
2106      evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_AUTO);
2107    else if (_elm_config->font_hinting == 2)
2108      evas_font_hinting_set(win->evas, EVAS_FONT_HINTING_BYTECODE);
2109
2110 #ifdef HAVE_ELEMENTARY_X
2111    _elm_win_xwin_update(win);
2112 #endif
2113
2114    _elm_win_list = eina_list_append(_elm_win_list, win->win_obj);
2115
2116    if (ENGINE_COMPARE(ELM_SOFTWARE_FB))
2117      {
2118         ecore_evas_fullscreen_set(win->ee, 1);
2119      }
2120 #undef ENGINE_COMPARE
2121
2122    if (_elm_config->focus_highlight_enable)
2123      elm_win_focus_highlight_enabled_set(win->win_obj, EINA_TRUE);
2124
2125 #ifdef ELM_DEBUG
2126    Evas_Modifier_Mask mask = evas_key_modifier_mask_get(win->evas, "Control");
2127    evas_object_event_callback_add(win->win_obj, EVAS_CALLBACK_KEY_DOWN,
2128                                   _debug_key_down, win);
2129
2130    Eina_Bool ret = evas_object_key_grab(win->win_obj, "F12", mask, 0,
2131                                         EINA_TRUE);
2132    printf("Ctrl+F12 key combination exclusive for dot tree generation\n");
2133 #endif
2134
2135    evas_object_smart_callbacks_descriptions_set(win->win_obj, _signals);
2136
2137    return win->win_obj;
2138 }
2139
2140 EAPI Evas_Object *
2141 elm_win_util_standard_add(const char *name, const char *title)
2142 {
2143    Evas_Object *win, *bg;
2144
2145    win = elm_win_add(NULL, name, ELM_WIN_BASIC);
2146    if (!win) return NULL;
2147    elm_win_title_set(win, title);
2148    bg = elm_bg_add(win);
2149    if (!bg)
2150      {
2151         evas_object_del(win);
2152         return NULL;
2153      }
2154    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2155    elm_win_resize_object_add(win, bg);
2156    evas_object_show(bg);
2157    return win;
2158 }
2159
2160 EAPI void
2161 elm_win_resize_object_add(Evas_Object *obj, Evas_Object *subobj)
2162 {
2163    Evas_Coord w, h;
2164    Elm_Win *win;
2165    ELM_CHECK_WIDTYPE(obj, widtype);
2166    win = elm_widget_data_get(obj);
2167    if (!win) return;
2168    if (eina_list_data_find(win->subobjs, subobj)) return;
2169    win->subobjs = eina_list_append(win->subobjs, subobj);
2170    elm_widget_sub_object_add(obj, subobj);
2171    evas_object_event_callback_add(subobj, EVAS_CALLBACK_DEL,
2172                                   _elm_win_subobj_callback_del, obj);
2173    evas_object_event_callback_add(subobj, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
2174                                   _elm_win_subobj_callback_changed_size_hints,
2175                                   obj);
2176    evas_object_geometry_get(obj, NULL, NULL, &w, &h);
2177    evas_object_move(subobj, 0, 0);
2178    evas_object_resize(subobj, w, h);
2179    _elm_win_eval_subobjs(obj);
2180 }
2181
2182 EAPI void
2183 elm_win_resize_object_del(Evas_Object *obj, Evas_Object *subobj)
2184 {
2185    Elm_Win *win;
2186    ELM_CHECK_WIDTYPE(obj, widtype);
2187    win = elm_widget_data_get(obj);
2188    if (!win) return;
2189    evas_object_event_callback_del_full(subobj,
2190                                        EVAS_CALLBACK_CHANGED_SIZE_HINTS,
2191                                        _elm_win_subobj_callback_changed_size_hints,
2192                                        obj);
2193    evas_object_event_callback_del_full(subobj, EVAS_CALLBACK_DEL,
2194                                        _elm_win_subobj_callback_del, obj);
2195    win->subobjs = eina_list_remove(win->subobjs, subobj);
2196    elm_widget_sub_object_del(obj, subobj);
2197    _elm_win_eval_subobjs(obj);
2198 }
2199
2200 EAPI void
2201 elm_win_title_set(Evas_Object *obj, const char *title)
2202 {
2203    Elm_Win *win;
2204    ELM_CHECK_WIDTYPE(obj, widtype);
2205    win = elm_widget_data_get(obj);
2206 <<<<<<< HEAD
2207    if (!win) return;
2208    ecore_evas_title_set(win->ee, title);
2209    if (win->frame_obj)
2210      edje_object_part_text_set(win->frame_obj, "elm.text.title", title);
2211 =======
2212    if (!win || !title) return;
2213    eina_stringshare_replace(&(win->title), title);
2214    ecore_evas_title_set(win->ee, win->title);
2215    if (win->frame_obj)
2216      edje_object_part_text_set(win->frame_obj, "elm.text.title", win->title);
2217 >>>>>>> remotes/origin/upstream
2218 }
2219
2220 EAPI const char *
2221 elm_win_title_get(const Evas_Object *obj)
2222 {
2223    Elm_Win *win;
2224    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2225    win = elm_widget_data_get(obj);
2226    if (!win) return NULL;
2227 <<<<<<< HEAD
2228    return ecore_evas_title_get(win->ee);
2229 =======
2230    return win->title;
2231 }
2232
2233 EAPI void
2234 elm_win_icon_name_set(Evas_Object *obj, const char *icon_name)
2235 {
2236    Elm_Win *win;
2237    ELM_CHECK_WIDTYPE(obj, widtype);
2238    win = elm_widget_data_get(obj);
2239    if (!win || !icon_name) return;
2240    eina_stringshare_replace(&(win->icon_name), icon_name);
2241 #ifdef HAVE_ELEMENTARY_X
2242    _elm_win_xwin_update(win);
2243 #endif
2244 }
2245
2246 EAPI const char *
2247 elm_win_icon_name_get(const Evas_Object *obj)
2248 {
2249    Elm_Win *win;
2250    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2251    win = elm_widget_data_get(obj);
2252    if (!win) return NULL;
2253    return win->icon_name;
2254 }
2255
2256 EAPI void
2257 elm_win_role_set(Evas_Object *obj, const char *role)
2258 {
2259    Elm_Win *win;
2260    ELM_CHECK_WIDTYPE(obj, widtype);
2261    win = elm_widget_data_get(obj);
2262    if (!win || !role) return;
2263    eina_stringshare_replace(&(win->role), role);
2264 #ifdef HAVE_ELEMENTARY_X
2265    _elm_win_xwin_update(win);
2266 #endif
2267 }
2268
2269 EAPI const char *
2270 elm_win_role_get(const Evas_Object *obj)
2271 {
2272    Elm_Win *win;
2273    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2274    win = elm_widget_data_get(obj);
2275    if (!win) return NULL;
2276    return win->role;
2277 }
2278
2279 EAPI void
2280 elm_win_icon_object_set(Evas_Object *obj, Evas_Object *icon)
2281 {
2282    Elm_Win *win;
2283    ELM_CHECK_WIDTYPE(obj, widtype);
2284    win = elm_widget_data_get(obj);
2285    if (!win) return;
2286    if (win->icon)
2287      evas_object_event_callback_del_full(win->icon, EVAS_CALLBACK_DEL,
2288                                          _elm_win_obj_icon_callback_del, win);
2289    win->icon = icon;
2290    if (win->icon)
2291      evas_object_event_callback_add(win->icon, EVAS_CALLBACK_DEL,
2292                                     _elm_win_obj_icon_callback_del, win);
2293 #ifdef HAVE_ELEMENTARY_X
2294    _elm_win_xwin_update(win);
2295 #endif
2296 }
2297
2298 EAPI const Evas_Object *
2299 elm_win_icon_object_get(const Evas_Object *obj)
2300 {
2301    Elm_Win *win;
2302    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2303    win = elm_widget_data_get(obj);
2304    if (!win) return NULL;
2305    return win->icon;
2306 >>>>>>> remotes/origin/upstream
2307 }
2308
2309 EAPI void
2310 elm_win_autodel_set(Evas_Object *obj, Eina_Bool autodel)
2311 {
2312    Elm_Win *win;
2313    ELM_CHECK_WIDTYPE(obj, widtype);
2314    win = elm_widget_data_get(obj);
2315    if (!win) return;
2316    win->autodel = autodel;
2317 }
2318
2319 EAPI Eina_Bool
2320 elm_win_autodel_get(const Evas_Object *obj)
2321 {
2322    Elm_Win *win;
2323    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2324    win = elm_widget_data_get(obj);
2325    if (!win) return EINA_FALSE;
2326    return win->autodel;
2327 }
2328
2329 EAPI void
2330 elm_win_activate(Evas_Object *obj)
2331 {
2332    Elm_Win *win;
2333    ELM_CHECK_WIDTYPE(obj, widtype);
2334    win = elm_widget_data_get(obj);
2335    if (!win) return;
2336    ecore_evas_activate(win->ee);
2337 }
2338
2339 EAPI void
2340 elm_win_lower(Evas_Object *obj)
2341 {
2342    Elm_Win *win;
2343    ELM_CHECK_WIDTYPE(obj, widtype);
2344    win = elm_widget_data_get(obj);
2345    if (!win) return;
2346    ecore_evas_lower(win->ee);
2347 }
2348
2349 EAPI void
2350 elm_win_raise(Evas_Object *obj)
2351 {
2352    Elm_Win *win;
2353    ELM_CHECK_WIDTYPE(obj, widtype);
2354    win = elm_widget_data_get(obj);
2355    if (!win) return;
2356    ecore_evas_raise(win->ee);
2357 }
2358
2359 EAPI void
2360 elm_win_center(Evas_Object *obj, Eina_Bool h, Eina_Bool v)
2361 {
2362    Elm_Win *win;
2363    int win_w, win_h, screen_w, screen_h, nx, ny;
2364    ELM_CHECK_WIDTYPE(obj, widtype);
2365    win = elm_widget_data_get(obj);
2366    if (!win) return;
2367    ecore_evas_screen_geometry_get(win->ee, NULL, NULL, &screen_w, &screen_h);
2368    if ((!screen_w) || (!screen_h)) return;
2369    evas_object_geometry_get(obj, NULL, NULL, &win_w, &win_h);
2370    if ((!win_w) || (!win_h)) return;
2371    if (h) nx = win_w >= screen_w ? 0 : (screen_w / 2) - (win_w / 2);
2372    else nx = win->screen.x;
2373    if (v) ny = win_h >= screen_h ? 0 : (screen_h / 2) - (win_h / 2);
2374    else ny = win->screen.y;
2375    if (nx < 0) nx = 0;
2376    if (ny < 0) ny = 0;
2377    evas_object_move(obj, nx, ny);
2378 }
2379
2380 EAPI void
2381 elm_win_borderless_set(Evas_Object *obj, Eina_Bool borderless)
2382 {
2383    Elm_Win *win;
2384    ELM_CHECK_WIDTYPE(obj, widtype);
2385    win = elm_widget_data_get(obj);
2386    if (!win) return;
2387    ecore_evas_borderless_set(win->ee, borderless);
2388 #ifdef HAVE_ELEMENTARY_X
2389    _elm_win_xwin_update(win);
2390 #endif
2391 }
2392
2393 EAPI Eina_Bool
2394 elm_win_borderless_get(const Evas_Object *obj)
2395 {
2396    Elm_Win *win;
2397    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2398    win = elm_widget_data_get(obj);
2399    if (!win) return EINA_FALSE;
2400    return ecore_evas_borderless_get(win->ee);
2401 }
2402
2403 EAPI void
2404 elm_win_shaped_set(Evas_Object *obj, Eina_Bool shaped)
2405 {
2406    Elm_Win *win;
2407    ELM_CHECK_WIDTYPE(obj, widtype);
2408    win = elm_widget_data_get(obj);
2409    if (!win) return;
2410    ecore_evas_shaped_set(win->ee, shaped);
2411 #ifdef HAVE_ELEMENTARY_X
2412    _elm_win_xwin_update(win);
2413 #endif
2414 }
2415
2416 EAPI Eina_Bool
2417 elm_win_shaped_get(const Evas_Object *obj)
2418 {
2419    Elm_Win *win;
2420    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2421    win = elm_widget_data_get(obj);
2422    if (!win) return EINA_FALSE;
2423    return ecore_evas_shaped_get(win->ee);
2424 }
2425
2426 EAPI void
2427 elm_win_alpha_set(Evas_Object *obj, Eina_Bool alpha)
2428 {
2429    Elm_Win *win;
2430    ELM_CHECK_WIDTYPE(obj, widtype);
2431    win = elm_widget_data_get(obj);
2432    if (!win) return;
2433    if (win->frame_obj)
2434      {
2435      }
2436    else if (win->img_obj)
2437      {
2438         evas_object_image_alpha_set(win->img_obj, alpha);
2439         ecore_evas_alpha_set(win->ee, alpha);
2440      }
2441    else
2442      {
2443 #ifdef HAVE_ELEMENTARY_X
2444         if (win->xwin)
2445           {
2446              if (alpha)
2447                {
2448                   if (!_elm_config->compositing)
2449                      elm_win_shaped_set(obj, alpha);
2450                   else
2451                      ecore_evas_alpha_set(win->ee, alpha);
2452                }
2453              else
2454                 ecore_evas_alpha_set(win->ee, alpha);
2455              _elm_win_xwin_update(win);
2456           }
2457         else
2458 #endif
2459            ecore_evas_alpha_set(win->ee, alpha);
2460      }
2461 }
2462
2463 EAPI Eina_Bool
2464 elm_win_alpha_get(const Evas_Object *obj)
2465 {
2466    Elm_Win *win;
2467    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2468    win = elm_widget_data_get(obj);
2469    if (!win) return EINA_FALSE;
2470    if (win->frame_obj)
2471      {
2472      }
2473    else if (win->img_obj)
2474      {
2475         return evas_object_image_alpha_get(win->img_obj);
2476      }
2477    return ecore_evas_alpha_get(win->ee);
2478 }
2479
2480 <<<<<<< HEAD
2481 EAPI void
2482 =======
2483 EINA_DEPRECATED EAPI void
2484 >>>>>>> remotes/origin/upstream
2485 elm_win_transparent_set(Evas_Object *obj, Eina_Bool transparent)
2486 {
2487    Elm_Win *win;
2488    ELM_CHECK_WIDTYPE(obj, widtype);
2489    win = elm_widget_data_get(obj);
2490    if (!win) return;
2491
2492    if (win->frame_obj)
2493      {
2494      }
2495    else if (win->img_obj)
2496      {
2497         evas_object_image_alpha_set(win->img_obj, transparent);
2498      }
2499    else
2500      {
2501 #ifdef HAVE_ELEMENTARY_X
2502         if (win->xwin)
2503           {
2504              ecore_evas_transparent_set(win->ee, transparent);
2505              _elm_win_xwin_update(win);
2506           }
2507         else
2508 #endif
2509            ecore_evas_transparent_set(win->ee, transparent);
2510      }
2511 }
2512
2513 <<<<<<< HEAD
2514 EAPI Eina_Bool
2515 =======
2516 EINA_DEPRECATED EAPI Eina_Bool
2517 >>>>>>> remotes/origin/upstream
2518 elm_win_transparent_get(const Evas_Object *obj)
2519 {
2520    Elm_Win *win;
2521    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2522    win = elm_widget_data_get(obj);
2523    if (!win) return EINA_FALSE;
2524
2525    return ecore_evas_transparent_get(win->ee);
2526 }
2527
2528 EAPI void
2529 elm_win_override_set(Evas_Object *obj, Eina_Bool override)
2530 {
2531    Elm_Win *win;
2532    ELM_CHECK_WIDTYPE(obj, widtype);
2533    win = elm_widget_data_get(obj);
2534    if (!win) return;
2535    ecore_evas_override_set(win->ee, override);
2536 #ifdef HAVE_ELEMENTARY_X
2537    _elm_win_xwin_update(win);
2538 #endif
2539 }
2540
2541 EAPI Eina_Bool
2542 elm_win_override_get(const Evas_Object *obj)
2543 {
2544    Elm_Win *win;
2545    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2546    win = elm_widget_data_get(obj);
2547    if (!win) return EINA_FALSE;
2548    return ecore_evas_override_get(win->ee);
2549 }
2550
2551 EAPI void
2552 elm_win_fullscreen_set(Evas_Object *obj, Eina_Bool fullscreen)
2553 {
2554    Elm_Win *win;
2555    ELM_CHECK_WIDTYPE(obj, widtype);
2556    win = elm_widget_data_get(obj);
2557    if (!win) return;
2558 <<<<<<< HEAD
2559
2560    // YYY: handle if win->img_obj
2561 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
2562 =======
2563    // YYY: handle if win->img_obj
2564 #define ENGINE_COMPARE(name) (!strcmp(_elm_preferred_engine, name))
2565 >>>>>>> remotes/origin/upstream
2566    if (ENGINE_COMPARE(ELM_SOFTWARE_FB) ||
2567        ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE))
2568      {
2569         // these engines... can ONLY be fullscreen
2570         return;
2571      }
2572    else
2573      {
2574 <<<<<<< HEAD
2575 =======
2576         win->fullscreen = fullscreen;
2577 >>>>>>> remotes/origin/upstream
2578         ecore_evas_fullscreen_set(win->ee, fullscreen);
2579 #ifdef HAVE_ELEMENTARY_X
2580         _elm_win_xwin_update(win);
2581 #endif
2582      }
2583 #undef ENGINE_COMPARE
2584 }
2585
2586 EAPI Eina_Bool
2587 elm_win_fullscreen_get(const Evas_Object *obj)
2588 {
2589    Elm_Win *win;
2590    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2591    win = elm_widget_data_get(obj);
2592    if (!win) return EINA_FALSE;
2593 <<<<<<< HEAD
2594
2595 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
2596 =======
2597 #define ENGINE_COMPARE(name) (!strcmp(_elm_preferred_engine, name))
2598 >>>>>>> remotes/origin/upstream
2599    if (ENGINE_COMPARE(ELM_SOFTWARE_FB) ||
2600        ENGINE_COMPARE(ELM_SOFTWARE_16_WINCE))
2601      {
2602         // these engines... can ONLY be fullscreen
2603         return EINA_TRUE;
2604      }
2605    else
2606      {
2607 <<<<<<< HEAD
2608         return ecore_evas_fullscreen_get(win->ee);
2609 =======
2610         return win->fullscreen;
2611 >>>>>>> remotes/origin/upstream
2612      }
2613 #undef ENGINE_COMPARE
2614 }
2615
2616 EAPI void
2617 elm_win_maximized_set(Evas_Object *obj, Eina_Bool maximized)
2618 {
2619    Elm_Win *win;
2620    ELM_CHECK_WIDTYPE(obj, widtype);
2621    win = elm_widget_data_get(obj);
2622    if (!win) return;
2623 <<<<<<< HEAD
2624 =======
2625    win->maximized = maximized;
2626 >>>>>>> remotes/origin/upstream
2627    // YYY: handle if win->img_obj
2628    ecore_evas_maximized_set(win->ee, maximized);
2629 #ifdef HAVE_ELEMENTARY_X
2630    _elm_win_xwin_update(win);
2631 #endif
2632 }
2633
2634 EAPI Eina_Bool
2635 elm_win_maximized_get(const Evas_Object *obj)
2636 {
2637    Elm_Win *win;
2638    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2639    win = elm_widget_data_get(obj);
2640    if (!win) return EINA_FALSE;
2641 <<<<<<< HEAD
2642    return ecore_evas_maximized_get(win->ee);
2643 =======
2644    return win->maximized;
2645 >>>>>>> remotes/origin/upstream
2646 }
2647
2648 EAPI void
2649 elm_win_iconified_set(Evas_Object *obj, Eina_Bool iconified)
2650 {
2651    Elm_Win *win;
2652    ELM_CHECK_WIDTYPE(obj, widtype);
2653    win = elm_widget_data_get(obj);
2654    if (!win) return;
2655 <<<<<<< HEAD
2656 =======
2657    win->iconified = iconified;
2658 >>>>>>> remotes/origin/upstream
2659    ecore_evas_iconified_set(win->ee, iconified);
2660 #ifdef HAVE_ELEMENTARY_X
2661    _elm_win_xwin_update(win);
2662 #endif
2663 }
2664
2665 EAPI Eina_Bool
2666 elm_win_iconified_get(const Evas_Object *obj)
2667 {
2668    Elm_Win *win;
2669    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2670    win = elm_widget_data_get(obj);
2671    if (!win) return EINA_FALSE;
2672 <<<<<<< HEAD
2673    return ecore_evas_iconified_get(win->ee);
2674 =======
2675    return win->iconified;
2676 }
2677
2678 EAPI void
2679 elm_win_withdrawn_set(Evas_Object *obj, Eina_Bool withdrawn)
2680 {
2681    Elm_Win *win;
2682    ELM_CHECK_WIDTYPE(obj, widtype);
2683    win = elm_widget_data_get(obj);
2684    if (!win) return;
2685    win->withdrawn = withdrawn;
2686    ecore_evas_withdrawn_set(win->ee, withdrawn);
2687 #ifdef HAVE_ELEMENTARY_X
2688    _elm_win_xwin_update(win);
2689 #endif
2690 }
2691
2692 EAPI Eina_Bool
2693 elm_win_withdrawn_get(const Evas_Object *obj)
2694 {
2695    Elm_Win *win;
2696    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2697    win = elm_widget_data_get(obj);
2698    if (!win) return EINA_FALSE;
2699    return win->withdrawn;
2700 }
2701
2702 EAPI void
2703 elm_win_urgent_set(Evas_Object *obj, Eina_Bool urgent)
2704 {
2705    Elm_Win *win;
2706    ELM_CHECK_WIDTYPE(obj, widtype);
2707    win = elm_widget_data_get(obj);
2708    if (!win) return;
2709    win->urgent = urgent;
2710    ecore_evas_urgent_set(win->ee, urgent);
2711 #ifdef HAVE_ELEMENTARY_X
2712    _elm_win_xwin_update(win);
2713 #endif
2714 }
2715
2716 EAPI Eina_Bool
2717 elm_win_urgent_get(const Evas_Object *obj)
2718 {
2719    Elm_Win *win;
2720    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2721    win = elm_widget_data_get(obj);
2722    if (!win) return EINA_FALSE;
2723    return win->urgent;
2724 }
2725
2726 EAPI void
2727 elm_win_demand_attention_set(Evas_Object *obj, Eina_Bool demand_attention)
2728 {
2729    Elm_Win *win;
2730    ELM_CHECK_WIDTYPE(obj, widtype);
2731    win = elm_widget_data_get(obj);
2732    if (!win) return;
2733    win->demand_attention = demand_attention;
2734    ecore_evas_demand_attention_set(win->ee, demand_attention);
2735 #ifdef HAVE_ELEMENTARY_X
2736    _elm_win_xwin_update(win);
2737 #endif
2738 }
2739
2740 EAPI Eina_Bool
2741 elm_win_demand_attention_get(const Evas_Object *obj)
2742 {
2743    Elm_Win *win;
2744    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2745    win = elm_widget_data_get(obj);
2746    if (!win) return EINA_FALSE;
2747    return win->demand_attention;
2748 }
2749
2750 EAPI void
2751 elm_win_modal_set(Evas_Object *obj, Eina_Bool modal)
2752 {
2753    Elm_Win *win;
2754    ELM_CHECK_WIDTYPE(obj, widtype);
2755    win = elm_widget_data_get(obj);
2756    if (!win) return;
2757    win->modal = modal;
2758    ecore_evas_modal_set(win->ee, modal);
2759 #ifdef HAVE_ELEMENTARY_X
2760    _elm_win_xwin_update(win);
2761 #endif
2762 }
2763
2764 EAPI Eina_Bool
2765 elm_win_modal_get(const Evas_Object *obj)
2766 {
2767    Elm_Win *win;
2768    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2769    win = elm_widget_data_get(obj);
2770    if (!win) return EINA_FALSE;
2771    return win->modal;
2772 }
2773
2774 EAPI void
2775 elm_win_aspect_set(Evas_Object *obj, double aspect)
2776 {
2777    Elm_Win *win;
2778    ELM_CHECK_WIDTYPE(obj, widtype);
2779    win = elm_widget_data_get(obj);
2780    if (!win) return;
2781    win->aspect = aspect;
2782    ecore_evas_aspect_set(win->ee, aspect);
2783 #ifdef HAVE_ELEMENTARY_X
2784    _elm_win_xwin_update(win);
2785 #endif
2786 }
2787
2788 EAPI double
2789 elm_win_aspect_get(const Evas_Object *obj)
2790 {
2791    Elm_Win *win;
2792    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2793    win = elm_widget_data_get(obj);
2794    if (!win) return EINA_FALSE;
2795    return win->aspect;
2796 >>>>>>> remotes/origin/upstream
2797 }
2798
2799 EAPI void
2800 elm_win_layer_set(Evas_Object *obj, int layer)
2801 {
2802    Elm_Win *win;
2803    ELM_CHECK_WIDTYPE(obj, widtype);
2804    win = elm_widget_data_get(obj);
2805    if (!win) return;
2806    ecore_evas_layer_set(win->ee, layer);
2807 #ifdef HAVE_ELEMENTARY_X
2808    _elm_win_xwin_update(win);
2809 #endif
2810 }
2811
2812 EAPI int
2813 elm_win_layer_get(const Evas_Object *obj)
2814 {
2815    Elm_Win *win;
2816    ELM_CHECK_WIDTYPE(obj, widtype) -1;
2817    win = elm_widget_data_get(obj);
2818    if (!win) return -1;
2819    return ecore_evas_layer_get(win->ee);
2820 }
2821
2822 EAPI void
2823 elm_win_rotation_set(Evas_Object *obj, int rotation)
2824 {
2825    Elm_Win *win;
2826    ELM_CHECK_WIDTYPE(obj, widtype);
2827    win = elm_widget_data_get(obj);
2828    if (!win) return;
2829    if (win->rot == rotation) return;
2830    win->rot = rotation;
2831    ecore_evas_rotation_set(win->ee, rotation);
2832    evas_object_size_hint_min_set(obj, -1, -1);
2833    evas_object_size_hint_max_set(obj, -1, -1);
2834    _elm_win_eval_subobjs(obj);
2835 #ifdef HAVE_ELEMENTARY_X
2836    _elm_win_xwin_update(win);
2837 #endif
2838 }
2839
2840 EAPI void
2841 elm_win_rotation_with_resize_set(Evas_Object *obj, int rotation)
2842 {
2843    Elm_Win *win;
2844    ELM_CHECK_WIDTYPE(obj, widtype);
2845    win = elm_widget_data_get(obj);
2846    if (!win) return;
2847    if (win->rot == rotation) return;
2848    win->rot = rotation;
2849    ecore_evas_rotation_with_resize_set(win->ee, rotation);
2850    evas_object_size_hint_min_set(obj, -1, -1);
2851    evas_object_size_hint_max_set(obj, -1, -1);
2852    _elm_win_eval_subobjs(obj);
2853 #ifdef HAVE_ELEMENTARY_X
2854    _elm_win_xwin_update(win);
2855 #endif
2856 }
2857
2858 EAPI int
2859 elm_win_rotation_get(const Evas_Object *obj)
2860 {
2861    Elm_Win *win;
2862    ELM_CHECK_WIDTYPE(obj, widtype) -1;
2863    win = elm_widget_data_get(obj);
2864    if (!win) return -1;
2865    return win->rot;
2866 }
2867
2868 EAPI void
2869 elm_win_sticky_set(Evas_Object *obj, Eina_Bool sticky)
2870 {
2871    Elm_Win *win;
2872    ELM_CHECK_WIDTYPE(obj, widtype);
2873    win = elm_widget_data_get(obj);
2874    if (!win) return;
2875 <<<<<<< HEAD
2876 =======
2877    win->sticky = sticky;
2878 >>>>>>> remotes/origin/upstream
2879    ecore_evas_sticky_set(win->ee, sticky);
2880 #ifdef HAVE_ELEMENTARY_X
2881    _elm_win_xwin_update(win);
2882 #endif
2883 }
2884
2885 EAPI Eina_Bool
2886 elm_win_sticky_get(const Evas_Object *obj)
2887 {
2888    Elm_Win *win;
2889    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2890    win = elm_widget_data_get(obj);
2891    if (!win) return EINA_FALSE;
2892 <<<<<<< HEAD
2893    return ecore_evas_sticky_get(win->ee);
2894 =======
2895    return win->sticky;
2896 >>>>>>> remotes/origin/upstream
2897 }
2898
2899 EAPI void
2900 elm_win_keyboard_mode_set(Evas_Object *obj, Elm_Win_Keyboard_Mode mode)
2901 {
2902    Elm_Win *win;
2903    ELM_CHECK_WIDTYPE(obj, widtype);
2904    win = elm_widget_data_get(obj);
2905    if (!win) return;
2906    if (mode == win->kbdmode) return;
2907 #ifdef HAVE_ELEMENTARY_X
2908    _elm_win_xwindow_get(win);
2909 #endif
2910    win->kbdmode = mode;
2911 #ifdef HAVE_ELEMENTARY_X
2912    if (win->xwin)
2913      ecore_x_e_virtual_keyboard_state_set
2914         (win->xwin, (Ecore_X_Virtual_Keyboard_State)win->kbdmode);
2915 #endif
2916 }
2917
2918 EAPI Elm_Win_Keyboard_Mode
2919 elm_win_keyboard_mode_get(const Evas_Object *obj)
2920 {
2921    Elm_Win *win;
2922    ELM_CHECK_WIDTYPE(obj, widtype) ELM_WIN_KEYBOARD_UNKNOWN;
2923    win = elm_widget_data_get(obj);
2924    if (!win) return ELM_WIN_KEYBOARD_UNKNOWN;
2925    return win->kbdmode;
2926 }
2927
2928 EAPI void
2929 elm_win_keyboard_win_set(Evas_Object *obj, Eina_Bool is_keyboard)
2930 {
2931    Elm_Win *win;
2932    ELM_CHECK_WIDTYPE(obj, widtype);
2933    win = elm_widget_data_get(obj);
2934    if (!win) return;
2935 #ifdef HAVE_ELEMENTARY_X
2936    _elm_win_xwindow_get(win);
2937    if (win->xwin)
2938      ecore_x_e_virtual_keyboard_set(win->xwin, is_keyboard);
2939 #else
2940    (void) is_keyboard;
2941 #endif
2942 }
2943
2944 EAPI Eina_Bool
2945 elm_win_keyboard_win_get(const Evas_Object *obj)
2946 {
2947    Elm_Win *win;
2948    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2949    win = elm_widget_data_get(obj);
2950    if (!win) return EINA_FALSE;
2951 #ifdef HAVE_ELEMENTARY_X
2952    _elm_win_xwindow_get(win);
2953    if (win->xwin)
2954      return ecore_x_e_virtual_keyboard_get(win->xwin);
2955 #endif
2956    return EINA_FALSE;
2957 }
2958
2959 EAPI void
2960 <<<<<<< HEAD
2961 =======
2962 elm_win_indicator_mode_set(Evas_Object *obj, Elm_Win_Indicator_Mode mode)
2963 {
2964    Elm_Win *win;
2965    ELM_CHECK_WIDTYPE(obj, widtype);
2966    win = elm_widget_data_get(obj);
2967    if (!win) return;
2968    if (mode == win->indmode) return;
2969 #ifdef HAVE_ELEMENTARY_X
2970    _elm_win_xwindow_get(win);
2971 #endif
2972    win->indmode = mode;
2973 #ifdef HAVE_ELEMENTARY_X
2974    if (win->xwin)
2975      {
2976         if (win->indmode == ELM_WIN_INDICATOR_SHOW)
2977           ecore_x_e_illume_indicator_state_set
2978           (win->xwin, ECORE_X_ILLUME_INDICATOR_STATE_ON);
2979         else if (win->indmode == ELM_WIN_INDICATOR_HIDE)
2980           ecore_x_e_illume_indicator_state_set
2981           (win->xwin, ECORE_X_ILLUME_INDICATOR_STATE_OFF);
2982      }
2983 #endif
2984 }
2985
2986 EAPI Elm_Win_Indicator_Mode
2987 elm_win_indicator_mode_get(const Evas_Object *obj)
2988 {
2989    Elm_Win *win;
2990    ELM_CHECK_WIDTYPE(obj, widtype) ELM_WIN_INDICATOR_UNKNOWN;
2991    win = elm_widget_data_get(obj);
2992    if (!win) return ELM_WIN_INDICATOR_UNKNOWN;
2993    return win->indmode;
2994 }
2995
2996 EAPI void
2997 elm_win_indicator_opacity_set(Evas_Object *obj, Elm_Win_Indicator_Opacity_Mode mode)
2998 {
2999    Elm_Win *win;
3000    ELM_CHECK_WIDTYPE(obj, widtype);
3001    win = elm_widget_data_get(obj);
3002    if (!win) return;
3003    if (mode == win->ind_o_mode) return;
3004    win->ind_o_mode = mode;
3005 #ifdef HAVE_ELEMENTARY_X
3006    _elm_win_xwindow_get(win);
3007    if (win->xwin)
3008      {
3009         if (win->ind_o_mode == ELM_WIN_INDICATOR_OPAQUE)
3010           ecore_x_e_illume_indicator_opacity_set
3011           (win->xwin, ECORE_X_ILLUME_INDICATOR_OPAQUE);
3012         else if (win->ind_o_mode == ELM_WIN_INDICATOR_TRANSLUCENT)
3013           ecore_x_e_illume_indicator_opacity_set
3014           (win->xwin, ECORE_X_ILLUME_INDICATOR_TRANSLUCENT);
3015         else if (win->ind_o_mode == ELM_WIN_INDICATOR_TRANSPARENT)
3016           ecore_x_e_illume_indicator_opacity_set
3017           (win->xwin, ECORE_X_ILLUME_INDICATOR_TRANSPARENT);
3018
3019      }
3020 #endif
3021 }
3022
3023 EAPI Elm_Win_Indicator_Opacity_Mode
3024 elm_win_indicator_opacity_get(const Evas_Object *obj)
3025 {
3026    Elm_Win *win;
3027    ELM_CHECK_WIDTYPE(obj, widtype) ELM_WIN_INDICATOR_OPACITY_UNKNOWN;
3028    win = elm_widget_data_get(obj);
3029    if (!win) return ELM_WIN_INDICATOR_OPACITY_UNKNOWN;
3030    return win->ind_o_mode;
3031 }
3032
3033 EAPI void
3034 >>>>>>> remotes/origin/upstream
3035 elm_win_screen_position_get(const Evas_Object *obj, int *x, int *y)
3036 {
3037    Elm_Win *win;
3038    ELM_CHECK_WIDTYPE(obj, widtype);
3039    win = elm_widget_data_get(obj);
3040    if (!win) return;
3041    if (x) *x = win->screen.x;
3042    if (y) *y = win->screen.y;
3043 }
3044
3045 EAPI Eina_Bool
3046 elm_win_focus_get(const Evas_Object *obj)
3047 {
3048    Elm_Win *win;
3049    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3050    win = elm_widget_data_get(obj);
3051    if (!win) return EINA_FALSE;
3052    return ecore_evas_focus_get(win->ee);
3053 }
3054
3055 EAPI void
3056 elm_win_screen_constrain_set(Evas_Object *obj, Eina_Bool constrain)
3057 {
3058    Elm_Win *win;
3059    ELM_CHECK_WIDTYPE(obj, widtype);
3060    win = elm_widget_data_get(obj);
3061    if (!win) return;
3062    win->constrain = !!constrain;
3063 }
3064
3065 EAPI Eina_Bool
3066 elm_win_screen_constrain_get(Evas_Object *obj)
3067 {
3068    Elm_Win *win;
3069    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3070    win = elm_widget_data_get(obj);
3071    if (!win) return EINA_FALSE;
3072    return win->constrain;
3073 }
3074
3075 EAPI void
3076 elm_win_screen_size_get(const Evas_Object *obj, int *x, int *y, int *w, int *h)
3077 {
3078    Elm_Win *win;
3079    ELM_CHECK_WIDTYPE(obj, widtype);
3080    win = elm_widget_data_get(obj);
3081    if (!win) return;
3082    ecore_evas_screen_geometry_get(win->ee, x, y, w, h);
3083 }
3084
3085 EAPI void
3086 elm_win_conformant_set(Evas_Object *obj, Eina_Bool conformant)
3087 {
3088    Elm_Win *win;
3089    ELM_CHECK_WIDTYPE(obj, widtype);
3090    win = elm_widget_data_get(obj);
3091    if (!win) return;
3092 #ifdef HAVE_ELEMENTARY_X
3093    _elm_win_xwindow_get(win);
3094    if (win->xwin)
3095      ecore_x_e_illume_conformant_set(win->xwin, conformant);
3096 #else
3097    (void) conformant;
3098 #endif
3099 }
3100
3101 EAPI Eina_Bool
3102 elm_win_conformant_get(const Evas_Object *obj)
3103 {
3104    Elm_Win *win;
3105    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3106    win = elm_widget_data_get(obj);
3107    if (!win) return EINA_FALSE;
3108 #ifdef HAVE_ELEMENTARY_X
3109    _elm_win_xwindow_get(win);
3110    if (win->xwin)
3111      return ecore_x_e_illume_conformant_get(win->xwin);
3112 #endif
3113    return EINA_FALSE;
3114 }
3115
3116 EAPI void
3117 elm_win_quickpanel_set(Evas_Object *obj, Eina_Bool quickpanel)
3118 {
3119    Elm_Win *win;
3120    ELM_CHECK_WIDTYPE(obj, widtype);
3121    win = elm_widget_data_get(obj);
3122    if (!win) return;
3123 #ifdef HAVE_ELEMENTARY_X
3124    _elm_win_xwindow_get(win);
3125    if (win->xwin)
3126      {
3127         ecore_x_e_illume_quickpanel_set(win->xwin, quickpanel);
3128         if (quickpanel)
3129           {
3130              Ecore_X_Window_State states[2];
3131
3132              states[0] = ECORE_X_WINDOW_STATE_SKIP_TASKBAR;
3133              states[1] = ECORE_X_WINDOW_STATE_SKIP_PAGER;
3134              ecore_x_netwm_window_state_set(win->xwin, states, 2);
3135              ecore_x_icccm_hints_set(win->xwin, 0, 0, 0, 0, 0, 0, 0);
3136           }
3137      }
3138 #else
3139    (void) quickpanel;
3140 #endif
3141 }
3142
3143 EAPI Eina_Bool
3144 elm_win_quickpanel_get(const Evas_Object *obj)
3145 {
3146    Elm_Win *win;
3147    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3148    win = elm_widget_data_get(obj);
3149    if (!win) return EINA_FALSE;
3150 #ifdef HAVE_ELEMENTARY_X
3151    _elm_win_xwindow_get(win);
3152    if (win->xwin)
3153      return ecore_x_e_illume_quickpanel_get(win->xwin);
3154 #endif
3155    return EINA_FALSE;
3156 }
3157
3158 EAPI void
3159 elm_win_quickpanel_priority_major_set(Evas_Object *obj, int priority)
3160 {
3161    Elm_Win *win;
3162    ELM_CHECK_WIDTYPE(obj, widtype);
3163    win = elm_widget_data_get(obj);
3164    if (!win) return;
3165 #ifdef HAVE_ELEMENTARY_X
3166    _elm_win_xwindow_get(win);
3167    if (win->xwin)
3168      ecore_x_e_illume_quickpanel_priority_major_set(win->xwin, priority);
3169 #else
3170    (void) priority;
3171 #endif
3172 }
3173
3174 EAPI int
3175 elm_win_quickpanel_priority_major_get(const Evas_Object *obj)
3176 {
3177    Elm_Win *win;
3178    ELM_CHECK_WIDTYPE(obj, widtype) -1;
3179    win = elm_widget_data_get(obj);
3180    if (!win) return -1;
3181 #ifdef HAVE_ELEMENTARY_X
3182    _elm_win_xwindow_get(win);
3183    if (win->xwin)
3184      return ecore_x_e_illume_quickpanel_priority_major_get(win->xwin);
3185 #endif
3186    return -1;
3187 }
3188
3189 EAPI void
3190 elm_win_quickpanel_priority_minor_set(Evas_Object *obj, int priority)
3191 {
3192    Elm_Win *win;
3193    ELM_CHECK_WIDTYPE(obj, widtype);
3194    win = elm_widget_data_get(obj);
3195    if (!win) return;
3196 #ifdef HAVE_ELEMENTARY_X
3197    _elm_win_xwindow_get(win);
3198    if (win->xwin)
3199      ecore_x_e_illume_quickpanel_priority_minor_set(win->xwin, priority);
3200 #else
3201    (void) priority;
3202 #endif
3203 }
3204
3205 EAPI int
3206 elm_win_quickpanel_priority_minor_get(const Evas_Object *obj)
3207 {
3208    Elm_Win *win;
3209    ELM_CHECK_WIDTYPE(obj, widtype) -1;
3210    win = elm_widget_data_get(obj);
3211    if (!win) return -1;
3212 #ifdef HAVE_ELEMENTARY_X
3213    _elm_win_xwindow_get(win);
3214    if (win->xwin)
3215      return ecore_x_e_illume_quickpanel_priority_minor_get(win->xwin);
3216 #endif
3217    return -1;
3218 }
3219
3220 EAPI void
3221 elm_win_quickpanel_zone_set(Evas_Object *obj, int zone)
3222 {
3223    Elm_Win *win;
3224    ELM_CHECK_WIDTYPE(obj, widtype);
3225    win = elm_widget_data_get(obj);
3226    if (!win) return;
3227 #ifdef HAVE_ELEMENTARY_X
3228    _elm_win_xwindow_get(win);
3229    if (win->xwin)
3230      ecore_x_e_illume_quickpanel_zone_set(win->xwin, zone);
3231 #else
3232    (void) zone;
3233 #endif
3234 }
3235
3236 EAPI int
3237 elm_win_quickpanel_zone_get(const Evas_Object *obj)
3238 {
3239    Elm_Win *win;
3240    ELM_CHECK_WIDTYPE(obj, widtype) 0;
3241    win = elm_widget_data_get(obj);
3242    if (!win) return 0;
3243 #ifdef HAVE_ELEMENTARY_X
3244    _elm_win_xwindow_get(win);
3245    if (win->xwin)
3246      return ecore_x_e_illume_quickpanel_zone_get(win->xwin);
3247 #endif
3248    return 0;
3249 }
3250
3251 EAPI void
3252 elm_win_prop_focus_skip_set(Evas_Object *obj, Eina_Bool skip)
3253 {
3254    Elm_Win *win;
3255    ELM_CHECK_WIDTYPE(obj, widtype);
3256    win = elm_widget_data_get(obj);
3257    if (!win) return;
3258 <<<<<<< HEAD
3259 #ifdef HAVE_ELEMENTARY_X
3260    _elm_win_xwindow_get(win);
3261    if (skip)
3262      {
3263         if (win->xwin)
3264           {
3265              Ecore_X_Window_State states[2];
3266
3267              ecore_x_icccm_hints_set(win->xwin, 0, 0, 0, 0, 0, 0, 0);
3268              states[0] = ECORE_X_WINDOW_STATE_SKIP_TASKBAR;
3269              states[1] = ECORE_X_WINDOW_STATE_SKIP_PAGER;
3270              ecore_x_netwm_window_state_set(win->xwin, states, 2);
3271           }
3272      }
3273 #else
3274    (void) skip;
3275 #endif
3276 =======
3277    win->skip_focus = skip;
3278    ecore_evas_focus_skip_set(win->ee, skip);
3279 >>>>>>> remotes/origin/upstream
3280 }
3281
3282 EAPI void
3283 elm_win_illume_command_send(Evas_Object *obj, Elm_Illume_Command command, void *params __UNUSED__)
3284 {
3285    Elm_Win *win;
3286    ELM_CHECK_WIDTYPE(obj, widtype);
3287    win = elm_widget_data_get(obj);
3288    if (!win) return;
3289 #ifdef HAVE_ELEMENTARY_X
3290    _elm_win_xwindow_get(win);
3291    if (win->xwin)
3292      {
3293         switch (command)
3294           {
3295            case ELM_ILLUME_COMMAND_FOCUS_BACK:
3296               ecore_x_e_illume_focus_back_send(win->xwin);
3297               break;
3298            case ELM_ILLUME_COMMAND_FOCUS_FORWARD:
3299               ecore_x_e_illume_focus_forward_send(win->xwin);
3300               break;
3301            case ELM_ILLUME_COMMAND_FOCUS_HOME:
3302               ecore_x_e_illume_focus_home_send(win->xwin);
3303               break;
3304            case ELM_ILLUME_COMMAND_CLOSE:
3305               ecore_x_e_illume_close_send(win->xwin);
3306               break;
3307            default:
3308               break;
3309           }
3310      }
3311 #else
3312    (void) command;
3313 #endif
3314 }
3315
3316 EAPI Evas_Object *
3317 elm_win_inlined_image_object_get(Evas_Object *obj)
3318 {
3319    Elm_Win *win;
3320    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3321    win = elm_widget_data_get(obj);
3322    if (!win) return NULL;
3323    return win->img_obj;
3324 }
3325
3326 EAPI void
3327 elm_win_focus_highlight_enabled_set(Evas_Object *obj, Eina_Bool enabled)
3328 {
3329    Elm_Win *win;
3330
3331    ELM_CHECK_WIDTYPE(obj, widtype);
3332
3333    win = elm_widget_data_get(obj);
3334    enabled = !!enabled;
3335    if (win->focus_highlight.enabled == enabled)
3336      return;
3337
3338    win->focus_highlight.enabled = enabled;
3339
3340    if (win->focus_highlight.enabled)
3341      _elm_win_focus_highlight_init(win);
3342    else
3343      _elm_win_focus_highlight_shutdown(win);
3344 }
3345
3346 EAPI Eina_Bool
3347 elm_win_focus_highlight_enabled_get(const Evas_Object *obj)
3348 {
3349    Elm_Win *win;
3350
3351    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3352
3353    win = elm_widget_data_get(obj);
3354    return win->focus_highlight.enabled;
3355 }
3356
3357 EAPI void
3358 elm_win_focus_highlight_style_set(Evas_Object *obj, const char *style)
3359 {
3360    Elm_Win *win;
3361
3362    ELM_CHECK_WIDTYPE(obj, widtype);
3363
3364    win = elm_widget_data_get(obj);
3365    eina_stringshare_replace(&win->focus_highlight.style, style);
3366    win->focus_highlight.changed_theme = EINA_TRUE;
3367    _elm_win_focus_highlight_reconfigure_job_start(win);
3368 }
3369
3370 EAPI const char *
3371 elm_win_focus_highlight_style_get(const Evas_Object *obj)
3372 {
3373    Elm_Win *win;
3374
3375    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3376
3377    win = elm_widget_data_get(obj);
3378    return win->focus_highlight.style;
3379 }
3380
3381 <<<<<<< HEAD
3382 EAPI void
3383 elm_win_indicator_state_set(Evas_Object *obj, int show_state)
3384 {
3385    Elm_Win *win;
3386    if (strcmp(elm_widget_type_get(obj), "win")) return;
3387    win = elm_widget_data_get(obj);
3388    if (!win) return;
3389 #ifdef HAVE_ELEMENTARY_X
3390    _elm_win_xwindow_get(win);
3391    if (win->xwin)
3392       return ecore_x_window_prop_property_set (win->xwin,
3393                    ECORE_X_ATOM_E_ILLUME_INDICATOR_STATE, ECORE_X_ATOM_CARDINAL, 32, &show_state, 1);
3394 #endif
3395    return;
3396 }
3397
3398 EAPI int
3399 elm_win_indicator_state_get(Evas_Object *obj)
3400 {
3401    Elm_Win *win;
3402    if (strcmp(elm_widget_type_get(obj), "win")) return -1;
3403    win = elm_widget_data_get(obj);
3404    if (!win) return -1;
3405 #ifdef HAVE_ELEMENTARY_X
3406    _elm_win_xwindow_get(win);
3407    if (win->xwin)
3408      {
3409         int ret;
3410         int count;
3411         int show = -1;
3412         unsigned int *prop_data = NULL;
3413
3414         ret = ecore_x_window_prop_property_get (win->xwin,
3415                     ECORE_X_ATOM_E_ILLUME_INDICATOR_STATE, ECORE_X_ATOM_CARDINAL, 32, (void *)&prop_data, &count);
3416         if( ret && prop_data )
3417            memcpy (&show, prop_data, sizeof (int));
3418
3419         if (prop_data) free (prop_data);
3420
3421         return show;
3422      }
3423 #endif
3424    return -1;
3425 }
3426
3427
3428 =======
3429 >>>>>>> remotes/origin/upstream
3430 typedef struct _Widget_Data Widget_Data;
3431
3432 struct _Widget_Data
3433 {
3434    Evas_Object *frm;
3435    Evas_Object *content;
3436 };
3437
3438 static void _del_hook(Evas_Object *obj);
3439 static void _theme_hook(Evas_Object *obj);
3440 static void _sizing_eval(Evas_Object *obj);
3441 static void _changed_size_hints(void *data, Evas *e, Evas_Object *obj, void *event_info);
3442 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
3443
3444 static const char *widtype2 = NULL;
3445
3446 static void
3447 _del_hook(Evas_Object *obj)
3448 {
3449    Widget_Data *wd = elm_widget_data_get(obj);
3450    if (!wd) return;
3451    free(wd);
3452 }
3453
3454 static void
3455 _theme_hook(Evas_Object *obj)
3456 {
3457    Widget_Data *wd = elm_widget_data_get(obj);
3458    _elm_theme_object_set(obj, wd->frm, "win", "inwin", elm_widget_style_get(obj));
3459    if (wd->content)
3460      edje_object_part_swallow(wd->frm, "elm.swallow.content", wd->content);
3461    _sizing_eval(obj);
3462
3463    evas_object_smart_callback_call(obj, SIG_THEME_CHANGED, NULL);
3464 }
3465
3466 static Eina_Bool
3467 _elm_inwin_focus_next_hook(const Evas_Object *obj, Elm_Focus_Direction dir, Evas_Object **next)
3468 {
3469    Widget_Data *wd = elm_widget_data_get(obj);
3470
3471    if (!wd)
3472      return EINA_FALSE;
3473
3474    /* Try Focus cycle in subitem */
3475    if (wd->content)
3476      {
3477         elm_widget_focus_next_get(wd->content, dir, next);
3478         if (*next)
3479           return EINA_TRUE;
3480      }
3481
3482    *next = (Evas_Object *)obj;
3483    return EINA_FALSE;
3484 }
3485
3486 static void
3487 <<<<<<< HEAD
3488 =======
3489 _elm_inwin_text_set_hook(Evas_Object *obj, const char *item, const char *text)
3490 {
3491    Widget_Data *wd = elm_widget_data_get(obj);
3492
3493    if (!wd || !item) return;
3494    edje_object_part_text_set(wd->frm, item, text);
3495    _sizing_eval(obj);
3496 }
3497
3498 static const char *
3499 _elm_inwin_text_get_hook(const Evas_Object *obj, const char *item)
3500 {
3501    Widget_Data *wd = elm_widget_data_get(obj);
3502
3503    if (!item || !wd || !wd->frm) return NULL;
3504    return edje_object_part_text_get(wd->frm, item);
3505 }
3506
3507 static void
3508 >>>>>>> remotes/origin/upstream
3509 _sizing_eval(Evas_Object *obj)
3510 {
3511    Widget_Data *wd = elm_widget_data_get(obj);
3512    Evas_Coord minw = -1, minh = -1;
3513
3514    evas_object_size_hint_min_get(wd->content, &minw, &minh);
3515    edje_object_size_min_calc(wd->frm, &minw, &minh);
3516    evas_object_size_hint_min_set(obj, minw, minh);
3517    evas_object_size_hint_max_set(obj, -1, -1);
3518 }
3519
3520 static void
3521 _changed_size_hints(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
3522 {
3523    _sizing_eval(data);
3524 }
3525
3526 static void
3527 _sub_del(void *data __UNUSED__, Evas_Object *obj, void *event_info)
3528 {
3529    Widget_Data *wd = elm_widget_data_get(obj);
3530    Evas_Object *sub = event_info;
3531    if (sub == wd->content)
3532      {
3533         evas_object_event_callback_del_full
3534            (sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
3535         wd->content = NULL;
3536         _sizing_eval(obj);
3537      }
3538 }
3539
3540 EAPI Evas_Object *
3541 elm_win_inwin_add(Evas_Object *obj)
3542 {
3543    Evas_Object *obj2;
3544    Widget_Data *wd;
3545    Elm_Win *win;
3546
3547    ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3548    win = elm_widget_data_get(obj);
3549    if (!win) return NULL;
3550    wd = ELM_NEW(Widget_Data);
3551    obj2 = elm_widget_add(win->evas);
3552    elm_widget_type_set(obj2, "inwin");
3553    ELM_SET_WIDTYPE(widtype2, "inwin");
3554    elm_widget_sub_object_add(obj, obj2);
3555    evas_object_size_hint_weight_set(obj2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3556    evas_object_size_hint_align_set(obj2, EVAS_HINT_FILL, EVAS_HINT_FILL);
3557    elm_win_resize_object_add(obj, obj2);
3558
3559    elm_widget_data_set(obj2, wd);
3560    elm_widget_del_hook_set(obj2, _del_hook);
3561    elm_widget_theme_hook_set(obj2, _theme_hook);
3562    elm_widget_focus_next_hook_set(obj2, _elm_inwin_focus_next_hook);
3563 <<<<<<< HEAD
3564 =======
3565    elm_widget_text_set_hook_set(obj2, _elm_inwin_text_set_hook);
3566    elm_widget_text_get_hook_set(obj2, _elm_inwin_text_get_hook);
3567 >>>>>>> remotes/origin/upstream
3568    elm_widget_can_focus_set(obj2, EINA_TRUE);
3569    elm_widget_highlight_ignore_set(obj2, EINA_TRUE);
3570
3571    wd->frm = edje_object_add(win->evas);
3572    _elm_theme_object_set(obj, wd->frm, "win", "inwin", "default");
3573    elm_widget_resize_object_set(obj2, wd->frm);
3574
3575    evas_object_smart_callback_add(obj2, "sub-object-del", _sub_del, obj2);
3576
3577    _sizing_eval(obj2);
3578    return obj2;
3579 }
3580
3581 EAPI void
3582 elm_win_inwin_activate(Evas_Object *obj)
3583 {
3584    ELM_CHECK_WIDTYPE(obj, widtype2);
3585    Widget_Data *wd = elm_widget_data_get(obj);
3586    if (!wd) return;
3587    evas_object_raise(obj);
3588    evas_object_show(obj);
3589    edje_object_signal_emit(wd->frm, "elm,action,show", "elm");
3590    elm_object_focus_set(obj, EINA_TRUE);
3591 }
3592
3593 EAPI void
3594 elm_win_inwin_content_set(Evas_Object *obj, Evas_Object *content)
3595 {
3596    ELM_CHECK_WIDTYPE(obj, widtype2);
3597    Widget_Data *wd = elm_widget_data_get(obj);
3598    if (!wd) return;
3599    if (wd->content == content) return;
3600    if (wd->content) evas_object_del(wd->content);
3601    wd->content = content;
3602    if (content)
3603      {
3604         elm_widget_sub_object_add(obj, content);
3605         evas_object_event_callback_add(content, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
3606                                        _changed_size_hints, obj);
3607         edje_object_part_swallow(wd->frm, "elm.swallow.content", content);
3608      }
3609    _sizing_eval(obj);
3610 }
3611
3612 EAPI Evas_Object *
3613 elm_win_inwin_content_get(const Evas_Object *obj)
3614 {
3615    ELM_CHECK_WIDTYPE(obj, widtype2) NULL;
3616    Widget_Data *wd = elm_widget_data_get(obj);
3617    if (!wd) return NULL;
3618    return wd->content;
3619 }
3620
3621 EAPI Evas_Object *
3622 elm_win_inwin_content_unset(Evas_Object *obj)
3623 {
3624    ELM_CHECK_WIDTYPE(obj, widtype2) NULL;
3625    Widget_Data *wd = elm_widget_data_get(obj);
3626    if (!wd) return NULL;
3627    if (!wd->content) return NULL;
3628    Evas_Object *content = wd->content;
3629    elm_widget_sub_object_del(obj, wd->content);
3630    evas_object_event_callback_del_full(wd->content,
3631                                        EVAS_CALLBACK_CHANGED_SIZE_HINTS,
3632                                        _changed_size_hints, obj);
3633    edje_object_part_unswallow(wd->frm, wd->content);
3634    wd->content = NULL;
3635    return content;
3636 }
3637
3638 EAPI Eina_Bool
3639 elm_win_socket_listen(Evas_Object *obj, const char *svcname, int svcnum, Eina_Bool svcsys)
3640 {
3641
3642    Elm_Win *win;
3643
3644    ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
3645    win = elm_widget_data_get(obj);
3646    if (!win) return EINA_FALSE;
3647    if (!win->ee) return EINA_FALSE;
3648
3649    if(!ecore_evas_extn_socket_listen(win->ee, svcname, svcnum, svcsys))
3650      return EINA_FALSE;
3651
3652    return EINA_TRUE;
3653 }
3654
3655 /* windowing spcific calls - shall we do this differently? */
3656
3657 static Ecore_X_Window
3658 _elm_ee_win_get(const Evas_Object *obj)
3659 {
3660    if (!obj) return 0;
3661 #ifdef HAVE_ELEMENTARY_X
3662    Ecore_Evas *ee = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
3663    if (ee) return (Ecore_X_Window)ecore_evas_window_get(ee);
3664 #endif
3665    return 0;
3666 }
3667
3668 EAPI Ecore_X_Window
3669 elm_win_xwindow_get(const Evas_Object *obj)
3670 {
3671    Elm_Win *win;
3672    const char *type;
3673
3674    if (!obj) return 0;
3675    type = elm_widget_type_get(obj);
3676    if ((!type) || (type != widtype)) return _elm_ee_win_get(obj);
3677    win = elm_widget_data_get(obj);
3678    if (!win) return 0;
3679 #ifdef HAVE_ELEMENTARY_X
3680    if (win->xwin) return win->xwin;
3681    if (win->parent) return elm_win_xwindow_get(win->parent);
3682 #endif
3683    return 0;
3684 }