Browse Source

Fix caption hit test.

pull/4857/head
Dariusz Komosinski 6 years ago
parent
commit
ba8b49d918
  1. 25
      src/Windows/Avalonia.Win32/WindowImpl.CustomCaptionProc.cs

25
src/Windows/Avalonia.Win32/WindowImpl.CustomCaptionProc.cs

@ -44,12 +44,25 @@ namespace Avalonia.Win32
ushort uCol = 1;
bool onResizeBorder = false;
// Determine if the point is at the left or right of the window.
if (ptMouse.X >= rcWindow.left && ptMouse.X < rcWindow.left + borderThickness.left)
{
uCol = 0; // left side
}
else if (ptMouse.X < rcWindow.right && ptMouse.X >= rcWindow.right - borderThickness.right)
{
uCol = 2; // right side
}
// Determine if the point is at the top or bottom of the window.
if (ptMouse.Y >= rcWindow.top && ptMouse.Y < rcWindow.top + borderThickness.top)
{
onResizeBorder = (ptMouse.Y < (rcWindow.top - rcFrame.top));
if (onResizeBorder)
// Two cases where we have a valid row 0 hit test:
// - window resize border (top resize border hit)
// - area below resize border that is actual titlebar (caption hit).
if (onResizeBorder || uCol == 1)
{
uRow = 0;
}
@ -59,16 +72,6 @@ namespace Avalonia.Win32
uRow = 2;
}
// Determine if the point is at the left or right of the window.
if (ptMouse.X >= rcWindow.left && ptMouse.X < rcWindow.left + borderThickness.left)
{
uCol = 0; // left side
}
else if (ptMouse.X < rcWindow.right && ptMouse.X >= rcWindow.right - borderThickness.right)
{
uCol = 2; // right side
}
ReadOnlySpan<HitTestValues> hitZones = stackalloc HitTestValues[]
{
HitTestValues.HTTOPLEFT, onResizeBorder ? HitTestValues.HTTOP : HitTestValues.HTCAPTION,

Loading…
Cancel
Save