2 #include "e_devicemgr_private.h"
4 E_API E_Devicemgr *e_devicemgr;
6 static int _e_devicemgr_intercept_hooks_delete = 0;
7 static int _e_devicemgr_intercept_hooks_walking = 0;
9 static Eina_Inlist *_e_devicemgr_intercept_hooks[] =
11 [E_DEVICEMGR_INTERCEPT_HOOK_DETENT] = NULL,
14 int _devicemgr_log_dom = -1;
16 EINTERN E_Devicemgr_Intercept_Hook *
17 e_devicemgr_intercept_hook_add(E_Devicemgr_Intercept_Hook_Point hookpoint, E_Devicemgr_Intercept_Hook_Cb func, const void *data)
19 E_Devicemgr_Intercept_Hook *ch;
21 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint < 0 || hookpoint >= E_DEVICEMGR_INTERCEPT_HOOK_LAST,
24 ch = E_NEW(E_Devicemgr_Intercept_Hook, 1);
26 ch->hookpoint = hookpoint;
28 ch->data = (void*)data;
29 _e_devicemgr_intercept_hooks[hookpoint] = eina_inlist_append(_e_devicemgr_intercept_hooks[hookpoint], EINA_INLIST_GET(ch));
34 e_devicemgr_intercept_hook_del(E_Devicemgr_Intercept_Hook *ch)
36 EINA_SAFETY_ON_NULL_RETURN(ch);
39 if (_e_devicemgr_intercept_hooks_walking == 0)
41 _e_devicemgr_intercept_hooks[ch->hookpoint] = eina_inlist_remove(_e_devicemgr_intercept_hooks[ch->hookpoint], EINA_INLIST_GET(ch));
45 _e_devicemgr_intercept_hooks_delete++;
49 _e_devicemgr_intercept_hooks_clean(void)
52 E_Devicemgr_Intercept_Hook *ch;
54 for (x = 0; x < E_DEVICEMGR_INTERCEPT_HOOK_LAST; x++)
55 EINA_INLIST_FOREACH_SAFE(_e_devicemgr_intercept_hooks[x], l, ch)
57 if (!ch->delete_me) continue;
58 _e_devicemgr_intercept_hooks[x] = eina_inlist_remove(_e_devicemgr_intercept_hooks[x], EINA_INLIST_GET(ch));
64 e_devicemgr_intercept_hook_call(E_Devicemgr_Intercept_Hook_Point hookpoint, void *event)
66 E_Devicemgr_Intercept_Hook *ch;
67 Eina_Bool res = EINA_TRUE, ret = EINA_TRUE;
69 EINA_SAFETY_ON_TRUE_RETURN_VAL(hookpoint < 0 || hookpoint >= E_DEVICEMGR_INTERCEPT_HOOK_LAST,
72 _e_devicemgr_intercept_hooks_walking++;
73 EINA_INLIST_FOREACH(_e_devicemgr_intercept_hooks[hookpoint], ch)
75 if (ch->delete_me) continue;
76 res = ch->func(ch->data, hookpoint, event);
77 if (!res) ret = EINA_FALSE;
79 _e_devicemgr_intercept_hooks_walking--;
80 if ((_e_devicemgr_intercept_hooks_walking == 0) && (_e_devicemgr_intercept_hooks_delete > 0))
81 _e_devicemgr_intercept_hooks_clean();
87 e_devicemgr_is_blocking_event(Ecore_Device_Class clas)
89 unsigned int dev_clas = 0x0;
93 case ECORE_DEVICE_CLASS_KEYBOARD:
94 dev_clas = TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD;
96 case ECORE_DEVICE_CLASS_MOUSE:
97 dev_clas = TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE;
99 case ECORE_DEVICE_CLASS_TOUCH:
100 dev_clas = TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
106 if (e_devicemgr->block.devtype & dev_clas)
113 e_devicemgr_init(void)
115 E_Devicemgr_Config_Data *dconfig = NULL;
116 Eina_Bool res = EINA_FALSE;
118 EINA_SAFETY_ON_NULL_GOTO(e_comp, failed);
120 _devicemgr_log_dom = eina_log_domain_register("e-devicemgr", EINA_COLOR_BLUE);
121 EINA_SAFETY_ON_FALSE_GOTO(_devicemgr_log_dom >= 0, failed);
122 eina_log_domain_level_set("e-devicemgr", EINA_LOG_LEVEL_INFO);
124 e_devicemgr = E_NEW(E_Devicemgr, 1);
125 EINA_SAFETY_ON_NULL_GOTO(e_devicemgr, failed);
127 dconfig = E_NEW(E_Devicemgr_Config_Data, 1);
128 EINA_SAFETY_ON_NULL_GOTO(dconfig, failed);
130 e_devicemgr_conf_init(dconfig);
131 e_devicemgr->dconfig = dconfig;
133 g_rec_mutex_init(&e_devicemgr->device_list_mutex);
135 res = e_devicemgr_wl_init();
136 EINA_SAFETY_ON_FALSE_GOTO(res, wl_failed);
138 res = e_devicemgr_input_init();
139 EINA_SAFETY_ON_FALSE_GOTO(res, input_failed);
144 e_devicemgr_input_shutdown();
147 e_devicemgr_wl_shutdown();
153 if (e_devicemgr->dconfig)
155 e_devicemgr_conf_fini(e_devicemgr->dconfig);
156 E_FREE(e_devicemgr->dconfig);
157 e_devicemgr->dconfig = NULL;
163 eina_log_domain_unregister(_devicemgr_log_dom);
164 _devicemgr_log_dom = -1;
169 e_devicemgr_shutdown(void)
171 g_rec_mutex_clear(&e_devicemgr->device_list_mutex);
173 eina_log_domain_unregister(_devicemgr_log_dom);
174 _devicemgr_log_dom = -1;
175 if (e_devicemgr->dconfig)
177 e_devicemgr_conf_fini(e_devicemgr->dconfig);
178 E_FREE(e_devicemgr->dconfig);
179 e_devicemgr->dconfig = NULL;
186 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)
188 unsigned int dev_clas = 0x0;
191 dev_clas = TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD |
192 TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE |
193 TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
198 case ECORE_DEVICE_CLASS_KEYBOARD:
199 dev_clas = TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD;
201 case ECORE_DEVICE_CLASS_MOUSE:
202 dev_clas = TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE;
204 case ECORE_DEVICE_CLASS_TOUCH:
205 dev_clas = TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN;
212 return e_devicemgr_block_add_internal(dev_clas, duration, cb_func, cb_data);
216 e_devicemgr_block_internal_remove(E_Devicemgr_Block_Expire_Cb cb_func, void *cb_data)
218 return e_devicemgr_block_remove_internal(cb_func, cb_data);
222 e_devicemgr_block_reset(void)
226 if (!e_devicemgr->block.client) return EINA_FALSE;
227 ret = e_devicemgr_block_remove(e_devicemgr->block.client);
228 if (ret == TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE)