Skip to content

Extend the Close button to the window's right edge - #5590

Merged
Gabriel Dufresne (GabrielDuf) merged 1 commit into
mainfrom
fix/caption-buttons-right-edge
Oct 23, 2026
Merged

Gabriel Dufresne (GabrielDuf) merged 1 commit into
mainfrom
fix/caption-buttons-right-edge

Conversation

@GabrielDuf

@GabrielDuf Gabriel Dufresne (GabrielDuf) commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #5571

When the window isn't maximized, the Close button stopped a few pixels short of the window's right edge: about 8 px at 100% scaling, and more at higher DPI.

Cause

#5477 added a right margin to the caption-button strip, equal to the WS_THICKFRAME width, so the side resize border would take priority over the buttons. Our WM_NCCALCSIZE handler makes the client area cover the whole window, so that frame band is visible window area, and the margin showed up as an empty strip next to Close.

The margin was never needed for hit-testing. The WM_NCHITTEST handler already returns the side resize edge before it looks at the caption buttons.

Fix

The strip is no longer pushed left. Instead, the Close button is widened by the inset and its padding keeps the X centred over the 46 px you can click. The red hover fill now reaches the edge, as it does in native Windows 11 apps, and the outer band still resizes. When maximized the inset is 0, so Close stays at 46 px.

Trade-off

Native apps keep their resize band in an invisible margin outside the visible edge. UniGetUI has none, so the outermost few pixels of the red Close fill show a resize cursor instead of closing the window. The alternative is the empty strip this issue reports.

Verification

  • Built x64 Debug: 0 errors.
  • dotnet format whitespace and dotnet format style with --verify-no-changes: both exit 0.
  • Checked manually on Windows 11: Close reaches the edge, and the right edge still resizes.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused layout change preserves existing resize behavior and icon positioning, with no blocking issues identified.

No open issues 🎉

What changed in this PR

Fixes #5571 by extending the Close button’s background to the window’s right edge without changing resize-edge hit-testing.

Changes:

  • Names the Close button so its layout can be adjusted in code.
  • Replaces the caption-strip margin with extra Close-button width and padding, preserving icon placement and the maximized layout.
File Description
src/​UniGetUI.Avalonia/​Views/​MainWindow.axaml.cs Applies the frame inset to Close-button width and padding instead of strip margin.
src/​UniGetUI.Avalonia/​Views/​MainWindow.axaml Names the Close button for code-behind access.

Review effort: Balanced

@randy-but-a-ro randy-but-a-ro Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Pull request was approved automatically: the AI review is complete and all its review threads are resolved. 🎉

Integration Details
{
	"deliveryId": "6ab7ec10-cf14-11f1-937c-7b466fb274b9",
	"headSha": "db791b4e08cf9fb96ccb55fdf30413bc8a4ee8c1",
	"reviewer": "copilot-pull-request-reviewer[bot]"
}

@GabrielDuf
Gabriel Dufresne (GabrielDuf) merged commit 23d4b46 into main Oct 23, 2026
6 checks passed
@GabrielDuf
Gabriel Dufresne (GabrielDuf) deleted the fix/caption-buttons-right-edge branch October 23, 2026 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Misplaced Caption Buttons

2 participants