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