From e50dfd06b947adedc2c1e6a5d7746e49b43178f8 Mon Sep 17 00:00:00 2001 From: "yukishiino@chromium.org" Date: Sat, 16 Nov 2013 02:57:11 +0000 Subject: Clean up InputMethodLinuxX11 following crrev.com/48203002 http://crrev.com/48203002 makes it possible to make the implementation of InputMethodXxx family much simpler and cleaner. Cleans InputMethodLinuxX11 following the CL. TEST=none Review URL: https://codereview.chromium.org/61903004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@235504 0039d316-1c4b-4281-b951-d872f2087c98 --- ui/base/ime/input_method_linux_x11.cc | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'ui/base/ime/input_method_linux_x11.cc') 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. -- cgit v1.1