-
Notifications
You must be signed in to change notification settings - Fork 770
Open
Labels
area-WindowingbugSomething isn't workingSomething isn't workingteam-CompInputIssue for IXP (Composition, Input) teamIssue for IXP (Composition, Input) team
Description
Describe the bug
I am using InputNonClientPointerSource
to set the maximize button region of a win32 window (created with CreateWindow
), but it secretly reverts back to default 32px width and position when the window is activated the second time. This event can even be caught using RegionsChanged
event.
Steps to reproduce the bug
- Create a normal win32 window
static HWND CreateWin32Window()
{
const wchar_t CLASS_NAME[] = L"Sample Window Class";
WNDCLASS wc = {};
wc.lpfnWndProc = WindowProc; // Pointer to the window procedure
wc.lpszClassName = CLASS_NAME; // Window class name
// Register the window class
RegisterClass(&wc);
// Create the window
HWND hwnd = CreateWindowEx(
0, // Optional window styles
CLASS_NAME, // Window class
L"Sample Window", // Window text
WS_OVERLAPPEDWINDOW, // Window style
// Size and position
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, // Parent window
NULL, // Menu
NULL, // Instance handle
NULL // Additional application data
);
ShowWindow(hwnd, SW_SHOW);
return hwnd;
}
- Set the region
auto hwnd = CreateWin32Window();
auto windowId = winrt::Microsoft::UI::GetWindowIdFromWindow(hwnd);
auto appWindow = winrt::Microsoft::UI::Windowing::AppWindow::GetFromWindowId(windowId);
appWindow.TitleBar().ExtendsContentIntoTitleBar(true);
auto pointerSource = winrt::Microsoft::UI::Input::InputNonClientPointerSource::GetForWindowId(windowId);
pointerSource.SetRegionRects(
winrt::Microsoft::UI::Input::NonClientRegionKind::Maximize,
{
winrt::Windows::Graphics::RectInt32
{
.X = 0,
.Y = 0,
.Width = 100,
.Height = 100
}
}
);
pointerSource.RegionsChanged([](
winrt::Microsoft::UI::Input::InputNonClientPointerSource const& source,
winrt::Microsoft::UI::Input::NonClientRegionsChangedEventArgs const& arg)
{
// filters the Maximize region change
if (auto regions = arg.ChangedRegions();
std::ranges::find(regions, winrt::Microsoft::UI::Input::NonClientRegionKind::Maximize) != regions.end())
{
auto changedRegions = source.GetRegionRects(winrt::Microsoft::UI::Input::NonClientRegionKind::Maximize);
for (auto region : changedRegions)
{
OutputDebugString(std::format(L"X: {}, Y: {}, Width: {}, Height: {}\n", region.X, region.Y, region.Width, region.Height).data()); // see this message!
}
}
});
Expected behavior
No response
Screenshots
No response
NuGet package version
Windows App SDK 1.6.3: 1.6.250108002
Packaging type
Packaged (MSIX)
Windows version
Windows 11 version 24H2 (22621, October 2024 Update)
IDE
Visual Studio 2022
Additional context
Repro, build and click the button to see.
aquinn39
Metadata
Metadata
Assignees
Labels
area-WindowingbugSomething isn't workingSomething isn't workingteam-CompInputIssue for IXP (Composition, Input) teamIssue for IXP (Composition, Input) team
Type
Projects
Status
Ready