Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(504)

Unified Diff: ui/base/win/tsf_bridge.cc

Issue 10933042: Call TSF's SetFocus iff the current focused document manager is expected ones (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/win/tsf_bridge.cc
diff --git a/ui/base/win/tsf_bridge.cc b/ui/base/win/tsf_bridge.cc
index 58785778dff0834f9a9977b441a2dc939e8aff57..8e98b76d4eb6b4e19a913ed824aa94978eeb88ab 100644
--- a/ui/base/win/tsf_bridge.cc
+++ b/ui/base/win/tsf_bridge.cc
@@ -104,32 +104,39 @@ class TsfBridgeDelegate : public TsfBridge {
virtual bool EnableIME() OVERRIDE {
DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type());
DCHECK(IsInitialized());
- if (SUCCEEDED(thread_manager_->SetFocus(document_manager_))) {
- return true;
- }
- return false;
+
+ // Since EnableIME and DisableIME are designed to be a swap operation of
+ // |document_manager_| and |disabled_document_manager_|, do nothing unless
+ // the current focused document manager is |disabled_document_manager_|.
+ // In other words, ITfThreadMgr::SetFocus should be called if and only if
+ // TsfBridge actually has TSF input focus. Otherwise, TSF input focus will
+ // be inconsistent with Win32 input focus.
+ if (!IsFocused(disabled_document_manager_))
+ return false;
+
+ return SUCCEEDED(thread_manager_->SetFocus(document_manager_));
}
// TsfBridge override.
virtual bool DisableIME() OVERRIDE {
DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type());
DCHECK(IsInitialized());
- if (SUCCEEDED(thread_manager_->SetFocus(disabled_document_manager_))) {
- return true;
- }
- return false;
+
+ // Do nothing unless the current focused document manager is
+ // |document_manager_|. See the comment in EnableIME.
+ if (!IsFocused(document_manager_))
+ return false;
+
+ return SUCCEEDED(thread_manager_->SetFocus(disabled_document_manager_));
}
// TsfBridge override.
virtual bool CancelComposition() OVERRIDE {
DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type());
DCHECK(IsInitialized());
- // If current focused document manager is not |document_manager_|, do
+ // If the current focused document manager is not |document_manager_|, do
// nothing here.
- base::win::ScopedComPtr<ITfDocumentMgr> focused_document_mangaer;
- if (FAILED(thread_manager_->GetFocus(focused_document_mangaer.Receive())))
- return false;
- if (!focused_document_mangaer.IsSameObject(document_manager_))
+ if (!IsFocused(document_manager_))
return false;
base::win::ScopedComPtr<ITfContext> context;
@@ -293,6 +300,14 @@ class TsfBridgeDelegate : public TsfBridge {
return true;
}
+ // Returns true if |document_manager| is the focused document manager.
+ bool IsFocused(base::win::ScopedComPtr<ITfDocumentMgr> document_manager) {
+ base::win::ScopedComPtr<ITfDocumentMgr> focused_document_mangaer;
+ if (FAILED(thread_manager_->GetFocus(focused_document_mangaer.Receive())))
+ return false;
+ return focused_document_mangaer.IsSameObject(document_manager);
+ }
+
// Returns true if already initialized.
bool IsInitialized() {
return client_id_ != TF_CLIENTID_NULL;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698