OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_XKEYBOARD_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_XKEYBOARD_H_ |
6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_XKEYBOARD_H_ | 6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_XKEYBOARD_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 | 13 |
14 namespace chromeos { | 14 namespace chromeos { |
15 namespace input_method { | 15 namespace input_method { |
16 | 16 |
17 struct AutoRepeatRate { | 17 struct AutoRepeatRate { |
18 AutoRepeatRate() : initial_delay_in_ms(0), repeat_interval_in_ms(0) {} | 18 AutoRepeatRate() : initial_delay_in_ms(0), repeat_interval_in_ms(0) {} |
19 unsigned int initial_delay_in_ms; | 19 unsigned int initial_delay_in_ms; |
20 unsigned int repeat_interval_in_ms; | 20 unsigned int repeat_interval_in_ms; |
21 }; | 21 }; |
22 | 22 |
23 enum ModifierLockStatus { | 23 enum ModifierLockStatus { |
24 kDisableLock = 0, | 24 kDisableLock = 0, |
25 kEnableLock, | 25 kEnableLock, |
26 kDontChange, | 26 kDontChange, |
27 }; | 27 }; |
28 | 28 |
29 // TODO(yusukes): Remove this enum when crbug.com/115112 is implemented. | |
30 enum ModifierKey { | 29 enum ModifierKey { |
31 kSearchKey = 0, // Customizable. | 30 kSearchKey = 0, // Customizable. |
32 kControlKey, // Customizable. | 31 kControlKey, // Customizable. |
33 kAltKey, // Customizable. | 32 kAltKey, // Customizable. |
34 kVoidKey, | 33 kVoidKey, |
35 kCapsLockKey, | 34 kCapsLockKey, |
36 // IMPORTANT: You should update kCustomizableKeys[] in .cc file, if you | 35 // IMPORTANT: You should update kCustomizableKeys[] in .cc file, if you |
37 // add a customizable key. | 36 // add a customizable key. |
38 kNumModifierKeys, | 37 kNumModifierKeys, |
39 }; | 38 }; |
40 | 39 |
41 // TODO(yusukes): Remove this struct when crbug.com/115112 is implemented. | |
42 struct ModifierKeyPair { | |
43 ModifierKeyPair(ModifierKey in_original, ModifierKey in_replacement) | |
44 : original(in_original), replacement(in_replacement) {} | |
45 bool operator==(const ModifierKeyPair& rhs) const { | |
46 // For CheckMap() in chromeos_keyboard_unittest.cc. | |
47 return (rhs.original == original) && (rhs.replacement == replacement); | |
48 } | |
49 ModifierKey original; // Replace the key with | |
50 ModifierKey replacement; // this key. | |
51 }; | |
52 typedef std::vector<ModifierKeyPair> ModifierMap; | |
53 | |
54 class InputMethodUtil; | 40 class InputMethodUtil; |
55 | 41 |
56 class XKeyboard { | 42 class XKeyboard { |
57 public: | 43 public: |
58 virtual ~XKeyboard() {} | 44 virtual ~XKeyboard() {} |
59 | 45 |
60 // Sets the current keyboard layout to |layout_name|. This function does not | 46 // Sets the current keyboard layout to |layout_name|. This function does not |
61 // change the current mapping of the modifier keys. Returns true on success. | 47 // change the current mapping of the modifier keys. Returns true on success. |
62 virtual bool SetCurrentKeyboardLayoutByName( | 48 virtual bool SetCurrentKeyboardLayoutByName( |
63 const std::string& layout_name) = 0; | 49 const std::string& layout_name) = 0; |
64 | 50 |
65 // Remaps modifier keys. This function does not change the current keyboard | |
66 // layout. Returns true on success. For now, you can't remap Left Control and | |
67 // Left Alt keys to caps lock. | |
68 // TODO(yusukes): Remove this method when crbug.com/115112 is implemented. | |
69 virtual bool RemapModifierKeys(const ModifierMap& modifier_map) = 0; | |
70 | |
71 // Sets the current keyboard layout again. We have to call the function every | 51 // Sets the current keyboard layout again. We have to call the function every |
72 // time when "XI_HierarchyChanged" XInput2 event is sent to Chrome. See | 52 // time when "XI_HierarchyChanged" XInput2 event is sent to Chrome. See |
73 // xinput_hierarchy_changed_event_listener.h for details. | 53 // xinput_hierarchy_changed_event_listener.h for details. |
74 virtual bool ReapplyCurrentKeyboardLayout() = 0; | 54 virtual bool ReapplyCurrentKeyboardLayout() = 0; |
75 | 55 |
76 // Updates keyboard LEDs on all keyboards. | 56 // Updates keyboard LEDs on all keyboards. |
77 // XKB asymmetrically propagates keyboard modifier indicator state changes to | 57 // XKB asymmetrically propagates keyboard modifier indicator state changes to |
78 // slave keyboards. If the state change is initiated from a client to the | 58 // slave keyboards. If the state change is initiated from a client to the |
79 // "core/master keyboard", XKB changes global state and pushes an indication | 59 // "core/master keyboard", XKB changes global state and pushes an indication |
80 // change down to all keyboards. If the state change is initiated by one slave | 60 // change down to all keyboards. If the state change is initiated by one slave |
(...skipping 24 matching lines...) Expand all Loading... |
105 // threads. | 85 // threads. |
106 virtual bool CapsLockIsEnabled() = 0; | 86 virtual bool CapsLockIsEnabled() = 0; |
107 | 87 |
108 // Creates a full XKB layout name like | 88 // Creates a full XKB layout name like |
109 // "gb(extd)+chromeos(leftcontrol_disabled_leftalt),us" | 89 // "gb(extd)+chromeos(leftcontrol_disabled_leftalt),us" |
110 // from modifier key mapping and |layout_name|, such as "us", "us(dvorak)", | 90 // from modifier key mapping and |layout_name|, such as "us", "us(dvorak)", |
111 // and "gb(extd)". Returns an empty string on error. Do not call this function | 91 // and "gb(extd)". Returns an empty string on error. Do not call this function |
112 // directly: it is public for testability. | 92 // directly: it is public for testability. |
113 // TODO(yusukes): Remove this method from the interface class. | 93 // TODO(yusukes): Remove this method from the interface class. |
114 virtual std::string CreateFullXkbLayoutName( | 94 virtual std::string CreateFullXkbLayoutName( |
115 const std::string& layout_name, | 95 const std::string& layout_name) = 0; |
116 const ModifierMap& modifire_map) = 0; | |
117 | 96 |
118 // Returns a mask (e.g. 1U<<4) for Num Lock. On error, returns 0. Do not call | 97 // Returns a mask (e.g. 1U<<4) for Num Lock. On error, returns 0. Do not call |
119 // the function from non-UI threads. | 98 // the function from non-UI threads. |
120 // TODO(yusukes): Move this and webdriver::GetXModifierMask() functions in | 99 // TODO(yusukes): Move this and webdriver::GetXModifierMask() functions in |
121 // chrome/test/webdriver/keycode_text_conversion_x.cc to ui/base/x/x11_util. | 100 // chrome/test/webdriver/keycode_text_conversion_x.cc to ui/base/x/x11_util. |
122 // The two functions are almost the same. | 101 // The two functions are almost the same. |
123 virtual unsigned int GetNumLockMask() = 0; | 102 virtual unsigned int GetNumLockMask() = 0; |
124 | 103 |
125 // Set true on |out_caps_lock_enabled| if Caps Lock is enabled. Set true on | 104 // Set true on |out_caps_lock_enabled| if Caps Lock is enabled. Set true on |
126 // |out_num_lock_enabled| if Num Lock is enabled. Both out parameters can be | 105 // |out_num_lock_enabled| if Num Lock is enabled. Both out parameters can be |
(...skipping 13 matching lines...) Expand all Loading... |
140 static bool SetAutoRepeatRate(const AutoRepeatRate& rate); | 119 static bool SetAutoRepeatRate(const AutoRepeatRate& rate); |
141 | 120 |
142 // Returns true if auto repeat is enabled. This function is protected: for | 121 // Returns true if auto repeat is enabled. This function is protected: for |
143 // testability. | 122 // testability. |
144 static bool GetAutoRepeatEnabledForTesting(); | 123 static bool GetAutoRepeatEnabledForTesting(); |
145 | 124 |
146 // On success, set current auto repeat rate on |out_rate| and returns true. | 125 // On success, set current auto repeat rate on |out_rate| and returns true. |
147 // Returns false otherwise. This function is protected: for testability. | 126 // Returns false otherwise. This function is protected: for testability. |
148 static bool GetAutoRepeatRateForTesting(AutoRepeatRate* out_rate); | 127 static bool GetAutoRepeatRateForTesting(AutoRepeatRate* out_rate); |
149 | 128 |
150 // Returns true if |key| is in |modifier_map| as replacement. Do not call this | |
151 // function directly: it is public for testability. | |
152 static bool ContainsModifierKeyAsReplacement(const ModifierMap& modifier_map, | |
153 ModifierKey key); | |
154 | |
155 // Note: At this moment, classes other than InputMethodManager should not | 129 // Note: At this moment, classes other than InputMethodManager should not |
156 // instantiate the XKeyboard class. | 130 // instantiate the XKeyboard class. |
157 static XKeyboard* Create(const InputMethodUtil& util); | 131 static XKeyboard* Create(const InputMethodUtil& util); |
158 }; | 132 }; |
159 | 133 |
160 } // namespace input_method | 134 } // namespace input_method |
161 } // namespace chromeos | 135 } // namespace chromeos |
162 | 136 |
163 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_XKEYBOARD_H_ | 137 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_XKEYBOARD_H_ |
OLD | NEW |