mirror of
https://github.com/labwc/labwc.git
synced 2025-11-03 09:01:51 -05:00
IME: don't forward key-release without correspinding key-press
After commit e2189903 in wlroots, when ctrl-f is pressed in firefox with a IME client running, the following key-release event for "f" is not sent, thus "f" is repeated like "ffffffffff..." in the input box of firefox. This is because the key-release event for "f" is firstly forwarded to the IME client and then sent via the virtual keyboard created by the IME client while the key-press event is sent via physical keyboard, and with e2189903, key-release events without a corresponding key-press event on the same keyboard is not emitted to the compositor. So this commit fixes this problem by not forwarding the key-release event to the IME client unless the corresponding key-press event was also forwarded.
This commit is contained in:
parent
5766bec70a
commit
683f67b761
2 changed files with 19 additions and 0 deletions
|
|
@ -21,6 +21,7 @@ struct input_method_relay {
|
||||||
struct wl_list text_inputs; /* struct text_input.link */
|
struct wl_list text_inputs; /* struct text_input.link */
|
||||||
struct wlr_input_method_v2 *input_method;
|
struct wlr_input_method_v2 *input_method;
|
||||||
struct wlr_surface *focused_surface;
|
struct wlr_surface *focused_surface;
|
||||||
|
struct lab_set pressed_keys;
|
||||||
/*
|
/*
|
||||||
* Text-input which is enabled by the client and communicating with
|
* Text-input which is enabled by the client and communicating with
|
||||||
* input-method.
|
* input-method.
|
||||||
|
|
|
||||||
|
|
@ -73,9 +73,25 @@ bool
|
||||||
input_method_keyboard_grab_forward_key(struct keyboard *keyboard,
|
input_method_keyboard_grab_forward_key(struct keyboard *keyboard,
|
||||||
struct wlr_keyboard_key_event *event)
|
struct wlr_keyboard_key_event *event)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* We should not forward key-release events without corresponding
|
||||||
|
* key-press events forwarded
|
||||||
|
*/
|
||||||
|
struct lab_set *pressed_keys =
|
||||||
|
&keyboard->base.seat->input_method_relay->pressed_keys;
|
||||||
|
if (event->state == WL_KEYBOARD_KEY_STATE_RELEASED
|
||||||
|
&& !lab_set_contains(pressed_keys, event->keycode)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
struct wlr_input_method_keyboard_grab_v2 *keyboard_grab =
|
struct wlr_input_method_keyboard_grab_v2 *keyboard_grab =
|
||||||
get_keyboard_grab(keyboard);
|
get_keyboard_grab(keyboard);
|
||||||
if (keyboard_grab) {
|
if (keyboard_grab) {
|
||||||
|
if (event->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
|
||||||
|
lab_set_add(pressed_keys, event->keycode);
|
||||||
|
} else {
|
||||||
|
lab_set_remove(pressed_keys, event->keycode);
|
||||||
|
}
|
||||||
wlr_input_method_keyboard_grab_v2_set_keyboard(keyboard_grab,
|
wlr_input_method_keyboard_grab_v2_set_keyboard(keyboard_grab,
|
||||||
keyboard->wlr_keyboard);
|
keyboard->wlr_keyboard);
|
||||||
wlr_input_method_keyboard_grab_v2_send_key(keyboard_grab,
|
wlr_input_method_keyboard_grab_v2_send_key(keyboard_grab,
|
||||||
|
|
@ -329,6 +345,8 @@ handle_input_method_grab_keyboard(struct wl_listener *listener, void *data)
|
||||||
keyboard_grab, active_keyboard);
|
keyboard_grab, active_keyboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
relay->pressed_keys = (struct lab_set){0};
|
||||||
|
|
||||||
relay->keyboard_grab_destroy.notify = handle_keyboard_grab_destroy;
|
relay->keyboard_grab_destroy.notify = handle_keyboard_grab_destroy;
|
||||||
wl_signal_add(&keyboard_grab->events.destroy,
|
wl_signal_add(&keyboard_grab->events.destroy,
|
||||||
&relay->keyboard_grab_destroy);
|
&relay->keyboard_grab_destroy);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue