From 6b1910338d609b22900c6a62d68f87274aa16204 Mon Sep 17 00:00:00 2001 From: jeon Date: Fri, 22 May 2020 13:35:40 +0900 Subject: [PATCH] e_input: block input events in e_input layer insteads of devicemgr Change-Id: I29e2044b905198a081693eb13d2e1b8cc28c483a --- src/bin/e_devicemgr.h | 4 - src/bin/e_devicemgr_block.c | 226 ++++++++++++---------------------- src/bin/e_devicemgr_input.c | 51 -------- src/bin/e_devicemgr_private.h | 3 - src/bin/e_input.h | 10 ++ src/bin/e_input_device.c | 80 ++++++++++++ src/bin/e_input_evdev.c | 179 ++++++++++++++++++++++++--- src/bin/e_input_inputs.c | 1 + src/bin/e_input_private.h | 6 + 9 files changed, 339 insertions(+), 221 deletions(-) diff --git a/src/bin/e_devicemgr.h b/src/bin/e_devicemgr.h index a703d73ee9..40345ccb1c 100644 --- a/src/bin/e_devicemgr.h +++ b/src/bin/e_devicemgr.h @@ -65,10 +65,6 @@ struct _E_Devicemgr void *internal_cb_data; } block; - Eina_List *pressed_keys; - unsigned int pressed_button; - unsigned int pressed_finger; - int virtual_key_device_fd; int virtual_mouse_device_fd; diff --git a/src/bin/e_devicemgr_block.c b/src/bin/e_devicemgr_block.c index 1aa15b901c..a26e3b0309 100644 --- a/src/bin/e_devicemgr_block.c +++ b/src/bin/e_devicemgr_block.c @@ -2,157 +2,13 @@ static void _e_devicemgr_block_client_cb_destroy(struct wl_listener *l, void *data); -Eina_Bool -e_devicemgr_block_check_keyboard(Ecore_Event_Key *ev, Eina_Bool pressed) -{ - Eina_List *l, *l_next; - int *keycode, *data; - - EINA_SAFETY_ON_NULL_RETURN_VAL(ev, ECORE_CALLBACK_PASS_ON); - - if ((e_devicemgr->block.devtype & TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD) || - (e_devicemgr->block.internal_devtype & TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD)) - { - if (!pressed) - { - EINA_LIST_FOREACH_SAFE(e_devicemgr->pressed_keys, l, l_next, data) - { - if (ev->keycode == *data) - { - DMERR("%d is already press key. Propagate this key event.\n", *data); - e_devicemgr->pressed_keys = eina_list_remove_list(e_devicemgr->pressed_keys, l); - E_FREE(data); - return ECORE_CALLBACK_PASS_ON; - } - } - } - return ECORE_CALLBACK_DONE; - } - - if (pressed) - { - keycode = E_NEW(int, 1); - EINA_SAFETY_ON_NULL_RETURN_VAL(keycode, ECORE_CALLBACK_PASS_ON); - - *keycode = ev->keycode; - - EINA_LIST_FOREACH(e_devicemgr->pressed_keys, l, data) - { - if (*data == *keycode) - { - E_FREE(keycode); - return ECORE_CALLBACK_PASS_ON; - } - } - e_devicemgr->pressed_keys = eina_list_append(e_devicemgr->pressed_keys, keycode); - } - else - { - EINA_LIST_FOREACH_SAFE(e_devicemgr->pressed_keys, l, l_next, data) - { - if (ev->keycode == *data) - { - e_devicemgr->pressed_keys = eina_list_remove_list(e_devicemgr->pressed_keys, l); - E_FREE(data); - } - } - } - - return ECORE_CALLBACK_PASS_ON; -} - -Eina_Bool -e_devicemgr_block_check_button(Ecore_Event_Mouse_Button *ev, Eina_Bool pressed) -{ - Ecore_Device *dev; - - EINA_SAFETY_ON_NULL_RETURN_VAL(ev, ECORE_CALLBACK_PASS_ON); - dev = ev->dev; - EINA_SAFETY_ON_NULL_RETURN_VAL(dev, ECORE_CALLBACK_PASS_ON); - - if (ecore_device_class_get(dev) == ECORE_DEVICE_CLASS_MOUSE) - { - if ((e_devicemgr->block.devtype & TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE) || - (e_devicemgr->block.internal_devtype & TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE)) - { - if (!pressed) - { - if (e_devicemgr->pressed_button & (1 << ev->buttons)) - { - e_devicemgr->pressed_button &= ~(1 << ev->buttons); - return ECORE_CALLBACK_PASS_ON; - } - } - return ECORE_CALLBACK_DONE; - } - - if (pressed) - { - e_devicemgr->pressed_button |= (1 << ev->buttons); - } - else - e_devicemgr->pressed_button &= ~(1 << ev->buttons); - } - else if (ecore_device_class_get(dev) == ECORE_DEVICE_CLASS_TOUCH) - { - if ((e_devicemgr->block.devtype & TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN) || - (e_devicemgr->block.internal_devtype & TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN)) - { - if (!pressed) - { - if (e_devicemgr->pressed_finger & (1 << ev->multi.device)) - { - e_devicemgr->pressed_finger &= ~(1 << ev->multi.device); - return ECORE_CALLBACK_PASS_ON; - } - } - return ECORE_CALLBACK_DONE; - } - - if (pressed) - { - e_devicemgr->pressed_finger |= (1 << ev->multi.device); - } - else - e_devicemgr->pressed_finger &= ~(1 << ev->multi.device); - } - - return ECORE_CALLBACK_PASS_ON; -} - -Eina_Bool -e_devicemgr_block_check_move(Ecore_Event_Mouse_Move *ev) -{ - Ecore_Device *dev; - - EINA_SAFETY_ON_NULL_RETURN_VAL(ev, ECORE_CALLBACK_PASS_ON); - dev = ev->dev; - EINA_SAFETY_ON_NULL_RETURN_VAL(dev, ECORE_CALLBACK_PASS_ON); - - if (ecore_device_class_get(dev) == ECORE_DEVICE_CLASS_MOUSE) - { - if ((e_devicemgr->block.devtype & TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE) || - (e_devicemgr->block.internal_devtype & TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE)) - { - return ECORE_CALLBACK_DONE; - } - } - else if (ecore_device_class_get(dev) == ECORE_DEVICE_CLASS_TOUCH) - { - if ((e_devicemgr->block.devtype & TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN) || - (e_devicemgr->block.internal_devtype & TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN)) - { - return ECORE_CALLBACK_DONE; - } - } - - return ECORE_CALLBACK_PASS_ON; -} - static void _e_devicemgr_block_client_remove(struct wl_client *client) { struct wl_listener *destroy_listener = NULL; + Eina_List *dev_list, *l; + E_Input_Device *device_data; + Eina_Bool res = EINA_TRUE; if (client != e_devicemgr->block.client) return; @@ -170,6 +26,12 @@ _e_devicemgr_block_client_remove(struct wl_client *client) E_FREE(destroy_listener); } + dev_list = (Eina_List *)e_input_devices_get(); + EINA_LIST_FOREACH(dev_list, l, device_data) + { + res = e_input_device_unblock(device_data, client); + if (!res) DMWRN("Failed to request unblock client: %p", client); + } } static Eina_Bool @@ -207,6 +69,10 @@ _e_devicemgr_block_client_add(struct wl_client *client, struct wl_resource *reso { struct wl_listener *destroy_listener = NULL; double milli_duration = (double)(duration) / 1000.0; + unsigned int block_type = 0x0; + Eina_List *dev_list, *l; + E_Input_Device *device_data; + Eina_Bool res = EINA_TRUE; /* Last request of block can renew timer time */ if (e_devicemgr->block.duration_timer) @@ -223,6 +89,26 @@ _e_devicemgr_block_client_add(struct wl_client *client, struct wl_resource *reso destroy_listener->notify = _e_devicemgr_block_client_cb_destroy; wl_client_add_destroy_listener(client, destroy_listener); + if (e_devicemgr->block.devtype & TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE) + { + block_type |= E_INPUT_SEAT_POINTER; + } + if (e_devicemgr->block.devtype & TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD) + { + block_type |= E_INPUT_SEAT_KEYBOARD; + } + if (e_devicemgr->block.devtype & TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN) + { + block_type |= E_INPUT_SEAT_TOUCH; + } + + dev_list = (Eina_List *)e_input_devices_get(); + EINA_LIST_FOREACH(dev_list, l, device_data) + { + res = e_input_device_block(device_data, block_type, client); + if (!res) DMWRN("Failed to request block block_type: 0x%x, client: %p", block_type, client); + } + return; failed: @@ -270,6 +156,10 @@ e_devicemgr_block_remove(struct wl_client *client) static Eina_Bool _e_devicemgr_block_timer_internal(void *data) { + Eina_List *dev_list, *l; + E_Input_Device *device_data; + Eina_Bool res; + e_devicemgr->block.internal_devtype = 0x0; e_devicemgr->block.internal_duration_timer = NULL; @@ -281,6 +171,13 @@ _e_devicemgr_block_timer_internal(void *data) e_devicemgr->block.internal_cb_func = NULL; e_devicemgr->block.internal_cb_data = NULL; + dev_list = (Eina_List *)e_input_devices_get(); + EINA_LIST_FOREACH(dev_list, l, device_data) + { + res = e_input_device_unblock(device_data, E_INPUT_REQUEST_SERVER); + if (!res) DMWRN("Failed to request unblock by server"); + } + return ECORE_CALLBACK_DONE; } @@ -292,6 +189,10 @@ e_devicemgr_block_add_internal(uint32_t clas, uint32_t duration, E_Devicemgr_Blo uint32_t all_class = TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE | TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD | TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN; + unsigned int block_type = 0x0; + Eina_List *dev_list, *l; + E_Input_Device *device_data; + Eina_Bool res; if (!(clas & all_class)) return EINA_FALSE; @@ -304,12 +205,36 @@ e_devicemgr_block_add_internal(uint32_t clas, uint32_t duration, E_Devicemgr_Blo e_devicemgr->block.internal_cb_func = cb_func; e_devicemgr->block.internal_cb_data = cb_data; + if (e_devicemgr->block.internal_devtype & TIZEN_INPUT_DEVICE_MANAGER_CLAS_MOUSE) + { + block_type |= E_INPUT_SEAT_POINTER; + } + if (e_devicemgr->block.internal_devtype & TIZEN_INPUT_DEVICE_MANAGER_CLAS_KEYBOARD) + { + block_type |= E_INPUT_SEAT_KEYBOARD; + } + if (e_devicemgr->block.internal_devtype & TIZEN_INPUT_DEVICE_MANAGER_CLAS_TOUCHSCREEN) + { + block_type |= E_INPUT_SEAT_TOUCH; + } + + dev_list = (Eina_List *)e_input_devices_get(); + EINA_LIST_FOREACH(dev_list, l, device_data) + { + res = e_input_device_block(device_data, block_type, E_INPUT_REQUEST_SERVER); + if (!res) DMWRN("Failed to request block block_type: 0x%x by server", block_type); + } + return EINA_TRUE; } Eina_Bool e_devicemgr_block_remove_internal(E_Devicemgr_Block_Expire_Cb cb_func, void *cb_data) { + Eina_List *dev_list, *l; + E_Input_Device *device_data; + Eina_Bool res; + if ((e_devicemgr->block.internal_cb_func != cb_func) || (e_devicemgr->block.internal_cb_data != cb_data)) return EINA_FALSE; @@ -323,5 +248,12 @@ e_devicemgr_block_remove_internal(E_Devicemgr_Block_Expire_Cb cb_func, void *cb_ e_devicemgr->block.internal_cb_func = NULL; e_devicemgr->block.internal_cb_data = NULL; + dev_list = (Eina_List *)e_input_devices_get(); + EINA_LIST_FOREACH(dev_list, l, device_data) + { + res = e_input_device_unblock(device_data, E_INPUT_REQUEST_SERVER); + if (!res) DMWRN("Failed to request unblock by server"); + } + return EINA_TRUE; } diff --git a/src/bin/e_devicemgr_input.c b/src/bin/e_devicemgr_input.c index f2c5d9e7f7..6175a2d266 100644 --- a/src/bin/e_devicemgr_input.c +++ b/src/bin/e_devicemgr_input.c @@ -311,9 +311,6 @@ _e_devicemgr_input_cb_mouse_button_down(void *data, int type, void *event) EINA_SAFETY_ON_NULL_RETURN_VAL(event, res); ev = (Ecore_Event_Mouse_Button *)event; - res = e_devicemgr_block_check_button(ev, EINA_TRUE); - if (res == ECORE_CALLBACK_DONE) return res; - if (e_devicemgr->dconfig->conf->input.button_remap_enable) res = _e_devicemgr_input_mouse_button_remap(ev, EINA_TRUE); @@ -337,9 +334,6 @@ _e_devicemgr_input_cb_mouse_button_up(void *data, int type, void *event) EINA_SAFETY_ON_NULL_RETURN_VAL(event, res); ev = (Ecore_Event_Mouse_Button *)event; - res = e_devicemgr_block_check_button(ev, EINA_FALSE); - if (res == ECORE_CALLBACK_DONE) return res; - if (e_devicemgr->dconfig->conf->input.button_remap_enable) res = _e_devicemgr_input_mouse_button_remap(ev, EINA_FALSE); @@ -353,20 +347,6 @@ _e_devicemgr_input_cb_mouse_button_up(void *data, int type, void *event) return res; } -static Eina_Bool -_e_devicemgr_input_cb_mouse_move(void *data, int type, void *event) -{ - Ecore_Event_Mouse_Move *ev; - Eina_Bool res = ECORE_CALLBACK_PASS_ON; - - EINA_SAFETY_ON_NULL_RETURN_VAL(event, res); - ev = (Ecore_Event_Mouse_Move *)event; - - res = e_devicemgr_block_check_move(ev); - - return res; -} - static Eina_Bool _e_devicemgr_input_cb_mouse_wheel(void *data, int type, void *event) { @@ -442,34 +422,6 @@ _e_devicemgr_input_cb_device_update(void *data, int type, void *event) return ECORE_CALLBACK_PASS_ON; } -static Eina_Bool -_e_devicemgr_input_cb_key_down(void *data, int type, void *event) -{ - Ecore_Event_Key *ev; - Eina_Bool res = ECORE_CALLBACK_PASS_ON; - - EINA_SAFETY_ON_NULL_RETURN_VAL(event, ECORE_CALLBACK_PASS_ON); - ev = (Ecore_Event_Key *)event; - - res = e_devicemgr_block_check_keyboard(ev, EINA_TRUE); - - return res; -} - -static Eina_Bool -_e_devicemgr_input_cb_key_up(void *data, int type, void *event) -{ - Ecore_Event_Key *ev; - Eina_Bool res = ECORE_CALLBACK_PASS_ON; - - EINA_SAFETY_ON_NULL_RETURN_VAL(event, ECORE_CALLBACK_PASS_ON); - ev = (Ecore_Event_Key *)event; - - res = e_devicemgr_block_check_keyboard(ev, EINA_FALSE); - - return res; -} - Eina_Bool e_devicemgr_input_init(void) { @@ -478,10 +430,7 @@ e_devicemgr_input_init(void) E_LIST_HANDLER_PREPEND(e_devicemgr->handlers, ECORE_EVENT_MOUSE_BUTTON_DOWN, _e_devicemgr_input_cb_mouse_button_down, NULL); E_LIST_HANDLER_PREPEND(e_devicemgr->handlers, ECORE_EVENT_MOUSE_BUTTON_UP, _e_devicemgr_input_cb_mouse_button_up, NULL); - E_LIST_HANDLER_PREPEND(e_devicemgr->handlers, ECORE_EVENT_MOUSE_MOVE, _e_devicemgr_input_cb_mouse_move, NULL); E_LIST_HANDLER_PREPEND(e_devicemgr->handlers, ECORE_EVENT_MOUSE_WHEEL, _e_devicemgr_input_cb_mouse_wheel, NULL); - E_LIST_HANDLER_PREPEND(e_devicemgr->handlers, ECORE_EVENT_KEY_DOWN, _e_devicemgr_input_cb_key_down, NULL); - E_LIST_HANDLER_PREPEND(e_devicemgr->handlers, ECORE_EVENT_KEY_UP, _e_devicemgr_input_cb_key_up, NULL); E_LIST_HANDLER_PREPEND(e_devicemgr->handlers, ECORE_EVENT_DEVICE_ADD, _e_devicemgr_input_cb_device_add, NULL); E_LIST_HANDLER_PREPEND(e_devicemgr->handlers, ECORE_EVENT_DEVICE_DEL, _e_devicemgr_input_cb_device_del, NULL); E_LIST_HANDLER_PREPEND(e_devicemgr->handlers, ECORE_EVENT_DEVICE_SUBCLASS_UPDATE, _e_devicemgr_input_cb_device_update, NULL); diff --git a/src/bin/e_devicemgr_private.h b/src/bin/e_devicemgr_private.h index b9c8eeb7fb..e9013e39d0 100644 --- a/src/bin/e_devicemgr_private.h +++ b/src/bin/e_devicemgr_private.h @@ -152,9 +152,6 @@ void e_devicemgr_wl_device_add(E_Devicemgr_Input_Device *dev); void e_devicemgr_wl_device_del(E_Devicemgr_Input_Device *dev); void e_devicemgr_wl_device_update(E_Devicemgr_Input_Device *dev); -Eina_Bool e_devicemgr_block_check_keyboard(Ecore_Event_Key *ev, Eina_Bool pressed); -Eina_Bool e_devicemgr_block_check_move(Ecore_Event_Mouse_Move *ev); -Eina_Bool e_devicemgr_block_check_button(Ecore_Event_Mouse_Button *ev, Eina_Bool pressed); void e_devicemgr_wl_block_send_expired(struct wl_resource *resource); int e_devicemgr_block_add(struct wl_client *client, struct wl_resource *resource, uint32_t clas, uint32_t duration); int e_devicemgr_block_remove(struct wl_client *client); diff --git a/src/bin/e_input.h b/src/bin/e_input.h index 7dd7694433..1743976345 100644 --- a/src/bin/e_input.h +++ b/src/bin/e_input.h @@ -13,6 +13,8 @@ E_API extern int E_EVENT_INPUT_DISABLED; #define E_INPUT_TYPE (int)0xE0b0beaf +#define E_INPUT_REQUEST_SERVER ((void *)0x1) + #include typedef enum _E_Input_Seat_Capabilities @@ -55,6 +57,10 @@ struct _E_Input_Device struct xkb_context *xkb_ctx; Ecore_Window window; Eina_Bool left_handed : 1; + + unsigned int blocked; + void *blocked_client; + unsigned int server_blocked; }; EINTERN int e_input_init(Ecore_Evas *ee); @@ -102,5 +108,9 @@ E_API Ecore_Device *e_input_evdev_get_ecore_device(const char *path, Ecore_Devic E_API unsigned int e_input_device_touch_pressed_get(E_Input_Device *dev); E_API Eina_Bool e_input_device_keyboard_remap_set(E_Input_Device *dev, int *from_keys, int *to_keys, int num); +EINTERN Eina_Bool e_input_device_block(E_Input_Device *dev, unsigned int type, void *client); +EINTERN Eina_Bool e_input_device_unblock(E_Input_Device *dev, void *client); + + #endif #endif diff --git a/src/bin/e_input_device.c b/src/bin/e_input_device.c index 8485e33696..dc1fb0cf09 100644 --- a/src/bin/e_input_device.c +++ b/src/bin/e_input_device.c @@ -1267,3 +1267,83 @@ e_input_device_keyboard_remap_set(E_Input_Device *dev, int *from_keys, int *to_k return ret; } + +EINTERN Eina_Bool +e_input_device_block(E_Input_Device *dev, unsigned int type, void *client) +{ + E_Input_Seat *seat = NULL; + E_Input_Evdev *edev = NULL; + Eina_List *l = NULL, *l2 = NULL; + + EINA_SAFETY_ON_NULL_RETURN_VAL(dev, EINA_FALSE); + + if (client && client != E_INPUT_REQUEST_SERVER) + { + if (dev->blocked_client && (dev->blocked_client != client)) + { + WRN("Already blocked by client: %p (type: 0x%x)\n", dev->blocked_client, dev->blocked); + return EINA_FALSE; + } + + dev->blocked |= type; + dev->blocked_client = client; + } + else if (client == E_INPUT_REQUEST_SERVER) + { + dev->server_blocked = type; + } + + if (type & E_INPUT_SEAT_TOUCH) + { + EINA_LIST_FOREACH(dev->seats, l, seat) + { + EINA_LIST_FOREACH(e_input_seat_evdev_list_get(seat), l2, edev) + { + edev->touch.blocked = EINA_TRUE; + } + } + } + + return EINA_TRUE; +} + +EINTERN Eina_Bool +e_input_device_unblock(E_Input_Device *dev, void *client) +{ + E_Input_Seat *seat = NULL; + E_Input_Evdev *edev = NULL; + Eina_List *l = NULL, *l2 = NULL; + + EINA_SAFETY_ON_NULL_RETURN_VAL(dev, EINA_FALSE); + + if (client != E_INPUT_REQUEST_SERVER && dev->blocked_client != client) + { + WRN("Currently %p client has already bloked (type: 0x%x)\n", dev->blocked_client, dev->blocked); + return EINA_FALSE; + } + + if ((dev->server_blocked & E_INPUT_SEAT_TOUCH) || + (dev->blocked & E_INPUT_SEAT_TOUCH)) + { + EINA_LIST_FOREACH(dev->seats, l, seat) + { + EINA_LIST_FOREACH(e_input_seat_evdev_list_get(seat), l2, edev) + { + if (edev->touch.raw_pressed == 0x0) + edev->touch.blocked = EINA_FALSE; + } + } + } + + if (client == E_INPUT_REQUEST_SERVER) + { + dev->server_blocked = 0x0; + } + else + { + dev->blocked = 0x0; + dev->blocked_client = NULL; + } + + return EINA_TRUE; +} \ No newline at end of file diff --git a/src/bin/e_input_evdev.c b/src/bin/e_input_evdev.c index e496c83c69..4618cff409 100644 --- a/src/bin/e_input_evdev.c +++ b/src/bin/e_input_evdev.c @@ -370,8 +370,10 @@ _device_handle_key(struct libinput_device *device, struct libinput_event_keyboar char *tmp = NULL, *compose = NULL; E_Keyrouter_Event_Data *key_data; Ecore_Device *ecore_dev = NULL, *data; - Eina_List *l; + Eina_List *l, *l_next; E_Comp_Config *comp_conf = NULL; + int *pressed_keycode = NULL, *idata = NULL; + Eina_Bool dup_found = EINA_FALSE; if (!(edev = libinput_device_get_user_data(device))) { @@ -413,6 +415,60 @@ _device_handle_key(struct libinput_device *device, struct libinput_event_keyboar state = libinput_event_keyboard_get_key_state(event); key_count = libinput_event_keyboard_get_seat_key_count(event); + if (state == LIBINPUT_KEY_STATE_PRESSED) + { + if ((edev->seat->dev->blocked & E_INPUT_SEAT_KEYBOARD) || + (edev->seat->dev->server_blocked & E_INPUT_SEAT_KEYBOARD)) + { + ELOGF("Key", "Press (keycode: %d, device: %s) is blocked by %p, server: 0x%x", NULL, + code, ecore_device_name_get(ecore_dev), edev->seat->dev->blocked_client, + edev->seat->dev->server_blocked); + return; + } + + /* FIXME: Currently to maintain press/release event pair during input block, + * used Eina_List and this is method used in devicemgr module. + * But we need to consider which way is better to maintain key press/release pair. + */ + + EINA_LIST_FOREACH(edev->xkb.pressed_keys, l, idata) + { + if (*idata == code) + { + dup_found = EINA_TRUE; + break; + } + } + if (!dup_found) + { + pressed_keycode = E_NEW(int, 1); + EINA_SAFETY_ON_NULL_RETURN(pressed_keycode); + *pressed_keycode = code; + + edev->xkb.pressed_keys = eina_list_append(edev->xkb.pressed_keys, pressed_keycode); + } + } + else + { + dup_found = EINA_FALSE; + EINA_LIST_FOREACH_SAFE(edev->xkb.pressed_keys, l, l_next, idata) + { + if (code == *idata) + { + edev->xkb.pressed_keys = eina_list_remove_list(edev->xkb.pressed_keys, l); + E_FREE(idata); + dup_found = EINA_TRUE; + break; + } + } + if (!dup_found) + { + ELOGF("Key", "Release (keycode: %d, device: %s) is blocked by %p", NULL, + code, ecore_device_name_get(ecore_dev), edev->seat->dev->blocked_client); + return; + } + } + /* ignore key events that are not seat wide state changes */ if (((state == LIBINPUT_KEY_STATE_PRESSED) && (key_count != 1)) || ((state == LIBINPUT_KEY_STATE_RELEASED) && (key_count != 0))) @@ -657,6 +713,12 @@ _device_handle_pointer_motion(struct libinput_device *device, struct libinput_ev edev->seat->ptr.ix = edev->seat->ptr.dx; edev->seat->ptr.iy = edev->seat->ptr.dy; + if ((edev->seat->dev->blocked & E_INPUT_SEAT_POINTER) || + (edev->seat->dev->server_blocked & E_INPUT_SEAT_POINTER)) + { + return; + } + _device_pointer_motion(edev, event); } @@ -686,6 +748,13 @@ _device_handle_pointer_motion_absolute(struct libinput_device *device, struct li edev->seat->ptr.ix = edev->seat->ptr.dx; edev->seat->ptr.iy = edev->seat->ptr.dy; + + if ((edev->seat->dev->blocked & E_INPUT_SEAT_POINTER) || + (edev->seat->dev->server_blocked & E_INPUT_SEAT_POINTER)) + { + return; + } + _device_pointer_motion(edev, event); } @@ -742,11 +811,6 @@ _device_handle_button(struct libinput_device *device, struct libinput_event_poin return; } - if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Button)))) - { - return; - } - state = libinput_event_pointer_get_button_state(event); button = libinput_event_pointer_get_button(event); timestamp = libinput_event_pointer_get_time(event); @@ -755,6 +819,38 @@ _device_handle_button(struct libinput_device *device, struct libinput_event_poin if (button == 3) button = 2; else if (button == 2) button = 3; + if (state) + { + if ((edev->seat->dev->blocked & E_INPUT_SEAT_POINTER) || + (edev->seat->dev->server_blocked & E_INPUT_SEAT_POINTER)) + { + ELOGF("Mouse", "Button Press (btn: %d, device: %s) is blocked by %p, server: 0x%x", NULL, + button, ecore_device_name_get(ecore_dev), edev->seat->dev->blocked_client, + edev->seat->dev->server_blocked); + return; + } + else + { + edev->mouse.pressed_button |= (1 << button); + } + } + else + { + if (!(edev->mouse.pressed_button & (1 << button))) + { + ELOGF("Mouse", "Button Release (btn: %d, device: %s) is blocked by %p, server: 0x%x", NULL, + button, ecore_device_name_get(ecore_dev), edev->seat->dev->blocked_client, + edev->seat->dev->server_blocked); + return; + } + edev->mouse.pressed_button &= ~(1 << button); + } + + if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Button)))) + { + return; + } + ev->window = (Ecore_Window)input->dev->window; ev->event_window = (Ecore_Window)input->dev->window; ev->root_window = (Ecore_Window)input->dev->window; @@ -837,6 +933,7 @@ _device_handle_axis(struct libinput_device *device, struct libinput_event_pointe Ecore_Device *ecore_dev = NULL, *detent_data = NULL, *data; Eina_List *l; E_Comp_Config *comp_conf = NULL; + int direction = 0, z = 0; if (!(edev = libinput_device_get_user_data(device))) { @@ -879,6 +976,29 @@ _device_handle_axis(struct libinput_device *device, struct libinput_event_pointe return; } + axis = LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL; + if (libinput_event_pointer_has_axis(event, axis)) + z = libinput_event_pointer_get_axis_value(event, axis); + + axis = LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL; + if (libinput_event_pointer_has_axis(event, axis)) + { + direction = 1; + z = libinput_event_pointer_get_axis_value(event, axis); + } + + if ((edev->seat->dev->blocked & E_INPUT_SEAT_POINTER) || + (edev->seat->dev->server_blocked & E_INPUT_SEAT_POINTER)) + { + if (detent_data) + ELOGF("Mouse", "Detent (direction: %d, value: %d) is blocked by %p, server: 0x%x", NULL, + direction, z, edev->seat->dev->blocked_client, edev->seat->dev->server_blocked); + else + ELOGF("Mouse", "Wheel (direction: %d, value: %d) is blocked by %p, server: 0x%x", NULL, + direction, z, edev->seat->dev->blocked_client, edev->seat->dev->server_blocked); + return; + } + if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Wheel)))) { return; @@ -901,16 +1021,8 @@ _device_handle_axis(struct libinput_device *device, struct libinput_event_pointe ev->root.y = ev->y; ev->dev = ecore_device_ref(ecore_dev); - axis = LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL; - if (libinput_event_pointer_has_axis(event, axis)) - ev->z = libinput_event_pointer_get_axis_value(event, axis); - - axis = LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL; - if (libinput_event_pointer_has_axis(event, axis)) - { - ev->direction = 1; - ev->z = libinput_event_pointer_get_axis_value(event, axis); - } + ev->z = z; + ev->direction = direction; comp_conf = e_comp_config_get(); if (comp_conf && comp_conf->input_log_enable) @@ -1169,6 +1281,16 @@ _device_handle_touch_down(struct libinput_device *device, struct libinput_event_ if (comp_conf && comp_conf->input_log_enable) ELOGF("Touch", "Down (id: %d, x: %d, y: %d)", NULL, edev->mt_slot, edev->seat->ptr.ix, edev->seat->ptr.iy); + edev->touch.raw_pressed |= (1 << edev->mt_slot); + + if (edev->touch.blocked) + { + ELOGF("Touch", "Down (id: %d, x: %d, y: %d) is blocked by %p, server: 0x%x", NULL, + edev->mt_slot, edev->seat->ptr.ix, edev->seat->ptr.iy, edev->seat->dev->blocked_client, + edev->seat->dev->server_blocked); + return; + } + _device_handle_touch_motion_send(edev, event); _device_handle_touch_event_send(edev, event, ECORE_EVENT_MOUSE_BUTTON_DOWN); } @@ -1223,6 +1345,14 @@ _device_handle_touch_motion(struct libinput_device *device, struct libinput_even edev->touch.coords[edev->mt_slot].y = edev->seat->ptr.iy; } + if (!(edev->touch.pressed & (1 << edev->mt_slot))) + { + if (edev->touch.blocked) + { + return; + } + } + _device_handle_touch_motion_send(edev, event); } @@ -1266,6 +1396,23 @@ _device_handle_touch_up(struct libinput_device *device, struct libinput_event_to if (comp_conf && comp_conf->input_log_enable) ELOGF("Touch", "Up (id: %d, x: %d, y: %d)", NULL, edev->mt_slot, edev->seat->ptr.ix, edev->seat->ptr.iy); + edev->touch.raw_pressed &= ~(1 << edev->mt_slot); + + if (edev->touch.blocked) + { + if (!(edev->touch.pressed & (1 << edev->mt_slot))) + { + ELOGF("Touch", "Up (id: %d, x: %d, y: %d) is blocked by %p, server(0x%x)", NULL, + edev->mt_slot, edev->seat->ptr.ix, edev->seat->ptr.iy, edev->seat->dev->blocked_client, + edev->seat->dev->server_blocked); + if (edev->touch.raw_pressed == 0x0) + { + edev->touch.blocked = EINA_FALSE; + } + return; + } + } + _device_handle_touch_event_send(edev, event, ECORE_EVENT_MOUSE_BUTTON_UP); } diff --git a/src/bin/e_input_inputs.c b/src/bin/e_input_inputs.c index d04621ffe2..c33a8c3d3e 100644 --- a/src/bin/e_input_inputs.c +++ b/src/bin/e_input_inputs.c @@ -120,6 +120,7 @@ _seat_create(E_Input_Backend *input, const char *seat) /* add this new seat to list */ input->dev->seats = eina_list_append(input->dev->seats, s); + s->dev = input->dev; ecore_event_add(E_INPUT_EVENT_SEAT_ADD, NULL, NULL, NULL); diff --git a/src/bin/e_input_private.h b/src/bin/e_input_private.h index abc89914a1..1c6323fc7f 100644 --- a/src/bin/e_input_private.h +++ b/src/bin/e_input_private.h @@ -22,6 +22,7 @@ struct _E_Input_Seat { const char *name; E_Input_Backend *input; + E_Input_Device *dev; Eina_List *devices; struct libinput_seat *seat; Ecore_Device *ecore_dev; @@ -77,6 +78,7 @@ struct _E_Input_Evdev Eina_Bool did_double : 1; Eina_Bool did_triple : 1; uint32_t prev_button, last_button; + unsigned int pressed_button; } mouse; struct @@ -93,6 +95,8 @@ struct _E_Input_Evdev xkb_mod_mask_t altgr_mask; unsigned int modifiers; unsigned int depressed, latched, locked, group; + + Eina_List *pressed_keys; } xkb; Eina_Hash *key_remap_hash; @@ -115,6 +119,8 @@ struct _E_Input_Evdev } coords[E_INPUT_MAX_SLOTS]; unsigned int pressed; + unsigned int raw_pressed; + Eina_Bool blocked; } touch; }; -- 2.34.1