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