mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-06-07 09:28:03 +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
|
dlls
|
||||||
DNLEN
|
DNLEN
|
||||||
doctype
|
doctype
|
||||||
|
DONOTROUND
|
||||||
DONTVALIDATEPATH
|
DONTVALIDATEPATH
|
||||||
dotnet
|
dotnet
|
||||||
DOverlay
|
DOverlay
|
||||||
@ -543,6 +544,8 @@ Dwmp
|
|||||||
DWMSENDICONICLIVEPREVIEWBITMAP
|
DWMSENDICONICLIVEPREVIEWBITMAP
|
||||||
DWMSENDICONICTHUMBNAIL
|
DWMSENDICONICTHUMBNAIL
|
||||||
DWMWA
|
DWMWA
|
||||||
|
DWMWCP
|
||||||
|
DWMWINDOWATTRIBUTE
|
||||||
DWMWINDOWMAXIMIZEDCHANGE
|
DWMWINDOWMAXIMIZEDCHANGE
|
||||||
dword
|
dword
|
||||||
dworigin
|
dworigin
|
||||||
@ -1817,6 +1820,7 @@ robocopy
|
|||||||
Roboto
|
Roboto
|
||||||
roslyn
|
roslyn
|
||||||
Rothera
|
Rothera
|
||||||
|
ROUNDSMALL
|
||||||
royvou
|
royvou
|
||||||
Rpc
|
Rpc
|
||||||
RRF
|
RRF
|
||||||
|
@ -19,6 +19,21 @@ namespace NonLocalizable
|
|||||||
const wchar_t SystemAppsFolder[] = L"SYSTEMAPPS";
|
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
|
namespace
|
||||||
{
|
{
|
||||||
BOOL CALLBACK saveDisplayToVector(HMONITOR monitor, HDC hdc, LPRECT rect, LPARAM data)
|
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);
|
ScreenToWorkAreaCoords(window, rect);
|
||||||
|
|
||||||
placement.rcNormalPosition = 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;
|
placement.flags |= WPF_ASYNCWINDOWPLACEMENT;
|
||||||
|
|
||||||
::SetWindowPlacement(window, &placement);
|
::SetWindowPlacement(window, &placement);
|
||||||
@ -373,6 +393,11 @@ void FancyZonesWindowUtils::RestoreWindowSize(HWND window) noexcept
|
|||||||
SizeWindowToRect(window, rect);
|
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);
|
::RemoveProp(window, ZonedWindowProperties::PropertyRestoreSizeID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user