Skip to content

Center the close glyph and size Close like the other caption buttons - #5644

Merged
Gabriel Dufresne (GabrielDuf) merged 1 commit into
mainfrom
fix/issue-5637
Nov 2, 2026
Merged

Gabriel Dufresne (GabrielDuf) merged 1 commit into
mainfrom
fix/issue-5637

Conversation

@GabrielDuf

Copy link
Copy Markdown
Contributor
  • I have read the contributing guidelines, and I agree with the Code of Conduct.
  • Have you checked that there aren't other open pull requests for the same changes?
  • Have you tested that the committed code can be executed without errors?
  • Have you confirmed that this issue is caused by UniGetUI itself, and not by the package manager or the package involved?

Root cause

The custom Windows caption strip is right-aligned in a client area that covers the whole window: the WM_NCCALCSIZE hook returns 0, so the WS_THICKFRAME band (about 8 px at 100%, more at higher DPI) is visible client area. #5477 added MainWindow.UpdateCaptionButtonInset, which measured that band and pushed the strip left by it. #5590 kept the measurement but set CaptionCloseButton.Width = 46 + inset and Padding = (0,0,inset,0). The Close button's background is the full Button bounds, so on a restored window its gray and red hover fill became wider than Minimize and Maximize, and the right padding centred the X over the left 46 px only, leaving it off-centre in the visible button. Maximized, the inset is 0, which is why it only shows on a restored window.

The extra width was never needed for hit-testing: #5477 also made WM_NCHITTEST return the side and corner resize edges (HitTestResizeBorder) before testing the caption buttons, and that ordering keeps the outer band resizing.

Fix

Removed the per-state inset adjustment. Close is now the same fixed 46x44 button as Minimize and Maximize, flush with the window's right edge, with the X centred by the caption style's Padding=0. Deleted UpdateCaptionButtonInset, its two callers (the WM_SHOWWINDOW/WM_SIZE post goes back to Dispatcher.UIThread.Post(cornerOwner.UpdateWindowCornerPreference)), and the unused x:Name="CaptionCloseButton". The hit-test ordering from #5477 is kept. Close reaches the window edge (#5571) and the three buttons are identical with a centred glyph (#5637).

Verification

  • dotnet build src/UniGetUI.Avalonia/UniGetUI.Avalonia.csproj -p:Platform=x64 -p:UseSharedCompilation=false exited 0 with 0 errors (warnings are unrelated analyzer and obsolete-API ones; not compared against a baseline).
  • dotnet format whitespace and dotnet format style --verify-no-changes on the changed files exited 0.
  • Not checked visually: no screenshots were taken. Please check the restored-window caption row at 100% and a higher DPI.
  • The full test suite is left to CI.

Regression test

None added. The bug is native window-chrome layout driven by a live Win32 HWND (IsZoomed, GetDpiForWindow, AdjustWindowRectExForDpi inside the WM_SHOWWINDOW/WM_SIZE hook). No unit test can reach that without a real top-level window, and after the fix no logic is left: the button is a static 46x44 declaration.

Review notes (non-blocking)


Closes #5637

🤖 Generated with Claude Code

The Close caption button was widened by the window frame inset and given
matching right padding. Its hover fill is the full button bounds, so on a
restored window it was wider than Minimize and Maximize, and the X was centered
over only the leftmost 46 px, landing off-center in the visible button.

The extra width was never needed for hit-testing: the side and corner resize
edges are returned before the caption buttons, which keeps the outer band
resizing. Remove the per-state inset adjustment so Close is a fixed 46x44
button like its siblings, flush with the right edge, with the glyph centered
by the caption style's zero padding. The outermost frame-width pixels of Close
still resize rather than close, as they did after the previous change.

Fixes #5637

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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.

🔵 Needs a closer look

The caption-button fix lacks live Windows verification of alignment, glyph centering, and edge-resize behavior in restored and maximized states at 100% and higher DPI.

No open issues 🎉

What changed in this PR

Fixes the restored-window Close button’s unequal width and off-center glyph by removing its dynamic inset adjustment. This addresses #5637 while preserving right-edge alignment and resize hit-testing.

Changes:

  • Keeps Close at the same fixed 46×44 size as the other caption buttons.
  • Removes the inset calculation and its startup/window-state callbacks.
  • Removes the unused Close button name from XAML.
File Description
src/​UniGetUI.Avalonia/​Views/​MainWindow.axaml.cs Removes dynamic Close button sizing and simplifies the window-state callback.
src/​UniGetUI.Avalonia/​Views/​MainWindow.axaml Removes the unused button name while retaining fixed dimensions and caption styling.

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": "630813b0-d472-11f1-854c-87c99f39ebcf",
	"headSha": "d0a0667acc767feeed88cb46d4e508a932ab7201",
	"reviewer": "copilot-pull-request-reviewer[bot]"
}

@GabrielDuf
Gabriel Dufresne (GabrielDuf) merged commit fb36408 into main Nov 2, 2026
7 checks passed
@GabrielDuf
Gabriel Dufresne (GabrielDuf) deleted the fix/issue-5637 branch November 2, 2026 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Development

Successfully merging this pull request may close these issues.

[BUG] Close Button Has Incorrect Dimensions; Glyph Is Off-Center

2 participants