2018-10-24 18:24:11 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2018-10-11 05:02:58 +00:00
|
|
|
From: Jeremy Apthorp <jeremya@chromium.org>
|
|
|
|
Date: Wed, 10 Oct 2018 15:07:34 -0700
|
2019-08-24 01:14:23 +00:00
|
|
|
Subject: command-ismediakey.patch
|
2018-10-11 05:02:58 +00:00
|
|
|
|
2020-05-28 12:56:48 +00:00
|
|
|
Override MediaKeysListener::IsMediaKeycode and associated functions to also listen for
|
|
|
|
Volume Up, Volume Down, and Mute.
|
2018-10-11 05:02:58 +00:00
|
|
|
|
|
|
|
Also apply electron/electron@0f67b1866a9f00b852370e721affa4efda623f3a
|
|
|
|
and electron/electron@d2368d2d3b3de9eec4cc32b6aaf035cc89921bf1 as
|
|
|
|
patches.
|
|
|
|
|
|
|
|
diff --git a/chrome/browser/extensions/global_shortcut_listener_win.cc b/chrome/browser/extensions/global_shortcut_listener_win.cc
|
2020-11-14 00:16:56 +00:00
|
|
|
index 0f344ee352a48497e77a72bb298146c61e7fcf2a..3bad4263ea552fc63445bf5613f8add746a3a374 100644
|
2018-10-11 05:02:58 +00:00
|
|
|
--- a/chrome/browser/extensions/global_shortcut_listener_win.cc
|
|
|
|
+++ b/chrome/browser/extensions/global_shortcut_listener_win.cc
|
2019-02-04 05:49:22 +00:00
|
|
|
@@ -62,6 +62,8 @@ void GlobalShortcutListenerWin::OnWndProc(HWND hwnd,
|
2018-10-11 05:02:58 +00:00
|
|
|
modifiers |= (LOWORD(lparam) & MOD_SHIFT) ? ui::EF_SHIFT_DOWN : 0;
|
|
|
|
modifiers |= (LOWORD(lparam) & MOD_ALT) ? ui::EF_ALT_DOWN : 0;
|
|
|
|
modifiers |= (LOWORD(lparam) & MOD_CONTROL) ? ui::EF_CONTROL_DOWN : 0;
|
|
|
|
+ modifiers |= (LOWORD(lparam) & MOD_WIN) ? ui::EF_COMMAND_DOWN : 0;
|
|
|
|
+
|
|
|
|
ui::Accelerator accelerator(
|
|
|
|
ui::KeyboardCodeForWindowsKeyCode(key_code), modifiers);
|
|
|
|
|
2019-04-20 17:20:37 +00:00
|
|
|
@@ -92,6 +94,7 @@ bool GlobalShortcutListenerWin::RegisterAcceleratorImpl(
|
2019-03-28 18:15:22 +00:00
|
|
|
modifiers |= accelerator.IsShiftDown() ? MOD_SHIFT : 0;
|
|
|
|
modifiers |= accelerator.IsCtrlDown() ? MOD_CONTROL : 0;
|
|
|
|
modifiers |= accelerator.IsAltDown() ? MOD_ALT : 0;
|
|
|
|
+ modifiers |= accelerator.IsCmdDown() ? MOD_WIN : 0;
|
|
|
|
|
|
|
|
// Create an observer that registers a hot key for |accelerator|.
|
|
|
|
std::unique_ptr<gfx::SingletonHwndHotKeyObserver> observer =
|
2018-10-11 05:02:58 +00:00
|
|
|
diff --git a/chrome/browser/extensions/global_shortcut_listener_x11.cc b/chrome/browser/extensions/global_shortcut_listener_x11.cc
|
2020-11-14 00:16:56 +00:00
|
|
|
index e1c49f5cd9bd249398a14905a6fb41d54238e1ec..ad1c76e77e029d759547f6aded492ae62a7ce946 100644
|
2018-10-11 05:02:58 +00:00
|
|
|
--- a/chrome/browser/extensions/global_shortcut_listener_x11.cc
|
|
|
|
+++ b/chrome/browser/extensions/global_shortcut_listener_x11.cc
|
2020-11-14 00:16:56 +00:00
|
|
|
@@ -37,7 +37,8 @@ x11::ModMask GetNativeModifiers(const ui::Accelerator& accelerator) {
|
2020-10-16 01:30:41 +00:00
|
|
|
constexpr auto kNoMods = x11::ModMask{};
|
|
|
|
return (accelerator.IsShiftDown() ? x11::ModMask::Shift : kNoMods) |
|
|
|
|
(accelerator.IsCtrlDown() ? x11::ModMask::Control : kNoMods) |
|
|
|
|
- (accelerator.IsAltDown() ? x11::ModMask::c_1 : kNoMods);
|
|
|
|
+ (accelerator.IsAltDown() ? x11::ModMask::c_1 : kNoMods) |
|
|
|
|
+ (accelerator.IsCmdDown() ? x11::ModMask::c_4 : kNoMods);
|
2018-10-11 05:02:58 +00:00
|
|
|
}
|
2020-10-16 01:30:41 +00:00
|
|
|
|
|
|
|
} // namespace
|
2019-12-11 06:48:55 +00:00
|
|
|
diff --git a/ui/base/accelerators/media_keys_listener.cc b/ui/base/accelerators/media_keys_listener.cc
|
|
|
|
index 1145e1f3d79482b5bb468c3128431ac674310e5f..e9f595045e0c076e0735f27dfc38bfbc7951d372 100644
|
|
|
|
--- a/ui/base/accelerators/media_keys_listener.cc
|
|
|
|
+++ b/ui/base/accelerators/media_keys_listener.cc
|
|
|
|
@@ -13,7 +13,8 @@ MediaKeysListener::~MediaKeysListener() = default;
|
|
|
|
// static
|
|
|
|
bool MediaKeysListener::IsMediaKeycode(KeyboardCode key_code) {
|
|
|
|
return key_code == VKEY_MEDIA_PLAY_PAUSE || key_code == VKEY_MEDIA_STOP ||
|
|
|
|
- key_code == VKEY_MEDIA_PREV_TRACK || key_code == VKEY_MEDIA_NEXT_TRACK;
|
|
|
|
+ key_code == VKEY_MEDIA_PREV_TRACK || key_code == VKEY_MEDIA_NEXT_TRACK ||
|
|
|
|
+ key_code == VKEY_VOLUME_UP || key_code == VKEY_VOLUME_DOWN || key_code == VKEY_VOLUME_MUTE;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace ui
|
2018-10-11 05:02:58 +00:00
|
|
|
diff --git a/ui/base/accelerators/media_keys_listener_mac.mm b/ui/base/accelerators/media_keys_listener_mac.mm
|
2020-06-22 17:35:10 +00:00
|
|
|
index 6052fd13ff3d63cf8a4b019b058efb61aad39c3b..42eac7a7b656096c1d2039e340037ac8a70678c9 100644
|
2018-10-11 05:02:58 +00:00
|
|
|
--- a/ui/base/accelerators/media_keys_listener_mac.mm
|
|
|
|
+++ b/ui/base/accelerators/media_keys_listener_mac.mm
|
2020-06-22 17:35:10 +00:00
|
|
|
@@ -33,6 +33,12 @@ KeyboardCode MediaKeyCodeToKeyboardCode(int key_code) {
|
2018-10-11 05:02:58 +00:00
|
|
|
case NX_KEYTYPE_NEXT:
|
|
|
|
case NX_KEYTYPE_FAST:
|
2019-01-16 18:07:52 +00:00
|
|
|
return VKEY_MEDIA_NEXT_TRACK;
|
2018-10-11 05:02:58 +00:00
|
|
|
+ case NX_KEYTYPE_SOUND_UP:
|
2019-01-16 18:07:52 +00:00
|
|
|
+ return VKEY_VOLUME_UP;
|
2018-10-11 05:02:58 +00:00
|
|
|
+ case NX_KEYTYPE_SOUND_DOWN:
|
2019-01-16 18:07:52 +00:00
|
|
|
+ return VKEY_VOLUME_DOWN;
|
2018-10-11 05:02:58 +00:00
|
|
|
+ case NX_KEYTYPE_MUTE:
|
2019-01-16 18:07:52 +00:00
|
|
|
+ return VKEY_VOLUME_MUTE;
|
2018-10-11 05:02:58 +00:00
|
|
|
}
|
2019-01-16 18:07:52 +00:00
|
|
|
return VKEY_UNKNOWN;
|
2018-10-11 05:02:58 +00:00
|
|
|
}
|
2020-08-10 15:23:21 +00:00
|
|
|
@@ -193,7 +199,10 @@ static CGEventRef EventTapCallback(CGEventTapProxy proxy,
|
2018-10-11 05:02:58 +00:00
|
|
|
int key_code = (data1 & 0xFFFF0000) >> 16;
|
|
|
|
if (key_code != NX_KEYTYPE_PLAY && key_code != NX_KEYTYPE_NEXT &&
|
|
|
|
key_code != NX_KEYTYPE_PREVIOUS && key_code != NX_KEYTYPE_FAST &&
|
|
|
|
- key_code != NX_KEYTYPE_REWIND) {
|
|
|
|
+ key_code != NX_KEYTYPE_REWIND &&
|
|
|
|
+ key_code != NX_KEYTYPE_SOUND_UP &&
|
|
|
|
+ key_code != NX_KEYTYPE_SOUND_DOWN &&
|
|
|
|
+ key_code != NX_KEYTYPE_MUTE) {
|
|
|
|
return event;
|
|
|
|
}
|
|
|
|
|
2020-05-28 12:56:48 +00:00
|
|
|
diff --git a/ui/base/accelerators/system_media_controls_media_keys_listener.cc b/ui/base/accelerators/system_media_controls_media_keys_listener.cc
|
2020-06-08 12:46:00 +00:00
|
|
|
index 9d6084ceaccfd071549e63e3015f55ef292312ec..846210b04d6e2e193413c643296938ec550f6d25 100644
|
2020-05-28 12:56:48 +00:00
|
|
|
--- a/ui/base/accelerators/system_media_controls_media_keys_listener.cc
|
|
|
|
+++ b/ui/base/accelerators/system_media_controls_media_keys_listener.cc
|
|
|
|
@@ -65,6 +65,11 @@ bool SystemMediaControlsMediaKeysListener::StartWatchingMediaKey(
|
|
|
|
case VKEY_MEDIA_STOP:
|
|
|
|
service_->SetIsStopEnabled(true);
|
|
|
|
break;
|
|
|
|
+ case VKEY_VOLUME_DOWN:
|
|
|
|
+ case VKEY_VOLUME_UP:
|
|
|
|
+ case VKEY_VOLUME_MUTE:
|
|
|
|
+ // Do nothing.
|
|
|
|
+ break;
|
|
|
|
default:
|
|
|
|
NOTREACHED();
|
|
|
|
}
|
2020-06-08 12:46:00 +00:00
|
|
|
@@ -97,6 +102,11 @@ void SystemMediaControlsMediaKeysListener::StopWatchingMediaKey(
|
|
|
|
case VKEY_MEDIA_STOP:
|
|
|
|
service_->SetIsStopEnabled(false);
|
|
|
|
break;
|
|
|
|
+ case VKEY_VOLUME_DOWN:
|
|
|
|
+ case VKEY_VOLUME_UP:
|
|
|
|
+ case VKEY_VOLUME_MUTE:
|
|
|
|
+ // Do nothing.
|
|
|
|
+ break;
|
|
|
|
default:
|
|
|
|
NOTREACHED();
|
|
|
|
}
|