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

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

Issue 1566083002: Makes sure the keyboard typing isn't blocked when InputMethod::OnFocus() is not correctly called. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remote_input_method_win.cc is gone again. Created 4 years, 11 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
« no previous file with comments | « ui/base/ime/input_method_log_collector.cc ('k') | ui/base/ime/mock_input_method.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/base/ime/input_method_win.h" 5 #include "ui/base/ime/input_method_win.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 } 255 }
256 256
257 LRESULT InputMethodWin::OnChar(HWND window_handle, 257 LRESULT InputMethodWin::OnChar(HWND window_handle,
258 UINT message, 258 UINT message,
259 WPARAM wparam, 259 WPARAM wparam,
260 LPARAM lparam, 260 LPARAM lparam,
261 const base::NativeEvent& event, 261 const base::NativeEvent& event,
262 BOOL* handled) { 262 BOOL* handled) {
263 *handled = TRUE; 263 *handled = TRUE;
264 264
265 if (!system_toplevel_window_focused()) {
266 GetLogCollector()->AddString(
267 "Unexpected OnChar: InputMethod is not active. Window focused: ");
268 GetLogCollector()->AddBoolean(
269 ::GetActiveWindow() == toplevel_window_handle_);
270 GetLogCollector()->DumpLogs();
271 // There are random issues that the keyboard typing doesn't work.
272 // The root cause might be the InputMethod::OnFocus() is not correctly
273 // called when the top-level window is activated
274 // (in DNWA::HandleActivationChanged).
275 // Calls OnFocus here to unblock the keyboard typing.
276 OnFocus();
277 } else {
278 GetLogCollector()->ClearLogs();
279 }
280
265 // We need to send character events to the focused text input client event if 281 // We need to send character events to the focused text input client event if
266 // its text input type is ui::TEXT_INPUT_TYPE_NONE. 282 // its text input type is ui::TEXT_INPUT_TYPE_NONE.
267 if (GetTextInputClient()) { 283 if (GetTextInputClient()) {
268 const base::char16 kCarriageReturn = L'\r'; 284 const base::char16 kCarriageReturn = L'\r';
269 const base::char16 ch = static_cast<base::char16>(wparam); 285 const base::char16 ch = static_cast<base::char16>(wparam);
270 // A mask to determine the previous key state from |lparam|. The value is 1 286 // A mask to determine the previous key state from |lparam|. The value is 1
271 // if the key is down before the message is sent, or it is 0 if the key is 287 // if the key is down before the message is sent, or it is 0 if the key is
272 // up. 288 // up.
273 const uint32_t kPrevKeyDownBit = 0x40000000; 289 const uint32_t kPrevKeyDownBit = 0x40000000;
274 if (ch == kCarriageReturn && !(lparam & kPrevKeyDownBit)) 290 if (ch == kCarriageReturn && !(lparam & kPrevKeyDownBit))
(...skipping 13 matching lines...) Expand all
288 gfx::ShowSystemMenu(window_handle); 304 gfx::ShowSystemMenu(window_handle);
289 305
290 return 0; 306 return 0;
291 } 307 }
292 308
293 LRESULT InputMethodWin::OnImeSetContext(HWND window_handle, 309 LRESULT InputMethodWin::OnImeSetContext(HWND window_handle,
294 UINT message, 310 UINT message,
295 WPARAM wparam, 311 WPARAM wparam,
296 LPARAM lparam, 312 LPARAM lparam,
297 BOOL* handled) { 313 BOOL* handled) {
314 GetLogCollector()->AddString("WM_IME_SETCONTEXT");
298 if (!!wparam) { 315 if (!!wparam) {
299 imm32_manager_.CreateImeWindow(window_handle); 316 imm32_manager_.CreateImeWindow(window_handle);
300 if (system_toplevel_window_focused()) { 317 if (system_toplevel_window_focused()) {
301 // Delay initialize the tsf to avoid perf regression. 318 // Delay initialize the tsf to avoid perf regression.
302 // Loading tsf dll causes some time, so doing it in UpdateIMEState() will 319 // Loading tsf dll causes some time, so doing it in UpdateIMEState() will
303 // slow down the browser window creation. 320 // slow down the browser window creation.
304 // See crbug.com/509984. 321 // See crbug.com/509984.
305 tsf_inputscope::InitializeTsfForInputScopes(); 322 tsf_inputscope::InitializeTsfForInputScopes();
306 tsf_inputscope::SetInputScopeForTsfUnawareWindow( 323 tsf_inputscope::SetInputScopeForTsfUnawareWindow(
307 toplevel_window_handle_, GetTextInputType(), GetTextInputMode()); 324 toplevel_window_handle_, GetTextInputType(), GetTextInputMode());
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 enabled_ = true; 651 enabled_ = true;
635 break; 652 break;
636 } 653 }
637 654
638 imm32_manager_.SetTextInputMode(window_handle, text_input_mode); 655 imm32_manager_.SetTextInputMode(window_handle, text_input_mode);
639 tsf_inputscope::SetInputScopeForTsfUnawareWindow( 656 tsf_inputscope::SetInputScopeForTsfUnawareWindow(
640 window_handle, text_input_type, text_input_mode); 657 window_handle, text_input_type, text_input_mode);
641 } 658 }
642 659
643 } // namespace ui 660 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/ime/input_method_log_collector.cc ('k') | ui/base/ime/mock_input_method.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698