tizen 2.4 release
[framework/uifw/e17-mod-tizen-comp.git] / src / e_mod_comp_object.c
1 #include "e_mod_comp_shared_types.h"
2 #include "e_mod_comp_debug.h"
3 #include "e_mod_comp.h"
4
5 #ifdef _F_BORDER_CLIP_TO_ZONE_
6 #undef _F_BORDER_CLIP_TO_ZONE_
7 #endif
8 #define _F_BORDER_CLIP_TO_ZONE_ 0
9
10 /* externally accessible functions */
11 EAPI E_Comp_Object *
12 e_mod_comp_obj_add(E_Comp_Win    *cw,
13                    E_Comp_Canvas *canvas)
14 {
15    E_Comp_Object *co;
16    co = E_NEW(E_Comp_Object, 1);
17    E_CHECK_RETURN(co, 0);
18    if ((!cw->input_only) && (!cw->invalid))
19      {
20         if (_comp_mod->conf->use_hwc)
21           {
22              co->hwc.mask_rect = evas_object_rectangle_add(canvas->evas);
23 #if DEBUG_HWC_COLOR
24              evas_object_color_set(co->hwc.mask_rect, 50, 0, 0, 50);
25 #else
26              evas_object_color_set(co->hwc.mask_rect, 0, 0, 0, 0);
27 #endif
28              evas_object_render_op_set(co->hwc.mask_rect, EVAS_RENDER_COPY);
29              evas_object_hide(co->hwc.mask_rect);
30           }
31         co->shadow = edje_object_add(canvas->evas);
32         co->img = evas_object_image_filled_add(canvas->evas);
33
34         if ((!co->shadow) || (!co->img))
35           {
36              ELBF(ELBT_COMP, 0, e_mod_comp_util_client_xid_get(cw),
37                   "%15.15s|ERROR shadow:%p img:%p evas:%p argb:%d canvas_num:%d",
38                   "OBJECT_CREATE", co->shadow, co->img,
39                   canvas->evas, cw->argb, canvas->num);
40           }
41
42         E_Comp_Layer *ly = e_mod_comp_canvas_layer_get(canvas, "comp");
43         if (ly)
44           {
45              e_mod_comp_layer_populate(ly, co->shadow);
46              if (_comp_mod->conf->use_hwc)
47                {
48                   e_mod_comp_layer_populate(ly, co->hwc.mask_rect);
49                }
50
51              ELBF(ELBT_COMP, 0, e_mod_comp_util_client_xid_get(cw),
52                   "%15.15s|OK!! layer shadow:%p img:%p evas:%p argb:%d canvas_num:%d ly:%p",
53                   "OBJECT_CREATE", co->shadow, co->img,
54                   canvas->evas, cw->argb, canvas->num, ly);
55           }
56         else
57           {
58              ELBF(ELBT_COMP, 0, e_mod_comp_util_client_xid_get(cw),
59                   "%15.15s|ERROR shadow:%p img:%p evas:%p argb:%d canvas_num:%d ly:%p",
60                   "OBJECT_CREATE", co->shadow, co->img,
61                   canvas->evas, cw->argb, canvas->num, ly);
62           }
63
64         evas_object_image_colorspace_set(co->img, EVAS_COLORSPACE_ARGB8888);
65         if (cw->argb) evas_object_image_alpha_set(co->img, 1);
66         else evas_object_image_alpha_set(co->img, 0);
67      }
68    else
69      {
70         co->shadow = evas_object_rectangle_add(canvas->evas);
71
72         if (!co->shadow)
73           {
74              ELBF(ELBT_COMP, 0, e_mod_comp_util_client_xid_get(cw),
75                   "%15.15s|ERROR shadow:%p evas:%p canvas_num:%d",
76                   "OBJECT_CREATE", co->shadow, canvas->evas,
77                   canvas->num);
78           }
79         else
80           {
81              E_Comp_Layer *ly = e_mod_comp_canvas_layer_get(canvas, "comp");
82              if (ly)
83                e_mod_comp_layer_populate(ly, co->shadow);
84           }
85         evas_object_color_set(co->shadow, 0, 0, 0, 0);
86      }
87
88    co->canvas = canvas;
89    co->zone = canvas->zone;
90    return co;
91 }
92
93 EAPI void
94 e_mod_comp_obj_del(E_Comp_Object *co)
95 {
96    E_Comp_Layer *ly = e_mod_comp_canvas_layer_get(co->canvas, "comp");
97    if (ly) e_layout_unpack(co->shadow);
98
99    if (_comp_mod->conf->use_hwc)
100      {
101         if (co->hwc.mask_rect)
102           {
103              evas_object_del(co->hwc.mask_rect);
104              co->hwc.mask_rect = NULL;
105           }
106       }
107
108    if (co->img_mirror)
109      {
110         Evas_Object *o;
111         EINA_LIST_FREE(co->img_mirror, o)
112           {
113              if (co->xim) evas_object_image_data_set(o, NULL);
114              evas_object_event_callback_del(o, EVAS_CALLBACK_DEL,
115                                             e_mod_comp_cb_win_mirror_del);
116              evas_object_del(o);
117           }
118      }
119    if (co->xim)
120      {
121         evas_object_image_data_set(co->img, NULL);
122         ecore_x_image_free(co->xim);
123         co->xim = NULL;
124      }
125    if (co->clipper)
126      {
127         evas_object_del(co->clipper);
128         co->clipper = NULL;
129      }
130    if (co->img)
131      {
132         evas_object_del(co->img);
133         co->img = NULL;
134      }
135    if (co->transp.offset)
136      {
137         evas_object_del(co->transp.offset);
138         co->transp.offset = NULL;
139      }
140    if (co->transp.rect)
141      {
142         evas_object_del(co->transp.rect);
143         co->transp.rect = NULL;
144      }
145    if (co->shadow)
146      {
147         evas_object_del(co->shadow);
148         co->shadow = NULL;
149      }
150    E_FREE(co);
151 }
152
153 EAPI Eina_List *
154 e_mod_comp_win_comp_objs_add(E_Comp_Win *cw)
155 {
156    Eina_List *l, *objs = NULL;
157    E_Comp_Canvas *canvas;
158    E_Comp_Object *co;
159
160    EINA_LIST_FOREACH(cw->c->canvases, l, canvas)
161      {
162         co = e_mod_comp_obj_add(cw, canvas);
163         if (!co)
164           {
165              e_mod_comp_win_comp_objs_del(cw, objs);
166              return NULL;
167           }
168         objs = eina_list_append(objs, co);
169      }
170    return objs;
171 }
172
173 EAPI void
174 e_mod_comp_win_comp_objs_del(E_Comp_Win *cw,
175                              Eina_List  *objs)
176 {
177    E_Comp_Object *co;
178    EINA_LIST_FREE(objs, co) e_mod_comp_obj_del(co);
179 }
180
181 EAPI void
182 e_mod_comp_win_comp_objs_move(E_Comp_Win *cw,
183                               int         x,
184                               int         y)
185 {
186    Eina_List *l;
187    E_Comp_Object *co;
188    E_Comp_Layer *ly;
189
190    E_Comp_Canvas *canvas, *ly_canvas = NULL;
191    E_Comp_Layer *eff_ly;
192    E_Comp_Effect_Object *eff_obj = NULL;
193    Eina_Bool eff_run = EINA_FALSE;
194    canvas = eina_list_nth(cw->c->canvases, 0);
195    eff_ly = e_mod_comp_canvas_layer_get(canvas, "effect");
196    eff_run = e_mod_comp_layer_effect_get(eff_ly);
197 #ifdef _F_USE_BORDER_TRANSFORM_
198    if ((cw->bd) && e_border_transform_enable_get(cw->bd))
199      {
200         e_border_transform_get(cw->bd, &x, &y, 0, 0, 0);
201      }
202 #endif /* end of _F_USE_BORDER_TRANSFORM_ */
203    if (eff_run)
204      {
205         /* do not change position of the mini-mode window effect object
206          * during effect to avoid unnecessary move around screen.
207          * TODO: Move INSET check code to effect.c file.
208          */
209         if (!STATE_INSET_CHECK(cw))
210           {
211              eff_obj = e_mod_comp_layer_effect_obj_get(eff_ly, cw->win);
212              if (eff_obj) ly_canvas = eff_ly->canvas;
213           }
214      }
215
216    EINA_LIST_FOREACH(cw->objs, l, co)
217      {
218         int zx = 0, zy = 0;
219         if (!co) continue;
220         if (!co->shadow) continue;
221         if (co->zone)
222           {
223              zx = co->zone->x;
224              zy = co->zone->y;
225           }
226
227         ly = e_mod_comp_canvas_layer_get(co->canvas, "comp");
228         if (ly)
229           {
230           e_layout_child_move(co->shadow, x - zx, y - zy);
231              if (_comp_mod->conf->use_hwc)
232                {
233                   e_layout_child_move(co->hwc.mask_rect, x - zx, y - zy);
234                }
235           }
236         else
237           {
238           evas_object_move(co->shadow, x - zx, y - zy);
239              if (_comp_mod->conf->use_hwc)
240                {
241                   evas_object_move(co->hwc.mask_rect, x - zx, y - zy);
242                }
243           }
244 #if MOVE_IN_EFFECT
245         /* to show moving window while effect, we should also update effect object */
246         if (eff_obj)
247           {
248              if (ly_canvas == co->canvas)
249                e_layout_child_move(eff_obj->edje, x -zx, y - zy);
250           }
251 #else
252         if ((eff_obj) && (TYPE_QUICKPANEL_CHECK(cw)))
253           {
254              if (ly_canvas == co->canvas)
255                e_layout_child_move(eff_obj->edje, x -zx, y - zy);
256           }
257 #endif
258
259 #if _F_BORDER_CLIP_TO_ZONE_
260         if ((cw->visible) && (cw->bd) && (co->zone) &&
261             (!cw->input_only) && (!cw->invalid) &&
262             E_INTERSECTS(co->zone->x, co->zone->y,
263                          co->zone->w, co->zone->h,
264                          cw->x, cw->y, cw->w, cw->h))
265           {
266              if (!(E_CONTAINS(co->zone->x, co->zone->y,
267                               co->zone->w, co->zone->h,
268                               cw->x, cw->y, cw->w, cw->h)))
269                {
270                   int _x, _y, _w, _h;
271                   _x = x - zx; _y = y - zy;
272                   _w = cw->pw; _h = cw->ph;
273
274                   E_RECTS_CLIP_TO_RECT(_x, _y, _w, _h,
275                                        0, 0, co->zone->w, co->zone->h);
276                   if (!co->clipper)
277                     {
278                        co->clipper = evas_object_rectangle_add(co->canvas->evas);
279                        evas_object_clip_set(co->shadow, co->clipper);
280                        /* check to see if a given object exists on the zone which is
281                         * equal to its border. if it is, the clipper will be shown.
282                         * otherwise, the clipper will be invisible.
283                         */
284                        if (cw->bd->zone == co->zone)
285                          evas_object_show(co->clipper);
286                     }
287                   if (ly)
288                     {
289                        e_layout_child_move(co->clipper, _x, _y);
290                        e_layout_child_resize(co->clipper, _w, _h);
291                     }
292                   else
293                     {
294                        evas_object_move(co->clipper, _x, _y);
295                        evas_object_resize(co->clipper, _w, _h);
296                     }
297                }
298              else
299                {
300                   if (co->clipper)
301                     {
302                        evas_object_hide(co->clipper);
303                        evas_object_clip_unset(co->shadow);
304                        evas_object_del(co->clipper);
305                        co->clipper = NULL;
306                     }
307                }
308           }
309 #endif
310      }
311 }
312
313 EAPI void
314 e_mod_comp_win_comp_objs_resize(E_Comp_Win *cw,
315                                 int         w,
316                                 int         h)
317 {
318    Eina_List *l;
319    E_Comp_Object *co;
320    E_Comp_Layer *ly;
321 #ifdef _F_USE_BORDER_TRANSFORM_
322    if ((cw->bd) && e_border_transform_enable_get(cw->bd))
323      {
324         e_border_transform_get(cw->bd, 0, 0, &w, &h, 0);
325      }
326 #endif /* end of _F_USE_BORDER_TRANSFORM_ */
327    EINA_LIST_FOREACH(cw->objs, l, co)
328      {
329         if (!co) continue;
330         if (!co->shadow) continue;
331         ly = e_mod_comp_canvas_layer_get(co->canvas, "comp");
332         if (ly)
333           {
334           e_layout_child_resize(co->shadow, w, h);
335              if (_comp_mod->conf->use_hwc)
336                {
337                   e_layout_child_resize(co->hwc.mask_rect, w, h);
338                }
339           }
340         else
341           {
342           evas_object_resize(co->shadow, w, h);
343              if (_comp_mod->conf->use_hwc)
344                {
345                   evas_object_resize(co->hwc.mask_rect, w, h);
346                }
347           }
348      }
349 }
350
351 EAPI void
352 e_mod_comp_win_comp_objs_img_resize(E_Comp_Win *cw,
353                                     int         w,
354                                     int         h)
355 {
356    Eina_List *l;
357    E_Comp_Object *co;
358    EINA_LIST_FOREACH(cw->objs, l, co)
359      {
360         if (!co) continue;
361         if (!co->img) continue;
362         evas_object_image_size_set(co->img, w, h);
363      }
364 }
365
366 EAPI void
367 e_mod_comp_win_comp_objs_img_init(E_Comp_Win *cw)
368 {
369    Eina_List *l, *ll;
370    E_Comp_Object *co;
371    Evas_Object *o;
372    EINA_LIST_FOREACH(cw->objs, l, co)
373      {
374         if (!co) continue;
375         if (co->native) continue;
376         Evas_Native_Surface ns;
377         ns.version = EVAS_NATIVE_SURFACE_VERSION;
378         ns.type = EVAS_NATIVE_SURFACE_X11;
379         ns.data.x11.visual = cw->vis;
380         ns.data.x11.pixmap = cw->pixmap;
381         if (!cw->argb)
382           evas_object_render_op_set(co->img, EVAS_RENDER_COPY);
383         evas_object_image_native_surface_set(co->img, &ns);
384         EINA_LIST_FOREACH(co->img_mirror, ll, o)
385           {
386              evas_object_image_native_surface_set(o, &ns);
387           }
388         evas_object_image_data_update_add(co->img, 0, 0, cw->pw, cw->ph);
389         co->native = 1;
390      }
391 }
392
393 EAPI void
394 e_mod_comp_win_comp_objs_img_deinit(E_Comp_Win *cw)
395 {
396    Eina_List *l, *ll;
397    E_Comp_Object *co;
398    Evas_Object *o;
399    EINA_LIST_FOREACH(cw->objs, l, co)
400      {
401         if (!co) continue;
402         if (!co->native) continue;
403         evas_object_image_native_surface_set(co->img, NULL);
404         co->native = 0;
405         EINA_LIST_FOREACH(co->img_mirror, ll, o)
406           {
407              if (!o) continue;
408              evas_object_image_native_surface_set(o, NULL);
409           }
410      }
411 }
412
413 EAPI void
414 e_mod_comp_win_comp_objs_xim_free(E_Comp_Win *cw)
415 {
416    Eina_List *l, *ll;
417    E_Comp_Object *co;
418    Evas_Object *o;
419    EINA_LIST_FOREACH(cw->objs, l, co)
420      {
421         if (!co) continue;
422         if (!co->xim) continue;
423         evas_object_image_size_set(co->img, 1, 1);
424         evas_object_image_data_set(co->img, NULL);
425         ecore_x_image_free(co->xim);
426         co->xim = NULL;
427         EINA_LIST_FOREACH(co->img_mirror, ll, o)
428           {
429              evas_object_image_size_set(o, 1, 1);
430              evas_object_image_data_set(o, NULL);
431           }
432      }
433 }
434
435 EAPI void
436 e_mod_comp_win_comp_objs_img_pass_events_set(E_Comp_Win *cw,
437                                              Eina_Bool   set)
438 {
439    Eina_List *l;
440    E_Comp_Object *co;
441    EINA_LIST_FOREACH(cw->objs, l, co)
442      {
443         if (!co) continue;
444         if (!co->img) continue;
445         evas_object_pass_events_set(co->img, set);
446      }
447 }
448
449 EAPI void
450 e_mod_comp_win_comp_objs_pass_events_set(E_Comp_Win *cw,
451                                          Eina_Bool   set)
452 {
453    Eina_List *l;
454    E_Comp_Object *co;
455    EINA_LIST_FOREACH(cw->objs, l, co)
456      {
457         if (!co) continue;
458         if (!co->shadow) continue;
459         evas_object_pass_events_set(co->shadow, set);
460      }
461 }
462
463 EAPI void
464 e_mod_comp_win_comp_objs_img_alpha_set(E_Comp_Win *cw,
465                                        Eina_Bool   alpha)
466 {
467    Eina_List *l, *ll;
468    E_Comp_Object *co;
469    Evas_Object *o;
470    EINA_LIST_FOREACH(cw->objs, l, co)
471      {
472         if (!co) continue;
473         if (!co->img) continue;
474         evas_object_image_alpha_set(co->img, alpha);
475         EINA_LIST_FOREACH(co->img_mirror, ll, o)
476           {
477              evas_object_image_alpha_set(o, alpha);
478           }
479      }
480 }
481
482 EAPI void
483 e_mod_comp_win_comp_objs_img_size_set(E_Comp_Win *cw,
484                                       int         w,
485                                       int         h)
486 {
487    Eina_List *l, *ll;
488    E_Comp_Object *co;
489    Evas_Object *o;
490    EINA_LIST_FOREACH(cw->objs, l, co)
491      {
492         if (!co) continue;
493         if (!co->img) continue;
494         evas_object_image_size_set(co->img, w, h);
495         EINA_LIST_FOREACH(co->img_mirror, ll, o)
496           {
497              evas_object_image_size_set(o, w, h);
498           }
499      }
500 }
501
502 EAPI void
503 e_mod_comp_win_comp_objs_img_data_update_add(E_Comp_Win *cw,
504                                              int         x,
505                                              int         y,
506                                              int         w,
507                                              int         h)
508 {
509    Eina_List *l, *ll;
510    E_Comp_Object *co;
511    Evas_Object *o;
512
513    E_Comp_Canvas *canvas, *ly_canvas = NULL;
514    E_Comp_Layer *ly;
515    E_Comp_Effect_Object *eff_obj = NULL;
516    Eina_Bool eff_run = EINA_FALSE;
517    canvas = eina_list_nth(cw->c->canvases, 0);
518    ly = e_mod_comp_canvas_layer_get(canvas, "effect");
519    eff_run = e_mod_comp_layer_effect_get(ly);
520    if (eff_run)
521      {
522         eff_obj = e_mod_comp_layer_effect_obj_get(ly, cw->win);
523         if (eff_obj) ly_canvas = ly->canvas;
524      }
525
526    EINA_LIST_FOREACH(cw->objs, l, co)
527      {
528         if (!co) continue;
529         if (!co->img) continue;
530
531         /* viewport culling:
532          * Do nothing if an object is not located on E_Zone.
533          * A given object should not be marked if it is located on
534          * outer viewport. The evas doesn't perform viewport culling
535          * correctly.
536          */
537         if ((cw->visible) &&
538             !((cw->input_only) && (cw->invalid)) &&
539             E_INTERSECTS(co->zone->x, co->zone->y,
540                          co->zone->w, co->zone->h,
541                          cw->x, cw->y, cw->w, cw->h))
542           {
543              evas_object_image_data_update_add(co->img, x, y, w, h);
544
545              /* to show damaged window while effect, we should also update effect object */
546              if (eff_obj)
547                {
548                   if (ly_canvas == co->canvas)
549                     evas_object_image_data_update_add(eff_obj->img, x, y, w, h);
550                }
551           }
552
553         EINA_LIST_FOREACH(co->img_mirror, ll, o)
554           {
555              evas_object_image_data_update_add(o, x, y, w, h);
556           }
557      }
558 }
559
560 EAPI void
561 e_mod_comp_win_comp_objs_needxim_set(E_Comp_Win *cw,
562                                      Eina_Bool   need)
563 {
564    Eina_List *l;
565    E_Comp_Object *co;
566    EINA_LIST_FOREACH(cw->objs, l, co)
567      {
568         if (!co) continue;
569         if (need && co->xim) co->needxim = EINA_TRUE;
570      }
571 }
572
573 EAPI void
574 e_mod_comp_win_comp_objs_native_set(E_Comp_Win *cw,
575                                     Eina_Bool   native)
576 {
577    Eina_List *l;
578    E_Comp_Object *co;
579    EINA_LIST_FOREACH(cw->objs, l, co)
580      {
581         if (!co) continue;
582         co->native = native;
583      }
584 }
585
586 EAPI void
587 e_mod_comp_win_comp_objs_data_del(E_Comp_Win *cw,
588                                   const char *key)
589 {
590    Eina_List *l;
591    E_Comp_Object *co;
592    EINA_LIST_FOREACH(cw->objs, l, co)
593      {
594         if (!co) continue;
595         evas_object_data_del(co->shadow, key);
596      }
597 }
598
599 EAPI void
600 e_mod_comp_win_comp_objs_data_set(E_Comp_Win *cw,
601                                   const char *key,
602                                   const void *data)
603 {
604    Eina_List *l;
605    E_Comp_Object *co;
606    EINA_LIST_FOREACH(cw->objs, l, co)
607      {
608         if (!co) continue;
609         if (!co->shadow) continue;
610         evas_object_data_set(co->shadow, key, data);
611      }
612 }
613
614 EAPI void
615 e_mod_comp_win_comp_objs_show(E_Comp_Win *cw)
616 {
617    Eina_List *l;
618    E_Comp_Object *co;
619    Eina_Bool eff = EINA_FALSE;
620    EINA_LIST_FOREACH(cw->objs, l, co)
621      {
622         if (!co) continue;
623         if ((!cw->update) &&
624             (cw->visible) &&
625             (cw->dmg_updates >= 1))
626           {
627              if (!evas_object_visible_get(co->shadow) &&
628                  !(cw->animate_hide))
629                {
630                   if (!cw->hidden_override)
631                     {
632                        ELBF(ELBT_COMP, 0, e_mod_comp_util_client_xid_get(cw),
633                             "[comp_objs_show] win:0x%07x name:%s",
634                             cw->bd ? cw->bd->client.win : cw->win,
635                             cw->bd ? cw->bd->client.netwm.name : NULL);
636
637                        evas_object_show(co->shadow);
638
639                        if (_comp_mod->conf->use_hwc)
640                          {
641                             cw->hwc.set_drawable = EINA_TRUE;
642                          }
643                     }
644                   else
645                     e_mod_comp_bg_win_handler_update(cw);
646
647                   if (!cw->hidden_override)
648                     eff = EINA_TRUE;
649                }
650           }
651      }
652
653    if (eff) cw->c->effect_funcs.win_show(cw);
654 }
655
656 /**
657  * It is possible that the WM can receive a border show event immediatly
658  * after getting a border hide event such as indicator hide/show.
659  * In that case, if we use e_mod_comp_win_objs_show() function then we
660  * don't append showing EDJE signal because a shadow object of given window
661  * is still visible state. The hide_done callback can make object to hide.
662  * Thus the WM has to append showing EDJE signal into the job queue
663  * to show a shadow object of given window.
664  */
665 EAPI void
666 e_mod_comp_win_comp_objs_force_show(E_Comp_Win *cw)
667 {
668    Eina_List *l;
669    E_Comp_Object *co;
670    Eina_Bool eff = EINA_FALSE;
671    EINA_LIST_FOREACH(cw->objs, l, co)
672      {
673         if (!co) continue;
674         if (!cw->animate_hide)
675           {
676              if (!cw->hidden_override)
677                {
678                   if (!evas_object_visible_get(co->shadow))
679                     {
680                        ELBF(ELBT_COMP, 0, e_mod_comp_util_client_xid_get(cw),
681                             "[comp_objs_force_show] win:0x%07x name:%s",
682                             cw->bd ? cw->bd->client.win : cw->win,
683                             cw->bd ? cw->bd->client.netwm.name : NULL);
684
685                        evas_object_show(co->shadow);
686
687                        if (_comp_mod->conf->use_hwc)
688                          {
689                             cw->hwc.set_drawable = EINA_TRUE;
690                          }
691                     }
692                   eff = EINA_TRUE;
693                }
694              else
695                e_mod_comp_bg_win_handler_update(cw);
696           }
697      }
698
699    if (eff) cw->c->effect_funcs.win_show(cw);
700 }
701
702 EAPI void
703 e_mod_comp_win_comp_objs_hide(E_Comp_Win *cw)
704 {
705    Eina_List *l;
706    E_Comp_Object *co;
707    EINA_LIST_FOREACH(cw->objs, l, co)
708      {
709         if (!co) continue;
710         if (!co->shadow) continue;
711
712         ELBF(ELBT_COMP, 0, e_mod_comp_util_client_xid_get(cw),
713              "[comp_objs_hide] win:0x%07x name:%s",
714              cw->bd ? cw->bd->client.win : cw->win,
715              cw->bd ? cw->bd->client.netwm.name : NULL);
716
717         evas_object_hide(co->shadow);
718
719         if (_comp_mod->conf->use_hwc)
720           {
721              evas_object_hide(co->hwc.mask_rect);
722              cw->hwc.set_drawable = EINA_FALSE;
723           }
724      }
725 }
726
727 EAPI void
728 e_mod_comp_win_comp_objs_raise(E_Comp_Win *cw)
729 {
730    Eina_List *l;
731    E_Comp_Object *co;
732    E_Comp_Layer *ly;
733    EINA_LIST_FOREACH(cw->objs, l, co)
734      {
735         if (!co) continue;
736         e_layout_child_raise(co->shadow);
737         if (_comp_mod->conf->use_hwc)
738           {
739              e_layout_child_raise_above(co->hwc.mask_rect, co->shadow);
740           }
741         ly = e_mod_comp_canvas_layer_get(co->canvas, "comp");
742         if (ly) e_mod_comp_layer_bg_adjust(ly);
743      }
744 }
745
746 EAPI void
747 e_mod_comp_win_comp_objs_lower(E_Comp_Win *cw)
748 {
749    Eina_List *l;
750    E_Comp_Object *co;
751    E_Comp_Layer *ly;
752    EINA_LIST_FOREACH(cw->objs, l, co)
753      {
754         if (!co) continue;
755         e_layout_child_lower(co->shadow);
756         if (_comp_mod->conf->use_hwc)
757           {
758              e_layout_child_raise_above(co->hwc.mask_rect, co->shadow);
759           }
760
761         ly = e_mod_comp_canvas_layer_get(co->canvas, "comp");
762         if (ly) e_mod_comp_layer_bg_adjust(ly);
763      }
764 }
765
766 EAPI void
767 e_mod_comp_win_comp_objs_stack_above(E_Comp_Win *cw,
768                                      E_Comp_Win *cw2)
769 {
770    Eina_List *l, *ll;
771    E_Comp_Object *co, *co2;
772    E_Comp_Layer *ly;
773    EINA_LIST_FOREACH(cw->objs, l, co)
774      {
775         EINA_LIST_FOREACH(cw2->objs, ll, co2)
776           {
777              if (co->zone == co2->zone)
778                {
779                   e_layout_child_raise_above(co->shadow,
780                                              co2->shadow);
781                   if (_comp_mod->conf->use_hwc)
782                     {
783                        e_layout_child_raise_above(co->hwc.mask_rect, co->shadow);
784                        e_layout_child_raise_above(co2->hwc.mask_rect, co2->shadow);
785                     }
786                   ly = e_mod_comp_canvas_layer_get(co->canvas, "comp");
787                   if (ly) e_mod_comp_layer_bg_adjust(ly);
788                }
789           }
790      }
791 }
792
793 EAPI void
794 e_mod_comp_win_comp_objs_transparent_rect_update(E_Comp_Win *cw)
795 {
796    E_Comp_Object *co;
797    Eina_List *l;
798
799    EINA_LIST_FOREACH(cw->objs, l, co)
800      {
801         if (cw->transp_rect.use)
802           {
803              if (!co->transp.offset)
804                co->transp.offset = evas_object_rectangle_add(co->canvas->evas);
805              if (!co->transp.rect)
806                co->transp.rect = evas_object_rectangle_add(co->canvas->evas);
807
808              if ((co->transp.offset) && (co->transp.rect))
809                {
810                   evas_object_size_hint_min_set(co->transp.offset,
811                                                 cw->transp_rect.x,
812                                                 cw->transp_rect.y);
813                   evas_object_size_hint_min_set(co->transp.rect,
814                                                 cw->transp_rect.w,
815                                                 cw->transp_rect.h);
816                   evas_object_color_set(co->transp.offset, 0, 0, 0, 0);
817                   evas_object_color_set(co->transp.rect, 0, 0, 0, 0);
818                   evas_object_render_op_set(co->transp.rect, EVAS_RENDER_COPY);
819
820                   if (co->shadow)
821                     {
822                        if (edje_object_part_exists(co->shadow, "e.swallow.transp.offset"))
823                          {
824                             edje_object_part_swallow(co->shadow,
825                                                      "e.swallow.transp.offset",
826                                                      co->transp.offset);
827                          }
828
829                        if (edje_object_part_exists(co->shadow, "e.swallow.transp.rect"))
830                          {
831                             edje_object_part_swallow(co->shadow,
832                                                      "e.swallow.transp.rect",
833                                                      co->transp.rect);
834                          }
835                     }
836                }
837           }
838         else
839           {
840              if (co->transp.offset)
841                {
842                   if (co->shadow)
843                     {
844                        if (edje_object_part_exists(co->shadow, "e.swallow.transp.offset"))
845                          {
846                             edje_object_part_unswallow(co->shadow,
847                                                        co->transp.offset);
848                          }
849                     }
850                   evas_object_size_hint_min_set(co->transp.offset, 0, 0);
851                   evas_object_color_set(co->transp.offset, 0, 0, 0, 0);
852                   evas_object_del(co->transp.offset);
853                   co->transp.offset = NULL;
854                }
855              if (co->transp.rect)
856                {
857                   if (co->shadow)
858                     {
859                        if (edje_object_part_exists(co->shadow, "e.swallow.transp.rect"))
860                          {
861                             edje_object_part_unswallow(co->shadow,
862                                                        co->transp.rect);
863                          }
864                     }
865                   evas_object_size_hint_min_set(co->transp.rect, 0, 0);
866                   evas_object_color_set(co->transp.rect, 0, 0, 0, 0);
867                   evas_object_render_op_set(co->transp.rect, EVAS_RENDER_BLEND);
868                   evas_object_del(co->transp.rect);
869                   co->transp.rect = NULL;
870                }
871           }
872      }
873
874 #ifdef _F_USE_BORDER_TRANSFORM_
875    e_mod_comp_win_comp_objs_img_transform_set(cw, EINA_TRUE);
876 #endif
877 }
878
879 EAPI void
880 e_mod_comp_win_hwcomp_mask_objs_show(E_Comp_Win *cw)
881 {
882    E_CHECK(cw);
883
884    Eina_List *l;
885    E_Comp_Object *co;
886    EINA_LIST_FOREACH(cw->objs, l, co)
887      {
888         if (!co) continue;
889         if (!co->hwc.mask_rect) continue;
890         if (!co->shadow) continue;
891
892         e_layout_child_move(co->hwc.mask_rect, cw->x, cw->y);
893         e_layout_child_resize(co->hwc.mask_rect, cw->pw, cw->ph);
894         e_layout_child_raise_above(co->hwc.mask_rect, co->shadow);
895         evas_object_show(co->hwc.mask_rect);
896 #if DEBUG_HWC
897         ELBF(ELBT_COMP, 0, e_mod_comp_util_client_xid_get(cw),
898              "%15.15s| Show(x:%d, y:%d, w:%d, h:%d)", "Mask OBJ", cw->x, cw->y, cw->pw, cw->ph);
899 #endif
900      }
901 }
902
903 EAPI void
904 e_mod_comp_win_hwcomp_mask_objs_hide(E_Comp_Win *cw)
905 {
906    E_CHECK(cw);
907
908    Eina_List *l;
909    E_Comp_Object *co;
910    EINA_LIST_FOREACH(cw->objs, l, co)
911      {
912         if (!co) continue;
913         if (!co->hwc.mask_rect) continue;
914
915         evas_object_hide(co->hwc.mask_rect);
916 #if DEBUG_HWC
917         ELBF(ELBT_COMP, 0, e_mod_comp_util_client_xid_get(cw),
918              "%15.15s| Hide", "Mask OBJ");
919 #endif
920      }
921 }
922
923 #ifdef _F_USE_BORDER_TRANSFORM_
924 EAPI void
925 e_mod_comp_win_comp_objs_img_transform_set(E_Comp_Win *cw, Eina_Bool force)
926 {
927    if (!cw) return;
928    if (!cw->bd) return;
929    if (!cw->objs) return;
930
931    E_Comp_Object* co = NULL;
932    co = eina_list_nth(cw->objs, 0);
933
934    if ((!co) || (!co->shadow)) return;;
935
936    if (e_border_transform_enable_get(cw->bd))
937      {
938 #if 0
939         Evas_Map* m = evas_map_new(4);
940         evas_map_util_points_populate_from_object_full(m, co->shadow, 0);
941         evas_map_util_points_color_set(m, 255, 255, 255, 255);
942         E_Border_Transform_Vertex vertex = e_border_transform_vertex_get(cw->bd);
943
944         int i;
945         for (i = 0; i < 4; ++i)
946           {
947              evas_map_point_coord_set(m, i, vertex.vertexPosition[i][0],
948                                       vertex.vertexPosition[i][1],
949                                       vertex.vertexPosition[i][2]);
950           }
951
952         evas_object_map_set(co->shadow, m);
953         evas_object_map_enable_set(co->shadow, EINA_TRUE);
954         evas_map_free(m);
955 #else
956         int x, y, w, h;
957
958         e_border_transform_get(cw->bd, &x, &y, &w, &h, 0);
959         e_mod_comp_win_comp_objs_move(cw, x, y);
960         e_mod_comp_win_comp_objs_resize(cw,  w, h);
961
962         if (cw->transp_rect.use)
963           {
964              float dw = 0;
965              float dh = 0;
966
967              if (cw->bd->w == 0) return;
968              if (cw->bd->h == 0) return;
969
970              dw = (float)w / (float)cw->bd->w;
971              dh = (float)h / (float)cw->bd->h;
972
973              if (co->transp.offset)
974                {
975                   evas_object_size_hint_min_set(co->transp.offset,
976                                                 (int)((float)cw->transp_rect.x * dw),
977                                                 (int)((float)cw->transp_rect.y * dh));
978                }
979              if (co->transp.rect)
980                {
981                   evas_object_size_hint_min_set(co->transp.rect,
982                                                 (int)((float)cw->transp_rect.w * dw),
983                                                 (int)((float)cw->transp_rect.h * dh));
984                }
985           }
986 #endif
987      }
988    else
989      {
990         if (force) return;
991
992         e_mod_comp_win_comp_objs_move(cw, cw->bd->x, cw->bd->y);
993         e_mod_comp_win_comp_objs_resize(cw, cw->bd->w, cw->bd->h);
994
995         if (cw->transp_rect.use)
996           {
997              if (co->transp.offset)
998                 evas_object_size_hint_min_set(co->transp.offset,
999                                               cw->transp_rect.x,
1000                                               cw->transp_rect.y);
1001              if (co->transp.rect)
1002                 evas_object_size_hint_min_set(co->transp.rect,
1003                                               cw->transp_rect.w,
1004                                               cw->transp_rect.h);
1005           }
1006      }
1007 }
1008 #endif /* end of _F_USE_BORDER_TRANSFORM_ */