OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 "mandoline/ui/aura/input_method_mandoline.h" | 5 #include "mandoline/ui/aura/input_method_mandoline.h" |
6 | 6 |
7 #include "ui/base/ime/text_input_client.h" | 7 #include "ui/base/ime/text_input_client.h" |
8 #include "ui/events/event.h" | 8 #include "ui/events/event.h" |
9 | 9 |
10 namespace mandoline { | 10 namespace mandoline { |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 //////////////////////////////////////////////////////////////////////////////// | 22 //////////////////////////////////////////////////////////////////////////////// |
23 // InputMethodMandoline, ui::InputMethod implementation: | 23 // InputMethodMandoline, ui::InputMethod implementation: |
24 | 24 |
25 bool InputMethodMandoline::OnUntranslatedIMEMessage( | 25 bool InputMethodMandoline::OnUntranslatedIMEMessage( |
26 const base::NativeEvent& event, | 26 const base::NativeEvent& event, |
27 NativeEventResult* result) { | 27 NativeEventResult* result) { |
28 return false; | 28 return false; |
29 } | 29 } |
30 | 30 |
31 bool InputMethodMandoline::DispatchKeyEvent(const ui::KeyEvent& event) { | 31 void InputMethodMandoline::DispatchKeyEvent(ui::KeyEvent* event) { |
32 DCHECK(event.type() == ui::ET_KEY_PRESSED || | 32 DCHECK(event->type() == ui::ET_KEY_PRESSED || |
33 event.type() == ui::ET_KEY_RELEASED); | 33 event->type() == ui::ET_KEY_RELEASED); |
34 | 34 |
35 // If no text input client, do nothing. | 35 // If no text input client, do nothing. |
36 if (!GetTextInputClient()) | 36 if (!GetTextInputClient()) { |
37 return DispatchKeyEventPostIME(event); | 37 ignore_result(DispatchKeyEventPostIME(event)); |
| 38 return; |
| 39 } |
38 | 40 |
39 // Here is where we change the differ from our base class's logic. Instead of | 41 // Here is where we change the differ from our base class's logic. Instead of |
40 // always dispatching a key down event, and then sending a synthesized | 42 // always dispatching a key down event, and then sending a synthesized |
41 // character event, we instead check to see if this is a character event and | 43 // character event, we instead check to see if this is a character event and |
42 // send out the key if it is. (We fallback to normal dispatch if it isn't.) | 44 // send out the key if it is. (We fallback to normal dispatch if it isn't.) |
43 if (event.is_char()) { | 45 if (event->is_char()) { |
44 const uint16 ch = event.GetCharacter(); | 46 const uint16 ch = event->GetCharacter(); |
45 if (GetTextInputClient()) | 47 if (GetTextInputClient()) |
46 GetTextInputClient()->InsertChar(ch, event.flags()); | 48 GetTextInputClient()->InsertChar(ch, event->flags()); |
47 | 49 return; |
48 return false; | |
49 } | 50 } |
50 | 51 |
51 return DispatchKeyEventPostIME(event); | 52 ignore_result(DispatchKeyEventPostIME(event)); |
52 } | 53 } |
53 | 54 |
54 void InputMethodMandoline::OnCaretBoundsChanged( | 55 void InputMethodMandoline::OnCaretBoundsChanged( |
55 const ui::TextInputClient* client) { | 56 const ui::TextInputClient* client) { |
56 } | 57 } |
57 | 58 |
58 void InputMethodMandoline::CancelComposition( | 59 void InputMethodMandoline::CancelComposition( |
59 const ui::TextInputClient* client) { | 60 const ui::TextInputClient* client) { |
60 } | 61 } |
61 | 62 |
62 void InputMethodMandoline::OnInputLocaleChanged() { | 63 void InputMethodMandoline::OnInputLocaleChanged() { |
63 } | 64 } |
64 | 65 |
65 std::string InputMethodMandoline::GetInputLocale() { | 66 std::string InputMethodMandoline::GetInputLocale() { |
66 return ""; | 67 return ""; |
67 } | 68 } |
68 | 69 |
69 bool InputMethodMandoline::IsCandidatePopupOpen() const { | 70 bool InputMethodMandoline::IsCandidatePopupOpen() const { |
70 return false; | 71 return false; |
71 } | 72 } |
72 | 73 |
73 } // namespace mandoline | 74 } // namespace mandoline |
OLD | NEW |