Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

input method: don't forward key-release without correspinding key-press #2544

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/core/seat/input-method-relay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/core/seat/input-method-relay.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <vector>
#include <memory>
#include <set>

namespace wf
{
Expand All @@ -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<uint32_t> pressed_keys;

text_input *find_focusable_text_input();
void set_focus(wlr_surface*);

Expand Down