OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/base/ime/input_method_tsf.h" | 5 #include "ui/base/ime/input_method_tsf.h" |
6 | 6 |
7 #include "ui/base/ime/text_input_client.h" | 7 #include "ui/base/ime/text_input_client.h" |
8 #include "ui/base/ime/win/tsf_bridge.h" | 8 #include "ui/base/ime/win/tsf_bridge.h" |
9 #include "ui/base/ime/win/tsf_event_router.h" | 9 #include "ui/base/ime/win/tsf_event_router.h" |
10 | 10 |
11 namespace ui { | 11 namespace ui { |
12 | 12 |
13 class InputMethodTSF::TSFEventObserver : public TSFEventRouterObserver { | 13 class InputMethodTSF::TSFEventObserver : public TSFEventRouterObserver { |
14 public: | 14 public: |
15 TSFEventObserver() : is_candidate_popup_open_(false) {} | 15 TSFEventObserver() : is_candidate_popup_open_(false), window_count_(0) {} |
16 | 16 |
17 // Returns true if we know for sure that a candidate window (or IME suggest, | 17 // Returns true if we know for sure that a candidate window (or IME suggest, |
18 // etc.) is open. | 18 // etc.) is open. |
19 bool IsCandidatePopupOpen() const { return is_candidate_popup_open_; } | 19 bool IsCandidatePopupOpen() const { return is_candidate_popup_open_; } |
20 | 20 |
21 // Overridden from TSFEventRouterObserver: | 21 // Overridden from TSFEventRouterObserver: |
22 virtual void OnCandidateWindowCountChanged(size_t window_count) OVERRIDE { | 22 virtual void OnCandidateWindowCountChanged(size_t window_count) OVERRIDE { |
23 is_candidate_popup_open_ = (window_count != 0); | 23 is_candidate_popup_open_ = (window_count != 0); |
| 24 if (window_count_ == 0 && window_count) { |
| 25 TSFBridge::GetInstance()->OnCandidateWindowShown(); |
| 26 } else if (window_count_ && window_count) { |
| 27 TSFBridge::GetInstance()->OnCandidateWindowUpdated(); |
| 28 } else if (window_count_ && window_count == 0) { |
| 29 TSFBridge::GetInstance()->OnCandidateWindowHidden(); |
| 30 } |
| 31 window_count_ = window_count; |
24 } | 32 } |
25 | 33 |
26 private: | 34 private: |
27 // True if we know for sure that a candidate window is open. | 35 // True if we know for sure that a candidate window is open. |
28 bool is_candidate_popup_open_; | 36 bool is_candidate_popup_open_; |
| 37 // Number of visible windows for showing candidates and their related |
| 38 // information. |
| 39 int window_count_; |
29 | 40 |
30 DISALLOW_COPY_AND_ASSIGN(TSFEventObserver); | 41 DISALLOW_COPY_AND_ASSIGN(TSFEventObserver); |
31 }; | 42 }; |
32 | 43 |
33 InputMethodTSF::InputMethodTSF(internal::InputMethodDelegate* delegate, | 44 InputMethodTSF::InputMethodTSF(internal::InputMethodDelegate* delegate, |
34 HWND toplevel_window_handle) | 45 HWND toplevel_window_handle) |
35 : InputMethodWin(delegate, toplevel_window_handle), | 46 : InputMethodWin(delegate, toplevel_window_handle), |
36 tsf_event_observer_(new TSFEventObserver()), | 47 tsf_event_observer_(new TSFEventObserver()), |
37 tsf_event_router_(new TSFEventRouter(tsf_event_observer_.get())) { | 48 tsf_event_router_(new TSFEventRouter(tsf_event_observer_.get())) { |
38 // In non-Aura environment, appropriate callbacks to OnFocus() and OnBlur() | 49 // In non-Aura environment, appropriate callbacks to OnFocus() and OnBlur() |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 } | 160 } |
150 InputMethodWin::OnDidChangeFocusedClient(focused_before, focused); | 161 InputMethodWin::OnDidChangeFocusedClient(focused_before, focused); |
151 } | 162 } |
152 | 163 |
153 void InputMethodTSF::ConfirmCompositionText() { | 164 void InputMethodTSF::ConfirmCompositionText() { |
154 if (!IsTextInputTypeNone()) | 165 if (!IsTextInputTypeNone()) |
155 ui::TSFBridge::GetInstance()->ConfirmComposition(); | 166 ui::TSFBridge::GetInstance()->ConfirmComposition(); |
156 } | 167 } |
157 | 168 |
158 } // namespace ui | 169 } // namespace ui |
OLD | NEW |