electron/patches/chromium/command-ismediakey.patch
electron-roller[bot] 87f7625c5d
chore: bump chromium to 96.0.4664.4 (main) (#31317)
* chore: bump chromium in DEPS to 96.0.4662.0

* chore: bump chromium in DEPS to 96.0.4663.0

* chore: update patches

* [Extensions] Remove RuntimeData entirely

https://chromium-review.googlesource.com/c/chromium/src/+/3177328

* Make helper macros behave consistently for //content/public UserData types

https://chromium-review.googlesource.com/c/chromium/src/+/3198788

* Enabling sandboxing for the speech recognition service browser tests

 https://chromium-review.googlesource.com/c/chromium/src/+/3146090

* [devtools] Add 'RegisterPreference' host binding

  https://chromium-review.googlesource.com/c/chromium/src/+/3162281

* [Reland][Extensions]: Add persistAcrossSessions flag (scripting API)

https://chromium-review.googlesource.com/c/chromium/src/+/3175161

* [Bluetooth] Add Passkey prompt dialog for bonding.

https://chromium-review.googlesource.com/c/chromium/src/+/2841104

* Clipboard: Remove ReadImage path in browser

https://chromium-review.googlesource.com/c/chromium/src/+/3194826

* Split printing metafile code into its own target.

https://chromium-review.googlesource.com/c/chromium/src/+/3164925

* Cleanup unused DesktopMediaListObserver params

https://chromium-review.googlesource.com/c/chromium/src/+/3179203

* Remove base::DictionaryValue::GetBinary

https://chromium-review.googlesource.com/c/chromium/src/+/3201974

* Window Placement: change RWHV::GetDisplayList to GetScreenInfos

https://chromium-review.googlesource.com/c/chromium/src/+/3138774

* Add a preview to the Tab Capture picker dialog

https://chromium-review.googlesource.com/c/chromium/src/+/3045268

* Add service-based usage to update print settings

https://chromium-review.googlesource.com/c/chromium/src/+/3155426

* chore: bump chromium in DEPS to 96.0.4664.2

* chore: update patches

* chore: bump chromium in DEPS to 96.0.4664.4

* chore: update patches

* chore: bump chromium in DEPS to 97.0.4666.0

* Revert "chore: bump chromium in DEPS to 97.0.4666.0"

This reverts commit d73caae8ba4b39efc9b3ea4de52685b9c92ef3d0.

* Reland "Block external protocol handler with sandbox."

https://chromium-review.googlesource.com/c/chromium/src/+/3198263

* fixup for lint

* Add CookiePartitionKeychain parameter to CookeManager.GetCookieList.

https://chromium-review.googlesource.com/c/chromium/src/+/3206016

* Move ui/gfx/transform*,rrect*,mask_filter_info* into ui/gfx/geometry

https://chromium-review.googlesource.com/c/chromium/src/+/3200392

* fixup Move ui/gfx/transform*,rrect*,mask_filter_info* into ui/gfx/geometry

* ozone: //chrome/browser clean up from USE_X11

https://chromium-review.googlesource.com/c/chromium/src/+/3186490

* content: don't load v8 snapshot in browser process

https://chromium-review.googlesource.com/c/chromium/src/+/3183394

* [devtools] Add 'RegisterPreference' host binding

  https://chromium-review.googlesource.com/c/chromium/src/+/3162281

* 3186491: Add 'devtools.sync_preferences' preference

https://chromium-review.googlesource.com/c/chromium/src/+/3186491

* 2951147: DCHECK accessible names for focusable Views

https://chromium-review.googlesource.com/c/chromium/src/+/2951147

* 3201014: Use real font size for calculation of SmallTextRatio

https://chromium-review.googlesource.com/c/chromium/src/+/3201014

* fixup Clipboard: Remove ReadImage path in browser

* chore: update patches

* fix: disable PlzServiceWorker to fix custom protocol SW script loading

Ref: https://chromium-review.googlesource.com/c/chromium/src/+/3199761

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
Co-authored-by: Samuel Attard <samuel.r.attard@gmail.com>
2021-10-21 11:51:36 -07:00

364 lines
18 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jeremy Apthorp <jeremya@chromium.org>
Date: Wed, 10 Oct 2018 15:07:34 -0700
Subject: command-ismediakey.patch
Override MediaKeysListener::IsMediaKeycode and associated functions to also listen for
Volume Up, Volume Down, and Mute.
Also apply electron/electron@0f67b1866a9f00b852370e721affa4efda623f3a
and electron/electron@d2368d2d3b3de9eec4cc32b6aaf035cc89921bf1 as
patches.
diff --git a/chrome/browser/extensions/global_shortcut_listener_ozone.cc b/chrome/browser/extensions/global_shortcut_listener_ozone.cc
index ed2ac20679a9357c9493224ec5e08837c7860d6e..7f9a97e11395e5521e100694cd37bcd95bcd8e35 100644
--- a/chrome/browser/extensions/global_shortcut_listener_ozone.cc
+++ b/chrome/browser/extensions/global_shortcut_listener_ozone.cc
@@ -58,7 +58,8 @@ bool GlobalShortcutListenerOzone::RegisterAcceleratorImpl(
const bool registered =
platform_global_shortcut_listener_->RegisterAccelerator(
accelerator.key_code(), accelerator.IsAltDown(),
- accelerator.IsCtrlDown(), accelerator.IsShiftDown());
+ accelerator.IsCtrlDown(), accelerator.IsShiftDown(),
+ accelerator.IsCmdDown());
if (registered)
registered_hot_keys_.insert(accelerator);
return registered;
@@ -72,14 +73,15 @@ void GlobalShortcutListenerOzone::UnregisterAcceleratorImpl(
platform_global_shortcut_listener_->UnregisterAccelerator(
accelerator.key_code(), accelerator.IsAltDown(), accelerator.IsCtrlDown(),
- accelerator.IsShiftDown());
+ accelerator.IsShiftDown(), accelerator.IsCmdDown());
registered_hot_keys_.erase(accelerator);
}
void GlobalShortcutListenerOzone::OnKeyPressed(ui::KeyboardCode key_code,
bool is_alt_down,
bool is_ctrl_down,
- bool is_shift_down) {
+ bool is_shift_down,
+ bool is_cmd_down) {
int modifiers = 0;
if (is_alt_down)
modifiers |= ui::EF_ALT_DOWN;
@@ -87,6 +89,8 @@ void GlobalShortcutListenerOzone::OnKeyPressed(ui::KeyboardCode key_code,
modifiers |= ui::EF_CONTROL_DOWN;
if (is_shift_down)
modifiers |= ui::EF_SHIFT_DOWN;
+ if (is_cmd_down)
+ modifiers |= ui::EF_COMMAND_DOWN;
NotifyKeyPressed(ui::Accelerator(key_code, modifiers));
}
diff --git a/chrome/browser/extensions/global_shortcut_listener_ozone.h b/chrome/browser/extensions/global_shortcut_listener_ozone.h
index 866c4e6c1ff8c1a2399d943837fce1753c8ea1a5..ecde46fe5f8c5f250a7cb505c86ae59cfa1bd623 100644
--- a/chrome/browser/extensions/global_shortcut_listener_ozone.h
+++ b/chrome/browser/extensions/global_shortcut_listener_ozone.h
@@ -46,7 +46,8 @@ class GlobalShortcutListenerOzone
void OnKeyPressed(ui::KeyboardCode key_code,
bool is_alt_down,
bool is_ctrl_down,
- bool is_shift_down) override;
+ bool is_shift_down,
+ bool is_cmd_down) override;
void OnPlatformListenerDestroyed() override;
bool is_listening_ = false;
diff --git a/chrome/browser/extensions/global_shortcut_listener_win.cc b/chrome/browser/extensions/global_shortcut_listener_win.cc
index 0f344ee352a48497e77a72bb298146c61e7fcf2a..3bad4263ea552fc63445bf5613f8add746a3a374 100644
--- a/chrome/browser/extensions/global_shortcut_listener_win.cc
+++ b/chrome/browser/extensions/global_shortcut_listener_win.cc
@@ -62,6 +62,8 @@ void GlobalShortcutListenerWin::OnWndProc(HWND hwnd,
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);
@@ -92,6 +94,7 @@ bool GlobalShortcutListenerWin::RegisterAcceleratorImpl(
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 =
diff --git a/content/browser/media/media_keys_listener_manager_impl.cc b/content/browser/media/media_keys_listener_manager_impl.cc
index 4145418210c2b1033390ec8a2e657cb1fcd048f8..5938f75742b793868638e693a9a8c8dc686dfc46 100644
--- a/content/browser/media/media_keys_listener_manager_impl.cc
+++ b/content/browser/media/media_keys_listener_manager_impl.cc
@@ -290,6 +290,11 @@ void MediaKeysListenerManagerImpl::UpdateSystemMediaControlsEnabledControls() {
case ui::VKEY_MEDIA_STOP:
system_media_controls_->SetIsStopEnabled(should_enable);
break;
+ case ui::VKEY_VOLUME_DOWN:
+ case ui::VKEY_VOLUME_UP:
+ case ui::VKEY_VOLUME_MUTE:
+ // Do nothing.
+ break;
default:
NOTREACHED();
}
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
diff --git a/ui/base/accelerators/media_keys_listener_mac.mm b/ui/base/accelerators/media_keys_listener_mac.mm
index ada705fb42e88d4bfa05b212c84111be9057a50e..a866b975687dd08ad88031a63f161b3164e82455 100644
--- a/ui/base/accelerators/media_keys_listener_mac.mm
+++ b/ui/base/accelerators/media_keys_listener_mac.mm
@@ -32,6 +32,12 @@ KeyboardCode MediaKeyCodeToKeyboardCode(int key_code) {
case NX_KEYTYPE_NEXT:
case NX_KEYTYPE_FAST:
return VKEY_MEDIA_NEXT_TRACK;
+ case NX_KEYTYPE_SOUND_UP:
+ return VKEY_VOLUME_UP;
+ case NX_KEYTYPE_SOUND_DOWN:
+ return VKEY_VOLUME_DOWN;
+ case NX_KEYTYPE_MUTE:
+ return VKEY_VOLUME_MUTE;
}
return VKEY_UNKNOWN;
}
@@ -192,7 +198,10 @@ static CGEventRef EventTapCallback(CGEventTapProxy proxy,
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;
}
diff --git a/ui/base/x/x11_global_shortcut_listener.cc b/ui/base/x/x11_global_shortcut_listener.cc
index a772666160a71e8e31242e25a8f3383ad9b914bf..7ed78ff875ccf9c38a480d0d59f4688ada1a3ad3 100644
--- a/ui/base/x/x11_global_shortcut_listener.cc
+++ b/ui/base/x/x11_global_shortcut_listener.cc
@@ -32,11 +32,13 @@ const x11::ModMask kModifiersMasks[] = {
x11::ModMask GetNativeModifiers(bool is_alt_down,
bool is_ctrl_down,
- bool is_shift_down) {
+ bool is_shift_down,
+ bool is_cmd_down) {
constexpr auto kNoMods = x11::ModMask{};
return (is_shift_down ? x11::ModMask::Shift : kNoMods) |
(is_ctrl_down ? x11::ModMask::Control : kNoMods) |
- (is_alt_down ? x11::ModMask::c_1 : kNoMods);
+ (is_alt_down ? x11::ModMask::c_1 : kNoMods) |
+ (is_cmd_down ? x11::ModMask::c_4 : kNoMods);
}
} // namespace
@@ -82,8 +84,9 @@ uint32_t XGlobalShortcutListener::DispatchEvent(const PlatformEvent& event) {
bool XGlobalShortcutListener::RegisterAccelerator(KeyboardCode key_code,
bool is_alt_down,
bool is_ctrl_down,
- bool is_shift_down) {
- auto modifiers = GetNativeModifiers(is_alt_down, is_ctrl_down, is_shift_down);
+ bool is_shift_down,
+ bool is_cmd_down) {
+ auto modifiers = GetNativeModifiers(is_alt_down, is_ctrl_down, is_shift_down, is_cmd_down);
auto keysym = XKeysymForWindowsKeyCode(key_code, false);
auto keycode = connection_->KeysymToKeycode(keysym);
@@ -108,7 +111,7 @@ bool XGlobalShortcutListener::RegisterAccelerator(KeyboardCode key_code,
}
registered_combinations_.insert(
- Accelerator(key_code, is_alt_down, is_ctrl_down, is_shift_down));
+ Accelerator(key_code, is_alt_down, is_ctrl_down, is_shift_down, is_cmd_down));
return true;
}
@@ -116,8 +119,9 @@ bool XGlobalShortcutListener::RegisterAccelerator(KeyboardCode key_code,
void XGlobalShortcutListener::UnregisterAccelerator(KeyboardCode key_code,
bool is_alt_down,
bool is_ctrl_down,
- bool is_shift_down) {
- auto modifiers = GetNativeModifiers(is_alt_down, is_ctrl_down, is_shift_down);
+ bool is_shift_down,
+ bool is_cmd_down) {
+ auto modifiers = GetNativeModifiers(is_alt_down, is_ctrl_down, is_shift_down, is_cmd_down);
auto keysym = XKeysymForWindowsKeyCode(key_code, false);
auto keycode = connection_->KeysymToKeycode(keysym);
@@ -125,7 +129,7 @@ void XGlobalShortcutListener::UnregisterAccelerator(KeyboardCode key_code,
connection_->UngrabKey({keycode, x_root_window_, modifiers | mask});
registered_combinations_.erase(
- Accelerator(key_code, is_alt_down, is_ctrl_down, is_shift_down));
+ Accelerator(key_code, is_alt_down, is_ctrl_down, is_shift_down, is_cmd_down));
}
void XGlobalShortcutListener::OnKeyPressEvent(const KeyEvent& event) {
@@ -135,14 +139,15 @@ void XGlobalShortcutListener::OnKeyPressEvent(const KeyEvent& event) {
const bool is_alt_down = event.flags() & EF_ALT_DOWN;
const bool is_ctrl_down = event.flags() & EF_CONTROL_DOWN;
const bool is_shift_down = event.flags() & EF_SHIFT_DOWN;
+ const bool is_cmd_down = event.flags() & EF_COMMAND_DOWN;
if (!base::Contains(
registered_combinations_,
- Accelerator(key_code, is_alt_down, is_ctrl_down, is_shift_down))) {
+ Accelerator(key_code, is_alt_down, is_ctrl_down, is_shift_down, is_cmd_down))) {
return;
}
- OnKeyPressed(key_code, is_alt_down, is_ctrl_down, is_shift_down);
+ OnKeyPressed(key_code, is_alt_down, is_ctrl_down, is_shift_down, is_cmd_down);
}
} // namespace ui
diff --git a/ui/base/x/x11_global_shortcut_listener.h b/ui/base/x/x11_global_shortcut_listener.h
index 9e472d76423a748cbf6257c6656d8fd69853dd93..404a294b9cf3dd6744ece0b5c1e611bbab207e78 100644
--- a/ui/base/x/x11_global_shortcut_listener.h
+++ b/ui/base/x/x11_global_shortcut_listener.h
@@ -40,18 +40,21 @@ class COMPONENT_EXPORT(UI_BASE_X) XGlobalShortcutListener
virtual void OnKeyPressed(KeyboardCode key_code,
bool is_alt_down,
bool is_ctrl_down,
- bool is_shift_down) = 0;
+ bool is_shift_down,
+ bool is_cmd_down) = 0;
void StartListening();
void StopListening();
bool RegisterAccelerator(KeyboardCode key_code,
bool is_alt_down,
bool is_ctrl_down,
- bool is_shift_down);
+ bool is_shift_down,
+ bool is_cmd_down);
void UnregisterAccelerator(KeyboardCode key_code,
bool is_alt_down,
bool is_ctrl_down,
- bool is_shift_down);
+ bool is_shift_down,
+ bool is_cmd_down);
private:
// Due to how system key grabbing works on X11, we have to be a bit greedy and
@@ -60,7 +63,7 @@ class COMPONENT_EXPORT(UI_BASE_X) XGlobalShortcutListener
// and filter the incoming events against that registry before notifying the
// observer. This tuple describes the meaningful parts of the event; booleans
// 1, 2, and 3 hold states of Alt, Control, and Shift keys, respectively.
- using Accelerator = std::tuple<KeyboardCode, bool, bool, bool>;
+ using Accelerator = std::tuple<KeyboardCode, bool, bool, bool, bool>;
// Invoked when a global shortcut is pressed.
void OnKeyPressEvent(const KeyEvent& event);
diff --git a/ui/ozone/platform/x11/x11_global_shortcut_listener_ozone.cc b/ui/ozone/platform/x11/x11_global_shortcut_listener_ozone.cc
index 760dfc340601b7c1807fa750b008bcc79780c583..54f9817017c9fc0ebcd2f5825fb20b2fb8412b02 100644
--- a/ui/ozone/platform/x11/x11_global_shortcut_listener_ozone.cc
+++ b/ui/ozone/platform/x11/x11_global_shortcut_listener_ozone.cc
@@ -26,27 +26,30 @@ void X11GlobalShortcutListenerOzone::StopListening() {
bool X11GlobalShortcutListenerOzone::RegisterAccelerator(KeyboardCode key_code,
bool is_alt_down,
bool is_ctrl_down,
- bool is_shift_down) {
+ bool is_shift_down,
+ bool is_cmd_down) {
return XGlobalShortcutListener::RegisterAccelerator(
- key_code, is_alt_down, is_ctrl_down, is_shift_down);
+ key_code, is_alt_down, is_ctrl_down, is_shift_down, is_cmd_down);
}
void X11GlobalShortcutListenerOzone::UnregisterAccelerator(
KeyboardCode key_code,
bool is_alt_down,
bool is_ctrl_down,
- bool is_shift_down) {
+ bool is_shift_down,
+ bool is_cmd_down) {
return XGlobalShortcutListener::UnregisterAccelerator(
- key_code, is_alt_down, is_ctrl_down, is_shift_down);
+ key_code, is_alt_down, is_ctrl_down, is_shift_down, is_cmd_down);
}
void X11GlobalShortcutListenerOzone::OnKeyPressed(KeyboardCode key_code,
bool is_alt_down,
bool is_ctrl_down,
- bool is_shift_down) {
+ bool is_shift_down,
+ bool is_cmd_down) {
if (delegate()) {
delegate()->OnKeyPressed(key_code, is_alt_down, is_ctrl_down,
- is_shift_down);
+ is_shift_down, is_cmd_down);
}
}
diff --git a/ui/ozone/platform/x11/x11_global_shortcut_listener_ozone.h b/ui/ozone/platform/x11/x11_global_shortcut_listener_ozone.h
index 0f1980abdcaf30e23f580b937ecb2c422bf2a357..112967622cb8a6263c7a88dd8d09f48f52448a45 100644
--- a/ui/ozone/platform/x11/x11_global_shortcut_listener_ozone.h
+++ b/ui/ozone/platform/x11/x11_global_shortcut_listener_ozone.h
@@ -28,17 +28,20 @@ class X11GlobalShortcutListenerOzone : public PlatformGlobalShortcutListener,
bool RegisterAccelerator(KeyboardCode key_code,
bool is_alt_down,
bool is_ctrl_down,
- bool is_shift_down) override;
+ bool is_shift_down,
+ bool is_cmd_down) override;
void UnregisterAccelerator(KeyboardCode key_code,
bool is_alt_down,
bool is_ctrl_down,
- bool is_shift_down) override;
+ bool is_shift_down,
+ bool is_cmd_down) override;
// ui::XGlobalShortcutListener:
void OnKeyPressed(KeyboardCode key_code,
bool is_alt_down,
bool is_ctrl_down,
- bool is_shift_down) override;
+ bool is_shift_down,
+ bool is_cmd_down) override;
};
} // namespace ui
diff --git a/ui/ozone/public/platform_global_shortcut_listener.h b/ui/ozone/public/platform_global_shortcut_listener.h
index a5b539d4e7461c4ca9faa08fef086fc28a4ebd3a..f3aacc605f07807a5b83b496bd8a87933981d4f3 100644
--- a/ui/ozone/public/platform_global_shortcut_listener.h
+++ b/ui/ozone/public/platform_global_shortcut_listener.h
@@ -19,7 +19,8 @@ class COMPONENT_EXPORT(OZONE_BASE) PlatformGlobalShortcutListenerDelegate {
virtual void OnKeyPressed(KeyboardCode key_code,
bool is_alt_down,
bool is_ctrl_down,
- bool is_shift_down) = 0;
+ bool is_shift_down,
+ bool is_cmd_down) = 0;
// Called back when the platform implementation is destroyed.
virtual void OnPlatformListenerDestroyed() = 0;
@@ -51,11 +52,13 @@ class COMPONENT_EXPORT(OZONE_BASE) PlatformGlobalShortcutListener {
virtual bool RegisterAccelerator(KeyboardCode key_code,
bool is_alt_down,
bool is_ctrl_down,
- bool is_shift_down) = 0;
+ bool is_shift_down,
+ bool is_cmd_down) = 0;
virtual void UnregisterAccelerator(KeyboardCode key_code,
bool is_alt_down,
bool is_ctrl_down,
- bool is_shift_down) = 0;
+ bool is_shift_down,
+ bool is_cmd_down) = 0;
protected:
PlatformGlobalShortcutListenerDelegate* delegate() { return delegate_; }