From fe62bac9101bc05ef0d133ccbee46a60deff501f Mon Sep 17 00:00:00 2001 From: Kan-Ru Chen Date: Tue, 24 Dec 2024 21:17:55 +0900 Subject: [PATCH] refactor: simplify unused compartment code --- ChewingPreferences/ChewingPreferences.cpp | 33 ------ chewing_tip/ChewingConfig.cpp | 56 +++++----- chewing_tip/ChewingConfig.h | 7 -- chewing_tip/ChewingTextService.cpp | 61 ++++------- chewing_tip/ChewingTextService.h | 3 - chewing_tip/TextService.cpp | 118 ++-------------------- chewing_tip/TextService.h | 9 +- 7 files changed, 53 insertions(+), 234 deletions(-) diff --git a/ChewingPreferences/ChewingPreferences.cpp b/ChewingPreferences/ChewingPreferences.cpp index 796412f..56d714c 100644 --- a/ChewingPreferences/ChewingPreferences.cpp +++ b/ChewingPreferences/ChewingPreferences.cpp @@ -21,7 +21,6 @@ #include "UiPropertyPage.h" #include "KeyboardPropertyPage.h" #include "SymbolsPropertyPage.h" -#include "Dialog.h" #include "PropertyDialog.h" #include "AboutDialog.h" #include "resource.h" @@ -33,10 +32,6 @@ namespace Chewing { -// {F4D1E543-FB2C-48D7-B78D-20394F355381} // global compartment GUID for config change notification -static const GUID g_configChangedGuid = -{ 0xf4d1e543, 0xfb2c, 0x48d7, { 0xb7, 0x8d, 0x20, 0x39, 0x4f, 0x35, 0x53, 0x81 } }; - static void initControls() { INITCOMMONCONTROLSEX ic; ic.dwSize = sizeof(ic); @@ -65,35 +60,7 @@ static void configDialog(HINSTANCE hInstance) { dlg.addPage(symbolsPage); INT_PTR ret = dlg.showModal(hInstance, (LPCTSTR)IDS_CONFIG_TITLE, 0, HWND_DESKTOP); if(ret) { // the user clicks OK button - // get current time stamp and set the value to global compartment to notify all - // text service instances to reload their config. - // TextService::onCompartmentChanged() of all other instances will be triggered. config.save(); - - DWORD stamp = ::GetTickCount(); - if(stamp == Config::INVALID_TIMESTAMP) // this is almost impossible - stamp = 0; - // set global compartment value to notify existing ChewingTextService instances - ::CoInitialize(NULL); // initialize COM - winrt::com_ptr threadMgr; - if(CoCreateInstance(CLSID_TF_ThreadMgr, NULL, CLSCTX_INPROC_SERVER, IID_ITfThreadMgr, threadMgr.put_void()) == S_OK) { - TfClientId clientId = 0; - if(threadMgr->Activate(&clientId) == S_OK) { - winrt::com_ptr compartmentMgr; - if(threadMgr->GetGlobalCompartment(compartmentMgr.put()) == S_OK) { - winrt::com_ptr compartment; - if(compartmentMgr->GetCompartment(g_configChangedGuid, compartment.put()) == S_OK) { - VARIANT var; - VariantInit(&var); - var.vt = VT_I4; - var.lVal = ::GetTickCount(); // set current timestamp - compartment->SetValue(clientId, &var); - } - } - threadMgr->Deactivate(); - } - } - ::CoUninitialize(); } } diff --git a/chewing_tip/ChewingConfig.cpp b/chewing_tip/ChewingConfig.cpp index 7496eef..d6d8bdc 100644 --- a/chewing_tip/ChewingConfig.cpp +++ b/chewing_tip/ChewingConfig.cpp @@ -92,8 +92,6 @@ Config::Config(): easySymbolsWithShift = 1; easySymbolsWithCtrl = 0; upperCaseWithShift = 0; - - stamp = INVALID_TIMESTAMP; } Config::~Config(void) { @@ -163,33 +161,35 @@ void Config::save() { BOOL isWow64 = FALSE; ::IsWow64Process(process, &isWow64); DWORD regFlags = isWow64 ? KEY_WOW64_64KEY : 0; + DWORD timestamp = GetTickCount(); HKEY hk = NULL; LSTATUS ret = ::RegCreateKeyExW(HKEY_CURRENT_USER, L"Software\\ChewingTextService", 0, NULL, 0, regFlags|KEY_READ|KEY_WRITE , NULL, &hk, NULL); if(ERROR_SUCCESS == ret) { - ::RegSetValueEx(hk, L"KeyboardLayout", 0, REG_DWORD, (LPBYTE)&keyboardLayout, sizeof(DWORD)); - ::RegSetValueEx(hk, L"CandPerRow", 0, REG_DWORD, (LPBYTE)&candPerRow, sizeof(DWORD)); - ::RegSetValueEx(hk, L"DefaultEnglish", 0, REG_DWORD, (LPBYTE)&defaultEnglish, sizeof(DWORD)); - ::RegSetValueEx(hk, L"DefaultFullSpace", 0, REG_DWORD, (LPBYTE)&defaultFullSpace, sizeof(DWORD)); - ::RegSetValueEx(hk, L"ShowCandWithSpaceKey", 0, REG_DWORD, (LPBYTE)&showCandWithSpaceKey, sizeof(DWORD)); - ::RegSetValueEx(hk, L"SwitchLangWithShift", 0, REG_DWORD, (LPBYTE)&switchLangWithShift, sizeof(DWORD)); - ::RegSetValueEx(hk, L"OutputSimpChinese", 0, REG_DWORD, (LPBYTE)&outputSimpChinese, sizeof(DWORD)); - ::RegSetValueEx(hk, L"AddPhraseForward", 0, REG_DWORD, (LPBYTE)&addPhraseForward, sizeof(DWORD)); - ::RegSetValueEx(hk, L"ColorCandWnd", 0, REG_DWORD, (LPBYTE)&colorCandWnd, sizeof(DWORD)); - ::RegSetValueEx(hk, L"AdvanceAfterSelection", 0, REG_DWORD, (LPBYTE)&advanceAfterSelection, sizeof(DWORD)); - ::RegSetValueEx(hk, L"DefFontSize", 0, REG_DWORD, (LPBYTE)&fontSize, sizeof(DWORD)); - ::RegSetValueEx(hk, L"SelKeyType", 0, REG_DWORD, (LPBYTE)&selKeyType, sizeof(DWORD)); - ::RegSetValueEx(hk, L"ConvEngine", 0, REG_DWORD, (LPBYTE)&convEngine, sizeof(DWORD)); - ::RegSetValueEx(hk, L"SelAreaLen", 0, REG_DWORD, (LPBYTE)&candPerPage, sizeof(DWORD)); - ::RegSetValueEx(hk, L"CursorCandList", 0, REG_DWORD, (LPBYTE)&cursorCandList, sizeof(DWORD)); - ::RegSetValueEx(hk, L"EnableCapsLock", 0, REG_DWORD, (LPBYTE)&enableCapsLock, sizeof(DWORD)); - ::RegSetValueEx(hk, L"FullShapeSymbols", 0, REG_DWORD, (LPBYTE)&fullShapeSymbols, sizeof(DWORD)); - ::RegSetValueEx(hk, L"PhraseMark", 0, REG_DWORD, (LPBYTE)&phraseMark, sizeof(DWORD)); - ::RegSetValueEx(hk, L"EscCleanAllBuf", 0, REG_DWORD, (LPBYTE)&escCleanAllBuf, sizeof(DWORD)); - ::RegSetValueEx(hk, L"EasySymbolsWithShift", 0, REG_DWORD, (LPBYTE)&easySymbolsWithShift, sizeof(DWORD)); - ::RegSetValueEx(hk, L"EasySymbolsWithCtrl", 0, REG_DWORD, (LPBYTE)&easySymbolsWithCtrl, sizeof(DWORD)); - ::RegSetValueEx(hk, L"UpperCaseWithShift", 0, REG_DWORD, (LPBYTE)&upperCaseWithShift, sizeof(DWORD)); + ::RegSetValueExW(hk, L"KeyboardLayout", 0, REG_DWORD, (LPBYTE)&keyboardLayout, sizeof(DWORD)); + ::RegSetValueExW(hk, L"CandPerRow", 0, REG_DWORD, (LPBYTE)&candPerRow, sizeof(DWORD)); + ::RegSetValueExW(hk, L"DefaultEnglish", 0, REG_DWORD, (LPBYTE)&defaultEnglish, sizeof(DWORD)); + ::RegSetValueExW(hk, L"DefaultFullSpace", 0, REG_DWORD, (LPBYTE)&defaultFullSpace, sizeof(DWORD)); + ::RegSetValueExW(hk, L"ShowCandWithSpaceKey", 0, REG_DWORD, (LPBYTE)&showCandWithSpaceKey, sizeof(DWORD)); + ::RegSetValueExW(hk, L"SwitchLangWithShift", 0, REG_DWORD, (LPBYTE)&switchLangWithShift, sizeof(DWORD)); + ::RegSetValueExW(hk, L"OutputSimpChinese", 0, REG_DWORD, (LPBYTE)&outputSimpChinese, sizeof(DWORD)); + ::RegSetValueExW(hk, L"AddPhraseForward", 0, REG_DWORD, (LPBYTE)&addPhraseForward, sizeof(DWORD)); + ::RegSetValueExW(hk, L"ColorCandWnd", 0, REG_DWORD, (LPBYTE)&colorCandWnd, sizeof(DWORD)); + ::RegSetValueExW(hk, L"AdvanceAfterSelection", 0, REG_DWORD, (LPBYTE)&advanceAfterSelection, sizeof(DWORD)); + ::RegSetValueExW(hk, L"DefFontSize", 0, REG_DWORD, (LPBYTE)&fontSize, sizeof(DWORD)); + ::RegSetValueExW(hk, L"SelKeyType", 0, REG_DWORD, (LPBYTE)&selKeyType, sizeof(DWORD)); + ::RegSetValueExW(hk, L"ConvEngine", 0, REG_DWORD, (LPBYTE)&convEngine, sizeof(DWORD)); + ::RegSetValueExW(hk, L"SelAreaLen", 0, REG_DWORD, (LPBYTE)&candPerPage, sizeof(DWORD)); + ::RegSetValueExW(hk, L"CursorCandList", 0, REG_DWORD, (LPBYTE)&cursorCandList, sizeof(DWORD)); + ::RegSetValueExW(hk, L"EnableCapsLock", 0, REG_DWORD, (LPBYTE)&enableCapsLock, sizeof(DWORD)); + ::RegSetValueExW(hk, L"FullShapeSymbols", 0, REG_DWORD, (LPBYTE)&fullShapeSymbols, sizeof(DWORD)); + ::RegSetValueExW(hk, L"PhraseMark", 0, REG_DWORD, (LPBYTE)&phraseMark, sizeof(DWORD)); + ::RegSetValueExW(hk, L"EscCleanAllBuf", 0, REG_DWORD, (LPBYTE)&escCleanAllBuf, sizeof(DWORD)); + ::RegSetValueExW(hk, L"EasySymbolsWithShift", 0, REG_DWORD, (LPBYTE)&easySymbolsWithShift, sizeof(DWORD)); + ::RegSetValueExW(hk, L"EasySymbolsWithCtrl", 0, REG_DWORD, (LPBYTE)&easySymbolsWithCtrl, sizeof(DWORD)); + ::RegSetValueExW(hk, L"UpperCaseWithShift", 0, REG_DWORD, (LPBYTE)&upperCaseWithShift, sizeof(DWORD)); + ::RegSetValueExW(hk, L"ModifiedTimestamp", 0, REG_DWORD, (LPBYTE)×tamp, sizeof(DWORD)); ::RegCloseKey(hk); @@ -199,17 +199,11 @@ void Config::save() { } } -void Config::reloadIfNeeded(DWORD timestamp) { - if(stamp != timestamp) { - load(); - stamp = timestamp; - } -} - bool Config::reloadIfNeeded() { if (hChangeEvent) { DWORD result = WaitForSingleObject(hChangeEvent, 0); if (WAIT_OBJECT_0 == result) { + OutputDebugStringW(L"[chewing] config change detected, reload.\n"); load(); watchChanges(); return true; diff --git a/chewing_tip/ChewingConfig.h b/chewing_tip/ChewingConfig.h index 07cef19..dea7cc5 100644 --- a/chewing_tip/ChewingConfig.h +++ b/chewing_tip/ChewingConfig.h @@ -34,8 +34,6 @@ class Config { void load(); void save(); - // reload configurations if changes are detected (if timestamp is different from this->stamp) - void reloadIfNeeded(DWORD timestamp); // Returns true if config was reloaded bool reloadIfNeeded(); void watchChanges(); @@ -46,10 +44,6 @@ class Config { static bool createSecurityDesc(SECURITY_DESCRIPTOR& sd); public: - enum { - INVALID_TIMESTAMP = (DWORD)-1 - }; - // Configuration DWORD keyboardLayout; // keyboard type DWORD candPerRow; // candidate string per row (not supported yet) @@ -78,7 +72,6 @@ class Config { static const wchar_t* convEngines[]; private: - DWORD stamp; // timestamp used to check if the config values are up to date HANDLE hChangeEvent; HKEY monitorHkey; }; diff --git a/chewing_tip/ChewingTextService.cpp b/chewing_tip/ChewingTextService.cpp index 64d3d64..b278714 100644 --- a/chewing_tip/ChewingTextService.cpp +++ b/chewing_tip/ChewingTextService.cpp @@ -64,10 +64,6 @@ static const GUID g_settingsButtonGuid = // settings button/menu static const GUID g_shiftSpaceGuid = // shift + space { 0xc77a44f5, 0xdb21, 0x474e, { 0xa2, 0xa2, 0xa1, 0x72, 0x42, 0x21, 0x7a, 0xb3 } }; -// {F4D1E543-FB2C-48D7-B78D-20394F355381} // global compartment GUID for config change notification -static const GUID g_configChangedGuid = -{ 0xf4d1e543, 0xfb2c, 0x48d7, { 0xb7, 0x8d, 0x20, 0x39, 0x4f, 0x35, 0x53, 0x81 } }; - // this is the GUID of the IME mode icon in Windows 8 // the value is not available in older SDK versions, so let's define it ourselves. static const GUID _GUID_LBI_INPUTMODE = @@ -90,6 +86,7 @@ TextService::TextService(): symbolsFileTime_(0), chewingContext_(NULL) { + OutputDebugStringW(L"[chewing] Load config and start watching changes\n"); config_.load(); config_.watchChanges(); @@ -127,9 +124,6 @@ TextService::TextService(): } addButton(imeModeIcon_); } - - // global compartment stuff - addCompartmentMonitor(g_configChangedGuid, true); } TextService::~TextService(void) { @@ -155,8 +149,7 @@ CLSID TextService::clsid() { // virtual void TextService::onActivate() { - DWORD configStamp = globalCompartmentValue(g_configChangedGuid); - config().reloadIfNeeded(configStamp); + config().reloadIfNeeded(); initChewingContext(); updateLangButtons(); if(imeModeIcon_) // windows 8 IME mode icon @@ -194,7 +187,24 @@ void TextService::onKillFocus() { bool TextService::filterKeyDown(Ime::KeyEvent& keyEvent) { Config& cfg = config(); if (cfg.reloadIfNeeded()) { - applyConfig(); + // check if chewing context needs to be reloaded + bool chewingNeedsReload = false; + // check if symbols.dat file is changed + // get last mtime of symbols.dat file + std::wstring file = userDir() + L"\\symbols.dat"; + struct _stat64 stbuf; + if(_wstat64(file.c_str(), &stbuf) == 0 && symbolsFileTime_ != stbuf.st_mtime) { + symbolsFileTime_ = stbuf.st_mtime; + chewingNeedsReload = true; + } + // re-create a new chewing context if needed + if(chewingNeedsReload && chewingContext_) { + freeChewingContext(); + initChewingContext(); + } + else { + applyConfig(); // apply the latest config + } } lastKeyDownCode_ = keyEvent.keyCode(); // return false if we don't need this key @@ -634,37 +644,6 @@ bool TextService::onCommand(UINT id, CommandType type) { return true; } -// virtual -void TextService::onCompartmentChanged(const GUID& key) { - if(::IsEqualGUID(key, g_configChangedGuid)) { - // changes of configuration are detected - DWORD stamp = globalCompartmentValue(g_configChangedGuid); - config().reloadIfNeeded(stamp); - - // check if chewing context needs to be reloaded - bool chewingNeedsReload = false; - // check if symbols.dat file is changed - // get last mtime of symbols.dat file - std::wstring file = userDir() + L"\\symbols.dat"; - struct _stat64 stbuf; - if(_wstat64(file.c_str(), &stbuf) == 0 && symbolsFileTime_ != stbuf.st_mtime) { - symbolsFileTime_ = stbuf.st_mtime; - chewingNeedsReload = true; - } - - // re-create a new chewing context if needed - if(chewingNeedsReload && chewingContext_) { - freeChewingContext(); - initChewingContext(); - } - else { - applyConfig(); // apply the latest config - } - return; - } - Ime::TextService::onCompartmentChanged(key); -} - // called when the keyboard is opened or closed // virtual void TextService::onKeyboardStatusChanged(bool opened) { diff --git a/chewing_tip/ChewingTextService.h b/chewing_tip/ChewingTextService.h index 6e9b27d..31d992d 100644 --- a/chewing_tip/ChewingTextService.h +++ b/chewing_tip/ChewingTextService.h @@ -57,9 +57,6 @@ class TextService: public Ime::TextService { virtual bool onCommand(UINT id, CommandType type); - // called when a compartment value is changed - virtual void onCompartmentChanged(const GUID& key); - // called when the keyboard is opened or closed virtual void onKeyboardStatusChanged(bool opened); diff --git a/chewing_tip/TextService.cpp b/chewing_tip/TextService.cpp index f58e999..aa40d4b 100644 --- a/chewing_tip/TextService.cpp +++ b/chewing_tip/TextService.cpp @@ -51,13 +51,12 @@ TextService::TextService(): textEditSinkCookie_(TF_INVALID_COOKIE), compositionSinkCookie_(TF_INVALID_COOKIE), keyboardOpenEventSinkCookie_(TF_INVALID_COOKIE), - globalCompartmentEventSinkCookie_(TF_INVALID_COOKIE), langBarSinkCookie_(TF_INVALID_COOKIE), activateLanguageProfileNotifySinkCookie_(TF_INVALID_COOKIE), composition_(NULL), input_atom_(TF_INVALID_GUIDATOM), refCount_(1) { - addCompartmentMonitor(GUID_COMPARTMENT_KEYBOARD_OPENCLOSE, false); + addCompartmentMonitor(GUID_COMPARTMENT_KEYBOARD_OPENCLOSE); // FIXME we should only initialize once LibIME2Init(); @@ -80,11 +79,7 @@ TextService::~TextService(void) { if(!compartmentMonitors_.empty()) { vector::iterator it; for(it = compartmentMonitors_.begin(); it != compartmentMonitors_.end(); ++it) { - winrt::com_ptr source; - if(it->isGlobal) - source = globalCompartment(it->guid).as(); - else - source = threadCompartment(it->guid).as(); + winrt::com_ptr source = threadCompartment(it->guid).as(); if (source) { source->UnadviseSink(it->cookie); } @@ -322,18 +317,6 @@ void TextService::setCompositionCursor(EditSession* session, int pos) { } // compartment handling -winrt::com_ptr TextService::globalCompartment(const GUID& key) { - if(threadMgr_) { - winrt::com_ptr compartmentMgr; - if(threadMgr_->GetGlobalCompartment(compartmentMgr.put()) == S_OK) { - winrt::com_ptr compartment; - compartmentMgr->GetCompartment(key, compartment.put()); - return compartment; - } - } - return NULL; -} - winrt::com_ptr TextService::threadCompartment(const GUID& key) { if(threadMgr_) { winrt::com_ptr compartmentMgr = threadMgr_.as(); @@ -361,23 +344,9 @@ winrt::com_ptr TextService::contextCompartment(const GUID& key, return compartment; } } - if(curContext) - curContext->Release(); return NULL; } - -DWORD TextService::globalCompartmentValue(const GUID& key) { - winrt::com_ptr compartment = globalCompartment(key); - if(compartment) { - VARIANT var; - if(compartment->GetValue(&var) == S_OK && var.vt == VT_I4) { - return (DWORD)var.lVal; - } - } - return 0; -} - DWORD TextService::threadCompartmentValue(const GUID& key) { winrt::com_ptr compartment = threadCompartment(key); if(compartment) { @@ -403,43 +372,6 @@ DWORD TextService::contextCompartmentValue(const GUID& key, ITfContext* context) return 0; } -void TextService::setGlobalCompartmentValue(const GUID& key, DWORD value) { - if(threadMgr_) { - winrt::com_ptr compartment = globalCompartment(key); - if(compartment) { - VARIANT var; - ::VariantInit(&var); - var.vt = VT_I4; - var.lVal = value; - compartment->SetValue(clientId_, &var); - } - } - else { - // if we don't have a thread manager (this is possible when we try to set - // a global compartment value while the text service is not activated) - winrt::com_ptr threadMgr; - if(::CoCreateInstance(CLSID_TF_ThreadMgr, NULL, CLSCTX_INPROC_SERVER, IID_ITfThreadMgr, threadMgr.put_void()) == S_OK) { - if(threadMgr) { - winrt::com_ptr compartmentMgr; - if(threadMgr->GetGlobalCompartment(compartmentMgr.put()) == S_OK) { - winrt::com_ptr compartment; - if(compartmentMgr->GetCompartment(key, compartment.put()) == S_OK && compartment) { - TfClientId id; - if(threadMgr->Activate(&id) == S_OK) { - VARIANT var; - ::VariantInit(&var); - var.vt = VT_I4; - var.lVal = value; - compartment->SetValue(id, &var); - threadMgr->Deactivate(); - } - } - } - } - } - } -} - void TextService::setThreadCompartmentValue(const GUID& key, DWORD value) { winrt::com_ptr compartment = threadCompartment(key); if(compartment) { @@ -451,30 +383,13 @@ void TextService::setThreadCompartmentValue(const GUID& key, DWORD value) { } } -void TextService::setContextCompartmentValue(const GUID& key, DWORD value, ITfContext* context) { - winrt::com_ptr compartment = contextCompartment(key, context); - if(compartment) { - VARIANT var; - ::VariantInit(&var); - var.vt = VT_I4; - var.lVal = value; - compartment->SetValue(clientId_, &var); - } -} - - -void TextService::addCompartmentMonitor(const GUID key, bool isGlobal) { +void TextService::addCompartmentMonitor(const GUID key) { CompartmentMonitor monitor; monitor.guid = key; monitor.cookie = 0; - monitor.isGlobal = isGlobal; // if the text service is activated if(threadMgr_) { - winrt::com_ptr source; - if(isGlobal) - source = globalCompartment(key).as(); - else - source = threadCompartment(key).as(); + winrt::com_ptr source = threadCompartment(key).as(); if(source) { source->AdviseSink(IID_ITfCompartmentEventSink, (ITfCompartmentEventSink*)this, &monitor.cookie); } @@ -487,11 +402,7 @@ void TextService::removeCompartmentMonitor(const GUID key) { it = find(compartmentMonitors_.begin(), compartmentMonitors_.end(), key); if(it != compartmentMonitors_.end()) { if(threadMgr_) { - winrt::com_ptr source; - if(it->isGlobal) - source = globalCompartment(key).as(); - else - source = threadCompartment(key).as(); + winrt::com_ptr source = threadCompartment(key).as(); source->UnadviseSink(it->cookie); } compartmentMonitors_.erase(it); @@ -608,12 +519,8 @@ STDMETHODIMP TextService::Activate(ITfThreadMgr *pThreadMgr, TfClientId tfClient if(!compartmentMonitors_.empty()) { vector::iterator it; for(it = compartmentMonitors_.begin(); it != compartmentMonitors_.end(); ++it) { - winrt::com_ptr compartmentSource; - if(it->isGlobal) // global compartment - compartmentSource = globalCompartment(it->guid).as(); - else // thread specific compartment - compartmentSource = threadCompartment(it->guid).as(); - compartmentSource->AdviseSink(IID_ITfCompartmentEventSink, (ITfCompartmentEventSink*)this, &it->cookie); + winrt::com_ptr source = threadCompartment(it->guid).as(); + source->AdviseSink(IID_ITfCompartmentEventSink, (ITfCompartmentEventSink*)this, &it->cookie); } } isKeyboardOpened_ = threadCompartmentValue(GUID_COMPARTMENT_KEYBOARD_OPENCLOSE) != 0; @@ -709,17 +616,6 @@ STDMETHODIMP TextService::Deactivate() { keyboardOpenEventSinkCookie_ = TF_INVALID_COOKIE; } -/* - // global compartment - compartment = globalCompartment(XXX_GUID); - if(compartment) { - ComQIPtr compartmentSource = compartment; - if(compartmentSource) - compartmentSource->UnadviseSink(globalCompartmentEventSinkCookie_); - globalCompartmentEventSinkCookie_ = TF_INVALID_COOKIE; - } -*/ - threadMgr_ = NULL; clientId_ = TF_CLIENTID_NULL; activateFlags_ = 0; diff --git a/chewing_tip/TextService.h b/chewing_tip/TextService.h index d852d79..25e5102 100644 --- a/chewing_tip/TextService.h +++ b/chewing_tip/TextService.h @@ -127,21 +127,16 @@ class TextService: void setCompositionCursor(EditSession* session, int pos); // compartment handling - // XXX if registry monitor works well we can stop using compartments for RPC - winrt::com_ptr globalCompartment(const GUID& key); winrt::com_ptr threadCompartment(const GUID& key); winrt::com_ptr contextCompartment(const GUID& key, ITfContext* context = NULL); - DWORD globalCompartmentValue(const GUID& key); DWORD threadCompartmentValue(const GUID& key); DWORD contextCompartmentValue(const GUID& key, ITfContext* context = NULL); - void setGlobalCompartmentValue(const GUID& key, DWORD value); void setThreadCompartmentValue(const GUID& key, DWORD value); - void setContextCompartmentValue(const GUID& key, DWORD value, ITfContext* context = NULL); // manage sinks to global or thread compartment (context specific compartment is not used) - void addCompartmentMonitor(const GUID key, bool isGlobal = false); + void addCompartmentMonitor(const GUID key); void removeCompartmentMonitor(const GUID key); // virtual functions that IME implementors may need to override @@ -258,7 +253,6 @@ class TextService: struct CompartmentMonitor { GUID guid; DWORD cookie; - bool isGlobal; bool operator == (const GUID& other) const { return bool(::IsEqualGUID(guid, other)); @@ -281,7 +275,6 @@ class TextService: DWORD textEditSinkCookie_; DWORD compositionSinkCookie_; DWORD keyboardOpenEventSinkCookie_; - DWORD globalCompartmentEventSinkCookie_; DWORD langBarSinkCookie_; DWORD activateLanguageProfileNotifySinkCookie_;