OLD | NEW |
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 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 // When Aura is enabled, |attached_window_handle| should always be a top-level | 612 // When Aura is enabled, |attached_window_handle| should always be a top-level |
613 // window. So we can safely assume that |attached_window_handle| is ready for | 613 // window. So we can safely assume that |attached_window_handle| is ready for |
614 // receiving keyboard input as long as it is an active window. This works well | 614 // receiving keyboard input as long as it is an active window. This works well |
615 // even when the |attached_window_handle| becomes active but has not received | 615 // even when the |attached_window_handle| becomes active but has not received |
616 // WM_FOCUS yet. | 616 // WM_FOCUS yet. |
617 return toplevel_window_handle_ && | 617 return toplevel_window_handle_ && |
618 GetActiveWindow() == toplevel_window_handle_; | 618 GetActiveWindow() == toplevel_window_handle_; |
619 } | 619 } |
620 | 620 |
621 void InputMethodWin::DispatchFabricatedKeyEvent(ui::KeyEvent* event) { | 621 void InputMethodWin::DispatchFabricatedKeyEvent(ui::KeyEvent* event) { |
622 if (event->is_char()) { | 622 // The key event if from calling input.ime.sendKeyEvent or test. |
623 if (GetTextInputClient()) { | 623 ui::EventDispatchDetails details = DispatchKeyEventPostIME(event); |
624 ui::KeyEvent ch_event(*event); | 624 if (details.dispatcher_destroyed || details.target_destroyed || |
625 ch_event.set_character(static_cast<base::char16>(event->key_code())); | 625 event->stopped_propagation()) { |
626 GetTextInputClient()->InsertChar(ch_event); | 626 return; |
627 return; | |
628 } | |
629 } | 627 } |
630 ignore_result(DispatchKeyEventPostIME(event)); | 628 |
| 629 if ((event->is_char() || event->GetDomKey().IsCharacter()) && |
| 630 event->type() == ui::ET_KEY_PRESSED && GetTextInputClient()) |
| 631 GetTextInputClient()->InsertChar(*event); |
631 } | 632 } |
632 | 633 |
633 void InputMethodWin::ConfirmCompositionText() { | 634 void InputMethodWin::ConfirmCompositionText() { |
634 if (composing_window_handle_) | 635 if (composing_window_handle_) |
635 imm32_manager_.CleanupComposition(composing_window_handle_); | 636 imm32_manager_.CleanupComposition(composing_window_handle_); |
636 | 637 |
637 // Though above line should confirm the client's composition text by sending a | 638 // Though above line should confirm the client's composition text by sending a |
638 // result text to us, in case the input method and the client are in | 639 // result text to us, in case the input method and the client are in |
639 // inconsistent states, we check the client's composition state again. | 640 // inconsistent states, we check the client's composition state again. |
640 if (!IsTextInputTypeNone() && GetTextInputClient()->HasCompositionText()) { | 641 if (!IsTextInputTypeNone() && GetTextInputClient()->HasCompositionText()) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 ui::IMEEngineHandlerInterface* engine = GetEngine(); | 680 ui::IMEEngineHandlerInterface* engine = GetEngine(); |
680 if (engine) { | 681 if (engine) { |
681 if (old_text_input_type != ui::TEXT_INPUT_TYPE_NONE) | 682 if (old_text_input_type != ui::TEXT_INPUT_TYPE_NONE) |
682 engine->FocusOut(); | 683 engine->FocusOut(); |
683 if (text_input_type != ui::TEXT_INPUT_TYPE_NONE) | 684 if (text_input_type != ui::TEXT_INPUT_TYPE_NONE) |
684 engine->FocusIn(context); | 685 engine->FocusIn(context); |
685 } | 686 } |
686 } | 687 } |
687 | 688 |
688 } // namespace ui | 689 } // namespace ui |
OLD | NEW |