Skip to content

Commit

Permalink
input method: try set_focus on new text_input; fix for some GTK4 apps
Browse files Browse the repository at this point in the history
  • Loading branch information
lilydjwg committed Jan 23, 2024
1 parent f036d01 commit 128f68f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/core/seat/input-method-relay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,23 @@ wf::input_method_relay::input_method_relay()
auto wlr_text_input = static_cast<wlr_text_input_v3*>(data);
text_inputs.push_back(std::make_unique<wf::text_input>(this,
wlr_text_input));
// Sometimes text_input is created after the surface, so we failed to
// set_focus when the surface is focused. Try once here.
//
// If no surface has been created, set_focus does nothing.
//
// Example apps (all GTK4): gnome-font-viewer, easyeffects
auto& seat = wf::get_core_impl().seat;
if (auto focus = seat->priv->keyboard_focus)
{
auto surface = wf::node_to_view(focus)->get_keyboard_focus_surface();

if (surface && (wl_resource_get_client(wlr_text_input->resource) ==
wl_resource_get_client(surface->resource)))
{
wlr_text_input_v3_send_enter(wlr_text_input, surface);
}
}
});

on_input_method_new.set_callback([&] (void *data)
Expand Down

0 comments on commit 128f68f

Please sign in to comment.