Skip to content

Commit

Permalink
input method: avoid sending IM sent keys to grabs.
Browse files Browse the repository at this point in the history
IM sends release key events when deactivated, which caused e.g. the
switcher plugin to deactivate early. The plugin has a higher priority
when activating, but lower for subsequent key events.
  • Loading branch information
lilydjwg authored and ammen99 committed Feb 27, 2024
1 parent 82275d4 commit 10fb8cb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/core/seat/keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ void wf::keyboard_t::setup_listeners()
}
}

if (seat->priv->keyboard_focus)
// don't send IM sent keys to plugin grabs
if (seat->priv->keyboard_focus && !(seat->priv->is_grab && is_im_sent))
{
seat->priv->keyboard_focus->keyboard_interaction()
.handle_keyboard_key(wf::get_core().seat.get(), *ev);
Expand Down
1 change: 1 addition & 0 deletions src/core/seat/seat-impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ struct seat_t::impl

void set_keyboard_focus(wf::scene::node_ptr keyboard_focus);
wf::scene::node_ptr keyboard_focus;
bool is_grab = false;
// Keys sent to the current keyboard focus
std::multiset<uint32_t> pressed_keys;
void transfer_grab(wf::scene::node_ptr new_focus);
Expand Down
2 changes: 2 additions & 0 deletions src/core/seat/seat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ void wf::seat_t::impl::transfer_grab(wf::scene::node_ptr grab_node)
}

this->keyboard_focus = grab_node;
this->is_grab = true;
grab_node->keyboard_interaction().handle_keyboard_enter(wf::get_core().seat.get());

wf::keyboard_focus_changed_signal data;
Expand All @@ -521,6 +522,7 @@ void wf::seat_t::impl::set_keyboard_focus(wf::scene::node_ptr new_focus)
}

this->keyboard_focus = new_focus;
this->is_grab = false;
if (new_focus)
{
new_focus->keyboard_interaction().handle_keyboard_enter(wf::get_core().seat.get());
Expand Down

0 comments on commit 10fb8cb

Please sign in to comment.