This repository has been archived by the owner on Feb 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added On_Char method to Window_Listener for WM_CHAR messages.
Removed a lot of TSF code because part of it was wrong and part was too complicated. Added Clear method to clear the window. IME input should work in both windowed mode and fullscreen mode with these changes. I have tested on Windows XP SP3 and Windows 7 Ultimate in VirtualBox. When you type a character (with an IME or not), the console will show the code point as U+XXXX. You use Left Alt+Shift (or whatever you have it set to) to switch input languages as usual. Hit ESC to exit (or close the window in windowed mode). The program will pause before exiting so you can review the console output (press a key to exit).
- Loading branch information
dewyatt
committed
Jun 9, 2010
1 parent
683b09d
commit 64169f7
Showing
8 changed files
with
66 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,140 +1,40 @@ | ||
#include "TSF.hpp" | ||
#include <stdexcept> | ||
|
||
TSF::TSF() : my_COM_Initialized(false), | ||
my_UI_Sink(0), | ||
my_UI_Element_Sink_Cookie(TF_INVALID_COOKIE), | ||
my_IPPA_Sink_Cookie(TF_INVALID_COOKIE) | ||
{ | ||
|
||
} | ||
|
||
TSF::~TSF() | ||
{ | ||
Finalize(); | ||
} | ||
bool TSF::COM_Initialized = false; | ||
CComPtr<ITfThreadMgr> TSF::Thread_Manager; | ||
|
||
void TSF::Initialize() | ||
{ | ||
Finalize(); | ||
|
||
if (S_OK != CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)) | ||
throw std::runtime_error("Failed to initialize COM"); | ||
|
||
my_COM_Initialized = true; | ||
if (S_OK != CoCreateInstance(CLSID_TF_ThreadMgr, NULL, CLSCTX_INPROC_SERVER, __uuidof(ITfThreadMgrEx), (void **)&my_Thread_Manager)) | ||
throw std::runtime_error("Failed to create ITfThreadMgrEx instance"); | ||
|
||
TfClientId Client_Id = 0; | ||
if (FAILED(my_Thread_Manager->ActivateEx(&Client_Id, TF_TMAE_UIELEMENTENABLEDONLY))) | ||
throw std::runtime_error("ITfThreadMgrEx::ActivateEx failed"); | ||
|
||
my_UI_Sink = new UI_Sink(); | ||
ITfSource *Source = NULL; | ||
if (FAILED(my_Thread_Manager->QueryInterface(__uuidof(ITfSource), (void **)&Source))) | ||
throw std::runtime_error("QueryInterface failed"); | ||
if (!COM_Initialized) | ||
{ | ||
HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); | ||
if (S_OK != hr && S_FALSE != hr) | ||
throw std::runtime_error("Failed to initialize COM"); | ||
|
||
if (FAILED(Source->AdviseSink(__uuidof(ITfUIElementSink), (ITfUIElementSink *)my_UI_Sink, &my_UI_Element_Sink_Cookie))) | ||
throw std::runtime_error("AdviseSink failed"); | ||
COM_Initialized = true; | ||
} | ||
if (!Thread_Manager) | ||
{ | ||
if (FAILED(CoCreateInstance(CLSID_TF_ThreadMgr, NULL, CLSCTX_INPROC_SERVER, IID_ITfThreadMgr, reinterpret_cast<void **>(&Thread_Manager)))) | ||
throw std::runtime_error("Failed to create ITfThreadMgr instance"); | ||
|
||
if (FAILED(Source->AdviseSink(__uuidof(ITfInputProcessorProfileActivationSink), (ITfInputProcessorProfileActivationSink *)my_UI_Sink, &my_IPPA_Sink_Cookie))) | ||
throw std::runtime_error("AdviseSink failed"); | ||
TfClientId ClientId; | ||
if (FAILED(Thread_Manager->Activate(&ClientId))) | ||
throw std::runtime_error("ITfThreadMgr::Activate failed"); | ||
} | ||
} | ||
|
||
void TSF::Finalize() | ||
{ | ||
if (my_UI_Sink) | ||
if (Thread_Manager) | ||
{ | ||
ITfSource *Source = NULL; | ||
if (SUCCEEDED(my_Thread_Manager->QueryInterface(__uuidof(ITfSource), (void **)&Source))) | ||
{ | ||
Source->UnadviseSink(my_IPPA_Sink_Cookie); | ||
Source->UnadviseSink(my_UI_Element_Sink_Cookie); | ||
Source->Release(); | ||
} | ||
if (my_Thread_Manager) | ||
my_Thread_Manager->Deactivate(); | ||
|
||
my_UI_Sink->Release(); | ||
delete my_UI_Sink; | ||
my_UI_Sink = NULL; | ||
Thread_Manager->Deactivate(); | ||
Thread_Manager = NULL; | ||
} | ||
my_Thread_Manager = NULL; | ||
if (my_COM_Initialized) | ||
if (COM_Initialized) | ||
{ | ||
CoUninitialize(); | ||
my_COM_Initialized = false; | ||
COM_Initialized = false; | ||
} | ||
} | ||
|
||
TSF::UI_Sink::UI_Sink() | ||
{ | ||
my_Reference_Count = 1; | ||
} | ||
|
||
TSF::UI_Sink::~UI_Sink() | ||
{ | ||
|
||
} | ||
|
||
STDMETHODIMP TSF::UI_Sink::QueryInterface(REFIID riid, void **ppvObj) | ||
{ | ||
if (NULL == ppvObj) | ||
return E_INVALIDARG; | ||
|
||
*ppvObj = NULL; | ||
if (IsEqualIID(riid, IID_IUnknown)) | ||
*ppvObj = reinterpret_cast<IUnknown *>(this); | ||
else if (IsEqualIID(riid, __uuidof(ITfUIElementSink))) | ||
*ppvObj = reinterpret_cast<ITfUIElementSink *>(this); | ||
else if (IsEqualIID(riid, __uuidof(ITfInputProcessorProfileActivationSink))) | ||
*ppvObj = reinterpret_cast<ITfInputProcessorProfileActivationSink *>(this); | ||
else if (IsEqualIID(riid, __uuidof(ITfCompartmentEventSink))) | ||
*ppvObj = reinterpret_cast<ITfCompartmentEventSink *>(this); | ||
|
||
if (*ppvObj) | ||
{ | ||
AddRef(); | ||
return S_OK; | ||
} | ||
return E_NOINTERFACE; | ||
} | ||
|
||
ULONG TSF::UI_Sink::AddRef(void) | ||
{ | ||
return ++my_Reference_Count; | ||
} | ||
|
||
ULONG TSF::UI_Sink::Release(void) | ||
{ | ||
LONG Count = --my_Reference_Count; | ||
if (0 == Count) | ||
delete this; | ||
|
||
return Count; | ||
} | ||
|
||
STDMETHODIMP TSF::UI_Sink::BeginUIElement(DWORD dwUIElementId, BOOL *pbShow) | ||
{ | ||
return S_OK; | ||
} | ||
|
||
STDMETHODIMP TSF::UI_Sink::UpdateUIElement(DWORD dwUIElementId) | ||
{ | ||
return S_OK; | ||
} | ||
|
||
STDMETHODIMP TSF::UI_Sink::EndUIElement(DWORD dwUIElementId) | ||
{ | ||
return S_OK; | ||
} | ||
|
||
STDMETHODIMP TSF::UI_Sink::OnActivated(DWORD dwProfileType, LANGID langid, REFCLSID clsid, REFGUID catid, REFGUID guidProfile, HKL hkl, DWORD dwFlags) | ||
{ | ||
return S_OK; | ||
} | ||
|
||
STDMETHODIMP TSF::UI_Sink::OnChange(REFGUID rguid) | ||
{ | ||
return S_OK; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters