From 693487313d8dfd3f5c41ca68fa8f631bb9fadb62 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 21 May 2020 15:05:28 -0300 Subject: [PATCH] fix hit testing. --- .../WindowImpl.CustomCaptionProc.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Windows/Avalonia.Win32/WindowImpl.CustomCaptionProc.cs b/src/Windows/Avalonia.Win32/WindowImpl.CustomCaptionProc.cs index a55a22c3c3..fee6bb90bf 100644 --- a/src/Windows/Avalonia.Win32/WindowImpl.CustomCaptionProc.cs +++ b/src/Windows/Avalonia.Win32/WindowImpl.CustomCaptionProc.cs @@ -1,6 +1,5 @@ using System; -using System.Collections.Generic; -using System.Text; +using System.Diagnostics; using Avalonia.Controls; using Avalonia.Input; using static Avalonia.Win32.Interop.UnmanagedMethods; @@ -34,6 +33,11 @@ namespace Avalonia.Win32 border_thickness = new RECT { bottom = 1, left = 1, right = 1, top = 1 }; } + if (_extendTitleBarHint >= 0) + { + border_thickness.top = (int)(_extendedMargins.Top * Scaling); + } + // Determine if the hit test is for resizing. Default middle (1,1). ushort uRow = 1; ushort uCol = 1; @@ -86,11 +90,13 @@ namespace Avalonia.Win32 case WindowsMessage.WM_NCHITTEST: if (lRet == IntPtr.Zero) { - lRet = (IntPtr)HitTestNCA(hWnd, wParam, lParam); + var hittestResult = HitTestNCA(hWnd, wParam, lParam); + + lRet = (IntPtr)hittestResult; uint timestamp = unchecked((uint)GetMessageTime()); - if (((HitTestValues)lRet) == HitTestValues.HTCAPTION) + if (hittestResult == HitTestValues.HTCAPTION) { var position = PointToClient(PointFromLParam(lParam)); @@ -106,11 +112,12 @@ namespace Avalonia.Win32 if (visual != null) { - lRet = (IntPtr)HitTestValues.HTCLIENT; + hittestResult = HitTestValues.HTCLIENT; + lRet = (IntPtr)hittestResult; } } - if (((HitTestValues)lRet) != HitTestValues.HTNOWHERE) + if (hittestResult != HitTestValues.HTNOWHERE) { callDwp = false; }