2018-10-24 18:24:11 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2018-09-21 00:30:26 +00:00
|
|
|
From: Cheng Zhao <zcbenz@gmail.com>
|
|
|
|
Date: Thu, 4 Oct 2018 14:57:02 -0700
|
|
|
|
Subject: accelerator.patch
|
|
|
|
|
|
|
|
|
2018-09-14 05:02:16 +00:00
|
|
|
diff --git a/ui/base/accelerators/accelerator.cc b/ui/base/accelerators/accelerator.cc
|
2019-01-12 01:00:43 +00:00
|
|
|
index d56e87be04cb4d765d0aa0eae1af86a9f562b222..9364ac4b75debc61e201e0da7eaef104acea770d 100644
|
2018-09-14 05:02:16 +00:00
|
|
|
--- a/ui/base/accelerators/accelerator.cc
|
|
|
|
+++ b/ui/base/accelerators/accelerator.cc
|
|
|
|
@@ -11,6 +11,7 @@
|
|
|
|
#include "base/logging.h"
|
|
|
|
#include "base/strings/strcat.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"
|
|
|
|
@@ -21,9 +22,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 {
|
|
|
|
|
2018-10-24 23:25:48 +00:00
|
|
|
@@ -147,7 +146,15 @@ base::string16 Accelerator::GetShortcutText() const {
|
2018-09-14 05:02:16 +00:00
|
|
|
shortcut = KeyCodeToName(key_code_);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
+ unsigned int flags = 0;
|
|
|
|
if (shortcut.empty()) {
|
|
|
|
+ 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
|
2019-01-12 01:00:43 +00:00
|
|
|
@@ -156,18 +163,14 @@ base::string16 Accelerator::GetShortcutText() const {
|
2018-09-14 05:02:16 +00:00
|
|
|
// 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;
|
|
|
|
+ }
|
2018-10-31 14:13:44 +00:00
|
|
|
#endif
|
2018-09-14 05:02:16 +00:00
|
|
|
+ if (key_code_ > VKEY_F1 && key_code_ <= VKEY_F24)
|
|
|
|
+ shortcut = base::UTF8ToUTF16(
|
|
|
|
+ base::StringPrintf("F%d", key_code_ - VKEY_F1 + 1));
|
|
|
|
}
|
|
|
|
|
2018-10-31 14:13:44 +00:00
|
|
|
// Checking whether the character used for the accelerator is alphanumeric.
|
2019-01-12 01:00:43 +00:00
|
|
|
@@ -231,7 +234,7 @@ base::string16 Accelerator::ApplyLongFormModifiers(
|
2018-09-14 05:02:16 +00:00
|
|
|
// more information.
|
|
|
|
if (IsCtrlDown())
|
2018-10-24 23:25:48 +00:00
|
|
|
shortcut = ApplyModifierToAcceleratorString(shortcut, IDS_APP_CTRL_KEY);
|
2018-09-14 05:02:16 +00:00
|
|
|
- else if (IsAltDown())
|
|
|
|
+ if (IsAltDown())
|
2018-10-24 23:25:48 +00:00
|
|
|
shortcut = ApplyModifierToAcceleratorString(shortcut, IDS_APP_ALT_KEY);
|
2018-09-14 05:02:16 +00:00
|
|
|
|
|
|
|
if (IsCmdDown()) {
|