| 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 GetTextInputClient()->InsertChar(event.GetCharacter(), event.flags()); | 46 GetTextInputClient()->InsertChar(event->GetCharacter(), event->flags()); |
| 45 | 47 event->StopPropagation(); |
| 46 return false; | 48 return; |
| 47 } | 49 } |
| 48 | 50 |
| 49 return DispatchKeyEventPostIME(event); | 51 ignore_result(DispatchKeyEventPostIME(event)); |
| 50 } | 52 } |
| 51 | 53 |
| 52 void InputMethodMandoline::OnCaretBoundsChanged( | 54 void InputMethodMandoline::OnCaretBoundsChanged( |
| 53 const ui::TextInputClient* client) { | 55 const ui::TextInputClient* client) { |
| 54 } | 56 } |
| 55 | 57 |
| 56 void InputMethodMandoline::CancelComposition( | 58 void InputMethodMandoline::CancelComposition( |
| 57 const ui::TextInputClient* client) { | 59 const ui::TextInputClient* client) { |
| 58 } | 60 } |
| 59 | 61 |
| 60 void InputMethodMandoline::OnInputLocaleChanged() { | 62 void InputMethodMandoline::OnInputLocaleChanged() { |
| 61 } | 63 } |
| 62 | 64 |
| 63 std::string InputMethodMandoline::GetInputLocale() { | 65 std::string InputMethodMandoline::GetInputLocale() { |
| 64 return ""; | 66 return ""; |
| 65 } | 67 } |
| 66 | 68 |
| 67 bool InputMethodMandoline::IsCandidatePopupOpen() const { | 69 bool InputMethodMandoline::IsCandidatePopupOpen() const { |
| 68 return false; | 70 return false; |
| 69 } | 71 } |
| 70 | 72 |
| 71 } // namespace mandoline | 73 } // namespace mandoline |
| OLD | NEW |