fix: system-context-menu should only fire in draggable regions (#45893)

fix: system-context-menu should only fire in draggable regions
This commit is contained in:
Shelley Vohr 2025-03-12 13:47:58 +01:00 committed by GitHub
parent 6bc7bde229
commit 5ce41bac8d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 72 additions and 15 deletions

View file

@ -108,6 +108,17 @@ bool ElectronDesktopWindowTreeHostWin::HandleMouseEventForCaption(
return native_window_view_->IsWindowControlsOverlayEnabled();
}
bool ElectronDesktopWindowTreeHostWin::HandleMouseEvent(ui::MouseEvent* event) {
if (event->is_system_menu() && !native_window_view_->has_frame()) {
bool prevent_default = false;
native_window_view_->NotifyWindowSystemContextMenu(event->x(), event->y(),
&prevent_default);
return prevent_default;
}
return views::DesktopWindowTreeHostWin::HandleMouseEvent(event);
}
void ElectronDesktopWindowTreeHostWin::OnNativeThemeUpdated(
ui::NativeTheme* observed_theme) {
HWND hWnd = GetAcceleratedWidget();

View file

@ -40,6 +40,7 @@ class ElectronDesktopWindowTreeHostWin : public views::DesktopWindowTreeHostWin,
bool GetClientAreaInsets(gfx::Insets* insets,
HMONITOR monitor) const override;
bool HandleMouseEventForCaption(UINT message) const override;
bool HandleMouseEvent(ui::MouseEvent* event) override;
// ui::NativeThemeObserver:
void OnNativeThemeUpdated(ui::NativeTheme* observed_theme) override;