[FancyZones] Fix canvas layout with scaling reset issue (#17186)

* canvas scaling

* predef layout check

* return false on custom layout error

* clean up

* update unit tests

* spelling

* floating point convert

* fix build
This commit is contained in:
Seraphima Zykova
2022-03-25 19:09:59 +03:00
committed by GitHub
parent 403969587e
commit 4aadaf9bf1
16 changed files with 651 additions and 723 deletions

View File

@@ -44,7 +44,7 @@ namespace DPIAware
return GetScreenDPIForMonitor(targetMonitor, dpi);
}
void Convert(HMONITOR monitor_handle, int& width, int& height)
void Convert(HMONITOR monitor_handle, float& width, float& height)
{
if (monitor_handle == NULL)
{
@@ -55,12 +55,12 @@ namespace DPIAware
UINT dpi_x, dpi_y;
if (GetDpiForMonitor(monitor_handle, MDT_EFFECTIVE_DPI, &dpi_x, &dpi_y) == S_OK)
{
width = width * static_cast<int>(dpi_x) / DEFAULT_DPI;
height = height * static_cast<int>(dpi_y) / DEFAULT_DPI;
width = width * dpi_x / DEFAULT_DPI;
height = height * dpi_y / DEFAULT_DPI;
}
}
void ConvertByCursorPosition(int& width, int& height)
void ConvertByCursorPosition(float& width, float& height)
{
HMONITOR targetMonitor = nullptr;
POINT currentCursorPos{ 0 };
@@ -73,7 +73,7 @@ namespace DPIAware
Convert(targetMonitor, width, height);
}
void InverseConvert(HMONITOR monitor_handle, int& width, int& height)
void InverseConvert(HMONITOR monitor_handle, float& width, float& height)
{
if (monitor_handle == NULL)
{
@@ -84,8 +84,8 @@ namespace DPIAware
UINT dpi_x, dpi_y;
if (GetDpiForMonitor(monitor_handle, MDT_EFFECTIVE_DPI, &dpi_x, &dpi_y) == S_OK)
{
width = width * DEFAULT_DPI / static_cast<int>(dpi_x);
height = height * DEFAULT_DPI / static_cast<int>(dpi_y);
width = width * DEFAULT_DPI / dpi_x;
height = height * DEFAULT_DPI / dpi_y;
}
}

View File

@@ -11,9 +11,9 @@ namespace DPIAware
HRESULT GetScreenDPIForWindow(HWND hwnd, UINT& dpi);
HRESULT GetScreenDPIForPoint(POINT p, UINT& dpi);
HRESULT GetScreenDPIForCursor(UINT& dpi);
void Convert(HMONITOR monitor_handle, int& width, int& height);
void ConvertByCursorPosition(int& width, int& height);
void InverseConvert(HMONITOR monitor_handle, int& width, int& height);
void Convert(HMONITOR monitor_handle, float& width, float& height);
void ConvertByCursorPosition(float& width, float& height);
void InverseConvert(HMONITOR monitor_handle, float& width, float& height);
void EnableDPIAwarenessForThisProcess();
enum AwarenessLevel