2019-09-05 00:26:26 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "Zone.h"
|
2020-02-10 21:59:51 +08:00
|
|
|
#include "JsonHelpers.h"
|
2019-09-05 00:26:26 +08:00
|
|
|
|
2020-03-10 02:22:53 +08:00
|
|
|
/**
|
|
|
|
* Class representing single zone layout. ZoneSet is responsible for actual calculation of rectangle coordinates
|
|
|
|
* (whether is grid or canvas layout) and moving windows through them.
|
|
|
|
*/
|
2019-09-05 00:26:26 +08:00
|
|
|
interface __declspec(uuid("{E4839EB7-669D-49CF-84A9-71A2DFD851A3}")) IZoneSet : public IUnknown
|
|
|
|
{
|
2020-03-10 02:22:53 +08:00
|
|
|
/**
|
|
|
|
* @returns Unique identifier of zone layout.
|
|
|
|
*/
|
2019-09-05 00:26:26 +08:00
|
|
|
IFACEMETHOD_(GUID, Id)() = 0;
|
2020-03-10 02:22:53 +08:00
|
|
|
/**
|
|
|
|
* @returns Type of the zone layout. Layout type can be focus, columns, rows, grid, priority grid or custom.
|
|
|
|
*/
|
2020-02-10 21:59:51 +08:00
|
|
|
IFACEMETHOD_(JSONHelpers::ZoneSetLayoutType, LayoutType)() = 0;
|
2020-03-10 02:22:53 +08:00
|
|
|
/**
|
|
|
|
* Add zone to the zone layout.
|
|
|
|
*
|
|
|
|
* @param zone Zone object (defining coordinates of the zone).
|
|
|
|
*/
|
2019-11-19 07:29:42 +08:00
|
|
|
IFACEMETHOD(AddZone)(winrt::com_ptr<IZone> zone) = 0;
|
2020-03-10 02:22:53 +08:00
|
|
|
/**
|
|
|
|
* Get zone from cursor coordinates.
|
|
|
|
*
|
|
|
|
* @param pt Cursor coordinates.
|
|
|
|
* @returns Zone object (defining coordinates of the zone).
|
|
|
|
*/
|
2019-09-05 00:26:26 +08:00
|
|
|
IFACEMETHOD_(winrt::com_ptr<IZone>, ZoneFromPoint)(POINT pt) = 0;
|
2020-03-10 02:22:53 +08:00
|
|
|
/**
|
|
|
|
* Get index of the zone inside zone layout by window assigned to it.
|
|
|
|
*
|
|
|
|
* @param window Handle of window assigned to zone.
|
|
|
|
* @returns Zone index withing zone layout.
|
|
|
|
*/
|
2019-09-05 00:26:26 +08:00
|
|
|
IFACEMETHOD_(int, GetZoneIndexFromWindow)(HWND window) = 0;
|
2020-03-10 02:22:53 +08:00
|
|
|
/**
|
|
|
|
* @returns Array of zone objects (defining coordinates of the zone) inside this zone layout.
|
|
|
|
*/
|
2019-09-05 00:26:26 +08:00
|
|
|
IFACEMETHOD_(std::vector<winrt::com_ptr<IZone>>, GetZones)() = 0;
|
2020-03-10 02:22:53 +08:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2019-09-05 00:26:26 +08:00
|
|
|
IFACEMETHOD_(void, MoveWindowIntoZoneByIndex)(HWND window, HWND zoneWindow, int index) = 0;
|
2020-03-10 02:22:53 +08:00
|
|
|
/**
|
|
|
|
* Assign window to the zone based on direction (using WIN + LEFT/RIGHT arrow).
|
|
|
|
*
|
|
|
|
* @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.
|
2020-03-25 01:50:26 +08:00
|
|
|
* @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.
|
2020-03-10 02:22:53 +08:00
|
|
|
*/
|
2020-03-25 01:50:26 +08:00
|
|
|
IFACEMETHOD_(bool, MoveWindowIntoZoneByDirection)(HWND window, HWND zoneWindow, DWORD vkCode, bool cycle) = 0;
|
2020-03-10 02:22:53 +08:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2020-02-10 21:59:51 +08:00
|
|
|
IFACEMETHOD_(void, MoveWindowIntoZoneByPoint)(HWND window, HWND zoneWindow, POINT ptClient) = 0;
|
2020-03-10 02:22:53 +08:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* @param monitorInfo Information about monitor on which zone layout is applied.
|
|
|
|
* @param zoneCount Number of zones inside zone layout.
|
|
|
|
* @param spacing Spacing between zones in pixels.
|
2020-03-25 01:50:26 +08:00
|
|
|
*
|
|
|
|
* @returns Boolean indicating if calculation was successful.
|
2020-03-10 02:22:53 +08:00
|
|
|
*/
|
2020-02-10 21:59:51 +08:00
|
|
|
IFACEMETHOD_(bool, CalculateZones)(MONITORINFO monitorInfo, int zoneCount, int spacing) = 0;
|
2019-09-05 00:26:26 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#define VERSION_PERSISTEDDATA 0x0000F00D
|
|
|
|
struct ZoneSetPersistedData
|
|
|
|
{
|
2019-11-08 02:56:32 +08:00
|
|
|
static constexpr inline size_t MAX_ZONES = 40;
|
|
|
|
|
2019-09-05 00:26:26 +08:00
|
|
|
DWORD Version{VERSION_PERSISTEDDATA};
|
|
|
|
WORD LayoutId{};
|
|
|
|
DWORD ZoneCount{};
|
2020-02-10 21:59:51 +08:00
|
|
|
JSONHelpers::ZoneSetLayoutType Layout{};
|
|
|
|
RECT Zones[MAX_ZONES]{};
|
|
|
|
};
|
|
|
|
|
2019-09-05 00:26:26 +08:00
|
|
|
struct ZoneSetConfig
|
|
|
|
{
|
|
|
|
ZoneSetConfig(
|
|
|
|
GUID id,
|
2020-02-10 21:59:51 +08:00
|
|
|
JSONHelpers::ZoneSetLayoutType layoutType,
|
2019-09-05 00:26:26 +08:00
|
|
|
HMONITOR monitor,
|
2019-11-19 07:29:42 +08:00
|
|
|
PCWSTR resolutionKey) noexcept :
|
2019-09-05 00:26:26 +08:00
|
|
|
Id(id),
|
2020-02-10 21:59:51 +08:00
|
|
|
LayoutType(layoutType),
|
2019-09-05 00:26:26 +08:00
|
|
|
Monitor(monitor),
|
2019-11-19 07:29:42 +08:00
|
|
|
ResolutionKey(resolutionKey)
|
2019-09-05 00:26:26 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
GUID Id{};
|
2020-02-10 21:59:51 +08:00
|
|
|
JSONHelpers::ZoneSetLayoutType LayoutType{};
|
2019-09-05 00:26:26 +08:00
|
|
|
HMONITOR Monitor{};
|
|
|
|
PCWSTR ResolutionKey{};
|
|
|
|
};
|
|
|
|
|
|
|
|
winrt::com_ptr<IZoneSet> MakeZoneSet(ZoneSetConfig const& config) noexcept;
|