From 2c3c4e7519ec270deb7a4c1f3d274c43a6cb1194 Mon Sep 17 00:00:00 2001 From: Bret Anderson Date: Mon, 16 Sep 2019 12:48:55 -0700 Subject: [PATCH] Need to adjust x/y by scaled diff between monitor and work area rect --- src/modules/fancyzones/lib/FancyZones.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/modules/fancyzones/lib/FancyZones.cpp b/src/modules/fancyzones/lib/FancyZones.cpp index 0b578add72..2e3d143556 100644 --- a/src/modules/fancyzones/lib/FancyZones.cpp +++ b/src/modules/fancyzones/lib/FancyZones.cpp @@ -253,10 +253,17 @@ void FancyZones::ToggleEditor() noexcept mi.cbSize = sizeof(mi); GetMonitorInfo(monitor, &mi); + // X/Y need to start in unscaled screen coordinates to get to the proper top/left of the monitor + // From there, we need to scale the difference between the monitor and workarea rects to get the + // appropriate offset where the overlay should appear. + // This covers the cases where the taskbar is not at the bottom of the screen. + const auto x = mi.rcMonitor.left + MulDiv(mi.rcWork.left - mi.rcMonitor.left, 96, dpi_x); + const auto y = mi.rcMonitor.top + MulDiv(mi.rcWork.top - mi.rcMonitor.top, 96, dpi_y); + // Location that the editor should occupy, scaled by DPI std::wstring editorLocation = - std::to_wstring(MulDiv(mi.rcWork.left, 96, dpi_x)) + L"_" + - std::to_wstring(MulDiv(mi.rcWork.top, 96, dpi_y)) + L"_" + + std::to_wstring(x) + L"_" + + std::to_wstring(y) + L"_" + std::to_wstring(MulDiv(mi.rcWork.right - mi.rcWork.left, 96, dpi_x)) + L"_" + std::to_wstring(MulDiv(mi.rcWork.bottom - mi.rcWork.top, 96, dpi_y));