fix: Wayland general CSD fixes (#34955)

* fix: broken wayland window decorations due to botched chromium update

The `GetTitlebarBounds().height()` is obviously intended to be placed in
the `top` parameter, which used to be the second one before upstream
removed multi-parameter `gfx::Rect::Inset`, but it's the first parameter
for `gfx::Insets::TLBR`, which was intended to replace the removed
`Inset` function. However, whoever updated Chromium kept the parameter
unchanged, causing the title bar height to be passed to the `left`
parameter, causing the window title bar to be unclickable.

* fix: wayland window top bar buttons unclickable

Use NonClientFrameView::TargetForRect for the ClientFrameViewLinux
implementation because the default inherited from FramelessView blocks
any non-HTCLIENT events.

* fix: add maximized parameter to LinuxUI::GetWindowFrameProvider

* fix: pass frame_->IsMaximized() to GetWindowFrameProvider

This ensures that the toolkit renders the window decorations in maximized mode
while the window is maximized to ensure that there is no empty space around the window.
This commit is contained in:
msizanoen1 2022-08-03 15:51:52 +07:00 committed by GitHub
parent 4e8480b15b
commit 7b8fb2b074
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 190 additions and 2 deletions

View file

@ -131,7 +131,7 @@ void ClientFrameViewLinux::Init(NativeWindowViews* window,
host_supports_client_frame_shadow_ = tree_host->SupportsClientFrameShadow();
frame_provider_ = ui::LinuxUi::instance()->GetWindowFrameProvider(
!host_supports_client_frame_shadow_);
!host_supports_client_frame_shadow_, frame_->IsMaximized());
UpdateWindowTitle();
@ -202,7 +202,7 @@ gfx::Rect ClientFrameViewLinux::GetBoundsForClientView() const {
if (!frame_->IsFullscreen()) {
client_bounds.Inset(GetBorderDecorationInsets());
client_bounds.Inset(
gfx::Insets::TLBR(0, GetTitlebarBounds().height(), 0, 0));
gfx::Insets::TLBR(GetTitlebarBounds().height(), 0, 0, 0));
}
return client_bounds;
}
@ -274,6 +274,9 @@ void ClientFrameViewLinux::Layout() {
return;
}
frame_provider_ = ui::LinuxUi::instance()->GetWindowFrameProvider(
!host_supports_client_frame_shadow_, frame_->IsMaximized());
UpdateButtonImages();
LayoutButtons();
@ -485,4 +488,9 @@ gfx::Size ClientFrameViewLinux::SizeWithDecorations(gfx::Size size) const {
return size;
}
views::View* ClientFrameViewLinux::TargetForRect(views::View* root,
const gfx::Rect& rect) {
return views::NonClientFrameView::TargetForRect(root, rect);
}
} // namespace electron

View file

@ -67,6 +67,9 @@ class ClientFrameViewLinux : public FramelessView,
void OnPaint(gfx::Canvas* canvas) override;
const char* GetClassName() const override;
// Overriden from views::ViewTargeterDelegate
views::View* TargetForRect(views::View* root, const gfx::Rect& rect) override;
private:
static constexpr int kNavButtonCount = 4;