fix: emit context-menu event in Windows draggable regions (#45851)

fix: emit context-menu event in Windows draggable regions
This commit is contained in:
Shelley Vohr 2025-03-14 10:29:29 +01:00 committed by GitHub
parent 785fe5f3b6
commit 7c0b7b417b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 29 additions and 5 deletions

View file

@ -6,6 +6,7 @@
#include "base/win/windows_version.h"
#include "electron/buildflags/buildflags.h"
#include "shell/browser/api/electron_api_web_contents.h"
#include "shell/browser/native_window_views.h"
#include "shell/browser/ui/views/win_frame_view.h"
#include "shell/browser/win/dark_mode.h"
@ -113,6 +114,12 @@ bool ElectronDesktopWindowTreeHostWin::HandleMouseEvent(ui::MouseEvent* event) {
bool prevent_default = false;
native_window_view_->NotifyWindowSystemContextMenu(event->x(), event->y(),
&prevent_default);
// If the user prevents default behavior, emit contextmenu event to
// allow bringing up the custom menu.
if (prevent_default) {
electron::api::WebContents::SetDisableDraggableRegions(true);
views::DesktopWindowTreeHostWin::HandleMouseEvent(event);
}
return prevent_default;
}