Skip to content

Commit

Permalink
input method: don't process pressed_keys if key event is sent to inpu…
Browse files Browse the repository at this point in the history
…t method

check:

* in firefox, no text input, press ctrl-l, there should not be
  continuous l being inserted into the urlbar
* in firefox, with text input, press super+some key to switch workspace
  and back (but don't release super inbetween). click in firefox, super
  should not be consider pressed
* with text input, does the switcher plugin activate and deactivate correctly
  • Loading branch information
lilydjwg committed Jan 23, 2024
1 parent 5ca59d7 commit f036d01
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
28 changes: 9 additions & 19 deletions src/core/seat/keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,15 @@ void wf::keyboard_t::setup_listeners()
}

seat->priv->set_keyboard(this);
if (!handle_keyboard_key(ev->time_msec, ev->keycode,
ev->state) && (mode == input_event_processing_mode_t::FULL))
auto is_im_sent = wf::get_core_impl().im_relay->is_im_sent(handle);
if ((is_im_sent || !handle_keyboard_key(ev->keycode, ev->state)) &&
(mode == input_event_processing_mode_t::FULL))
{
if (wf::get_core_impl().im_relay->handle_key(handle, ev->time_msec, ev->keycode, ev->state))
{
return;
}

if (ev->state == WL_KEYBOARD_KEY_STATE_PRESSED)
{
seat->priv->pressed_keys.insert(ev->keycode);
Expand Down Expand Up @@ -287,19 +293,13 @@ bool wf::keyboard_t::has_only_modifiers()
return true;
}

bool wf::keyboard_t::handle_keyboard_key(uint32_t time, uint32_t key, uint32_t state)
bool wf::keyboard_t::handle_keyboard_key(uint32_t key, uint32_t state)
{
using namespace std::chrono;

auto& input = wf::get_core_impl().input;
auto& seat = wf::get_core_impl().seat;

if (wf::get_core_impl().im_relay->is_im_sent(handle))
{
mod_binding_key = 0;
return false;
}

bool handled_in_plugin = false;
auto mod = mod_from_key(key);
input->locked_mods = this->get_locked_mods();
Expand Down Expand Up @@ -328,11 +328,6 @@ bool wf::keyboard_t::handle_keyboard_key(uint32_t time, uint32_t key, uint32_t s

handled_in_plugin |= wf::get_core().bindings->handle_key(
wf::keybinding_t{get_modifiers(), key}, mod_binding_key);

if (!handled_in_plugin)
{
handled_in_plugin |= wf::get_core_impl().im_relay->handle_key(handle, time, key, state);
}
} else
{
if (mod_binding_key != 0)
Expand All @@ -349,11 +344,6 @@ bool wf::keyboard_t::handle_keyboard_key(uint32_t time, uint32_t key, uint32_t s
}
}

if (!handled_in_plugin)
{
handled_in_plugin |= wf::get_core_impl().im_relay->handle_key(handle, time, key, state);
}

mod_binding_key = 0;
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/seat/keyboard.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class keyboard_t

std::chrono::steady_clock::time_point mod_binding_start;

bool handle_keyboard_key(uint32_t time, uint32_t key, uint32_t state);
bool handle_keyboard_key(uint32_t key, uint32_t state);

/** Get the current locked mods */
uint32_t get_locked_mods();
Expand Down

0 comments on commit f036d01

Please sign in to comment.