tizen 2.4 release
[framework/uifw/e17-mod-tizen-comp.git] / src / effect / effect.c
1 #include "e_mod_comp_shared_types.h"
2 #include "e_mod_comp.h"
3 #include "e_mod_comp_atoms.h"
4 #include "e_mod_comp_debug.h"
5 #include <X11/Xlib.h>
6
7 #include "effect.h"
8 #include "effect_image_launch.h"
9 #include "effect_win_rotation.h"
10
11 static Eina_List *effect_jobs = NULL;
12
13 /* local subsystem functions */
14 static E_Comp_Effect_Style   _effect_style_get(Ecore_X_Atom a);
15 static Eina_Bool             _state_send(E_Comp_Win *cw, Eina_Bool state);
16 static Eina_Bool             _effect_signal_del_intern(E_Comp_Win *cw, Evas_Object *obj, const char *name, Eina_Bool clean_all);
17 static E_Border             *_effect_policy_border_transient_for_border_top_get(E_Border *bd);
18 static void                  _effect_policy_border_transient_for_group_make(E_Border  *bd, Eina_List **list);
19
20 static void                  _effect_win_set(E_Comp_Win *cw, const char *emission, Eina_Bool send_ev, Eina_Bool show, Eina_Bool recreate);
21 static void                  _effect_win_lower(E_Comp_Win *cw, const char *emission, Eina_Bool recreate);
22 static void                  _effect_below_wins_set(E_Comp_Win *cw, Eina_Bool recreate);
23 static void                  _effect_below_floating_wins_set(E_Comp_Win *cw, Eina_Bool show, Eina_Bool recreate);
24 static void                  _effect_home_active_below_wins_set(E_Comp_Win *cw, Eina_Bool show, Eina_Bool   recreate);
25
26 static void                  _effect_above_wins_set(E_Comp_Win *cw, Eina_Bool show, Eina_Bool recreate);
27
28 static E_Comp_Effect_Object * _effect_object_control_layer_new(E_Comp_Layer *ly, E_Comp_Win *cw);
29 static void                  _effect_control_layer_set(E_Comp_Win *cw);
30
31 static Eina_Bool             _effect_show(E_Comp_Win *cw, Eina_Bool send_ev);
32 static Eina_Bool             _effect_hide(E_Comp_Win *cw, Eina_Bool send_ev);
33 static Eina_Bool             _effect_obj_win_set(E_Comp_Effect_Object *o, E_Comp_Win *cw);
34 static void                  _effect_obj_win_shape_rectangles_apply(E_Comp_Effect_Object *o, E_Comp_Win *cw);
35 static void                  _effect_obj_effect_done(void *data, Evas_Object *obj, const char *emission, const char *source);
36 static E_Comp_Effect_Object *_effect_obj_find(E_Comp_Win *cw);
37 static Eina_Bool             _effect_obj_win_shaped_check(int w, int h, const Ecore_X_Rectangle *rects, int num);
38 static void                  _effect_role_handle(E_Comp_Effect_Object *o);
39 static Eina_Bool             _effect_active_except_bd_check(E_Border *bd);
40 static void                  _effect_home_active_unset(E_Comp_Win *cw);
41
42 EAPI Eina_Bool
43 e_mod_comp_effect_mod_init(E_Comp *c)
44 {
45    E_CHECK_RETURN(c, 0);
46
47    c->effect_funcs.type_new = _effect_mod_type_new;
48    c->effect_funcs.type_free = _effect_mod_type_free;
49    c->effect_funcs.type_setup = _effect_mod_type_setup;
50    c->effect_funcs.state_setup = _effect_mod_state_setup;
51    c->effect_funcs.state_get = _effect_mod_state_get;
52    c->effect_funcs.state_set = _effect_mod_state_set;
53    c->effect_funcs.style_setup = _effect_mod_style_setup;
54    c->effect_funcs.style_get = _effect_mod_style_get;
55    c->effect_funcs.win_show = _effect_mod_win_show;
56    c->effect_funcs.win_hide = _effect_mod_win_hide;
57    c->effect_funcs.win_restack = _effect_mod_win_restack;
58    c->effect_funcs.signal_add = _effect_mod_signal_add;
59    c->effect_funcs.signal_del = _effect_mod_signal_del;
60    c->effect_funcs.jobs_clean = _effect_mod_jobs_clean;
61    c->effect_funcs.signal_flush = _effect_mod_signal_flush;
62    c->effect_funcs.animating_set = _effect_mod_animating_set;
63    c->effect_funcs.object_new = _effect_mod_object_new;
64    c->effect_funcs.object_free = _effect_mod_object_free;
65    c->effect_funcs.object_win_set = _effect_mod_object_win_set;
66    c->effect_funcs.above_wins_set = _effect_mod_above_wins_set;
67
68    c->effect_funcs.image_launch_new = _effect_mod_image_launch_new;
69    c->effect_funcs.image_launch_free = _effect_mod_image_launch_free;
70    c->effect_funcs.image_launch_handler_message = _effect_mod_image_launch_handler_message;
71    c->effect_funcs.image_launch_show = _effect_mod_image_launch_show;
72    c->effect_funcs.image_launch_hide = _effect_mod_image_launch_hide;
73    c->effect_funcs.image_launch_window_check = _effect_mod_image_launch_window_check;
74    c->effect_funcs.image_launch_running_check = _effect_mod_image_launch_running_check;
75    c->effect_funcs.image_launch_fake_show_done_check = _effect_mod_image_launch_fake_show_done_check;
76    c->effect_funcs.image_launch_window_set = _effect_mod_image_launch_window_set;
77    c->effect_funcs.image_launch_disable = _effect_mod_image_launch_disable;
78
79    c->effect_funcs.win_angle_get = _effect_mod_win_angle_get;
80    c->effect_funcs.zone_rotation_new = _effect_mod_zone_rotation_new;
81    c->effect_funcs.zone_rotation_free = _effect_mod_zone_rotation_free;
82    c->effect_funcs.zone_rotation_begin = _effect_mod_zone_rotation_begin;
83    c->effect_funcs.zone_rotation_end = _effect_mod_zone_rotation_end;
84    c->effect_funcs.zone_rotation_cancel = _effect_mod_zone_rotation_cancel;
85    c->effect_funcs.zone_rotation_do = _effect_mod_zone_rotation_do;
86    c->effect_funcs.zone_rotation_clear = _effect_mod_zone_rotation_clear;
87
88    return EINA_TRUE;
89 }
90
91 EAPI void
92 e_mod_comp_effect_mod_shutdown(E_Comp *c)
93 {
94    E_CHECK_RETURN(c, 0);
95
96    c->effect_funcs.type_new = NULL;
97    c->effect_funcs.type_free = NULL;
98    c->effect_funcs.type_setup = NULL;
99    c->effect_funcs.state_setup = NULL;
100    c->effect_funcs.state_get = NULL;
101    c->effect_funcs.state_set = NULL;
102    c->effect_funcs.style_setup = NULL;
103    c->effect_funcs.style_get = NULL;
104    c->effect_funcs.win_show = NULL;
105    c->effect_funcs.win_hide = NULL;
106    c->effect_funcs.win_restack = NULL;
107    c->effect_funcs.signal_add = NULL;
108    c->effect_funcs.signal_del = NULL;
109    c->effect_funcs.jobs_clean = NULL;
110    c->effect_funcs.signal_flush = NULL;
111    c->effect_funcs.animating_set = NULL;
112    c->effect_funcs.object_new = NULL;
113    c->effect_funcs.object_free = NULL;
114    c->effect_funcs.object_win_set = NULL;
115    c->effect_funcs.above_wins_set = NULL;
116
117    c->effect_funcs.image_launch_new = NULL;
118    c->effect_funcs.image_launch_free = NULL;
119    c->effect_funcs.image_launch_handler_message = NULL;
120    c->effect_funcs.image_launch_show = NULL;
121    c->effect_funcs.image_launch_hide = NULL;
122    c->effect_funcs.image_launch_window_check = NULL;
123    c->effect_funcs.image_launch_running_check = NULL;
124    c->effect_funcs.image_launch_fake_show_done_check = NULL;
125    c->effect_funcs.image_launch_window_set = NULL;
126    c->effect_funcs.image_launch_disable = NULL;
127
128    c->effect_funcs.win_angle_get = NULL;
129    c->effect_funcs.zone_rotation_new = NULL;
130    c->effect_funcs.zone_rotation_free = NULL;
131    c->effect_funcs.zone_rotation_begin = NULL;
132    c->effect_funcs.zone_rotation_end = NULL;
133    c->effect_funcs.zone_rotation_cancel = NULL;
134    c->effect_funcs.zone_rotation_do = NULL;
135    c->effect_funcs.zone_rotation_clear = NULL;
136 }
137
138 /* externally accessible functions */
139 E_Comp_Effect_Object *
140 _effect_mod_object_new(E_Comp_Layer *ly,
141                              E_Comp_Win   *cw,
142                              Eina_Bool recreate)
143 {
144    E_Comp_Effect_Object *o = NULL, *o2 = NULL;
145    Eina_Bool res;
146    E_CHECK_RETURN(ly, NULL);
147    E_CHECK_RETURN(cw, NULL);
148    traceBegin(TTRACE_TAG_WINDOW_MANAGER,"WM:COMP:EFFECT OBJECT NEW");
149
150    o2 = _effect_obj_find(cw);
151    if ((o2) && (recreate))
152      {
153         e_layout_unpack(o2->edje);
154         o2 = NULL;
155      }
156    /* TODO: clean up previous effect job */
157    E_CHECK_RETURN(!o2, NULL);
158
159    o = E_NEW(E_Comp_Effect_Object, 1);
160    E_CHECK_RETURN(o, NULL);
161
162    o->edje = edje_object_add(ly->canvas->evas);
163    E_CHECK_GOTO(o->edje, fail);
164
165    e_mod_comp_layer_populate(ly, o->edje);
166
167    evas_object_data_set(o->edje, "comp.effect_obj.ly", ly);
168    evas_object_data_set(o->edje, "comp.effect_obj.cwin",
169                         (void *)e_mod_comp_util_client_xid_get(cw));
170
171    res = _effect_obj_win_set(o, cw);
172    E_CHECK_GOTO(res, fail);
173
174    ly->objs = eina_list_append(ly->objs, o);
175
176    ELBF(ELBT_COMP, 0, o->cwin,
177         "%15.15s| OBJ_NEW %p", "EFFECT", o->edje);
178
179    traceEnd(TTRACE_TAG_WINDOW_MANAGER);
180    return o;
181
182 fail:
183    ELBF(ELBT_COMP, 0, e_mod_comp_util_client_xid_get(cw),
184         "%15.15s| OBJ_NEW Failed", "EFFECT");
185    if (o)
186      {
187         if (o->edje)
188           {
189              e_layout_unpack(o->edje);
190              evas_object_del(o->edje);
191           }
192         E_FREE(o);
193      }
194    traceEnd(TTRACE_TAG_WINDOW_MANAGER);
195    return NULL;
196 }
197
198 void
199 _effect_mod_object_free(E_Comp_Effect_Object *o)
200 {
201    E_CHECK(o);
202
203 #if SEND_LAUNCHING_DONE
204    if ((o->cwin) && (o->send_launching_done))
205      {
206         ecore_x_client_message32_send (o->cwin, ATOM_WINDOW_LAUNCHING_EFFECT_DONE,
207                                        ECORE_X_EVENT_MASK_WINDOW_CONFIGURE, 0, 0, 0, 0, 0);
208         e_msg_send("comp.message", "launching.done", o->cwin, NULL, NULL, NULL, NULL);
209      }
210 #endif
211
212    if ((o->cwin) && (o->ev_vis))
213      e_comp_event_src_visibility_send(o->cwin, o->show);
214
215    if ((o->edje) && (o->img))
216      edje_object_part_unswallow(o->edje, o->img);
217
218    if (o->img)
219      {
220         /* TODO: consider when using an xim */
221         evas_object_image_native_surface_set(o->img, NULL);
222         evas_object_image_size_set(o->img, 1, 1);
223         evas_object_image_data_set(o->img, NULL);
224         evas_object_hide(o->img);
225         evas_object_del(o->img);
226      }
227
228    if(o->edje && o->transp.rect)
229      {
230         edje_object_part_unswallow(o->edje,o->transp.rect);
231      }
232
233    if(o->edje && o->transp.offset)
234      {
235         edje_object_part_unswallow(o->edje,o->transp.offset);
236      }
237
238    if(o->transp.offset)
239      {
240         evas_object_del(o->transp.offset);
241         o->transp.offset=NULL;
242      }
243
244    if (o->transp.rect)
245      {
246         evas_object_del(o->transp.rect);
247         o->transp.rect=NULL;
248      }
249
250    if (o->pixmap)
251      ecore_x_pixmap_free(o->pixmap);
252
253    if (o->edje)
254      {
255         evas_object_data_del(o->edje, "comp.effect_obj.ly");
256         evas_object_data_del(o->edje, "comp.effect_obj.cwin");
257         evas_object_hide(o->edje);
258         evas_object_del(o->edje);
259      }
260
261    ELBF(ELBT_COMP, 0, o->cwin,
262         "%15.15s| OBJ_FREE", "EFFECT");
263
264    memset(o, 0, sizeof(E_Comp_Effect_Object));
265
266    E_FREE(o);
267 }
268
269 void
270 _effect_mod_object_win_set(E_Comp_Win *cw, const char *emission)
271 {
272    _effect_win_set(cw, emission, EINA_FALSE, EINA_FALSE, EINA_FALSE);
273 }
274
275 void
276 _effect_mod_above_wins_set(E_Comp_Win *cw, Eina_Bool show)
277 {
278    _effect_above_wins_set(cw, show, EINA_FALSE);
279 }
280
281 Eina_Bool
282 _effect_mod_signal_del(E_Comp_Win  *cw,
283                              Evas_Object *obj,
284                              const char  *name)
285 {
286    return _effect_signal_del_intern(cw, obj, name, EINA_FALSE);
287 }
288
289 Eina_Bool
290 _effect_mod_jobs_clean(E_Comp_Win  *cw,
291                              Evas_Object *obj,
292                              const char  *name)
293 {
294    return _effect_signal_del_intern(cw, obj, name, EINA_TRUE);
295 }
296
297 Eina_Bool
298 _effect_mod_signal_flush(void)
299 {
300    E_Comp_Effect_Job *job;
301    Eina_List *l;
302    E_Comp_Win *cw;
303    E_Comp_Layer *ly;
304    traceBegin(TTRACE_TAG_WINDOW_MANAGER,"WM:COMP:EFFECT SIGNAL FLUSH");
305
306    EINA_LIST_FOREACH(effect_jobs, l, job)
307      {
308         if (!job) continue;
309         if (job->emitted) continue;
310
311         if ((job->win) && (job->canvas))
312           {
313              if ((cw = e_mod_comp_win_find(job->win)))
314                {
315                   if (cw->animating)
316                     {
317                        ELBF(ELBT_COMP, 0, job->cwin,
318                             "%15.15s|     SIG_PEND:%s", "EFFECT",
319                             job->emission);
320                        continue;
321                     }
322                   else
323                     {
324                        _effect_mod_animating_set(cw->c, cw, EINA_TRUE);
325                        job->emitted = EINA_TRUE;
326
327                        edje_object_signal_emit(job->o, job->emission, job->src);
328
329                        ELBF(ELBT_COMP, 0, job->cwin,
330                             "%15.15s|     SIG_EMIT>%s", "EFFECT",
331                             job->emission);
332                     }
333                }
334              else
335                {
336                   ELBF(ELBT_COMP, 0, job->cwin,
337                        "%15.15s|     SIG_DEL :%s", "EFFECT",
338                        job->emission);
339
340                   /* remove this job if cw was already removed */
341                   effect_jobs = eina_list_remove(effect_jobs, job);
342                   E_FREE(job);
343                }
344           }
345         else
346           {
347              edje_object_signal_emit(job->o, job->emission, job->src);
348
349              ELBF(ELBT_COMP, 0, job->cwin,
350                   "%15.15s| OBJ SIG_EMIT>%s", "EFFECT",
351                   job->emission);
352
353              ly = evas_object_data_get(job->o, "comp.effect_obj.ly");
354              if (ly) e_mod_comp_layer_effect_set(ly, EINA_TRUE);
355
356              effect_jobs = eina_list_remove(effect_jobs, job);
357              E_FREE(job);
358           }
359      }
360
361    traceEnd(TTRACE_TAG_WINDOW_MANAGER);
362    return EINA_TRUE;
363 }
364
365 E_Comp_Effect_Type *
366 _effect_mod_type_new(void)
367 {
368    E_Comp_Effect_Type *t;
369    t = E_NEW(E_Comp_Effect_Type, 1);
370    E_CHECK_RETURN(t, 0);
371    t->animatable = EINA_TRUE;
372    return t;
373 }
374
375 void
376 _effect_mod_type_free(E_Comp_Effect_Type *type)
377 {
378    E_CHECK(type);
379    E_FREE(type);
380 }
381
382 Eina_Bool
383 _effect_mod_type_setup(E_Comp_Effect_Type *type,
384                              Ecore_X_Window win)
385 {
386    E_CHECK_RETURN(type, 0);
387    E_CHECK_RETURN(win, 0);
388
389    _effect_mod_state_setup(type, win);
390    _effect_mod_style_setup(type, win);
391
392    return EINA_TRUE;
393 }
394
395 Eina_Bool
396 _effect_mod_state_setup(E_Comp_Effect_Type *type,
397                               Ecore_X_Window win)
398 {
399    Atom type_ret = 0;
400    int ret, size_ret = 0;
401    unsigned long num_ret = 0, bytes = 0;
402    unsigned char *prop_ret = NULL;
403    Ecore_X_Display *dpy;
404    Eina_Bool is_ok;
405
406    E_CHECK_RETURN(type, 0);
407    E_CHECK_RETURN(win, 0);
408
409    dpy = ecore_x_display_get();
410    ret = XGetWindowProperty(dpy, win, ATOM_WINDOW_EFFECT_ENABLE, 0, LONG_MAX,
411                             False, ECORE_X_ATOM_CARDINAL, &type_ret, &size_ret,
412                             &num_ret, &bytes, &prop_ret);
413    if (ret == 0) // success
414      {
415         if (prop_ret && num_ret)
416           {
417              type->animatable =  prop_ret[0];
418              is_ok = EINA_TRUE;
419           }
420         else
421           is_ok = EINA_FALSE;
422      }
423    else // error
424      {
425         is_ok = EINA_FALSE;
426      }
427
428    if (prop_ret) XFree(prop_ret);
429    return is_ok;
430 }
431
432 Eina_Bool
433 _effect_mod_state_get(E_Comp_Effect_Type *type)
434 {
435    E_CHECK_RETURN(type, 0);
436    return type->animatable;
437 }
438
439 void
440 _effect_mod_state_set(E_Comp_Effect_Type *type, Eina_Bool state)
441 {
442    E_CHECK(type);
443    type->animatable = state;
444 }
445
446
447 Eina_Bool
448 _effect_mod_style_setup(E_Comp_Effect_Type *type,
449                               Ecore_X_Window win)
450 {
451    Ecore_X_Atom *atoms = NULL;
452    Eina_Bool res = EINA_FALSE;
453    int num = 0;
454
455    E_CHECK_RETURN(type, 0);
456    E_CHECK_RETURN(win, 0);
457
458    num = ecore_x_window_prop_atom_list_get
459            (win, ATOM_WINDOW_EFFECT_TYPE, &atoms);
460    E_CHECK_GOTO((num == 6), cleanup);
461    E_CHECK_GOTO(atoms, cleanup);
462
463    type->show     = _effect_style_get(atoms[0]);
464    type->hide     = _effect_style_get(atoms[1]);
465    type->restack  = _effect_style_get(atoms[2]);
466    type->rotation = _effect_style_get(atoms[3]);
467    type->focusin  = _effect_style_get(atoms[4]);
468    type->focusout = _effect_style_get(atoms[5]);
469
470    res = EINA_TRUE;
471
472 cleanup:
473    if (atoms) E_FREE(atoms);
474    return res;
475 }
476
477 E_Comp_Effect_Style
478 _effect_mod_style_get(E_Comp_Effect_Type *type,
479                             E_Comp_Effect_Kind kind)
480 {
481    E_Comp_Effect_Style res;
482    E_CHECK_RETURN(type, E_COMP_EFFECT_STYLE_NONE);
483    switch (kind)
484      {
485       case E_COMP_EFFECT_KIND_SHOW:     res = type->show;     break;
486       case E_COMP_EFFECT_KIND_HIDE:     res = type->hide;     break;
487       case E_COMP_EFFECT_KIND_RESTACK:  res = type->restack;  break;
488       case E_COMP_EFFECT_KIND_ROTATION: res = type->rotation; break;
489       case E_COMP_EFFECT_KIND_FOCUSIN:  res = type->focusin;  break;
490       case E_COMP_EFFECT_KIND_FOCUSOUT: res = type->focusout; break;
491       default: res = E_COMP_EFFECT_STYLE_NONE;                break;
492      }
493    return res;
494 }
495
496 #define _MAKE_EMISSION(f, x...) do { snprintf(emission, sizeof(emission), f, ##x); } while(0)
497
498 void
499 _effect_mod_win_restack(E_Comp_Win *cw,
500                               Eina_Bool   v1,
501                               Eina_Bool   v2)
502 {
503    Eina_Bool animatable = _effect_mod_state_get(cw->eff_type);
504    if (!((cw->c->animatable) && (animatable))) return;
505    if ((v1) == (v2)) return;
506
507    if ((!v1) && (v2))
508      _effect_show(cw, EINA_FALSE);
509    else
510      _effect_hide(cw, EINA_FALSE);
511
512    _effect_home_active_unset(cw);
513 }
514
515 void
516 _effect_mod_win_show(E_Comp_Win *cw)
517 {
518    Eina_Bool animatable = _effect_mod_state_get(cw->eff_type);
519    Eina_Bool res = EINA_FALSE;
520
521    if (cw->c->fake_image_launch)
522      {
523         if ((_effect_mod_image_launch_window_check(cw->c->eff_img, cw)) &&
524             (_effect_mod_image_launch_running_check(cw->c->eff_img)))
525           {
526              if (_effect_mod_image_launch_fake_show_done_check(cw->c->eff_img))
527                {
528 #if SEND_LAUNCHING_DONE
529                   _effect_mod_image_launch_window_set(cw->c->eff_img, cw->win);
530 #endif
531                   _effect_mod_image_launch_disable(cw->c->eff_img);
532                   goto postjob;
533                }
534              else
535                {
536                   _effect_mod_image_launch_window_set(cw->c->eff_img, cw->win);
537                   goto postjob;
538                }
539           }
540      }
541
542    if ((cw->c->animatable) && (animatable))
543      {
544         res = _effect_show(cw, EINA_TRUE);
545      }
546
547 postjob:
548    /* for the composite window */
549    _effect_mod_signal_add(cw, NULL, "e,state,visible,on,noeffect", "e");
550    e_mod_comp_comp_event_src_visibility_send(cw);
551    if (!res)
552      {
553         e_comp_event_src_visibility_send
554           (e_mod_comp_util_client_xid_get(cw), EINA_TRUE);
555      }
556
557    _effect_home_active_unset(cw);
558 }
559
560 void
561 _effect_mod_win_hide(E_Comp_Win *cw)
562 {
563    Eina_Bool animatable, vis;
564    Eina_Bool res = EINA_FALSE;
565
566    animatable = _effect_mod_state_get(cw->eff_type);
567    vis = e_mod_comp_util_win_visible_get(cw, EINA_TRUE);
568
569    ELBF(ELBT_COMP, 0, e_mod_comp_util_client_xid_get(cw),
570         "%15.15s| CHECK visible:%d cw->visible:%d a:%d", "EFFECT",
571         vis, cw->visible, animatable);
572
573    if ((cw->c->animatable) && (animatable) && (vis))
574      {
575         res = _effect_hide(cw, EINA_TRUE);
576      }
577
578    /* for the composite window */
579    _effect_mod_signal_add(cw, NULL, "e,state,visible,off,noeffect", "e");
580    e_mod_comp_comp_event_src_visibility_send(cw);
581    if (!res)
582      {
583         e_comp_event_src_visibility_send
584           (e_mod_comp_util_client_xid_get(cw), EINA_TRUE);
585      }
586
587    _effect_home_active_unset(cw);
588 }
589
590 Eina_Bool
591 _effect_mod_signal_add(E_Comp_Win  *cw,
592                              Evas_Object *o,
593                              const char  *emission,
594                              const char  *src)
595
596 {
597    Eina_List *l;
598    E_Comp *c = NULL;
599    E_Comp_Object *co;
600    E_Comp_Effect_Job *job = NULL;
601    size_t len;
602
603    E_CHECK_RETURN((cw || o), 0);
604    E_CHECK_RETURN(emission, 0);
605    E_CHECK_RETURN(src, 0);
606
607    if (cw)
608      {
609         c = cw->c;
610
611         EINA_LIST_FOREACH(cw->objs, l, co)
612           {
613              if (!co) continue;
614              if (!co->shadow) continue;
615
616              job = E_NEW(E_Comp_Effect_Job, 1);
617              if (!job) continue;
618
619              job->o = co->shadow;
620              job->win = cw->win;
621              job->cwin = e_mod_comp_util_client_xid_get(cw);
622              job->canvas = co->canvas;
623
624              len = sizeof(job->emission);
625              strncpy(job->emission, emission, len);
626              job->emission[len-1] = '\0';
627
628              len = sizeof(job->src);
629              strncpy(job->src, src, len);
630              job->src[len-1] = '\0';
631
632              effect_jobs = eina_list_append(effect_jobs, job);
633
634              e_mod_comp_hw_ov_win_msg_show
635                (E_COMP_LOG_TYPE_EFFECT,
636                "SIG_ADD 0x%x %s",
637                job->cwin, emission);
638           }
639      }
640    else
641      {
642         job = E_NEW(E_Comp_Effect_Job, 1);
643         if (job)
644           {
645              job->effect_obj = EINA_TRUE;
646              job->o = o;
647              job->win = 0;
648              job->cwin = (Ecore_X_Window)evas_object_data_get(o, "comp.effect_obj.cwin");
649
650              len = sizeof(job->emission);
651              strncpy(job->emission, emission, len);
652              job->emission[len-1] = '\0';
653
654              len = sizeof(job->src);
655              strncpy(job->src, src, len);
656              job->src[len-1] = '\0';
657
658              effect_jobs = eina_list_append(effect_jobs, job);
659           }
660      }
661
662    if (job)
663      {
664         ELBF(ELBT_COMP, 0, job->cwin,
665              "%15.15s| %s  SIG_ADD:%s", "EFFECT",
666              job->effect_obj ? "OBJ" : "   ",
667              emission);
668      }
669
670    return EINA_TRUE;
671 }
672
673 Eina_Bool
674 _effect_mod_animating_set(E_Comp *c,
675                                 E_Comp_Win *cw,
676                                 Eina_Bool set)
677 {
678    Eina_Bool state;
679    E_CHECK_RETURN(c, 0);
680    E_CHECK_GOTO(cw, postjob);
681
682    if (set)
683      {
684         if (cw->animating)
685           {
686              c->animating--;
687              _state_send(cw, EINA_FALSE);
688           }
689         state = EINA_TRUE;
690      }
691    else
692      {
693         state = EINA_FALSE;
694      }
695
696    cw->animating = state;
697    _state_send(cw, state);
698
699 postjob:
700    if (set) c->animating++;
701    else c->animating--;
702    return EINA_TRUE;
703 }
704
705 /* local subsystem functions */
706 static E_Comp_Effect_Style
707 _effect_style_get(Ecore_X_Atom a)
708 {
709    E_CHECK_RETURN(a, E_COMP_EFFECT_STYLE_NONE);
710
711    if      (a == ATOM_EFFECT_DEFAULT) return E_COMP_EFFECT_STYLE_DEFAULT;
712    else if (a == ATOM_EFFECT_NONE   ) return E_COMP_EFFECT_STYLE_NONE;
713    else if (a == ATOM_EFFECT_CUSTOM0) return E_COMP_EFFECT_STYLE_CUSTOM0;
714    else if (a == ATOM_EFFECT_CUSTOM1) return E_COMP_EFFECT_STYLE_CUSTOM1;
715    else if (a == ATOM_EFFECT_CUSTOM2) return E_COMP_EFFECT_STYLE_CUSTOM2;
716    else if (a == ATOM_EFFECT_CUSTOM3) return E_COMP_EFFECT_STYLE_CUSTOM3;
717    else if (a == ATOM_EFFECT_CUSTOM4) return E_COMP_EFFECT_STYLE_CUSTOM4;
718    else if (a == ATOM_EFFECT_CUSTOM5) return E_COMP_EFFECT_STYLE_CUSTOM5;
719    else if (a == ATOM_EFFECT_CUSTOM6) return E_COMP_EFFECT_STYLE_CUSTOM6;
720    else if (a == ATOM_EFFECT_CUSTOM7) return E_COMP_EFFECT_STYLE_CUSTOM7;
721    else if (a == ATOM_EFFECT_CUSTOM8) return E_COMP_EFFECT_STYLE_CUSTOM8;
722    else if (a == ATOM_EFFECT_CUSTOM9) return E_COMP_EFFECT_STYLE_CUSTOM9;
723
724    return E_COMP_EFFECT_STYLE_NONE;
725 }
726
727 static Eina_Bool
728 _state_send(E_Comp_Win *cw,
729             Eina_Bool state)
730 {
731    long d[5] = {0L, 0L, 0L, 0L, 0L};
732    Ecore_X_Window win;
733    E_CHECK_RETURN(cw, 0);
734
735    win = e_mod_comp_util_client_xid_get(cw);
736    E_CHECK_RETURN(win, 0);
737
738    if (state) d[0] = 1L;
739    else d[1] = 1L;
740
741    ecore_x_client_message32_send
742      (win, ATOM_WINDOW_EFFECT_CLIENT_STATE,
743      ECORE_X_EVENT_MASK_WINDOW_CONFIGURE,
744      d[0], d[1], d[2], d[3], d[4]);
745
746    return EINA_TRUE;
747 }
748
749 static Eina_Bool
750 _effect_signal_del_intern(E_Comp_Win  *cw,
751                           Evas_Object *obj,
752                           const char  *name,
753                           Eina_Bool    clean_all)
754 {
755    E_Comp_Effect_Job *job;
756    Eina_List *l;
757    EINA_LIST_FOREACH(effect_jobs, l, job)
758      {
759         if (!job) continue;
760         if (!job->emitted) continue;
761         if (!job->win) continue;
762         if (!job->canvas) continue;
763
764         Ecore_X_Window win = cw ? cw->win : 0;
765         if (job->win == win)
766           {
767              ELBF(ELBT_COMP, 0, job->cwin,
768                   "%15.15s|     SIG_DEL :%s", "EFFECT",
769                   job->emission);
770
771              e_mod_comp_hw_ov_win_msg_show
772                (E_COMP_LOG_TYPE_EFFECT,
773                "SIG_DEL 0x%x %s",
774                job->win, job->emission);
775
776              effect_jobs = eina_list_remove(effect_jobs, job);
777
778              E_FREE(job);
779
780              if (!clean_all) break;
781           }
782      }
783    return EINA_TRUE;
784 }
785
786 static void
787 _effect_win_transparent_rect( E_Comp_Win  *cw,
788                               E_Comp_Effect_Object *o,
789                               E_Comp_Layer *ly)
790 {
791    ELBF(ELBT_COMP, 0, e_mod_comp_util_client_xid_get(cw),
792         "%15.15s| TRANSP_RECT_UPDATE[%d, %d %d %d %d]", "EFFECT",
793         cw->transp_rect.use, cw->transp_rect.x, cw->transp_rect.y,
794         cw->transp_rect.w, cw->transp_rect.h);
795
796    if (cw->transp_rect.use)
797      {
798         int alpha = 0;
799         if (!o->transp.offset)
800            o->transp.offset = evas_object_rectangle_add(ly->canvas->evas);
801         if (!o->transp.rect)
802            o->transp.rect = evas_object_rectangle_add(ly->canvas->evas);
803
804         if ((o->transp.offset) && (o->transp.rect))
805           {
806 #ifdef _F_USE_BORDER_TRANSFORM_
807              if ((cw->bd) && (e_border_transform_enable_get(cw->bd)))
808                {
809                   float dw = 0;
810                   float dh = 0;
811                   if (cw->bd->w != 0 && cw->bd->h != 0)
812                     {
813                        int tw, th;
814                        e_border_transform_get(cw->bd, 0, 0, &tw, &th, 0);
815
816                        dw = (float)tw / (float)cw->bd->w;
817                        dh = (float)th / (float)cw->bd->h;
818
819                        if (o->transp.offset)
820                          {
821                             evas_object_size_hint_min_set(o->transp.offset,
822                                                           (int)((float)cw->transp_rect.x * dw),
823                                                           (int)((float)cw->transp_rect.y * dh));
824                          }
825                        if (o->transp.rect)
826                          {
827                             evas_object_size_hint_min_set(o->transp.rect,
828                                                           (int)((float)cw->transp_rect.w * dw),
829                                                           (int)((float)cw->transp_rect.h * dh));
830                          }
831                     }
832                }
833              else
834 #endif
835                {
836                   evas_object_size_hint_min_set(o->transp.offset,
837                                                 cw->transp_rect.x,
838                                                 cw->transp_rect.y);
839                   evas_object_size_hint_min_set(o->transp.rect,
840                                                 cw->transp_rect.w,
841                                                 cw->transp_rect.h);
842                }
843
844              evas_object_color_set(o->transp.offset, 0,0,0,0);
845              evas_object_color_set(o->transp.rect, 0,0,0,0);
846              evas_object_render_op_set(o->transp.rect, EVAS_RENDER_COPY);
847
848              if (o->edje)
849                {
850                   if (edje_object_part_exists(o->edje, "e.swallow.transp.offset"))
851                     {
852                        edje_object_part_swallow(o->edje,"e.swallow.transp.offset",o->transp.offset);
853                     }
854                   if (edje_object_part_exists(o->edje, "e.swallow.transp.rect"))
855                     {
856                        edje_object_part_swallow(o->edje,"e.swallow.transp.rect",o->transp.rect);
857                     }
858                }
859           }
860      }
861    else
862      {
863         if (o->transp.offset)
864           {
865              if (o->edje)
866                {
867                   if (edje_object_part_exists(o->edje, "e.swallow.transp.offset"))
868                     {
869                        edje_object_part_unswallow(o->edje, o->transp.offset);
870                     }
871                }
872              evas_object_size_hint_min_set(o->transp.offset, 0, 0);
873              evas_object_color_set(o->transp.offset, 0, 0, 0, 0);
874              evas_object_del(o->transp.offset);
875              o->transp.offset = NULL;
876           }
877         if (o->transp.rect)
878           {
879              if (o->edje)
880                {
881                   if (edje_object_part_exists(o->edje, "e.swallow.transp.rect"))
882                     {
883                        edje_object_part_unswallow(o->edje, o->transp.rect);
884                     }
885                }
886              evas_object_size_hint_min_set(o->transp.rect, 0, 0);
887              evas_object_color_set(o->transp.rect, 0, 0, 0, 0);
888              evas_object_render_op_set(o->transp.rect, EVAS_RENDER_BLEND);
889              evas_object_del(o->transp.rect);
890              o->transp.rect = NULL;
891           }
892      }
893 }
894
895 static void
896 _effect_role_handle(E_Comp_Effect_Object *o)
897 {
898    E_CHECK(o);
899    E_CHECK(o->cwin);
900    E_CHECK(o->edje);
901
902    char *hints = NULL;
903    char *token = NULL;
904
905    hints = ecore_x_window_prop_string_get(o->cwin, ECORE_X_ATOM_WM_WINDOW_ROLE);
906
907    if (hints)
908      token = strtok(hints, " ,");
909    while (token != NULL)
910      {
911         if (!strncmp(token, "no-dim", strlen("no-dim")))
912           {
913              const char *file = NULL, *group = NULL;
914              edje_object_file_get(o->edje, &file, &group);
915              E_CHECK_GOTO(group, cleanup);
916
917              if (!strcmp(group, "dialog"))
918                edje_object_signal_emit(o->edje, "e,state,dim,off", "e");
919           }
920         token = strtok (NULL, " ,");
921      }
922
923 cleanup:
924    if (hints) free(hints);
925 }
926
927 static Eina_Bool
928 _effect_obj_win_set(E_Comp_Effect_Object *o,
929                     E_Comp_Win           *cw)
930 {
931    E_Comp_Object *co = NULL;
932    E_Comp_Layer *ly = NULL;
933    const char *file = NULL, *group = NULL;
934    int ok = 0, pw = 0, ph = 0;
935    Ecore_X_Image *xim;
936
937    ly = evas_object_data_get(o->edje, "comp.effect_obj.ly");
938    E_CHECK_RETURN(ly, EINA_FALSE);
939    E_CHECK_RETURN(ly->canvas, EINA_FALSE);
940
941    if(!cw->sync_info.version)
942      {
943         ELBF(ELBT_COMP, 0, e_mod_comp_util_client_xid_get(cw),
944              "%15.15s| Not Drawn", "EFFECT");
945         return EINA_FALSE;
946      }
947
948    co = eina_list_nth(cw->objs, 0);
949    E_CHECK_RETURN(co, EINA_FALSE);
950
951    edje_object_file_get(co->shadow, &file, &group);
952    E_CHECK_RETURN(file, EINA_FALSE);
953    E_CHECK_RETURN(group, EINA_FALSE);
954
955    ok = edje_object_file_set(o->edje, file, group);
956    E_CHECK_RETURN(ok, EINA_FALSE);
957
958    o->img = evas_object_image_filled_add(ly->canvas->evas);
959    E_CHECK_RETURN(o->img, EINA_FALSE);
960
961    if (cw->shaped)
962      {
963         pw = cw->pw;
964         ph = cw->ph;
965         E_CHECK_GOTO((pw > 0), fail);
966         E_CHECK_GOTO((ph > 0), fail);
967
968         unsigned int *pix;
969         xim = ecore_x_image_new(pw, ph, cw->vis, cw->depth);
970         E_CHECK_GOTO(xim, fail);
971         pix = ecore_x_image_data_get(xim, NULL, NULL, NULL);
972         evas_object_image_size_set(o->img, pw, ph);
973         evas_object_image_data_set(o->img, pix);
974         evas_object_image_data_update_add(o->img, 0, 0, pw, ph);
975         if (ecore_x_image_get(xim, cw->win, 0, 0, 0, 0, pw, ph))
976           {
977              pix = ecore_x_image_data_get(xim, NULL, NULL, NULL);
978              evas_object_image_data_set(o->img, pix);
979              evas_object_image_data_update_add(o->img, 0, 0, pw, ph);
980           }
981         _effect_obj_win_shape_rectangles_apply(o, cw);
982         ELBF(ELBT_COMP, 0, e_mod_comp_util_client_xid_get(cw),
983             "%15.15s| SHAPED OBJ_NEW pix:0x%p %dx%d", "EFFECT",
984             xim, pw, ph);
985      }
986    else
987      {
988         evas_object_image_colorspace_set(o->img, EVAS_COLORSPACE_ARGB8888);
989         evas_object_image_smooth_scale_set(o->img, _comp_mod->conf->smooth_windows);
990         if (cw->argb) evas_object_image_alpha_set(o->img, 1);
991         else evas_object_image_alpha_set(o->img, 0);
992
993         /* set nocomp mode before getting named pixmap */
994         E_Comp_Win *nocomp_cw = e_mod_comp_util_win_nocomp_get(cw->c, ly->canvas->zone);
995         if (nocomp_cw == cw)
996           e_mod_comp_canvas_nocomp_end(ly->canvas);
997         if (cw->dmg_updates)
998           o->pixmap = ecore_x_composite_name_window_pixmap_get(cw->win);
999         else if (cw->needpix)
1000           o->pixmap = e_mod_comp_util_copied_pixmap_get(cw);
1001         E_CHECK_GOTO(o->pixmap, fail);
1002
1003         ecore_x_pixmap_geometry_get(o->pixmap, NULL, NULL, &pw, &ph);
1004         E_CHECK_GOTO((pw > 0), fail);
1005         E_CHECK_GOTO((ph > 0), fail);
1006
1007         Evas_Native_Surface ns;
1008         ns.version = EVAS_NATIVE_SURFACE_VERSION;
1009         ns.type = EVAS_NATIVE_SURFACE_X11;
1010         ns.data.x11.visual = cw->vis;
1011         ns.data.x11.pixmap = o->pixmap;
1012
1013         evas_object_image_size_set(o->img, pw, ph);
1014         evas_object_image_native_surface_set(o->img, &ns);
1015         evas_object_image_data_update_add(o->img, 0, 0, pw, ph);
1016
1017         ELBF(ELBT_COMP, 0, e_mod_comp_util_client_xid_get(cw),
1018              "%15.15s| OBJ_NEW pix:0x%x %dx%d", "EFFECT",
1019              o->pixmap, pw, ph);
1020      }
1021
1022    _effect_win_transparent_rect(cw, o, ly);
1023    edje_object_part_swallow(o->edje, "e.swallow.content", o->img);
1024 #ifdef _F_USE_BORDER_TRANSFORM_
1025    if ((cw->bd) && (e_border_transform_enable_get(cw->bd)))
1026      {
1027         int x, y, w, h;
1028         e_border_transform_get(cw->bd, &x, &y, &w, &h, 0);
1029         e_layout_child_move(o->edje, x, y);
1030         e_layout_child_resize(o->edje, w, h);
1031      }
1032    else
1033 #endif /* end of _F_USE_BORDER_TRANSFORM_ */
1034      {
1035         if (cw->dmg_updates)
1036            e_layout_child_move(o->edje, cw->x, cw->y);
1037         else if (cw->needpix)
1038            e_layout_child_move(o->edje, cw->resizing.x, cw->resizing.y);
1039         e_layout_child_resize(o->edje, pw, ph);
1040      }
1041
1042    edje_object_signal_callback_add(o->edje, "e,action,show,done", "e", _effect_obj_effect_done, o);
1043    edje_object_signal_callback_add(o->edje, "e,action,hide,done", "e", _effect_obj_effect_done, o);
1044
1045    o->win = cw->win;
1046    o->cwin = e_mod_comp_util_client_xid_get(cw);
1047
1048    _effect_role_handle(o);
1049
1050    return EINA_TRUE;
1051
1052 fail:
1053    if (o->img)
1054      {
1055         evas_object_del(o->img);
1056         o->img = NULL;
1057      }
1058    if (o->pixmap)
1059      {
1060         ecore_x_pixmap_free(o->pixmap);
1061         o->pixmap = 0;
1062      }
1063    return EINA_FALSE;
1064 }
1065
1066 static Eina_Bool
1067 _effect_obj_win_shaped_check(int                      w,
1068                              int                      h,
1069                              const Ecore_X_Rectangle *rects,
1070                              int                      num)
1071 {
1072    if ((!rects) || (num < 1)) return EINA_FALSE;
1073    if (num > 1) return EINA_TRUE;
1074    if ((rects[0].x == 0) && (rects[0].y == 0) &&
1075        ((int)rects[0].width == w) && ((int)rects[0].height == h))
1076      return EINA_FALSE;
1077    return EINA_TRUE;
1078 }
1079
1080 static void
1081 _effect_obj_win_shape_rectangles_apply(E_Comp_Effect_Object *o,
1082                                        E_Comp_Win           *cw)
1083 {
1084    int num;
1085    Ecore_X_Rectangle *rects = ecore_x_window_shape_rectangles_get(cw->win, &(num));
1086    int w, h, i, px, py;
1087    unsigned int *pix, *p;
1088    unsigned char *spix, *sp;
1089
1090    if (rects)
1091      {
1092         for (i = 0; i < cw->rects_num; i++)
1093           {
1094              E_RECTS_CLIP_TO_RECT(rects[i].x,
1095                                   rects[i].y,
1096                                   rects[i].width,
1097                                   rects[i].height,
1098                                   0, 0, cw->pw, cw->ph);
1099           }
1100      }
1101
1102    if (!_effect_obj_win_shaped_check(cw->pw, cw->ph, rects, num))
1103      {
1104         if (rects)
1105           free (rects);
1106         rects = NULL;
1107      }
1108
1109    if (rects)
1110      {
1111         evas_object_image_size_get(o->img, &w, &h);
1112         evas_object_image_alpha_set(o->img, 1);
1113         pix = evas_object_image_data_get(o->img, 1);
1114
1115         if (pix)
1116           {
1117              spix = calloc(w * h, sizeof(unsigned char));
1118              if (spix)
1119                {
1120                   for (i = 0; i < num; i++)
1121                     {
1122                        int rx, ry, rw, rh;
1123
1124                        rx = rects[i].x; ry = rects[i].y;
1125                        rw = rects[i].width; rh = rects[i].height;
1126                        E_RECTS_CLIP_TO_RECT(rx, ry, rw, rh, 0, 0, w, h);
1127                        sp = spix + (w * ry) + rx;
1128                        for (py = 0; py < rh; py++)
1129                          {
1130                             for (px = 0; px < rw; px++)
1131                               {
1132                                  *sp = 0xff; sp++;
1133                               }
1134                             sp += w - rw;
1135                          }
1136                     }
1137                   sp = spix;
1138                   p = pix;
1139                   for (py = 0; py < h; py++)
1140                     {
1141                        for (px = 0; px < w; px++)
1142                          {
1143                             unsigned int mask, imask;
1144                             mask = ((unsigned int)(*sp)) << 24;
1145                             imask = mask >> 8;
1146                             imask |= imask >> 8;
1147                             imask |= imask >> 8;
1148                             *p = mask | (*p & imask);
1149                             sp++;
1150                             p++;
1151                          }
1152                     }
1153                   free(spix);
1154                }
1155              evas_object_image_data_set(o->img, pix);
1156              evas_object_image_data_update_add(o->img, 0, 0, w, h);
1157           }
1158         free (rects);
1159      }
1160    else
1161      {
1162         if (cw->shaped)
1163           {
1164              evas_object_image_size_get(o->img, &w, &h);
1165
1166              evas_object_image_size_set(o->img, w, h);
1167              evas_object_image_alpha_set(o->img, 0);
1168              pix = evas_object_image_data_get(o->img, 1);
1169
1170              if (pix)
1171                {
1172                   p = pix;
1173                   for (py = 0; py < h; py++)
1174                     {
1175                        for (px = 0; px < w; px++)
1176                        *p |= 0xff000000;
1177                     }
1178                }
1179              evas_object_image_data_set(o->img, pix);
1180              evas_object_image_data_update_add(o->img, 0, 0, w, h);
1181           }
1182      }
1183 }
1184
1185 static void
1186 _effect_obj_effect_done(void                 *data,
1187                         Evas_Object          *obj,
1188                         const char  *emission __UNUSED__,
1189                         const char  *source   __UNUSED__)
1190 {
1191    E_Comp_Effect_Object *o = data;
1192    E_Comp_Layer *ly;
1193    E_CHECK(o);
1194    E_CHECK(obj);
1195
1196    ly = evas_object_data_get(obj, "comp.effect_obj.ly");
1197    E_CHECK(ly);
1198
1199    /* decrease effect count and hide effect layer if it is 0 */
1200    e_mod_comp_layer_effect_set(ly, EINA_FALSE);
1201 }
1202
1203 static void
1204 _effect_policy_border_transient_for_group_make(E_Border  *bd,
1205                                         Eina_List **list)
1206 {
1207    E_Border *child;
1208    Eina_List *l;
1209
1210    if (!bd) return;
1211
1212    E_OBJECT_CHECK(bd);
1213    E_OBJECT_TYPE_CHECK(bd, E_BORDER_TYPE);
1214
1215    if (e_config->transient.raise)
1216      {
1217         EINA_LIST_FOREACH(bd->transients, l, child)
1218           {
1219              if (!child) continue;
1220              if (!child->iconic)
1221                {
1222                   *list = eina_list_prepend(*list, child);
1223                   _effect_policy_border_transient_for_group_make(child, list);
1224                }
1225           }
1226      }
1227 }
1228
1229 static E_Border *
1230 _effect_policy_border_transient_for_border_top_get(E_Border *bd)
1231 {
1232    E_Border *top_border = NULL;
1233    Eina_List *transient_list = NULL;
1234
1235    _effect_policy_border_transient_for_group_make(bd, &transient_list);
1236
1237    if (transient_list)
1238      {
1239         Eina_List *l = NULL;
1240         E_Border *temp_bd;
1241         E_Border *temp_bd2;
1242         E_Border_List *bl;
1243
1244         bl = e_container_border_list_last(bd->zone->container);
1245         if (bl)
1246           {
1247              while ((temp_bd = e_container_border_list_prev(bl)))
1248                {
1249                   if (top_border) break;
1250                   if (temp_bd == bd) break;
1251
1252                   EINA_LIST_FOREACH(transient_list, l, temp_bd2)
1253                     {
1254                        if (temp_bd == temp_bd2)
1255                          {
1256                             top_border = temp_bd2;
1257                             break;
1258                          }
1259                     }
1260                }
1261              e_container_border_list_free(bl);
1262           }
1263      }
1264
1265    eina_list_free(transient_list);
1266
1267    return top_border;
1268 }
1269
1270 static void
1271 _effect_win_set(E_Comp_Win *cw,
1272                 const char *emission,
1273                 Eina_Bool   send_ev,
1274                 Eina_Bool   show,
1275                 Eina_Bool   recreate)
1276 {
1277    E_Comp_Canvas *canvas;
1278    E_Comp_Layer *ly;
1279    E_Comp_Effect_Object *o;
1280    E_Comp_Effect_Object *o2 = NULL;
1281    E_Comp_Effect_Object *o3 = NULL;
1282
1283    canvas = eina_list_nth(cw->c->canvases, 0);
1284    ly = e_mod_comp_canvas_layer_get(canvas, "effect");
1285    if (ly)
1286      {
1287         o = _effect_mod_object_new(ly, cw, recreate);
1288         if (o)
1289           {
1290              /* adjust the stack position of the given border to the above of
1291               * parent if border belongs to parent using 'transient_for'
1292               */
1293              if ((cw->bd) && (cw->bd->parent))
1294                {
1295                   E_Comp_Win *cw2 = e_mod_comp_win_find(cw->bd->parent->win);
1296                   if (cw2)
1297                     {
1298                        E_Border *top_border = NULL;
1299                        top_border = _effect_policy_border_transient_for_border_top_get(cw2->bd);
1300                        if (top_border)
1301                          {
1302                             E_Comp_Win *cw3 = e_mod_comp_border_client_find(top_border->client.win);
1303                             if (cw3)
1304                                o3 = _effect_obj_find(cw3);
1305                          }
1306                        o2 = _effect_obj_find(cw2);
1307
1308                        if (o3)
1309                          e_layout_child_raise_above(o->edje, o3->edje);
1310                        else if (o2)
1311                          e_layout_child_raise_above(o->edje, o2->edje);
1312                     }
1313                }
1314
1315              evas_object_show(o->img);
1316              evas_object_show(o->edje);
1317              _effect_mod_signal_add(NULL, o->edje, emission, "e");
1318 #if SEND_LAUNCHING_DONE
1319              if ( strncmp(emission,"e,state,visible,on,",strlen("e,state,visible,on,")) == 0 )
1320                o->send_launching_done = 0;
1321              else if ( strncmp(emission,"e,state,visible,on",strlen("e,state,visible,on")) == 0 )
1322                o->send_launching_done = 1;
1323              else
1324                o->send_launching_done = 0;
1325 #endif
1326
1327 #if USE_SHADOW
1328              /* add shadow on floating mode window while doing effect */
1329              if (STATE_INSET_CHECK(cw))
1330                edje_object_signal_emit(o->edje, "e,state,shadow,on", "e");
1331 #endif
1332
1333              if (send_ev)
1334                {
1335                   o->ev_vis = send_ev;
1336                   o->show = show;
1337                }
1338           }
1339      }
1340 }
1341
1342 static void
1343 _effect_win_lower(E_Comp_Win *cw,
1344                   const char *emission,
1345                   Eina_Bool   recreate)
1346 {
1347    E_Comp_Canvas *canvas;
1348    E_Comp_Layer *ly;
1349    E_Comp_Effect_Object *o;
1350
1351    canvas = eina_list_nth(cw->c->canvases, 0);
1352    ly = e_mod_comp_canvas_layer_get(canvas, "effect");
1353
1354    if (ly)
1355      {
1356         o = _effect_mod_object_new(ly, cw, recreate);
1357         if (o)
1358           {
1359              evas_object_show(o->img);
1360              evas_object_show(o->edje);
1361              _effect_mod_signal_add(NULL, o->edje, emission, "e");
1362
1363              e_layout_child_lower(o->edje);
1364              e_mod_comp_layer_bg_adjust(ly);
1365           }
1366      }
1367 }
1368
1369 static void
1370 _effect_below_wins_set(E_Comp_Win *cw,
1371                        Eina_Bool   recreate)
1372 {
1373    E_Comp_Canvas *canvas;
1374    E_Comp_Layer *ly;
1375    E_Comp_Effect_Object *o;
1376    Eina_Inlist *l;
1377    E_Comp_Win *_cw = cw, *nocomp_cw = NULL;
1378    E_Zone *zone;
1379    char emission[64];
1380    Eina_Bool bg_noeffect = EINA_FALSE;
1381
1382    _MAKE_EMISSION("e,state,visible,on,noeffect");
1383    if (TYPE_KEYBOARD_CHECK(cw) ||
1384        STATE_INSET_CHECK(cw) ||
1385        cw->argb)
1386      bg_noeffect = EINA_TRUE;
1387
1388    canvas = eina_list_nth(cw->c->canvases, 0);
1389    ly = e_mod_comp_canvas_layer_get(canvas, "effect");
1390    E_CHECK(ly);
1391
1392    zone = canvas->zone;
1393    E_CHECK(zone);
1394
1395    nocomp_cw = e_mod_comp_util_win_nocomp_get(cw->c, zone);
1396 #if USE_NOCOMP_DISPOSE
1397    E_Comp_Win *nocomp_end_cw = e_mod_comp_util_win_nocomp_end_get(cw->c, zone);
1398 #endif
1399
1400    /* create effect objects until finding a non-alpha full-screen window */
1401    while ((l = EINA_INLIST_GET(_cw)->prev))
1402      {
1403         _cw = _EINA_INLIST_CONTAINER(_cw, l);
1404
1405         if (TYPE_HOME_CHECK(_cw) && !bg_noeffect)
1406           _MAKE_EMISSION("e,state,background,visible,on");
1407
1408         if (!(_cw->visible)) continue;
1409         if (_cw->invalid) continue;
1410         if (_cw->input_only) continue;
1411         if (!E_INTERSECTS_EFFECT(_cw, zone->x, zone->y, zone->w, zone->h))
1412           continue;
1413
1414         /* if nocomp exist, change mode to the composite mode */
1415         if ((nocomp_cw) && (nocomp_cw == _cw))
1416           {
1417              ELBF(ELBT_COMP, 0, e_mod_comp_util_client_xid_get(_cw),
1418                   "%15.15s| END EFFECT_OBJ_NEW", "NOCOMP");
1419              e_mod_comp_canvas_nocomp_end(canvas);
1420           }
1421 #if USE_NOCOMP_DISPOSE
1422         else if ((nocomp_end_cw) && (nocomp_end_cw == _cw))
1423           {
1424              ELBF(ELBT_COMP, 0, e_mod_comp_util_client_xid_get(_cw),
1425                   "%15.15s| ENDED EFFECT_OBJ_NEW", "NOCOMP");
1426           }
1427 #endif
1428         else if (!((_cw->pixmap) &&
1429                    (_cw->pw > 0) && (_cw->ph > 0)))
1430           {
1431              continue;
1432           }
1433
1434         o = _effect_mod_object_new(ly, _cw, recreate);
1435         if (o)
1436           {
1437              evas_object_show(o->img);
1438              evas_object_show(o->edje);
1439              _effect_mod_signal_add(NULL, o->edje, emission, "e");
1440
1441 #if USE_SHADOW
1442              /* add shadow on floating mode window while doing effect */
1443              if (STATE_INSET_CHECK(_cw))
1444                edje_object_signal_emit(o->edje, "e,state,shadow,on", "e");
1445 #endif
1446
1447              /* change the stack position of the object to the bottom
1448               * of layer and also background object too
1449               */
1450              e_layout_child_lower(o->edje);
1451              e_mod_comp_layer_bg_adjust(ly);
1452           }
1453
1454         /* found a non-alpha full-screen window */
1455         if ((REGION_EQUAL_TO_ZONE(_cw, zone)) && !(_cw->argb))
1456           break;
1457      }
1458 }
1459
1460 static void
1461 _effect_below_floating_wins_set(E_Comp_Win *cw,
1462                                 Eina_Bool show,
1463                                 Eina_Bool   recreate)
1464 {
1465    E_Comp_Canvas *canvas;
1466    E_Comp_Layer *ly;
1467    E_Comp_Effect_Object *o;
1468    Eina_Inlist *l;
1469    E_Comp_Win *_cw = cw;
1470    E_Zone *zone;
1471    char emission[64];
1472
1473    canvas = eina_list_nth(cw->c->canvases, 0);
1474    ly = e_mod_comp_canvas_layer_get(canvas, "effect");
1475    E_CHECK(ly);
1476
1477    zone = canvas->zone;
1478    E_CHECK(zone);
1479
1480    while ((l = EINA_INLIST_GET(_cw)->prev))
1481      {
1482         _cw = _EINA_INLIST_CONTAINER(_cw, l);
1483
1484         if (!(_cw->visible)) continue;
1485         if ((REGION_EQUAL_TO_ZONE(_cw, zone)) && !(_cw->argb) && (!TYPE_VIDEO_CALL_CHECK(_cw))) break;
1486
1487         _MAKE_EMISSION("e,state,visible,on,noeffect");
1488
1489         o = _effect_mod_object_new(ly, _cw, recreate);
1490         if (o)
1491           {
1492              evas_object_show(o->img);
1493              evas_object_show(o->edje);
1494              _effect_mod_signal_add(NULL, o->edje, emission, "e");
1495 #if USE_SHADOW
1496              edje_object_signal_emit(o->edje, "e,state,shadow,on", "e");
1497 #endif
1498
1499              /* change the stack position of the object to the bottom
1500               * of layer and also background object too
1501               */
1502              e_layout_child_lower(o->edje);
1503              e_mod_comp_layer_bg_adjust(ly);
1504           }
1505
1506      }
1507 }
1508
1509 static void
1510 _effect_home_active_below_wins_set(E_Comp_Win *cw,
1511                                 Eina_Bool show,
1512                                 Eina_Bool   recreate)
1513 {
1514    E_Comp_Canvas *canvas;
1515    E_Comp_Layer *ly;
1516    E_Comp_Effect_Object *o;
1517    Eina_Inlist *l;
1518    E_Comp_Win *_cw = cw;
1519    E_Zone *zone;
1520    char emission[64];
1521
1522    canvas = eina_list_nth(cw->c->canvases, 0);
1523    ly = e_mod_comp_canvas_layer_get(canvas, "effect");
1524    E_CHECK(ly);
1525
1526    zone = canvas->zone;
1527    E_CHECK(zone);
1528
1529    while ((l = EINA_INLIST_GET(_cw)->prev))
1530      {
1531         _cw = _EINA_INLIST_CONTAINER(_cw, l);
1532
1533         if (!(_cw->visible)) continue;
1534         if (TYPE_HOME_CHECK(_cw)) break;
1535
1536         if (STATE_INSET_CHECK(_cw))
1537           _MAKE_EMISSION("e,state,visible,on,noeffect");
1538         else
1539           _MAKE_EMISSION("e,state,visible,off");
1540
1541         if (TYPE_VIDEO_CALL_CHECK(cw) && TYPE_VIDEO_CALL_CHECK(_cw))
1542           {
1543              if (REGION_EQUAL_TO_ZONE(_cw, zone))
1544                _MAKE_EMISSION("e,state,visible,off");
1545              else
1546                continue;
1547           }
1548
1549         o = _effect_mod_object_new(ly, _cw, recreate);
1550         if (o)
1551           {
1552              evas_object_show(o->img);
1553              evas_object_show(o->edje);
1554              _effect_mod_signal_add(NULL, o->edje, emission, "e");
1555 #if USE_SHADOW
1556              edje_object_signal_emit(o->edje, "e,state,shadow,on", "e");
1557 #endif
1558
1559              /* change the stack position of the object to the bottom
1560               * of layer and also background object too
1561               */
1562              e_layout_child_lower(o->edje);
1563              e_mod_comp_layer_bg_adjust(ly);
1564           }
1565
1566         if ((REGION_EQUAL_TO_ZONE(_cw, zone)) && !(_cw->argb) && (!TYPE_VIDEO_CALL_CHECK(_cw))) break;
1567      }
1568 }
1569
1570 static void
1571 _effect_above_wins_set(E_Comp_Win *cw,
1572                        Eina_Bool   show,
1573                        Eina_Bool   recreate)
1574 {
1575    E_Comp_Canvas *canvas;
1576    E_Comp_Layer *ly;
1577    E_Comp_Effect_Object *o;
1578    Eina_Inlist *l;
1579    E_Comp_Win *_cw = cw;
1580    E_Zone *zone;
1581    char emission[64];
1582    E_Comp_Win *parent_cw = NULL;
1583
1584    canvas = eina_list_nth(cw->c->canvases, 0);
1585    ly = e_mod_comp_canvas_layer_get(canvas, "effect");
1586    E_CHECK(ly);
1587
1588    zone = canvas->zone;
1589    E_CHECK(zone);
1590
1591    while ((l = EINA_INLIST_GET(_cw)->next))
1592      {
1593         _cw = _EINA_INLIST_CONTAINER(_cw, l);
1594         if (!(_cw->visible)) continue;
1595         if (_cw->invalid) continue;
1596         if (_cw->input_only) continue;
1597         if (!E_INTERSECTS_EFFECT(_cw, zone->x, zone->y, zone->w, zone->h))
1598           continue;
1599         if (!((_cw->pixmap) &&
1600               (_cw->pw > 0) && (_cw->ph > 0)))
1601           continue;
1602
1603         if ((TYPE_KEYBOARD_SUB_CHECK(_cw)) && (!show)) continue;
1604
1605         if ((REGION_EQUAL_TO_ZONE(_cw, zone)) && (!_cw->argb)) continue;
1606
1607         if ((_cw->bd) && (_cw->bd->parent))
1608           {
1609              parent_cw = e_mod_comp_win_find(_cw->bd->parent->win);
1610           }
1611
1612         if ((parent_cw) && (parent_cw == cw) && (!show))
1613           _MAKE_EMISSION("e,state,visible,off");
1614         else
1615           _MAKE_EMISSION("e,state,visible,on,noeffect");
1616
1617         if ((TYPE_KEYBOARD_CHECK(_cw)) && (!show))
1618           {
1619              if (cw->c->keyboard_effect && (!PARENT_FLOAT_CHECK(_cw)))
1620                {
1621                   if (_effect_mod_win_angle_get(_cw))
1622                     _MAKE_EMISSION("e,state,visible,off,angle,%d", _cw->angle);
1623                   else
1624                     _MAKE_EMISSION("e,state,visible,off,angle,0");
1625                }
1626              else if (!cw->c->keyboard_effect)
1627                continue;
1628           }
1629
1630         o = _effect_mod_object_new(ly, _cw, recreate);
1631         if (o)
1632           {
1633              evas_object_show(o->img);
1634              evas_object_show(o->edje);
1635              _effect_mod_signal_add(NULL, o->edje, emission, "e");
1636
1637 #if USE_SHADOW
1638              /* add shadow on floating mode window while doing effect */
1639              if (STATE_INSET_CHECK(_cw))
1640                edje_object_signal_emit(o->edje, "e,state,shadow,on", "e");
1641 #endif
1642           }
1643      }
1644 }
1645
1646 static E_Comp_Effect_Object *
1647 _effect_object_control_layer_new(E_Comp_Layer *ly, E_Comp_Win *cw)
1648 {
1649    E_Comp_Effect_Object *o = NULL;
1650    int ok = 0;
1651
1652    E_CHECK_RETURN(ly, NULL);
1653    E_CHECK_RETURN(ly->canvas, NULL);
1654    E_CHECK_RETURN(cw, NULL);
1655
1656    E_Comp_Layer *effect_ly = e_mod_comp_canvas_layer_get(ly->canvas, "effect");
1657    E_CHECK_GOTO(effect_ly, fail);
1658
1659    o = E_NEW(E_Comp_Effect_Object, 1);
1660    E_CHECK_GOTO(o, fail);
1661
1662    o->edje = edje_object_add(ly->canvas->evas);
1663    E_CHECK_GOTO(o->edje, fail);
1664
1665    e_mod_comp_layer_populate(effect_ly, o->edje);
1666
1667    evas_object_data_set(o->edje, "comp.effect_obj.ly", effect_ly);
1668
1669    E_Comp_Object *co = NULL;
1670    const char *file = NULL, *group = NULL;
1671
1672    co = eina_list_nth(cw->objs, 0);
1673    E_CHECK_GOTO(co, fail);
1674
1675    edje_object_file_get(co->shadow, &file, &group);
1676    E_CHECK_GOTO(file, fail);
1677    E_CHECK_GOTO(group, fail);
1678
1679    ok = edje_object_file_set(o->edje, file, "no-effect");
1680    E_CHECK_GOTO(ok, fail);
1681
1682    o->img = evas_object_image_filled_add(ly->canvas->evas);
1683    E_CHECK_GOTO(o->img, fail);
1684
1685    evas_object_image_source_set(o->img, ly->layout);
1686    edje_object_part_swallow(o->edje, "e.swallow.content", o->img);
1687
1688    e_layout_child_move(o->edje, ly->x, ly->y);
1689    e_layout_child_resize(o->edje, ly->w, ly->h);
1690
1691    evas_object_show(o->img);
1692    evas_object_show(o->edje);
1693
1694    edje_object_signal_callback_add(o->edje, "e,action,show,done", "e", _effect_obj_effect_done, o);
1695    edje_object_signal_callback_add(o->edje, "e,action,hide,done", "e", _effect_obj_effect_done, o);
1696
1697    o->win = 0;
1698    o->cwin = 0;
1699
1700    effect_ly->objs = eina_list_append(effect_ly->objs, o);
1701
1702    return o;
1703
1704 fail:
1705    if (o)
1706      {
1707         if (o->img) evas_object_del(o->img);
1708
1709         if (o->edje)
1710           {
1711              e_layout_unpack(o->edje);
1712              evas_object_del(o->edje);
1713           }
1714         E_FREE(o);
1715      }
1716    return NULL;
1717
1718
1719 }
1720
1721
1722 static void
1723 _effect_control_layer_set(E_Comp_Win *cw)
1724 {
1725    E_Comp_Canvas *canvas = NULL;
1726    E_Comp_Layer *ctrl_ly = NULL;
1727    E_Comp_Layer *comp_ly = NULL;
1728    Eina_Bool ctrl_visible;
1729    Eina_List *lm = NULL;
1730    Eina_List *l, *ll;
1731    Evas_Object *member = NULL;
1732    Evas_Object *active_shadow = NULL;
1733    Eina_Bool find_ctrl_ly = EINA_FALSE;
1734    E_Comp_Win *_cw;
1735    E_Comp_Win *active_window = NULL;
1736    E_Comp_Object *co;
1737    char emission[64];
1738
1739    canvas = eina_list_nth(cw->c->canvases, 0);
1740    ctrl_ly = e_mod_comp_canvas_layer_get(canvas, "ly-ctrl");
1741    E_CHECK(ctrl_ly);
1742
1743    ctrl_visible = evas_object_visible_get(ctrl_ly->layout);
1744    E_CHECK(ctrl_visible);
1745
1746    comp_ly = e_mod_comp_canvas_layer_get(canvas, "comp");
1747    E_CHECK(comp_ly);
1748
1749    lm = evas_object_smart_members_get(comp_ly->layout);
1750    E_CHECK(lm);
1751
1752    EINA_LIST_REVERSE_FOREACH(lm, ll, member)
1753      {
1754         if (member == ctrl_ly->layout)
1755           {
1756              find_ctrl_ly = EINA_TRUE;
1757              continue;
1758           }
1759         if ((find_ctrl_ly) && (evas_object_visible_get(member)))
1760           {
1761              active_shadow = member;
1762              break;
1763           }
1764      }
1765    eina_list_free(lm);
1766    E_CHECK(active_shadow);
1767
1768    EINA_INLIST_REVERSE_FOREACH(cw->c->wins, _cw)
1769      {
1770         EINA_LIST_FOREACH(_cw->objs, l, co)
1771           {
1772              if (!co) continue;
1773              if (co->shadow == active_shadow)
1774                {
1775                   active_window = _cw;
1776                   break;
1777                }
1778           }
1779      }
1780    E_CHECK(active_window);
1781
1782    E_Comp_Effect_Object *active_window_object = _effect_obj_find(active_window);
1783    E_CHECK(active_window_object);
1784
1785    E_Comp_Effect_Object *control_layer_object = _effect_object_control_layer_new(ctrl_ly, active_window);
1786    E_CHECK(control_layer_object);
1787
1788    _MAKE_EMISSION("e,state,visible,on,noeffect");
1789    _effect_mod_signal_add(NULL, control_layer_object->edje, emission, "e");
1790
1791    e_layout_child_raise_above(control_layer_object->edje, active_window_object->edje);
1792 }
1793
1794 static E_Comp_Effect_Object *
1795 _effect_obj_find(E_Comp_Win *cw)
1796 {
1797    E_Comp_Canvas *canvas = eina_list_nth(cw->c->canvases, 0);
1798    E_CHECK_RETURN(canvas, NULL);
1799
1800    E_Comp_Layer *ly = e_mod_comp_canvas_layer_get(canvas, "effect");
1801    E_CHECK_RETURN(ly, NULL);
1802
1803    Eina_List *l;
1804    E_Comp_Effect_Object *o;
1805    EINA_LIST_FOREACH(ly->objs, l, o)
1806      {
1807         if (!o) continue;
1808         if (o->win == cw->win)
1809           {
1810              ELBF(ELBT_COMP, 0, e_mod_comp_util_client_xid_get(cw),
1811                   "%15.15s| OBJ already exists!", "EFFECT");
1812              return o;
1813           }
1814      }
1815
1816    return NULL;
1817 }
1818
1819 /* send_ev: indicates that comp sends the E_EVENT_COMP_SOURCE_VISIBILITY event
1820  * when effect is done. show and hide effects will set this to true, but restack
1821  * effect sets false.
1822  */
1823 static Eina_Bool
1824 _effect_show(E_Comp_Win *cw,
1825              Eina_Bool   send_ev)
1826 {
1827    E_Comp_Effect_Style st;
1828    char emission[64];
1829    E_Comp_Win *cw2 = NULL, *cw_below = NULL, *home_cw = NULL;
1830    E_Comp_Effect_Object *o = NULL;
1831    Eina_Bool launch, vis, res = EINA_FALSE;
1832    Eina_Bool recreate = EINA_FALSE;
1833
1834    E_CHECK_RETURN(cw, EINA_FALSE);
1835
1836    o = _effect_obj_find(cw);
1837    E_CHECK_RETURN(!o, EINA_FALSE);
1838
1839    /* check effect condition and make emission string */
1840    st = _effect_mod_style_get(cw->eff_type, E_COMP_EFFECT_KIND_SHOW);
1841    vis = e_mod_comp_util_win_visible_get(cw, EINA_TRUE);
1842
1843    ELBF(ELBT_COMP, 0, e_mod_comp_util_client_xid_get(cw),
1844         "%15.15s|SHOW", "EFFECT");
1845
1846    if (E_COMP_EFFECT_STYLE_DEFAULT == st)
1847      {
1848         launch = e_mod_comp_policy_app_launch_check(cw);
1849         if (launch)
1850           {
1851              home_cw = e_mod_comp_util_win_home_get(NULL);
1852
1853              if ((cw->depth == 32) && (home_cw) && (_effect_obj_find(home_cw)))
1854                {
1855                   cw2 = e_mod_comp_util_win_normal_get(NULL, EINA_TRUE);
1856                   if ((cw2) && (cw2 == cw))
1857                     {
1858                       /* when 32bit window(Transient for) is resumed*/
1859                        _effect_below_wins_set(cw, recreate);
1860                        ELBF(ELBT_COMP, 0, e_mod_comp_util_client_xid_get(cw),
1861                             "%15.15s|>FG", "EFFECT");
1862                        _MAKE_EMISSION("e,state,visible,on");
1863                        _effect_win_set(cw, emission, send_ev, EINA_TRUE, recreate);
1864                        _effect_above_wins_set(cw, EINA_TRUE, recreate);
1865                        _effect_control_layer_set(cw);
1866                        res = EINA_TRUE;
1867                     }
1868                   else if ((cw2) && (cw2 != cw))
1869                     {
1870                        /* when a stack of window lowered above 32bit window. */
1871                        recreate = EINA_TRUE;
1872                        _MAKE_EMISSION("e,state,visible,on,noeffect");
1873                        _effect_win_set(cw, emission, send_ev, EINA_TRUE, recreate);
1874
1875                        _MAKE_EMISSION("e,state,visible,off");
1876                        _effect_win_set(cw2, emission, send_ev, EINA_TRUE, recreate);
1877
1878                        _effect_above_wins_set(cw, EINA_TRUE, recreate);
1879                        _effect_control_layer_set(cw);
1880                        res = EINA_TRUE;
1881                     }
1882                }
1883              else if (vis)
1884                {
1885                   _effect_below_wins_set(cw, recreate);
1886
1887                   int full_child_count = 0;
1888                   E_Comp_Win *full_child_cw = NULL;
1889
1890                   if ((cw->bd) && (cw->bd->transients))
1891                     {
1892                        E_Border *child_border = NULL;
1893                        E_Zone *zone = cw->bd->zone;
1894                        Eina_List *l;
1895
1896                        EINA_LIST_FOREACH(cw->bd->transients, l, child_border)
1897                          {
1898                             E_Comp_Win *child_cw = e_mod_comp_border_client_find(child_border->client.win);
1899                             if ((child_cw) && (zone))
1900                               {
1901                                  if ((zone) && (REGION_EQUAL_TO_ZONE(child_cw, zone)))
1902                                    {
1903                                       full_child_cw = child_cw;
1904                                       full_child_count++;
1905                                    }
1906                               }
1907                          }
1908                     }
1909
1910                   ELBF(ELBT_COMP, 0, e_mod_comp_util_client_xid_get(cw),
1911                        "%15.15s|>FG(Child : 0x%08x) A : %d", "EFFECT",
1912                        full_child_cw ? e_mod_comp_util_client_xid_get(full_child_cw): 0,
1913                        full_child_cw ? full_child_cw->argb : 0);
1914                   _MAKE_EMISSION("e,state,visible,on");
1915                   if ((full_child_count == 1) && full_child_cw)
1916                     {
1917                        if (full_child_cw->argb)
1918                          {
1919                             _effect_win_set(cw, emission, send_ev, EINA_TRUE, recreate);
1920                             _effect_win_set(full_child_cw, emission, send_ev, EINA_TRUE, recreate);
1921                          }
1922                        else
1923                          _effect_win_set(full_child_cw, emission, send_ev, EINA_TRUE, recreate);
1924                     }
1925                   else
1926                     _effect_win_set(cw, emission, send_ev, EINA_TRUE, recreate);
1927                   _effect_above_wins_set(cw, EINA_TRUE, recreate);
1928                   _effect_control_layer_set(cw);
1929                   res = EINA_TRUE;
1930                }
1931           }
1932         else if ((TYPE_KEYBOARD_CHECK(cw)) && (vis))
1933           {
1934              if (cw->c->keyboard_effect)
1935                {
1936                   _effect_below_wins_set(cw, recreate);
1937
1938                   E_Zone *zone = NULL;
1939                   if ((cw->bd) && (cw->bd->zone))
1940                     zone = cw->bd->zone;
1941
1942                   if ((zone) && (zone->rot.block_count))
1943                     _MAKE_EMISSION("e,state,visible,on,noeffect");
1944                   else if (_effect_mod_win_angle_get(cw))
1945                     _MAKE_EMISSION("e,state,window,angle,%d", cw->angle);
1946                   else
1947                     _MAKE_EMISSION("e,state,window,angle,0");
1948
1949                   _effect_win_set(cw, emission, send_ev, EINA_TRUE, recreate);
1950                   _effect_above_wins_set(cw, EINA_TRUE, recreate);
1951                   _effect_control_layer_set(cw);
1952                   res = EINA_TRUE;
1953                }
1954           }
1955         else if ((STATE_INSET_CHECK(cw)) && (vis))
1956           {
1957              cw2 = e_mod_comp_util_win_normal_get(NULL, EINA_TRUE);
1958              if ((cw2) && (cw2->depth == 32) && (_effect_obj_find(cw2)))
1959                {
1960                   recreate = EINA_TRUE;
1961                   _MAKE_EMISSION("e,state,visible,on,noeffect");
1962                   _effect_win_set(cw2, emission, EINA_FALSE, EINA_TRUE, EINA_TRUE);
1963                }
1964
1965              _effect_below_wins_set(cw, recreate);
1966
1967              ELBF(ELBT_COMP, 0, e_mod_comp_util_client_xid_get(cw),
1968                   "%15.15s|>FG", "EFFECT");
1969
1970              _MAKE_EMISSION("e,state,visible,on");
1971              _effect_win_set(cw, emission, send_ev, EINA_TRUE, recreate);
1972              _effect_above_wins_set(cw, EINA_TRUE, recreate);
1973              _effect_control_layer_set(cw);
1974              res = EINA_TRUE;
1975           }
1976         /* in most cases, border show events of home window are generated
1977          * by pressing the h/w home button. at that moment, home window
1978          * is invisible thus the wm doesn't need to check visibility for
1979          * home window. just make app closing effect except lock and
1980          * setup wizard window.
1981          */
1982         else if (TYPE_HOME_CHECK(cw) && (cw->activate))
1983           {
1984              Eina_Bool animatable = EINA_FALSE;
1985              /* app window hide effect by pressing the h/w home button */
1986              cw2 = e_mod_comp_util_win_normal_get(NULL, EINA_FALSE);
1987
1988              if (cw2)
1989                animatable = _effect_mod_state_get(cw2->eff_type);
1990
1991              if (!animatable)
1992                return EINA_FALSE;
1993
1994              /* in case after hide effect proccessed already */
1995              if ((cw2) && (_effect_obj_find(cw2)))
1996                return EINA_FALSE;
1997
1998              if ((cw2) && (cw2->bd) && (_effect_active_except_bd_check(cw2->bd)))
1999                {
2000                   ELBF(ELBT_COMP, 0, e_mod_comp_util_client_xid_get(cw2),
2001                        "%15.15s|>BG HOME 0x%08x FG 0x%08x except_bd SKIP", "EFFECT",
2002                        e_mod_comp_util_client_xid_get(cw),
2003                        e_mod_comp_util_client_xid_get(cw2));
2004                   return EINA_FALSE;
2005                }
2006
2007              /* In case of that Notification window show*/
2008              if ((cw2) &&
2009                  (cw2->win_type == E_COMP_WIN_TYPE_NOTIFICATION))
2010                {
2011                   ELBF(ELBT_COMP, 0, e_mod_comp_util_client_xid_get(cw2),
2012                        "%15.15s|>BG HOME 0x%08x FG 0x%08x Notification SKIP", "EFFECT",
2013                        e_mod_comp_util_client_xid_get(cw),
2014                        e_mod_comp_util_client_xid_get(cw2));
2015                   return EINA_FALSE;
2016                }
2017
2018             /* In case of that quickpanel window show*/
2019              if ((cw2) &&
2020                  (cw2->win_type == E_COMP_WIN_TYPE_QUICKPANEL))
2021                {
2022                   ELBF(ELBT_COMP, 0, e_mod_comp_util_client_xid_get(cw2),
2023                        "%15.15s|>BG HOME 0x%08x FG 0x%08x quickpanel SKIP", "EFFECT",
2024                        e_mod_comp_util_client_xid_get(cw),
2025                        e_mod_comp_util_client_xid_get(cw2));
2026                   return EINA_FALSE;
2027                }
2028
2029              /* In case of that no-effect 32bit windows show */
2030              if ((cw2) &&
2031                  (cw2->win_type == E_COMP_WIN_TYPE_UTILITY))
2032                {
2033                   if (cw2->depth == 32)
2034                     return EINA_FALSE;
2035                   else
2036                     {
2037                        cw_below = e_mod_comp_util_win_below_get(cw2, EINA_FALSE, EINA_FALSE);
2038                        if ((cw_below) && (cw_below->depth == 32))
2039                          return EINA_FALSE;
2040                     }
2041                }
2042
2043             /* In case of minimizing. */
2044              if ((cw2) && STATE_INSET_CHECK(cw2))
2045                {
2046                   ELBF(ELBT_COMP, 0, e_mod_comp_util_client_xid_get(cw2),
2047                        "%15.15s|>BG HOME 0x%08x FG 0x%08x Minimize SKIP", "EFFECT",
2048                        e_mod_comp_util_client_xid_get(cw),
2049                        e_mod_comp_util_client_xid_get(cw2));
2050                   return EINA_FALSE;
2051                }
2052
2053              /* In case of pressing home button when top normal window transients for floating window. */
2054              if ((cw2) && (PARENT_FLOAT_CHECK(cw2)))
2055                {
2056                   cw2 = NULL;
2057                }
2058
2059              /* When top app window is stacked lower already.
2060               * it is observed in case of a top window is 32bit windows.
2061               */
2062              if ((cw2) && (cw2 == cw))
2063                {
2064                   cw_below = e_mod_comp_util_win_below_get(cw, EINA_FALSE, EINA_FALSE);
2065                   if ((cw_below) && (cw_below->depth == 32))
2066                     cw2 = cw_below;
2067                   else
2068                     return EINA_FALSE;
2069                }
2070              if (cw2)
2071                {
2072                   /* do nothing, if cw2 is such exceptional windows as lock
2073                    * and setup wizard window. this case usually happens when
2074                    * system is booting. (first show of the home window)
2075                    */
2076                   res = e_mod_comp_policy_home_app_win_check(cw2);
2077
2078                   ELBF(ELBT_COMP, 0, e_mod_comp_util_client_xid_get(cw),
2079                        "%15.15s|>BG HOME 0x%08x FG 0x%08x SKIP:%d", "EFFECT",
2080                        e_mod_comp_util_client_xid_get(cw),
2081                        e_mod_comp_util_client_xid_get(cw2),
2082                        !(res));
2083
2084                   E_CHECK_RETURN(res, EINA_FALSE);
2085                   /* not enough to add effect to above wins.
2086                    * because it can be possible to stack cw2 above floating wins.
2087                    * typically, the case of that cw transients for any floating windows.
2088                    */
2089                   _effect_home_active_below_wins_set(cw2, EINA_FALSE, recreate);
2090
2091                   _MAKE_EMISSION("e,state,visible,on,noeffect");
2092                   _effect_win_lower(cw, emission, recreate);
2093
2094                   _MAKE_EMISSION("e,state,visible,off");
2095                   _effect_win_set(cw2, emission, EINA_FALSE, EINA_FALSE, recreate);
2096
2097                   /* in order to show 'keyboard hide effect with 'app window hide effect',
2098                    * 'show' argument should be passed to false
2099                    */
2100                   _effect_above_wins_set(cw2, EINA_FALSE, recreate);
2101                   _effect_control_layer_set(cw);
2102                }
2103           }
2104      }
2105
2106    return res;
2107 }
2108
2109 static Eina_Bool
2110 _effect_hide(E_Comp_Win *cw,
2111              Eina_Bool   send_ev)
2112 {
2113    E_Comp_Effect_Style st;
2114    char emission[64];
2115    E_Comp_Win *cw2 = NULL, *home_cw = NULL;
2116    E_Comp_Effect_Object *o = NULL;
2117    Eina_Bool close, res = EINA_FALSE;
2118    Eina_Bool recreate = EINA_FALSE;
2119
2120    o = _effect_obj_find(cw);
2121
2122    /* check effect condition and make emission string */
2123    st = _effect_mod_style_get(cw->eff_type, E_COMP_EFFECT_KIND_HIDE);
2124
2125    ELBF(ELBT_COMP, 0, e_mod_comp_util_client_xid_get(cw),
2126         "%15.15s|HIDE", "EFFECT");
2127
2128    if (E_COMP_EFFECT_STYLE_DEFAULT == st)
2129      {
2130         close = e_mod_comp_policy_app_close_check(cw);
2131
2132         if ((!close) && (o))
2133           return EINA_FALSE;
2134
2135         if (close)
2136           {
2137              /* not enough to add effect to above wins.
2138               * because it can be possible to stack cw above floating wins.
2139               * typically, the case of that cw transients for any floating windows.
2140               * when hide effect runs on a normal window, change to show only below floating windows not all below windows.
2141               */
2142              _effect_below_floating_wins_set(cw, EINA_TRUE, recreate);
2143
2144              /* background window */
2145              cw2 = e_mod_comp_util_win_normal_get(cw, EINA_TRUE);
2146
2147              /* when 32bit window hides effect doesn't work,
2148               * because there are effect object of the window already (home show effect).
2149               * so it need to be handled exceptionally.
2150               */
2151              if ((cw2) && (cw2->depth == 32) && (o))
2152                {
2153                   home_cw = e_mod_comp_util_win_home_get(cw);
2154                   if ((home_cw) && (_effect_obj_find(home_cw)))
2155                     {
2156                        recreate = EINA_TRUE;
2157                        _MAKE_EMISSION("e,state,visible,on,noeffect");
2158                        _effect_win_set(cw2, emission, send_ev, EINA_FALSE, EINA_TRUE);
2159                        cw2 = NULL;
2160                     }
2161                   else
2162                     return EINA_FALSE;
2163                }
2164              else if(o)
2165                return EINA_FALSE;
2166
2167              if (cw2)
2168                {
2169                   ELBF(ELBT_COMP, 0, e_mod_comp_util_client_xid_get(cw),
2170                        "%15.15s|>BG 0x%08x", "EFFECT",
2171                        e_mod_comp_util_client_xid_get(cw2));
2172
2173                   if (cw->argb)
2174                     _MAKE_EMISSION("e,state,visible,on,noeffect");
2175                   else
2176                     _MAKE_EMISSION("e,state,background,visible,off");
2177
2178                   _effect_win_lower(cw2, emission, recreate);
2179                }
2180
2181              ELBF(ELBT_COMP, 0, e_mod_comp_util_client_xid_get(cw),
2182                   "%15.15s|>FG", "EFFECT");
2183
2184              _MAKE_EMISSION("e,state,visible,off");
2185              _effect_win_set(cw, emission, send_ev, EINA_FALSE, recreate);
2186              _effect_above_wins_set(cw, EINA_FALSE, recreate);
2187              _effect_control_layer_set(cw);
2188
2189              res = EINA_TRUE;
2190           }
2191         else if (TYPE_KEYBOARD_CHECK(cw))
2192           {
2193              if (cw->c->keyboard_effect)
2194                {
2195                   _effect_below_wins_set(cw, recreate);
2196
2197                   E_Zone *zone = NULL;
2198                   if ((cw->bd) && (cw->bd->zone))
2199                     zone = cw->bd->zone;
2200
2201                   if ((zone) && (zone->rot.block_count))
2202                     _MAKE_EMISSION("e,state,visible,off,noeffect");
2203                   else if (_effect_mod_win_angle_get(cw))
2204                     _MAKE_EMISSION("e,state,visible,off,angle,%d", cw->angle);
2205                   else
2206                     _MAKE_EMISSION("e,state,visible,off,angle,0");
2207
2208                   _effect_win_set(cw, emission, send_ev, EINA_FALSE, recreate);
2209                   _effect_above_wins_set(cw, EINA_FALSE, recreate);
2210                   _effect_control_layer_set(cw);
2211
2212                   res = EINA_TRUE;
2213                }
2214           }
2215         else if (STATE_INSET_CHECK(cw))
2216           {
2217              _effect_below_wins_set(cw, recreate);
2218
2219              ELBF(ELBT_COMP, 0, e_mod_comp_util_client_xid_get(cw),
2220                   "%15.15s|>FG", "EFFECT");
2221
2222              _MAKE_EMISSION("e,state,visible,off");
2223              _effect_win_set(cw, emission, send_ev, EINA_FALSE, recreate);
2224              _effect_above_wins_set(cw, EINA_FALSE, recreate);
2225              _effect_control_layer_set(cw);
2226           }
2227      }
2228
2229    return res;
2230 }
2231
2232 static Eina_Bool
2233 _effect_active_except_bd_check(E_Border *bd)
2234 {
2235    const char *name = NULL;
2236    const char *clas = NULL;
2237
2238    if (!bd) return EINA_FALSE;
2239
2240    name = bd->client.icccm.name;
2241    clas = bd->client.icccm.class;
2242
2243    if (!clas) return EINA_FALSE;
2244    if (!name) return EINA_FALSE;
2245    if (strncmp(clas,"setting_encrypting_menu", strlen("setting_encrypting_menu")) == 0) return EINA_TRUE;
2246    if (strncmp(name,"com.samsung.setting.encrypting", strlen("com.samsung.setting.encrypting")) == 0) return EINA_TRUE;
2247
2248    return EINA_FALSE;
2249 }
2250
2251 static void
2252 _effect_home_active_unset(E_Comp_Win *cw)
2253 {
2254    E_CHECK(cw);
2255    E_CHECK(TYPE_HOME_CHECK(cw));
2256    E_CHECK(cw->c->animatable);
2257    E_CHECK(cw->activate);
2258
2259    ELBF(ELBT_COMP, 0, e_mod_comp_util_client_xid_get(cw),
2260         "%s", "HOME ACTIVE Unset");
2261
2262    cw->activate = 0;
2263 }