Index: mojo/services/native_viewport/platform_viewport_x11.cc |
diff --git a/mojo/services/native_viewport/platform_viewport_x11.cc b/mojo/services/native_viewport/platform_viewport_x11.cc |
index 6654cf59b2d43fec2731a9ca02a8ca03b7267e86..dbf7fb80d8718faecbefad341111aa6ccff66fc1 100644 |
--- a/mojo/services/native_viewport/platform_viewport_x11.cc |
+++ b/mojo/services/native_viewport/platform_viewport_x11.cc |
@@ -6,6 +6,7 @@ |
#include "base/command_line.h" |
#include "base/message_loop/message_loop.h" |
+#include "mojo/services/public/cpp/input_events/lib/mojo_extended_key_event_data.h" |
#include "ui/events/event.h" |
#include "ui/events/event_utils.h" |
#include "ui/events/platform/platform_event_dispatcher.h" |
@@ -79,6 +80,37 @@ class PlatformViewportX11 : public PlatformViewport, |
virtual void DispatchEvent(ui::Event* event) OVERRIDE { |
delegate_->OnEvent(event); |
+ |
+ // We want to emulate the WM_CHAR generation behaviour of Windows. |
+ // |
+ // On Linux, we've previously inserted characters by having |
+ // InputMethodAuraLinux take all key down events and send a character event |
+ // to the TextInputClient. This causes a mismatch in code that has to be |
+ // shared between Windows and Linux, including blink code. Now that we're |
+ // trying to have one way of doing things, we need to standardize on and |
+ // emulate Windows character events. |
+ // |
+ // This is equivalent to what we're doing in the current Linux port, but |
+ // done once instead of done multiple times in different places. |
+ if (event->type() == ui::ET_KEY_PRESSED) { |
+ ui::KeyEvent* key_press_event = static_cast<ui::KeyEvent*>(event); |
+ ui::KeyEvent char_event(key_press_event->GetCharacter(), |
+ key_press_event->key_code(), |
+ key_press_event->flags()); |
+ |
+ DCHECK_EQ(key_press_event->GetCharacter(), char_event.GetCharacter()); |
+ DCHECK_EQ(key_press_event->key_code(), char_event.key_code()); |
+ DCHECK_EQ(key_press_event->flags(), char_event.flags()); |
+ |
+ char_event.SetExtendedKeyEventData(scoped_ptr<ui::ExtendedKeyEventData>( |
+ new MojoExtendedKeyEventData( |
+ ui::WindowsKeycodeFromNative(key_press_event->native_event()), |
+ ui::TextFromNative(key_press_event->native_event()), |
+ ui::UnmodifiedTextFromNative(key_press_event->native_event())))); |
+ char_event.set_platform_keycode(key_press_event->platform_keycode()); |
+ |
+ delegate_->OnEvent(&char_event); |
+ } |
} |
virtual void OnCloseRequest() OVERRIDE { |