Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Unified Diff: ui/base/ime/fake_input_method.cc

Issue 17265006: wayland patch for inspection Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/events/event.cc ('k') | ui/base/keycodes/keyboard_code_conversion_wayland.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/ime/fake_input_method.cc
diff --git a/ui/base/ime/fake_input_method.cc b/ui/base/ime/fake_input_method.cc
index 26998e67d4b95714a2aa1a47d0f69e5e57d45988..ecca88cedbbb1b254f1d55a18021a749591d0c0b 100644
--- a/ui/base/ime/fake_input_method.cc
+++ b/ui/base/ime/fake_input_method.cc
@@ -14,7 +14,9 @@
#include "ui/base/ime/text_input_client.h"
#include "ui/base/keycodes/keyboard_code_conversion.h"
-#if defined(USE_X11)
+#if defined(USE_WAYLAND)
+#include "ui/base/keycodes/keyboard_code_conversion_wayland.h"
+#elif defined(USE_X11)
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
@@ -23,7 +25,8 @@
namespace {
-#if defined(USE_X11)
+#if defined(USE_WAYLAND)
+#elif defined(USE_X11)
uint32 EventFlagsFromXFlags(unsigned int flags) {
return (flags & LockMask ? ui::EF_CAPS_LOCK_DOWN : 0U) |
(flags & ControlMask ? ui::EF_CONTROL_DOWN : 0U) |
@@ -71,6 +74,27 @@ bool FakeInputMethod::DispatchKeyEvent(const base::NativeEvent& native_event) {
} else {
handled = delegate_->DispatchKeyEventPostIME(native_event);
}
+#elif defined(USE_WAYLAND)
+ DCHECK(native_event);
+ if (EventTypeFromNative(native_event) == ET_KEY_RELEASED) {
+ // On key release, just dispatch it.
+ delegate_->DispatchKeyEventPostIME(native_event);
+ } else {
+ const uint32 state = EventFlagsFromNative(native_event);
+ // Send a RawKeyDown event first,
+ delegate_->DispatchKeyEventPostIME(native_event);
+ if (text_input_client_) {
+ // then send a Char event via ui::TextInputClient.
+ const KeyboardCode key_code = ui::KeyboardCodeFromNative(native_event);
+ uint16 ch = 0;
+ if (!(state & ui::EF_CONTROL_DOWN))
+ ch = ui::GetCharacterFromWaylandEvent(native_event);
+ if (!ch)
+ ch = ui::GetCharacterFromKeyCode(key_code, state);
+ if (ch)
+ text_input_client_->InsertChar(ch, state);
+ }
+ }
#elif defined(USE_X11)
DCHECK(native_event);
if (native_event->type == KeyRelease) {
« no previous file with comments | « ui/base/events/event.cc ('k') | ui/base/keycodes/keyboard_code_conversion_wayland.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698