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_UI_ASH_EVENT_REWRITER_H_ | 5 #ifndef CHROME_BROWSER_UI_ASH_EVENT_REWRITER_H_ |
6 #define CHROME_BROWSER_UI_ASH_EVENT_REWRITER_H_ | 6 #define CHROME_BROWSER_UI_ASH_EVENT_REWRITER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 virtual void DeviceRemoved(int device_id) OVERRIDE; | 88 virtual void DeviceRemoved(int device_id) OVERRIDE; |
89 virtual void DeviceKeyPressedOrReleased(int device_id) OVERRIDE; | 89 virtual void DeviceKeyPressedOrReleased(int device_id) OVERRIDE; |
90 | 90 |
91 // Updates |*_xkeycode_| in response to a keyboard map change. | 91 // Updates |*_xkeycode_| in response to a keyboard map change. |
92 void RefreshKeycodes(); | 92 void RefreshKeycodes(); |
93 // Converts an X key symbol like XK_Control_L to a key code. | 93 // Converts an X key symbol like XK_Control_L to a key code. |
94 unsigned char NativeKeySymToNativeKeycode(unsigned long keysym); | 94 unsigned char NativeKeySymToNativeKeycode(unsigned long keysym); |
95 #endif | 95 #endif |
96 | 96 |
97 // Rewrites the |event| by applying all RewriteXXX functions as needed. | 97 // Rewrites the |event| by applying all RewriteXXX functions as needed. |
98 void Rewrite(ui::KeyEvent* event); | 98 // Returns whether the event should be rewritten or dropped. |
99 ash::EventRewriterDelegate::Action Rewrite(ui::KeyEvent* event); | |
99 | 100 |
100 // Rewrites a modifier key press/release following the current user | 101 // Rewrites a modifier key press/release following the current user |
101 // preferences. | 102 // preferences. |
102 bool RewriteModifiers(ui::KeyEvent* event); | 103 bool RewriteModifiers(ui::KeyEvent* event); |
103 | 104 |
104 // Rewrites Fn key press/release to Control. In some cases, Fn key is not | 105 // Rewrites Fn key press/release to Control. In some cases, Fn key is not |
105 // intercepted by the EC, but generates a key event like "XK_F15 + Mod3Mask" | 106 // intercepted by the EC, but generates a key event like "XK_F15 + Mod3Mask" |
106 // as shown in crosbug.com/p/14339. | 107 // as shown in crosbug.com/p/14339. |
107 bool RewriteFnKey(ui::KeyEvent* event); | 108 bool RewriteFnKey(ui::KeyEvent* event); |
108 | 109 |
109 // Rewrites a NumPad key press/release without Num Lock to a corresponding key | 110 // Rewrites a NumPad key press/release without Num Lock to a corresponding key |
110 // press/release with the lock. Returns true when |event| is rewritten. | 111 // press/release with the lock. Returns true when |event| is rewritten. |
111 bool RewriteNumPadKeys(ui::KeyEvent* event); | 112 bool RewriteNumPadKeys(ui::KeyEvent* event); |
112 | 113 |
113 // Rewrites Backspace and Arrow keys following the Chrome OS keyboard spec. | 114 // Rewrites Backspace and Arrow keys following the Chrome OS keyboard spec. |
114 // * Alt+Backspace -> Delete | 115 // * Alt+Backspace -> Delete |
115 // * Alt+Up -> Prior (aka PageUp) | 116 // * Alt+Up -> Prior (aka PageUp) |
116 // * Alt+Down -> Next (aka PageDown) | 117 // * Alt+Down -> Next (aka PageDown) |
117 // * Ctrl+Alt+Up -> Home | 118 // * Ctrl+Alt+Up -> Home |
118 // * Ctrl+Alt+Down -> End | 119 // * Ctrl+Alt+Down -> End |
120 // When the Search key acts as a function key, it instead maps: | |
121 // * Search+Backspace -> Delete | |
122 // * Search+Up -> Prior (aka PageUp) | |
123 // * Search+Down -> Next (aka PageDown) | |
124 // * Search+Left -> Home | |
125 // * Search+right -> End | |
126 // Returns true whn the |event| is rewritten. | |
Yusuke Sato
2012/11/26 06:09:38
nit: when
danakj
2012/11/26 19:36:26
Done.
| |
119 bool RewriteBackspaceAndArrowKeys(ui::KeyEvent* event); | 127 bool RewriteBackspaceAndArrowKeys(ui::KeyEvent* event); |
120 | 128 |
129 #if defined(OS_CHROMEOS) | |
130 // When the Search key acts as a function key, it drops Search key presses, | |
131 // and drops the release as well if any key is pressed while Search was down. | |
132 bool DropSearchKey(ui::KeyEvent* event); | |
133 #endif | |
134 | |
121 // Rewrites the located |event|. | 135 // Rewrites the located |event|. |
122 void RewriteLocatedEvent(ui::LocatedEvent* event); | 136 void RewriteLocatedEvent(ui::LocatedEvent* event); |
123 | 137 |
124 // Overwrites |event| with the keycodes and flags. | 138 // Overwrites |event| with the keycodes and flags. |
125 void OverwriteEvent(ui::KeyEvent* event, | 139 void OverwriteEvent(ui::KeyEvent* event, |
126 unsigned int new_native_keycode, | 140 unsigned int new_native_keycode, |
127 unsigned int new_native_state, | 141 unsigned int new_native_state, |
128 ui::KeyboardCode new_keycode, | 142 ui::KeyboardCode new_keycode, |
129 int new_flags); | 143 int new_flags); |
130 | 144 |
131 // Checks the type of the |device_name|, and inserts a new entry to | 145 // Checks the type of the |device_name|, and inserts a new entry to |
132 // |device_id_to_type_|. | 146 // |device_id_to_type_|. |
133 DeviceType DeviceAddedInternal(int device_id, const std::string& device_name); | 147 DeviceType DeviceAddedInternal(int device_id, const std::string& device_name); |
134 | 148 |
135 // Returns true if |last_device_id_| is Apple's. | 149 // Returns true if |last_device_id_| is Apple's. |
136 bool IsAppleKeyboard() const; | 150 bool IsAppleKeyboard() const; |
137 | 151 |
138 // Remaps |original_flags| to |remapped_flags| and |original_native_modifiers| | 152 // Remaps |original_flags| to |remapped_flags| and |original_native_modifiers| |
139 // to |remapped_native_modifiers| following the current user prefs. | 153 // to |remapped_native_modifiers| following the current user prefs. |
140 void GetRemappedModifierMasks(int original_flags, | 154 void GetRemappedModifierMasks(int original_flags, |
141 unsigned int original_native_modifiers, | 155 unsigned int original_native_modifiers, |
142 int* remapped_flags, | 156 int* remapped_flags, |
143 unsigned int* remapped_native_modifiers) const; | 157 unsigned int* remapped_native_modifiers) const; |
144 | 158 |
145 std::map<int, DeviceType> device_id_to_type_; | 159 std::map<int, DeviceType> device_id_to_type_; |
146 int last_device_id_; | 160 int last_device_id_; |
147 | 161 |
148 #if defined(OS_CHROMEOS) | 162 #if defined(OS_CHROMEOS) |
163 bool drop_search_key_release_; | |
Yusuke Sato
2012/11/26 06:09:38
nit: you might want to remove line 164-166.
danakj
2012/11/26 19:36:26
Done.
| |
164 #endif | |
165 | |
166 #if defined(OS_CHROMEOS) | |
149 // X keycodes corresponding to various keysyms. | 167 // X keycodes corresponding to various keysyms. |
150 unsigned int control_l_xkeycode_; | 168 unsigned int control_l_xkeycode_; |
151 unsigned int control_r_xkeycode_; | 169 unsigned int control_r_xkeycode_; |
152 unsigned int alt_l_xkeycode_; | 170 unsigned int alt_l_xkeycode_; |
153 unsigned int alt_r_xkeycode_; | 171 unsigned int alt_r_xkeycode_; |
154 unsigned int meta_l_xkeycode_; | 172 unsigned int meta_l_xkeycode_; |
155 unsigned int meta_r_xkeycode_; | 173 unsigned int meta_r_xkeycode_; |
156 unsigned int windows_l_xkeycode_; | 174 unsigned int windows_l_xkeycode_; |
157 unsigned int caps_lock_xkeycode_; | 175 unsigned int caps_lock_xkeycode_; |
158 unsigned int void_symbol_xkeycode_; | 176 unsigned int void_symbol_xkeycode_; |
159 unsigned int delete_xkeycode_; | 177 unsigned int delete_xkeycode_; |
160 unsigned int home_xkeycode_; | 178 unsigned int home_xkeycode_; |
161 unsigned int end_xkeycode_; | 179 unsigned int end_xkeycode_; |
162 unsigned int prior_xkeycode_; | 180 unsigned int prior_xkeycode_; |
163 unsigned int next_xkeycode_; | 181 unsigned int next_xkeycode_; |
164 unsigned int kp_0_xkeycode_; | 182 unsigned int kp_0_xkeycode_; |
165 unsigned int kp_1_xkeycode_; | 183 unsigned int kp_1_xkeycode_; |
166 unsigned int kp_2_xkeycode_; | 184 unsigned int kp_2_xkeycode_; |
167 unsigned int kp_3_xkeycode_; | 185 unsigned int kp_3_xkeycode_; |
168 unsigned int kp_4_xkeycode_; | 186 unsigned int kp_4_xkeycode_; |
169 unsigned int kp_5_xkeycode_; | 187 unsigned int kp_5_xkeycode_; |
170 unsigned int kp_6_xkeycode_; | 188 unsigned int kp_6_xkeycode_; |
171 unsigned int kp_7_xkeycode_; | 189 unsigned int kp_7_xkeycode_; |
172 unsigned int kp_8_xkeycode_; | 190 unsigned int kp_8_xkeycode_; |
173 unsigned int kp_9_xkeycode_; | 191 unsigned int kp_9_xkeycode_; |
174 unsigned int kp_decimal_xkeycode_; | 192 unsigned int kp_decimal_xkeycode_; |
193 unsigned int f1_xkeycode_; | |
Yusuke Sato
2012/11/26 06:09:38
Looks like this part is for the next CL.
danakj
2012/11/26 19:36:26
Done.
| |
194 unsigned int f2_xkeycode_; | |
195 unsigned int f3_xkeycode_; | |
196 unsigned int f4_xkeycode_; | |
197 unsigned int f5_xkeycode_; | |
198 unsigned int f6_xkeycode_; | |
199 unsigned int f7_xkeycode_; | |
200 unsigned int f8_xkeycode_; | |
201 unsigned int f9_xkeycode_; | |
202 unsigned int f10_xkeycode_; | |
203 unsigned int f11_xkeycode_; | |
204 unsigned int f12_xkeycode_; | |
175 | 205 |
176 chromeos::input_method::XKeyboard* xkeyboard_; // for testing. | 206 chromeos::input_method::XKeyboard* xkeyboard_; // for testing. |
177 #endif | 207 #endif |
178 | 208 |
179 const PrefService* pref_service_; // for testing. | 209 const PrefService* pref_service_; // for testing. |
180 | 210 |
181 DISALLOW_COPY_AND_ASSIGN(EventRewriter); | 211 DISALLOW_COPY_AND_ASSIGN(EventRewriter); |
182 }; | 212 }; |
183 | 213 |
184 #endif // CHROME_BROWSER_UI_ASH_EVENT_REWRITER_H_ | 214 #endif // CHROME_BROWSER_UI_ASH_EVENT_REWRITER_H_ |
OLD | NEW |