[FancyZones] Minor refactoring of ZoneSet class (#7274)

* Minor refactoring of ZoneSet class

* Remove comment
This commit is contained in:
stefansjfw 2020-10-16 15:25:30 +02:00 committed by GitHub
parent 4634c74f9e
commit 36bcbe9d95
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 127 additions and 138 deletions

View file

@ -1,10 +1,12 @@
#include "pch.h"
#include "util.h"
#include "lib/ZoneSet.h"
#include "Settings.h"
#include "ZoneSet.h"
#include "FancyZonesData.h"
#include "FancyZonesDataTypes.h"
#include "Settings.h"
#include "Zone.h"
#include "util.h"
#include <common/dpi_aware.h>
@ -15,19 +17,7 @@ using namespace FancyZonesUtils;
namespace
{
constexpr int C_MULTIPLIER = 10000;
constexpr int MAX_ZONE_COUNT = 50;
/*
struct GridLayoutInfo {
int rows;
int columns;
int rowsPercents[MAX_ZONE_COUNT];
int columnsPercents[MAX_ZONE_COUNT];
int cellChildMap[MAX_ZONE_COUNT][MAX_ZONE_COUNT];
};
*/
auto l = FancyZonesDataTypes::GridLayoutInfo(FancyZonesDataTypes::GridLayoutInfo::Minimal{ .rows = 1, .columns = 1 });
// PriorityGrid layout is unique for zoneCount <= 11. For zoneCount > 11 PriorityGrid is same as Grid
FancyZonesDataTypes::GridLayoutInfo predefinedPriorityGridLayouts[11] = {
/* 1 */
@ -108,6 +98,11 @@ namespace
.columnsPercents = { 2500, 2500, 2500, 2500 },
.cellChildMap = { { 0, 1, 2, 3 }, { 4, 1, 5, 6 }, { 7, 8, 9, 10 } } }),
};
inline void StampWindow(HWND window, size_t bitmask) noexcept
{
SetProp(window, ZonedWindowProperties::PropertyMultipleZoneID, reinterpret_cast<HANDLE>(bitmask));
}
}
struct ZoneSet : winrt::implements<ZoneSet, IZoneSet>
@ -125,34 +120,34 @@ public:
}
IFACEMETHODIMP_(GUID)
Id() noexcept { return m_config.Id; }
Id() const noexcept { return m_config.Id; }
IFACEMETHODIMP_(FancyZonesDataTypes::ZoneSetLayoutType)
LayoutType() noexcept { return m_config.LayoutType; }
LayoutType() const noexcept { return m_config.LayoutType; }
IFACEMETHODIMP AddZone(winrt::com_ptr<IZone> zone) noexcept;
IFACEMETHODIMP_(std::vector<size_t>)
ZonesFromPoint(POINT pt) noexcept;
ZonesFromPoint(POINT pt) const noexcept;
IFACEMETHODIMP_(std::vector<size_t>)
GetZoneIndexSetFromWindow(HWND window) noexcept;
GetZoneIndexSetFromWindow(HWND window) const noexcept;
IFACEMETHODIMP_(std::vector<winrt::com_ptr<IZone>>)
GetZones() noexcept { return m_zones; }
GetZones() const noexcept { return m_zones; }
IFACEMETHODIMP_(void)
MoveWindowIntoZoneByIndex(HWND window, HWND zoneWindow, size_t index) noexcept;
MoveWindowIntoZoneByIndex(HWND window, HWND workAreaWindow, size_t index) noexcept;
IFACEMETHODIMP_(void)
MoveWindowIntoZoneByIndexSet(HWND window, HWND windowZone, const std::vector<size_t>& indexSet) noexcept;
MoveWindowIntoZoneByIndexSet(HWND window, HWND workAreaWindow, const std::vector<size_t>& indexSet) noexcept;
IFACEMETHODIMP_(bool)
MoveWindowIntoZoneByDirectionAndIndex(HWND window, HWND zoneWindow, DWORD vkCode, bool cycle) noexcept;
MoveWindowIntoZoneByDirectionAndIndex(HWND window, HWND workAreaWindow, DWORD vkCode, bool cycle) noexcept;
IFACEMETHODIMP_(bool)
MoveWindowIntoZoneByDirectionAndPosition(HWND window, HWND zoneWindow, DWORD vkCode, bool cycle) noexcept;
MoveWindowIntoZoneByDirectionAndPosition(HWND window, HWND workAreaWindow, DWORD vkCode, bool cycle) noexcept;
IFACEMETHODIMP_(bool)
ExtendWindowByDirectionAndPosition(HWND window, HWND windowZone, DWORD vkCode) noexcept;
ExtendWindowByDirectionAndPosition(HWND window, HWND workAreaWindow, DWORD vkCode) noexcept;
IFACEMETHODIMP_(void)
MoveWindowIntoZoneByPoint(HWND window, HWND zoneWindow, POINT ptClient) noexcept;
MoveWindowIntoZoneByPoint(HWND window, HWND workAreaWindow, POINT ptClient) noexcept;
IFACEMETHODIMP_(bool)
CalculateZones(RECT workArea, int zoneCount, int spacing) noexcept;
IFACEMETHODIMP_(bool)
IsZoneEmpty(int zoneIndex) noexcept;
IsZoneEmpty(int zoneIndex) const noexcept;
IFACEMETHODIMP_(std::vector<size_t>)
GetCombinedZoneRange(const std::vector<size_t>& initialZones, const std::vector<size_t>& finalZones) noexcept;
GetCombinedZoneRange(const std::vector<size_t>& initialZones, const std::vector<size_t>& finalZones) const noexcept;
private:
bool CalculateFocusLayout(Rect workArea, int zoneCount) noexcept;
@ -161,7 +156,6 @@ private:
bool CalculateUniquePriorityGridLayout(Rect workArea, int zoneCount, int spacing) noexcept;
bool CalculateCustomLayout(Rect workArea, int spacing) noexcept;
bool CalculateGridZones(Rect workArea, FancyZonesDataTypes::GridLayoutInfo gridLayoutInfo, int spacing);
void StampWindow(HWND window, size_t bitmask) noexcept;
std::vector<winrt::com_ptr<IZone>> m_zones;
std::map<HWND, std::vector<size_t>> m_windowIndexSet;
@ -182,28 +176,23 @@ IFACEMETHODIMP ZoneSet::AddZone(winrt::com_ptr<IZone> zone) noexcept
}
IFACEMETHODIMP_(std::vector<size_t>)
ZoneSet::ZonesFromPoint(POINT pt) noexcept
ZoneSet::ZonesFromPoint(POINT pt) const noexcept
{
int sensitivityRadius = m_config.SensitivityRadius;
std::vector<size_t> capturedZones;
std::vector<size_t> strictlyCapturedZones;
for (size_t i = 0; i < m_zones.size(); i++)
{
auto zone = m_zones[i];
RECT newZoneRect = zone->GetZoneRect();
if (newZoneRect.left < newZoneRect.right && newZoneRect.top < newZoneRect.bottom) // proper zone
const RECT& zoneRect = m_zones[i]->GetZoneRect();
if (zoneRect.left - m_config.SensitivityRadius <= pt.x && pt.x <= zoneRect.right + m_config.SensitivityRadius &&
zoneRect.top - m_config.SensitivityRadius <= pt.y && pt.y <= zoneRect.bottom + m_config.SensitivityRadius)
{
if (newZoneRect.left - sensitivityRadius <= pt.x && pt.x <= newZoneRect.right + sensitivityRadius &&
newZoneRect.top - sensitivityRadius <= pt.y && pt.y <= newZoneRect.bottom + sensitivityRadius)
{
capturedZones.emplace_back(i);
}
capturedZones.emplace_back(i);
}
if (newZoneRect.left <= pt.x && pt.x < newZoneRect.right &&
newZoneRect.top <= pt.y && pt.y < newZoneRect.bottom)
{
strictlyCapturedZones.emplace_back(i);
}
if (zoneRect.left <= pt.x && pt.x < zoneRect.right &&
zoneRect.top <= pt.y && pt.y < zoneRect.bottom)
{
strictlyCapturedZones.emplace_back(i);
}
}
@ -216,22 +205,24 @@ ZoneSet::ZonesFromPoint(POINT pt) noexcept
// If captured zones do not overlap, return all of them
// Otherwise, return the smallest one
bool overlap = false;
for (size_t i = 0; i < capturedZones.size(); ++i)
{
for (size_t j = i + 1; j < capturedZones.size(); ++j)
{
auto rectI = m_zones[capturedZones[i]]->GetZoneRect();
auto rectJ = m_zones[capturedZones[j]]->GetZoneRect();
if (max(rectI.top, rectJ.top) + sensitivityRadius < min(rectI.bottom, rectJ.bottom) &&
max(rectI.left, rectJ.left) + sensitivityRadius < min(rectI.right, rectJ.right))
const auto& rectI = m_zones[capturedZones[i]]->GetZoneRect();
const auto& rectJ = m_zones[capturedZones[j]]->GetZoneRect();
if (max(rectI.top, rectJ.top) + m_config.SensitivityRadius < min(rectI.bottom, rectJ.bottom) &&
max(rectI.left, rectJ.left) + m_config.SensitivityRadius < min(rectI.right, rectJ.right))
{
overlap = true;
i = capturedZones.size() - 1;
break;
}
}
if (overlap)
{
break;
}
}
if (overlap)
@ -239,8 +230,8 @@ ZoneSet::ZonesFromPoint(POINT pt) noexcept
size_t smallestIdx = 0;
for (size_t i = 1; i < capturedZones.size(); ++i)
{
auto rectS = m_zones[capturedZones[smallestIdx]]->GetZoneRect();
auto rectI = m_zones[capturedZones[i]]->GetZoneRect();
const auto& rectS = m_zones[capturedZones[smallestIdx]]->GetZoneRect();
const auto& rectI = m_zones[capturedZones[i]]->GetZoneRect();
int smallestSize = (rectS.bottom - rectS.top) * (rectS.right - rectS.left);
int iSize = (rectI.bottom - rectI.top) * (rectI.right - rectI.left);
@ -256,7 +247,7 @@ ZoneSet::ZonesFromPoint(POINT pt) noexcept
return capturedZones;
}
std::vector<size_t> ZoneSet::GetZoneIndexSetFromWindow(HWND window) noexcept
std::vector<size_t> ZoneSet::GetZoneIndexSetFromWindow(HWND window) const noexcept
{
auto it = m_windowIndexSet.find(window);
if (it == m_windowIndexSet.end())
@ -270,13 +261,13 @@ std::vector<size_t> ZoneSet::GetZoneIndexSetFromWindow(HWND window) noexcept
}
IFACEMETHODIMP_(void)
ZoneSet::MoveWindowIntoZoneByIndex(HWND window, HWND windowZone, size_t index) noexcept
ZoneSet::MoveWindowIntoZoneByIndex(HWND window, HWND workAreaWindow, size_t index) noexcept
{
MoveWindowIntoZoneByIndexSet(window, windowZone, { index });
MoveWindowIntoZoneByIndexSet(window, workAreaWindow, { index });
}
IFACEMETHODIMP_(void)
ZoneSet::MoveWindowIntoZoneByIndexSet(HWND window, HWND windowZone, const std::vector<size_t>& indexSet) noexcept
ZoneSet::MoveWindowIntoZoneByIndexSet(HWND window, HWND workAreaWindow, const std::vector<size_t>& indexSet) noexcept
{
if (m_zones.empty())
{
@ -294,14 +285,13 @@ ZoneSet::MoveWindowIntoZoneByIndexSet(HWND window, HWND windowZone, const std::v
bool sizeEmpty = true;
size_t bitmask = 0;
auto& storedIndexSet = m_windowIndexSet[window];
storedIndexSet = {};
m_windowIndexSet[window] = {};
for (size_t index : indexSet)
{
if (index < m_zones.size())
{
RECT newSize = m_zones.at(index)->ComputeActualZoneRect(window, windowZone);
RECT newSize = m_zones.at(index)->ComputeActualZoneRect(window, workAreaWindow);
if (!sizeEmpty)
{
size.left = min(size.left, newSize.left);
@ -315,7 +305,7 @@ ZoneSet::MoveWindowIntoZoneByIndexSet(HWND window, HWND windowZone, const std::v
sizeEmpty = false;
}
storedIndexSet.push_back(index);
m_windowIndexSet[window].push_back(index);
}
if (index < std::numeric_limits<size_t>::digits)
@ -333,7 +323,7 @@ ZoneSet::MoveWindowIntoZoneByIndexSet(HWND window, HWND windowZone, const std::v
}
IFACEMETHODIMP_(bool)
ZoneSet::MoveWindowIntoZoneByDirectionAndIndex(HWND window, HWND windowZone, DWORD vkCode, bool cycle) noexcept
ZoneSet::MoveWindowIntoZoneByDirectionAndIndex(HWND window, HWND workAreaWindow, DWORD vkCode, bool cycle) noexcept
{
if (m_zones.empty())
{
@ -346,7 +336,7 @@ ZoneSet::MoveWindowIntoZoneByDirectionAndIndex(HWND window, HWND windowZone, DWO
// The window was not assigned to any zone here
if (indexSet.size() == 0)
{
MoveWindowIntoZoneByIndexSet(window, windowZone, { vkCode == VK_LEFT ? numZones - 1 : 0 });
MoveWindowIntoZoneByIndexSet(window, workAreaWindow, { vkCode == VK_LEFT ? numZones - 1 : 0 });
return true;
}
@ -357,12 +347,12 @@ ZoneSet::MoveWindowIntoZoneByDirectionAndIndex(HWND window, HWND windowZone, DWO
{
if (!cycle)
{
MoveWindowIntoZoneByIndexSet(window, windowZone, {});
MoveWindowIntoZoneByIndexSet(window, workAreaWindow, {});
return false;
}
else
{
MoveWindowIntoZoneByIndexSet(window, windowZone, { vkCode == VK_LEFT ? numZones - 1 : 0 });
MoveWindowIntoZoneByIndexSet(window, workAreaWindow, { vkCode == VK_LEFT ? numZones - 1 : 0 });
return true;
}
}
@ -370,25 +360,24 @@ ZoneSet::MoveWindowIntoZoneByDirectionAndIndex(HWND window, HWND windowZone, DWO
// We didn't reach the edge
if (vkCode == VK_LEFT)
{
MoveWindowIntoZoneByIndexSet(window, windowZone, { oldIndex - 1 });
MoveWindowIntoZoneByIndexSet(window, workAreaWindow, { oldIndex - 1 });
}
else
{
MoveWindowIntoZoneByIndexSet(window, windowZone, { oldIndex + 1 });
MoveWindowIntoZoneByIndexSet(window, workAreaWindow, { oldIndex + 1 });
}
return true;
}
IFACEMETHODIMP_(bool)
ZoneSet::MoveWindowIntoZoneByDirectionAndPosition(HWND window, HWND windowZone, DWORD vkCode, bool cycle) noexcept
ZoneSet::MoveWindowIntoZoneByDirectionAndPosition(HWND window, HWND workAreaWindow, DWORD vkCode, bool cycle) noexcept
{
if (m_zones.empty())
{
return false;
}
auto zoneObjects = GetZones();
std::vector<bool> usedZoneIndices(zoneObjects.size(), false);
std::vector<bool> usedZoneIndices(m_zones.size(), false);
for (size_t idx : GetZoneIndexSetFromWindow(window))
{
usedZoneIndices[idx] = true;
@ -397,17 +386,17 @@ ZoneSet::MoveWindowIntoZoneByDirectionAndPosition(HWND window, HWND windowZone,
std::vector<RECT> zoneRects;
std::vector<size_t> freeZoneIndices;
for (size_t i = 0; i < zoneObjects.size(); i++)
for (size_t i = 0; i < m_zones.size(); i++)
{
if (!usedZoneIndices[i])
{
zoneRects.emplace_back(zoneObjects[i]->GetZoneRect());
zoneRects.emplace_back(m_zones[i]->GetZoneRect());
freeZoneIndices.emplace_back(i);
}
}
RECT windowRect, windowZoneRect;
if (GetWindowRect(window, &windowRect) && GetWindowRect(windowZone, &windowZoneRect))
if (GetWindowRect(window, &windowRect) && GetWindowRect(workAreaWindow, &windowZoneRect))
{
// Move to coordinates relative to windowZone
windowRect.top -= windowZoneRect.top;
@ -418,21 +407,21 @@ ZoneSet::MoveWindowIntoZoneByDirectionAndPosition(HWND window, HWND windowZone,
size_t result = FancyZonesUtils::ChooseNextZoneByPosition(vkCode, windowRect, zoneRects);
if (result < zoneRects.size())
{
MoveWindowIntoZoneByIndex(window, windowZone, freeZoneIndices[result]);
MoveWindowIntoZoneByIndex(window, workAreaWindow, freeZoneIndices[result]);
return true;
}
else if (cycle)
{
// Try again from the position off the screen in the opposite direction to vkCode
// Consider all zones as available
zoneRects.resize(zoneObjects.size());
std::transform(zoneObjects.begin(), zoneObjects.end(), zoneRects.begin(), [](auto zone) { return zone->GetZoneRect(); });
zoneRects.resize(m_zones.size());
std::transform(m_zones.begin(), m_zones.end(), zoneRects.begin(), [](auto zone) { return zone->GetZoneRect(); });
windowRect = FancyZonesUtils::PrepareRectForCycling(windowRect, windowZoneRect, vkCode);
result = FancyZonesUtils::ChooseNextZoneByPosition(vkCode, windowRect, zoneRects);
if (result < zoneRects.size())
{
MoveWindowIntoZoneByIndex(window, windowZone, result);
MoveWindowIntoZoneByIndex(window, workAreaWindow, result);
return true;
}
}
@ -442,7 +431,7 @@ ZoneSet::MoveWindowIntoZoneByDirectionAndPosition(HWND window, HWND windowZone,
}
IFACEMETHODIMP_(bool)
ZoneSet::ExtendWindowByDirectionAndPosition(HWND window, HWND windowZone, DWORD vkCode) noexcept
ZoneSet::ExtendWindowByDirectionAndPosition(HWND window, HWND workAreaWindow, DWORD vkCode) noexcept
{
if (m_zones.empty())
{
@ -450,11 +439,10 @@ ZoneSet::ExtendWindowByDirectionAndPosition(HWND window, HWND windowZone, DWORD
}
RECT windowRect, windowZoneRect;
if (GetWindowRect(window, &windowRect) && GetWindowRect(windowZone, &windowZoneRect))
if (GetWindowRect(window, &windowRect) && GetWindowRect(workAreaWindow, &windowZoneRect))
{
auto zoneObjects = GetZones();
auto oldZones = GetZoneIndexSetFromWindow(window);
std::vector<bool> usedZoneIndices(zoneObjects.size(), false);
std::vector<bool> usedZoneIndices(m_zones.size(), false);
std::vector<RECT> zoneRects;
std::vector<size_t> freeZoneIndices;
@ -464,7 +452,7 @@ ZoneSet::ExtendWindowByDirectionAndPosition(HWND window, HWND windowZone, DWORD
if (finalIndexIt != m_windowFinalIndex.end())
{
usedZoneIndices[finalIndexIt->second] = true;
windowRect = zoneObjects[finalIndexIt->second]->GetZoneRect();
windowRect = m_zones[finalIndexIt->second]->GetZoneRect();
}
else
{
@ -479,11 +467,11 @@ ZoneSet::ExtendWindowByDirectionAndPosition(HWND window, HWND windowZone, DWORD
windowRect.right -= windowZoneRect.left;
}
for (size_t i = 0; i < zoneObjects.size(); i++)
for (size_t i = 0; i < m_zones.size(); i++)
{
if (!usedZoneIndices[i])
{
zoneRects.emplace_back(zoneObjects[i]->GetZoneRect());
zoneRects.emplace_back(m_zones[i]->GetZoneRect());
freeZoneIndices.emplace_back(i);
}
}
@ -519,7 +507,7 @@ ZoneSet::ExtendWindowByDirectionAndPosition(HWND window, HWND windowZone, DWORD
}
m_inExtendWindow = true;
MoveWindowIntoZoneByIndexSet(window, windowZone, resultIndexSet);
MoveWindowIntoZoneByIndexSet(window, workAreaWindow, resultIndexSet);
m_inExtendWindow = false;
return true;
}
@ -529,10 +517,10 @@ ZoneSet::ExtendWindowByDirectionAndPosition(HWND window, HWND windowZone, DWORD
}
IFACEMETHODIMP_(void)
ZoneSet::MoveWindowIntoZoneByPoint(HWND window, HWND zoneWindow, POINT ptClient) noexcept
ZoneSet::MoveWindowIntoZoneByPoint(HWND window, HWND workAreaWindow, POINT ptClient) noexcept
{
auto zones = ZonesFromPoint(ptClient);
MoveWindowIntoZoneByIndexSet(window, zoneWindow, zones);
const auto& zones = ZonesFromPoint(ptClient);
MoveWindowIntoZoneByIndexSet(window, workAreaWindow, zones);
}
IFACEMETHODIMP_(bool)
@ -573,7 +561,7 @@ ZoneSet::CalculateZones(RECT workAreaRect, int zoneCount, int spacing) noexcept
return success;
}
bool ZoneSet::IsZoneEmpty(int zoneIndex) noexcept
bool ZoneSet::IsZoneEmpty(int zoneIndex) const noexcept
{
for (auto& [window, zones] : m_windowIndexSet)
{
@ -878,12 +866,7 @@ bool ZoneSet::CalculateGridZones(Rect workArea, FancyZonesDataTypes::GridLayoutI
return true;
}
void ZoneSet::StampWindow(HWND window, size_t bitmask) noexcept
{
SetProp(window, ZonedWindowProperties::PropertyMultipleZoneID, reinterpret_cast<HANDLE>(bitmask));
}
std::vector<size_t> ZoneSet::GetCombinedZoneRange(const std::vector<size_t>& initialZones, const std::vector<size_t>& finalZones) noexcept
std::vector<size_t> ZoneSet::GetCombinedZoneRange(const std::vector<size_t>& initialZones, const std::vector<size_t>& finalZones) const noexcept
{
std::vector<size_t> combinedZones, result;
std::set_union(begin(initialZones), end(initialZones), begin(finalZones), end(finalZones), std::back_inserter(combinedZones));
@ -894,7 +877,7 @@ std::vector<size_t> ZoneSet::GetCombinedZoneRange(const std::vector<size_t>& ini
for (size_t zoneId : combinedZones)
{
RECT rect = zones[zoneId]->GetZoneRect();
const RECT& rect = zones[zoneId]->GetZoneRect();
if (boundingRectEmpty)
{
boundingRect = rect;

View file

@ -16,11 +16,11 @@ interface __declspec(uuid("{E4839EB7-669D-49CF-84A9-71A2DFD851A3}")) IZoneSet :
/**
* @returns Unique identifier of zone layout.
*/
IFACEMETHOD_(GUID, Id)() = 0;
IFACEMETHOD_(GUID, Id)() const = 0;
/**
* @returns Type of the zone layout. Layout type can be focus, columns, rows, grid, priority grid or custom.
*/
IFACEMETHOD_(FancyZonesDataTypes::ZoneSetLayoutType, LayoutType)() = 0;
IFACEMETHOD_(FancyZonesDataTypes::ZoneSetLayoutType, LayoutType)() const = 0;
/**
* Add zone to the zone layout.
*
@ -33,89 +33,95 @@ interface __declspec(uuid("{E4839EB7-669D-49CF-84A9-71A2DFD851A3}")) IZoneSet :
* @param pt Cursor coordinates.
* @returns Vector of indices, corresponding to the current set of zones - the zones considered active.
*/
IFACEMETHOD_(std::vector<size_t>, ZonesFromPoint)(POINT pt) = 0;
IFACEMETHOD_(std::vector<size_t>, ZonesFromPoint)(POINT pt) const = 0;
/**
* Get index set of the zones to which the window was assigned.
*
* @param window Handle of the window.
* @returns A vector of size_t, 0-based, the index set.
* @returns A vector of size_t, 0-based index set.
*/
IFACEMETHOD_(std::vector<size_t>, GetZoneIndexSetFromWindow)(HWND window) = 0;
IFACEMETHOD_(std::vector<size_t>, GetZoneIndexSetFromWindow)
(HWND window) const = 0;
/**
* @returns Array of zone objects (defining coordinates of the zone) inside this zone layout.
*/
IFACEMETHOD_(std::vector<winrt::com_ptr<IZone>>, GetZones)() = 0;
IFACEMETHOD_(std::vector<winrt::com_ptr<IZone>>, GetZones)() const = 0;
/**
* Assign window to the zone based on zone index inside zone layout.
*
* @param window Handle of window which should be assigned to zone.
* @param zoneWindow The m_window of a ZoneWindow, it's a hidden window representing the
* current monitor desktop work area.
* @param index Zone index within zone layout.
* @param window Handle of window which should be assigned to zone.
* @param workAreaWindow The m_window of a ZoneWindow, it's a hidden window representing the
* current monitor desktop work area.
* @param index Zone index within zone layout.
*/
IFACEMETHOD_(void, MoveWindowIntoZoneByIndex)(HWND window, HWND zoneWindow, size_t index) = 0;
IFACEMETHOD_(void, MoveWindowIntoZoneByIndex)
(HWND window, HWND workAreaWindow, size_t index) = 0;
/**
* Assign window to the zones based on the set of zone indices inside zone layout.
*
* @param window Handle of window which should be assigned to zone.
* @param zoneWindow The m_window of a ZoneWindow, it's a hidden window representing the
* current monitor desktop work area.
* @param indexSet The set of zone indices within zone layout.
* @param window Handle of window which should be assigned to zone.
* @param workAreaWindow The m_window of a ZoneWindow, it's a hidden window representing the
* current monitor desktop work area.
* @param indexSet The set of zone indices within zone layout.
*/
IFACEMETHOD_(void, MoveWindowIntoZoneByIndexSet)(HWND window, HWND zoneWindow, const std::vector<size_t>& indexSet) = 0;
IFACEMETHOD_(void, MoveWindowIntoZoneByIndexSet)
(HWND window, HWND workAreaWindow, const std::vector<size_t>& indexSet) = 0;
/**
* Assign window to the zone based on direction (using WIN + LEFT/RIGHT arrow), based on zone index numbers,
* not their on-screen position.
*
* @param window Handle of window which should be assigned to zone.
* @param zoneWindow The m_window of a ZoneWindow, it's a hidden window representing the
* current monitor desktop work area.
* @param vkCode Pressed arrow key.
* @param cycle Whether we should move window to the first zone if we reached last zone in layout.
* @param window Handle of window which should be assigned to zone.
* @param workAreaWindow The m_window of a ZoneWindow, it's a hidden window representing the
* current monitor desktop work area.
* @param vkCode Pressed arrow key.
* @param cycle Whether we should move window to the first zone if we reached last zone in layout.
*
* @returns Boolean which is always true if cycle argument is set, otherwise indicating if there is more
* zones left in the zone layout in which window can move.
*/
IFACEMETHOD_(bool, MoveWindowIntoZoneByDirectionAndIndex)(HWND window, HWND zoneWindow, DWORD vkCode, bool cycle) = 0;
IFACEMETHOD_(bool, MoveWindowIntoZoneByDirectionAndIndex)
(HWND window, HWND workAreaWindow, DWORD vkCode, bool cycle) = 0;
/**
* Assign window to the zone based on direction (using WIN + LEFT/RIGHT/UP/DOWN arrow), based on
* their on-screen position.
*
* @param window Handle of window which should be assigned to zone.
* @param zoneWindow The m_window of a ZoneWindow, it's a hidden window representing the
* current monitor desktop work area.
* @param vkCode Pressed arrow key.
* @param cycle Whether we should move window to the first zone if we reached last zone in layout.
* @param window Handle of window which should be assigned to zone.
* @param workAreaWindow The m_window of a ZoneWindow, it's a hidden window representing the
* current monitor desktop work area.
* @param vkCode Pressed arrow key.
* @param cycle Whether we should move window to the first zone if we reached last zone in layout.
*
* @returns Boolean which is always true if cycle argument is set, otherwise indicating if there is more
* zones left in the zone layout in which window can move.
*/
IFACEMETHOD_(bool, MoveWindowIntoZoneByDirectionAndPosition)(HWND window, HWND zoneWindow, DWORD vkCode, bool cycle) = 0;
IFACEMETHOD_(bool, MoveWindowIntoZoneByDirectionAndPosition)
(HWND window, HWND workAreaWindow, DWORD vkCode, bool cycle) = 0;
/**
* Extend or shrink the window to an adjacent zone based on direction (using CTRL+WIN+ALT + LEFT/RIGHT/UP/DOWN arrow), based on
* their on-screen position.
*
* @param window Handle of window which should be assigned to zone.
* @param zoneWindow The m_window of a ZoneWindow, it's a hidden window representing the
* current monitor desktop work area.
* @param vkCode Pressed arrow key.
* @param window Handle of window which should be assigned to zone.
* @param workAreaWindow The m_window of a ZoneWindow, it's a hidden window representing the
* current monitor desktop work area.
* @param vkCode Pressed arrow key.
*
* @returns Boolean indicating whether the window was rezoned. False could be returned when there are no more
* zones available in the given direction.
*/
IFACEMETHOD_(bool, ExtendWindowByDirectionAndPosition)(HWND window, HWND zoneWindow, DWORD vkCode) = 0;
IFACEMETHOD_(bool, ExtendWindowByDirectionAndPosition)
(HWND window, HWND workAreaWindow, DWORD vkCode) = 0;
/**
* Assign window to the zone based on cursor coordinates.
*
* @param window Handle of window which should be assigned to zone.
* @param zoneWindow The m_window of a ZoneWindow, it's a hidden window representing the
* current monitor desktop work area.
* @param pt Cursor coordinates.
* @param window Handle of window which should be assigned to zone.
* @param workAreaWindow The m_window of a ZoneWindow, it's a hidden window representing the
* current monitor desktop work area.
* @param pt Cursor coordinates.
*/
IFACEMETHOD_(void, MoveWindowIntoZoneByPoint)(HWND window, HWND zoneWindow, POINT ptClient) = 0;
IFACEMETHOD_(void, MoveWindowIntoZoneByPoint)
(HWND window, HWND workAreaWindow, POINT ptClient) = 0;
/**
* Calculate zone coordinates within zone layout based on number of zones and spacing. Used for one of
* the predefined layouts (focus, columns, rows, grid, priority grid) or for custom layout.
* Calculate zone coordinates within zone layout based on number of zones and spacing.
*
* @param workAreaRect The rectangular area on the screen on which the zone layout is applied.
* @param zoneCount Number of zones inside zone layout.
@ -125,13 +131,13 @@ interface __declspec(uuid("{E4839EB7-669D-49CF-84A9-71A2DFD851A3}")) IZoneSet :
*/
IFACEMETHOD_(bool, CalculateZones)(RECT workAreaRect, int zoneCount, int spacing) = 0;
/**
* Check if the zone with the specified index is empty. Returns true if the zone does not exist.
* Check if the zone with the specified index is empty. Returns true if the zone with passed zoneIndex does not exist.
*
* @param zoneIndex The index of of the zone within this zone set.
*
* @returns Boolean indicating whether the zone is empty.
*/
IFACEMETHOD_(bool, IsZoneEmpty)(int zoneIndex) = 0;
IFACEMETHOD_(bool, IsZoneEmpty)(int zoneIndex) const = 0;
/**
* Returns all zones spanned by the minimum bounding rectangle containing the two given zone index sets.
*
@ -140,7 +146,7 @@ interface __declspec(uuid("{E4839EB7-669D-49CF-84A9-71A2DFD851A3}")) IZoneSet :
*
* @returns A vector indicating describing the chosen zone index set.
*/
IFACEMETHOD_(std::vector<size_t>, GetCombinedZoneRange)(const std::vector<size_t>& initialZones, const std::vector<size_t>& finalZones) = 0;
IFACEMETHOD_(std::vector<size_t>, GetCombinedZoneRange)(const std::vector<size_t>& initialZones, const std::vector<size_t>& finalZones) const = 0;
};
struct ZoneSetConfig