OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_linux_x11.h" | 5 #include "ui/base/ime/input_method_linux_x11.h" |
6 | 6 |
7 #include "ui/base/ime/linux/linux_input_method_context_factory.h" | 7 #include "ui/base/ime/linux/linux_input_method_context_factory.h" |
8 #include "ui/base/ime/text_input_client.h" | 8 #include "ui/base/ime/text_input_client.h" |
9 #include "ui/events/event.h" | 9 #include "ui/events/event.h" |
10 #include "ui/events/event_utils.h" | 10 #include "ui/events/event_utils.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 TEXT_INPUT_TYPE_TEXT); | 38 TEXT_INPUT_TYPE_TEXT); |
39 } | 39 } |
40 } | 40 } |
41 | 41 |
42 bool InputMethodLinuxX11::OnUntranslatedIMEMessage( | 42 bool InputMethodLinuxX11::OnUntranslatedIMEMessage( |
43 const base::NativeEvent& event, | 43 const base::NativeEvent& event, |
44 NativeEventResult* result) { | 44 NativeEventResult* result) { |
45 return false; | 45 return false; |
46 } | 46 } |
47 | 47 |
48 bool InputMethodLinuxX11::DispatchKeyEvent( | 48 bool InputMethodLinuxX11::DispatchKeyEvent(const ui::KeyEvent& event) { |
49 const base::NativeEvent& native_key_event) { | 49 if (!event.HasNativeEvent()) |
| 50 return DispatchFabricatedKeyEvent(event); |
| 51 |
| 52 const base::NativeEvent& native_key_event = event.native_event(); |
50 EventType event_type = EventTypeFromNative(native_key_event); | 53 EventType event_type = EventTypeFromNative(native_key_event); |
51 DCHECK(event_type == ET_KEY_PRESSED || event_type == ET_KEY_RELEASED); | 54 DCHECK(event_type == ET_KEY_PRESSED || event_type == ET_KEY_RELEASED); |
52 DCHECK(system_toplevel_window_focused()); | 55 DCHECK(system_toplevel_window_focused()); |
53 | 56 |
54 // If no text input client, do nothing. | 57 // If no text input client, do nothing. |
55 if (!GetTextInputClient()) | 58 if (!GetTextInputClient()) |
56 return DispatchKeyEventPostIME(native_key_event); | 59 return DispatchKeyEventPostIME(native_key_event); |
57 | 60 |
58 // Let an IME handle the key event first. | 61 // Let an IME handle the key event first. |
59 if (input_method_context_->DispatchKeyEvent(native_key_event)) { | 62 if (input_method_context_->DispatchKeyEvent(native_key_event)) { |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 TextInputClient* focused_before, | 180 TextInputClient* focused_before, |
178 TextInputClient* focused) { | 181 TextInputClient* focused) { |
179 input_method_context_->Reset(); | 182 input_method_context_->Reset(); |
180 input_method_context_->OnTextInputTypeChanged( | 183 input_method_context_->OnTextInputTypeChanged( |
181 focused ? focused->GetTextInputType() : TEXT_INPUT_TYPE_NONE); | 184 focused ? focused->GetTextInputType() : TEXT_INPUT_TYPE_NONE); |
182 | 185 |
183 InputMethodBase::OnDidChangeFocusedClient(focused_before, focused); | 186 InputMethodBase::OnDidChangeFocusedClient(focused_before, focused); |
184 } | 187 } |
185 | 188 |
186 } // namespace ui | 189 } // namespace ui |
OLD | NEW |