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

Unified Diff: ui/events/x/events_x.cc

Issue 548303003: Revert of Removing X11 native_event uses for key events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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/events/win/events_win.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/x/events_x.cc
diff --git a/ui/events/x/events_x.cc b/ui/events/x/events_x.cc
index 371c8f58688fc5ad4ab1cab5d37b9a0910785351..b3fc9bb0386798eebcee742136f21cb45ddba8b9 100644
--- a/ui/events/x/events_x.cc
+++ b/ui/events/x/events_x.cc
@@ -685,6 +685,54 @@
return false;
}
+uint32 WindowsKeycodeFromNative(const base::NativeEvent& native_event) {
+ int windows_key_code = ui::KeyboardCodeFromXKeyEvent(native_event);
+ if (windows_key_code == ui::VKEY_SHIFT ||
+ windows_key_code == ui::VKEY_CONTROL ||
+ windows_key_code == ui::VKEY_MENU) {
+ // To support DOM3 'location' attribute, we need to lookup an X KeySym and
+ // set ui::VKEY_[LR]XXX instead of ui::VKEY_XXX.
+ KeySym keysym = XK_VoidSymbol;
+ XLookupString(&native_event->xkey, NULL, 0, &keysym, NULL);
+ switch (keysym) {
+ case XK_Shift_L:
+ return ui::VKEY_LSHIFT;
+ case XK_Shift_R:
+ return ui::VKEY_RSHIFT;
+ case XK_Control_L:
+ return ui::VKEY_LCONTROL;
+ case XK_Control_R:
+ return ui::VKEY_RCONTROL;
+ case XK_Meta_L:
+ case XK_Alt_L:
+ return ui::VKEY_LMENU;
+ case XK_Meta_R:
+ case XK_Alt_R:
+ return ui::VKEY_RMENU;
+ }
+ }
+ return windows_key_code;
+}
+
+uint16 TextFromNative(const base::NativeEvent& native_event) {
+ int flags = EventFlagsFromNative(native_event);
+ if ((flags & ui::EF_CONTROL_DOWN) != 0) {
+ int windows_key_code = WindowsKeycodeFromNative(native_event);
+ return ui::GetControlCharacterForKeycode(windows_key_code,
+ flags & ui::EF_SHIFT_DOWN);
+ }
+
+ return UnmodifiedTextFromNative(native_event);
+}
+
+uint16 UnmodifiedTextFromNative(const base::NativeEvent& native_event) {
+ uint32 keycode = WindowsKeycodeFromNative(native_event);
+ if (keycode == ui::VKEY_RETURN)
+ return '\r';
+ else
+ return ui::GetCharacterFromXEvent(native_event);
+}
+
int GetChangedMouseButtonFlagsFromNative(
const base::NativeEvent& native_event) {
switch (native_event->type) {
« no previous file with comments | « ui/events/win/events_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698