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

Side by Side Diff: ui/views/ime/input_method_win.cc

Issue 17112021: New method: InputMethod::IsCandidatePopupOpen() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed test code Created 7 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/views/ime/input_method_win.h" 5 #include "ui/views/ime/input_method_win.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "ui/base/events/event.h" 10 #include "ui/base/events/event.h"
11 #include "ui/base/events/event_constants.h" 11 #include "ui/base/events/event_constants.h"
12 #include "ui/base/events/event_utils.h" 12 #include "ui/base/events/event_utils.h"
13 #include "ui/base/ime/composition_text.h" 13 #include "ui/base/ime/composition_text.h"
14 #include "ui/base/ime/input_method.h" 14 #include "ui/base/ime/input_method.h"
15 #include "ui/base/ime/text_input_client.h" 15 #include "ui/base/ime/text_input_client.h"
16 #include "ui/base/keycodes/keyboard_codes.h" 16 #include "ui/base/keycodes/keyboard_codes.h"
17 #include "ui/base/win/hwnd_util.h" 17 #include "ui/base/win/hwnd_util.h"
18 18
19 // Extra number of chars before and after selection (or composition) range which 19 // Extra number of chars before and after selection (or composition) range which
20 // is returned to IME for improving conversion accuracy. 20 // is returned to IME for improving conversion accuracy.
21 static const size_t kExtraNumberOfChars = 20; 21 static const size_t kExtraNumberOfChars = 20;
22 22
23 namespace views { 23 namespace views {
24 24
25 InputMethodWin::InputMethodWin(internal::InputMethodDelegate* delegate, 25 InputMethodWin::InputMethodWin(internal::InputMethodDelegate* delegate,
26 HWND hwnd, 26 HWND hwnd,
27 ui::InputMethod* host) 27 ui::InputMethod* host)
28 : hwnd_(hwnd), 28 : hwnd_(hwnd),
29 active_(false), 29 active_(false),
30 is_popup_open_(false),
30 direction_(base::i18n::UNKNOWN_DIRECTION), 31 direction_(base::i18n::UNKNOWN_DIRECTION),
31 pending_requested_direction_(base::i18n::UNKNOWN_DIRECTION), 32 pending_requested_direction_(base::i18n::UNKNOWN_DIRECTION),
32 host_(host) { 33 host_(host) {
33 SetDelegate(delegate); 34 SetDelegate(delegate);
34 } 35 }
35 36
36 InputMethodWin::~InputMethodWin() { 37 InputMethodWin::~InputMethodWin() {
37 if (widget()) 38 if (widget())
38 ime_input_.DisableIME(hwnd_); 39 ime_input_.DisableIME(hwnd_);
39 } 40 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 event.message, event.wParam, event.lParam, &handled); 72 event.message, event.wParam, event.lParam, &handled);
72 break; 73 break;
73 case WM_IME_ENDCOMPOSITION: 74 case WM_IME_ENDCOMPOSITION:
74 original_result = OnImeEndComposition( 75 original_result = OnImeEndComposition(
75 event.message, event.wParam, event.lParam, &handled); 76 event.message, event.wParam, event.lParam, &handled);
76 break; 77 break;
77 case WM_IME_REQUEST: 78 case WM_IME_REQUEST:
78 original_result = OnImeRequest( 79 original_result = OnImeRequest(
79 event.message, event.wParam, event.lParam, &handled); 80 event.message, event.wParam, event.lParam, &handled);
80 break; 81 break;
82 case WM_IME_NOTIFY:
83 original_result = OnImeNotify(
84 event.message, event.wParam, event.lParam, &handled);
85 break;
81 case WM_CHAR: 86 case WM_CHAR:
82 case WM_SYSCHAR: 87 case WM_SYSCHAR:
83 original_result = OnChar( 88 original_result = OnChar(
84 event.message, event.wParam, event.lParam, &handled); 89 event.message, event.wParam, event.lParam, &handled);
85 break; 90 break;
86 case WM_DEADCHAR: 91 case WM_DEADCHAR:
87 case WM_SYSDEADCHAR: 92 case WM_SYSDEADCHAR:
88 original_result = OnDeadChar( 93 original_result = OnDeadChar(
89 event.message, event.wParam, event.lParam, &handled); 94 event.message, event.wParam, event.lParam, &handled);
90 break; 95 break;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 return active_; 165 return active_;
161 } 166 }
162 167
163 ui::TextInputClient* InputMethodWin::GetTextInputClient() const { 168 ui::TextInputClient* InputMethodWin::GetTextInputClient() const {
164 if (InputMethodBase::GetTextInputClient()) 169 if (InputMethodBase::GetTextInputClient())
165 return InputMethodBase::GetTextInputClient(); 170 return InputMethodBase::GetTextInputClient();
166 171
167 return host_ ? host_->GetTextInputClient() : NULL; 172 return host_ ? host_->GetTextInputClient() : NULL;
168 } 173 }
169 174
175 bool InputMethodWin::IsPopupOpen() const {
176 return is_popup_open_;
177 }
178
170 void InputMethodWin::OnWillChangeFocus(View* focused_before, View* focused) { 179 void InputMethodWin::OnWillChangeFocus(View* focused_before, View* focused) {
171 ConfirmCompositionText(); 180 ConfirmCompositionText();
172 } 181 }
173 182
174 void InputMethodWin::OnDidChangeFocus(View* focused_before, View* focused) { 183 void InputMethodWin::OnDidChangeFocus(View* focused_before, View* focused) {
175 UpdateIMEState(); 184 UpdateIMEState();
176 } 185 }
177 186
178 LRESULT InputMethodWin::OnImeSetContext( 187 LRESULT InputMethodWin::OnImeSetContext(
179 UINT message, WPARAM wparam, LPARAM lparam, BOOL* handled) { 188 UINT message, WPARAM wparam, LPARAM lparam, BOOL* handled) {
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 *handled = TRUE; 276 *handled = TRUE;
268 return OnDocumentFeed(reinterpret_cast<RECONVERTSTRING*>(lparam)); 277 return OnDocumentFeed(reinterpret_cast<RECONVERTSTRING*>(lparam));
269 case IMR_QUERYCHARPOSITION: 278 case IMR_QUERYCHARPOSITION:
270 *handled = TRUE; 279 *handled = TRUE;
271 return OnQueryCharPosition(reinterpret_cast<IMECHARPOSITION*>(lparam)); 280 return OnQueryCharPosition(reinterpret_cast<IMECHARPOSITION*>(lparam));
272 default: 281 default:
273 return 0; 282 return 0;
274 } 283 }
275 } 284 }
276 285
286 LRESULT InputMethodWin::OnImeNotify(
287 UINT message, WPARAM wparam, LPARAM lparam, BOOL* handled) {
288 *handled = FALSE;
289
290 // Update |is_popup_open_|, whether a candidate window is open or not.
291 switch (wparam) {
292 case IMN_OPENCANDIDATE:
293 is_popup_open_ = true;
294 break;
295 case IMN_CLOSECANDIDATE:
296 is_popup_open_ = false;
297 break;
298 }
299
300 return 0;
301 }
302
277 LRESULT InputMethodWin::OnChar( 303 LRESULT InputMethodWin::OnChar(
278 UINT message, WPARAM wparam, LPARAM lparam, BOOL* handled) { 304 UINT message, WPARAM wparam, LPARAM lparam, BOOL* handled) {
279 *handled = TRUE; 305 *handled = TRUE;
280 306
281 // We need to send character events to the focused text input client event if 307 // We need to send character events to the focused text input client event if
282 // its text input type is ui::TEXT_INPUT_TYPE_NONE. 308 // its text input type is ui::TEXT_INPUT_TYPE_NONE.
283 if (GetTextInputClient()) { 309 if (GetTextInputClient()) {
284 GetTextInputClient()->InsertChar(static_cast<char16>(wparam), 310 GetTextInputClient()->InsertChar(static_cast<char16>(wparam),
285 ui::GetModifiersFromKeyState()); 311 ui::GetModifiersFromKeyState());
286 } 312 }
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 case ui::TEXT_INPUT_TYPE_PASSWORD: 498 case ui::TEXT_INPUT_TYPE_PASSWORD:
473 ime_input_.DisableIME(hwnd_); 499 ime_input_.DisableIME(hwnd_);
474 break; 500 break;
475 default: 501 default:
476 ime_input_.EnableIME(hwnd_); 502 ime_input_.EnableIME(hwnd_);
477 break; 503 break;
478 } 504 }
479 } 505 }
480 506
481 } // namespace views 507 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698