diff --git a/src/core/seat/input-method-relay.cpp b/src/core/seat/input-method-relay.cpp index b523c1e8d..c5ad160dc 100644 --- a/src/core/seat/input-method-relay.cpp +++ b/src/core/seat/input-method-relay.cpp @@ -284,6 +284,19 @@ bool wf::input_method_relay::handle_key(struct wlr_keyboard *kbd, uint32_t time, return false; } + if (state == WL_KEYBOARD_KEY_STATE_PRESSED) { + pressed_keys.insert(key); + } else + { + // Don't forward the release event if the press event for the same key + // has also been forwarded. + if (!pressed_keys.count(key)) + { + return false; + } + pressed_keys.erase(key); + } + wlr_input_method_keyboard_grab_v2_set_keyboard(keyboard_grab, kbd); wlr_input_method_keyboard_grab_v2_send_key(keyboard_grab, time, key, state); return true; diff --git a/src/core/seat/input-method-relay.hpp b/src/core/seat/input-method-relay.hpp index 7a5b81a19..f5212db1f 100644 --- a/src/core/seat/input-method-relay.hpp +++ b/src/core/seat/input-method-relay.hpp @@ -7,6 +7,7 @@ #include #include +#include namespace wf { @@ -25,6 +26,8 @@ class input_method_relay : public text_input_v3_im_relay_interface_t uint32_t next_done_serial = 0; void send_im_done(); + std::multiset pressed_keys; + text_input *find_focusable_text_input(); void set_focus(wlr_surface*);