Skip to content

Hit-test the resize border instead of borrowing Avalonia's - #5474

Merged
Gabriel Dufresne (GabrielDuf) merged 1 commit into
mainfrom
fix/5471-window-resize-border-hit-test
Oct 5, 2026
Merged

Gabriel Dufresne (GabrielDuf) merged 1 commit into
mainfrom
fix/5471-window-resize-border-hit-test

Conversation

@GabrielDuf

Copy link
Copy Markdown
Contributor

This pull request adds logic to improve window resizing behavior by implementing custom hit testing for the window borders. The main changes include defining additional hit test constants, adding a new HitTestResizeBorder method, integrating this logic into the window procedure, and adding a native interop method for retrieving the window rectangle.

Window resizing and hit testing improvements:

  • Defined additional hit test constants (HTLEFT, HTRIGHT, HTTOP, HTTOPLEFT, HTTOPRIGHT, HTBOTTOM, HTBOTTOMLEFT, HTBOTTOMRIGHT, HTNOWHERE) to support more precise window edge detection.
  • Added the HitTestResizeBorder method to determine which border or corner of the window is being interacted with, enabling custom resize behavior.
  • Integrated the new hit test logic into the window procedure (OnWindowsWndProc) to handle WM_NCHITTEST messages and return the appropriate hit test result, allowing for correct window resizing from all edges and corners.

Native interop enhancements:

  • Added a P/Invoke declaration for GetWindowRect in the NativeMethods class to retrieve the window's dimensions, which is used in the hit testing logic.

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.

Copilot review overview

🟡 Changes recommended

Caption-button hit testing takes precedence and prevents resizing along overlapping top-right borders.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds custom Win32 resize-border hit testing for the Avalonia main window.

Changes:

  • Detects all resize edges and corners.
  • Handles WM_NCHITTEST using calculated border regions.
  • Adds GetWindowRect interop.
File Description
src/​UniGetUI.Avalonia/​Views/​MainWindow.axaml.cs Implements native resize-border hit testing and required interop.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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.

Copilot review overview

🔵 Needs a closer look

Native window hit testing requires manual validation across DPI levels, monitor layouts, snapping, and window states.

Review effort: Balanced
Findings: None

Resolved since last review (1)

@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": "fd8de190-c0df-11f1-8c95-f112a5288bc6",
	"headSha": "c870d0f6381c68245212aaa9cdfeb34ea865d03b",
	"reviewer": "copilot-pull-request-reviewer[bot]"
}

@GabrielDuf
Gabriel Dufresne (GabrielDuf) merged commit fa3ab16 into main Oct 5, 2026
7 checks passed
@GabrielDuf
Gabriel Dufresne (GabrielDuf) deleted the fix/5471-window-resize-border-hit-test branch October 5, 2026 17:13
@GabrielDuf Gabriel Dufresne (GabrielDuf) linked an issue Oct 5, 2026 that may be closed by this pull request
4 tasks done
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] Cannot resize the window when video acceleration is off

2 participants