2 #include "e_devicemgr_intern.h"
3 #include "e_devicemgr_private.h"
5 E_API E_Devicemgr *e_devicemgr;
7 static int _e_devicemgr_intercept_hooks_delete = 0;
8 static int _e_devicemgr_intercept_hooks_walking = 0;
10 static Eina_Inlist *_e_devicemgr_intercept_hooks[] =
12 [E_DEVICEMGR_INTERCEPT_HOOK_DETENT] = NULL,
15 int _devicemgr_log_dom = -1;
17 EINTERN E_Devicemgr_Intercept_Hook *
18 e_devicemgr_intercept_hook_add(E_Devicemgr_Intercept_Hook_Point hookpoint, E_Devicemgr_Intercept_Hook_Cb func, const void *data)
20 E_Devicemgr_Intercept_Hook *ch;
22 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint < 0 || hookpoint >= E_DEVICEMGR_INTERCEPT_HOOK_LAST,
25 ch = E_NEW(E_Devicemgr_Intercept_Hook, 1);
27 ch->hookpoint = hookpoint;
29 ch->data = (void*)data;
30 _e_devicemgr_intercept_hooks[hookpoint] = eina_inlist_append(_e_devicemgr_intercept_hooks[hookpoint], EINA_INLIST_GET(ch));
35 e_devicemgr_intercept_hook_del(E_Devicemgr_Intercept_Hook *ch)
37 EINA_SAFETY_ON_NULL_RETURN(ch);
40 if (_e_devicemgr_intercept_hooks_walking == 0)
42 _e_devicemgr_intercept_hooks[ch->hookpoint] = eina_inlist_remove(_e_devicemgr_intercept_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
46 _e_devicemgr_intercept_hooks_delete++;
50 _e_devicemgr_intercept_hooks_clean(void)
53 E_Devicemgr_Intercept_Hook *ch;
55 for (x = 0; x < E_DEVICEMGR_INTERCEPT_HOOK_LAST; x++)
56 EINA_INLIST_FOREACH_SAFE(_e_devicemgr_intercept_hooks[x], l, ch)
58 if (!ch->delete_me) continue;
59 _e_devicemgr_intercept_hooks[x] = eina_inlist_remove(_e_devicemgr_intercept_hooks[x], EINA_INLIST_GET(ch));
65 e_devicemgr_intercept_hook_call(E_Devicemgr_Intercept_Hook_Point hookpoint, void *event)
67 E_Devicemgr_Intercept_Hook *ch;
68 Eina_Bool res = EINA_TRUE, ret = EINA_TRUE;
70 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint < 0 || hookpoint >= E_DEVICEMGR_INTERCEPT_HOOK_LAST,
73 _e_devicemgr_intercept_hooks_walking++;
74 EINA_INLIST_FOREACH(_e_devicemgr_intercept_hooks[hookpoint], ch)
76 if (ch->delete_me) continue;
77 res = ch->func(ch->data, hookpoint, event);
78 if (!res) ret = EINA_FALSE;
80 _e_devicemgr_intercept_hooks_walking--;
81 if ((_e_devicemgr_intercept_hooks_walking == 0) && (_e_devicemgr_intercept_hooks_delete > 0))
82 _e_devicemgr_intercept_hooks_clean();
88 e_devicemgr_is_blocking_event(Ecore_Device_Class clas)
90 unsigned int dev_clas = 0x0;
94 case ECORE_DEVICE_CLASS_KEYBOARD:
95 dev_clas = TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD;
97 case ECORE_DEVICE_CLASS_MOUSE:
98 dev_clas = TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE;
100 case ECORE_DEVICE_CLASS_TOUCH:
101 dev_clas = TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
107 if (e_devicemgr->block.devtype & dev_clas)
114 e_devicemgr_init(void)
116 E_Devicemgr_Config_Data *dconfig = NULL;
117 Eina_Bool res = EINA_FALSE;
119 EINA_SAFETY_ON_NULL_GOTO(e_comp, failed);
121 _devicemgr_log_dom = eina_log_domain_register("e-devicemgr", EINA_COLOR_BLUE);
122 EINA_SAFETY_ON_FALSE_GOTO(_devicemgr_log_dom >= 0, failed);
123 eina_log_domain_level_set("e-devicemgr", EINA_LOG_LEVEL_INFO);
125 e_devicemgr = E_NEW(E_Devicemgr, 1);
126 EINA_SAFETY_ON_NULL_GOTO(e_devicemgr, failed);
128 dconfig = E_NEW(E_Devicemgr_Config_Data, 1);
129 EINA_SAFETY_ON_NULL_GOTO(dconfig, failed);
131 e_devicemgr_conf_init(dconfig);
132 e_devicemgr->dconfig = dconfig;
134 g_rec_mutex_init(&e_devicemgr->device_list_mutex);
136 res = e_devicemgr_wl_init();
137 EINA_SAFETY_ON_FALSE_GOTO(res, wl_failed);
139 res = e_devicemgr_input_init();
140 EINA_SAFETY_ON_FALSE_GOTO(res, input_failed);
145 e_devicemgr_input_shutdown();
148 e_devicemgr_wl_shutdown();
154 if (e_devicemgr->dconfig)
156 e_devicemgr_conf_fini(e_devicemgr->dconfig);
157 E_FREE(e_devicemgr->dconfig);
158 e_devicemgr->dconfig = NULL;
164 eina_log_domain_unregister(_devicemgr_log_dom);
165 _devicemgr_log_dom = -1;
170 e_devicemgr_shutdown(void)
172 g_rec_mutex_clear(&e_devicemgr->device_list_mutex);
174 eina_log_domain_unregister(_devicemgr_log_dom);
175 _devicemgr_log_dom = -1;
176 if (e_devicemgr->dconfig)
178 e_devicemgr_conf_fini(e_devicemgr->dconfig);
179 E_FREE(e_devicemgr->dconfig);
180 e_devicemgr->dconfig = NULL;
187 e_devicemgr_block_internal_add(Ecore_Device_Class clas, Eina_Bool all_class, uint32_t duration, E_Devicemgr_Block_Expire_Cb cb_func, void *cb_data)
189 unsigned int dev_clas = 0x0;
192 dev_clas = TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD |
193 TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE |
194 TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
199 case ECORE_DEVICE_CLASS_KEYBOARD:
200 dev_clas = TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD;
202 case ECORE_DEVICE_CLASS_MOUSE:
203 dev_clas = TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE;
205 case ECORE_DEVICE_CLASS_TOUCH:
206 dev_clas = TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
213 return e_devicemgr_block_add_internal(dev_clas, duration, cb_func, cb_data);
217 e_devicemgr_block_internal_remove(E_Devicemgr_Block_Expire_Cb cb_func, void *cb_data)
219 return e_devicemgr_block_remove_internal(cb_func, cb_data);
223 e_devicemgr_block_reset(void)
227 if (!e_devicemgr->block.client) return EINA_FALSE;
228 ret = e_devicemgr_block_remove(e_devicemgr->block.client);
229 if (ret == TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE)