microsoft / microsoft/microsoft-ui-xaml

InputNonClientPointerSource.SetRegionRects seems to do not work when used with NonClientRegionKind.Maximize

Open
#10,762 4 comments 0 reactions 0 assignees View on GitHub
area-TitleBar bug team-Core
Dominant language
C++
Stars
8.4k
Forks
942
Avg merge
2d 7h
Merged PRs (30d)
105

Description

### Describe the bug

When ExtendsContentIntoTitleBar is true and an UIElement has been set as title bar by Window.SetTitleBar, use InputNonClientPointerSource.SetRegionRects with the region parameter is NonClientRegionKind.Maximize to set an area as maximize button area. When the pointer hovering on the maximize button area, the Snap Layout on Windows 11 does not appear.

### Why is this important?

- The built-in title bar acts not very similarly to native title bar on Windows 11: close button hovering background is dark red in native title bar on Windows 11 but is lighter red in WinUI 3, looking more like to UWP on Windows 10.
- Some apps need custom title bar including caption buttons, so developers need to adapt the title bar to Windows 11 Snap Layout.

### Steps to reproduce the bug

1. Create a new WinUI 3 application project.
2. Set ```ExtendsContentIntoTitleBar = true``` in MainWindow.
3. When the root elements is Loaded, set title bar for MainWindow.
``` xaml








```
``` C#
using Microsoft.UI.Input;
using Microsoft.UI.Xaml;

using Windows.Graphics;

namespace InputNonClientPointerSourceIssue;

public sealed partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
ExtendsContentIntoTitleBar = true;
}

private void Grid_Loaded(object sender, RoutedEventArgs e)
{
SetTitleBar(TitleBarDragArea);
InputNonClientPointerSource
.GetForWindowId(AppWindow.Id)
.SetRegionRects(NonClientRegionKind.Maximize, [new RectInt32
{
X = 0,
Y = 0,
Width = (int) (30 * Content.XamlRoot.RasterizationScale),
Height = (int) (30 * Content.XamlRoot.RasterizationScale)
}]);
}
}
```
4. Hover the pointer on the left top rectagle area but there is no Snap Layout popup shows on Windows 11.

### Actual behavior

Hover the pointer on the left top rectagle area that was set as NonClientRegionKind.Maximize region but there is no Snap Layout popup shows on Windows 11.

### Expected behavior

When pointer hovering on the region that set as NonClientRegionKind.Maximize by InputNonClientPointerSource.SetRegionRects on Windows 11, the Snap Layout popup should appear.

### Screenshots

The region on the top left is my NonClientRegionKind.Maximize region, but hovering pointer on it does not make Snap Layout popup appear like the actual maximize button.

Image

### NuGet package version

WinUI 3 - Windows App SDK 1.7.3: 1.7.250606001

### Windows version

Windows 11 (24H2): Build 26100

### Additional context

I had tried to set my region NonClientRegionKind.Passthrough, the region cannot by drag as expected. It may ensure:

- Setting NonClientRegionKind.Passthrough acts properly.
- My area rect is passed to SetRegionRects correctly but it does not act properly.

``` C#
private void Grid_Loaded(object sender, RoutedEventArgs e)
{
SetTitleBar(TitleBarDragArea);
InputNonClientPointerSource
.GetForWindowId(AppWindow.Id)
.SetRegionRects(NonClientRegionKind.Passthrough, [new RectInt32
{
X = 0,
Y = 0,
Width = (int) (30 * Content.XamlRoot.RasterizationScale),
Height = (int) (30 * Content.XamlRoot.RasterizationScale)
}]);
}
```

Contributor guide

Open the contributing guide

Research direction

Start with the supplied WinUI 3 repro and the Grid_Loaded entry point, focusing on InputNonClientPointerSource.SetRegionRects with NonClientRegionKind.Maximize and Passthrough. Run it on Windows 11 24H2 with Windows App SDK 1.7.3 and compare the custom region with the native maximize button; done means the configured maximize region shows Snap Layout while Passthrough still permits dragging.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.