[FancyZones] Remove m_workArea from ZoneWindow (#5185)

* Removed m_workArea from ZoneWindow

* Remove another unused variable
This commit is contained in:
Ivan Stošić 2020-07-24 11:17:39 +02:00 committed by GitHub
parent ff1e04b957
commit 5d66473a4f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 42 deletions

View file

@ -111,19 +111,16 @@ struct ZoneSetConfig
ZoneSetConfig( ZoneSetConfig(
GUID id, GUID id,
FancyZonesDataTypes::ZoneSetLayoutType layoutType, FancyZonesDataTypes::ZoneSetLayoutType layoutType,
HMONITOR monitor, HMONITOR monitor) noexcept :
PCWSTR resolutionKey) noexcept :
Id(id), Id(id),
LayoutType(layoutType), LayoutType(layoutType),
Monitor(monitor), Monitor(monitor)
ResolutionKey(resolutionKey)
{ {
} }
GUID Id{}; GUID Id{};
FancyZonesDataTypes::ZoneSetLayoutType LayoutType{}; FancyZonesDataTypes::ZoneSetLayoutType LayoutType{};
HMONITOR Monitor{}; HMONITOR Monitor{};
PCWSTR ResolutionKey{};
}; };
winrt::com_ptr<IZoneSet> MakeZoneSet(ZoneSetConfig const& config) noexcept; winrt::com_ptr<IZoneSet> MakeZoneSet(ZoneSetConfig const& config) noexcept;

View file

@ -184,8 +184,6 @@ public:
CycleActiveZoneSet(DWORD vkCode) noexcept; CycleActiveZoneSet(DWORD vkCode) noexcept;
IFACEMETHODIMP_(std::wstring) IFACEMETHODIMP_(std::wstring)
UniqueId() noexcept { return { m_uniqueId }; } UniqueId() noexcept { return { m_uniqueId }; }
IFACEMETHODIMP_(std::wstring)
WorkAreaKey() noexcept { return { m_workArea }; }
IFACEMETHODIMP_(void) IFACEMETHODIMP_(void)
SaveWindowProcessToZoneIndex(HWND window) noexcept; SaveWindowProcessToZoneIndex(HWND window) noexcept;
IFACEMETHODIMP_(IZoneSet*) IFACEMETHODIMP_(IZoneSet*)
@ -216,7 +214,6 @@ private:
winrt::com_ptr<IZoneWindowHost> m_host; winrt::com_ptr<IZoneWindowHost> m_host;
HMONITOR m_monitor{}; HMONITOR m_monitor{};
std::wstring m_uniqueId; // Parsed deviceId + resolution + virtualDesktopId std::wstring m_uniqueId; // Parsed deviceId + resolution + virtualDesktopId
wchar_t m_workArea[256]{};
wil::unique_hwnd m_window{}; // Hidden tool window used to represent current monitor desktop work area. wil::unique_hwnd m_window{}; // Hidden tool window used to represent current monitor desktop work area.
HWND m_windowMoveSize{}; HWND m_windowMoveSize{};
bool m_drawHints{}; bool m_drawHints{};
@ -265,9 +262,7 @@ bool ZoneWindow::Init(IZoneWindowHost* host, HINSTANCE hinstance, HMONITOR monit
m_monitor = monitor; m_monitor = monitor;
const UINT dpi = GetDpiForMonitor(m_monitor); const UINT dpi = GetDpiForMonitor(m_monitor);
const Rect monitorRect(mi.rcMonitor);
const Rect workAreaRect(mi.rcWork, dpi); const Rect workAreaRect(mi.rcWork, dpi);
StringCchPrintf(m_workArea, ARRAYSIZE(m_workArea), L"%d_%d", monitorRect.width(), monitorRect.height());
m_uniqueId = uniqueId; m_uniqueId = uniqueId;
InitializeZoneSets(parentUniqueId); InitializeZoneSets(parentUniqueId);
@ -570,8 +565,7 @@ void ZoneWindow::CalculateZoneSet() noexcept
auto zoneSet = MakeZoneSet(ZoneSetConfig( auto zoneSet = MakeZoneSet(ZoneSetConfig(
zoneSetId, zoneSetId,
activeZoneSet.type, activeZoneSet.type,
m_monitor, m_monitor));
m_workArea));
MONITORINFO monitorInfo{}; MONITORINFO monitorInfo{};
monitorInfo.cbSize = sizeof(monitorInfo); monitorInfo.cbSize = sizeof(monitorInfo);
if (GetMonitorInfoW(m_monitor, &monitorInfo)) if (GetMonitorInfoW(m_monitor, &monitorInfo))

View file

@ -85,10 +85,6 @@ interface __declspec(uuid("{7F017528-8110-4FB3-BE41-F472969C2560}")) IZoneWindow
* @returns Unique work area identifier. Format: <device-id>_<resolution>_<virtual-desktop-id> * @returns Unique work area identifier. Format: <device-id>_<resolution>_<virtual-desktop-id>
*/ */
IFACEMETHOD_(std::wstring, UniqueId)() = 0; IFACEMETHOD_(std::wstring, UniqueId)() = 0;
/**
* @returns Work area resolution (not same as monitor resolution).
*/
IFACEMETHOD_(std::wstring, WorkAreaKey)() = 0;
/** /**
* @returns Active zone layout for this work area. * @returns Active zone layout for this work area.
*/ */

View file

@ -18,7 +18,6 @@ namespace FancyZonesUnitTests
{ {
GUID m_id; GUID m_id;
const ZoneSetLayoutType m_layoutType = ZoneSetLayoutType::Custom; const ZoneSetLayoutType m_layoutType = ZoneSetLayoutType::Custom;
const PCWSTR m_resolutionKey = L"WorkAreaIn";
winrt::com_ptr<IZoneSet> m_set; winrt::com_ptr<IZoneSet> m_set;
@ -27,7 +26,7 @@ namespace FancyZonesUnitTests
auto hres = CoCreateGuid(&m_id); auto hres = CoCreateGuid(&m_id);
Assert::AreEqual(S_OK, hres); Assert::AreEqual(S_OK, hres);
ZoneSetConfig m_config = ZoneSetConfig(m_id, m_layoutType, Mocks::Monitor(), m_resolutionKey); ZoneSetConfig m_config = ZoneSetConfig(m_id, m_layoutType, Mocks::Monitor());
m_set = MakeZoneSet(m_config); m_set = MakeZoneSet(m_config);
} }
@ -51,7 +50,7 @@ namespace FancyZonesUnitTests
TEST_METHOD (TestCreateZoneSetGuidEmpty) TEST_METHOD (TestCreateZoneSetGuidEmpty)
{ {
GUID zoneSetId{}; GUID zoneSetId{};
ZoneSetConfig config(zoneSetId, m_layoutType, Mocks::Monitor(), m_resolutionKey); ZoneSetConfig config(zoneSetId, m_layoutType, Mocks::Monitor());
winrt::com_ptr<IZoneSet> set = MakeZoneSet(config); winrt::com_ptr<IZoneSet> set = MakeZoneSet(config);
Assert::IsNotNull(&set); Assert::IsNotNull(&set);
@ -61,7 +60,7 @@ namespace FancyZonesUnitTests
TEST_METHOD (TestCreateZoneSetMonitorEmpty) TEST_METHOD (TestCreateZoneSetMonitorEmpty)
{ {
ZoneSetConfig config(m_id, m_layoutType, nullptr, m_resolutionKey); ZoneSetConfig config(m_id, m_layoutType, nullptr);
winrt::com_ptr<IZoneSet> set = MakeZoneSet(config); winrt::com_ptr<IZoneSet> set = MakeZoneSet(config);
Assert::IsNotNull(&set); Assert::IsNotNull(&set);
CustomAssert::AreEqual(set->Id(), m_id); CustomAssert::AreEqual(set->Id(), m_id);
@ -70,7 +69,7 @@ namespace FancyZonesUnitTests
TEST_METHOD (TestCreateZoneSetKeyEmpty) TEST_METHOD (TestCreateZoneSetKeyEmpty)
{ {
ZoneSetConfig config(m_id, m_layoutType, Mocks::Monitor(), nullptr); ZoneSetConfig config(m_id, m_layoutType, Mocks::Monitor());
winrt::com_ptr<IZoneSet> set = MakeZoneSet(config); winrt::com_ptr<IZoneSet> set = MakeZoneSet(config);
Assert::IsNotNull(&set); Assert::IsNotNull(&set);
CustomAssert::AreEqual(set->Id(), m_id); CustomAssert::AreEqual(set->Id(), m_id);
@ -492,7 +491,7 @@ namespace FancyZonesUnitTests
TEST_METHOD_INITIALIZE(Initialize) TEST_METHOD_INITIALIZE(Initialize)
{ {
ZoneSetConfig config({}, ZoneSetLayoutType::Custom, Mocks::Monitor(), L"WorkAreaIn"); ZoneSetConfig config({}, ZoneSetLayoutType::Custom, Mocks::Monitor());
m_set = MakeZoneSet(config); m_set = MakeZoneSet(config);
// Add a couple of zones. // Add a couple of zones.
@ -506,7 +505,7 @@ namespace FancyZonesUnitTests
TEST_METHOD (EmptyZonesLeft) TEST_METHOD (EmptyZonesLeft)
{ {
ZoneSetConfig config({}, ZoneSetLayoutType::Custom, Mocks::Monitor(), L"WorkAreaIn"); ZoneSetConfig config({}, ZoneSetLayoutType::Custom, Mocks::Monitor());
auto set = MakeZoneSet(config); auto set = MakeZoneSet(config);
set->MoveWindowIntoZoneByDirection(Mocks::Window(), Mocks::Window(), VK_LEFT, true); set->MoveWindowIntoZoneByDirection(Mocks::Window(), Mocks::Window(), VK_LEFT, true);
@ -514,7 +513,7 @@ namespace FancyZonesUnitTests
TEST_METHOD (EmptyZonesRight) TEST_METHOD (EmptyZonesRight)
{ {
ZoneSetConfig config({}, ZoneSetLayoutType::Custom, Mocks::Monitor(), L"WorkAreaIn"); ZoneSetConfig config({}, ZoneSetLayoutType::Custom, Mocks::Monitor());
auto set = MakeZoneSet(config); auto set = MakeZoneSet(config);
set->MoveWindowIntoZoneByDirection(Mocks::Window(), Mocks::Window(), VK_RIGHT, true); set->MoveWindowIntoZoneByDirection(Mocks::Window(), Mocks::Window(), VK_RIGHT, true);
@ -746,7 +745,7 @@ namespace FancyZonesUnitTests
m_monitor = MonitorFromPoint(POINT{ 0, 0 }, MONITOR_DEFAULTTOPRIMARY); m_monitor = MonitorFromPoint(POINT{ 0, 0 }, MONITOR_DEFAULTTOPRIMARY);
ZoneSetConfig m_config = ZoneSetConfig(m_id, m_layoutType, m_monitor, m_resolutionKey); ZoneSetConfig m_config = ZoneSetConfig(m_id, m_layoutType, m_monitor);
m_set = MakeZoneSet(m_config); m_set = MakeZoneSet(m_config);
} }
@ -787,7 +786,7 @@ namespace FancyZonesUnitTests
for (int type = static_cast<int>(ZoneSetLayoutType::Focus); type < static_cast<int>(ZoneSetLayoutType::Custom); type++) for (int type = static_cast<int>(ZoneSetLayoutType::Focus); type < static_cast<int>(ZoneSetLayoutType::Custom); type++)
{ {
ZoneSetConfig m_config = ZoneSetConfig(m_id, static_cast<ZoneSetLayoutType>(type), m_monitor, m_resolutionKey); ZoneSetConfig m_config = ZoneSetConfig(m_id, static_cast<ZoneSetLayoutType>(type), m_monitor);
for (const auto& monitorInfo : m_popularMonitors) for (const auto& monitorInfo : m_popularMonitors)
{ {
@ -805,7 +804,7 @@ namespace FancyZonesUnitTests
for (int type = static_cast<int>(ZoneSetLayoutType::Focus); type < static_cast<int>(ZoneSetLayoutType::Custom); type++) for (int type = static_cast<int>(ZoneSetLayoutType::Focus); type < static_cast<int>(ZoneSetLayoutType::Custom); type++)
{ {
ZoneSetConfig m_config = ZoneSetConfig(m_id, static_cast<ZoneSetLayoutType>(type), m_monitor, m_resolutionKey); ZoneSetConfig m_config = ZoneSetConfig(m_id, static_cast<ZoneSetLayoutType>(type), m_monitor);
auto set = MakeZoneSet(m_config); auto set = MakeZoneSet(m_config);
MONITORINFO info{}; MONITORINFO info{};
@ -821,7 +820,7 @@ namespace FancyZonesUnitTests
for (int type = static_cast<int>(ZoneSetLayoutType::Focus); type < static_cast<int>(ZoneSetLayoutType::Custom); type++) for (int type = static_cast<int>(ZoneSetLayoutType::Focus); type < static_cast<int>(ZoneSetLayoutType::Custom); type++)
{ {
ZoneSetConfig m_config = ZoneSetConfig(m_id, static_cast<ZoneSetLayoutType>(type), m_monitor, m_resolutionKey); ZoneSetConfig m_config = ZoneSetConfig(m_id, static_cast<ZoneSetLayoutType>(type), m_monitor);
for (const auto& monitorInfo : m_popularMonitors) for (const auto& monitorInfo : m_popularMonitors)
{ {
@ -840,7 +839,7 @@ namespace FancyZonesUnitTests
for (int type = static_cast<int>(ZoneSetLayoutType::Focus); type < static_cast<int>(ZoneSetLayoutType::Custom); type++) for (int type = static_cast<int>(ZoneSetLayoutType::Focus); type < static_cast<int>(ZoneSetLayoutType::Custom); type++)
{ {
ZoneSetConfig m_config = ZoneSetConfig(m_id, static_cast<ZoneSetLayoutType>(type), m_monitor, m_resolutionKey); ZoneSetConfig m_config = ZoneSetConfig(m_id, static_cast<ZoneSetLayoutType>(type), m_monitor);
auto set = MakeZoneSet(m_config); auto set = MakeZoneSet(m_config);
for (const auto& monitorInfo : m_popularMonitors) for (const auto& monitorInfo : m_popularMonitors)
@ -865,7 +864,7 @@ namespace FancyZonesUnitTests
for (int type = static_cast<int>(ZoneSetLayoutType::Focus); type < static_cast<int>(ZoneSetLayoutType::Custom); type++) for (int type = static_cast<int>(ZoneSetLayoutType::Focus); type < static_cast<int>(ZoneSetLayoutType::Custom); type++)
{ {
ZoneSetConfig m_config = ZoneSetConfig(m_id, static_cast<ZoneSetLayoutType>(type), m_monitor, m_resolutionKey); ZoneSetConfig m_config = ZoneSetConfig(m_id, static_cast<ZoneSetLayoutType>(type), m_monitor);
auto set = MakeZoneSet(m_config); auto set = MakeZoneSet(m_config);
for (const auto& monitorInfo : m_popularMonitors) for (const auto& monitorInfo : m_popularMonitors)
@ -891,7 +890,7 @@ namespace FancyZonesUnitTests
for (int type = static_cast<int>(ZoneSetLayoutType::Focus); type < static_cast<int>(ZoneSetLayoutType::Custom); type++) for (int type = static_cast<int>(ZoneSetLayoutType::Focus); type < static_cast<int>(ZoneSetLayoutType::Custom); type++)
{ {
ZoneSetConfig m_config = ZoneSetConfig(m_id, static_cast<ZoneSetLayoutType>(type), m_monitor, m_resolutionKey); ZoneSetConfig m_config = ZoneSetConfig(m_id, static_cast<ZoneSetLayoutType>(type), m_monitor);
auto set = MakeZoneSet(m_config); auto set = MakeZoneSet(m_config);
for (const auto& monitorInfo : m_popularMonitors) for (const auto& monitorInfo : m_popularMonitors)
@ -918,7 +917,7 @@ namespace FancyZonesUnitTests
for (int type = static_cast<int>(ZoneSetLayoutType::Focus); type < static_cast<int>(ZoneSetLayoutType::Custom); type++) for (int type = static_cast<int>(ZoneSetLayoutType::Focus); type < static_cast<int>(ZoneSetLayoutType::Custom); type++)
{ {
ZoneSetConfig m_config = ZoneSetConfig(m_id, static_cast<ZoneSetLayoutType>(type), m_monitor, m_resolutionKey); ZoneSetConfig m_config = ZoneSetConfig(m_id, static_cast<ZoneSetLayoutType>(type), m_monitor);
auto set = MakeZoneSet(m_config); auto set = MakeZoneSet(m_config);
for (const auto& monitorInfo : m_popularMonitors) for (const auto& monitorInfo : m_popularMonitors)
@ -938,7 +937,7 @@ namespace FancyZonesUnitTests
const int spacing = 10; const int spacing = 10;
const int zoneCount = 40; //editor limit const int zoneCount = 40; //editor limit
ZoneSetConfig m_config = ZoneSetConfig(m_id, static_cast<ZoneSetLayoutType>(type), m_monitor, m_resolutionKey); ZoneSetConfig m_config = ZoneSetConfig(m_id, static_cast<ZoneSetLayoutType>(type), m_monitor);
for (const auto& monitorInfo : m_popularMonitors) for (const auto& monitorInfo : m_popularMonitors)
{ {
@ -961,7 +960,7 @@ namespace FancyZonesUnitTests
std::filesystem::remove(m_path); std::filesystem::remove(m_path);
} }
ZoneSetConfig m_config = ZoneSetConfig(m_id, ZoneSetLayoutType::Custom, m_monitor, m_resolutionKey); ZoneSetConfig m_config = ZoneSetConfig(m_id, ZoneSetLayoutType::Custom, m_monitor);
auto set = MakeZoneSet(m_config); auto set = MakeZoneSet(m_config);
for (const auto& monitorInfo : m_popularMonitors) for (const auto& monitorInfo : m_popularMonitors)
@ -979,7 +978,7 @@ namespace FancyZonesUnitTests
Assert::IsTrue(std::filesystem::create_directories(m_path)); Assert::IsTrue(std::filesystem::create_directories(m_path));
Assert::IsTrue(std::filesystem::exists(m_path)); Assert::IsTrue(std::filesystem::exists(m_path));
ZoneSetConfig m_config = ZoneSetConfig(m_id, ZoneSetLayoutType::Custom, m_monitor, m_resolutionKey); ZoneSetConfig m_config = ZoneSetConfig(m_id, ZoneSetLayoutType::Custom, m_monitor);
auto set = MakeZoneSet(m_config); auto set = MakeZoneSet(m_config);
for (const auto& monitorInfo : m_popularMonitors) for (const auto& monitorInfo : m_popularMonitors)
@ -1000,7 +999,7 @@ namespace FancyZonesUnitTests
const int spacing = 10; const int spacing = 10;
const int zoneCount = static_cast<int>(info.zones.size()); const int zoneCount = static_cast<int>(info.zones.size());
ZoneSetConfig m_config = ZoneSetConfig(m_id, ZoneSetLayoutType::Custom, m_monitor, m_resolutionKey); ZoneSetConfig m_config = ZoneSetConfig(m_id, ZoneSetLayoutType::Custom, m_monitor);
auto set = MakeZoneSet(m_config); auto set = MakeZoneSet(m_config);
for (const auto& monitorInfo : m_popularMonitors) for (const auto& monitorInfo : m_popularMonitors)
@ -1026,7 +1025,7 @@ namespace FancyZonesUnitTests
const int spacing = 0; const int spacing = 0;
const int zoneCount = grid.rows() * grid.columns(); const int zoneCount = grid.rows() * grid.columns();
ZoneSetConfig m_config = ZoneSetConfig(m_id, ZoneSetLayoutType::Custom, m_monitor, m_resolutionKey); ZoneSetConfig m_config = ZoneSetConfig(m_id, ZoneSetLayoutType::Custom, m_monitor);
auto set = MakeZoneSet(m_config); auto set = MakeZoneSet(m_config);
for (const auto& monitorInfo : m_popularMonitors) for (const auto& monitorInfo : m_popularMonitors)
@ -1061,7 +1060,7 @@ namespace FancyZonesUnitTests
//test //test
const int spacing = 10; const int spacing = 10;
const int zoneCount = static_cast<int>(info.zones.size()); const int zoneCount = static_cast<int>(info.zones.size());
ZoneSetConfig m_config = ZoneSetConfig(m_id, ZoneSetLayoutType::Custom, m_monitor, m_resolutionKey); ZoneSetConfig m_config = ZoneSetConfig(m_id, ZoneSetLayoutType::Custom, m_monitor);
for (const auto& monitorInfo : m_popularMonitors) for (const auto& monitorInfo : m_popularMonitors)
{ {
auto set = MakeZoneSet(m_config); auto set = MakeZoneSet(m_config);
@ -1101,7 +1100,7 @@ namespace FancyZonesUnitTests
const int spacing = 10; const int spacing = 10;
const int zoneCount = grid.rows() * grid.columns(); const int zoneCount = grid.rows() * grid.columns();
ZoneSetConfig m_config = ZoneSetConfig(m_id, ZoneSetLayoutType::Custom, m_monitor, m_resolutionKey); ZoneSetConfig m_config = ZoneSetConfig(m_id, ZoneSetLayoutType::Custom, m_monitor);
for (const auto& monitorInfo : m_popularMonitors) for (const auto& monitorInfo : m_popularMonitors)
{ {
@ -1125,7 +1124,7 @@ namespace FancyZonesUnitTests
const int spacing = 0; const int spacing = 0;
const int zoneCount = grid.rows() * grid.columns(); const int zoneCount = grid.rows() * grid.columns();
ZoneSetConfig m_config = ZoneSetConfig(m_id, ZoneSetLayoutType::Custom, m_monitor, m_resolutionKey); ZoneSetConfig m_config = ZoneSetConfig(m_id, ZoneSetLayoutType::Custom, m_monitor);
auto set = MakeZoneSet(m_config); auto set = MakeZoneSet(m_config);
for (const auto& monitorInfo : m_popularMonitors) for (const auto& monitorInfo : m_popularMonitors)

View file

@ -133,7 +133,6 @@ namespace FancyZonesUnitTests
Assert::IsNotNull(zoneWindow.get()); Assert::IsNotNull(zoneWindow.get());
Assert::AreEqual(m_uniqueId.str().c_str(), zoneWindow->UniqueId().c_str()); Assert::AreEqual(m_uniqueId.str().c_str(), zoneWindow->UniqueId().c_str());
Assert::AreEqual(expectedWorkArea, zoneWindow->WorkAreaKey());
} }
public: public:
@ -187,7 +186,6 @@ namespace FancyZonesUnitTests
Assert::IsNotNull(m_zoneWindow.get()); Assert::IsNotNull(m_zoneWindow.get());
Assert::AreEqual(expectedUniqueId.c_str(), m_zoneWindow->UniqueId().c_str()); Assert::AreEqual(expectedUniqueId.c_str(), m_zoneWindow->UniqueId().c_str());
Assert::AreEqual(expectedWorkArea, m_zoneWindow->WorkAreaKey());
Assert::IsNull(m_zoneWindow->ActiveZoneSet()); Assert::IsNull(m_zoneWindow->ActiveZoneSet());
} }