mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
[FancyZones] Custom canvas layouts scaling (#3644)
* Make canvas layout scaling sensitive * Revert "Make canvas layout scaling sensitive" This reverts commit705dab7e36. * Revert "Revert "Make canvas layout scaling sensitive"" This reverts commitb9dd27644c. * Cleanup * Minor refactoring * Address PR comments
This commit is contained in:
@@ -487,7 +487,6 @@ void FancyZones::ToggleEditor() noexcept
|
||||
const auto& fancyZonesData = JSONHelpers::FancyZonesDataInstance();
|
||||
fancyZonesData.CustomZoneSetsToJsonFile(ZoneWindowUtils::GetCustomZoneSetsTmpPath());
|
||||
|
||||
// Do not scale window params by the dpi, that will be done in the editor - see LayoutModel.Apply
|
||||
const auto taskbar_x_offset = mi.rcWork.left - mi.rcMonitor.left;
|
||||
const auto taskbar_y_offset = mi.rcWork.top - mi.rcMonitor.top;
|
||||
const auto x = mi.rcMonitor.left + taskbar_x_offset;
|
||||
|
||||
@@ -853,9 +853,9 @@ namespace JSONHelpers
|
||||
CanvasLayoutInfo info;
|
||||
|
||||
int j = 5;
|
||||
info.referenceWidth = data[j] * 256 + data[j + 1];
|
||||
info.lastWorkAreaWidth = data[j] * 256 + data[j + 1];
|
||||
j += 2;
|
||||
info.referenceHeight = data[j] * 256 + data[j + 1];
|
||||
info.lastWorkAreaHeight = data[j] * 256 + data[j + 1];
|
||||
j += 2;
|
||||
|
||||
int count = data[j++];
|
||||
@@ -1023,8 +1023,9 @@ namespace JSONHelpers
|
||||
json::JsonObject CanvasLayoutInfo::ToJson(const CanvasLayoutInfo& canvasInfo)
|
||||
{
|
||||
json::JsonObject infoJson{};
|
||||
infoJson.SetNamedValue(L"ref-width", json::value(canvasInfo.referenceWidth));
|
||||
infoJson.SetNamedValue(L"ref-height", json::value(canvasInfo.referenceHeight));
|
||||
infoJson.SetNamedValue(L"ref-width", json::value(canvasInfo.lastWorkAreaWidth));
|
||||
infoJson.SetNamedValue(L"ref-height", json::value(canvasInfo.lastWorkAreaHeight));
|
||||
|
||||
json::JsonArray zonesJson;
|
||||
|
||||
for (const auto& [x, y, width, height] : canvasInfo.zones)
|
||||
@@ -1045,8 +1046,9 @@ namespace JSONHelpers
|
||||
try
|
||||
{
|
||||
CanvasLayoutInfo info;
|
||||
info.referenceWidth = static_cast<int>(infoJson.GetNamedNumber(L"ref-width"));
|
||||
info.referenceHeight = static_cast<int>(infoJson.GetNamedNumber(L"ref-height"));
|
||||
info.lastWorkAreaWidth = static_cast<int>(infoJson.GetNamedNumber(L"ref-width"));
|
||||
info.lastWorkAreaHeight = static_cast<int>(infoJson.GetNamedNumber(L"ref-height"));
|
||||
|
||||
json::JsonArray zonesJson = infoJson.GetNamedArray(L"zones");
|
||||
uint32_t size = zonesJson.Size();
|
||||
info.zones.reserve(size);
|
||||
|
||||
@@ -45,8 +45,9 @@ namespace JSONHelpers
|
||||
|
||||
struct CanvasLayoutInfo
|
||||
{
|
||||
int referenceWidth;
|
||||
int referenceHeight;
|
||||
int lastWorkAreaWidth;
|
||||
int lastWorkAreaHeight;
|
||||
|
||||
struct Rect
|
||||
{
|
||||
int x;
|
||||
|
||||
@@ -576,7 +576,7 @@ bool ZoneSet::CalculateUniquePriorityGridLayout(Rect workArea, int zoneCount, in
|
||||
bool ZoneSet::CalculateCustomLayout(Rect workArea, int spacing) noexcept
|
||||
{
|
||||
wil::unique_cotaskmem_string guidStr;
|
||||
if (SUCCEEDED_LOG(StringFromCLSID(m_config.Id, &guidStr)))
|
||||
if (SUCCEEDED(StringFromCLSID(m_config.Id, &guidStr)))
|
||||
{
|
||||
const std::wstring guid = guidStr.get();
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <dwmapi.h>
|
||||
#include <ProjectTelemetry.h>
|
||||
#include <shellapi.h>
|
||||
#include <ShellScalingApi.h>
|
||||
#include <strsafe.h>
|
||||
#include <TraceLoggingActivity.h>
|
||||
#include <wil\resource.h>
|
||||
|
||||
Reference in New Issue
Block a user