fix: non-client mouse events on WCO-enabled windows (#32871)

This commit is contained in:
Calvin 2022-03-08 14:06:20 -07:00 committed by GitHub
parent 076bc58b2a
commit e41c3e960d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 62 additions and 18 deletions

View file

@ -99,21 +99,4 @@ 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

View file

@ -36,7 +36,6 @@ 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