diff options
Diffstat (limited to 'ui/base/ime/input_method_linux_x11.cc')
-rw-r--r-- | ui/base/ime/input_method_linux_x11.cc | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/ui/base/ime/input_method_linux_x11.cc b/ui/base/ime/input_method_linux_x11.cc index 08d9109..5d9b8c9 100644 --- a/ui/base/ime/input_method_linux_x11.cc +++ b/ui/base/ime/input_method_linux_x11.cc @@ -46,38 +46,31 @@ bool InputMethodLinuxX11::OnUntranslatedIMEMessage( } bool InputMethodLinuxX11::DispatchKeyEvent(const ui::KeyEvent& event) { + DCHECK(event.type() == ET_KEY_PRESSED || event.type() == ET_KEY_RELEASED); + DCHECK(system_toplevel_window_focused()); + if (!event.HasNativeEvent()) return DispatchFabricatedKeyEvent(event); - const base::NativeEvent& native_key_event = event.native_event(); - EventType event_type = EventTypeFromNative(native_key_event); - DCHECK(event_type == ET_KEY_PRESSED || event_type == ET_KEY_RELEASED); - DCHECK(system_toplevel_window_focused()); - // If no text input client, do nothing. + const base::NativeEvent& native_key_event = event.native_event(); if (!GetTextInputClient()) return DispatchKeyEventPostIME(native_key_event); // Let an IME handle the key event first. if (input_method_context_->DispatchKeyEvent(native_key_event)) { - if (event_type == ET_KEY_PRESSED) + if (event.type() == ET_KEY_PRESSED) DispatchFabricatedKeyEventPostIME(ET_KEY_PRESSED, VKEY_PROCESSKEY, - EventFlagsFromNative(native_key_event)); + event.flags()); return true; } // Otherwise, insert the character. const bool handled = DispatchKeyEventPostIME(native_key_event); - if (event_type == ET_KEY_PRESSED && GetTextInputClient()) { - uint16 ch = 0; - const int flags = EventFlagsFromNative(native_key_event); - if (!(flags & EF_CONTROL_DOWN)) - ch = GetCharacterFromXEvent(native_key_event); - if (!ch) - ch = GetCharacterFromKeyCode(KeyboardCodeFromNative(native_key_event), - flags); + if (event.type() == ET_KEY_PRESSED && GetTextInputClient()) { + const uint16 ch = event.GetCharacter(); if (ch) { - GetTextInputClient()->InsertChar(ch, flags); + GetTextInputClient()->InsertChar(ch, event.flags()); return true; } } @@ -167,6 +160,8 @@ void InputMethodLinuxX11::OnDidChangeFocusedClient( InputMethodBase::OnDidChangeFocusedClient(focused_before, focused); } +// private + bool InputMethodLinuxX11::DispatchFabricatedKeyEvent( const ui::KeyEvent& event) { // Let a post IME handler handle the key event. |