mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
Merge pull request #739 from TheMrJukes/master
FancyZones: Remove legacy editor
This commit is contained in:
@@ -73,10 +73,8 @@ STDAPI PersistZoneSet(
|
||||
ZoneSetConfig(
|
||||
id,
|
||||
layoutId,
|
||||
reinterpret_cast<HMONITOR>(monitor),
|
||||
resolutionKey,
|
||||
ZoneSetLayout::Custom,
|
||||
0, 0, 0));
|
||||
MonitorFromPoint({}, MONITOR_DEFAULTTOPRIMARY),
|
||||
resolutionKey));
|
||||
|
||||
for (int i = 0; i < zoneCount; i++)
|
||||
{
|
||||
@@ -85,7 +83,7 @@ STDAPI PersistZoneSet(
|
||||
const int top = zones[baseIndex+1];
|
||||
const int right = zones[baseIndex+2];
|
||||
const int bottom = zones[baseIndex+3];
|
||||
zoneSet->AddZone(MakeZone({ left, top, right, bottom }), false);
|
||||
zoneSet->AddZone(MakeZone({ left, top, right, bottom }));
|
||||
}
|
||||
zoneSet->Save();
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ public:
|
||||
IFACEMETHODIMP_(void) SettingsChanged() noexcept;
|
||||
|
||||
// IZoneWindowHost
|
||||
IFACEMETHODIMP_(void) ToggleZoneViewers() noexcept;
|
||||
IFACEMETHODIMP_(void) MoveWindowsOnActiveZoneSetChange() noexcept;
|
||||
IFACEMETHODIMP_(COLORREF) GetZoneHighlightColor() noexcept
|
||||
{
|
||||
@@ -43,7 +42,6 @@ public:
|
||||
|
||||
LRESULT WndProc(HWND, UINT, WPARAM, LPARAM) noexcept;
|
||||
void OnDisplayChange(DisplayChangeType changeType) noexcept;
|
||||
void ShowZoneEditorForMonitor(HMONITOR monitor) noexcept;
|
||||
void AddZoneWindow(HMONITOR monitor, PCWSTR deviceId) noexcept;
|
||||
void MoveWindowIntoZoneByIndex(HWND window, int index) noexcept;
|
||||
|
||||
@@ -80,20 +78,20 @@ private:
|
||||
mutable std::shared_mutex m_lock;
|
||||
HWND m_window{};
|
||||
HWND m_windowMoveSize{}; // The window that is being moved/sized
|
||||
bool m_editorsVisible{}; // Are we showing the zone editors?
|
||||
bool m_inMoveSize{}; // Whether or not a move/size operation is currently active
|
||||
bool m_dragEnabled{}; // True if we should be showing zone hints while dragging
|
||||
std::map<HMONITOR, winrt::com_ptr<IZoneWindow>> m_zoneWindowMap; // Map of monitor to ZoneWindow (one per monitor)
|
||||
winrt::com_ptr<IZoneWindow> m_zoneWindowMoveSize; // "Active" ZoneWindow, where the move/size is happening. Will update as drag moves between monitors.
|
||||
IFancyZonesSettings* m_settings{};
|
||||
GUID m_currentVirtualDesktopId{};
|
||||
wil::unique_handle m_terminateEditorEvent;
|
||||
GUID m_currentVirtualDesktopId{}; // UUID of the current virtual desktop. Is GUID_NULL until first VD switch per session.
|
||||
wil::unique_handle m_terminateEditorEvent; // Handle of FancyZonesEditor.exe we launch and wait on
|
||||
|
||||
OnThreadExecutor m_dpiUnawareThread;
|
||||
|
||||
static UINT WM_PRIV_VDCHANGED;
|
||||
static UINT WM_PRIV_EDITOR;
|
||||
static UINT WM_PRIV_VDCHANGED; // Message to get back on to the UI thread when virtual desktop changes
|
||||
static UINT WM_PRIV_EDITOR; // Message to get back on to the UI thread when the editor exits
|
||||
|
||||
// Did we terminate the editor or was it closed cleanly?
|
||||
enum class EditorExitKind : byte
|
||||
{
|
||||
Exit,
|
||||
@@ -122,6 +120,7 @@ IFACEMETHODIMP_(void) FancyZones::Run() noexcept
|
||||
if (!m_window) return;
|
||||
|
||||
RegisterHotKey(m_window, 1, m_settings->GetSettings().editorHotkey.get_modifiers(), m_settings->GetSettings().editorHotkey.get_code());
|
||||
|
||||
VirtualDesktopChanged();
|
||||
|
||||
m_dpiUnawareThread.submit(OnThreadExecutor::task_t{[]{
|
||||
@@ -198,16 +197,12 @@ IFACEMETHODIMP_(bool) FancyZones::OnKeyDown(PKBDLLHOOKSTRUCT info) noexcept
|
||||
bool const win = GetAsyncKeyState(VK_LWIN) & 0x8000;
|
||||
if (win && !shift)
|
||||
{
|
||||
if (!m_settings->GetSettings().overrideSnapHotkeys)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool const ctrl = GetAsyncKeyState(VK_CONTROL) & 0x8000;
|
||||
if (ctrl)
|
||||
{
|
||||
if ((info->vkCode >= '0') && (info->vkCode <= '9'))
|
||||
{
|
||||
// Win+Ctrl+Number will cycle through ZoneSets
|
||||
Trace::FancyZones::OnKeyDown(info->vkCode, win, ctrl, false /*inMoveSize*/);
|
||||
CycleActiveZoneSet(info->vkCode);
|
||||
return true;
|
||||
@@ -215,13 +210,18 @@ IFACEMETHODIMP_(bool) FancyZones::OnKeyDown(PKBDLLHOOKSTRUCT info) noexcept
|
||||
}
|
||||
else if ((info->vkCode == VK_RIGHT) || (info->vkCode == VK_LEFT))
|
||||
{
|
||||
if (!m_settings->GetSettings().overrideSnapHotkeys)
|
||||
{
|
||||
// Win+Left, Win+Right will cycle through Zones in the active ZoneSet
|
||||
Trace::FancyZones::OnKeyDown(info->vkCode, win, ctrl, false /*inMoveSize*/);
|
||||
OnSnapHotkey(info->vkCode);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (m_inMoveSize && (info->vkCode >= '0') && (info->vkCode <= '9'))
|
||||
{
|
||||
// This allows you to cycle through ZoneSets while dragging a window
|
||||
Trace::FancyZones::OnKeyDown(info->vkCode, win, false /*control*/, true /*inMoveSize*/);
|
||||
CycleActiveZoneSet(info->vkCode);
|
||||
return true;
|
||||
@@ -356,38 +356,6 @@ void FancyZones::SettingsChanged() noexcept
|
||||
RegisterHotKey(m_window, 1, m_settings->GetSettings().editorHotkey.get_modifiers(), m_settings->GetSettings().editorHotkey.get_code());
|
||||
}
|
||||
|
||||
// IZoneWindowHost
|
||||
IFACEMETHODIMP_(void) FancyZones::ToggleZoneViewers() noexcept
|
||||
{
|
||||
bool alreadyVisible{};
|
||||
|
||||
{
|
||||
std::unique_lock writeLock(m_lock);
|
||||
alreadyVisible = m_editorsVisible;
|
||||
m_editorsVisible = !alreadyVisible;
|
||||
}
|
||||
Trace::FancyZones::ToggleZoneViewers(!alreadyVisible);
|
||||
|
||||
if (!alreadyVisible)
|
||||
{
|
||||
auto callback = [](HMONITOR monitor, HDC, RECT *, LPARAM data) -> BOOL
|
||||
{
|
||||
auto strongThis = reinterpret_cast<FancyZones*>(data);
|
||||
strongThis->ShowZoneEditorForMonitor(monitor);
|
||||
return TRUE;
|
||||
};
|
||||
EnumDisplayMonitors(nullptr, nullptr, callback, reinterpret_cast<LPARAM>(this));
|
||||
}
|
||||
else
|
||||
{
|
||||
std::shared_lock readLock(m_lock);
|
||||
for (auto iter : m_zoneWindowMap)
|
||||
{
|
||||
iter.second->HideZoneWindow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// IZoneWindowHost
|
||||
IFACEMETHODIMP_(void) FancyZones::MoveWindowsOnActiveZoneSetChange() noexcept
|
||||
{
|
||||
@@ -404,16 +372,9 @@ LRESULT FancyZones::WndProc(HWND window, UINT message, WPARAM wparam, LPARAM lpa
|
||||
case WM_HOTKEY:
|
||||
{
|
||||
if (wparam == 1)
|
||||
{
|
||||
if (m_settings->GetSettings().use_standalone_editor)
|
||||
{
|
||||
ToggleEditor();
|
||||
}
|
||||
else
|
||||
{
|
||||
ToggleZoneViewers();
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -508,18 +469,6 @@ void FancyZones::OnDisplayChange(DisplayChangeType changeType) noexcept
|
||||
}
|
||||
}
|
||||
|
||||
void FancyZones::ShowZoneEditorForMonitor(HMONITOR monitor) noexcept
|
||||
{
|
||||
std::shared_lock readLock(m_lock);
|
||||
|
||||
auto iter = m_zoneWindowMap.find(monitor);
|
||||
if (iter != m_zoneWindowMap.end())
|
||||
{
|
||||
bool const activate = MonitorFromPoint(POINT(), MONITOR_DEFAULTTOPRIMARY) == monitor;
|
||||
iter->second->ShowZoneWindow(activate, false /*fadeIn*/);
|
||||
}
|
||||
}
|
||||
|
||||
void FancyZones::AddZoneWindow(HMONITOR monitor, PCWSTR deviceId) noexcept
|
||||
{
|
||||
std::unique_lock writeLock(m_lock);
|
||||
|
||||
@@ -32,7 +32,6 @@ interface __declspec(uuid("{2CB37E8F-87E6-4AEC-B4B2-E0FDC873343F}")) IFancyZones
|
||||
|
||||
interface __declspec(uuid("{5C8D99D6-34B2-4F4A-A8E5-7483F6869775}")) IZoneWindowHost : public IUnknown
|
||||
{
|
||||
IFACEMETHOD_(void, ToggleZoneViewers)() = 0;
|
||||
IFACEMETHOD_(void, MoveWindowsOnActiveZoneSetChange)() = 0;
|
||||
IFACEMETHOD_(COLORREF, GetZoneHighlightColor)() = 0;
|
||||
};
|
||||
|
||||
@@ -32,7 +32,7 @@ private:
|
||||
PCWSTR name;
|
||||
bool* value;
|
||||
int resourceId;
|
||||
} m_configBools[9] = {
|
||||
} m_configBools[8] = {
|
||||
{ L"fancyzones_shiftDrag", &m_settings.shiftDrag, IDS_SETTING_DESCRIPTION_SHIFTDRAG },
|
||||
{ L"fancyzones_overrideSnapHotkeys", &m_settings.overrideSnapHotkeys, IDS_SETTING_DESCRIPTION_OVERRIDE_SNAP_HOTKEYS },
|
||||
{ L"fancyzones_zoneSetChange_flashZones", &m_settings.zoneSetChange_flashZones, IDS_SETTING_DESCRIPTION_ZONESETCHANGE_FLASHZONES },
|
||||
@@ -40,7 +40,6 @@ private:
|
||||
{ L"fancyzones_zoneSetChange_moveWindows", &m_settings.zoneSetChange_moveWindows, IDS_SETTING_DESCRIPTION_ZONESETCHANGE_MOVEWINDOWS },
|
||||
{ L"fancyzones_virtualDesktopChange_moveWindows", &m_settings.virtualDesktopChange_moveWindows, IDS_SETTING_DESCRIPTION_VIRTUALDESKTOPCHANGE_MOVEWINDOWS },
|
||||
{ L"fancyzones_appLastZone_moveWindows", &m_settings.appLastZone_moveWindows, IDS_SETTING_DESCRIPTION_APPLASTZONE_MOVEWINDOWS },
|
||||
{ L"fancyzones_use_standalone_editor", &m_settings.use_standalone_editor, IDS_SETTING_DESCRIPTION_USE_STANDALONE_EDITOR },
|
||||
{ L"use_cursorpos_editor_startupscreen", &m_settings.use_cursorpos_editor_startupscreen, IDS_SETTING_DESCRIPTION_USE_CURSORPOS_EDITOR_STARTUPSCREEN },
|
||||
};
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ struct Settings
|
||||
bool zoneSetChange_moveWindows = false;
|
||||
bool overrideSnapHotkeys = false;
|
||||
bool appLastZone_moveWindows = false;
|
||||
bool use_standalone_editor = true;
|
||||
bool use_cursorpos_editor_startupscreen = true;
|
||||
std::wstring zoneHightlightColor = L"#0078D7";
|
||||
PowerToysSettings::HotkeyObject editorHotkey = PowerToysSettings::HotkeyObject::from_settings(true, false, false, false, VK_OEM_3, L"~");
|
||||
|
||||
@@ -5,10 +5,6 @@ struct ZoneSet : winrt::implements<ZoneSet, IZoneSet>
|
||||
public:
|
||||
ZoneSet(ZoneSetConfig const& config) : m_config(config)
|
||||
{
|
||||
if (config.ZoneCount > 0)
|
||||
{
|
||||
InitialPopulateZones();
|
||||
}
|
||||
}
|
||||
|
||||
ZoneSet(ZoneSetConfig const& config, std::vector<winrt::com_ptr<IZone>> zones) :
|
||||
@@ -19,44 +15,25 @@ public:
|
||||
|
||||
IFACEMETHODIMP_(GUID) Id() noexcept { return m_config.Id; }
|
||||
IFACEMETHODIMP_(WORD) LayoutId() noexcept { return m_config.LayoutId; }
|
||||
IFACEMETHODIMP AddZone(winrt::com_ptr<IZone> zone, bool front) noexcept;
|
||||
IFACEMETHODIMP RemoveZone(winrt::com_ptr<IZone> zone) noexcept;
|
||||
IFACEMETHODIMP AddZone(winrt::com_ptr<IZone> zone) noexcept;
|
||||
IFACEMETHODIMP_(winrt::com_ptr<IZone>) ZoneFromPoint(POINT pt) noexcept;
|
||||
IFACEMETHODIMP_(winrt::com_ptr<IZone>) ZoneFromWindow(HWND window) noexcept;
|
||||
IFACEMETHODIMP_(int) GetZoneIndexFromWindow(HWND window) noexcept;
|
||||
IFACEMETHODIMP_(std::vector<winrt::com_ptr<IZone>>) GetZones() noexcept { return m_zones; }
|
||||
IFACEMETHODIMP_(ZoneSetLayout) GetLayout() noexcept { return m_config.Layout; }
|
||||
IFACEMETHODIMP_(int) GetInnerPadding() noexcept { return m_config.PaddingInner; }
|
||||
IFACEMETHODIMP_(winrt::com_ptr<IZoneSet>) MakeCustomClone() noexcept;
|
||||
IFACEMETHODIMP_(void) Save() noexcept;
|
||||
IFACEMETHODIMP_(void) MoveZoneToFront(winrt::com_ptr<IZone> zone) noexcept;
|
||||
IFACEMETHODIMP_(void) MoveZoneToBack(winrt::com_ptr<IZone> zone) noexcept;
|
||||
IFACEMETHODIMP_(void) MoveWindowIntoZoneByIndex(HWND window, HWND zoneWindow, int index) noexcept;
|
||||
IFACEMETHODIMP_(void) MoveWindowIntoZoneByDirection(HWND window, HWND zoneWindow, DWORD vkCode) noexcept;
|
||||
IFACEMETHODIMP_(void) MoveSizeEnd(HWND window, HWND zoneWindow, POINT ptClient) noexcept;
|
||||
|
||||
private:
|
||||
void InitialPopulateZones() noexcept;
|
||||
void GenerateGridZones(MONITORINFO const& mi) noexcept;
|
||||
void DoGridLayout(SIZE const& zoneArea, int numCols, int numRows) noexcept;
|
||||
void GenerateFocusZones(MONITORINFO const& mi) noexcept;
|
||||
void StampZone(HWND window, _In_opt_ winrt::com_ptr<IZone> zone) noexcept;
|
||||
winrt::com_ptr<IZone> ZoneFromWindow(HWND window) noexcept;
|
||||
|
||||
std::vector<winrt::com_ptr<IZone>> m_zones;
|
||||
ZoneSetConfig m_config;
|
||||
};
|
||||
|
||||
IFACEMETHODIMP ZoneSet::AddZone(winrt::com_ptr<IZone> zone, bool front) noexcept
|
||||
{
|
||||
// XXXX: need to reorder ids when inserting...
|
||||
if (front)
|
||||
{
|
||||
m_zones.insert(m_zones.begin(), zone);
|
||||
}
|
||||
else
|
||||
IFACEMETHODIMP ZoneSet::AddZone(winrt::com_ptr<IZone> zone) noexcept
|
||||
{
|
||||
m_zones.emplace_back(zone);
|
||||
}
|
||||
|
||||
// Important not to set Id 0 since we store it in the HWND using SetProp.
|
||||
// SetProp(0) doesn't really work.
|
||||
@@ -64,17 +41,6 @@ IFACEMETHODIMP ZoneSet::AddZone(winrt::com_ptr<IZone> zone, bool front) noexcept
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
IFACEMETHODIMP ZoneSet::RemoveZone(winrt::com_ptr<IZone> zone) noexcept
|
||||
{
|
||||
auto iter = std::find(m_zones.begin(), m_zones.end(), zone);
|
||||
if (iter != m_zones.end())
|
||||
{
|
||||
m_zones.erase(iter);
|
||||
return S_OK;
|
||||
}
|
||||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
IFACEMETHODIMP_(winrt::com_ptr<IZone>) ZoneSet::ZoneFromPoint(POINT pt) noexcept
|
||||
{
|
||||
winrt::com_ptr<IZone> smallestKnownZone = nullptr;
|
||||
@@ -111,31 +77,6 @@ IFACEMETHODIMP_(winrt::com_ptr<IZone>) ZoneSet::ZoneFromPoint(POINT pt) noexcept
|
||||
return smallestKnownZone;
|
||||
}
|
||||
|
||||
IFACEMETHODIMP_(winrt::com_ptr<IZone>) ZoneSet::ZoneFromWindow(HWND window) noexcept
|
||||
{
|
||||
for (auto iter = m_zones.begin(); iter != m_zones.end(); iter++)
|
||||
{
|
||||
if (winrt::com_ptr<IZone> zone = iter->try_as<IZone>())
|
||||
{
|
||||
if (zone->ContainsWindow(window))
|
||||
{
|
||||
return zone;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
IFACEMETHODIMP_(winrt::com_ptr<IZoneSet>) ZoneSet::MakeCustomClone() noexcept
|
||||
{
|
||||
if (SUCCEEDED_LOG(CoCreateGuid(&m_config.Id)))
|
||||
{
|
||||
m_config.IsCustom = true;
|
||||
return winrt::make_self<ZoneSet>(m_config, m_zones);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
IFACEMETHODIMP_(void) ZoneSet::Save() noexcept
|
||||
{
|
||||
size_t const zoneCount = m_zones.size();
|
||||
@@ -148,9 +89,6 @@ IFACEMETHODIMP_(void) ZoneSet::Save() noexcept
|
||||
ZoneSetPersistedData data{};
|
||||
data.LayoutId = m_config.LayoutId;
|
||||
data.ZoneCount = static_cast<DWORD>(zoneCount);
|
||||
data.Layout = m_config.Layout;
|
||||
data.PaddingInner = m_config.PaddingInner;
|
||||
data.PaddingOuter = m_config.PaddingOuter;
|
||||
|
||||
int i = 0;
|
||||
for (auto iter = m_zones.begin(); iter != m_zones.end(); iter++)
|
||||
@@ -170,24 +108,6 @@ IFACEMETHODIMP_(void) ZoneSet::Save() noexcept
|
||||
}
|
||||
}
|
||||
|
||||
IFACEMETHODIMP_(void) ZoneSet::MoveZoneToFront(winrt::com_ptr<IZone> zone) noexcept
|
||||
{
|
||||
auto iter = std::find(m_zones.begin(), m_zones.end(), zone);
|
||||
if (iter != m_zones.end())
|
||||
{
|
||||
std::rotate(m_zones.begin(), iter, iter + 1);
|
||||
}
|
||||
}
|
||||
|
||||
IFACEMETHODIMP_(void) ZoneSet::MoveZoneToBack(winrt::com_ptr<IZone> zone) noexcept
|
||||
{
|
||||
auto iter = std::find(m_zones.begin(), m_zones.end(), zone);
|
||||
if (iter != m_zones.end())
|
||||
{
|
||||
std::rotate(iter, iter + 1, m_zones.end());
|
||||
}
|
||||
}
|
||||
|
||||
IFACEMETHODIMP_(int) ZoneSet::GetZoneIndexFromWindow(HWND window) noexcept
|
||||
{
|
||||
int zoneIndex = 0;
|
||||
@@ -273,127 +193,19 @@ IFACEMETHODIMP_(void) ZoneSet::MoveSizeEnd(HWND window, HWND zoneWindow, POINT p
|
||||
}
|
||||
}
|
||||
|
||||
void ZoneSet::InitialPopulateZones() noexcept
|
||||
winrt::com_ptr<IZone> ZoneSet::ZoneFromWindow(HWND window) noexcept
|
||||
{
|
||||
// TODO: reconcile the pregenerated FZ layouts with the editor
|
||||
|
||||
MONITORINFO mi{};
|
||||
mi.cbSize = sizeof(mi);
|
||||
if (GetMonitorInfoW(m_config.Monitor, &mi))
|
||||
for (auto iter = m_zones.begin(); iter != m_zones.end(); iter++)
|
||||
{
|
||||
if ((m_config.Layout == ZoneSetLayout::Grid) || (m_config.Layout == ZoneSetLayout::Row))
|
||||
if (winrt::com_ptr<IZone> zone = iter->try_as<IZone>())
|
||||
{
|
||||
GenerateGridZones(mi);
|
||||
}
|
||||
else if (m_config.Layout == ZoneSetLayout::Focus)
|
||||
if (zone->ContainsWindow(window))
|
||||
{
|
||||
GenerateFocusZones(mi);
|
||||
}
|
||||
|
||||
Save();
|
||||
}
|
||||
}
|
||||
|
||||
void ZoneSet::GenerateGridZones(MONITORINFO const& mi) noexcept
|
||||
{
|
||||
Rect workArea(mi.rcWork);
|
||||
|
||||
int numCols, numRows;
|
||||
if (m_config.Layout == ZoneSetLayout::Grid)
|
||||
{
|
||||
switch (m_config.ZoneCount)
|
||||
{
|
||||
case 1: numCols = 1; numRows = 1; break;
|
||||
case 2: numCols = 2; numRows = 1; break;
|
||||
case 3: numCols = 2; numRows = 2; break;
|
||||
case 4: numCols = 2; numRows = 2; break;
|
||||
case 5: numCols = 3; numRows = 3; break;
|
||||
case 6: numCols = 3; numRows = 3; break;
|
||||
case 7: numCols = 3; numRows = 3; break;
|
||||
case 8: numCols = 3; numRows = 3; break;
|
||||
case 9: numCols = 3; numRows = 3; break;
|
||||
}
|
||||
|
||||
if ((m_config.ZoneCount == 2) && (workArea.height() > workArea.width()))
|
||||
{
|
||||
numCols = 1;
|
||||
numRows = 2;
|
||||
}
|
||||
}
|
||||
else if (m_config.Layout == ZoneSetLayout::Row)
|
||||
{
|
||||
numCols = m_config.ZoneCount;
|
||||
numRows = 1;
|
||||
}
|
||||
|
||||
SIZE const zoneArea = {
|
||||
workArea.width() - ((m_config.PaddingOuter * 2) + (m_config.PaddingInner * (numCols - 1))),
|
||||
workArea.height() - ((m_config.PaddingOuter * 2) + (m_config.PaddingInner * (numRows - 1)))
|
||||
};
|
||||
|
||||
DoGridLayout(zoneArea, numCols, numRows);
|
||||
}
|
||||
|
||||
void ZoneSet::DoGridLayout(SIZE const& zoneArea, int numCols, int numRows) noexcept
|
||||
{
|
||||
auto x = m_config.PaddingOuter;
|
||||
auto y = m_config.PaddingOuter;
|
||||
auto const zoneWidth = (zoneArea.cx / numCols);
|
||||
auto const zoneHeight = (zoneArea.cy / numRows);
|
||||
for (auto i = 1; i <= m_config.ZoneCount; i++)
|
||||
{
|
||||
auto col = numCols - (i % numCols);
|
||||
RECT const zoneRect = { x, y, x + zoneWidth, y + zoneHeight };
|
||||
AddZone(MakeZone(zoneRect), false);
|
||||
|
||||
x += zoneWidth + m_config.PaddingInner;
|
||||
if (col == numCols)
|
||||
{
|
||||
x = m_config.PaddingOuter;
|
||||
y += zoneHeight + m_config.PaddingInner;
|
||||
return zone;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ZoneSet::GenerateFocusZones(MONITORINFO const& mi) noexcept
|
||||
{
|
||||
Rect const workArea(mi.rcWork);
|
||||
|
||||
SIZE const workHalf = { workArea.width() / 2, workArea.height() / 2 };
|
||||
RECT const safeZone = {
|
||||
m_config.PaddingOuter,
|
||||
m_config.PaddingOuter,
|
||||
workArea.width() - m_config.PaddingOuter,
|
||||
workArea.height() - m_config.PaddingOuter
|
||||
};
|
||||
|
||||
int const width = min(1920, workArea.width() * 60 / 100);
|
||||
int const height = min(1200, workArea.height() * 75 / 100);
|
||||
int const halfWidth = width / 2;
|
||||
int const halfHeight = height / 2;
|
||||
int x = workHalf.cx - halfWidth;
|
||||
int y = workHalf.cy - halfHeight;
|
||||
|
||||
RECT const focusRect = { x, y, x + width, y + height };
|
||||
AddZone(MakeZone(focusRect), false);
|
||||
|
||||
for (auto i = 2; i <= m_config.ZoneCount; i++)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 2: x = focusRect.right - halfWidth; y = focusRect.top + m_config.PaddingInner; break; // right
|
||||
case 3: x = focusRect.left - halfWidth; y = focusRect.top + (m_config.PaddingInner * 2); break; // left
|
||||
case 4: x = focusRect.left + m_config.PaddingInner; y = focusRect.top - halfHeight; break; // up
|
||||
case 5: x = focusRect.left - m_config.PaddingInner; y = focusRect.bottom - halfHeight; break; // down
|
||||
}
|
||||
|
||||
// Bound into safe zone
|
||||
x = min(safeZone.right - width, max(safeZone.left, x));
|
||||
y = min(safeZone.bottom - height, max(safeZone.top, y));
|
||||
|
||||
RECT const zoneRect = { x, y, x + width, y + height };
|
||||
AddZone(MakeZone(zoneRect), false);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
winrt::com_ptr<IZoneSet> MakeZoneSet(ZoneSetConfig const& config) noexcept
|
||||
|
||||
@@ -14,18 +14,11 @@ interface __declspec(uuid("{E4839EB7-669D-49CF-84A9-71A2DFD851A3}")) IZoneSet :
|
||||
{
|
||||
IFACEMETHOD_(GUID, Id)() = 0;
|
||||
IFACEMETHOD_(WORD, LayoutId)() = 0;
|
||||
IFACEMETHOD(AddZone)(winrt::com_ptr<IZone> zone, bool front) = 0;
|
||||
IFACEMETHOD(RemoveZone)(winrt::com_ptr<IZone> zone) = 0;
|
||||
IFACEMETHOD(AddZone)(winrt::com_ptr<IZone> zone) = 0;
|
||||
IFACEMETHOD_(winrt::com_ptr<IZone>, ZoneFromPoint)(POINT pt) = 0;
|
||||
IFACEMETHOD_(winrt::com_ptr<IZone>, ZoneFromWindow)(HWND window) = 0;
|
||||
IFACEMETHOD_(int, GetZoneIndexFromWindow)(HWND window) = 0;
|
||||
IFACEMETHOD_(std::vector<winrt::com_ptr<IZone>>, GetZones)() = 0;
|
||||
IFACEMETHOD_(ZoneSetLayout, GetLayout)() = 0;
|
||||
IFACEMETHOD_(int, GetInnerPadding)() = 0;
|
||||
IFACEMETHOD_(winrt::com_ptr<IZoneSet>, MakeCustomClone)() = 0;
|
||||
IFACEMETHOD_(void, Save)() = 0;
|
||||
IFACEMETHOD_(void, MoveZoneToFront)(winrt::com_ptr<IZone> zone) = 0;
|
||||
IFACEMETHOD_(void, MoveZoneToBack)(winrt::com_ptr<IZone> zone) = 0;
|
||||
IFACEMETHOD_(void, MoveWindowIntoZoneByIndex)(HWND window, HWND zoneWindow, int index) = 0;
|
||||
IFACEMETHOD_(void, MoveWindowIntoZoneByDirection)(HWND window, HWND zoneWindow, DWORD vkCode) = 0;
|
||||
IFACEMETHOD_(void, MoveSizeEnd)(HWND window, HWND zoneWindow, POINT ptClient) = 0;
|
||||
@@ -51,19 +44,11 @@ struct ZoneSetConfig
|
||||
GUID id,
|
||||
WORD layoutId,
|
||||
HMONITOR monitor,
|
||||
PCWSTR resolutionKey,
|
||||
ZoneSetLayout layout,
|
||||
int zoneCount,
|
||||
int paddingOuter,
|
||||
int paddingInner) noexcept :
|
||||
PCWSTR resolutionKey) noexcept :
|
||||
Id(id),
|
||||
LayoutId(layoutId),
|
||||
Monitor(monitor),
|
||||
ResolutionKey(resolutionKey),
|
||||
Layout(layout),
|
||||
ZoneCount(zoneCount),
|
||||
PaddingOuter(paddingOuter),
|
||||
PaddingInner(paddingInner)
|
||||
ResolutionKey(resolutionKey)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -71,11 +56,6 @@ struct ZoneSetConfig
|
||||
WORD LayoutId{};
|
||||
HMONITOR Monitor{};
|
||||
PCWSTR ResolutionKey{};
|
||||
ZoneSetLayout Layout{};
|
||||
int ZoneCount{};
|
||||
int PaddingOuter{};
|
||||
int PaddingInner{};
|
||||
bool IsCustom{};
|
||||
};
|
||||
|
||||
winrt::com_ptr<IZoneSet> MakeZoneSet(ZoneSetConfig const& config) noexcept;
|
||||
@@ -8,8 +8,6 @@ struct ZoneWindow : public winrt::implements<ZoneWindow, IZoneWindow>
|
||||
public:
|
||||
ZoneWindow(IZoneWindowHost* host, HINSTANCE hinstance, HMONITOR monitor, PCWSTR deviceId, PCWSTR virtualDesktopId, bool flashZones);
|
||||
|
||||
IFACEMETHODIMP ShowZoneWindow(bool activate, bool fadeIn) noexcept;
|
||||
IFACEMETHODIMP HideZoneWindow() noexcept;
|
||||
IFACEMETHODIMP MoveSizeEnter(HWND window, bool dragEnabled) noexcept;
|
||||
IFACEMETHODIMP MoveSizeUpdate(POINT const& ptScreen, bool dragEnabled) noexcept;
|
||||
IFACEMETHODIMP MoveSizeEnd(HWND window, POINT const& ptScreen) noexcept;
|
||||
@@ -37,37 +35,26 @@ private:
|
||||
int thickness{};
|
||||
};
|
||||
|
||||
void ShowZoneWindow() noexcept;
|
||||
void HideZoneWindow() noexcept;
|
||||
void InitializeId(PCWSTR deviceId, PCWSTR virtualDesktopId) noexcept;
|
||||
void LoadSettings() noexcept;
|
||||
void InitializeZoneSets() noexcept;
|
||||
void InitializeZoneSets(MONITORINFO const& mi) noexcept;
|
||||
void LoadZoneSetsFromRegistry() noexcept;
|
||||
winrt::com_ptr<IZoneSet> AddZoneSet(ZoneSetLayout layout, int numZones, int paddingOuter, int paddingInner) noexcept;
|
||||
void MakeActiveZoneSetCustom() noexcept;
|
||||
void AddDefaultZoneSet(MONITORINFO const& mi) noexcept;
|
||||
void UpdateActiveZoneSet(_In_opt_ IZoneSet* zoneSet) noexcept;
|
||||
LRESULT WndProc(UINT message, WPARAM wparam, LPARAM lparam) noexcept;
|
||||
void OnLButtonDown(LPARAM lparam) noexcept;
|
||||
void OnLButtonUp(LPARAM lparam) noexcept;
|
||||
void OnRButtonUp(LPARAM lparam) noexcept;
|
||||
void OnMouseMove(LPARAM lparam) noexcept;
|
||||
void DrawBackdrop(wil::unique_hdc& hdc, RECT const& clientRect) noexcept;
|
||||
void DrawGridLines(wil::unique_hdc& hdc, RECT const& clientRect) noexcept;
|
||||
void DrawZone(wil::unique_hdc& hdc, ColorSetting const& colorSetting, winrt::com_ptr<IZone> zone) noexcept;
|
||||
void DrawIndex(wil::unique_hdc& hdc, POINT offset, size_t index, int padding, int size, bool flipX, bool flipY, COLORREF colorFill);
|
||||
void DrawActiveZoneSet(wil::unique_hdc& hdc, RECT const& clientRect) noexcept;
|
||||
void DrawZoneBuilder(wil::unique_hdc& hdc, RECT const& clientRect) noexcept;
|
||||
void DrawSwitchButtons(wil::unique_hdc& hdc, RECT const& clientRect) noexcept;
|
||||
void OnPaint(wil::unique_hdc& hdc) noexcept;
|
||||
void UpdateGrid(int stepColumns, int stepRows) noexcept;
|
||||
void UpdateGridMargins(int inc) noexcept;
|
||||
void EnterEditorMode() noexcept;
|
||||
void ExitEditorMode() noexcept;
|
||||
void OnKeyUp(WPARAM wparam) noexcept;
|
||||
winrt::com_ptr<IZone> ZoneFromPoint(POINT pt) noexcept;
|
||||
void ChooseDefaultActiveZoneSet() noexcept;
|
||||
bool IsOccluded(POINT pt, size_t index) noexcept;
|
||||
void CycleActiveZoneSetInternal(DWORD wparam, Trace::ZoneWindow::InputMode mode) noexcept;
|
||||
void FlashZones() noexcept;
|
||||
int GetSwitchButtonIndexFromPoint(POINT ptClient) noexcept;
|
||||
UINT GetDpiForMonitor() noexcept;
|
||||
|
||||
winrt::com_ptr<IZoneWindowHost> m_host;
|
||||
@@ -77,30 +64,15 @@ private:
|
||||
wil::unique_cotaskmem_string m_deviceId{};
|
||||
wil::unique_hwnd m_window{};
|
||||
HWND m_windowMoveSize{};
|
||||
bool m_buttonDown{};
|
||||
bool m_drawHints{};
|
||||
bool m_editorMode{};
|
||||
bool m_flashMode{};
|
||||
bool m_dragEnabled{};
|
||||
POINT m_ptDown{};
|
||||
POINT m_ptLast{};
|
||||
winrt::com_ptr<IZoneSet> m_activeZoneSet;
|
||||
GUID m_activeZoneSetId{};
|
||||
std::vector<winrt::com_ptr<IZoneSet>> m_zoneSets;
|
||||
winrt::com_ptr<IZone> m_highlightZone;
|
||||
WPARAM m_keyLast{};
|
||||
size_t m_keyCycle{};
|
||||
int m_gridWidth{};
|
||||
int m_gridHeight{};
|
||||
int m_gridRows{};
|
||||
int m_gridColumns{};
|
||||
int m_switchButtonWidth = 50;
|
||||
int m_switchButtonPadding = 5;
|
||||
int m_switchButtonHover = -1;
|
||||
SIZE m_gridMargins{};
|
||||
RECT m_zoneBuilder{};
|
||||
RECT m_switchButtonContainerRect{};
|
||||
Trace::ZoneWindow::EditorModeActivity m_editorModeActivity;
|
||||
static const UINT m_showAnimationDuration = 200; // ms
|
||||
static const UINT m_flashDuration = 700; // ms
|
||||
};
|
||||
@@ -130,7 +102,7 @@ ZoneWindow::ZoneWindow(
|
||||
|
||||
InitializeId(deviceId, virtualDesktopId);
|
||||
LoadSettings();
|
||||
InitializeZoneSets();
|
||||
InitializeZoneSets(mi);
|
||||
|
||||
WNDCLASSEXW wcex{};
|
||||
wcex.cbSize = sizeof(WNDCLASSEX);
|
||||
@@ -149,7 +121,6 @@ ZoneWindow::ZoneWindow(
|
||||
if (m_window)
|
||||
{
|
||||
MakeWindowTransparent(m_window.get());
|
||||
UpdateGrid(0, 0);
|
||||
if (flashZones)
|
||||
{
|
||||
FlashZones();
|
||||
@@ -157,63 +128,6 @@ ZoneWindow::ZoneWindow(
|
||||
}
|
||||
}
|
||||
|
||||
IFACEMETHODIMP ZoneWindow::ShowZoneWindow(bool activate, bool fadeIn) noexcept
|
||||
{
|
||||
if (!m_window)
|
||||
{
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
m_flashMode = false;
|
||||
|
||||
UINT flags = SWP_NOSIZE | SWP_NOMOVE;
|
||||
if (!activate)
|
||||
{
|
||||
WI_SetFlag(flags, SWP_NOACTIVATE);
|
||||
}
|
||||
|
||||
if (!fadeIn)
|
||||
{
|
||||
WI_SetFlag(flags, SWP_SHOWWINDOW);
|
||||
}
|
||||
|
||||
HWND windowInsertAfter = m_windowMoveSize;
|
||||
if (windowInsertAfter == nullptr)
|
||||
{
|
||||
windowInsertAfter = HWND_TOPMOST;
|
||||
}
|
||||
|
||||
SetWindowPos(m_window.get(), windowInsertAfter, 0, 0, 0, 0, flags);
|
||||
|
||||
if (fadeIn)
|
||||
{
|
||||
AnimateWindow(m_window.get(), m_showAnimationDuration, AW_BLEND);
|
||||
InvalidateRect(m_window.get(), nullptr, true);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
IFACEMETHODIMP ZoneWindow::HideZoneWindow() noexcept
|
||||
{
|
||||
if (!m_window)
|
||||
{
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if (m_editorMode)
|
||||
{
|
||||
ExitEditorMode();
|
||||
}
|
||||
|
||||
ShowWindow(m_window.get(), SW_HIDE);
|
||||
m_keyLast = 0;
|
||||
m_windowMoveSize = nullptr;
|
||||
m_drawHints = false;
|
||||
m_highlightZone = nullptr;
|
||||
m_editorMode = false;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
IFACEMETHODIMP ZoneWindow::MoveSizeEnter(HWND window, bool dragEnabled) noexcept
|
||||
{
|
||||
if (m_windowMoveSize)
|
||||
@@ -225,7 +139,7 @@ IFACEMETHODIMP ZoneWindow::MoveSizeEnter(HWND window, bool dragEnabled) noexcept
|
||||
m_windowMoveSize = window;
|
||||
m_drawHints = true;
|
||||
m_highlightZone = nullptr;
|
||||
ShowZoneWindow(false /*activate*/, true /*fadeIn*/);
|
||||
ShowZoneWindow();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -315,7 +229,53 @@ IFACEMETHODIMP_(void) ZoneWindow::CycleActiveZoneSet(DWORD wparam) noexcept
|
||||
}
|
||||
}
|
||||
|
||||
IFACEMETHODIMP_(void) ZoneWindow::SaveWindowProcessToZoneIndex(HWND window) noexcept
|
||||
{
|
||||
auto processPath = get_process_path(window);
|
||||
if (!processPath.empty())
|
||||
{
|
||||
DWORD zoneIndex = static_cast<DWORD>(m_activeZoneSet->GetZoneIndexFromWindow(window));
|
||||
if (zoneIndex != -1)
|
||||
{
|
||||
RegistryHelpers::SaveAppLastZone(window, processPath.data(), zoneIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#pragma region private
|
||||
void ZoneWindow::ShowZoneWindow() noexcept
|
||||
{
|
||||
if (m_window)
|
||||
{
|
||||
m_flashMode = false;
|
||||
|
||||
UINT flags = SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE;
|
||||
|
||||
HWND windowInsertAfter = m_windowMoveSize;
|
||||
if (windowInsertAfter == nullptr)
|
||||
{
|
||||
windowInsertAfter = HWND_TOPMOST;
|
||||
}
|
||||
|
||||
SetWindowPos(m_window.get(), windowInsertAfter, 0, 0, 0, 0, flags);
|
||||
|
||||
AnimateWindow(m_window.get(), m_showAnimationDuration, AW_BLEND);
|
||||
InvalidateRect(m_window.get(), nullptr, true);
|
||||
}
|
||||
}
|
||||
|
||||
void ZoneWindow::HideZoneWindow() noexcept
|
||||
{
|
||||
if (m_window)
|
||||
{
|
||||
ShowWindow(m_window.get(), SW_HIDE);
|
||||
m_keyLast = 0;
|
||||
m_windowMoveSize = nullptr;
|
||||
m_drawHints = false;
|
||||
m_highlightZone = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void ZoneWindow::InitializeId(PCWSTR deviceId, PCWSTR virtualDesktopId) noexcept
|
||||
{
|
||||
SHStrDup(deviceId, &m_deviceId);
|
||||
@@ -338,17 +298,16 @@ void ZoneWindow::LoadSettings() noexcept
|
||||
wchar_t activeZoneSetId[256];
|
||||
RegistryHelpers::GetString(m_uniqueId, L"ActiveZoneSetId", activeZoneSetId, sizeof(activeZoneSetId));
|
||||
CLSIDFromString(activeZoneSetId, &m_activeZoneSetId);
|
||||
|
||||
RegistryHelpers::GetValue<SIZE>(m_uniqueId, L"GridMargins", &m_gridMargins, sizeof(m_gridMargins));
|
||||
}
|
||||
|
||||
void ZoneWindow::InitializeZoneSets() noexcept
|
||||
void ZoneWindow::InitializeZoneSets(MONITORINFO const& mi) noexcept
|
||||
{
|
||||
LoadZoneSetsFromRegistry();
|
||||
|
||||
if (m_zoneSets.empty())
|
||||
{
|
||||
// Add a "maximize" zone as the only default layout.
|
||||
AddZoneSet(ZoneSetLayout::Grid, 1, 0, 0);
|
||||
AddDefaultZoneSet(mi);
|
||||
}
|
||||
|
||||
if (!m_activeZoneSet)
|
||||
@@ -364,6 +323,7 @@ void ZoneWindow::LoadZoneSetsFromRegistry() noexcept
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ZoneSetPersistedData data{};
|
||||
DWORD dataSize = sizeof(data);
|
||||
wchar_t value[256]{};
|
||||
@@ -380,17 +340,13 @@ void ZoneWindow::LoadZoneSetsFromRegistry() noexcept
|
||||
zoneSetId,
|
||||
data.LayoutId,
|
||||
m_monitor,
|
||||
m_workArea,
|
||||
data.Layout,
|
||||
0,
|
||||
static_cast<int>(data.PaddingInner),
|
||||
static_cast<int>(data.PaddingOuter)));
|
||||
m_workArea));
|
||||
|
||||
if (zoneSet)
|
||||
{
|
||||
for (UINT j = 0; j < data.ZoneCount; j++)
|
||||
{
|
||||
zoneSet->AddZone(MakeZone(data.Zones[j]), false);
|
||||
zoneSet->AddZone(MakeZone(data.Zones[j]));
|
||||
}
|
||||
|
||||
if (zoneSetId == m_activeZoneSetId)
|
||||
@@ -412,28 +368,16 @@ void ZoneWindow::LoadZoneSetsFromRegistry() noexcept
|
||||
}
|
||||
}
|
||||
|
||||
winrt::com_ptr<IZoneSet> ZoneWindow::AddZoneSet(ZoneSetLayout layout, int numZones, int paddingOuter, int paddingInner) noexcept
|
||||
void ZoneWindow::AddDefaultZoneSet(MONITORINFO const& mi) noexcept
|
||||
{
|
||||
GUID zoneSetId;
|
||||
if (SUCCEEDED_LOG(CoCreateGuid(&zoneSetId)))
|
||||
{
|
||||
if (auto zoneSet = MakeZoneSet(ZoneSetConfig(zoneSetId, 0, m_monitor, m_workArea, layout, numZones, paddingOuter, paddingInner)))
|
||||
if (auto zoneSet = MakeZoneSet(ZoneSetConfig(zoneSetId, 0, m_monitor, m_workArea)))
|
||||
{
|
||||
m_zoneSets.emplace_back(zoneSet);
|
||||
return zoneSet;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
zoneSet->AddZone(MakeZone(mi.rcWork));
|
||||
|
||||
void ZoneWindow::MakeActiveZoneSetCustom() noexcept
|
||||
{
|
||||
if (m_activeZoneSet)
|
||||
{
|
||||
if (auto customZoneSet = m_activeZoneSet->MakeCustomClone())
|
||||
{
|
||||
UpdateActiveZoneSet(customZoneSet.get());
|
||||
m_zoneSets.emplace_back(customZoneSet);
|
||||
m_zoneSets.emplace_back(zoneSet);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -487,26 +431,6 @@ LRESULT ZoneWindow::WndProc(UINT message, WPARAM wparam, LPARAM lparam) noexcept
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_LBUTTONDOWN:
|
||||
OnLButtonDown(lparam);
|
||||
break;
|
||||
|
||||
case WM_LBUTTONUP:
|
||||
OnLButtonUp(lparam);
|
||||
break;
|
||||
|
||||
case WM_RBUTTONUP:
|
||||
OnRButtonUp(lparam);
|
||||
break;
|
||||
|
||||
case WM_MOUSEMOVE:
|
||||
OnMouseMove(lparam);
|
||||
break;
|
||||
|
||||
case WM_KEYUP:
|
||||
OnKeyUp(wparam);
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
return DefWindowProc(m_window.get(), message, wparam, lparam);
|
||||
@@ -515,201 +439,10 @@ LRESULT ZoneWindow::WndProc(UINT message, WPARAM wparam, LPARAM lparam) noexcept
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ZoneWindow::OnLButtonDown(LPARAM lparam) noexcept
|
||||
{
|
||||
m_buttonDown = true;
|
||||
m_ptDown = { GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam) };
|
||||
}
|
||||
|
||||
void ZoneWindow::OnLButtonUp(LPARAM lparam) noexcept
|
||||
{
|
||||
POINT const ptClient = { GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam) };
|
||||
if (m_buttonDown && m_activeZoneSet)
|
||||
{
|
||||
if (m_editorMode)
|
||||
{
|
||||
bool const ctrl = GetAsyncKeyState(VK_CONTROL) & 0x8000;
|
||||
if (ctrl)
|
||||
{
|
||||
auto zone = ZoneFromPoint(ptClient);
|
||||
if (zone)
|
||||
{
|
||||
m_activeZoneSet->RemoveZone(zone);
|
||||
|
||||
int const padding = m_activeZoneSet->GetInnerPadding();
|
||||
RECT const zoneRect = zone->GetZoneRect();
|
||||
int const zoneRectWidthHalf = ((zoneRect.right - zoneRect.left) / 2) - padding;
|
||||
RECT rectLeft = zoneRect;
|
||||
rectLeft.right = rectLeft.left + zoneRectWidthHalf;
|
||||
m_activeZoneSet->AddZone(MakeZone(rectLeft), false);
|
||||
|
||||
RECT rectRight = zoneRect;
|
||||
rectRight.left = rectLeft.right + padding;
|
||||
m_activeZoneSet->AddZone(MakeZone(rectRight), false);
|
||||
|
||||
m_activeZoneSet->Save();
|
||||
}
|
||||
}
|
||||
else if (m_activeZoneSet && !IsRectEmpty(&m_zoneBuilder))
|
||||
{
|
||||
m_activeZoneSet->AddZone(MakeZone(m_zoneBuilder), true);
|
||||
}
|
||||
}
|
||||
else if (!m_flashMode && !m_editorMode && !m_drawHints)
|
||||
{
|
||||
if (PtInRect(&m_switchButtonContainerRect, ptClient))
|
||||
{
|
||||
auto switchButtonIndex = GetSwitchButtonIndexFromPoint(ptClient);
|
||||
if (switchButtonIndex != -1)
|
||||
{
|
||||
CycleActiveZoneSetInternal('0' + switchButtonIndex, Trace::ZoneWindow::InputMode::Mouse);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (auto zone = ZoneFromPoint(ptClient))
|
||||
{
|
||||
m_activeZoneSet->MoveZoneToFront(zone);
|
||||
m_activeZoneSet->Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_zoneBuilder = {};
|
||||
m_buttonDown = false;
|
||||
InvalidateRect(m_window.get(), nullptr, true);
|
||||
}
|
||||
|
||||
void ZoneWindow::OnRButtonUp(LPARAM lparam) noexcept
|
||||
{
|
||||
POINT const ptClient = { GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam) };
|
||||
if (m_activeZoneSet)
|
||||
{
|
||||
if (m_editorMode)
|
||||
{
|
||||
if (bool const ctrl = GetAsyncKeyState(VK_CONTROL) & 0x8000)
|
||||
{
|
||||
if (auto zone = ZoneFromPoint(ptClient))
|
||||
{
|
||||
m_activeZoneSet->RemoveZone(zone);
|
||||
|
||||
int const padding = m_activeZoneSet->GetInnerPadding();
|
||||
RECT const zoneRect = zone->GetZoneRect();
|
||||
int const zoneRectHeightHalf = ((zoneRect.bottom - zoneRect.top) / 2) - padding;
|
||||
RECT rectTop = zoneRect;
|
||||
rectTop.bottom = rectTop.top + zoneRectHeightHalf;
|
||||
m_activeZoneSet->AddZone(MakeZone(rectTop), false);
|
||||
|
||||
RECT rectBottom = zoneRect;
|
||||
rectBottom.top = rectTop.bottom + padding;
|
||||
m_activeZoneSet->AddZone(MakeZone(rectBottom), false);
|
||||
|
||||
m_activeZoneSet->Save();
|
||||
}
|
||||
}
|
||||
else if (auto zone = ZoneFromPoint(ptClient))
|
||||
{
|
||||
m_activeZoneSet->RemoveZone(zone);
|
||||
m_activeZoneSet->Save();
|
||||
}
|
||||
}
|
||||
else if (auto zone = ZoneFromPoint(ptClient))
|
||||
{
|
||||
m_activeZoneSet->MoveZoneToBack(zone);
|
||||
m_activeZoneSet->Save();
|
||||
}
|
||||
}
|
||||
InvalidateRect(m_window.get(), nullptr, true);
|
||||
}
|
||||
|
||||
void ZoneWindow::OnMouseMove(LPARAM lparam) noexcept
|
||||
{
|
||||
int const oldHover = m_switchButtonHover;
|
||||
m_switchButtonHover = -1;
|
||||
|
||||
POINT const ptClient = { GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam) };
|
||||
if (m_buttonDown && m_editorMode && ((ptClient.x != m_ptLast.x) || (ptClient.y != m_ptLast.y)))
|
||||
{
|
||||
RECT start;
|
||||
int const startColumn = max(0, min(m_gridColumns, ((m_ptDown.x - m_gridMargins.cx) / m_gridWidth)));
|
||||
int const startRow = max(0, min(m_gridRows, ((m_ptDown.y - m_gridMargins.cy) / m_gridHeight)));
|
||||
start.left = startColumn * m_gridWidth;
|
||||
start.top = startRow * m_gridHeight;
|
||||
start.right = start.left + m_gridWidth;
|
||||
start.bottom = start.top + m_gridHeight;
|
||||
OffsetRect(&start, m_gridMargins.cx, m_gridMargins.cy);
|
||||
|
||||
RECT current;
|
||||
int const currentColumn = max(0, min(m_gridColumns, ((ptClient.x - m_gridMargins.cx) / m_gridWidth)));
|
||||
int const currentRow = max(0, min(m_gridRows, ((ptClient.y - m_gridMargins.cy) / m_gridHeight)));
|
||||
current.left = currentColumn * m_gridWidth;
|
||||
current.top = currentRow * m_gridHeight;
|
||||
current.right = current.left + m_gridWidth;
|
||||
current.bottom = current.top + m_gridHeight;
|
||||
OffsetRect(¤t, m_gridMargins.cx, m_gridMargins.cy);
|
||||
|
||||
RECT invalidateRect = m_zoneBuilder;
|
||||
POINT const last = {
|
||||
m_gridMargins.cx + ((m_ptLast.x - m_gridMargins.cx) / m_gridWidth),
|
||||
m_gridMargins.cy + ((m_ptLast.y - m_gridMargins.cy) / m_gridHeight)
|
||||
};
|
||||
|
||||
m_ptLast = ptClient;
|
||||
UnionRect(&m_zoneBuilder, &start, ¤t);
|
||||
UnionRect(&invalidateRect, &invalidateRect, &m_zoneBuilder);
|
||||
|
||||
if ((current.left != last.x) || (current.top != last.y))
|
||||
{
|
||||
InvalidateRect(m_window.get(), &invalidateRect, true);
|
||||
}
|
||||
}
|
||||
else if (!m_flashMode && !m_editorMode && !m_drawHints && PtInRect(&m_switchButtonContainerRect, ptClient))
|
||||
{
|
||||
m_switchButtonHover = GetSwitchButtonIndexFromPoint(ptClient);
|
||||
}
|
||||
|
||||
if (oldHover != m_switchButtonHover)
|
||||
{
|
||||
InvalidateRect(m_window.get(), &m_switchButtonContainerRect, true);
|
||||
}
|
||||
}
|
||||
|
||||
void ZoneWindow::DrawBackdrop(wil::unique_hdc& hdc, RECT const& clientRect) noexcept
|
||||
{
|
||||
if (m_windowMoveSize || m_flashMode)
|
||||
{
|
||||
FillRectARGB(hdc, &clientRect, 0, RGB(0, 0, 0), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
FillRectARGB(hdc, &clientRect, 225, RGB(0, 0, 0), false);
|
||||
}
|
||||
}
|
||||
|
||||
void ZoneWindow::DrawGridLines(wil::unique_hdc& hdc, RECT const& clientRect) noexcept
|
||||
{
|
||||
if (m_editorMode)
|
||||
{
|
||||
COLORREF const color = RGB(225, 225, 225);
|
||||
|
||||
wil::unique_hpen pen{ CreatePen(PS_SOLID, 1, color) };
|
||||
wil::unique_select_object oldPen{ SelectObject(hdc.get(), pen.get()) };
|
||||
for (int i = 0; i <= m_gridRows; i++)
|
||||
{
|
||||
int const y = m_gridMargins.cy + (i * m_gridHeight);
|
||||
MoveToEx(hdc.get(), m_gridMargins.cx, y, nullptr);
|
||||
LineTo(hdc.get(), clientRect.right - m_gridMargins.cx, y);
|
||||
}
|
||||
|
||||
for (int i = 0; i <= m_gridColumns; i++)
|
||||
{
|
||||
int const x = m_gridMargins.cx + (i * m_gridWidth);
|
||||
MoveToEx(hdc.get(), x, m_gridMargins.cy, nullptr);
|
||||
LineTo(hdc.get(), x, clientRect.bottom - m_gridMargins.cy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ZoneWindow::DrawZone(wil::unique_hdc& hdc, ColorSetting const& colorSetting, winrt::com_ptr<IZone> zone) noexcept
|
||||
{
|
||||
@@ -817,7 +550,6 @@ void ZoneWindow::DrawActiveZoneSet(wil::unique_hdc& hdc, RECT const& clientRect)
|
||||
|
||||
// { fillAlpha, fill, borderAlpha, border, thickness }
|
||||
ColorSetting const colorHints { 225, RGB(81, 92, 107), 255, RGB(104, 118, 138), -2 };
|
||||
ColorSetting const colorEditorMode { 240, RGB(100, 100, 100), 255, RGB(50, 50, 50), -5 };
|
||||
ColorSetting colorViewer { 225, 0, 255, RGB(40, 50, 60), -2 };
|
||||
ColorSetting colorHighlight { 225, 0, 255, 0, -2 };
|
||||
ColorSetting const colorFlash { 200, RGB(81, 92, 107), 200, RGB(104, 118, 138), -2 };
|
||||
@@ -832,6 +564,7 @@ void ZoneWindow::DrawActiveZoneSet(wil::unique_hdc& hdc, RECT const& clientRect)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (zone != m_highlightZone)
|
||||
{
|
||||
if (m_flashMode)
|
||||
@@ -842,11 +575,6 @@ void ZoneWindow::DrawActiveZoneSet(wil::unique_hdc& hdc, RECT const& clientRect)
|
||||
{
|
||||
DrawZone(hdc, colorHints, zone);
|
||||
}
|
||||
else if (m_editorMode)
|
||||
{
|
||||
DrawZone(hdc, colorEditorMode, zone);
|
||||
}
|
||||
else
|
||||
{
|
||||
colorViewer.fill = colors[colorIndex];
|
||||
DrawZone(hdc, colorViewer, zone);
|
||||
@@ -868,72 +596,6 @@ void ZoneWindow::DrawActiveZoneSet(wil::unique_hdc& hdc, RECT const& clientRect)
|
||||
}
|
||||
}
|
||||
|
||||
void ZoneWindow::DrawZoneBuilder(wil::unique_hdc& hdc, RECT const& clientRect) noexcept
|
||||
{
|
||||
if (m_editorMode && m_buttonDown)
|
||||
{
|
||||
COLORREF const colorDrag = RGB(255, 255, 255);
|
||||
FillRectARGB(hdc, &m_zoneBuilder, 255, colorDrag, false);
|
||||
}
|
||||
}
|
||||
|
||||
void ZoneWindow::DrawSwitchButtons(wil::unique_hdc& hdc, RECT const& clientRect) noexcept
|
||||
{
|
||||
if (!m_editorMode && !m_drawHints && !m_flashMode)
|
||||
{
|
||||
Rect const rect(clientRect);
|
||||
|
||||
int const numButtons = 9;
|
||||
int const containerRectWidth = (m_switchButtonWidth * numButtons) + (m_switchButtonPadding * numButtons) + m_switchButtonPadding;
|
||||
int const containerRectHeight = 42;
|
||||
|
||||
m_switchButtonContainerRect = { (rect.width() / 2) - (containerRectWidth / 2), 0, (rect.width() / 2) + (containerRectWidth / 2), containerRectHeight };
|
||||
|
||||
COLORREF const switchButtonContainerColor = RGB(50, 50, 50);
|
||||
BYTE const switchButtonContainerAlpha = 150;
|
||||
FillRectARGB(hdc, &m_switchButtonContainerRect, switchButtonContainerAlpha, switchButtonContainerColor, true);
|
||||
|
||||
COLORREF const fillColor = RGB(128, 128, 128);
|
||||
COLORREF const hoverColor = RGB(255, 255, 255);
|
||||
COLORREF const activeColor = RGB(0, 128, 0);
|
||||
COLORREF const activeHoverColor = RGB(0, 200, 0);
|
||||
|
||||
size_t activeZoneCount = 0;
|
||||
if (m_activeZoneSet)
|
||||
{
|
||||
activeZoneCount = m_activeZoneSet->GetZones().size();
|
||||
}
|
||||
|
||||
int x = m_switchButtonContainerRect.left + m_switchButtonPadding;
|
||||
for (UINT i = 1; i < 10; i++)
|
||||
{
|
||||
POINT const offset = { x, 5 };
|
||||
int const padding = 1;
|
||||
int const size = 10;
|
||||
|
||||
bool const active = activeZoneCount == i;
|
||||
bool const hover = i == m_switchButtonHover;
|
||||
|
||||
COLORREF color = fillColor;
|
||||
if (active && hover)
|
||||
{
|
||||
color = activeHoverColor;
|
||||
}
|
||||
else if (active)
|
||||
{
|
||||
color = activeColor;
|
||||
}
|
||||
else if (hover)
|
||||
{
|
||||
color = hoverColor;
|
||||
}
|
||||
|
||||
DrawIndex(hdc, offset, i, padding, size, false /*flipX*/, false /*flipY*/, color);
|
||||
x += m_switchButtonWidth + m_switchButtonPadding;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ZoneWindow::OnPaint(wil::unique_hdc& hdc) noexcept
|
||||
{
|
||||
RECT clientRect;
|
||||
@@ -944,155 +606,22 @@ void ZoneWindow::OnPaint(wil::unique_hdc& hdc) noexcept
|
||||
if (bufferedPaint)
|
||||
{
|
||||
DrawBackdrop(hdcMem, clientRect);
|
||||
DrawGridLines(hdcMem, clientRect);
|
||||
DrawActiveZoneSet(hdcMem, clientRect);
|
||||
DrawZoneBuilder(hdcMem, clientRect);
|
||||
DrawSwitchButtons(hdcMem, clientRect);
|
||||
EndBufferedPaint(bufferedPaint, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
void ZoneWindow::UpdateGrid(int stepColumns, int stepRows) noexcept
|
||||
{
|
||||
bool const shift = GetAsyncKeyState(VK_SHIFT) & 0x8000;
|
||||
bool const control = GetAsyncKeyState(VK_CONTROL) & 0x8000;
|
||||
|
||||
RECT clientRect;
|
||||
::GetClientRect(m_window.get(), &clientRect);
|
||||
InflateRect(&clientRect, -m_gridMargins.cx, -m_gridMargins.cy);
|
||||
|
||||
Rect gridRect(clientRect);
|
||||
if (control || (!stepColumns && !stepRows))
|
||||
{
|
||||
// Reset
|
||||
m_gridColumns = (gridRect.width() / 50) + 1;
|
||||
m_gridRows = (gridRect.height() / 50) + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
stepColumns = stepColumns * (shift ? 5 : 1);
|
||||
stepRows = stepRows * (shift ? 5 : 1);
|
||||
|
||||
m_gridColumns = max(1, m_gridColumns + stepColumns);
|
||||
m_gridRows = max(1, m_gridRows + stepRows);
|
||||
}
|
||||
|
||||
m_gridWidth = gridRect.width() / m_gridColumns;
|
||||
m_gridHeight = gridRect.height() / m_gridRows;
|
||||
}
|
||||
|
||||
void ZoneWindow::UpdateGridMargins(int inc) noexcept
|
||||
{
|
||||
bool const shift = GetAsyncKeyState(VK_SHIFT) & 0x8000;
|
||||
bool const control = GetAsyncKeyState(VK_CONTROL) & 0x8000;
|
||||
if (control)
|
||||
{
|
||||
m_gridMargins.cx = 0;
|
||||
m_gridMargins.cy = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
inc = inc * (shift ? 5 : 1);
|
||||
m_gridMargins.cx = max(0, m_gridMargins.cx + inc);
|
||||
m_gridMargins.cy = max(0, m_gridMargins.cy + inc);
|
||||
}
|
||||
UpdateGrid(0, 0);
|
||||
|
||||
RegistryHelpers::SetValue<SIZE>(m_uniqueId, L"GridMargins", m_gridMargins, sizeof(m_gridMargins));
|
||||
}
|
||||
|
||||
void ZoneWindow::EnterEditorMode() noexcept
|
||||
{
|
||||
m_editorModeActivity.Start();
|
||||
MakeActiveZoneSetCustom();
|
||||
m_editorMode = true;
|
||||
}
|
||||
|
||||
void ZoneWindow::ExitEditorMode() noexcept
|
||||
{
|
||||
m_editorMode = false;
|
||||
if (m_activeZoneSet)
|
||||
{
|
||||
m_activeZoneSet->Save();
|
||||
}
|
||||
m_editorModeActivity.Stop(m_activeZoneSet);
|
||||
}
|
||||
|
||||
void ZoneWindow::OnKeyUp(WPARAM wparam) noexcept
|
||||
{
|
||||
bool fRedraw = false;
|
||||
Trace::ZoneWindow::KeyUp(wparam, m_editorMode);
|
||||
Trace::ZoneWindow::KeyUp(wparam);
|
||||
|
||||
if ((wparam >= '0') && (wparam <= '9'))
|
||||
{
|
||||
CycleActiveZoneSetInternal(static_cast<DWORD>(wparam), Trace::ZoneWindow::InputMode::Keyboard);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (wparam)
|
||||
{
|
||||
case VK_DELETE:
|
||||
case 'd':
|
||||
case 'D':
|
||||
{
|
||||
// Delete active zone set
|
||||
for (auto iter = m_zoneSets.begin(); iter != m_zoneSets.end(); iter++)
|
||||
{
|
||||
if (iter->get() == m_activeZoneSet.get())
|
||||
{
|
||||
RegistryHelpers::DeleteZoneSet(m_workArea, m_activeZoneSet->Id());
|
||||
m_zoneSets.erase(iter);
|
||||
m_activeZoneSet = nullptr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
case 'R':
|
||||
{
|
||||
// Reset zone sets for current work area
|
||||
m_zoneSets.clear();
|
||||
m_activeZoneSet = nullptr;
|
||||
RegistryHelpers::DeleteAllZoneSets(m_workArea);
|
||||
InitializeZoneSets();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'e':
|
||||
case 'E':
|
||||
{
|
||||
// Toggle editor mode
|
||||
m_editorMode ? ExitEditorMode() : EnterEditorMode();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
case 'C':
|
||||
{
|
||||
// Create a custom zone
|
||||
if (auto zoneSet = AddZoneSet(ZoneSetLayout::Custom, 0, 0, 0))
|
||||
{
|
||||
UpdateActiveZoneSet(zoneSet.get());
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case VK_LEFT: UpdateGrid(-1, 0); break;
|
||||
case VK_RIGHT: UpdateGrid(1, 0); break;
|
||||
|
||||
case VK_UP: UpdateGrid(0, 1); break;
|
||||
case VK_DOWN: UpdateGrid(0, -1); break;
|
||||
|
||||
case VK_PRIOR: UpdateGridMargins(10); break;
|
||||
case VK_NEXT: UpdateGridMargins(-10); break;
|
||||
|
||||
case VK_ESCAPE: m_host->ToggleZoneViewers(); break;
|
||||
}
|
||||
}
|
||||
InvalidateRect(m_window.get(), nullptr, true);
|
||||
}
|
||||
}
|
||||
|
||||
winrt::com_ptr<IZone> ZoneWindow::ZoneFromPoint(POINT pt) noexcept
|
||||
{
|
||||
@@ -1105,69 +634,8 @@ winrt::com_ptr<IZone> ZoneWindow::ZoneFromPoint(POINT pt) noexcept
|
||||
|
||||
void ZoneWindow::ChooseDefaultActiveZoneSet() noexcept
|
||||
{
|
||||
MONITORINFO mi{};
|
||||
mi.cbSize = sizeof(mi);
|
||||
if (GetMonitorInfoW(m_monitor, &mi))
|
||||
{
|
||||
Rect const monitorRect(mi.rcMonitor);
|
||||
|
||||
if ((monitorRect.width() == 3840) && (monitorRect.height() == 2160))
|
||||
{
|
||||
// For 4k screens, pick a layout with 5 zones in focus mode as the default.
|
||||
winrt::com_ptr<IZoneSet> zoneSetBest;
|
||||
for (auto zoneSet : m_zoneSets)
|
||||
{
|
||||
auto zones = zoneSet->GetZones();
|
||||
if (zones.size() == 5)
|
||||
{
|
||||
if (!zoneSetBest)
|
||||
{
|
||||
zoneSetBest = zoneSet;
|
||||
}
|
||||
else if (zoneSet->GetLayout() == ZoneSetLayout::Focus)
|
||||
{
|
||||
zoneSetBest = zoneSet;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (zoneSetBest)
|
||||
{
|
||||
UpdateActiveZoneSet(zoneSetBest.get());
|
||||
}
|
||||
}
|
||||
else if (monitorRect.aspectRatio() < 40)
|
||||
{
|
||||
// Ultrawide, prefer 3 columns
|
||||
winrt::com_ptr<IZoneSet> zoneSetBest;
|
||||
for (auto zoneSet : m_zoneSets)
|
||||
{
|
||||
auto zones = zoneSet->GetZones();
|
||||
if (zones.size() == 3)
|
||||
{
|
||||
if (!zoneSetBest)
|
||||
{
|
||||
zoneSetBest = zoneSet;
|
||||
}
|
||||
else if (zoneSet->GetLayout() == ZoneSetLayout::Row)
|
||||
{
|
||||
zoneSetBest = zoneSet;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (zoneSetBest)
|
||||
{
|
||||
UpdateActiveZoneSet(zoneSetBest.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_activeZoneSet)
|
||||
{
|
||||
// Couldn't find a ZoneSet to use so just use the first one.
|
||||
auto zoneSet = m_zoneSets.at(0);
|
||||
UpdateActiveZoneSet(zoneSet.get());
|
||||
}
|
||||
@@ -1196,8 +664,6 @@ bool ZoneWindow::IsOccluded(POINT pt, size_t index) noexcept
|
||||
}
|
||||
|
||||
void ZoneWindow::CycleActiveZoneSetInternal(DWORD wparam, Trace::ZoneWindow::InputMode mode) noexcept
|
||||
{
|
||||
if (!m_editorMode)
|
||||
{
|
||||
Trace::ZoneWindow::CycleActiveZoneSet(m_activeZoneSet, mode);
|
||||
if (m_keyLast != wparam)
|
||||
@@ -1241,7 +707,6 @@ void ZoneWindow::CycleActiveZoneSetInternal(DWORD wparam, Trace::ZoneWindow::Inp
|
||||
m_host->MoveWindowsOnActiveZoneSetChange();
|
||||
m_highlightZone = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void ZoneWindow::FlashZones() noexcept
|
||||
{
|
||||
@@ -1254,25 +719,6 @@ void ZoneWindow::FlashZones() noexcept
|
||||
}).detach();
|
||||
}
|
||||
|
||||
int ZoneWindow::GetSwitchButtonIndexFromPoint(POINT ptClient) noexcept
|
||||
{
|
||||
auto const switchButtonIndex = ((ptClient.x - m_switchButtonContainerRect.left) / (m_switchButtonWidth + m_switchButtonPadding)) + 1;
|
||||
return ((switchButtonIndex > 0) && (switchButtonIndex < 10)) ? switchButtonIndex : -1;
|
||||
}
|
||||
|
||||
IFACEMETHODIMP_(void) ZoneWindow::SaveWindowProcessToZoneIndex(HWND window) noexcept
|
||||
{
|
||||
auto processPath = get_process_path(window);
|
||||
if (!processPath.empty())
|
||||
{
|
||||
DWORD zoneIndex = static_cast<DWORD>(m_activeZoneSet->GetZoneIndexFromWindow(window));
|
||||
if (zoneIndex != -1)
|
||||
{
|
||||
RegistryHelpers::SaveAppLastZone(window, processPath.data(), zoneIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
typedef BOOL(WINAPI *GetDpiForMonitorInternalFunc)(HMONITOR, UINT, UINT*, UINT*);
|
||||
UINT ZoneWindow::GetDpiForMonitor() noexcept
|
||||
{
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
interface __declspec(uuid("{7F017528-8110-4FB3-BE41-F472969C2560}")) IZoneWindow : public IUnknown
|
||||
{
|
||||
IFACEMETHOD(ShowZoneWindow)(bool activate, bool fadeIn) = 0;
|
||||
IFACEMETHOD(HideZoneWindow)() = 0;
|
||||
IFACEMETHOD(MoveSizeEnter)(HWND window, bool dragEnabled) = 0;
|
||||
IFACEMETHOD(MoveSizeUpdate)(POINT const& ptScreen, bool dragEnabled) = 0;
|
||||
IFACEMETHOD(MoveSizeEnd)(HWND window, POINT const& ptScreen) = 0;
|
||||
|
||||
Binary file not shown.
@@ -6,11 +6,10 @@
|
||||
#define IDS_SETTING_DESCRIPTION_VIRTUALDESKTOPCHANGE_MOVEWINDOWS 106
|
||||
#define IDS_SETTING_DESCRIPTION_ZONEHIGHLIGHTCOLOR 107
|
||||
#define IDS_SETTING_DESCRIPTION_APPLASTZONE_MOVEWINDOWS 108
|
||||
#define IDS_SETTING_DESCRIPTION_USE_STANDALONE_EDITOR 109
|
||||
#define IDS_SETTING_DESCRIPTION_USE_CURSORPOS_EDITOR_STARTUPSCREEN 110
|
||||
#define IDS_SETTING_DESCRIPTION 111
|
||||
#define IDS_SETTING_LAUNCH_EDITOR_LABEL 112
|
||||
#define IDS_SETTING_LAUNCH_EDITOR_BUTTON 113
|
||||
#define IDS_SETTING_LAUNCH_EDITOR_DESCRIPTION 114
|
||||
#define IDS_SETTING_LAUNCH_EDITOR_HOTKEY_LABEL 115
|
||||
#define IDS_SETTING_EXCLCUDED_APPS_DESCRIPTION 116
|
||||
#define IDS_SETTING_DESCRIPTION_USE_CURSORPOS_EDITOR_STARTUPSCREEN 109
|
||||
#define IDS_SETTING_DESCRIPTION 110
|
||||
#define IDS_SETTING_LAUNCH_EDITOR_LABEL 111
|
||||
#define IDS_SETTING_LAUNCH_EDITOR_BUTTON 112
|
||||
#define IDS_SETTING_LAUNCH_EDITOR_DESCRIPTION 113
|
||||
#define IDS_SETTING_LAUNCH_EDITOR_HOTKEY_LABEL 114
|
||||
#define IDS_SETTING_EXCLCUDED_APPS_DESCRIPTION 115
|
||||
|
||||
@@ -12,7 +12,6 @@ struct ZoneSetInfo
|
||||
{
|
||||
size_t NumberOfZones = 0;
|
||||
size_t NumberOfWindows = 0;
|
||||
ZoneSetLayout Layout = ZoneSetLayout::Custom;
|
||||
};
|
||||
|
||||
ZoneSetInfo GetZoneSetInfo(_In_opt_ winrt::com_ptr<IZoneSet> set) noexcept
|
||||
@@ -22,7 +21,6 @@ ZoneSetInfo GetZoneSetInfo(_In_opt_ winrt::com_ptr<IZoneSet> set) noexcept
|
||||
{
|
||||
auto zones = set->GetZones();
|
||||
info.NumberOfZones = zones.size();
|
||||
info.Layout = set->GetLayout();
|
||||
info.NumberOfWindows = std::count_if(zones.cbegin(), zones.cend(), [&](winrt::com_ptr<IZone> zone)
|
||||
{
|
||||
return !zone->IsEmpty();
|
||||
@@ -31,7 +29,6 @@ ZoneSetInfo GetZoneSetInfo(_In_opt_ winrt::com_ptr<IZoneSet> set) noexcept
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
void Trace::RegisterProvider() noexcept
|
||||
{
|
||||
TraceLoggingRegister(g_hProvider);
|
||||
@@ -52,16 +49,6 @@ void Trace::FancyZones::EnableFancyZones(bool enabled) noexcept
|
||||
TraceLoggingBoolean(enabled, "Enabled"));
|
||||
}
|
||||
|
||||
void Trace::FancyZones::ToggleZoneViewers(bool visible) noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
g_hProvider,
|
||||
"FancyZones_ToggleZoneViewers",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE),
|
||||
TraceLoggingBoolean(visible, "Visible"));
|
||||
}
|
||||
|
||||
void Trace::FancyZones::OnKeyDown(DWORD vkCode, bool win, bool control, bool inMoveSize) noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
@@ -100,15 +87,14 @@ void Trace::VirtualDesktopChanged() noexcept
|
||||
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE));
|
||||
}
|
||||
|
||||
void Trace::ZoneWindow::KeyUp(WPARAM wParam, bool isEditorMode) noexcept
|
||||
void Trace::ZoneWindow::KeyUp(WPARAM wParam) noexcept
|
||||
{
|
||||
TraceLoggingWrite(
|
||||
g_hProvider,
|
||||
"FancyZones_ZoneWindowKeyUp",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE),
|
||||
TraceLoggingValue(wParam, "KeyboardValue"),
|
||||
TraceLoggingBoolean(isEditorMode, "EditorMode"));
|
||||
TraceLoggingValue(wParam, "KeyboardValue"));
|
||||
}
|
||||
|
||||
void Trace::ZoneWindow::MoveSizeEnd(_In_opt_ winrt::com_ptr<IZoneSet> activeSet) noexcept
|
||||
@@ -121,8 +107,7 @@ void Trace::ZoneWindow::MoveSizeEnd(_In_opt_ winrt::com_ptr<IZoneSet> activeSet)
|
||||
TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE),
|
||||
TraceLoggingValue(reinterpret_cast<void*>(activeSet.get()), "ActiveSet"),
|
||||
TraceLoggingValue(zoneInfo.NumberOfZones, "NumberOfZones"),
|
||||
TraceLoggingValue(zoneInfo.NumberOfWindows, "NumberOfWindows"),
|
||||
TraceLoggingValue(static_cast<int>(zoneInfo.Layout), "LayoutKind"));
|
||||
TraceLoggingValue(zoneInfo.NumberOfWindows, "NumberOfWindows"));
|
||||
}
|
||||
|
||||
void Trace::ZoneWindow::CycleActiveZoneSet(_In_opt_ winrt::com_ptr<IZoneSet> activeSet, InputMode mode) noexcept
|
||||
@@ -136,29 +121,5 @@ void Trace::ZoneWindow::CycleActiveZoneSet(_In_opt_ winrt::com_ptr<IZoneSet> act
|
||||
TraceLoggingValue(reinterpret_cast<void*>(activeSet.get()), "ActiveSet"),
|
||||
TraceLoggingValue(zoneInfo.NumberOfZones, "NumberOfZones"),
|
||||
TraceLoggingValue(zoneInfo.NumberOfWindows, "NumberOfWindows"),
|
||||
TraceLoggingValue(static_cast<int>(zoneInfo.Layout), "LayoutKind"),
|
||||
TraceLoggingValue(static_cast<int>(mode), "InputMode"));
|
||||
}
|
||||
|
||||
void Trace::ZoneWindow::EditorModeActivity::Start() noexcept
|
||||
{
|
||||
m_activity = TraceLoggingActivity<g_hProvider, PROJECT_KEYWORD_MEASURE>();
|
||||
TraceLoggingWriteStart(
|
||||
m_activity.value(),
|
||||
"FancyZones_Activity_EditorMode",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance));
|
||||
}
|
||||
|
||||
void Trace::ZoneWindow::EditorModeActivity::Stop(_In_opt_ winrt::com_ptr<IZoneSet> activeSet) noexcept
|
||||
{
|
||||
auto const zoneInfo = GetZoneSetInfo(activeSet);
|
||||
TraceLoggingWriteStop(
|
||||
m_activity.value(),
|
||||
"FancyZones_Activity_EditorMode",
|
||||
ProjectTelemetryPrivacyDataTag(ProjectTelemetryTag_ProductAndServicePerformance),
|
||||
TraceLoggingValue(reinterpret_cast<void*>(activeSet.get()), "ActiveSet"),
|
||||
TraceLoggingValue(zoneInfo.NumberOfZones, "NumberOfZones"),
|
||||
TraceLoggingValue(zoneInfo.NumberOfWindows, "NumberOfWindows"),
|
||||
TraceLoggingValue(static_cast<int>(zoneInfo.Layout), "LayoutKind"));
|
||||
m_activity.reset();
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ public:
|
||||
{
|
||||
public:
|
||||
static void EnableFancyZones(bool enabled) noexcept;
|
||||
static void ToggleZoneViewers(bool visible) noexcept;
|
||||
static void OnKeyDown(DWORD vkCode, bool win, bool control, bool inMoveSize) noexcept;
|
||||
};
|
||||
|
||||
@@ -29,17 +28,8 @@ public:
|
||||
Mouse
|
||||
};
|
||||
|
||||
static void KeyUp(WPARAM wParam, bool isEditorMode) noexcept;
|
||||
static void KeyUp(WPARAM wparam) noexcept;
|
||||
static void MoveSizeEnd(_In_opt_ winrt::com_ptr<IZoneSet> activeSet) noexcept;
|
||||
static void CycleActiveZoneSet(_In_opt_ winrt::com_ptr<IZoneSet> activeSet, InputMode mode) noexcept;
|
||||
|
||||
class EditorModeActivity
|
||||
{
|
||||
public:
|
||||
void Start() noexcept;
|
||||
void Stop(_In_opt_ winrt::com_ptr<IZoneSet> activeSet) noexcept;
|
||||
private:
|
||||
std::optional<TraceLoggingActivity<g_hProvider, PROJECT_KEYWORD_MEASURE>> m_activity{};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -12,30 +12,24 @@ namespace FancyZonesUnitTests
|
||||
{
|
||||
GUID zoneSetId{};
|
||||
CoCreateGuid(&zoneSetId);
|
||||
constexpr size_t zoneCount = 0;
|
||||
constexpr WORD layoutId = 0xFFFF;
|
||||
constexpr int outerPadding = 3;
|
||||
constexpr int innerPadding = 4;
|
||||
|
||||
ZoneSetConfig config(zoneSetId, layoutId, Mocks::Monitor(), L"WorkAreaIn", ZoneSetLayout::Grid, zoneCount, outerPadding, innerPadding);
|
||||
ZoneSetConfig config(zoneSetId, layoutId, Mocks::Monitor(), L"WorkAreaIn");
|
||||
winrt::com_ptr<IZoneSet> set = MakeZoneSet(config);
|
||||
Assert::IsNotNull(&set);
|
||||
CustomAssert::AreEqual(set->Id(), zoneSetId);
|
||||
CustomAssert::AreEqual(set->LayoutId(), layoutId);
|
||||
Assert::IsTrue(set->GetLayout() == ZoneSetLayout::Grid);
|
||||
Assert::AreEqual(set->GetZones().size(), zoneCount);
|
||||
Assert::AreEqual(set->GetInnerPadding(), innerPadding);
|
||||
}
|
||||
|
||||
TEST_METHOD(TestAddZone)
|
||||
{
|
||||
ZoneSetConfig config({}, 0xFFFF, Mocks::Monitor(), L"WorkAreaIn", ZoneSetLayout::Grid, 0, 3, 4);
|
||||
ZoneSetConfig config({}, 0xFFFF, Mocks::Monitor(), L"WorkAreaIn");
|
||||
winrt::com_ptr<IZoneSet> set = MakeZoneSet(config);
|
||||
|
||||
// Add a zone
|
||||
{
|
||||
winrt::com_ptr<IZone> zone = MakeZone({ 0, 0, 100, 100 });
|
||||
set->AddZone(zone, false /*front*/);
|
||||
set->AddZone(zone);
|
||||
auto zones = set->GetZones();
|
||||
Assert::IsTrue(zones.size() == 1);
|
||||
Assert::IsTrue(zones[0] == zone);
|
||||
@@ -45,7 +39,7 @@ namespace FancyZonesUnitTests
|
||||
// Add a second zone at the back.
|
||||
{
|
||||
winrt::com_ptr<IZone> zone = MakeZone({ 0, 0, 100, 100 });
|
||||
set->AddZone(zone, false /*front*/);
|
||||
set->AddZone(zone);
|
||||
auto zones = set->GetZones();
|
||||
Assert::IsTrue(zones.size() == 2);
|
||||
Assert::IsTrue(zones[1] == zone);
|
||||
@@ -53,157 +47,18 @@ namespace FancyZonesUnitTests
|
||||
}
|
||||
}
|
||||
|
||||
TEST_METHOD(TestAddZoneFront)
|
||||
{
|
||||
ZoneSetConfig config({}, 0xFFFF, Mocks::Monitor(), L"WorkAreaIn", ZoneSetLayout::Grid, 0, 3, 4);
|
||||
winrt::com_ptr<IZoneSet> set = MakeZoneSet(config);
|
||||
|
||||
// Add a zone.
|
||||
{
|
||||
winrt::com_ptr<IZone> zone = MakeZone({ 0, 0, 100, 100 });
|
||||
set->AddZone(zone, false /*front*/);
|
||||
auto zones = set->GetZones();
|
||||
Assert::IsTrue(zones.size() == 1);
|
||||
Assert::IsTrue(zones[0] == zone);
|
||||
Assert::IsTrue(zone->Id() == 1);
|
||||
}
|
||||
|
||||
// Add a second zone at the front.
|
||||
{
|
||||
winrt::com_ptr<IZone> zone = MakeZone({ 0, 0, 100, 100 });
|
||||
set->AddZone(zone, true /*front*/);
|
||||
auto zones = set->GetZones();
|
||||
Assert::IsTrue(zones.size() == 2);
|
||||
Assert::IsTrue(zones[0] == zone);
|
||||
Assert::IsTrue(zone->Id() == 2);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_METHOD(TestRemoveZone)
|
||||
{
|
||||
ZoneSetConfig config({}, 0xFFFF, Mocks::Monitor(), L"WorkAreaIn", ZoneSetLayout::Grid, 0, 3, 4);
|
||||
winrt::com_ptr<IZoneSet> set = MakeZoneSet(config);
|
||||
|
||||
// Add a zone.
|
||||
winrt::com_ptr<IZone> zone = MakeZone({ 0, 0, 100, 100 });
|
||||
set->AddZone(zone, false /*front*/);
|
||||
|
||||
// And remove it.
|
||||
set->RemoveZone(zone);
|
||||
Assert::IsTrue(set->GetZones().size() == 0);
|
||||
}
|
||||
|
||||
TEST_METHOD(TestRemoveInvalidZone)
|
||||
{
|
||||
ZoneSetConfig config({}, 0xFFFF, Mocks::Monitor(), L"WorkAreaIn", ZoneSetLayout::Grid, 0, 3, 4);
|
||||
winrt::com_ptr<IZoneSet> set = MakeZoneSet(config);
|
||||
|
||||
winrt::com_ptr<IZone> zone = MakeZone({ 0, 0, 100, 100 });
|
||||
Assert::AreEqual(set->RemoveZone(zone), E_INVALIDARG);
|
||||
}
|
||||
|
||||
TEST_METHOD(TestMoveZoneToFront)
|
||||
{
|
||||
ZoneSetConfig config({}, 0xFFFF, Mocks::Monitor(), L"WorkAreaIn", ZoneSetLayout::Grid, 0, 3, 4);
|
||||
winrt::com_ptr<IZoneSet> set = MakeZoneSet(config);
|
||||
|
||||
// Add a couple of zones.
|
||||
winrt::com_ptr<IZone> zone1 = MakeZone({ 0, 0, 100, 100 });
|
||||
winrt::com_ptr<IZone> zone2 = MakeZone({ 0, 0, 100, 100 });
|
||||
winrt::com_ptr<IZone> zone3 = MakeZone({ 0, 0, 100, 100 });
|
||||
set->AddZone(zone1, false /*front*/);
|
||||
set->AddZone(zone2, false /*front*/);
|
||||
set->AddZone(zone3, false /*front*/);
|
||||
|
||||
// And move it to the back.
|
||||
set->MoveZoneToFront(zone3);
|
||||
auto zones = set->GetZones();
|
||||
Assert::IsTrue(zones.size() == 3);
|
||||
Assert::IsTrue(zones[0] == zone3);
|
||||
Assert::IsTrue(zones[1] == zone1);
|
||||
Assert::IsTrue(zones[2] == zone2);
|
||||
}
|
||||
|
||||
TEST_METHOD(TestMoveZoneToFrontWithInvalidZone)
|
||||
{
|
||||
ZoneSetConfig config({}, 0xFFFF, Mocks::Monitor(), L"WorkAreaIn", ZoneSetLayout::Grid, 0, 3, 4);
|
||||
winrt::com_ptr<IZoneSet> set = MakeZoneSet(config);
|
||||
|
||||
// Add a couple of zones.
|
||||
winrt::com_ptr<IZone> zone1 = MakeZone({ 0, 0, 100, 100 });
|
||||
winrt::com_ptr<IZone> zone2 = MakeZone({ 0, 0, 100, 100 });
|
||||
winrt::com_ptr<IZone> zone3 = MakeZone({ 0, 0, 100, 100 });
|
||||
set->AddZone(zone1, false /*front*/);
|
||||
set->AddZone(zone2, false /*front*/);
|
||||
set->AddZone(zone3, false /*front*/);
|
||||
|
||||
// Create an invalid zone and try to move it.
|
||||
winrt::com_ptr<IZone> invalidZone = MakeZone({ 0, 0, 100, 100 });
|
||||
set->MoveZoneToFront(invalidZone);
|
||||
auto zones = set->GetZones();
|
||||
Assert::IsTrue(zones.size() == 3);
|
||||
Assert::IsTrue(zones[0] == zone1);
|
||||
Assert::IsTrue(zones[1] == zone2);
|
||||
Assert::IsTrue(zones[2] == zone3);
|
||||
}
|
||||
|
||||
TEST_METHOD(TestMoveZoneToBack)
|
||||
{
|
||||
ZoneSetConfig config({}, 0xFFFF, Mocks::Monitor(), L"WorkAreaIn", ZoneSetLayout::Grid, 0, 3, 4);
|
||||
winrt::com_ptr<IZoneSet> set = MakeZoneSet(config);
|
||||
|
||||
// Add a couple of zones.
|
||||
winrt::com_ptr<IZone> zone1 = MakeZone({ 0, 0, 100, 100 });
|
||||
winrt::com_ptr<IZone> zone2 = MakeZone({ 0, 0, 100, 100 });
|
||||
winrt::com_ptr<IZone> zone3 = MakeZone({ 0, 0, 100, 100 });
|
||||
set->AddZone(zone1, false /*front*/);
|
||||
set->AddZone(zone2, false /*front*/);
|
||||
set->AddZone(zone3, false /*front*/);
|
||||
|
||||
// And move it to the back.
|
||||
set->MoveZoneToBack(zone1);
|
||||
auto zones = set->GetZones();
|
||||
Assert::IsTrue(zones.size() == 3);
|
||||
Assert::IsTrue(zones[0] == zone2);
|
||||
Assert::IsTrue(zones[1] == zone3);
|
||||
Assert::IsTrue(zones[2] == zone1);
|
||||
}
|
||||
|
||||
TEST_METHOD(TestMoveZoneToBackWithInvalidZone)
|
||||
{
|
||||
ZoneSetConfig config({}, 0xFFFF, Mocks::Monitor(), L"WorkAreaIn", ZoneSetLayout::Grid, 0, 3, 4);
|
||||
winrt::com_ptr<IZoneSet> set = MakeZoneSet(config);
|
||||
|
||||
// Add a couple of zones.
|
||||
winrt::com_ptr<IZone> zone1 = MakeZone({ 0, 0, 100, 100 });
|
||||
winrt::com_ptr<IZone> zone2 = MakeZone({ 0, 0, 100, 100 });
|
||||
winrt::com_ptr<IZone> zone3 = MakeZone({ 0, 0, 100, 100 });
|
||||
set->AddZone(zone1, false /*front*/);
|
||||
set->AddZone(zone2, false /*front*/);
|
||||
set->AddZone(zone3, false /*front*/);
|
||||
|
||||
// Create an invalid zone and try to move it.
|
||||
winrt::com_ptr<IZone> invalidZone = MakeZone({ 0, 0, 100, 100 });
|
||||
set->MoveZoneToBack(invalidZone);
|
||||
auto zones = set->GetZones();
|
||||
Assert::IsTrue(zones.size() == 3);
|
||||
Assert::IsTrue(zones[0] == zone1);
|
||||
Assert::IsTrue(zones[1] == zone2);
|
||||
Assert::IsTrue(zones[2] == zone3);
|
||||
}
|
||||
|
||||
TEST_METHOD(TestMoveWindowIntoZoneByIndex)
|
||||
{
|
||||
ZoneSetConfig config({}, 0xFFFF, Mocks::Monitor(), L"WorkAreaIn", ZoneSetLayout::Grid, 0, 3, 4);
|
||||
ZoneSetConfig config({}, 0xFFFF, Mocks::Monitor(), L"WorkAreaIn");
|
||||
winrt::com_ptr<IZoneSet> set = MakeZoneSet(config);
|
||||
|
||||
// Add a couple of zones.
|
||||
winrt::com_ptr<IZone> zone1 = MakeZone({ 0, 0, 100, 100 });
|
||||
winrt::com_ptr<IZone> zone2 = MakeZone({ 0, 0, 100, 100 });
|
||||
winrt::com_ptr<IZone> zone3 = MakeZone({ 0, 0, 100, 100 });
|
||||
set->AddZone(zone1, false /*front*/);
|
||||
set->AddZone(zone2, false /*front*/);
|
||||
set->AddZone(zone3, false /*front*/);
|
||||
set->AddZone(zone1);
|
||||
set->AddZone(zone2);
|
||||
set->AddZone(zone3);
|
||||
|
||||
HWND window = Mocks::Window();
|
||||
set->MoveWindowIntoZoneByIndex(window, Mocks::Window(), 1);
|
||||
@@ -214,7 +69,7 @@ namespace FancyZonesUnitTests
|
||||
|
||||
TEST_METHOD(TestMoveWindowIntoZoneByIndexWithNoZones)
|
||||
{
|
||||
ZoneSetConfig config({}, 0xFFFF, Mocks::Monitor(), L"WorkAreaIn", ZoneSetLayout::Grid, 0, 3, 4);
|
||||
ZoneSetConfig config({}, 0xFFFF, Mocks::Monitor(), L"WorkAreaIn");
|
||||
winrt::com_ptr<IZoneSet> set = MakeZoneSet(config);
|
||||
|
||||
// Add a couple of zones.
|
||||
@@ -224,16 +79,16 @@ namespace FancyZonesUnitTests
|
||||
|
||||
TEST_METHOD(TestMoveWindowIntoZoneByIndexWithInvalidIndex)
|
||||
{
|
||||
ZoneSetConfig config({}, 0xFFFF, Mocks::Monitor(), L"WorkAreaIn", ZoneSetLayout::Grid, 0, 3, 4);
|
||||
ZoneSetConfig config({}, 0xFFFF, Mocks::Monitor(), L"WorkAreaIn");
|
||||
winrt::com_ptr<IZoneSet> set = MakeZoneSet(config);
|
||||
|
||||
// Add a couple of zones.
|
||||
winrt::com_ptr<IZone> zone1 = MakeZone({ 0, 0, 100, 100 });
|
||||
winrt::com_ptr<IZone> zone2 = MakeZone({ 0, 0, 100, 100 });
|
||||
winrt::com_ptr<IZone> zone3 = MakeZone({ 0, 0, 100, 100 });
|
||||
set->AddZone(zone1, false /*front*/);
|
||||
set->AddZone(zone2, false /*front*/);
|
||||
set->AddZone(zone3, false /*front*/);
|
||||
set->AddZone(zone1);
|
||||
set->AddZone(zone2);
|
||||
set->AddZone(zone3);
|
||||
|
||||
HWND window = Mocks::Window();
|
||||
set->MoveWindowIntoZoneByIndex(window, Mocks::Window(), 100);
|
||||
@@ -253,16 +108,16 @@ namespace FancyZonesUnitTests
|
||||
|
||||
TEST_METHOD_INITIALIZE(Initialize)
|
||||
{
|
||||
ZoneSetConfig config({}, 0xFFFF, Mocks::Monitor(), L"WorkAreaIn", ZoneSetLayout::Grid, 0, 3, 4);
|
||||
ZoneSetConfig config({}, 0xFFFF, Mocks::Monitor(), L"WorkAreaIn");
|
||||
set = MakeZoneSet(config);
|
||||
|
||||
// Add a couple of zones.
|
||||
zone1 = MakeZone({ 0, 0, 100, 100 });
|
||||
zone2 = MakeZone({ 0, 0, 100, 100 });
|
||||
zone3 = MakeZone({ 0, 0, 100, 100 });
|
||||
set->AddZone(zone1, false /*front*/);
|
||||
set->AddZone(zone2, false /*front*/);
|
||||
set->AddZone(zone3, false /*front*/);
|
||||
set->AddZone(zone1);
|
||||
set->AddZone(zone2);
|
||||
set->AddZone(zone3);
|
||||
}
|
||||
|
||||
TEST_METHOD(MoveWindowIntoZoneByDirectionRightNoZones)
|
||||
|
||||
Reference in New Issue
Block a user