[FancyZones] Custom canvas layouts scaling (#3644)

* Make canvas layout scaling sensitive

* Revert "Make canvas layout scaling sensitive"

This reverts commit 705dab7e36.

* Revert "Revert "Make canvas layout scaling sensitive""

This reverts commit b9dd27644c.

* Cleanup

* Minor refactoring

* Address PR comments
This commit is contained in:
stefansjfw
2020-05-29 09:38:29 +02:00
committed by GitHub
parent 3bb3c06456
commit ff328381af
15 changed files with 120 additions and 126 deletions

View File

@@ -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;

View File

@@ -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);

View File

@@ -45,8 +45,9 @@ namespace JSONHelpers
struct CanvasLayoutInfo
{
int referenceWidth;
int referenceHeight;
int lastWorkAreaWidth;
int lastWorkAreaHeight;
struct Rect
{
int x;

View File

@@ -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();

View File

@@ -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>