diff --git a/ui/base/ime/input_method_initializer.cc b/ui/base/ime/input_method_initializer.cc index b64f362a5d851..6dd0a9347de0d 100644 --- a/ui/base/ime/input_method_initializer.cc +++ b/ui/base/ime/input_method_initializer.cc @@ -50,11 +50,13 @@ void InitializeInputMethodForTesting() { if (!g_linux_input_method_context_factory_for_testing) g_linux_input_method_context_factory_for_testing = new FakeInputMethodContextFactory(); +#if !defined(USE_OZONE) const LinuxInputMethodContextFactory* factory = LinuxInputMethodContextFactory::instance(); CHECK(!factory || factory == g_linux_input_method_context_factory_for_testing) << "LinuxInputMethodContextFactory was already initialized somewhere " << "else."; +#endif LinuxInputMethodContextFactory::SetInstance( g_linux_input_method_context_factory_for_testing); #elif defined(OS_WIN) diff --git a/ui/ozone/platform/headless/BUILD.gn b/ui/ozone/platform/headless/BUILD.gn index 046dec9b9b3cf..8fa5fa97bf0db 100644 --- a/ui/ozone/platform/headless/BUILD.gn +++ b/ui/ozone/platform/headless/BUILD.gn @@ -26,6 +26,7 @@ source_set("headless") { "//base", "//skia", "//ui/base", + "//ui/base/ime", "//ui/display/manager", "//ui/events", "//ui/events/ozone:events_ozone_layout", diff --git a/ui/ozone/platform/headless/ozone_platform_headless.cc b/ui/ozone/platform/headless/ozone_platform_headless.cc index 3e22233d1ec60..2bed591e6bc88 100644 --- a/ui/ozone/platform/headless/ozone_platform_headless.cc +++ b/ui/ozone/platform/headless/ozone_platform_headless.cc @@ -8,6 +8,7 @@ #include "base/files/file_path.h" #include "base/macros.h" #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" +#include "ui/base/ime/linux/fake_input_method_context_factory.h" #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" #include "ui/events/ozone/layout/stub/stub_keyboard_layout_engine.h" #include "ui/events/platform/platform_event_source.h" @@ -90,6 +91,13 @@ class OzonePlatformHeadless : public OzonePlatform { input_controller_ = CreateStubInputController(); cursor_factory_ozone_ = std::make_unique(); gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost()); + + if (LinuxInputMethodContextFactory::instance()) + return; + fake_input_method_factory_ = + std::make_unique(); + LinuxInputMethodContextFactory::SetInstance( + fake_input_method_factory_.get()); } void InitializeGPU(const InitParams& params) override { @@ -105,6 +113,7 @@ class OzonePlatformHeadless : public OzonePlatform { std::unique_ptr input_controller_; std::unique_ptr gpu_platform_support_host_; std::unique_ptr overlay_manager_; + std::unique_ptr fake_input_method_factory_; base::FilePath file_path_; DISALLOW_COPY_AND_ASSIGN(OzonePlatformHeadless); diff --git a/ui/ozone/platform/x11/BUILD.gn b/ui/ozone/platform/x11/BUILD.gn index 4910fe34e0a16..948ed961a127e 100644 --- a/ui/ozone/platform/x11/BUILD.gn +++ b/ui/ozone/platform/x11/BUILD.gn @@ -41,6 +41,7 @@ source_set("x11") { "//gpu/vulkan:buildflags", "//skia", "//ui/base", + "//ui/base/ime", "//ui/base/x", "//ui/display/manager", "//ui/events", diff --git a/ui/ozone/platform/x11/DEPS b/ui/ozone/platform/x11/DEPS index 8d590992a5c1a..db1d9fe859da4 100644 --- a/ui/ozone/platform/x11/DEPS +++ b/ui/ozone/platform/x11/DEPS @@ -1,3 +1,4 @@ include_rules = [ "+ui/base/x", + "+ui/base/ime", ] diff --git a/ui/ozone/platform/x11/ozone_platform_x11.cc b/ui/ozone/platform/x11/ozone_platform_x11.cc index ea33369f2e3e6..ca170899ae4dd 100644 --- a/ui/ozone/platform/x11/ozone_platform_x11.cc +++ b/ui/ozone/platform/x11/ozone_platform_x11.cc @@ -9,6 +9,7 @@ #include "base/message_loop/message_loop.h" #include "base/strings/utf_string_conversions.h" +#include "ui/base/ime/linux/fake_input_method_context_factory.h" #include "ui/base/x/x11_util.h" #include "ui/display/manager/fake_display_delegate.h" #include "ui/events/devices/x11/touch_factory_x11.h" @@ -89,8 +90,13 @@ class OzonePlatformX11 : public OzonePlatform { input_controller_ = CreateStubInputController(); cursor_factory_ozone_ = std::make_unique(); gpu_platform_support_host_.reset(CreateStubGpuPlatformSupportHost()); - TouchFactory::SetTouchDeviceListFromCommandLine(); + + if (LinuxInputMethodContextFactory::instance()) + return; + fake_input_method_factory_ = + std::make_unique(); + LinuxInputMethodContextFactory::SetInstance(fake_input_method_factory_.get()); } void InitializeGPU(const InitParams& params) override { @@ -147,6 +153,7 @@ class OzonePlatformX11 : public OzonePlatform { std::unique_ptr input_controller_; std::unique_ptr cursor_factory_ozone_; std::unique_ptr gpu_platform_support_host_; + std::unique_ptr fake_input_method_factory_; // Objects in the GPU process. std::unique_ptr surface_factory_ozone_;