| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/mock_input_method.h" | 5 #include "ui/base/ime/mock_input_method.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/string16.h" | 8 #include "base/string16.h" |
| 9 #include "ui/base/events.h" | 9 #include "ui/base/events.h" |
| 10 #include "ui/base/glib/glib_integers.h" | 10 #include "ui/base/glib/glib_integers.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 EventFlagsFromXFlags(reinterpret_cast<XKeyEvent*>(native_event)->state); | 66 EventFlagsFromXFlags(reinterpret_cast<XKeyEvent*>(native_event)->state); |
| 67 if (consume_next_key_) { | 67 if (consume_next_key_) { |
| 68 // Send the VKEY_PROCESSKEY RawKeyDown event. | 68 // Send the VKEY_PROCESSKEY RawKeyDown event. |
| 69 SendFakeProcessKeyEvent(true, state); | 69 SendFakeProcessKeyEvent(true, state); |
| 70 } else { | 70 } else { |
| 71 // Send a RawKeyDown event first, | 71 // Send a RawKeyDown event first, |
| 72 delegate_->DispatchKeyEventPostIME(native_event); | 72 delegate_->DispatchKeyEventPostIME(native_event); |
| 73 if (text_input_client_) { | 73 if (text_input_client_) { |
| 74 // then send a Char event via ui::TextInputClient. | 74 // then send a Char event via ui::TextInputClient. |
| 75 const KeyboardCode key_code = ui::KeyboardCodeFromNative(native_event); | 75 const KeyboardCode key_code = ui::KeyboardCodeFromNative(native_event); |
| 76 uint16 ch = ui::DefaultSymbolFromXEvent(native_event); | 76 uint16 ch = ui::GetCharacterFromXEvent(native_event); |
| 77 if (!ch) | 77 if (!ch) |
| 78 ch = ui::GetCharacterFromKeyCode(key_code, state); | 78 ch = ui::GetCharacterFromKeyCode(key_code, state); |
| 79 if (ch) | 79 if (ch) |
| 80 text_input_client_->InsertChar(ch, state); | 80 text_input_client_->InsertChar(ch, state); |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 consume_next_key_ = false; | 84 consume_next_key_ = false; |
| 85 #else | 85 #else |
| 86 // TODO(yusukes): Support Windows. | 86 // TODO(yusukes): Support Windows. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 114 void MockInputMethod::ConsumeNextKey() { | 114 void MockInputMethod::ConsumeNextKey() { |
| 115 consume_next_key_ = true; | 115 consume_next_key_ = true; |
| 116 } | 116 } |
| 117 | 117 |
| 118 void MockInputMethod::SendFakeProcessKeyEvent(bool pressed, int flags) const { | 118 void MockInputMethod::SendFakeProcessKeyEvent(bool pressed, int flags) const { |
| 119 delegate_->DispatchFabricatedKeyEventPostIME( | 119 delegate_->DispatchFabricatedKeyEventPostIME( |
| 120 pressed ? ET_KEY_PRESSED : ET_KEY_RELEASED, VKEY_PROCESSKEY, flags); | 120 pressed ? ET_KEY_PRESSED : ET_KEY_RELEASED, VKEY_PROCESSKEY, flags); |
| 121 } | 121 } |
| 122 | 122 |
| 123 } // namespace ui | 123 } // namespace ui |
| OLD | NEW |