mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
[FancyZones] Improve code quality (part 5: work area initialization) (#23671)
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user