Index: ui/events/ozone/evdev/keyboard_evdev.cc |
diff --git a/ui/events/ozone/evdev/keyboard_evdev.cc b/ui/events/ozone/evdev/keyboard_evdev.cc |
index 1def4c66a8bef5977b6066af3636e5516bfbb436..9f74d924af3888c42c47970d7436f81708cdb0fe 100644 |
--- a/ui/events/ozone/evdev/keyboard_evdev.cc |
+++ b/ui/events/ozone/evdev/keyboard_evdev.cc |
@@ -18,6 +18,15 @@ |
namespace ui { |
+// We can't include ui/events/keycodes/dom/dom_code.h here because of |
+// conflicts with preprocessor macros in <linux/input.h>, so we use the |
+// same underlying data with an additional prefix. |
+#define USB_KEYMAP(usb, xkb, win, mac, code, id) DOM_CODE_ ## id = usb |
+#define USB_KEYMAP_DECLARATION enum class DomCode |
+#include "ui/events/keycodes/dom/keycode_converter_data.inc" |
+#undef USB_KEYMAP |
+#undef USB_KEYMAP_DECLARATION |
+ |
namespace { |
const int kRepeatDelayMs = 500; |
@@ -35,6 +44,8 @@ int EventFlagToEvdevModifier(int flag) { |
return EVDEV_MODIFIER_ALT; |
case EF_ALTGR_DOWN: |
return EVDEV_MODIFIER_ALTGR; |
+ case EF_MOD3_DOWN: |
+ return EVDEV_MODIFIER_MOD3; |
case EF_LEFT_MOUSE_BUTTON: |
return EVDEV_MODIFIER_LEFT_MOUSE_BUTTON; |
case EF_MIDDLE_MOUSE_BUTTON: |
@@ -201,9 +212,7 @@ void KeyboardEvdev::DispatchKey(unsigned int key, |
int device_id) { |
DomCode dom_code = |
KeycodeConverter::NativeKeycodeToDomCode(EvdevCodeToNativeCode(key)); |
- // DomCode constants are not included here because of conflicts with |
- // evdev preprocessor macros. |
- if (!static_cast<int>(dom_code)) |
+ if (dom_code == DomCode::DOM_CODE_NONE) |
return; |
int flags = modifiers_->GetModifierFlags(); |
DomKey dom_key; |
@@ -214,8 +223,16 @@ void KeyboardEvdev::DispatchKey(unsigned int key, |
&key_code, &platform_keycode)) { |
return; |
} |
- if (!repeat) |
- UpdateModifier(ModifierDomKeyToEventFlag(dom_key), down); |
+ if (!repeat) { |
+ int flag = ModifierDomKeyToEventFlag(dom_key); |
+ UpdateModifier(flag, down); |
+ // X11 XKB, using the configuration as modified for ChromeOS, always sets |
+ // EF_MOD3_DOWN for the physical CapsLock key, even if the layout maps |
+ // it to something else, so we imitate this to make certain layouts (e.g. |
+ // German Neo2) work. crbug.com/495277 |
+ if (dom_code == DomCode::DOM_CODE_CAPS_LOCK) |
+ UpdateModifier(EF_MOD3_DOWN, down); |
spang
2015/06/08 22:43:09
Can you now remove the other hack for MOD3 in Upda
kpschoedel
2015/06/09 13:28:50
No, it's still required (in fact, the Neo layout i
|
+ } |
KeyEvent event(down ? ET_KEY_PRESSED : ET_KEY_RELEASED, key_code, dom_code, |
modifiers_->GetModifierFlags(), dom_key, character, timestamp); |
@@ -224,5 +241,4 @@ void KeyboardEvdev::DispatchKey(unsigned int key, |
event.set_platform_keycode(platform_keycode); |
callback_.Run(&event); |
} |
- |
} // namespace ui |