microsoft / microsoft/microsoft-ui-xaml
InputNonClientPointerSource.SetRegionRects with NonClientRegionKind.Passthrough fails to apply the provided excluded regions when Display scale is changed to higher value
- Dominant language
- C++
- Stars
- 8.4k
- Forks
- 942
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 105
Description
### Describe the bug
Using the full example at https://learn.microsoft.com/en-us/windows/apps/develop/title-bar, with modified toolbar layout. The calculation of the excluded rectangles is fully detailed in the application debug traces below. The calculation is correct, and works as long as the Display scale is not changed or is set to a lower value. Note that reproduction works with changing the Display Scale in the Settings App or by dragging the window between two monitors with different Display Scale.
If the Display Scale is changed to a Higher value (from 150% to 175% for example), the calculation of the excluded region is correct, but the call to `InputNonClientPointerSource.SetRegionRects()` does not properly apply the regions. The old rectangle for the padding right in the traces below is still the one active.
```
SetRegionsForCustomTitleBar: 1.75
SetRegionsForCustomTitleBar: padding left=0 , right=123.42857360839844
SetRegionsForCustomTitleBar: primary width=46 , height=46
SetRegionsForCustomTitleBar: secondary width=92 , height=46
--> Change Scale to 150% , rectangles properly excluded
SetRegionsForCustomTitleBar
SetRegionsForCustomTitleBar: 1.5
SetRegionsForCustomTitleBar: padding left=0 , right=144
SetRegionsForCustomTitleBar: primary width=40 , height=39
SetRegionsForCustomTitleBar: secondary width=79 , height=39
--> Change Scale back to 175%, rectangles not properly excluded, the right padding area is still as if it were 144
SetRegionsForCustomTitleBar
SetRegionsForCustomTitleBar: 1.75
SetRegionsForCustomTitleBar: padding left=0 , right=123.42857360839844
SetRegionsForCustomTitleBar: primary width=46 , height=46
SetRegionsForCustomTitleBar: secondary width=92 , height=46
--> Maximize then restore the Window => excluded rectangles are now applied, although the bounds did not change of course.
SetRegionsForCustomTitleBar
SetRegionsForCustomTitleBar: 1.75
SetRegionsForCustomTitleBar: padding left=0 , right=123.42857360839844
SetRegionsForCustomTitleBar: primary width=46 , height=46
SetRegionsForCustomTitleBar: secondary width=92 , height=46
```
### Steps to reproduce the bug
Use the Microsoft sample at https://learn.microsoft.com/en-us/windows/apps/develop/title-bar
Make the PersonPicture interactive, a button for example.
Change Display Scale with Windows 11 Settings App.
### Expected behavior
Excluded regions should be applied as provided when Display scale is set to a higher value or when the application window is moved across monitors with different display scale, or when they are programmatically changed... Basically honor the rectangles provided to the API call.
### Screenshots
_No response_
### NuGet package version
WinUI 3 - Windows App SDK 1.6.1: 1.6.240923002
### Windows version
Windows 11 (22H2): Build 22621
### Additional context
_No response_
Contributor guide
Research direction
Start with the Microsoft title-bar sample linked in the issue and reproduce the sequence of changing Display scale from 150% to 175%, including moving the window between monitors. Inspect the calls to InputNonClientPointerSource.SetRegionRects and the logged rectangle values. Done means the newly provided excluded regions are honored after a higher scale change without requiring maximize and restore.
Written by the indexing model from the issue text.
Assessment
- Domain
- desktop, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100