E_FREE_LIST(actions, e_object_del);
E_FREE_LIST(hooks, e_client_hook_del);
- input_event_source = e_input_event_source_get();
- if (input_event_source)
+ if (e_input_thread_mode_get())
{
- if (_key_down_handler)
- e_input_event_handler_del(input_event_source, _key_down_handler);
+ input_event_source = e_input_event_source_get();
+ if (input_event_source)
+ {
+ if (_key_down_handler)
+ e_input_event_handler_del(input_event_source, _key_down_handler);
+ }
}
_key_down_handler = NULL;
uint32_t serial, keycode;
struct wl_client *wc = NULL;
E_Comp_Config *comp_conf = NULL;
+ const char *device_name = NULL;
keycode = (ev->keycode - 8);
if (wl_resource_get_client(res) != wc) continue;
TRACE_INPUT_BEGIN(_e_comp_wl_key_send);
- _e_comp_wl_send_event_e_device(wc, ev->timestamp, dev, serial);
+ if (!e_input_thread_mode_get())
+ {
+ _e_comp_wl_send_event_device(wc, ev->timestamp, ev->dev, serial);
+ device_name = ecore_device_name_get(ev->dev);
+ }
+ else
+ {
+ if (dev)
+ {
+ _e_comp_wl_send_event_e_device(wc, ev->timestamp, dev, serial);
+ device_name = e_device_name_get(dev);
+ }
+ }
if (comp_conf && comp_conf->input_log_enable)
- ELOGF("Key", "Send Key %s (time: %d, device: %s)", ec, (state ? "Down" : "Up"), ev->timestamp, e_device_name_get(dev));
+ ELOGF("Key", "Send Key %s (time: %d, device: %s)", ec, (state ? "Down" : "Up"), ev->timestamp, device_name);
wl_keyboard_send_key(res, serial, ev->timestamp,
keycode, state);
E_CONFIG_VAL(D, T, resize_object.border_width.b, INT);
E_CONFIG_VAL(D, T, resize_object.image_path, STR);
E_CONFIG_VAL(D, T, calc_vis_ignore_geometry, UINT);
+ E_CONFIG_VAL(D, T, input_thread_mode, UCHAR);
}
static Eina_Bool
E_CONFIG_LIMIT(e_config->resize_object.border_width.t, 0, 128);
E_CONFIG_LIMIT(e_config->resize_object.border_width.b, 0, 128);
E_CONFIG_LIMIT(e_config->calc_vis_ignore_geometry, 0, 1);
+ E_CONFIG_LIMIT(e_config->input_thread_mode, 0, 1);
}
EINTERN int
} resize_object;
Eina_Bool calc_vis_ignore_geometry; // 0: unset ignore geometry, 1: ignore geometry calculate when the calculation of visibility.
+ Eina_Bool input_thread_mode; // 0: process key input event in main thread, 1: process key input event in input thread
};
struct _E_Config_Desklock_Background
ev_key->keycode = e_devicemgr->dconfig->conf->input.back_keycode;
ev_key->data = key_data;
- E_Input_Event_Source *input_event_source = e_input_event_source_get();
- e_input_event_add(input_event_source, pressed ? ECORE_EVENT_KEY_DOWN : ECORE_EVENT_KEY_UP, ev_key, _e_devicemgr_input_keyevent_free, NULL);
+ if (e_input_thread_mode_get())
+ {
+ E_Input_Event_Source *input_event_source = e_input_event_source_get();
+ e_input_event_add(input_event_source, pressed ? ECORE_EVENT_KEY_DOWN : ECORE_EVENT_KEY_UP, ev_key, _e_devicemgr_input_keyevent_free, NULL);
+ }
+ else
+ {
+ ecore_event_add(pressed ? ECORE_EVENT_KEY_DOWN : ECORE_EVENT_KEY_UP, ev_key, _e_devicemgr_input_keyevent_free, NULL);
+ }
return ECORE_CALLBACK_DONE;
eina_stringshare_del(e->key);
eina_stringshare_del(e->compose);
+ if (e_input_thread_mode_get())
+ {
+ if (e->dev) g_object_unref(e->dev);
+ }
+ else
+ {
+ if (e->dev) ecore_device_unref(e->dev);
+ }
+
if (e->data) E_FREE(e->data);
free(e);
e->modifiers = 0;
- dev = e_input_evdev_get_e_device(identifier, ECORE_DEVICE_CLASS_KEYBOARD);
- e->dev = (Eo *)dev;
+ if (e_input_thread_mode_get())
+ {
+ dev = e_input_evdev_get_e_device(identifier, ECORE_DEVICE_CLASS_KEYBOARD);
+ e->dev = (Eo *)g_object_ref(dev);
+ }
+ else
+ {
+ e->dev = ecore_device_ref(e_input_evdev_get_ecore_device(identifier, ECORE_DEVICE_CLASS_KEYBOARD));
+ }
DMDBG("Generate key event: key: %s, keycode: %d, iden: %s\n", e->key, e->keycode, identifier);
- E_Input_Event_Source *input_event_source = e_input_event_source_get();
- e_input_event_add(input_event_source, pressed ? ECORE_EVENT_KEY_DOWN : ECORE_EVENT_KEY_UP, e, _e_devicemgr_inputgen_key_event_free, NULL);
+ if (e_input_thread_mode_get())
+ {
+ E_Input_Event_Source *input_event_source = e_input_event_source_get();
+ e_input_event_add(input_event_source, pressed ? ECORE_EVENT_KEY_DOWN : ECORE_EVENT_KEY_UP, e, _e_devicemgr_inputgen_key_event_free, NULL);
+ }
+ else
+ {
+ ecore_event_add(pressed ? ECORE_EVENT_KEY_DOWN : ECORE_EVENT_KEY_UP, e, _e_devicemgr_inputgen_key_event_free, NULL);
+ }
return TIZEN_INPUT_DEVICE_MANAGER_ERROR_NONE;
E_API E_Input_Hook *e_input_hook_add(E_Input_Hook_Point hookpoint, E_Input_Hook_Cb func, const void *data);
E_API void e_input_hook_del(E_Input_Hook *ch);
+
+E_API Eina_Bool e_input_thread_mode_get();
E_API E_Input_Event_Source *e_input_event_source_get();
EINTERN Eina_Bool e_input_relative_motion_handler_set(e_input_relative_motion_cb handler);
{
Ecore_Event_Key *ev = event;
- //if (ev->dev) ecore_device_unref(ev->dev);
+ if (e_input_thread_mode_get())
+ {
+ if (ev->dev) g_object_unref(ev->dev);
+ }
+ else
+ {
+ if (ev->dev) ecore_device_unref(ev->dev);
+ }
+
if (ev->data) E_FREE(ev->data);
free(ev);
e->same_screen = 1;
e->keycode = code;
e->data = key_data;
- e->dev = (Eo *)e_dev;
_device_modifiers_update(edev);
e->modifiers = edev->xkb.modifiers;
comp_conf = e_comp_config_get();
- if (comp_conf && comp_conf->input_log_enable)
- ELOGF("Key", "%s (keyname: %s, keycode: %d, device: %s)", NULL, state?"Press":"Release", e->keyname, e->keycode, e_device_name_get(e_dev));
- e_input_event_add(input->event_source, state ? ECORE_EVENT_KEY_DOWN : ECORE_EVENT_KEY_UP, e, _e_input_event_key_cb_free, NULL);
+ if (e_input_thread_mode_get())
+ {
+ e->dev = (Eo *)g_object_ref(e_dev);
+ if (comp_conf && comp_conf->input_log_enable)
+ ELOGF("Key", "%s (keyname: %s, keycode: %d, device: %s)", NULL, state?"Press":"Release", e->keyname, e->keycode, e_device_name_get(e_dev));
+ e_input_event_add(input->event_source, state ? ECORE_EVENT_KEY_DOWN : ECORE_EVENT_KEY_UP, e, _e_input_event_key_cb_free, NULL);
+ }
+ else
+ {
+ e->dev = ecore_device_ref(ecore_dev);
+ if (comp_conf && comp_conf->input_log_enable)
+ ELOGF("Key", "%s (keyname: %s, keycode: %d, device: %s)", NULL, state?"Press":"Release", e->keyname, e->keycode, ecore_device_name_get(ecore_dev));
+
+ ecore_event_add(state ? ECORE_EVENT_KEY_DOWN : ECORE_EVENT_KEY_UP, e, _e_input_event_key_cb_free, NULL);
+ }
if (tmp) free(tmp);
}
#ifndef E_INPUT_EVENT_H
#define E_INPUT_EVENT_H
-typedef gboolean (*ev_handler_func)(void *func_data, int type, void *user_data);
+typedef Eina_Bool (*ev_handler_func)(void *func_data, int type, void *user_data);
typedef void (*ev_free_func)(void *user_data, void *event_data);
struct _e_input_event_handler {
}
}
+static Eina_Bool
+_cb_input_dispatch(void *data, Ecore_Fd_Handler *hdlr EINA_UNUSED)
+{
+ E_Input_Backend *input;
+
+ if (!(input = data)) return EINA_TRUE;
+
+ if (libinput_dispatch(input->libinput) != 0)
+ ERR("Failed to dispatch libinput events: %m");
+
+ /* process pending events */
+ _input_events_process(input);
+
+ return EINA_TRUE;
+}
+
static gboolean
input_thread_prepare(GSource *source, gint *time)
{
input->fd = libinput_get_fd(input->libinput);
+ if (!e_input_thread_mode_get())
+ {
+ if (!input->hdlr)
+ {
+ input->hdlr =
+ ecore_main_fd_handler_add(input->fd, ECORE_FD_READ,
+ _cb_input_dispatch, input, NULL, NULL);
+ }
+
+ if (input->suspended)
+ {
+ if (libinput_resume(input->libinput) != 0)
+ goto err;
+
+ input->suspended = EINA_FALSE;
+
+ /* process pending events */
+ _input_events_process(input);
+ }
+ }
+
input->enabled = EINA_TRUE;
input->suspended = EINA_FALSE;
- input->input_thread = ecore_thread_feedback_run(input_thread_start, input_thread_feedback, input_thread_end, input_thread_cancel, input, EINA_FALSE);
+ if (e_input_thread_mode_get())
+ {
+ input->input_thread = ecore_thread_feedback_run(input_thread_start, input_thread_feedback, input_thread_end, input_thread_cancel, input, EINA_FALSE);
+ }
return EINA_TRUE;
err:
input->enabled = EINA_FALSE;
+ if (!e_input_thread_mode_get())
+ {
+ if (input->hdlr)
+ ecore_main_fd_handler_del(input->hdlr);
+ input->hdlr = NULL;
+ }
return EINA_FALSE;
}
input->suspended = EINA_TRUE;
- if (input->input_thread && !ecore_thread_check(input->input_thread))
- ecore_thread_cancel(input->input_thread);
+ if (e_input_thread_mode_get())
+ {
+ if (input->input_thread && !ecore_thread_check(input->input_thread))
+ ecore_thread_cancel(input->input_thread);
+ }
}
EINTERN Eina_List *
e_input_event_source_get()
{
return g_input_event_source;
-}
\ No newline at end of file
+}
+
+E_API Eina_Bool
+e_input_thread_mode_get()
+{
+ if (e_config)
+ return e_config->input_thread_mode;
+ else
+ return EINA_TRUE;
+}
log_fl = NULL;
}
-static gboolean
+static Eina_Bool
_e_keyrouter_cb_key_down(void *data, int type, void *event)
{
Ecore_Event_Key *ev;
return e_keyrouter_event_process(event, (E_Device *)ev->dev, type);
}
-static gboolean
+static Eina_Bool
_e_keyrouter_cb_key_up(void *data, int type, void *event)
{
Ecore_Event_Key *ev;
E_LIST_HANDLER_APPEND(krt->handlers, E_EVENT_CLIENT_STACK, _e_keyrouter_client_cb_stack, NULL);
E_LIST_HANDLER_APPEND(krt->handlers, E_EVENT_CLIENT_REMOVE, _e_keyrouter_client_cb_remove, NULL);
- input_event_source = e_input_event_source_get();
- if (input_event_source)
+ if (!e_input_thread_mode_get())
{
- krt->_key_down_handler = e_input_event_handler_add(input_event_source, ECORE_EVENT_KEY_DOWN, _e_keyrouter_cb_key_down, NULL);
- krt->_key_up_handler = e_input_event_handler_add(input_event_source, ECORE_EVENT_KEY_UP, _e_keyrouter_cb_key_up, NULL);
+ E_LIST_HANDLER_APPEND(krt->handlers, ECORE_EVENT_KEY_DOWN, _e_keyrouter_cb_key_down, NULL);
+ E_LIST_HANDLER_APPEND(krt->handlers, ECORE_EVENT_KEY_UP, _e_keyrouter_cb_key_up, NULL);
+ }
+ else
+ {
+ input_event_source = e_input_event_source_get();
+ if (input_event_source)
+ {
+ krt->_key_down_handler = e_input_event_handler_add(input_event_source, ECORE_EVENT_KEY_DOWN, _e_keyrouter_cb_key_down, NULL);
+ krt->_key_up_handler = e_input_event_handler_add(input_event_source, ECORE_EVENT_KEY_UP, _e_keyrouter_cb_key_up, NULL);
+ }
}
e_info_server_hook_set("keyrouter", _e_keyrouter_info_print, NULL);
EINA_LIST_FREE(krt->handlers, h)
ecore_event_handler_del(h);
- input_event_source = e_input_event_source_get();
- if (input_event_source)
+ if (e_input_thread_mode_get())
{
- if (krt->_key_down_handler)
- e_input_event_handler_del(input_event_source, krt->_key_down_handler);
+ input_event_source = e_input_event_source_get();
+ if (input_event_source)
+ {
+ if (krt->_key_down_handler)
+ e_input_event_handler_del(input_event_source, krt->_key_down_handler);
- if (krt->_key_up_handler)
- e_input_event_handler_del(input_event_source, krt->_key_up_handler);
- }
+ if (krt->_key_up_handler)
+ e_input_event_handler_del(input_event_source, krt->_key_up_handler);
+ }
- krt->_key_down_handler = NULL;
- krt->_key_up_handler = NULL;
+ krt->_key_down_handler = NULL;
+ krt->_key_up_handler = NULL;
+ }
e_info_server_hook_set("keyrouter", NULL, NULL);
e_info_server_hook_set("keygrab", NULL, NULL);
eina_stringshare_del(ev->string);
eina_stringshare_del(ev->compose);
+ if (e_input_thread_mode_get())
+ {
+ if (ev->dev) g_object_unref(ev->dev);
+ }
+ else
+ {
+ if (ev->dev) ecore_device_unref(ev->dev);
+ }
if (ev->data) E_FREE(ev->data);
- if (ev->dev) ecore_device_unref(ev->dev);
E_FREE(ev);
}
wc = wl_resource_get_client(res);
if (!focused && wc != client) continue;
TRACE_INPUT_BEGIN(_e_comp_wl_key_send);
- if (dev)
- e_comp_wl_send_event_e_device(client, ev->timestamp, dev, serial);
+ if (!e_input_thread_mode_get())
+ {
+ e_comp_wl_send_event_device(client, ev->timestamp, ev->dev, serial);
+ }
+ else
+ {
+ if (dev)
+ e_comp_wl_send_event_e_device(client, ev->timestamp, dev, serial);
+ }
if (comp_conf && comp_conf->input_log_enable)
INF("[Server] Routed Key %s (time: %d)\n", (state ? "Down" : "Up"), ev->timestamp);