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_imm32.h" | 5 #include "ui/base/ime/input_method_imm32.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "ui/base/ime/composition_text.h" | 8 #include "ui/base/ime/composition_text.h" |
9 #include "ui/base/ime/text_input_client.h" | 9 #include "ui/base/ime/text_input_client.h" |
10 #include "ui/base/ime/win/tsf_input_scope.h" | 10 #include "ui/base/ime/win/tsf_input_scope.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 | 87 |
88 void InputMethodIMM32::OnTextInputTypeChanged(const TextInputClient* client) { | 88 void InputMethodIMM32::OnTextInputTypeChanged(const TextInputClient* client) { |
89 if (IsTextInputClientFocused(client) && IsWindowFocused(client)) { | 89 if (IsTextInputClientFocused(client) && IsWindowFocused(client)) { |
90 imm32_manager_.CancelIME(GetAttachedWindowHandle(client)); | 90 imm32_manager_.CancelIME(GetAttachedWindowHandle(client)); |
91 UpdateIMEState(); | 91 UpdateIMEState(); |
92 } | 92 } |
93 InputMethodWin::OnTextInputTypeChanged(client); | 93 InputMethodWin::OnTextInputTypeChanged(client); |
94 } | 94 } |
95 | 95 |
96 void InputMethodIMM32::OnCaretBoundsChanged(const TextInputClient* client) { | 96 void InputMethodIMM32::OnCaretBoundsChanged(const TextInputClient* client) { |
97 if (!enabled_ || !IsTextInputClientFocused(client) || | 97 if (enabled_ && IsTextInputClientFocused(client) && IsWindowFocused(client)) { |
98 !IsWindowFocused(client)) { | 98 // The current text input type should not be NONE if |client| is focused. |
99 return; | 99 DCHECK(!IsTextInputTypeNone()); |
| 100 gfx::Rect screen_bounds(GetTextInputClient()->GetCaretBounds()); |
| 101 |
| 102 HWND attached_window = GetAttachedWindowHandle(client); |
| 103 // TODO(ime): see comment in TextInputClient::GetCaretBounds(), this |
| 104 // conversion shouldn't be necessary. |
| 105 RECT r = {}; |
| 106 GetClientRect(attached_window, &r); |
| 107 POINT window_point = { screen_bounds.x(), screen_bounds.y() }; |
| 108 ScreenToClient(attached_window, &window_point); |
| 109 gfx::Rect caret_rect(gfx::Point(window_point.x, window_point.y), |
| 110 screen_bounds.size()); |
| 111 imm32_manager_.UpdateCaretRect(attached_window, caret_rect); |
100 } | 112 } |
101 | 113 InputMethodWin::OnCaretBoundsChanged(client); |
102 // The current text input type should not be NONE if |client| is focused. | |
103 DCHECK(!IsTextInputTypeNone()); | |
104 gfx::Rect screen_bounds(GetTextInputClient()->GetCaretBounds()); | |
105 | |
106 HWND attached_window = GetAttachedWindowHandle(client); | |
107 // TODO(ime): see comment in TextInputClient::GetCaretBounds(), this | |
108 // conversion shouldn't be necessary. | |
109 RECT r; | |
110 GetClientRect(attached_window, &r); | |
111 POINT window_point = { screen_bounds.x(), screen_bounds.y() }; | |
112 ScreenToClient(attached_window, &window_point); | |
113 imm32_manager_.UpdateCaretRect( | |
114 attached_window, | |
115 gfx::Rect(gfx::Point(window_point.x, window_point.y), | |
116 screen_bounds.size())); | |
117 } | 114 } |
118 | 115 |
119 void InputMethodIMM32::CancelComposition(const TextInputClient* client) { | 116 void InputMethodIMM32::CancelComposition(const TextInputClient* client) { |
120 if (enabled_ && IsTextInputClientFocused(client)) | 117 if (enabled_ && IsTextInputClientFocused(client)) |
121 imm32_manager_.CancelIME(GetAttachedWindowHandle(client)); | 118 imm32_manager_.CancelIME(GetAttachedWindowHandle(client)); |
122 } | 119 } |
123 | 120 |
124 bool InputMethodIMM32::IsCandidatePopupOpen() const { | 121 bool InputMethodIMM32::IsCandidatePopupOpen() const { |
125 return is_candidate_popup_open_; | 122 return is_candidate_popup_open_; |
126 } | 123 } |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 enabled_ = true; | 276 enabled_ = true; |
280 break; | 277 break; |
281 } | 278 } |
282 | 279 |
283 imm32_manager_.SetTextInputMode(window_handle, text_input_mode); | 280 imm32_manager_.SetTextInputMode(window_handle, text_input_mode); |
284 tsf_inputscope::SetInputScopeForTsfUnawareWindow( | 281 tsf_inputscope::SetInputScopeForTsfUnawareWindow( |
285 window_handle, text_input_type, text_input_mode); | 282 window_handle, text_input_type, text_input_mode); |
286 } | 283 } |
287 | 284 |
288 } // namespace ui | 285 } // namespace ui |
OLD | NEW |