| 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 when the |event| is rewritten. |
| 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_; |
| 164 |
| 149 // X keycodes corresponding to various keysyms. | 165 // X keycodes corresponding to various keysyms. |
| 150 unsigned int control_l_xkeycode_; | 166 unsigned int control_l_xkeycode_; |
| 151 unsigned int control_r_xkeycode_; | 167 unsigned int control_r_xkeycode_; |
| 152 unsigned int alt_l_xkeycode_; | 168 unsigned int alt_l_xkeycode_; |
| 153 unsigned int alt_r_xkeycode_; | 169 unsigned int alt_r_xkeycode_; |
| 154 unsigned int meta_l_xkeycode_; | 170 unsigned int meta_l_xkeycode_; |
| 155 unsigned int meta_r_xkeycode_; | 171 unsigned int meta_r_xkeycode_; |
| 156 unsigned int windows_l_xkeycode_; | 172 unsigned int windows_l_xkeycode_; |
| 157 unsigned int caps_lock_xkeycode_; | 173 unsigned int caps_lock_xkeycode_; |
| 158 unsigned int void_symbol_xkeycode_; | 174 unsigned int void_symbol_xkeycode_; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 175 | 191 |
| 176 chromeos::input_method::XKeyboard* xkeyboard_; // for testing. | 192 chromeos::input_method::XKeyboard* xkeyboard_; // for testing. |
| 177 #endif | 193 #endif |
| 178 | 194 |
| 179 const PrefService* pref_service_; // for testing. | 195 const PrefService* pref_service_; // for testing. |
| 180 | 196 |
| 181 DISALLOW_COPY_AND_ASSIGN(EventRewriter); | 197 DISALLOW_COPY_AND_ASSIGN(EventRewriter); |
| 182 }; | 198 }; |
| 183 | 199 |
| 184 #endif // CHROME_BROWSER_UI_ASH_EVENT_REWRITER_H_ | 200 #endif // CHROME_BROWSER_UI_ASH_EVENT_REWRITER_H_ |
| OLD | NEW |