tizen 2.4 release
[framework/uifw/e17-mod-tizen-comp.git] / src / e_mod_comp_aux_hint.c
1 #include "e_mod_comp.h"
2 #include "e_mod_comp_debug.h"
3
4 typedef struct _E_Comp_Aux_Hint_Item E_Comp_Aux_Hint_Item;
5
6 struct _E_Comp_Aux_Hint_Item
7 {
8    /* val[0] previous value, val[1] current value */
9    union
10      {
11         Eina_Bool b;
12         int       i;
13      } val[2];
14    Eina_Bool changed;
15 };
16
17 static const char *hint_names[] =
18 {
19    "wm.comp.win.effect.enable",
20    "wm.comp.win.dim_bg.enable",
21    "wm.comp.win.sync_draw.support",
22    "wm.comp.win.always.selective.mode"
23 };
24
25 /* externally accessible functions */
26 EAPI int
27 e_mod_comp_aux_hint_init(void)
28 {
29    int i, n;
30    n = (sizeof(hint_names) / sizeof(char *));
31
32    Eina_List *l;
33    E_Manager *man;
34    EINA_LIST_FOREACH(e_manager_list(), l, man)
35      {
36         for (i = 0; i < n; i++)
37           {
38              e_hints_aux_hint_supported_add(man->root, hint_names[i]);
39           }
40      }
41
42    return 1;
43 }
44
45 EAPI int
46 e_mod_comp_aux_hint_shutdown(void)
47 {
48    return 1;
49 }
50
51 #define _STR_CMP(a, b) (strncmp(a, b, strlen(b)) == 0)
52
53 #define _VAL_CHECK(a, b, c, d, e) \
54    else if (_STR_CMP(a, b))       \
55      {                            \
56         c = d;                    \
57         e = EINA_TRUE;            \
58         send = EINA_TRUE;         \
59      }
60
61 EAPI void
62 e_mod_comp_aux_hint_eval(void *data __UNUSED__,
63                          void      *data2)
64 {
65    E_Border *bd = (E_Border *)data2;
66    E_CHECK(bd);
67
68    E_Comp_Win *cw = e_mod_comp_win_find(bd->win);
69    E_CHECK(cw);
70
71    E_Comp_Aux_Hint_Item eff;
72    eff.val[0].b = cw->c->effect_funcs.state_get(cw->eff_type);
73    eff.val[1].b = EINA_FALSE;
74    eff.changed = EINA_FALSE;
75
76    E_Comp_Aux_Hint_Item dim;
77    dim.val[0].b = EINA_TRUE; /* TODO: make e,state,dim,on */
78    dim.val[1].b = EINA_FALSE;
79    dim.changed = EINA_FALSE;
80
81    E_Comp_Aux_Hint_Item sync_draw;
82    sync_draw.val[0].b = cw->sync_draw_support;
83    sync_draw.val[1].b = EINA_FALSE;
84    sync_draw.changed = EINA_FALSE;
85
86    E_Comp_Aux_Hint_Item selective_mode;
87    selective_mode.val[0].b = cw->always_selective_mode;
88    selective_mode.val[1].b = EINA_FALSE;
89    selective_mode.changed = EINA_FALSE;
90
91    E_Border_Aux_Hint *hint;
92    Eina_List *l;
93    EINA_LIST_FOREACH(bd->client.e.state.aux_hint.hints, l, hint)
94      {
95         Eina_Bool send = EINA_FALSE;
96         if (!hint->deleted)
97           {
98              if (_STR_CMP(hint->hint, hint_names[0]))
99                {
100                   if (0) ;
101                   _VAL_CHECK(hint->val, "0", eff.val[1].b, EINA_FALSE, eff.changed)
102                   _VAL_CHECK(hint->val, "1", eff.val[1].b, EINA_TRUE,  eff.changed)
103                }
104              else if (_STR_CMP(hint->hint, hint_names[1]))
105                {
106                   if (0) ;
107                   _VAL_CHECK(hint->val, "0", dim.val[1].b, EINA_FALSE, dim.changed)
108                   _VAL_CHECK(hint->val, "1", dim.val[1].b, EINA_TRUE,  dim.changed)
109                }
110              else if (_STR_CMP(hint->hint, hint_names[2]))
111                {
112                   if (0) ;
113                   _VAL_CHECK(hint->val, "0", sync_draw.val[1].b, EINA_FALSE, sync_draw.changed)
114                   _VAL_CHECK(hint->val, "1", sync_draw.val[1].b, EINA_TRUE,  sync_draw.changed)
115                }
116              else if (_STR_CMP(hint->hint, hint_names[3]))
117                {
118                   if (0) ;
119                   _VAL_CHECK(hint->val, "0", selective_mode.val[1].b, EINA_FALSE, selective_mode.changed)
120                   _VAL_CHECK(hint->val, "1", selective_mode.val[1].b, EINA_TRUE,  selective_mode.changed)
121                }
122           }
123
124         if (hint->changed)
125           {
126              if (send)
127                e_border_aux_hint_reply_send(bd, hint->id);
128           }
129      }
130
131    if ((eff.changed) && (eff.val[0].b != eff.val[1].b))
132      cw->c->effect_funcs.state_set(cw->eff_type, eff.val[1].b);
133
134    if ((dim.changed) && (dim.val[0].b != dim.val[1].b))
135      {
136         E_Comp_Win_Type type = e_mod_comp_win_type_get(cw);
137         if ((type == E_COMP_WIN_TYPE_DIALOG) ||
138             (type == E_COMP_WIN_TYPE_NOTIFICATION))
139           {
140              /* TODO: make e,state,dim,on */
141              if (!dim.val[1].b)
142                {
143                   E_Comp_Object *co;
144                   Eina_List *l;
145                   EINA_LIST_FOREACH(cw->objs, l, co)
146                     {
147                        if (!co) continue;
148                        if ((co->shadow) && (co->img))
149                          {
150                             edje_object_signal_emit(co->shadow, "e,state,dim,off", "e");
151                          }
152                     }
153                }
154           }
155      }
156
157    if ((sync_draw.changed) && (sync_draw.val[0].b != sync_draw.val[1].b))
158      cw->sync_draw_support = sync_draw.val[1].b;
159
160    if ((selective_mode.changed) && (selective_mode.val[0].b != selective_mode.val[1].b))
161       cw->always_selective_mode = selective_mode.val[1].b;
162 }