UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
WindowsTextInputMethodSystem.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
6#include "Containers/Map.h"
9
11#include <msctf.h>
13
14class FGenericWindow;
15
16class FTextStoreACP;
18
19
21 : public ITfInputProcessorProfileActivationSink
22 , public ITfActiveLanguageProfileNotifySink
23{
24public:
31
33 { }
34
35 // IUnknown Interface Begin
37 STDMETHODIMP_(ULONG) AddRef() override;
39 // IUnknown Interface End
40
41 // ITfInputProcessorProfileActivationSink Interface Begin
43 // ITfInputProcessorProfileActivationSink Interface End
44
45 // ITfActiveLanguageProfileNotifySink Interface Begin
47 // ITfActiveLanguageProfileNotifySink Interface End
48
49public:
50
53
54private:
55
57
58 // Reference count for IUnknown Implementation
59 ULONG ReferenceCount;
60};
61
62
65{
66 friend class FTSFActivationProxy;
67
68public:
69
71
72 bool Initialize();
73 void Terminate();
74
75 int32 ProcessMessage(HWND hwnd, uint32 msg, WPARAM wParam, LPARAM lParam);
76
77public:
78
79 // ITextInputMethodSystem interface
80
81 virtual void ApplyDefaults(const TSharedRef<FGenericWindow>& InWindow) override;
86 virtual bool IsActiveContext(const TSharedRef<ITextInputMethodContext>& Context) const override;
87
88private:
89
90 void LogActiveInputMethod();
91
92 // IMM Implementation
93
94 bool InitializeIMM();
95 void UpdateIMMProperty(HKL KeyboardLatoutHandle);
96 bool ShouldDrawIMMCompositionString() const;
97 void UpdateIMMWindowPositions(HIMC IMMContext);
98 void BeginIMMComposition();
99 void EndIMMComposition();
100 void CancelIMMComposition();
101
102 // TSF Implementation
103
104 bool InitializeTSF();
105 void OnIMEActivationStateChanged(const bool bIsEnabled);
106 void ClearStaleWindowHandles();
107
108private:
109
110 enum class EAPI
111 {
112 Unknown,
113 IMM,
114 TSF
115 } CurrentAPI;
116
117 // TSF Implementation
118 TComPtr<ITfInputProcessorProfiles> TSFInputProcessorProfiles;
119 TComPtr<ITfInputProcessorProfileMgr> TSFInputProcessorProfileManager;
120 TComPtr<ITfThreadMgr> TSFThreadManager;
121 TfClientId TSFClientId = 0;
122 TComPtr<ITfDocumentMgr> TSFDisabledDocumentManager;
123 TComPtr<FTSFActivationProxy> TSFActivationProxy;
124
125 // IMM Implementation
126 HIMC IMMContextId = nullptr;
127 DWORD IMMProperties = 0;
128
129 struct FInternalContext
130 {
131 HWND WindowHandle = nullptr;
132
133 TComPtr<FTextStoreACP> TSFContext;
134
135 struct
136 {
137 bool IsComposing = false;
138 bool IsDeactivating = false;
139 int32 CompositionBeginIndex = 0;
140 uint32 CompositionLength = 0;
141 } IMMContext;
142 };
143
145
146 TMap< TWeakPtr<ITextInputMethodContext>, FInternalContext > ContextToInternalContextMap;
147
148 TSet<TWeakPtr<FGenericWindow>> KnownWindows;
149};
150
151
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition GenericWindow.h:94
Definition WindowsTextInputMethodSystem.h:23
STDMETHODIMP_(ULONG) Release() override
STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj) override
Definition WindowsTextInputMethodSystem.cpp:192
FTSFActivationProxy(FWindowsTextInputMethodSystem *InOwner)
Definition WindowsTextInputMethodSystem.h:25
STDMETHODIMP OnActivated(DWORD dwProfileType, LANGID langid, __RPC__in REFCLSID clsid, __RPC__in REFGUID catid, __RPC__in REFGUID guidProfile, HKL hkl, DWORD dwFlags) override
Definition WindowsTextInputMethodSystem.cpp:229
virtual ~FTSFActivationProxy()
Definition WindowsTextInputMethodSystem.h:32
STDMETHODIMP_(ULONG) AddRef() override
DWORD TSFLanguageCookie
Definition WindowsTextInputMethodSystem.h:52
DWORD TSFProfileCookie
Definition WindowsTextInputMethodSystem.h:51
Definition TextStoreACP.h:18
Definition WindowsTextInputMethodSystem.h:65
virtual void DeactivateContext(const TSharedRef< ITextInputMethodContext > &Context) override
Definition WindowsTextInputMethodSystem.cpp:876
virtual void UnregisterContext(const TSharedRef< ITextInputMethodContext > &Context) override
Definition WindowsTextInputMethodSystem.cpp:812
virtual bool IsActiveContext(const TSharedRef< ITextInputMethodContext > &Context) const override
Definition WindowsTextInputMethodSystem.cpp:919
virtual void ActivateContext(const TSharedRef< ITextInputMethodContext > &Context) override
Definition WindowsTextInputMethodSystem.cpp:839
int32 ProcessMessage(HWND hwnd, uint32 msg, WPARAM wParam, LPARAM lParam)
Definition WindowsTextInputMethodSystem.cpp:960
virtual TSharedPtr< ITextInputMethodChangeNotifier > RegisterContext(const TSharedRef< ITextInputMethodContext > &Context) override
Definition WindowsTextInputMethodSystem.cpp:748
virtual ~FWindowsTextInputMethodSystem()
Definition WindowsTextInputMethodSystem.h:70
virtual void ApplyDefaults(const TSharedRef< FGenericWindow > &InWindow) override
Definition WindowsTextInputMethodSystem.cpp:702
bool Initialize()
Definition WindowsTextInputMethodSystem.cpp:242
void Terminate()
Definition WindowsTextInputMethodSystem.cpp:631
Definition ITextInputMethodSystem.h:169
Definition COMPointer.h:19
Definition UnrealString.h.inl:34
Definition SharedPointer.h:692
Definition SharedPointer.h:153
unsigned long DWORD
Definition MinimalWindowsApi.h:67
HWND__ * HWND
Definition MinimalWindowsApi.h:81