mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-06-07 01:08:18 +08:00
[FancyZones] Set correct corner preference when snapping windows on Windows 11 (#16542)
* [FancyZones] Set correct corner preference when snapping windows on Windows 11 * Changed magic numbers to use enum values. * Added missing words to spell check list. * Changed note: to todo: for future visibility * Changed note: to todo: for future visibility
This commit is contained in:
parent
81f61630cb
commit
b20e991a35
4
.github/actions/spell-check/expect.txt
vendored
4
.github/actions/spell-check/expect.txt
vendored
@ -501,6 +501,7 @@ dllmain
|
||||
dlls
|
||||
DNLEN
|
||||
doctype
|
||||
DONOTROUND
|
||||
DONTVALIDATEPATH
|
||||
dotnet
|
||||
DOverlay
|
||||
@ -543,6 +544,8 @@ Dwmp
|
||||
DWMSENDICONICLIVEPREVIEWBITMAP
|
||||
DWMSENDICONICTHUMBNAIL
|
||||
DWMWA
|
||||
DWMWCP
|
||||
DWMWINDOWATTRIBUTE
|
||||
DWMWINDOWMAXIMIZEDCHANGE
|
||||
dword
|
||||
dworigin
|
||||
@ -1817,6 +1820,7 @@ robocopy
|
||||
Roboto
|
||||
roslyn
|
||||
Rothera
|
||||
ROUNDSMALL
|
||||
royvou
|
||||
Rpc
|
||||
RRF
|
||||
|
@ -19,6 +19,21 @@ namespace NonLocalizable
|
||||
const wchar_t SystemAppsFolder[] = L"SYSTEMAPPS";
|
||||
}
|
||||
|
||||
// Placeholder enums since dwmapi.h doesn't have these until SDK 22000.
|
||||
// TODO: Remove once SDK targets 22000 or above.
|
||||
enum DWMWINDOWATTRIBUTE_CUSTOM
|
||||
{
|
||||
DWMWA_WINDOW_CORNER_PREFERENCE = 33
|
||||
};
|
||||
|
||||
enum DWM_WINDOW_CORNER_PREFERENCE
|
||||
{
|
||||
DWMWCP_DEFAULT = 0,
|
||||
DWMWCP_DONOTROUND = 1,
|
||||
DWMWCP_ROUND = 2,
|
||||
DWMWCP_ROUNDSMALL = 3
|
||||
};
|
||||
|
||||
namespace
|
||||
{
|
||||
BOOL CALLBACK saveDisplayToVector(HMONITOR monitor, HDC hdc, LPRECT rect, LPARAM data)
|
||||
@ -316,6 +331,11 @@ void FancyZonesWindowUtils::SizeWindowToRect(HWND window, RECT rect) noexcept
|
||||
ScreenToWorkAreaCoords(window, rect);
|
||||
|
||||
placement.rcNormalPosition = rect;
|
||||
|
||||
// Set window corner preference on Windows 11 to "Do not round"
|
||||
int corner_preference = DWMWCP_DONOTROUND;
|
||||
DwmSetWindowAttribute(window, DWMWA_WINDOW_CORNER_PREFERENCE, &corner_preference, sizeof(corner_preference));
|
||||
|
||||
placement.flags |= WPF_ASYNCWINDOWPLACEMENT;
|
||||
|
||||
::SetWindowPlacement(window, &placement);
|
||||
@ -373,6 +393,11 @@ void FancyZonesWindowUtils::RestoreWindowSize(HWND window) noexcept
|
||||
SizeWindowToRect(window, rect);
|
||||
}
|
||||
|
||||
// Set window corner preference on Windows 11 to "Default"
|
||||
// TODO: Should probably store preference from before snap
|
||||
int corner_preference = DWMWCP_DEFAULT;
|
||||
DwmSetWindowAttribute(window, DWMWA_WINDOW_CORNER_PREFERENCE, &corner_preference, sizeof(corner_preference));
|
||||
|
||||
::RemoveProp(window, ZonedWindowProperties::PropertyRestoreSizeID);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user