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 <X11/extensions/XInput2.h> | 7 #include <X11/extensions/XInput2.h> |
8 #include <X11/keysym.h> | 8 #include <X11/keysym.h> |
9 #include <X11/XF86keysym.h> | 9 #include <X11/XF86keysym.h> |
10 #include <X11/Xlib.h> | 10 #include <X11/Xlib.h> |
(...skipping 22 matching lines...) Expand all Loading... |
33 #include "ui/base/x/x11_util.h" | 33 #include "ui/base/x/x11_util.h" |
34 #include "ui/events/event.h" | 34 #include "ui/events/event.h" |
35 #include "ui/events/event_utils.h" | 35 #include "ui/events/event_utils.h" |
36 #include "ui/events/keycodes/keyboard_code_conversion_x.h" | 36 #include "ui/events/keycodes/keyboard_code_conversion_x.h" |
37 #include "ui/views/corewm/window_util.h" | 37 #include "ui/views/corewm/window_util.h" |
38 | 38 |
39 namespace { | 39 namespace { |
40 | 40 |
41 const int kBadDeviceId = -1; | 41 const int kBadDeviceId = -1; |
42 | 42 |
43 const char kNeo2LayoutId[] = "xkb:de:neo:ger"; | |
44 const char kCaMultixLayoutId[] = "xkb:ca:multix:fra"; | |
45 | |
46 // A key code and a flag we should use when a key is remapped to |remap_to|. | 43 // A key code and a flag we should use when a key is remapped to |remap_to|. |
47 const struct ModifierRemapping { | 44 const struct ModifierRemapping { |
48 int remap_to; | 45 int remap_to; |
49 int flag; | 46 int flag; |
50 unsigned int native_modifier; | 47 unsigned int native_modifier; |
51 ui::KeyboardCode keycode; | 48 ui::KeyboardCode keycode; |
52 KeySym native_keysyms[4]; // left, right, shift+left, shift+right. | 49 KeySym native_keysyms[4]; // left, right, shift+left, shift+right. |
53 } kModifierRemappings[] = { | 50 } kModifierRemappings[] = { |
54 { chromeos::input_method::kSearchKey, 0, Mod4Mask, ui::VKEY_LWIN, | 51 { chromeos::input_method::kSearchKey, 0, Mod4Mask, ui::VKEY_LWIN, |
55 { XK_Super_L, XK_Super_L, XK_Super_L, XK_Super_L }}, | 52 { XK_Super_L, XK_Super_L, XK_Super_L, XK_Super_L }}, |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 chromeos::switches::kHasChromeOSDiamondKey); | 116 chromeos::switches::kHasChromeOSDiamondKey); |
120 } | 117 } |
121 | 118 |
122 bool IsMod3UsedByCurrentInputMethod() { | 119 bool IsMod3UsedByCurrentInputMethod() { |
123 // Since both German Neo2 XKB layout and Caps Lock depend on Mod3Mask, | 120 // Since both German Neo2 XKB layout and Caps Lock depend on Mod3Mask, |
124 // it's not possible to make both features work. For now, we don't remap | 121 // it's not possible to make both features work. For now, we don't remap |
125 // Mod3Mask when Neo2 is in use. | 122 // Mod3Mask when Neo2 is in use. |
126 // TODO(yusukes): Remove the restriction. | 123 // TODO(yusukes): Remove the restriction. |
127 chromeos::input_method::InputMethodManager* manager = | 124 chromeos::input_method::InputMethodManager* manager = |
128 chromeos::input_method::InputMethodManager::Get(); | 125 chromeos::input_method::InputMethodManager::Get(); |
129 return manager->GetCurrentInputMethod().id() == kNeo2LayoutId || | 126 return manager->IsMod3UsedByCurrentInputMethod(); |
130 manager->GetCurrentInputMethod().id() == kCaMultixLayoutId; | |
131 } | 127 } |
132 | 128 |
133 } // namespace | 129 } // namespace |
134 | 130 |
135 namespace chromeos { | 131 namespace chromeos { |
136 | 132 |
137 EventRewriter::EventRewriter() | 133 EventRewriter::EventRewriter() |
138 : last_device_id_(kBadDeviceId), | 134 : last_device_id_(kBadDeviceId), |
139 xkeyboard_for_testing_(NULL), | 135 xkeyboard_for_testing_(NULL), |
140 keyboard_driven_event_rewriter_(new KeyboardDrivenEventRewriter), | 136 keyboard_driven_event_rewriter_(new KeyboardDrivenEventRewriter), |
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
897 VLOG(1) << "Apple keyboard '" << device_name << "' connected: " | 893 VLOG(1) << "Apple keyboard '" << device_name << "' connected: " |
898 << "id=" << device_id; | 894 << "id=" << device_id; |
899 } | 895 } |
900 // Always overwrite the existing device_id since the X server may reuse a | 896 // Always overwrite the existing device_id since the X server may reuse a |
901 // device id for an unattached device. | 897 // device id for an unattached device. |
902 device_id_to_type_[device_id] = type; | 898 device_id_to_type_[device_id] = type; |
903 return type; | 899 return type; |
904 } | 900 } |
905 | 901 |
906 } // namespace chromeos | 902 } // namespace chromeos |
OLD | NEW |