diff --git a/src/modules/fancyzones/FancyZonesLib/FancyZones.cpp b/src/modules/fancyzones/FancyZonesLib/FancyZones.cpp index ae1a05b4f4..0eaaa24f6e 100644 --- a/src/modules/fancyzones/FancyZonesLib/FancyZones.cpp +++ b/src/modules/fancyzones/FancyZonesLib/FancyZones.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -156,8 +157,8 @@ private: void OnSettingsChanged() noexcept; - std::pair, std::vector> GetAppZoneHistoryInfo(HWND window, HMONITOR monitor, bool isPrimaryMonitor) noexcept; - void MoveWindowIntoZone(HWND window, winrt::com_ptr zoneWindow, const std::vector& zoneIndexSet) noexcept; + std::pair, ZoneIndexSet> GetAppZoneHistoryInfo(HWND window, HMONITOR monitor, bool isPrimaryMonitor) noexcept; + void MoveWindowIntoZone(HWND window, winrt::com_ptr zoneWindow, const ZoneIndexSet& zoneIndexSet) noexcept; void OnEditorExitEvent() noexcept; void UpdateZoneSets() noexcept; @@ -265,9 +266,9 @@ FancyZones::VirtualDesktopChanged() noexcept PostMessage(m_window, WM_PRIV_VD_SWITCH, 0, 0); } -std::pair, std::vector> FancyZones::GetAppZoneHistoryInfo(HWND window, HMONITOR monitor, bool isPrimaryMonitor) noexcept +std::pair, ZoneIndexSet> FancyZones::GetAppZoneHistoryInfo(HWND window, HMONITOR monitor, bool isPrimaryMonitor) noexcept { - std::pair, std::vector> appZoneHistoryInfo{ nullptr, {} }; + std::pair, ZoneIndexSet> appZoneHistoryInfo{ nullptr, {} }; auto workAreaMap = m_workAreaHandler.GetWorkAreasByDesktopId(m_currentDesktopId); if (workAreaMap.empty()) { @@ -301,7 +302,7 @@ std::pair, std::vector> FancyZones::GetAppZone return appZoneHistoryInfo; } -void FancyZones::MoveWindowIntoZone(HWND window, winrt::com_ptr zoneWindow, const std::vector& zoneIndexSet) noexcept +void FancyZones::MoveWindowIntoZone(HWND window, winrt::com_ptr zoneWindow, const ZoneIndexSet& zoneIndexSet) noexcept { _TRACER_; auto& fancyZonesData = FancyZonesDataInstance(); @@ -328,7 +329,7 @@ void FancyZones::WindowCreated(HWND window) noexcept // Avoid processing splash screens, already stamped (zoned) windows, or those windows // that belong to excluded applications list. const bool isSplashScreen = FancyZonesUtils::IsSplashScreen(window); - const bool isZoned = reinterpret_cast(::GetProp(window, ZonedWindowProperties::PropertyMultipleZoneID)) != 0; + const bool isZoned = reinterpret_cast(::GetProp(window, ZonedWindowProperties::PropertyMultipleZoneID)) != 0; const bool isCandidateForLastKnownZone = FancyZonesUtils::IsCandidateForLastKnownZone(window, m_settings->GetSettings()->excludedAppsArray); const bool shouldProcessNewWindow = !isSplashScreen && !isZoned && isCandidateForLastKnownZone; @@ -347,7 +348,7 @@ void FancyZones::WindowCreated(HWND window) noexcept if (moveToAppLastZone) { const bool primaryActive = (primary == active); - std::pair, std::vector> appZoneHistoryInfo = GetAppZoneHistoryInfo(window, active, primaryActive); + std::pair, ZoneIndexSet> appZoneHistoryInfo = GetAppZoneHistoryInfo(window, active, primaryActive); if (!appZoneHistoryInfo.second.empty()) { @@ -828,31 +829,18 @@ void FancyZones::UpdateZoneWindows() noexcept void FancyZones::UpdateWindowsPositions() noexcept { auto callback = [](HWND window, LPARAM data) -> BOOL { - size_t bitmask = reinterpret_cast(::GetProp(window, ZonedWindowProperties::PropertyMultipleZoneID)); - - if (bitmask != 0) + auto zoneIndexSet = GetZoneIndexSet(window); + auto strongThis = reinterpret_cast(data); + auto desktopId = strongThis->m_virtualDesktop.GetWindowDesktopId(window); + if (desktopId.has_value()) { - std::vector indexSet; - for (int i = 0; i < std::numeric_limits::digits; i++) + auto zoneWindow = strongThis->m_workAreaHandler.GetWorkArea(window, *desktopId); + if (zoneWindow) { - if ((1ull << i) & bitmask) - { - indexSet.push_back(i); - } + strongThis->m_windowMoveHandler.MoveWindowIntoZoneByIndexSet(window, zoneIndexSet, zoneWindow); } - - auto strongThis = reinterpret_cast(data); - auto desktopId = strongThis->m_virtualDesktop.GetWindowDesktopId(window); - if (desktopId.has_value()) - { - auto zoneWindow = strongThis->m_workAreaHandler.GetWorkArea(window, *desktopId); - if (zoneWindow) - { - strongThis->m_windowMoveHandler.MoveWindowIntoZoneByIndexSet(window, indexSet, zoneWindow); - } - } - } + return TRUE; }; EnumWindows(callback, reinterpret_cast(this)); @@ -933,7 +921,7 @@ bool FancyZones::OnSnapHotkeyBasedOnPosition(HWND window, DWORD vkCode) noexcept // If that didn't work, extract zones from all other monitors and target one of them std::vector zoneRects; - std::vector>> zoneRectsInfo; + std::vector>> zoneRectsInfo; RECT currentMonitorRect{ .top = 0, .bottom = -1 }; for (const auto& [monitor, monitorRect] : allMonitors) @@ -975,7 +963,7 @@ bool FancyZones::OnSnapHotkeyBasedOnPosition(HWND window, DWORD vkCode) noexcept return false; } - size_t chosenIdx = FancyZonesUtils::ChooseNextZoneByPosition(vkCode, windowRect, zoneRects); + auto chosenIdx = FancyZonesUtils::ChooseNextZoneByPosition(vkCode, windowRect, zoneRects); if (chosenIdx < zoneRects.size()) { diff --git a/src/modules/fancyzones/FancyZonesLib/FancyZonesData.cpp b/src/modules/fancyzones/FancyZonesLib/FancyZonesData.cpp index 835eecea23..bbb2a67ab1 100644 --- a/src/modules/fancyzones/FancyZonesLib/FancyZonesData.cpp +++ b/src/modules/fancyzones/FancyZonesLib/FancyZonesData.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -375,7 +376,7 @@ void FancyZonesData::UpdateProcessIdToHandleMap(HWND window, const std::wstring_ } } -std::vector FancyZonesData::GetAppLastZoneIndexSet(HWND window, const std::wstring_view& deviceId, const std::wstring_view& zoneSetId) const +ZoneIndexSet FancyZonesData::GetAppLastZoneIndexSet(HWND window, const std::wstring_view& deviceId, const std::wstring_view& zoneSetId) const { std::scoped_lock lock{ dataLock }; auto processPath = get_process_path(window); @@ -422,10 +423,10 @@ bool FancyZonesData::RemoveAppLastZone(HWND window, const std::wstring_view& dev } // if there is another instance of same application placed in the same zone don't erase history - size_t windowZoneStamp = reinterpret_cast(::GetProp(window, ZonedWindowProperties::PropertyMultipleZoneID)); + ZoneIndex windowZoneStamp = reinterpret_cast(::GetProp(window, ZonedWindowProperties::PropertyMultipleZoneID)); for (auto placedWindow : data->processIdToHandleMap) { - size_t placedWindowZoneStamp = reinterpret_cast(::GetProp(placedWindow.second, ZonedWindowProperties::PropertyMultipleZoneID)); + ZoneIndex placedWindowZoneStamp = reinterpret_cast(::GetProp(placedWindow.second, ZonedWindowProperties::PropertyMultipleZoneID)); if (IsWindow(placedWindow.second) && (windowZoneStamp == placedWindowZoneStamp)) { return false; @@ -451,7 +452,7 @@ bool FancyZonesData::RemoveAppLastZone(HWND window, const std::wstring_view& dev return false; } -bool FancyZonesData::SetAppLastZones(HWND window, const std::wstring& deviceId, const std::wstring& zoneSetId, const std::vector& zoneIndexSet) +bool FancyZonesData::SetAppLastZones(HWND window, const std::wstring& deviceId, const std::wstring& zoneSetId, const ZoneIndexSet& zoneIndexSet) { _TRACER_; std::scoped_lock lock{ dataLock }; diff --git a/src/modules/fancyzones/FancyZonesLib/FancyZonesData.h b/src/modules/fancyzones/FancyZonesLib/FancyZonesData.h index 50a17fa261..7497fb5083 100644 --- a/src/modules/fancyzones/FancyZonesLib/FancyZonesData.h +++ b/src/modules/fancyzones/FancyZonesLib/FancyZonesData.h @@ -77,9 +77,9 @@ public: bool IsAnotherWindowOfApplicationInstanceZoned(HWND window, const std::wstring_view& deviceId) const; void UpdateProcessIdToHandleMap(HWND window, const std::wstring_view& deviceId); - std::vector GetAppLastZoneIndexSet(HWND window, const std::wstring_view& deviceId, const std::wstring_view& zoneSetId) const; + ZoneIndexSet GetAppLastZoneIndexSet(HWND window, const std::wstring_view& deviceId, const std::wstring_view& zoneSetId) const; bool RemoveAppLastZone(HWND window, const std::wstring_view& deviceId, const std::wstring_view& zoneSetId); - bool SetAppLastZones(HWND window, const std::wstring& deviceId, const std::wstring& zoneSetId, const std::vector& zoneIndexSet); + bool SetAppLastZones(HWND window, const std::wstring& deviceId, const std::wstring& zoneSetId, const ZoneIndexSet& zoneIndexSet); void SetActiveZoneSet(const std::wstring& deviceId, const FancyZonesDataTypes::ZoneSetData& zoneSet); diff --git a/src/modules/fancyzones/FancyZonesLib/FancyZonesDataTypes.h b/src/modules/fancyzones/FancyZonesLib/FancyZonesDataTypes.h index 6ab782f9c9..6d3c2990d5 100644 --- a/src/modules/fancyzones/FancyZonesLib/FancyZonesDataTypes.h +++ b/src/modules/fancyzones/FancyZonesLib/FancyZonesDataTypes.h @@ -10,6 +10,8 @@ #include +#include + namespace FancyZonesDataTypes { enum class ZoneSetLayoutType : int @@ -117,7 +119,7 @@ namespace FancyZonesDataTypes std::wstring zoneSetUuid; std::wstring deviceId; - std::vector zoneIndexSet; + ZoneIndexSet zoneIndexSet; }; struct DeviceIdData diff --git a/src/modules/fancyzones/FancyZonesLib/FancyZonesLib.vcxproj b/src/modules/fancyzones/FancyZonesLib/FancyZonesLib.vcxproj index 08c6ca5f11..c6d9f960fe 100644 --- a/src/modules/fancyzones/FancyZonesLib/FancyZonesLib.vcxproj +++ b/src/modules/fancyzones/FancyZonesLib/FancyZonesLib.vcxproj @@ -56,6 +56,7 @@ + diff --git a/src/modules/fancyzones/FancyZonesLib/FancyZonesLib.vcxproj.filters b/src/modules/fancyzones/FancyZonesLib/FancyZonesLib.vcxproj.filters index b24fdf06ec..b50f8148d4 100644 --- a/src/modules/fancyzones/FancyZonesLib/FancyZonesLib.vcxproj.filters +++ b/src/modules/fancyzones/FancyZonesLib/FancyZonesLib.vcxproj.filters @@ -87,6 +87,9 @@ Header Files + + Header Files + diff --git a/src/modules/fancyzones/FancyZonesLib/FancyZonesWindowProperties.h b/src/modules/fancyzones/FancyZonesLib/FancyZonesWindowProperties.h new file mode 100644 index 0000000000..865aa31b4b --- /dev/null +++ b/src/modules/fancyzones/FancyZonesLib/FancyZonesWindowProperties.h @@ -0,0 +1,46 @@ +#pragma once + +#include + +#include + +// Zoned window properties are not localized. +namespace ZonedWindowProperties +{ + const wchar_t PropertyMultipleZoneID[] = L"FancyZones_zones"; + const wchar_t PropertyRestoreSizeID[] = L"FancyZones_RestoreSize"; + const wchar_t PropertyRestoreOriginID[] = L"FancyZones_RestoreOrigin"; + + const wchar_t MultiMonitorDeviceID[] = L"FancyZones#MultiMonitorDevice"; +} + +inline ZoneIndexSet GetZoneIndexSet(HWND window) +{ + HANDLE handle = ::GetProp(window, ZonedWindowProperties::PropertyMultipleZoneID); + ZoneIndexSet zoneIndexSet; + + std::array data; + memcpy(data.data(), &handle, sizeof data); + uint64_t bitmask = ((uint64_t)data[0] << 32) + data[1]; + + if (bitmask != 0) + { + for (int i = 0; i < std::numeric_limits::digits; i++) + { + if ((1ull << i) & bitmask) + { + zoneIndexSet.push_back(i); + } + } + } + + return zoneIndexSet; +} + +inline void StampWindow(HWND window, Bitmask bitmask) noexcept +{ + std::array data = { (bitmask >> 32), static_cast(bitmask) }; + HANDLE rawData; + memcpy(&rawData, data.data(), sizeof data); + SetProp(window, ZonedWindowProperties::PropertyMultipleZoneID, rawData); +} \ No newline at end of file diff --git a/src/modules/fancyzones/FancyZonesLib/JsonHelpers.cpp b/src/modules/fancyzones/FancyZonesLib/JsonHelpers.cpp index cd52f4d67a..d51e0da5a1 100644 --- a/src/modules/fancyzones/FancyZonesLib/JsonHelpers.cpp +++ b/src/modules/fancyzones/FancyZonesLib/JsonHelpers.cpp @@ -101,12 +101,12 @@ namespace data.zoneIndexSet = {}; for (const auto& value : json.GetNamedArray(NonLocalizable::ZoneIndexSetStr)) { - data.zoneIndexSet.push_back(static_cast(value.GetNumber())); + data.zoneIndexSet.push_back(static_cast(value.GetNumber())); } } else if (json.HasKey(NonLocalizable::ZoneIndexStr)) { - data.zoneIndexSet = { static_cast(json.GetNamedNumber(NonLocalizable::ZoneIndexStr)) }; + data.zoneIndexSet = { static_cast(json.GetNamedNumber(NonLocalizable::ZoneIndexStr)) }; } data.deviceId = json.GetNamedString(NonLocalizable::DeviceIdStr); @@ -371,7 +371,7 @@ namespace JSONHelpers { json::JsonObject desktopData; json::JsonArray jsonIndexSet; - for (size_t index : data.zoneIndexSet) + for (ZoneIndex index : data.zoneIndexSet) { jsonIndexSet.Append(json::value(static_cast(index))); } diff --git a/src/modules/fancyzones/FancyZonesLib/Settings.h b/src/modules/fancyzones/FancyZonesLib/Settings.h index c188cbdce0..dac2c992e9 100644 --- a/src/modules/fancyzones/FancyZonesLib/Settings.h +++ b/src/modules/fancyzones/FancyZonesLib/Settings.h @@ -2,16 +2,6 @@ #include -// Zoned window properties are not localized. -namespace ZonedWindowProperties -{ - const wchar_t PropertyMultipleZoneID[] = L"FancyZones_zones"; - const wchar_t PropertyRestoreSizeID[] = L"FancyZones_RestoreSize"; - const wchar_t PropertyRestoreOriginID[] = L"FancyZones_RestoreOrigin"; - - const wchar_t MultiMonitorDeviceID[] = L"FancyZones#MultiMonitorDevice"; -} - enum struct OverlappingZonesAlgorithm : int { Smallest = 0, diff --git a/src/modules/fancyzones/FancyZonesLib/WindowMoveHandler.cpp b/src/modules/fancyzones/FancyZonesLib/WindowMoveHandler.cpp index 435da0b0d7..77048d4e36 100644 --- a/src/modules/fancyzones/FancyZonesLib/WindowMoveHandler.cpp +++ b/src/modules/fancyzones/FancyZonesLib/WindowMoveHandler.cpp @@ -273,7 +273,7 @@ void WindowMoveHandler::MoveSizeEnd(HWND window, POINT const& ptScreen, const st } } -void WindowMoveHandler::MoveWindowIntoZoneByIndexSet(HWND window, const std::vector& indexSet, winrt::com_ptr zoneWindow) noexcept +void WindowMoveHandler::MoveWindowIntoZoneByIndexSet(HWND window, const ZoneIndexSet& indexSet, winrt::com_ptr zoneWindow) noexcept { if (window != m_windowMoveSize) { diff --git a/src/modules/fancyzones/FancyZonesLib/WindowMoveHandler.h b/src/modules/fancyzones/FancyZonesLib/WindowMoveHandler.h index 87ffeef5f1..48eeaae2f9 100644 --- a/src/modules/fancyzones/FancyZonesLib/WindowMoveHandler.h +++ b/src/modules/fancyzones/FancyZonesLib/WindowMoveHandler.h @@ -1,5 +1,6 @@ #pragma once +#include "FancyZonesWindowProperties.h" #include "KeyState.h" #include "SecondaryMouseButtonsHook.h" @@ -17,7 +18,7 @@ public: void MoveSizeUpdate(HMONITOR monitor, POINT const& ptScreen, const std::unordered_map>& zoneWindowMap) noexcept; void MoveSizeEnd(HWND window, POINT const& ptScreen, const std::unordered_map>& zoneWindowMap) noexcept; - void MoveWindowIntoZoneByIndexSet(HWND window, const std::vector& indexSet, winrt::com_ptr zoneWindow) noexcept; + void MoveWindowIntoZoneByIndexSet(HWND window, const ZoneIndexSet& indexSet, winrt::com_ptr zoneWindow) noexcept; bool MoveWindowIntoZoneByDirectionAndIndex(HWND window, DWORD vkCode, bool cycle, winrt::com_ptr zoneWindow) noexcept; bool MoveWindowIntoZoneByDirectionAndPosition(HWND window, DWORD vkCode, bool cycle, winrt::com_ptr zoneWindow) noexcept; bool ExtendWindowByDirectionAndPosition(HWND window, DWORD vkCode, winrt::com_ptr zoneWindow) noexcept; diff --git a/src/modules/fancyzones/FancyZonesLib/WorkArea.cpp b/src/modules/fancyzones/FancyZonesLib/WorkArea.cpp index 0f0045029e..e53e5380eb 100644 --- a/src/modules/fancyzones/FancyZonesLib/WorkArea.cpp +++ b/src/modules/fancyzones/FancyZonesLib/WorkArea.cpp @@ -115,9 +115,9 @@ public: IFACEMETHODIMP MoveSizeUpdate(POINT const& ptScreen, bool dragEnabled, bool selectManyZones) noexcept; IFACEMETHODIMP MoveSizeEnd(HWND window, POINT const& ptScreen) noexcept; IFACEMETHODIMP_(void) - MoveWindowIntoZoneByIndex(HWND window, size_t index) noexcept; + MoveWindowIntoZoneByIndex(HWND window, ZoneIndex index) noexcept; IFACEMETHODIMP_(void) - MoveWindowIntoZoneByIndexSet(HWND window, const std::vector& indexSet) noexcept; + MoveWindowIntoZoneByIndexSet(HWND window, const ZoneIndexSet& indexSet) noexcept; IFACEMETHODIMP_(bool) MoveWindowIntoZoneByDirectionAndIndex(HWND window, DWORD vkCode, bool cycle) noexcept; IFACEMETHODIMP_(bool) @@ -130,7 +130,7 @@ public: SaveWindowProcessToZoneIndex(HWND window) noexcept; IFACEMETHODIMP_(IZoneSet*) ActiveZoneSet() const noexcept { return m_activeZoneSet.get(); } - IFACEMETHODIMP_(std::vector) + IFACEMETHODIMP_(ZoneIndexSet) GetWindowZoneIndexes(HWND window) const noexcept; IFACEMETHODIMP_(void) ShowZoneWindow() noexcept; @@ -155,7 +155,7 @@ private: void CalculateZoneSet(OverlappingZonesAlgorithm overlappingAlgorithm) noexcept; void UpdateActiveZoneSet(_In_opt_ IZoneSet* zoneSet) noexcept; LRESULT WndProc(UINT message, WPARAM wparam, LPARAM lparam) noexcept; - std::vector ZonesFromPoint(POINT pt) noexcept; + ZoneIndexSet ZonesFromPoint(POINT pt) noexcept; void SetAsTopmostWindow() noexcept; HMONITOR m_monitor{}; @@ -164,8 +164,8 @@ private: HWND m_windowMoveSize{}; winrt::com_ptr m_activeZoneSet; std::vector> m_zoneSets; - std::vector m_initialHighlightZone; - std::vector m_highlightZone; + ZoneIndexSet m_initialHighlightZone; + ZoneIndexSet m_highlightZone; WPARAM m_keyLast{}; size_t m_keyCycle{}; std::unique_ptr m_zoneWindowDrawing; @@ -305,13 +305,13 @@ IFACEMETHODIMP WorkArea::MoveSizeEnd(HWND window, POINT const& ptScreen) noexcep } IFACEMETHODIMP_(void) -WorkArea::MoveWindowIntoZoneByIndex(HWND window, size_t index) noexcept +WorkArea::MoveWindowIntoZoneByIndex(HWND window, ZoneIndex index) noexcept { MoveWindowIntoZoneByIndexSet(window, { index }); } IFACEMETHODIMP_(void) -WorkArea::MoveWindowIntoZoneByIndexSet(HWND window, const std::vector& indexSet) noexcept +WorkArea::MoveWindowIntoZoneByIndexSet(HWND window, const ZoneIndexSet& indexSet) noexcept { if (m_activeZoneSet) { @@ -383,7 +383,7 @@ WorkArea::SaveWindowProcessToZoneIndex(HWND window) noexcept } } -IFACEMETHODIMP_(std::vector) +IFACEMETHODIMP_(ZoneIndexSet) WorkArea::GetWindowZoneIndexes(HWND window) const noexcept { if (m_activeZoneSet) @@ -575,7 +575,7 @@ LRESULT WorkArea::WndProc(UINT message, WPARAM wparam, LPARAM lparam) noexcept return 0; } -std::vector WorkArea::ZonesFromPoint(POINT pt) noexcept +ZoneIndexSet WorkArea::ZonesFromPoint(POINT pt) noexcept { if (m_activeZoneSet) { diff --git a/src/modules/fancyzones/FancyZonesLib/WorkArea.h b/src/modules/fancyzones/FancyZonesLib/WorkArea.h index 9f87dd0fae..078056255f 100644 --- a/src/modules/fancyzones/FancyZonesLib/WorkArea.h +++ b/src/modules/fancyzones/FancyZonesLib/WorkArea.h @@ -44,14 +44,14 @@ interface __declspec(uuid("{7F017528-8110-4FB3-BE41-F472969C2560}")) IWorkArea : * @param window Handle of window which should be assigned to zone. * @param index Zone index within zone layout. */ - IFACEMETHOD_(void, MoveWindowIntoZoneByIndex)(HWND window, size_t index) = 0; + IFACEMETHOD_(void, MoveWindowIntoZoneByIndex)(HWND window, ZoneIndex 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 indexSet The set of zone indices within zone layout. */ - IFACEMETHOD_(void, MoveWindowIntoZoneByIndexSet)(HWND window, const std::vector& indexSet) = 0; + IFACEMETHOD_(void, MoveWindowIntoZoneByIndexSet)(HWND window, const ZoneIndexSet& 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. @@ -105,7 +105,7 @@ interface __declspec(uuid("{7F017528-8110-4FB3-BE41-F472969C2560}")) IWorkArea : /* * @returns Zone index of the window */ - IFACEMETHOD_(std::vector, GetWindowZoneIndexes)(HWND window) const = 0; + IFACEMETHOD_(ZoneIndexSet, GetWindowZoneIndexes)(HWND window) const = 0; IFACEMETHOD_(void, ShowZoneWindow)() = 0; IFACEMETHOD_(void, HideZoneWindow)() = 0; /** diff --git a/src/modules/fancyzones/FancyZonesLib/Zone.cpp b/src/modules/fancyzones/FancyZonesLib/Zone.cpp index e9156798a3..d44130c458 100644 --- a/src/modules/fancyzones/FancyZonesLib/Zone.cpp +++ b/src/modules/fancyzones/FancyZonesLib/Zone.cpp @@ -26,7 +26,7 @@ namespace struct Zone : winrt::implements { public: - Zone(RECT zoneRect, const size_t zoneId) : + Zone(RECT zoneRect, const ZoneIndex zoneId) : m_zoneRect(zoneRect), m_id(zoneId) { @@ -34,12 +34,12 @@ public: IFACEMETHODIMP_(RECT) GetZoneRect() const noexcept { return m_zoneRect; } IFACEMETHODIMP_(long) GetZoneArea() const noexcept { return max(m_zoneRect.bottom - m_zoneRect.top, 0) * max(m_zoneRect.right - m_zoneRect.left, 0); } - IFACEMETHODIMP_(size_t) Id() const noexcept { return m_id; } + IFACEMETHODIMP_(ZoneIndex) Id() const noexcept { return m_id; } IFACEMETHODIMP_(RECT) ComputeActualZoneRect(HWND window, HWND zoneWindow) const noexcept; private: RECT m_zoneRect{}; - const size_t m_id{}; + const ZoneIndex m_id{}; std::map m_windows{}; }; @@ -75,7 +75,7 @@ RECT Zone::ComputeActualZoneRect(HWND window, HWND zoneWindow) const noexcept return newWindowRect; } -winrt::com_ptr MakeZone(const RECT& zoneRect, const size_t zoneId) noexcept +winrt::com_ptr MakeZone(const RECT& zoneRect, const ZoneIndex zoneId) noexcept { if (ValidateZoneRect(zoneRect) && zoneId >= 0) { diff --git a/src/modules/fancyzones/FancyZonesLib/Zone.h b/src/modules/fancyzones/FancyZonesLib/Zone.h index d1d9e92fc1..8be1f1ba18 100644 --- a/src/modules/fancyzones/FancyZonesLib/Zone.h +++ b/src/modules/fancyzones/FancyZonesLib/Zone.h @@ -5,6 +5,10 @@ namespace ZoneConstants constexpr int MAX_NEGATIVE_SPACING = -10; } +using ZoneIndex = int64_t; +using ZoneIndexSet = std::vector; +using Bitmask = ZoneIndex; + /** * Class representing one zone inside applied zone layout, which is basically wrapper around rectangle structure. */ @@ -21,7 +25,7 @@ interface __declspec(uuid("{8228E934-B6EF-402A-9892-15A1441BF8B0}")) IZone : pub /** * @returns Zone identifier. */ - IFACEMETHOD_(size_t, Id)() const = 0; + IFACEMETHOD_(ZoneIndex, Id)() const = 0; /** * Compute the coordinates of the rectangle to which a window should be resized. * @@ -34,4 +38,4 @@ interface __declspec(uuid("{8228E934-B6EF-402A-9892-15A1441BF8B0}")) IZone : pub }; -winrt::com_ptr MakeZone(const RECT& zoneRect, const size_t zoneId) noexcept; +winrt::com_ptr MakeZone(const RECT& zoneRect, const ZoneIndex zoneId) noexcept; diff --git a/src/modules/fancyzones/FancyZonesLib/ZoneSet.cpp b/src/modules/fancyzones/FancyZonesLib/ZoneSet.cpp index 2fc88058bc..c89ba458db 100644 --- a/src/modules/fancyzones/FancyZonesLib/ZoneSet.cpp +++ b/src/modules/fancyzones/FancyZonesLib/ZoneSet.cpp @@ -4,6 +4,7 @@ #include "FancyZonesData.h" #include "FancyZonesDataTypes.h" +#include "FancyZonesWindowProperties.h" #include "Settings.h" #include "Zone.h" #include "util.h" @@ -102,11 +103,6 @@ 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(bitmask)); - } } struct ZoneSet : winrt::implements @@ -128,16 +124,13 @@ public: IFACEMETHODIMP_(FancyZonesDataTypes::ZoneSetLayoutType) LayoutType() const noexcept { return m_config.LayoutType; } IFACEMETHODIMP AddZone(winrt::com_ptr zone) noexcept; - IFACEMETHODIMP_(std::vector) - ZonesFromPoint(POINT pt) const noexcept; - IFACEMETHODIMP_(std::vector) - GetZoneIndexSetFromWindow(HWND window) const noexcept; - IFACEMETHODIMP_(ZonesMap) - GetZones()const noexcept override { return m_zones; } + IFACEMETHODIMP_(ZoneIndexSet) ZonesFromPoint(POINT pt) const noexcept; + IFACEMETHODIMP_(ZoneIndexSet) GetZoneIndexSetFromWindow(HWND window) const noexcept; + IFACEMETHODIMP_(ZonesMap) GetZones()const noexcept override { return m_zones; } IFACEMETHODIMP_(void) - MoveWindowIntoZoneByIndex(HWND window, HWND workAreaWindow, size_t index) noexcept; + MoveWindowIntoZoneByIndex(HWND window, HWND workAreaWindow, ZoneIndex index) noexcept; IFACEMETHODIMP_(void) - MoveWindowIntoZoneByIndexSet(HWND window, HWND workAreaWindow, const std::vector& indexSet) noexcept; + MoveWindowIntoZoneByIndexSet(HWND window, HWND workAreaWindow, const ZoneIndexSet& indexSet) noexcept; IFACEMETHODIMP_(bool) MoveWindowIntoZoneByDirectionAndIndex(HWND window, HWND workAreaWindow, DWORD vkCode, bool cycle) noexcept; IFACEMETHODIMP_(bool) @@ -148,10 +141,8 @@ public: MoveWindowIntoZoneByPoint(HWND window, HWND workAreaWindow, POINT ptClient) noexcept; IFACEMETHODIMP_(bool) CalculateZones(RECT workArea, int zoneCount, int spacing) noexcept; - IFACEMETHODIMP_(bool) - IsZoneEmpty(int zoneIndex) const noexcept; - IFACEMETHODIMP_(std::vector) - GetCombinedZoneRange(const std::vector& initialZones, const std::vector& finalZones) const noexcept; + IFACEMETHODIMP_(bool) IsZoneEmpty(ZoneIndex zoneIndex) const noexcept; + IFACEMETHODIMP_(ZoneIndexSet) GetCombinedZoneRange(const ZoneIndexSet& initialZones, const ZoneIndexSet& finalZones) const noexcept; private: bool CalculateFocusLayout(Rect workArea, int zoneCount) noexcept; @@ -160,19 +151,19 @@ 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); - std::vector ZoneSelectSubregion(const std::vector& capturedZones, POINT pt) const; - std::vector ZoneSelectClosestCenter(const std::vector& capturedZones, POINT pt) const; + ZoneIndexSet ZoneSelectSubregion(const ZoneIndexSet& capturedZones, POINT pt) const; + ZoneIndexSet ZoneSelectClosestCenter(const ZoneIndexSet& capturedZones, POINT pt) const; // `compare` should return true if the first argument is a better choice than the second argument. template - std::vector ZoneSelectPriority(const std::vector& capturedZones, CompareF compare) const; + ZoneIndexSet ZoneSelectPriority(const ZoneIndexSet& capturedZones, CompareF compare) const; ZonesMap m_zones; - std::map> m_windowIndexSet; + std::map m_windowIndexSet; // Needed for ExtendWindowByDirectionAndPosition - std::map> m_windowInitialIndexSet; - std::map m_windowFinalIndex; + std::map m_windowInitialIndexSet; + std::map m_windowFinalIndex; bool m_inExtendWindow = false; ZoneSetConfig m_config; @@ -190,11 +181,11 @@ IFACEMETHODIMP ZoneSet::AddZone(winrt::com_ptr zone) noexcept return S_OK; } -IFACEMETHODIMP_(std::vector) +IFACEMETHODIMP_(ZoneIndexSet) ZoneSet::ZonesFromPoint(POINT pt) const noexcept { - std::vector capturedZones; - std::vector strictlyCapturedZones; + ZoneIndexSet capturedZones; + ZoneIndexSet strictlyCapturedZones; for (const auto& [zoneId, zone] : m_zones) { const RECT& zoneRect = zone->GetZoneRect(); @@ -278,7 +269,7 @@ ZoneSet::ZonesFromPoint(POINT pt) const noexcept return capturedZones; } -std::vector ZoneSet::GetZoneIndexSetFromWindow(HWND window) const noexcept +ZoneIndexSet ZoneSet::GetZoneIndexSetFromWindow(HWND window) const noexcept { auto it = m_windowIndexSet.find(window); if (it == m_windowIndexSet.end()) @@ -292,13 +283,13 @@ std::vector ZoneSet::GetZoneIndexSetFromWindow(HWND window) const noexce } IFACEMETHODIMP_(void) -ZoneSet::MoveWindowIntoZoneByIndex(HWND window, HWND workAreaWindow, size_t index) noexcept +ZoneSet::MoveWindowIntoZoneByIndex(HWND window, HWND workAreaWindow, ZoneIndex index) noexcept { MoveWindowIntoZoneByIndexSet(window, workAreaWindow, { index }); } IFACEMETHODIMP_(void) -ZoneSet::MoveWindowIntoZoneByIndexSet(HWND window, HWND workAreaWindow, const std::vector& zoneIds) noexcept +ZoneSet::MoveWindowIntoZoneByIndexSet(HWND window, HWND workAreaWindow, const ZoneIndexSet& zoneIds) noexcept { if (m_zones.empty()) { @@ -314,11 +305,11 @@ ZoneSet::MoveWindowIntoZoneByIndexSet(HWND window, HWND workAreaWindow, const st RECT size; bool sizeEmpty = true; - size_t bitmask = 0; + Bitmask bitmask = 0; m_windowIndexSet[window] = {}; - for (size_t id : zoneIds) + for (ZoneIndex id : zoneIds) { if (m_zones.contains(id)) { @@ -340,7 +331,7 @@ ZoneSet::MoveWindowIntoZoneByIndexSet(HWND window, HWND workAreaWindow, const st m_windowIndexSet[window].push_back(id); } - if (id < std::numeric_limits::digits) + if (id < std::numeric_limits::digits) { bitmask |= 1ull << id; } @@ -363,7 +354,7 @@ ZoneSet::MoveWindowIntoZoneByDirectionAndIndex(HWND window, HWND workAreaWindow, } auto indexSet = GetZoneIndexSetFromWindow(window); - size_t numZones = m_zones.size(); + auto numZones = m_zones.size(); // The window was not assigned to any zone here if (indexSet.size() == 0) @@ -372,7 +363,7 @@ ZoneSet::MoveWindowIntoZoneByDirectionAndIndex(HWND window, HWND workAreaWindow, return true; } - size_t oldId = indexSet[0]; + ZoneIndex oldId = indexSet[0]; // We reached the edge if ((vkCode == VK_LEFT && oldId == 0) || (vkCode == VK_RIGHT && oldId == numZones - 1)) @@ -410,13 +401,13 @@ ZoneSet::MoveWindowIntoZoneByDirectionAndPosition(HWND window, HWND workAreaWind } std::vector usedZoneIndices(m_zones.size(), false); - for (size_t id : GetZoneIndexSetFromWindow(window)) + for (ZoneIndex id : GetZoneIndexSetFromWindow(window)) { usedZoneIndices[id] = true; } std::vector zoneRects; - std::vector freeZoneIndices; + ZoneIndexSet freeZoneIndices; for (const auto& [zoneId, zone] : m_zones) { @@ -436,7 +427,7 @@ ZoneSet::MoveWindowIntoZoneByDirectionAndPosition(HWND window, HWND workAreaWind windowRect.left -= windowZoneRect.left; windowRect.right -= windowZoneRect.left; - size_t result = FancyZonesUtils::ChooseNextZoneByPosition(vkCode, windowRect, zoneRects); + auto result = FancyZonesUtils::ChooseNextZoneByPosition(vkCode, windowRect, zoneRects); if (result < zoneRects.size()) { MoveWindowIntoZoneByIndex(window, workAreaWindow, freeZoneIndices[result]); @@ -476,7 +467,7 @@ ZoneSet::ExtendWindowByDirectionAndPosition(HWND window, HWND workAreaWindow, DW auto oldZones = GetZoneIndexSetFromWindow(window); std::vector usedZoneIndices(m_zones.size(), false); std::vector zoneRects; - std::vector freeZoneIndices; + ZoneIndexSet freeZoneIndices; // If selectManyZones = true for the second time, use the last zone into which we moved // instead of the window rect and enable moving to all zones except the old one @@ -488,7 +479,7 @@ ZoneSet::ExtendWindowByDirectionAndPosition(HWND window, HWND workAreaWindow, DW } else { - for (size_t idx : oldZones) + for (ZoneIndex idx : oldZones) { usedZoneIndices[idx] = true; } @@ -508,11 +499,11 @@ ZoneSet::ExtendWindowByDirectionAndPosition(HWND window, HWND workAreaWindow, DW } } - size_t result = FancyZonesUtils::ChooseNextZoneByPosition(vkCode, windowRect, zoneRects); + auto result = FancyZonesUtils::ChooseNextZoneByPosition(vkCode, windowRect, zoneRects); if (result < zoneRects.size()) { - size_t targetZone = freeZoneIndices[result]; - std::vector resultIndexSet; + ZoneIndex targetZone = freeZoneIndices[result]; + ZoneIndexSet resultIndexSet; // First time with selectManyZones = true for this window? if (finalIndexIt == m_windowFinalIndex.end()) @@ -593,7 +584,7 @@ ZoneSet::CalculateZones(RECT workAreaRect, int zoneCount, int spacing) noexcept return success; } -bool ZoneSet::IsZoneEmpty(int zoneIndex) const noexcept +bool ZoneSet::IsZoneEmpty(ZoneIndex zoneIndex) const noexcept { for (auto& [window, zones] : m_windowIndexSet) { @@ -903,15 +894,15 @@ bool ZoneSet::CalculateGridZones(Rect workArea, FancyZonesDataTypes::GridLayoutI return true; } -std::vector ZoneSet::GetCombinedZoneRange(const std::vector& initialZones, const std::vector& finalZones) const noexcept +ZoneIndexSet ZoneSet::GetCombinedZoneRange(const ZoneIndexSet& initialZones, const ZoneIndexSet& finalZones) const noexcept { - std::vector combinedZones, result; + ZoneIndexSet combinedZones, result; std::set_union(begin(initialZones), end(initialZones), begin(finalZones), end(finalZones), std::back_inserter(combinedZones)); RECT boundingRect; bool boundingRectEmpty = true; - for (size_t zoneId : combinedZones) + for (ZoneIndex zoneId : combinedZones) { if (m_zones.contains(zoneId)) { @@ -947,7 +938,7 @@ std::vector ZoneSet::GetCombinedZoneRange(const std::vector& ini return result; } -std::vector ZoneSet::ZoneSelectSubregion(const std::vector& capturedZones, POINT pt) const +ZoneIndexSet ZoneSet::ZoneSelectSubregion(const ZoneIndexSet& capturedZones, POINT pt) const { auto expand = [&](RECT& rect) { rect.top -= m_config.SensitivityRadius / 2; @@ -976,7 +967,7 @@ std::vector ZoneSet::ZoneSelectSubregion(const std::vector& capt int height = max(overlap.bottom - overlap.top, 1); bool verticalSplit = height > width; - size_t zoneIndex; + ZoneIndex zoneIndex; if (verticalSplit) { @@ -987,12 +978,12 @@ std::vector ZoneSet::ZoneSelectSubregion(const std::vector& capt zoneIndex = (pt.x - overlap.left) * capturedZones.size() / width; } - zoneIndex = std::clamp(zoneIndex, size_t(0), capturedZones.size() - 1); + zoneIndex = std::clamp(zoneIndex, ZoneIndex(0), static_cast(capturedZones.size()) - 1); return { capturedZones[zoneIndex] }; } -std::vector ZoneSet::ZoneSelectClosestCenter(const std::vector& capturedZones, POINT pt) const +ZoneIndexSet ZoneSet::ZoneSelectClosestCenter(const ZoneIndexSet& capturedZones, POINT pt) const { auto getCenter = [](auto zone) { RECT rect = zone->GetZoneRect(); @@ -1019,7 +1010,7 @@ std::vector ZoneSet::ZoneSelectClosestCenter(const std::vector& } template -std::vector ZoneSet::ZoneSelectPriority(const std::vector& capturedZones, CompareF compare) const +ZoneIndexSet ZoneSet::ZoneSelectPriority(const ZoneIndexSet& capturedZones, CompareF compare) const { size_t chosen = 0; diff --git a/src/modules/fancyzones/FancyZonesLib/ZoneSet.h b/src/modules/fancyzones/FancyZonesLib/ZoneSet.h index 73d22e47ef..9d7705cb0c 100644 --- a/src/modules/fancyzones/FancyZonesLib/ZoneSet.h +++ b/src/modules/fancyzones/FancyZonesLib/ZoneSet.h @@ -14,7 +14,7 @@ namespace FancyZonesDataTypes interface __declspec(uuid("{E4839EB7-669D-49CF-84A9-71A2DFD851A3}")) IZoneSet : public IUnknown { // Mapping zone id to zone - using ZonesMap = std::map>; + using ZonesMap = std::map>; /** * @returns Unique identifier of zone layout. @@ -36,15 +36,14 @@ 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, ZonesFromPoint)(POINT pt) const = 0; + IFACEMETHOD_(ZoneIndexSet, 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 index set. + * @returns A vector of ZoneIndex, 0-based index set. */ - IFACEMETHOD_(std::vector, GetZoneIndexSetFromWindow) - (HWND window) const = 0; + IFACEMETHOD_(ZoneIndexSet, GetZoneIndexSetFromWindow)(HWND window) const = 0; /** * @returns Array of zone objects (defining coordinates of the zone) inside this zone layout. */ @@ -57,8 +56,7 @@ interface __declspec(uuid("{E4839EB7-669D-49CF-84A9-71A2DFD851A3}")) IZoneSet : * current monitor desktop work area. * @param index Zone index within zone layout. */ - IFACEMETHOD_(void, MoveWindowIntoZoneByIndex) - (HWND window, HWND workAreaWindow, size_t index) = 0; + IFACEMETHOD_(void, MoveWindowIntoZoneByIndex)(HWND window, HWND workAreaWindow, ZoneIndex index) = 0; /** * Assign window to the zones based on the set of zone indices inside zone layout. * @@ -67,8 +65,7 @@ interface __declspec(uuid("{E4839EB7-669D-49CF-84A9-71A2DFD851A3}")) IZoneSet : * current monitor desktop work area. * @param indexSet The set of zone indices within zone layout. */ - IFACEMETHOD_(void, MoveWindowIntoZoneByIndexSet) - (HWND window, HWND workAreaWindow, const std::vector& indexSet) = 0; + IFACEMETHOD_(void, MoveWindowIntoZoneByIndexSet)(HWND window, HWND workAreaWindow, const ZoneIndexSet& 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. @@ -82,8 +79,7 @@ interface __declspec(uuid("{E4839EB7-669D-49CF-84A9-71A2DFD851A3}")) IZoneSet : * @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 workAreaWindow, 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. @@ -140,7 +136,7 @@ interface __declspec(uuid("{E4839EB7-669D-49CF-84A9-71A2DFD851A3}")) IZoneSet : * * @returns Boolean indicating whether the zone is empty. */ - IFACEMETHOD_(bool, IsZoneEmpty)(int zoneIndex) const = 0; + IFACEMETHOD_(bool, IsZoneEmpty)(ZoneIndex zoneIndex) const = 0; /** * Returns all zones spanned by the minimum bounding rectangle containing the two given zone index sets. * @@ -149,7 +145,7 @@ interface __declspec(uuid("{E4839EB7-669D-49CF-84A9-71A2DFD851A3}")) IZoneSet : * * @returns A vector indicating describing the chosen zone index set. */ - IFACEMETHOD_(std::vector, GetCombinedZoneRange)(const std::vector& initialZones, const std::vector& finalZones) const = 0; + IFACEMETHOD_(ZoneIndexSet, GetCombinedZoneRange)(const ZoneIndexSet& initialZones, const ZoneIndexSet& finalZones) const = 0; }; struct ZoneSetConfig diff --git a/src/modules/fancyzones/FancyZonesLib/ZoneWindowDrawing.cpp b/src/modules/fancyzones/FancyZonesLib/ZoneWindowDrawing.cpp index 5085f71e12..caabd0cadf 100644 --- a/src/modules/fancyzones/FancyZonesLib/ZoneWindowDrawing.cpp +++ b/src/modules/fancyzones/FancyZonesLib/ZoneWindowDrawing.cpp @@ -278,7 +278,7 @@ void ZoneWindowDrawing::Flash() } void ZoneWindowDrawing::DrawActiveZoneSet(const IZoneSet::ZonesMap& zones, - const std::vector& highlightZones, + const ZoneIndexSet& highlightZones, const ZoneColors& colors) { _TRACER_; @@ -294,7 +294,7 @@ void ZoneWindowDrawing::DrawActiveZoneSet(const IZoneSet::ZonesMap& zones, highlightColor.a = colors.highlightOpacity / 100.f; std::vector isHighlighted(zones.size() + 1, false); - for (size_t x : highlightZones) + for (ZoneIndex x : highlightZones) { isHighlighted[x] = true; } diff --git a/src/modules/fancyzones/FancyZonesLib/ZoneWindowDrawing.h b/src/modules/fancyzones/FancyZonesLib/ZoneWindowDrawing.h index e17da9f50d..ee5322e55e 100644 --- a/src/modules/fancyzones/FancyZonesLib/ZoneWindowDrawing.h +++ b/src/modules/fancyzones/FancyZonesLib/ZoneWindowDrawing.h @@ -20,7 +20,7 @@ class ZoneWindowDrawing D2D1_RECT_F rect; D2D1_COLOR_F borderColor; D2D1_COLOR_F fillColor; - size_t id; + ZoneIndex id; }; struct AnimationInfo @@ -65,6 +65,6 @@ public: void Show(); void Flash(); void DrawActiveZoneSet(const IZoneSet::ZonesMap& zones, - const std::vector& highlightZones, + const ZoneIndexSet& highlightZones, const ZoneColors& colors); }; diff --git a/src/modules/fancyzones/FancyZonesLib/util.cpp b/src/modules/fancyzones/FancyZonesLib/util.cpp index dcb9e93f62..6773923dbe 100644 --- a/src/modules/fancyzones/FancyZonesLib/util.cpp +++ b/src/modules/fancyzones/FancyZonesLib/util.cpp @@ -12,6 +12,7 @@ #include #include +#include // Non-Localizable strings namespace NonLocalizable diff --git a/src/modules/fancyzones/FancyZonesTests/UnitTests/JsonHelpers.Tests.cpp b/src/modules/fancyzones/FancyZonesTests/UnitTests/JsonHelpers.Tests.cpp index 5d98b8b727..5f58070dce 100644 --- a/src/modules/fancyzones/FancyZonesTests/UnitTests/JsonHelpers.Tests.cpp +++ b/src/modules/fancyzones/FancyZonesTests/UnitTests/JsonHelpers.Tests.cpp @@ -1201,7 +1201,7 @@ namespace FancyZonesUnitTests Assert::AreEqual(expected.data.size(), entryData.size()); Assert::AreEqual(expectedZoneSetId.c_str(), entryData[0].zoneSetUuid.c_str()); Assert::AreEqual(expectedDeviceId.c_str(), entryData[0].deviceId.c_str()); - Assert::IsTrue(std::vector{ expectedIndex } == entryData[0].zoneIndexSet); + Assert::IsTrue(std::vector{ expectedIndex } == entryData[0].zoneIndexSet); } TEST_METHOD (AppZoneHistoryParseManyApps) @@ -1842,11 +1842,11 @@ namespace FancyZonesUnitTests FancyZonesData data; data.SetSettingsModulePath(m_moduleName); - Assert::IsTrue(std::vector{} == data.GetAppLastZoneIndexSet(window, deviceId, zoneSetId)); + Assert::IsTrue(std::vector{} == data.GetAppLastZoneIndexSet(window, deviceId, zoneSetId)); const int expectedZoneIndex = 10; Assert::IsTrue(data.SetAppLastZones(window, deviceId, zoneSetId, { expectedZoneIndex } )); - Assert::IsTrue(std::vector{ expectedZoneIndex } == data.GetAppLastZoneIndexSet(window, deviceId, zoneSetId)); + Assert::IsTrue(std::vector{ expectedZoneIndex } == data.GetAppLastZoneIndexSet(window, deviceId, zoneSetId)); } TEST_METHOD (AppLastZoneIndexZero) @@ -1859,7 +1859,7 @@ namespace FancyZonesUnitTests const int expectedZoneIndex = 0; Assert::IsTrue(data.SetAppLastZones(window, deviceId, zoneSetId, { expectedZoneIndex })); - Assert::IsTrue(std::vector{ expectedZoneIndex } == data.GetAppLastZoneIndexSet(window, deviceId, zoneSetId)); + Assert::IsTrue(std::vector{ expectedZoneIndex } == data.GetAppLastZoneIndexSet(window, deviceId, zoneSetId)); } TEST_METHOD (AppLastZoneIndexNegative) @@ -1870,9 +1870,9 @@ namespace FancyZonesUnitTests FancyZonesData data; data.SetSettingsModulePath(m_moduleName); - const size_t expectedZoneIndex = -1; + const ZoneIndex expectedZoneIndex = -1; Assert::IsTrue(data.SetAppLastZones(window, deviceId, zoneSetId, { expectedZoneIndex })); - Assert::IsTrue(std::vector{ expectedZoneIndex } == data.GetAppLastZoneIndexSet(window, deviceId, zoneSetId)); + Assert::IsTrue(std::vector{ expectedZoneIndex } == data.GetAppLastZoneIndexSet(window, deviceId, zoneSetId)); } TEST_METHOD (AppLastZoneIndexOverflow) @@ -1883,9 +1883,9 @@ namespace FancyZonesUnitTests FancyZonesData data; data.SetSettingsModulePath(m_moduleName); - const size_t expectedZoneIndex = ULLONG_MAX; + const ZoneIndex expectedZoneIndex = ULLONG_MAX; Assert::IsTrue(data.SetAppLastZones(window, deviceId, zoneSetId, { expectedZoneIndex })); - Assert::IsTrue(std::vector{ expectedZoneIndex } == data.GetAppLastZoneIndexSet(window, deviceId, zoneSetId)); + Assert::IsTrue(std::vector{ expectedZoneIndex } == data.GetAppLastZoneIndexSet(window, deviceId, zoneSetId)); } TEST_METHOD (AppLastZoneIndexOverride) @@ -1900,7 +1900,7 @@ namespace FancyZonesUnitTests Assert::IsTrue(data.SetAppLastZones(window, deviceId, zoneSetId, { 1 })); Assert::IsTrue(data.SetAppLastZones(window, deviceId, zoneSetId, { 2 })); Assert::IsTrue(data.SetAppLastZones(window, deviceId, zoneSetId, { expectedZoneIndex })); - Assert::IsTrue(std::vector{ expectedZoneIndex } == data.GetAppLastZoneIndexSet(window, deviceId, zoneSetId)); + Assert::IsTrue(std::vector{ expectedZoneIndex } == data.GetAppLastZoneIndexSet(window, deviceId, zoneSetId)); } TEST_METHOD (AppLastZoneInvalidWindow) @@ -1911,7 +1911,7 @@ namespace FancyZonesUnitTests FancyZonesData data; data.SetSettingsModulePath(m_moduleName); - Assert::IsTrue(std::vector{} == data.GetAppLastZoneIndexSet(window, deviceId, zoneSetId)); + Assert::IsTrue(std::vector{} == data.GetAppLastZoneIndexSet(window, deviceId, zoneSetId)); const int expectedZoneIndex = 1; Assert::IsFalse(data.SetAppLastZones(window, deviceId, zoneSetId, { expectedZoneIndex })); @@ -1939,8 +1939,8 @@ namespace FancyZonesUnitTests const int expectedZoneIndex = 10; Assert::IsTrue(data.SetAppLastZones(window, deviceId1, zoneSetId, { expectedZoneIndex })); - Assert::IsTrue(std::vector{ expectedZoneIndex } == data.GetAppLastZoneIndexSet(window, deviceId1, zoneSetId)); - Assert::IsTrue(std::vector{} == data.GetAppLastZoneIndexSet(window, deviceId2, zoneSetId)); + Assert::IsTrue(std::vector{ expectedZoneIndex } == data.GetAppLastZoneIndexSet(window, deviceId1, zoneSetId)); + Assert::IsTrue(std::vector{} == data.GetAppLastZoneIndexSet(window, deviceId2, zoneSetId)); } TEST_METHOD (AppLastZoneSetIdTest) @@ -1954,8 +1954,8 @@ namespace FancyZonesUnitTests const int expectedZoneIndex = 10; Assert::IsTrue(data.SetAppLastZones(window, deviceId, zoneSetId1, { expectedZoneIndex })); - Assert::IsTrue(std::vector{ expectedZoneIndex } == data.GetAppLastZoneIndexSet(window, deviceId, zoneSetId1)); - Assert::IsTrue(std::vector{} == data.GetAppLastZoneIndexSet(window, deviceId, zoneSetId2)); + Assert::IsTrue(std::vector{ expectedZoneIndex } == data.GetAppLastZoneIndexSet(window, deviceId, zoneSetId1)); + Assert::IsTrue(std::vector{} == data.GetAppLastZoneIndexSet(window, deviceId, zoneSetId2)); } TEST_METHOD (AppLastZoneRemoveWindow) @@ -1968,7 +1968,7 @@ namespace FancyZonesUnitTests Assert::IsTrue(data.SetAppLastZones(window, deviceId, zoneSetId, { 1 })); Assert::IsTrue(data.RemoveAppLastZone(window, deviceId, zoneSetId)); - Assert::IsTrue(std::vector{} == data.GetAppLastZoneIndexSet(window, deviceId, zoneSetId)); + Assert::IsTrue(std::vector{} == data.GetAppLastZoneIndexSet(window, deviceId, zoneSetId)); } TEST_METHOD (AppLastZoneRemoveUnknownWindow) @@ -1980,7 +1980,7 @@ namespace FancyZonesUnitTests data.SetSettingsModulePath(m_moduleName); Assert::IsFalse(data.RemoveAppLastZone(window, deviceId, zoneSetId)); - Assert::IsTrue(std::vector{} == data.GetAppLastZoneIndexSet(window, deviceId, zoneSetId)); + Assert::IsTrue(std::vector{} == data.GetAppLastZoneIndexSet(window, deviceId, zoneSetId)); } TEST_METHOD (AppLastZoneRemoveUnknownZoneSetId) @@ -1994,7 +1994,7 @@ namespace FancyZonesUnitTests Assert::IsTrue(data.SetAppLastZones(window, deviceId, zoneSetIdToInsert, { 1 })); Assert::IsFalse(data.RemoveAppLastZone(window, deviceId, zoneSetIdToRemove)); - Assert::IsTrue(std::vector{ 1 } == data.GetAppLastZoneIndexSet(window, deviceId, zoneSetIdToInsert)); + Assert::IsTrue(std::vector{ 1 } == data.GetAppLastZoneIndexSet(window, deviceId, zoneSetIdToInsert)); } TEST_METHOD (AppLastZoneRemoveUnknownWindowId) @@ -2008,7 +2008,7 @@ namespace FancyZonesUnitTests Assert::IsTrue(data.SetAppLastZones(window, deviceIdToInsert, zoneSetId, { 1 })); Assert::IsFalse(data.RemoveAppLastZone(window, deviceIdToRemove, zoneSetId)); - Assert::IsTrue(std::vector{ 1 } == data.GetAppLastZoneIndexSet(window, deviceIdToInsert, zoneSetId)); + Assert::IsTrue(std::vector{ 1 } == data.GetAppLastZoneIndexSet(window, deviceIdToInsert, zoneSetId)); } TEST_METHOD (AppLastZoneRemoveNullWindow) diff --git a/src/modules/fancyzones/FancyZonesTests/UnitTests/WorkArea.Spec.cpp b/src/modules/fancyzones/FancyZonesTests/UnitTests/WorkArea.Spec.cpp index 3ee4cf6d59..d2cd2897b0 100644 --- a/src/modules/fancyzones/FancyZonesTests/UnitTests/WorkArea.Spec.cpp +++ b/src/modules/fancyzones/FancyZonesTests/UnitTests/WorkArea.Spec.cpp @@ -271,7 +271,7 @@ namespace FancyZonesUnitTests const auto zoneSet = workArea->ActiveZoneSet(); zoneSet->MoveWindowIntoZoneByIndex(window, Mocks::Window(), 0); const auto actualZoneIndexSet = zoneSet->GetZoneIndexSetFromWindow(window); - Assert::IsFalse(std::vector{} == actualZoneIndexSet); + Assert::IsFalse(std::vector{} == actualZoneIndexSet); } TEST_METHOD (MoveSizeEndWindowNotAdded) @@ -287,7 +287,7 @@ namespace FancyZonesUnitTests const auto zoneSet = workArea->ActiveZoneSet(); const auto actualZoneIndexSet = zoneSet->GetZoneIndexSetFromWindow(window); - Assert::IsTrue(std::vector{} == actualZoneIndexSet); + Assert::IsTrue(std::vector{} == actualZoneIndexSet); } TEST_METHOD (MoveSizeEndDifferentWindows) @@ -327,7 +327,7 @@ namespace FancyZonesUnitTests const auto zoneSet = workArea->ActiveZoneSet(); zoneSet->MoveWindowIntoZoneByIndex(window, Mocks::Window(), 0); const auto actualZoneIndex = zoneSet->GetZoneIndexSetFromWindow(window); - Assert::IsFalse(std::vector{} == actualZoneIndex); // with invalid point zone remains the same + Assert::IsFalse(std::vector{} == actualZoneIndex); // with invalid point zone remains the same } TEST_METHOD (MoveWindowIntoZoneByIndex) @@ -352,7 +352,7 @@ namespace FancyZonesUnitTests Assert::AreEqual((size_t)1, actualAppZoneHistory.size()); const auto& appHistoryArray = actualAppZoneHistory.begin()->second; Assert::AreEqual((size_t)1, appHistoryArray.size()); - Assert::IsTrue(std::vector{ 0 } == appHistoryArray[0].zoneIndexSet); + Assert::IsTrue(std::vector{ 0 } == appHistoryArray[0].zoneIndexSet); } TEST_METHOD (MoveWindowIntoZoneByDirectionManyTimes) @@ -369,7 +369,7 @@ namespace FancyZonesUnitTests Assert::AreEqual((size_t)1, actualAppZoneHistory.size()); const auto& appHistoryArray = actualAppZoneHistory.begin()->second; Assert::AreEqual((size_t)1, appHistoryArray.size()); - Assert::IsTrue(std::vector{ 2 } == appHistoryArray[0].zoneIndexSet); + Assert::IsTrue(std::vector{ 2 } == appHistoryArray[0].zoneIndexSet); } TEST_METHOD (SaveWindowProcessToZoneIndexNullptrWindow) @@ -413,7 +413,7 @@ namespace FancyZonesUnitTests Assert::AreEqual((size_t)1, m_fancyZonesData.GetAppZoneHistoryMap().size()); const auto& appHistoryArray1 = m_fancyZonesData.GetAppZoneHistoryMap().at(processPath); Assert::AreEqual((size_t)1, appHistoryArray1.size()); - Assert::IsTrue(std::vector{ 0 } == appHistoryArray1[0].zoneIndexSet); + Assert::IsTrue(std::vector{ 0 } == appHistoryArray1[0].zoneIndexSet); // add zone without window const auto zone = MakeZone(RECT{ 0, 0, 100, 100 }, 1); @@ -423,7 +423,7 @@ namespace FancyZonesUnitTests Assert::AreEqual((size_t)1, m_fancyZonesData.GetAppZoneHistoryMap().size()); const auto& appHistoryArray2 = m_fancyZonesData.GetAppZoneHistoryMap().at(processPath); Assert::AreEqual((size_t)1, appHistoryArray2.size()); - Assert::IsTrue(std::vector{ 0 } == appHistoryArray2[0].zoneIndexSet); + Assert::IsTrue(std::vector{ 0 } == appHistoryArray2[0].zoneIndexSet); } TEST_METHOD (SaveWindowProcessToZoneIndexWindowAdded) @@ -445,7 +445,7 @@ namespace FancyZonesUnitTests Assert::AreEqual((size_t)1, m_fancyZonesData.GetAppZoneHistoryMap().size()); const auto& appHistoryArray = m_fancyZonesData.GetAppZoneHistoryMap().at(processPath); Assert::AreEqual((size_t)1, appHistoryArray.size()); - Assert::IsTrue(std::vector{ 2 } == appHistoryArray[0].zoneIndexSet); + Assert::IsTrue(std::vector{ 2 } == appHistoryArray[0].zoneIndexSet); workArea->SaveWindowProcessToZoneIndex(window); diff --git a/src/modules/fancyzones/FancyZonesTests/UnitTests/Zone.Spec.cpp b/src/modules/fancyzones/FancyZonesTests/UnitTests/Zone.Spec.cpp index f66f27b2b4..c1ff9d9810 100644 --- a/src/modules/fancyzones/FancyZonesTests/UnitTests/Zone.Spec.cpp +++ b/src/modules/fancyzones/FancyZonesTests/UnitTests/Zone.Spec.cpp @@ -37,7 +37,7 @@ namespace FancyZonesUnitTests TEST_METHOD(GetSetId) { - constexpr size_t zoneId = 123; + constexpr ZoneIndex zoneId = 123; winrt::com_ptr zone = MakeZone(m_zoneRect, zoneId); Assert::AreEqual(zone->Id(), zoneId); diff --git a/src/modules/fancyzones/FancyZonesTests/UnitTests/ZoneSet.Spec.cpp b/src/modules/fancyzones/FancyZonesTests/UnitTests/ZoneSet.Spec.cpp index 564469e2bb..e2e4adb279 100644 --- a/src/modules/fancyzones/FancyZonesTests/UnitTests/ZoneSet.Spec.cpp +++ b/src/modules/fancyzones/FancyZonesTests/UnitTests/ZoneSet.Spec.cpp @@ -85,7 +85,7 @@ namespace FancyZonesUnitTests TEST_METHOD (AddOne) { - constexpr size_t zoneId = 0; + constexpr ZoneIndex zoneId = 0; winrt::com_ptr zone = MakeZone({ 0, 0, 100, 100 }, zoneId); Assert::IsNotNull(zone.get()); m_set->AddZone(zone); @@ -99,7 +99,7 @@ namespace FancyZonesUnitTests { for (size_t i = 0; i < 1024; i++) { - size_t zoneId = i; + ZoneIndex zoneId = i; winrt::com_ptr zone = MakeZone({ 0, 0, 100, 100 }, zoneId); Assert::IsNotNull(zone.get()); m_set->AddZone(zone); @@ -114,7 +114,7 @@ namespace FancyZonesUnitTests { for (size_t i = 0; i < 1024; i++) { - size_t zoneId = i; + ZoneIndex zoneId = i; int left = rand() % 10; int top = rand() % 10; int right = left + 1 + rand() % 100; @@ -302,7 +302,7 @@ namespace FancyZonesUnitTests m_set->MoveWindowIntoZoneByIndexSet(window, zoneWindow, { 0 }); auto actual = m_set->GetZoneIndexSetFromWindow(Mocks::Window()); - Assert::IsTrue(std::vector{} == actual); + Assert::IsTrue(std::vector{} == actual); } TEST_METHOD (ZoneIndexFromWindowNull) @@ -314,7 +314,7 @@ namespace FancyZonesUnitTests m_set->MoveWindowIntoZoneByIndexSet(window, zoneWindow, { 0 }); auto actual = m_set->GetZoneIndexSetFromWindow(nullptr); - Assert::IsTrue(std::vector{} == actual); + Assert::IsTrue(std::vector{} == actual); } TEST_METHOD (MoveWindowIntoZoneByIndex) @@ -328,7 +328,7 @@ namespace FancyZonesUnitTests HWND window = Mocks::Window(); m_set->MoveWindowIntoZoneByIndex(window, Mocks::Window(), 1); - Assert::IsTrue(std::vector{ 1 } == m_set->GetZoneIndexSetFromWindow(window)); + Assert::IsTrue(std::vector{ 1 } == m_set->GetZoneIndexSetFromWindow(window)); } TEST_METHOD (MoveWindowIntoZoneByIndexWithNoZones) @@ -348,7 +348,7 @@ namespace FancyZonesUnitTests HWND window = Mocks::Window(); m_set->MoveWindowIntoZoneByIndex(window, Mocks::Window(), 100); - Assert::IsTrue(std::vector{} == m_set->GetZoneIndexSetFromWindow(window)); + Assert::IsTrue(std::vector{} == m_set->GetZoneIndexSetFromWindow(window)); } TEST_METHOD (MoveWindowIntoZoneByIndexSeveralTimesSameWindow) @@ -363,13 +363,13 @@ namespace FancyZonesUnitTests HWND window = Mocks::Window(); m_set->MoveWindowIntoZoneByIndex(window, Mocks::Window(), 0); - Assert::IsTrue(std::vector{ 0 } == m_set->GetZoneIndexSetFromWindow(window)); + Assert::IsTrue(std::vector{ 0 } == m_set->GetZoneIndexSetFromWindow(window)); m_set->MoveWindowIntoZoneByIndex(window, Mocks::Window(), 1); - Assert::IsTrue(std::vector{ 1 } == m_set->GetZoneIndexSetFromWindow(window)); + Assert::IsTrue(std::vector{ 1 } == m_set->GetZoneIndexSetFromWindow(window)); m_set->MoveWindowIntoZoneByIndex(window, Mocks::Window(), 2); - Assert::IsTrue(std::vector{ 2 } == m_set->GetZoneIndexSetFromWindow(window)); + Assert::IsTrue(std::vector{ 2 } == m_set->GetZoneIndexSetFromWindow(window)); } TEST_METHOD (MoveWindowIntoZoneByIndexSeveralTimesSameIndex) @@ -386,7 +386,7 @@ namespace FancyZonesUnitTests m_set->MoveWindowIntoZoneByIndex(window, Mocks::Window(), 0); m_set->MoveWindowIntoZoneByIndex(window, Mocks::Window(), 0); m_set->MoveWindowIntoZoneByIndex(window, Mocks::Window(), 0); - Assert::IsTrue(std::vector{ 0 } == m_set->GetZoneIndexSetFromWindow(window)); + Assert::IsTrue(std::vector{ 0 } == m_set->GetZoneIndexSetFromWindow(window)); } TEST_METHOD (MoveWindowIntoZoneByPointEmpty) @@ -402,7 +402,7 @@ namespace FancyZonesUnitTests auto window = Mocks::Window(); m_set->MoveWindowIntoZoneByPoint(window, Mocks::Window(), POINT{ 200, 200 }); - Assert::IsTrue(std::vector{} == m_set->GetZoneIndexSetFromWindow(window)); + Assert::IsTrue(std::vector{} == m_set->GetZoneIndexSetFromWindow(window)); } TEST_METHOD (MoveWindowIntoZoneByPointInnerPoint) @@ -413,7 +413,7 @@ namespace FancyZonesUnitTests auto window = Mocks::Window(); m_set->MoveWindowIntoZoneByPoint(window, Mocks::Window(), POINT{ 50, 50 }); - Assert::IsTrue(std::vector{ 0 } == m_set->GetZoneIndexSetFromWindow(window)); + Assert::IsTrue(std::vector{ 0 } == m_set->GetZoneIndexSetFromWindow(window)); } TEST_METHOD (MoveWindowIntoZoneByPointInnerPointOverlappingZones) @@ -426,7 +426,7 @@ namespace FancyZonesUnitTests auto window = Mocks::Window(); m_set->MoveWindowIntoZoneByPoint(window, Mocks::Window(), POINT{ 50, 50 }); - Assert::IsTrue(std::vector{ 1 } == m_set->GetZoneIndexSetFromWindow(window)); + Assert::IsTrue(std::vector{ 1 } == m_set->GetZoneIndexSetFromWindow(window)); } TEST_METHOD (MoveWindowIntoZoneByPointDropAddWindow) @@ -444,7 +444,7 @@ namespace FancyZonesUnitTests m_set->MoveWindowIntoZoneByPoint(window, Mocks::Window(), POINT{ 50, 50 }); - Assert::IsTrue(std::vector{ 1 } == m_set->GetZoneIndexSetFromWindow(window)); + Assert::IsTrue(std::vector{ 1 } == m_set->GetZoneIndexSetFromWindow(window)); } TEST_METHOD (MoveWindowIntoZoneByPointDropAddWindowToSameZone) @@ -462,7 +462,7 @@ namespace FancyZonesUnitTests m_set->MoveWindowIntoZoneByPoint(window, Mocks::Window(), POINT{ 50, 50 }); - Assert::IsTrue(std::vector{ 1 } == m_set->GetZoneIndexSetFromWindow(window)); + Assert::IsTrue(std::vector{ 1 } == m_set->GetZoneIndexSetFromWindow(window)); } TEST_METHOD (MoveWindowIntoZoneByPointSeveralZonesWithSameWindow) @@ -482,7 +482,7 @@ namespace FancyZonesUnitTests m_set->MoveWindowIntoZoneByPoint(window, Mocks::Window(), POINT{ 50, 50 }); - Assert::IsTrue(std::vector{ 2 } == m_set->GetZoneIndexSetFromWindow(window)); + Assert::IsTrue(std::vector{ 2 } == m_set->GetZoneIndexSetFromWindow(window)); } }; @@ -528,14 +528,14 @@ namespace FancyZonesUnitTests { HWND window = Mocks::Window(); m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_RIGHT, true); - Assert::IsTrue(std::vector{ 0 } == m_set->GetZoneIndexSetFromWindow(window)); + Assert::IsTrue(std::vector{ 0 } == m_set->GetZoneIndexSetFromWindow(window)); } TEST_METHOD (MoveLeftNoZones) { HWND window = Mocks::Window(); m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_LEFT, true); - Assert::IsTrue(std::vector{ 2 } == m_set->GetZoneIndexSetFromWindow(window)); + Assert::IsTrue(std::vector{ 2 } == m_set->GetZoneIndexSetFromWindow(window)); } TEST_METHOD (MoveRightTwice) @@ -543,7 +543,7 @@ namespace FancyZonesUnitTests HWND window = Mocks::Window(); m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_RIGHT, true); m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_RIGHT, true); - Assert::IsTrue(std::vector{ 1 } == m_set->GetZoneIndexSetFromWindow(window)); + Assert::IsTrue(std::vector{ 1 } == m_set->GetZoneIndexSetFromWindow(window)); } TEST_METHOD (MoveLeftTwice) @@ -551,7 +551,7 @@ namespace FancyZonesUnitTests HWND window = Mocks::Window(); m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_LEFT, true); m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_LEFT, true); - Assert::IsTrue(std::vector{ 1 } == m_set->GetZoneIndexSetFromWindow(window)); + Assert::IsTrue(std::vector{ 1 } == m_set->GetZoneIndexSetFromWindow(window)); } TEST_METHOD (MoveRightMoreThanZonesCount) @@ -562,7 +562,7 @@ namespace FancyZonesUnitTests m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_RIGHT, true); } - Assert::IsTrue(std::vector{ 0 } == m_set->GetZoneIndexSetFromWindow(window)); + Assert::IsTrue(std::vector{ 0 } == m_set->GetZoneIndexSetFromWindow(window)); } TEST_METHOD (MoveLeftMoreThanZonesCount) @@ -573,7 +573,7 @@ namespace FancyZonesUnitTests m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_LEFT, true); } - Assert::IsTrue(std::vector{ 2 } == m_set->GetZoneIndexSetFromWindow(window)); + Assert::IsTrue(std::vector{ 2 } == m_set->GetZoneIndexSetFromWindow(window)); } TEST_METHOD (MoveWindowIntoZoneByDirectionRight) @@ -581,10 +581,10 @@ namespace FancyZonesUnitTests HWND window = Mocks::Window(); m_set->MoveWindowIntoZoneByIndex(window, Mocks::Window(), 0); m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_RIGHT, true); - Assert::IsTrue(std::vector{ 1 } == m_set->GetZoneIndexSetFromWindow(window)); + Assert::IsTrue(std::vector{ 1 } == m_set->GetZoneIndexSetFromWindow(window)); m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_RIGHT, true); - Assert::IsTrue(std::vector{ 2 } == m_set->GetZoneIndexSetFromWindow(window)); + Assert::IsTrue(std::vector{ 2 } == m_set->GetZoneIndexSetFromWindow(window)); } TEST_METHOD (MoveRightWithSameWindowAdded) @@ -592,13 +592,13 @@ namespace FancyZonesUnitTests HWND window = Mocks::Window(); m_set->MoveWindowIntoZoneByIndexSet(window, Mocks::Window(), { 0, 1 }); - Assert::IsTrue(std::vector{ 0, 1 } == m_set->GetZoneIndexSetFromWindow(window)); + Assert::IsTrue(std::vector{ 0, 1 } == m_set->GetZoneIndexSetFromWindow(window)); m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_RIGHT, true); - Assert::IsTrue(std::vector{ 1 } == m_set->GetZoneIndexSetFromWindow(window)); + Assert::IsTrue(std::vector{ 1 } == m_set->GetZoneIndexSetFromWindow(window)); m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_RIGHT, true); - Assert::IsTrue(std::vector{ 2 } == m_set->GetZoneIndexSetFromWindow(window)); + Assert::IsTrue(std::vector{ 2 } == m_set->GetZoneIndexSetFromWindow(window)); } TEST_METHOD (MoveRightWithDifferentWindowsAdded) @@ -608,18 +608,18 @@ namespace FancyZonesUnitTests m_set->MoveWindowIntoZoneByIndex(window1, Mocks::Window(), { 0 }); m_set->MoveWindowIntoZoneByIndex(window2, Mocks::Window(), { 1 }); - Assert::IsTrue(std::vector{ 0 } == m_set->GetZoneIndexSetFromWindow(window1)); - Assert::IsTrue(std::vector{ 1 } == m_set->GetZoneIndexSetFromWindow(window2)); + Assert::IsTrue(std::vector{ 0 } == m_set->GetZoneIndexSetFromWindow(window1)); + Assert::IsTrue(std::vector{ 1 } == m_set->GetZoneIndexSetFromWindow(window2)); m_set->MoveWindowIntoZoneByDirectionAndIndex(window1, Mocks::Window(), VK_RIGHT, true); - Assert::IsTrue(std::vector{ 1 } == m_set->GetZoneIndexSetFromWindow(window1)); - Assert::IsTrue(std::vector{ 1 } == m_set->GetZoneIndexSetFromWindow(window2)); + Assert::IsTrue(std::vector{ 1 } == m_set->GetZoneIndexSetFromWindow(window1)); + Assert::IsTrue(std::vector{ 1 } == m_set->GetZoneIndexSetFromWindow(window2)); m_set->MoveWindowIntoZoneByDirectionAndIndex(window1, Mocks::Window(), VK_RIGHT, true); - Assert::IsTrue(std::vector{ 2 } == m_set->GetZoneIndexSetFromWindow(window1)); - Assert::IsTrue(std::vector{ 1 } == m_set->GetZoneIndexSetFromWindow(window2)); + Assert::IsTrue(std::vector{ 2 } == m_set->GetZoneIndexSetFromWindow(window1)); + Assert::IsTrue(std::vector{ 1 } == m_set->GetZoneIndexSetFromWindow(window2)); } TEST_METHOD (MoveWindowIntoZoneByDirectionLeft) @@ -627,10 +627,10 @@ namespace FancyZonesUnitTests HWND window = Mocks::Window(); m_set->MoveWindowIntoZoneByIndex(window, Mocks::Window(), 2); m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_LEFT, true); - Assert::IsTrue(std::vector{ 1 } == m_set->GetZoneIndexSetFromWindow(window)); + Assert::IsTrue(std::vector{ 1 } == m_set->GetZoneIndexSetFromWindow(window)); m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_LEFT, true); - Assert::IsTrue(std::vector{ 0 } == m_set->GetZoneIndexSetFromWindow(window)); + Assert::IsTrue(std::vector{ 0 } == m_set->GetZoneIndexSetFromWindow(window)); } TEST_METHOD (MoveLeftWithSameWindowAdded) @@ -638,13 +638,13 @@ namespace FancyZonesUnitTests HWND window = Mocks::Window(); m_set->MoveWindowIntoZoneByIndexSet(window, Mocks::Window(), { 1, 2 }); - Assert::IsTrue(std::vector{ 1, 2 } == m_set->GetZoneIndexSetFromWindow(window)); + Assert::IsTrue(std::vector{ 1, 2 } == m_set->GetZoneIndexSetFromWindow(window)); m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_LEFT, true); - Assert::IsTrue(std::vector{ 0 } == m_set->GetZoneIndexSetFromWindow(window)); + Assert::IsTrue(std::vector{ 0 } == m_set->GetZoneIndexSetFromWindow(window)); m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_LEFT, true); - Assert::IsTrue(std::vector{ 2 } == m_set->GetZoneIndexSetFromWindow(window)); + Assert::IsTrue(std::vector{ 2 } == m_set->GetZoneIndexSetFromWindow(window)); } TEST_METHOD (MoveLeftWithDifferentWindowsAdded) @@ -654,16 +654,16 @@ namespace FancyZonesUnitTests m_set->MoveWindowIntoZoneByIndex(window1, Mocks::Window(), 1); m_set->MoveWindowIntoZoneByIndex(window2, Mocks::Window(), 2); - Assert::IsTrue(std::vector{ 1 } == m_set->GetZoneIndexSetFromWindow(window1)); - Assert::IsTrue(std::vector{ 2 } == m_set->GetZoneIndexSetFromWindow(window2)); + Assert::IsTrue(std::vector{ 1 } == m_set->GetZoneIndexSetFromWindow(window1)); + Assert::IsTrue(std::vector{ 2 } == m_set->GetZoneIndexSetFromWindow(window2)); m_set->MoveWindowIntoZoneByDirectionAndIndex(window2, Mocks::Window(), VK_LEFT, true); - Assert::IsTrue(std::vector{ 1 } == m_set->GetZoneIndexSetFromWindow(window1)); - Assert::IsTrue(std::vector{ 1 } == m_set->GetZoneIndexSetFromWindow(window2)); + Assert::IsTrue(std::vector{ 1 } == m_set->GetZoneIndexSetFromWindow(window1)); + Assert::IsTrue(std::vector{ 1 } == m_set->GetZoneIndexSetFromWindow(window2)); m_set->MoveWindowIntoZoneByDirectionAndIndex(window2, Mocks::Window(), VK_LEFT, true); - Assert::IsTrue(std::vector{ 1 } == m_set->GetZoneIndexSetFromWindow(window1)); - Assert::IsTrue(std::vector{ 0 } == m_set->GetZoneIndexSetFromWindow(window2)); + Assert::IsTrue(std::vector{ 1 } == m_set->GetZoneIndexSetFromWindow(window1)); + Assert::IsTrue(std::vector{ 0 } == m_set->GetZoneIndexSetFromWindow(window2)); } TEST_METHOD (MoveWindowIntoZoneByDirectionWrapAroundRight) @@ -671,7 +671,7 @@ namespace FancyZonesUnitTests HWND window = Mocks::Window(); m_set->MoveWindowIntoZoneByIndex(window, Mocks::Window(), 2); m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_RIGHT, true); - Assert::IsTrue(std::vector{ 0 } == m_set->GetZoneIndexSetFromWindow(window)); + Assert::IsTrue(std::vector{ 0 } == m_set->GetZoneIndexSetFromWindow(window)); } TEST_METHOD (MoveWindowIntoZoneByDirectionWrapAroundLeft) @@ -679,7 +679,7 @@ namespace FancyZonesUnitTests HWND window = Mocks::Window(); m_set->MoveWindowIntoZoneByIndex(window, Mocks::Window(), 0); m_set->MoveWindowIntoZoneByDirectionAndIndex(window, Mocks::Window(), VK_LEFT, true); - Assert::IsTrue(std::vector{ 2 } == m_set->GetZoneIndexSetFromWindow(window)); + Assert::IsTrue(std::vector{ 2 } == m_set->GetZoneIndexSetFromWindow(window)); } TEST_METHOD (MoveSecondWindowIntoSameZone) @@ -690,8 +690,8 @@ namespace FancyZonesUnitTests HWND window2 = Mocks::Window(); m_set->MoveWindowIntoZoneByDirectionAndIndex(window2, Mocks::Window(), VK_RIGHT, true); - Assert::IsTrue(std::vector{ 0 } == m_set->GetZoneIndexSetFromWindow(window1)); - Assert::IsTrue(std::vector{ 0 } == m_set->GetZoneIndexSetFromWindow(window2)); + Assert::IsTrue(std::vector{ 0 } == m_set->GetZoneIndexSetFromWindow(window1)); + Assert::IsTrue(std::vector{ 0 } == m_set->GetZoneIndexSetFromWindow(window2)); } TEST_METHOD (MoveRightMoreThanZoneCountReturnsFalse)