mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 19:57:07 +02:00
[FancyZones] Increase the number of zones limit to 128 (#15976)
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <optional>
|
||||
|
||||
#include <FancyZonesLib/Zone.h>
|
||||
@@ -8,66 +7,19 @@
|
||||
// Zoned window properties are not localized.
|
||||
namespace ZonedWindowProperties
|
||||
{
|
||||
const wchar_t PropertyMultipleZoneID[] = L"FancyZones_zones";
|
||||
const wchar_t PropertySortKeyWithinZone[] = L"FancyZones_TabSortKeyWithinZone";
|
||||
const wchar_t PropertyRestoreSizeID[] = L"FancyZones_RestoreSize";
|
||||
const wchar_t PropertyRestoreOriginID[] = L"FancyZones_RestoreOrigin";
|
||||
|
||||
const wchar_t MultiMonitorDeviceID[] = L"FancyZones#MultiMonitorDevice";
|
||||
}
|
||||
|
||||
inline ZoneIndexSet GetZoneIndexSet(HWND window)
|
||||
namespace FancyZonesWindowProperties
|
||||
{
|
||||
HANDLE handle = ::GetProp(window, ZonedWindowProperties::PropertyMultipleZoneID);
|
||||
ZoneIndexSet zoneIndexSet;
|
||||
void StampZoneIndexProperty(HWND window, const ZoneIndexSet& zoneSet);
|
||||
void RemoveZoneIndexProperty(HWND window);
|
||||
ZoneIndexSet RetrieveZoneIndexProperty(HWND window);
|
||||
|
||||
std::array<int, 2> data;
|
||||
memcpy(data.data(), &handle, sizeof data);
|
||||
uint64_t bitmask = ((uint64_t)data[1] << 32) + data[0];
|
||||
|
||||
if (bitmask != 0)
|
||||
{
|
||||
for (int i = 0; i < std::numeric_limits<ZoneIndex>::digits; i++)
|
||||
{
|
||||
if ((1ull << i) & bitmask)
|
||||
{
|
||||
zoneIndexSet.push_back(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return zoneIndexSet;
|
||||
std::optional<size_t> GetTabSortKeyWithinZone(HWND window);
|
||||
void SetTabSortKeyWithinZone(HWND window, std::optional<size_t> tabSortKeyWithinZone);
|
||||
}
|
||||
|
||||
inline void StampWindow(HWND window, Bitmask bitmask) noexcept
|
||||
{
|
||||
std::array<int, 2> data = { static_cast<int>(bitmask), (bitmask >> 32) };
|
||||
HANDLE rawData;
|
||||
memcpy(&rawData, data.data(), sizeof data);
|
||||
SetProp(window, ZonedWindowProperties::PropertyMultipleZoneID, rawData);
|
||||
}
|
||||
|
||||
inline std::optional<size_t> GetTabSortKeyWithinZone(HWND window)
|
||||
{
|
||||
auto rawTabSortKeyWithinZone = ::GetPropW(window, ZonedWindowProperties::PropertySortKeyWithinZone);
|
||||
if (rawTabSortKeyWithinZone == NULL)
|
||||
{
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
auto tabSortKeyWithinZone = reinterpret_cast<uint64_t>(rawTabSortKeyWithinZone) - 1;
|
||||
return tabSortKeyWithinZone;
|
||||
}
|
||||
|
||||
inline void SetTabSortKeyWithinZone(HWND window, std::optional<size_t> tabSortKeyWithinZone)
|
||||
{
|
||||
if (!tabSortKeyWithinZone.has_value())
|
||||
{
|
||||
::RemovePropW(window, ZonedWindowProperties::PropertySortKeyWithinZone);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto rawTabSortKeyWithinZone = reinterpret_cast<HANDLE>(tabSortKeyWithinZone.value() + 1);
|
||||
::SetPropW(window, ZonedWindowProperties::PropertySortKeyWithinZone, rawTabSortKeyWithinZone);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user