| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 void MockInputMethod::SetFocusedTextInputClient(TextInputClient* client) { | 51 void MockInputMethod::SetFocusedTextInputClient(TextInputClient* client) { |
| 52 text_input_client_ = client; | 52 text_input_client_ = client; |
| 53 } | 53 } |
| 54 | 54 |
| 55 TextInputClient* MockInputMethod::GetTextInputClient() const { | 55 TextInputClient* MockInputMethod::GetTextInputClient() const { |
| 56 return text_input_client_; | 56 return text_input_client_; |
| 57 } | 57 } |
| 58 | 58 |
| 59 void MockInputMethod::DispatchKeyEvent(const base::NativeEvent& native_event) { | 59 void MockInputMethod::DispatchKeyEvent(const base::NativeEvent& native_event) { |
| 60 #if defined(USE_X11) | 60 #if defined(USE_X11) |
| 61 DCHECK(native_event); |
| 61 if (native_event->type == KeyRelease) { | 62 if (native_event->type == KeyRelease) { |
| 62 // On key release, just dispatch it. | 63 // On key release, just dispatch it. |
| 63 delegate_->DispatchKeyEventPostIME(native_event); | 64 delegate_->DispatchKeyEventPostIME(native_event); |
| 64 } else { | 65 } else { |
| 65 const uint32 state = | 66 const uint32 state = |
| 66 EventFlagsFromXFlags(reinterpret_cast<XKeyEvent*>(native_event)->state); | 67 EventFlagsFromXFlags(reinterpret_cast<XKeyEvent*>(native_event)->state); |
| 67 if (consume_next_key_) { | 68 if (consume_next_key_) { |
| 68 // Send the VKEY_PROCESSKEY RawKeyDown event. | 69 // Send the VKEY_PROCESSKEY RawKeyDown event. |
| 69 SendFakeProcessKeyEvent(true, state); | 70 SendFakeProcessKeyEvent(true, state); |
| 70 } else { | 71 } else { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 void MockInputMethod::ConsumeNextKey() { | 115 void MockInputMethod::ConsumeNextKey() { |
| 115 consume_next_key_ = true; | 116 consume_next_key_ = true; |
| 116 } | 117 } |
| 117 | 118 |
| 118 void MockInputMethod::SendFakeProcessKeyEvent(bool pressed, int flags) const { | 119 void MockInputMethod::SendFakeProcessKeyEvent(bool pressed, int flags) const { |
| 119 delegate_->DispatchFabricatedKeyEventPostIME( | 120 delegate_->DispatchFabricatedKeyEventPostIME( |
| 120 pressed ? ET_KEY_PRESSED : ET_KEY_RELEASED, VKEY_PROCESSKEY, flags); | 121 pressed ? ET_KEY_PRESSED : ET_KEY_RELEASED, VKEY_PROCESSKEY, flags); |
| 121 } | 122 } |
| 122 | 123 |
| 123 } // namespace ui | 124 } // namespace ui |
| OLD | NEW |