// Some useful information can be found from chromium code: // https://chromium.googlesource.com/chromium/chromium/+/refs/heads/master/ui/base/win/ime_input.h #pragma once #include "resource.hpp" #include "cru/platform/native/input_method.hpp" #include "window_native_message_event_args.hpp" #include namespace cru::platform::native::win { class WinInputMethodContextRef : public WinNativeResource, public virtual IInputMethodContextRef { public: WinInputMethodContextRef(WinNativeWindow* window); CRU_DELETE_COPY(WinInputMethodContextRef) CRU_DELETE_MOVE(WinInputMethodContextRef) ~WinInputMethodContextRef() override; ::HIMC GetHandle() const { return handle_; } bool ShouldManuallyDrawCompositionText() override { return true; } void Reset() override; std::string GetCompositionText() override; void SetCandidateWindowPosition(const Point& point) override; IEvent* CompositionStartEvent() override; IEvent* CompositionEndEvent() override; IEvent* CompositionTextChangeEvent() override; private: void OnWindowNativeMessage(WindowNativeMessageEventArgs& args); private: [[maybe_unused]] WinNativeWindow* window_; std::vector event_revoker_guards_; ::HWND window_handle_; ::HIMC handle_; Event composition_start_event_; Event composition_end_event_; Event composition_text_change_event_; }; class WinInputMethodManager : public WinNativeResource, public virtual IInputMethodManager { public: WinInputMethodManager(WinUiApplication* application); CRU_DELETE_COPY(WinInputMethodManager) CRU_DELETE_MOVE(WinInputMethodManager) ~WinInputMethodManager() override; public: std::unique_ptr GetContext( INativeWindow* window) override; }; } // namespace cru::platform::native::win