mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 19:57:07 +02:00
Add keyboard shortcuts (without GUI) for switching windows in the same zone (tabs) (#13973)
Authored-by: float4 <float4-unspecified-mail>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <optional>
|
||||
|
||||
#include <FancyZonesLib/Zone.h>
|
||||
|
||||
@@ -8,6 +9,7 @@
|
||||
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";
|
||||
|
||||
@@ -44,3 +46,28 @@ inline void StampWindow(HWND window, Bitmask bitmask) noexcept
|
||||
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