feat: enable Windows Control Overlay on Linux (#41769)

This commit is contained in:
Shelley Vohr 2024-06-27 14:56:36 +02:00 committed by GitHub
parent 1d4b00692d
commit 32e5012017
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 1026 additions and 107 deletions

View file

@ -37,8 +37,6 @@ void WinFrameView::Init(NativeWindowViews* window, views::Widget* frame) {
if (window->IsWindowControlsOverlayEnabled()) {
caption_button_container_ =
AddChildView(std::make_unique<WinCaptionButtonContainer>(this));
} else {
caption_button_container_ = nullptr;
}
}
@ -82,24 +80,23 @@ views::View* WinFrameView::TargetForRect(views::View* root,
// Custom system titlebar returns non HTCLIENT value, however event should
// be handled by the view, not by the system, because there are no system
// buttons underneath.
if (!ShouldCustomDrawSystemTitlebar()) {
if (!window()->IsWindowControlsOverlayEnabled())
return this;
}
auto local_point = rect.origin();
ConvertPointToTarget(parent(), caption_button_container_, &local_point);
if (!caption_button_container_->HitTestPoint(local_point)) {
if (!caption_button_container_->HitTestPoint(local_point))
return this;
}
}
return NonClientFrameView::TargetForRect(root, rect);
}
int WinFrameView::NonClientHitTest(const gfx::Point& point) {
if (window_->has_frame())
if (window()->has_frame())
return frame_->client_view()->NonClientHitTest(point);
if (ShouldCustomDrawSystemTitlebar()) {
if (window()->IsWindowControlsOverlayEnabled()) {
// See if the point is within any of the window controls.
if (caption_button_container_) {
gfx::Point local_point = point;
@ -168,10 +165,6 @@ bool WinFrameView::IsMaximized() const {
return frame()->IsMaximized();
}
bool WinFrameView::ShouldCustomDrawSystemTitlebar() const {
return window()->IsWindowControlsOverlayEnabled();
}
void WinFrameView::Layout(PassKey) {
LayoutCaptionButtons();
if (window()->IsWindowControlsOverlayEnabled()) {
@ -197,7 +190,7 @@ int WinFrameView::FrameTopBorderThicknessPx(bool restored) const {
// See comments in BrowserDesktopWindowTreeHostWin::GetClientAreaInsets().
const bool needs_no_border =
(ShouldCustomDrawSystemTitlebar() && frame()->IsMaximized()) ||
(window()->IsWindowControlsOverlayEnabled() && frame()->IsMaximized()) ||
frame()->IsFullscreen();
if (needs_no_border && !restored)
return 0;
@ -245,7 +238,7 @@ void WinFrameView::LayoutCaptionButtons() {
return;
// Non-custom system titlebar already contains caption buttons.
if (!ShouldCustomDrawSystemTitlebar()) {
if (!window()->IsWindowControlsOverlayEnabled()) {
caption_button_container_->SetVisible(false);
return;
}