Merge pull request #391 from microsoft/user/bretan/fz-multimon

Fix for #195 - Fancy Zones new editor needs to support multiple monitors
Fix for #292 - Zone Editor opens behind PowerToys Window
This commit is contained in:
Bret
2019-09-17 17:58:53 -07:00
committed by GitHub
9 changed files with 577 additions and 500 deletions

View File

@@ -27,27 +27,26 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReser
return TRUE;
}
// TODO: multimon support, need to pass the HMONITOR from the editor to here instead
// of using MonitorFromPoint
// This function is exported and called from FancyZonesEditor.exe to save a layout from the editor.
STDAPI PersistZoneSet(
PCWSTR activeKey, // Registry key holding ActiveZoneSet
PCWSTR resolutionKey, // Registry key for screen resolution
PCWSTR resolutionKey, // Registry key to persist ZoneSet to
HMONITOR monitor,
WORD layoutId, // LayoutModel Id
int zoneCount, // Number of zones in zones
int zones[]) // Array of zones serialized in left/top/right/bottom chunks
{
// See if we have already persisted this layout we can update.
UUID id{GUID_NULL};
if (wil::unique_hkey key{ RegistryHelpers::OpenKey(resolutionKey) })
{
ZoneSetPersistedData data{};
DWORD dataSize = sizeof(data);
wchar_t value[256]{};
DWORD valueLength = ARRAYSIZE(value);
DWORD i = 0;
while (RegEnumValueW(key.get(), i++, value, &valueLength, nullptr, nullptr, reinterpret_cast<BYTE*>(&data), &dataSize) == ERROR_SUCCESS)
{
UUID id{GUID_NULL};
if (wil::unique_hkey key{ RegistryHelpers::OpenKey(resolutionKey) })
{
ZoneSetPersistedData data{};
DWORD dataSize = sizeof(data);
wchar_t value[256]{};
DWORD valueLength = ARRAYSIZE(value);
DWORD i = 0;
while (RegEnumValueW(key.get(), i++, value, &valueLength, nullptr, nullptr, reinterpret_cast<BYTE*>(&data), &dataSize) == ERROR_SUCCESS)
{
if (data.LayoutId == layoutId)
{
if (data.ZoneCount == zoneCount)
@@ -73,7 +72,7 @@ STDAPI PersistZoneSet(
ZoneSetConfig(
id,
layoutId,
MonitorFromPoint({}, MONITOR_DEFAULTTOPRIMARY),
reinterpret_cast<HMONITOR>(monitor),
resolutionKey,
ZoneSetLayout::Custom,
0, 0, 0));