From ad2b1364256e551726413248a06a6275cfba16c1 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Thu, 3 Feb 2022 09:46:32 -0500 Subject: [PATCH] fix: WCO window hover on window controls on Windows (#32723) * fix: WCO window hover on window controls * Update shell/browser/ui/win/electron_desktop_window_tree_host_win.cc Co-authored-by: Robo * Trigger Build Co-authored-by: clavin Co-authored-by: Calvin Co-authored-by: Robo Co-authored-by: John Kleinschmidt --- .../electron_desktop_window_tree_host_win.cc | 17 +++++++++++++++++ .../win/electron_desktop_window_tree_host_win.h | 1 + 2 files changed, 18 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 03d0846c7f8f5..16e71fac12b39 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 @@ -99,4 +99,21 @@ bool ElectronDesktopWindowTreeHostWin::GetClientAreaInsets( return false; } +bool ElectronDesktopWindowTreeHostWin::HandleMouseEvent(ui::MouseEvent* event) { + // Call the default implementation of this method to get the event to its + // proper handler. + bool handled = views::DesktopWindowTreeHostWin::HandleMouseEvent(event); + + // On WCO-enabled windows, we need to mark non-client mouse moved events as + // handled so they don't incorrectly propogate back to the OS. + if (native_window_view_->IsWindowControlsOverlayEnabled() && + event->type() == ui::ET_MOUSE_MOVED && + (event->flags() & ui::EF_IS_NON_CLIENT) != 0) { + event->SetHandled(); + handled = true; + } + + return handled; +} + } // namespace electron 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 3fd831aae1ed0..8c7be1175a193 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 @@ -36,6 +36,7 @@ class ElectronDesktopWindowTreeHostWin bool GetDwmFrameInsetsInPixels(gfx::Insets* insets) const override; bool GetClientAreaInsets(gfx::Insets* insets, HMONITOR monitor) const override; + bool HandleMouseEvent(ui::MouseEvent* event) override; private: NativeWindowViews* native_window_view_; // weak ref