dotnet / dotnet/wpf

Bug: WindowChromeWorker Precedence in HitTest is Incorrect

Open
#3,741 1 comment 1 reaction 0 assignees View on GitHub
Bug
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

https://github.com/dotnet/wpf/blob/ac9d1b7a6b0ee7c44fd2875a1174b820b3940619/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Shell/WindowChromeWorker.cs#L673

```
if (WindowChrome.GetIsHitTestVisibleInChrome(inputElement))
{
handled = true;
return new IntPtr((int)HT.CLIENT);
}

ResizeGripDirection direction = WindowChrome.GetResizeGripDirection(inputElement);
if (direction != ResizeGripDirection.None)
{
handled = true;
return new IntPtr((int)_GetHTFromResizeGripDirection(direction));
}
```

**Order of check is incorrect here.**

ResizeGrip should take precedence over IsHitTestVisibleInChrome. If you check existing Windows apps, you should have resize grip when you hover over the top of DWM caption button, before seeing the input. If you create custom caption buttons in DWM, you can no longer get the Resize Grip when you hover over the top of the buttons, this is not the expected behavior. I have root caused it to this conditional.

**Actual code should be:**

```
ResizeGripDirection direction = WindowChrome.GetResizeGripDirection(inputElement);
if (direction != ResizeGripDirection.None)
{
handled = true;
return new IntPtr((int)_GetHTFromResizeGripDirection(direction));
}

if (WindowChrome.GetIsHitTestVisibleInChrome(inputElement))
{
handled = true;
return new IntPtr((int)HT.CLIENT);
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.