diff --git a/engine/src/flutter/shell/platform/linux/fl_text_input_plugin.cc b/engine/src/flutter/shell/platform/linux/fl_text_input_plugin.cc index ec232b05b5..f81cd8074e 100644 --- a/engine/src/flutter/shell/platform/linux/fl_text_input_plugin.cc +++ b/engine/src/flutter/shell/platform/linux/fl_text_input_plugin.cc @@ -708,6 +708,10 @@ static void fl_text_input_plugin_init(FlTextInputPlugin* self) { priv->client_id = kClientIdUnset; priv->im_context = gtk_im_multicontext_new(); + // On Wayland, this call sets up the input method so it can be enabled + // immediately when required. Without it, on-screen keyboard's don't come up + // the first time a text field is focused. + gtk_im_context_focus_out(priv->im_context); priv->input_type = FL_TEXT_INPUT_TYPE_TEXT; g_signal_connect_object(priv->im_context, "preedit-start", G_CALLBACK(im_preedit_start_cb), self, diff --git a/engine/src/flutter/shell/platform/linux/testing/fl_test.cc b/engine/src/flutter/shell/platform/linux/testing/fl_test.cc index 3af19052fc..57b36d164c 100644 --- a/engine/src/flutter/shell/platform/linux/testing/fl_test.cc +++ b/engine/src/flutter/shell/platform/linux/testing/fl_test.cc @@ -9,6 +9,18 @@ #include "flutter/shell/platform/linux/fl_engine_private.h" #include "flutter/shell/platform/linux/testing/mock_renderer.h" +namespace { +class ImModuleEnv : public ::testing::Environment { + public: + void SetUp() override { + setenv("GTK_IM_MODULE", "gtk-im-context-simple", true); + } +}; + +testing::Environment* const env = + testing::AddGlobalTestEnvironment(new ImModuleEnv); +} // namespace + static uint8_t hex_digit_to_int(char value) { if (value >= '0' && value <= '9') { return value - '0';