OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/events/event_rewriter.h" | 5 #include "chrome/browser/chromeos/events/event_rewriter.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/sticky_keys/sticky_keys_controller.h" | 9 #include "ash/sticky_keys/sticky_keys_controller.h" |
10 #include "ash/wm/window_state.h" | 10 #include "ash/wm/window_state.h" |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
205 XEvent* xev = key_event.native_event(); | 205 XEvent* xev = key_event.native_event(); |
206 if (xev) { | 206 if (xev) { |
207 XEvent xkeyevent; | 207 XEvent xkeyevent; |
208 // Convert all XI2-based key events into X11 core-based key events, | 208 // Convert all XI2-based key events into X11 core-based key events, |
209 // until consumers no longer depend on receiving X11 core events. | 209 // until consumers no longer depend on receiving X11 core events. |
210 if (xev->type == GenericEvent) | 210 if (xev->type == GenericEvent) |
211 ui::InitXKeyEventFromXIDeviceEvent(*xev, &xkeyevent); | 211 ui::InitXKeyEventFromXIDeviceEvent(*xev, &xkeyevent); |
212 else | 212 else |
213 xkeyevent.xkey = xev->xkey; | 213 xkeyevent.xkey = xev->xkey; |
214 | 214 |
215 // Update native event to match rewritten |ui::Event|. | 215 // The X11 keycode for numpad keys should always NOT be changed because |
Yusuke Sato
2014/08/08 01:04:09
Would you mind adding tests for this? (numpad, num
Shu Chen
2014/08/08 05:44:09
Actually there are test failure for this change. I
| |
216 // The X11 keycode represents a physical key position, so it shouldn't | 216 // XKeyCodeForWindowsKeyCode method cannot handle non-US keyboard layout. |
217 // change unless we have actually changed keys, not just modifiers. | 217 // The original X11 keycode should be correct to get the correct keysym. |
Yusuke Sato
2014/08/08 01:04:09
This works because ui:: keycode is for accelerator
Shu Chen
2014/08/08 05:44:09
With new solution, no need to add such comments.
| |
218 // This is one guard against problems like crbug.com/390263. | 218 // For SHIFT+NumpadKey cases, use the US keyboard layout. |
219 if (key_event.key_code() != key_code) { | 219 // Please see crbug.com/335644. |
220 if (key_code >= ui::VKEY_NUMPAD0 && key_code <= ui::VKEY_DIVIDE) { | |
221 if (flags & ui::EF_SHIFT_DOWN) { | |
222 flags &= ~ui::EF_SHIFT_DOWN; | |
223 xkeyevent.xkey.keycode = | |
224 XKeyCodeForWindowsKeyCode(key_code, flags, gfx::GetXDisplay()); | |
225 } | |
226 } else if (key_event.key_code() != key_code) { | |
227 // Update native event to match rewritten |ui::Event|. | |
228 // The X11 keycode represents a physical key position, so it shouldn't | |
229 // change unless we have actually changed keys, not just modifiers. | |
230 // This is one guard against problems like crbug.com/390263. | |
220 xkeyevent.xkey.keycode = | 231 xkeyevent.xkey.keycode = |
221 XKeyCodeForWindowsKeyCode(key_code, flags, gfx::GetXDisplay()); | 232 XKeyCodeForWindowsKeyCode(key_code, flags, gfx::GetXDisplay()); |
222 } | 233 } |
223 ui::KeyEvent x11_key_event(&xkeyevent); | 234 ui::KeyEvent x11_key_event(&xkeyevent); |
224 rewritten_key_event = new ui::KeyEvent(x11_key_event); | 235 rewritten_key_event = new ui::KeyEvent(x11_key_event); |
225 } | 236 } |
226 #endif | 237 #endif |
227 if (!rewritten_key_event) | 238 if (!rewritten_key_event) |
228 rewritten_key_event = new ui::KeyEvent(key_event); | 239 rewritten_key_event = new ui::KeyEvent(key_event); |
229 rewritten_key_event->set_flags(flags); | 240 rewritten_key_event->set_flags(flags); |
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
840 KeyboardDeviceAddedInternal(device_info[i].deviceid, device_info[i].name); | 851 KeyboardDeviceAddedInternal(device_info[i].deviceid, device_info[i].name); |
841 } | 852 } |
842 | 853 |
843 XIFreeDeviceInfo(device_info); | 854 XIFreeDeviceInfo(device_info); |
844 #else | 855 #else |
845 KeyboardDeviceAddedInternal(device_id, "keyboard"); | 856 KeyboardDeviceAddedInternal(device_id, "keyboard"); |
846 #endif | 857 #endif |
847 } | 858 } |
848 | 859 |
849 } // namespace chromeos | 860 } // namespace chromeos |
OLD | NEW |