From 04f4bcdb7834e238689e145f75739618ea69a703 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 3 Feb 2026 20:26:39 +0100 Subject: [PATCH] fix: alt-space should route through 'system-context-menu' (#49640) fix: alt-space should route through system-context-menu Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr --- .../electron_desktop_window_tree_host_win.cc | 25 +++++++++++++++++++ .../electron_desktop_window_tree_host_win.h | 4 +++ 2 files changed, 29 insertions(+) diff --git a/shell/browser/ui/win/electron_desktop_window_tree_host_win.cc b/shell/browser/ui/win/electron_desktop_window_tree_host_win.cc index 42039cd92f..5e5683a387 100644 --- a/shell/browser/ui/win/electron_desktop_window_tree_host_win.cc +++ b/shell/browser/ui/win/electron_desktop_window_tree_host_win.cc @@ -150,6 +150,31 @@ bool ElectronDesktopWindowTreeHostWin::HandleMouseEvent(ui::MouseEvent* event) { return views::DesktopWindowTreeHostWin::HandleMouseEvent(event); } +bool ElectronDesktopWindowTreeHostWin::HandleIMEMessage(UINT message, + WPARAM w_param, + LPARAM l_param, + LRESULT* result) { + if ((message == WM_SYSCHAR) && (w_param == VK_SPACE)) { + if (native_window_view_->widget() && + native_window_view_->widget()->non_client_view()) { + const auto* frame = + native_window_view_->widget()->non_client_view()->frame_view(); + auto location = frame->GetSystemMenuScreenPixelLocation(); + + bool prevent_default = false; + native_window_view_->NotifyWindowSystemContextMenu( + location.x(), location.y(), &prevent_default); + + return prevent_default || + views::DesktopWindowTreeHostWin::HandleIMEMessage(message, w_param, + l_param, result); + } + } + + return views::DesktopWindowTreeHostWin::HandleIMEMessage(message, w_param, + l_param, result); +} + void ElectronDesktopWindowTreeHostWin::HandleVisibilityChanged(bool visible) { if (native_window_view_->widget()) native_window_view_->widget()->OnNativeWidgetVisibilityChanged(visible); diff --git a/shell/browser/ui/win/electron_desktop_window_tree_host_win.h b/shell/browser/ui/win/electron_desktop_window_tree_host_win.h index 366dd08270..dbb0cbf5a4 100644 --- a/shell/browser/ui/win/electron_desktop_window_tree_host_win.h +++ b/shell/browser/ui/win/electron_desktop_window_tree_host_win.h @@ -44,6 +44,10 @@ class ElectronDesktopWindowTreeHostWin : public views::DesktopWindowTreeHostWin, int frame_thickness) const override; bool HandleMouseEventForCaption(UINT message) const override; bool HandleMouseEvent(ui::MouseEvent* event) override; + bool HandleIMEMessage(UINT message, + WPARAM w_param, + LPARAM l_param, + LRESULT* result) override; void HandleVisibilityChanged(bool visible) override; void SetAllowScreenshots(bool allow) override;