Skip to content

Commit 605a88e

Browse files
committed
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 preceding 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.
1 parent fdadd85 commit 605a88e

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/core/seat/input-method-relay.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,19 @@ bool wf::input_method_relay::handle_key(struct wlr_keyboard *kbd, uint32_t time,
284284
return false;
285285
}
286286

287+
if (state == WL_KEYBOARD_KEY_STATE_PRESSED) {
288+
pressed_keys.insert(key);
289+
} else
290+
{
291+
// Don't forward the release event if the press event for the same key
292+
// has also been forwarded.
293+
if (!pressed_keys.count(key))
294+
{
295+
return false;
296+
}
297+
pressed_keys.erase(key);
298+
}
299+
287300
wlr_input_method_keyboard_grab_v2_set_keyboard(keyboard_grab, kbd);
288301
wlr_input_method_keyboard_grab_v2_send_key(keyboard_grab, time, key, state);
289302
return true;

src/core/seat/input-method-relay.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <vector>
99
#include <memory>
10+
#include <set>
1011

1112
namespace wf
1213
{
@@ -25,6 +26,8 @@ class input_method_relay : public text_input_v3_im_relay_interface_t
2526
uint32_t next_done_serial = 0;
2627
void send_im_done();
2728

29+
std::multiset<uint32_t> pressed_keys;
30+
2831
text_input *find_focusable_text_input();
2932
void set_focus(wlr_surface*);
3033

0 commit comments

Comments
 (0)