diff options
author | yukishiino@chromium.org <yukishiino@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-10 09:25:08 +0000 |
---|---|---|
committer | yukishiino@chromium.org <yukishiino@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-10 09:25:08 +0000 |
commit | 99a31b2aef6a7bf32f0dfb8944faa5aa1ef8de34 (patch) | |
tree | 157f945c652fd38fa711c603c17c2260fb23a525 /ui/base | |
parent | fd5e0ca43155e82788d8cdaff70607bc2dd90508 (diff) | |
download | chromium_src-99a31b2aef6a7bf32f0dfb8944faa5aa1ef8de34.zip chromium_src-99a31b2aef6a7bf32f0dfb8944faa5aa1ef8de34.tar.gz chromium_src-99a31b2aef6a7bf32f0dfb8944faa5aa1ef8de34.tar.bz2 |
Supports IsCandidatePopupOpen() on Windows-TSF environment.
BUG=245578
TEST=Test manually.
Review URL: https://chromiumcodereview.appspot.com/17573006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@210788 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base')
-rw-r--r-- | ui/base/ime/input_method_tsf.cc | 43 | ||||
-rw-r--r-- | ui/base/ime/input_method_tsf.h | 10 |
2 files changed, 46 insertions, 7 deletions
diff --git a/ui/base/ime/input_method_tsf.cc b/ui/base/ime/input_method_tsf.cc index c786b48..cd94355 100644 --- a/ui/base/ime/input_method_tsf.cc +++ b/ui/base/ime/input_method_tsf.cc @@ -6,12 +6,35 @@ #include "ui/base/ime/text_input_client.h" #include "ui/base/ime/win/tsf_bridge.h" +#include "ui/base/ime/win/tsf_event_router.h" namespace ui { +class InputMethodTSF::TSFEventObserver : public TSFEventRouterObserver { + public: + TSFEventObserver() : is_candidate_popup_open_(false) {} + + // Returns true if we know for sure that a candidate window (or IME suggest, + // etc.) is open. + bool IsCandidatePopupOpen() const { return is_candidate_popup_open_; } + + // Overridden from TSFEventRouterObserver: + virtual void OnCandidateWindowCountChanged(size_t window_count) OVERRIDE { + is_candidate_popup_open_ = (window_count != 0); + } + + private: + // True if we know for sure that a candidate window is open. + bool is_candidate_popup_open_; + + DISALLOW_COPY_AND_ASSIGN(TSFEventObserver); +}; + InputMethodTSF::InputMethodTSF(internal::InputMethodDelegate* delegate, HWND toplevel_window_handle) - : InputMethodWin(delegate, toplevel_window_handle) { + : InputMethodWin(delegate, toplevel_window_handle), + tsf_event_observer_(new TSFEventObserver()), + tsf_event_router_(new TSFEventRouter(tsf_event_observer_.get())) { // In non-Aura environment, appropriate callbacks to OnFocus() and OnBlur() // are not implemented yet. To work around this limitation, here we use // "always focused" model. @@ -20,16 +43,23 @@ InputMethodTSF::InputMethodTSF(internal::InputMethodDelegate* delegate, InputMethodWin::OnFocus(); } +InputMethodTSF::~InputMethodTSF() {} + void InputMethodTSF::OnFocus() { - // Ignore OnFocus event for "always focused" model. See the comment in the - // constructor. + // Do not call baseclass' OnFocus() and discard the event being in + // "always focused" model. See the comment in the constructor. // TODO(ime): Implement OnFocus once the callers are fixed. + + tsf_event_router_->SetManager( + ui::TSFBridge::GetInstance()->GetThreadManager()); } void InputMethodTSF::OnBlur() { - // Ignore OnBlur event for "always focused" model. See the comment in the - // constructor. + // Do not call baseclass' OnBlur() and discard the event being in + // "always focused" model. See the comment in the constructor. // TODO(ime): Implement OnFocus once the callers are fixed. + + tsf_event_router_->SetManager(NULL); } bool InputMethodTSF::OnUntranslatedIMEMessage( @@ -99,8 +129,7 @@ void InputMethodTSF::SetFocusedTextInputClient(TextInputClient* client) { } bool InputMethodTSF::IsCandidatePopupOpen() const { - // TODO(yukishiino): Implement this method. - return false; + return tsf_event_observer_->IsCandidatePopupOpen(); } void InputMethodTSF::OnWillChangeFocusedClient(TextInputClient* focused_before, diff --git a/ui/base/ime/input_method_tsf.h b/ui/base/ime/input_method_tsf.h index 45c5add..98fa1f7 100644 --- a/ui/base/ime/input_method_tsf.h +++ b/ui/base/ime/input_method_tsf.h @@ -9,15 +9,19 @@ #include <string> +#include "base/memory/scoped_ptr.h" #include "ui/base/ime/input_method_win.h" namespace ui { +class TSFEventRouter; + // An InputMethod implementation based on Windows TSF API. class UI_EXPORT InputMethodTSF : public InputMethodWin { public: InputMethodTSF(internal::InputMethodDelegate* delegate, HWND toplevel_window_handle); + virtual ~InputMethodTSF(); // Overridden from InputMethod: virtual void OnFocus() OVERRIDE; @@ -37,6 +41,8 @@ class UI_EXPORT InputMethodTSF : public InputMethodWin { TextInputClient* focused) OVERRIDE; private: + class TSFEventObserver; + // Asks the client to confirm current composition text. void ConfirmCompositionText(); @@ -44,6 +50,10 @@ class UI_EXPORT InputMethodTSF : public InputMethodWin { // focus. bool IsWindowFocused(const TextInputClient* client) const; + // TSF event router and observer. + scoped_ptr<TSFEventObserver> tsf_event_observer_; + scoped_ptr<TSFEventRouter> tsf_event_router_; + DISALLOW_COPY_AND_ASSIGN(InputMethodTSF); }; |