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

Unified Diff: ui/events/keycodes/platform_key_map_win.cc

Issue 2630213003: Return AltGraph for right-Alt keydown/keyup, under layouts which use AltGraph. (Closed)
Patch Set: Add comment Created 3 years, 11 months 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 | « ui/events/keycodes/platform_key_map_win.h ('k') | ui/events/keycodes/platform_key_map_win_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/keycodes/platform_key_map_win.cc
diff --git a/ui/events/keycodes/platform_key_map_win.cc b/ui/events/keycodes/platform_key_map_win.cc
index 439384c634941d9eb9017b047e3dd464860a9f9f..32b544e31ca8b72463fc8b75052ff91984cc3b5b 100644
--- a/ui/events/keycodes/platform_key_map_win.cc
+++ b/ui/events/keycodes/platform_key_map_win.cc
@@ -286,6 +286,12 @@ PlatformKeyMap::~PlatformKeyMap() {}
DomKey PlatformKeyMap::DomKeyFromKeyboardCodeImpl(KeyboardCode key_code,
int flags) const {
+ // Windows expresses right-Alt as VKEY_MENU with the extended flag set.
+ // This key should generate AltGraph under layouts which use that modifier.
+ if (key_code == VKEY_MENU && (flags & EF_IS_EXTENDED_KEY) && has_alt_graph_) {
+ return DomKey::ALT_GRAPH;
+ }
+
DomKey key = NonPrintableKeyboardCodeToDomKey(key_code, keyboard_layout_);
if (key != DomKey::NONE)
return key;
@@ -346,6 +352,7 @@ void PlatformKeyMap::UpdateLayout(HKL layout) {
// TODO(chongz): Optimize layout switching (see crbug.com/587147).
keyboard_layout_ = layout;
printable_keycode_to_key_.clear();
+ has_alt_graph_ = false;
// Map size for some sample keyboard layouts:
// US: 476, French: 602, Persian: 482, Vietnamese: 1436
@@ -385,6 +392,11 @@ void PlatformKeyMap::UpdateLayout(HKL layout) {
printable_keycode_to_key_[std::make_pair(static_cast<int>(key_code),
flags)] =
DomKey::FromCharacter(translated_chars[0]);
+
+ // Detect whether the layout makes use of AltGraph.
+ if (flags & EF_ALTGR_DOWN) {
+ has_alt_graph_ = true;
+ }
} else {
// Ignores legacy non-printable control characters.
}
« no previous file with comments | « ui/events/keycodes/platform_key_map_win.h ('k') | ui/events/keycodes/platform_key_map_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698