Use same zone set initially for new virtual desktops of same monitor (#815)

This commit is contained in:
vldmr11080
2019-12-06 15:09:27 +01:00
committed by Enrico Giordani
parent add63d2dde
commit 014c2c5249
4 changed files with 32 additions and 35 deletions

View File

@@ -41,7 +41,6 @@ private:
void LoadSettings() noexcept;
void InitializeZoneSets(MONITORINFO const& mi) noexcept;
void LoadZoneSetsFromRegistry() noexcept;
void AddDefaultZoneSet(MONITORINFO const& mi) noexcept;
void UpdateActiveZoneSet(_In_opt_ IZoneSet* zoneSet) noexcept;
LRESULT WndProc(UINT message, WPARAM wparam, LPARAM lparam) noexcept;
void DrawBackdrop(wil::unique_hdc& hdc, RECT const& clientRect) noexcept;
@@ -250,7 +249,7 @@ IFACEMETHODIMP_(void) ZoneWindow::SaveWindowProcessToZoneIndex(HWND window) noex
RegistryHelpers::SaveAppLastZone(window, processPath.data(), zoneIndex);
}
}
}
}
#pragma region private
void ZoneWindow::ShowZoneWindow() noexcept
@@ -314,12 +313,6 @@ void ZoneWindow::InitializeZoneSets(MONITORINFO const& mi) noexcept
{
LoadZoneSetsFromRegistry();
if (m_zoneSets.empty())
{
// Add a "maximize" zone as the only default layout.
AddDefaultZoneSet(mi);
}
if (!m_activeZoneSet)
{
ChooseDefaultActiveZoneSet();
@@ -378,20 +371,6 @@ void ZoneWindow::LoadZoneSetsFromRegistry() 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)))
{
zoneSet->AddZone(MakeZone(mi.rcWork));
m_zoneSets.emplace_back(zoneSet);
}
}
}
void ZoneWindow::UpdateActiveZoneSet(_In_opt_ IZoneSet* zoneSet) noexcept
{
m_activeZoneSet.copy_from(zoneSet);
@@ -644,10 +623,15 @@ winrt::com_ptr<IZone> ZoneWindow::ZoneFromPoint(POINT pt) noexcept
void ZoneWindow::ChooseDefaultActiveZoneSet() noexcept
{
if (!m_activeZoneSet)
{
auto zoneSet = m_zoneSets.at(0);
UpdateActiveZoneSet(zoneSet.get());
// Default zone set can be empty (no fancyzones layout), or it can be layout from virtual
// desktop from which this virtual desktop is created.
if (GUID id{ m_host->GetCurrentMonitorZoneSetId(m_monitor) }; id != GUID_NULL) {
for (const auto& zoneSet : m_zoneSets) {
if (id == zoneSet->Id()) {
UpdateActiveZoneSet(zoneSet.get());
return;
}
}
}
}