This repository has been archived by the owner on Jan 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 183
/
accelerator.patch
72 lines (67 loc) · 2.56 KB
/
accelerator.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
diff --git a/ui/base/accelerators/accelerator.cc b/ui/base/accelerators/accelerator.cc
index 0694f7433df5..a22ef96a7307 100644
--- a/ui/base/accelerators/accelerator.cc
+++ b/ui/base/accelerators/accelerator.cc
@@ -9,6 +9,7 @@
#include "base/i18n/rtl.h"
#include "base/logging.h"
#include "base/strings/string_util.h"
+#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "ui/base/l10n/l10n_util.h"
@@ -19,9 +20,7 @@
#include <windows.h>
#endif
-#if !defined(OS_WIN) && (defined(USE_AURA) || defined(OS_MACOSX))
#include "ui/events/keycodes/keyboard_code_conversion.h"
-#endif
namespace ui {
@@ -210,7 +209,14 @@ base::string16 Accelerator::GetShortcutText() const {
}
base::string16 shortcut;
+ unsigned int flags = 0;
if (!string_id) {
+ const uint16_t c = DomCodeToUsLayoutCharacter(
+ UsLayoutKeyboardCodeToDomCode(key_code_), flags);
+ if (c != 0)
+ shortcut +=
+ static_cast<base::string16::value_type>(
+ base::ToUpperASCII(static_cast<base::char16>(c)));
#if defined(OS_WIN)
// Our fallback is to try translate the key code to a regular character
// unless it is one of digits (VK_0 to VK_9). Some keyboard
@@ -219,18 +225,14 @@ base::string16 Accelerator::GetShortcutText() const {
// accent' for '0'). For display in the menu (e.g. Ctrl-0 for the
// default zoom level), we leave VK_[0-9] alone without translation.
wchar_t key;
- if (base::IsAsciiDigit(key_code_))
+ if (base::IsAsciiDigit(key_code_)) {
key = static_cast<wchar_t>(key_code_);
- else
- key = LOWORD(::MapVirtualKeyW(key_code_, MAPVK_VK_TO_CHAR));
- shortcut += key;
-#elif defined(USE_AURA) || defined(OS_MACOSX)
- const uint16_t c = DomCodeToUsLayoutCharacter(
- UsLayoutKeyboardCodeToDomCode(key_code_), false);
- if (c != 0)
- shortcut +=
- static_cast<base::string16::value_type>(base::ToUpperASCII(c));
+ shortcut = key;
+ }
#endif
+ if (key_code_ > VKEY_F1 && key_code_ <= VKEY_F24)
+ shortcut += base::UTF8ToUTF16(
+ base::StringPrintf("F%d", key_code_ - VKEY_F1 + 1));
} else {
shortcut = l10n_util::GetStringUTF16(string_id);
}
@@ -255,7 +257,8 @@ base::string16 Accelerator::GetShortcutText() const {
// more information.
if (IsCtrlDown())
shortcut = l10n_util::GetStringFUTF16(IDS_APP_CONTROL_MODIFIER, shortcut);
- else if (IsAltDown())
+
+ if (IsAltDown())
shortcut = l10n_util::GetStringFUTF16(IDS_APP_ALT_MODIFIER, shortcut);
if (IsCmdDown()) {