Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(288)

Unified Diff: chrome/browser/ui/ash/event_rewriter.h

Issue 11417144: Use rewriting to make ChromeOS keyboard F<number> keys produce extended keycodes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: forlanding3 Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/ash/chrome_shell_delegate.cc ('k') | chrome/browser/ui/ash/event_rewriter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/ash/event_rewriter.h
diff --git a/chrome/browser/ui/ash/event_rewriter.h b/chrome/browser/ui/ash/event_rewriter.h
index f35276df188009a5ecdf3480343aa082ec014695..2cb279c70ca5dd1ceeaa816c741d356cc4a73502 100644
--- a/chrome/browser/ui/ash/event_rewriter.h
+++ b/chrome/browser/ui/ash/event_rewriter.h
@@ -11,6 +11,7 @@
#include "ash/event_rewriter_delegate.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
+#include "base/hash_tables.h"
#include "ui/aura/root_window_observer.h"
#include "ui/base/keycodes/keyboard_codes.h"
@@ -42,6 +43,9 @@ class EventRewriter : public ash::EventRewriterDelegate,
enum DeviceType {
kDeviceUnknown = 0,
kDeviceAppleKeyboard,
+#if defined(OS_CHROMEOS)
+ kDeviceChromeOSKeyboard,
+#endif
};
EventRewriter();
@@ -66,6 +70,9 @@ class EventRewriter : public ash::EventRewriterDelegate,
void set_xkeyboard_for_testing(chromeos::input_method::XKeyboard* xkeyboard) {
xkeyboard_ = xkeyboard;
}
+ void set_force_chromeos_keyboard_for_testing(bool chromeos_keyboard) {
+ force_chromeos_keyboard_for_testing_ = chromeos_keyboard;
+ }
#endif
// Gets DeviceType from the |device_name|.
@@ -88,10 +95,55 @@ class EventRewriter : public ash::EventRewriterDelegate,
virtual void DeviceRemoved(int device_id) OVERRIDE;
virtual void DeviceKeyPressedOrReleased(int device_id) OVERRIDE;
+ bool EventSourceIsChromeOSKeyboard() const;
+
+ // We don't want to include Xlib.h here since it has polluting macros, so
+ // define these locally.
+ typedef unsigned long KeySym;
+ typedef unsigned char KeyCode;
+
// Updates |*_xkeycode_| in response to a keyboard map change.
void RefreshKeycodes();
// Converts an X key symbol like XK_Control_L to a key code.
- unsigned char NativeKeySymToNativeKeycode(unsigned long keysym);
+ unsigned char NativeKeySymToNativeKeycode(KeySym keysym);
+
+ struct KeyboardRemapping {
+ KeySym input_keysym;
+ unsigned int input_mods;
+ unsigned int input_native_mods;
+ KeySym output_keysym;
+ ui::KeyboardCode output_keycode;
+ };
+
+ // Given a set of KeyboardRemapping structs, it finds a matching struct
+ // if possible, and updates the remapped event values. Returns true if a
+ // remapping was found and remapped values were updated.
+ bool RewriteWithKeyboardRemappingsByKeySym(
+ const KeyboardRemapping* remappings,
+ size_t num_remappings,
+ KeySym keysym,
+ unsigned int native_mods,
+ unsigned int mods,
+ KeySym* remapped_native_keysym,
+ unsigned int* remapped_native_mods,
+ ui::KeyboardCode* remapped_keycode,
+ unsigned int* remapped_mods);
+
+ // Given a set of KeyboardRemapping structs, it finds a matching struct
+ // if possible, and updates the remapped event values. This function converts
+ // the KeySym in the KeyboardRemapping struct into the KeyCode before matching
+ // to allow any KeyCode on the same physical key as the given KeySym to match.
+ // Returns true if a remapping was found and remapped values were updated.
+ bool RewriteWithKeyboardRemappingsByKeyCode(
+ const KeyboardRemapping* remappings,
+ size_t num_remappings,
+ KeyCode keycode,
+ unsigned int native_mods,
+ unsigned int mods,
+ KeySym* remapped_native_keysym,
+ unsigned int* remapped_native_mods,
+ ui::KeyboardCode* remapped_keycode,
+ unsigned int* remapped_mods);
#endif
// Rewrites the |event| by applying all RewriteXXX functions as needed.
@@ -125,6 +177,11 @@ class EventRewriter : public ash::EventRewriterDelegate,
// Returns true when the |event| is rewritten.
bool RewriteBackspaceAndArrowKeys(ui::KeyEvent* event);
+ // When the Search key acts as a function key, it remaps Search+1
+ // through Search+= to F1 through F12. Returns true when the |event| is
+ // rewritten.
+ bool RewriteFunctionKeys(ui::KeyEvent* event);
+
// Rewrites the located |event|.
void RewriteLocatedEvent(ui::LocatedEvent* event);
@@ -153,32 +210,10 @@ class EventRewriter : public ash::EventRewriterDelegate,
int last_device_id_;
#if defined(OS_CHROMEOS)
- // X keycodes corresponding to various keysyms.
- unsigned int control_l_xkeycode_;
- unsigned int control_r_xkeycode_;
- unsigned int alt_l_xkeycode_;
- unsigned int alt_r_xkeycode_;
- unsigned int meta_l_xkeycode_;
- unsigned int meta_r_xkeycode_;
- unsigned int windows_l_xkeycode_;
- unsigned int caps_lock_xkeycode_;
- unsigned int void_symbol_xkeycode_;
- unsigned int delete_xkeycode_;
- unsigned int home_xkeycode_;
- unsigned int end_xkeycode_;
- unsigned int prior_xkeycode_;
- unsigned int next_xkeycode_;
- unsigned int kp_0_xkeycode_;
- unsigned int kp_1_xkeycode_;
- unsigned int kp_2_xkeycode_;
- unsigned int kp_3_xkeycode_;
- unsigned int kp_4_xkeycode_;
- unsigned int kp_5_xkeycode_;
- unsigned int kp_6_xkeycode_;
- unsigned int kp_7_xkeycode_;
- unsigned int kp_8_xkeycode_;
- unsigned int kp_9_xkeycode_;
- unsigned int kp_decimal_xkeycode_;
+ bool force_chromeos_keyboard_for_testing_;
+
+ // A mapping from X11 KeySym keys to KeyCode values.
+ base::hash_map<unsigned long, unsigned long> keysym_to_keycode_map_;
chromeos::input_method::XKeyboard* xkeyboard_; // for testing.
#endif
« no previous file with comments | « chrome/browser/ui/ash/chrome_shell_delegate.cc ('k') | chrome/browser/ui/ash/event_rewriter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698