[FancyZones] Improve code quality (part 5: work area initialization) (#23671)

This commit is contained in:
Seraphima Zykova
2023-01-31 12:55:46 +03:00
committed by GitHub
parent c1c14b4f2e
commit fcd05f2f51
12 changed files with 469 additions and 627 deletions

View File

@@ -13,9 +13,10 @@
#include <common/utils/elevation.h>
WindowDrag::WindowDrag(HWND window, const std::unordered_map<HMONITOR, std::shared_ptr<WorkArea>>& activeWorkAreas) :
WindowDrag::WindowDrag(HWND window, const std::unordered_map<HMONITOR, std::unique_ptr<WorkArea>>& activeWorkAreas) :
m_window(window),
m_activeWorkAreas(activeWorkAreas),
m_currentWorkArea(nullptr),
m_snappingMode(false)
{
m_windowProperties.hasNoVisibleOwner = !FancyZonesWindowUtils::HasVisibleOwner(m_window);
@@ -28,7 +29,7 @@ WindowDrag::~WindowDrag()
ResetWindowTransparency();
}
std::unique_ptr<WindowDrag> WindowDrag::Create(HWND window, const std::unordered_map<HMONITOR, std::shared_ptr<WorkArea>>& activeWorkAreas)
std::unique_ptr<WindowDrag> WindowDrag::Create(HWND window, const std::unordered_map<HMONITOR, std::unique_ptr<WorkArea>>& activeWorkAreas)
{
if (!FancyZonesWindowProcessing::IsProcessable(window) ||
!FancyZonesWindowUtils::IsCandidateForZoning(window) ||
@@ -57,7 +58,7 @@ bool WindowDrag::MoveSizeStart(HMONITOR monitor, bool isSnapping)
if (isSnapping)
{
m_currentWorkArea = iter->second;
m_currentWorkArea = iter->second.get();
}
SwitchSnappingMode(isSnapping);
@@ -72,7 +73,7 @@ void WindowDrag::MoveSizeUpdate(HMONITOR monitor, POINT const& ptScreen, bool is
{
// The drag has moved to a different monitor.
// Change work area
if (iter->second != m_currentWorkArea)
if (iter->second.get() != m_currentWorkArea)
{
m_highlightedZones.Reset();
@@ -88,7 +89,7 @@ void WindowDrag::MoveSizeUpdate(HMONITOR monitor, POINT const& ptScreen, bool is
}
}
m_currentWorkArea = iter->second;
m_currentWorkArea = iter->second.get();
}
if (m_currentWorkArea)
@@ -169,18 +170,6 @@ void WindowDrag::SwitchSnappingMode(bool isSnapping)
if (m_currentWorkArea)
{
m_currentWorkArea->UnsnapWindow(m_window);
FancyZonesWindowProperties::RemoveZoneIndexProperty(m_window);
const auto& layout = m_currentWorkArea->GetLayout();
if (layout)
{
auto guidStr = FancyZonesUtils::GuidToString(layout->Id());
if (guidStr.has_value())
{
AppZoneHistory::instance().RemoveAppLastZone(m_window, m_currentWorkArea->UniqueId(), guidStr.value());
}
}
Trace::WorkArea::MoveOrResizeStarted(m_currentWorkArea->GetLayout().get(), m_currentWorkArea->GetLayoutWindows().get());
}
}