[FancyZones] Fix canvas zones drawing (#27882)

This commit is contained in:
Seraphima Zykova 2023-08-09 11:34:25 +03:00 committed by GitHub
parent f0c30132a2
commit 3fe2a2459d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 15 deletions

View File

@ -627,6 +627,7 @@ LRESULT FancyZones::WndProc(HWND window, UINT message, WPARAM wparam, LPARAM lpa
if (auto monitor = MonitorFromPoint(ptScreen, MONITOR_DEFAULTTONULL))
{
MoveSizeStart(hwnd, monitor);
MoveSizeUpdate(monitor, ptScreen);
}
}
else if (message == WM_PRIV_MOVESIZEEND)

View File

@ -57,19 +57,21 @@ bool WindowDrag::MoveSizeStart(HMONITOR monitor, bool isSnapping)
}
m_currentWorkArea = iter->second.get();
SwitchSnappingMode(isSnapping);
if (m_currentWorkArea)
if (!m_currentWorkArea)
{
m_currentWorkArea->UnsnapWindow(m_window);
return false;
}
m_currentWorkArea->UnsnapWindow(m_window);
SwitchSnappingMode(isSnapping);
return true;
}
void WindowDrag::MoveSizeUpdate(HMONITOR monitor, POINT const& ptScreen, bool isSnapping, bool isSelectManyZonesState)
{
SwitchSnappingMode(isSnapping);
auto iter = m_activeWorkAreas.find(monitor);
if (isSnapping && iter != m_activeWorkAreas.end())
{
@ -105,8 +107,6 @@ void WindowDrag::MoveSizeUpdate(HMONITOR monitor, POINT const& ptScreen, bool is
}
}
}
SwitchSnappingMode(isSnapping);
}
void WindowDrag::MoveSizeEnd()
@ -149,10 +149,19 @@ void WindowDrag::MoveSizeEnd()
void WindowDrag::SwitchSnappingMode(bool isSnapping)
{
if (!m_currentWorkArea)
{
return;
}
if (!m_snappingMode && isSnapping) // turn on
{
SetWindowTransparency();
// init active layout
m_currentWorkArea->ShowZonesOverlay(m_highlightedZones.Zones(), m_window);
// init layouts on other monitors
if (FancyZonesSettings::settings().showZonesOnAllMonitors)
{
for (const auto& [_, workArea] : m_activeWorkAreas)
@ -164,10 +173,7 @@ void WindowDrag::SwitchSnappingMode(bool isSnapping)
}
}
if (m_currentWorkArea)
{
Trace::WorkArea::MoveOrResizeStarted(m_currentWorkArea->GetLayout().get(), m_currentWorkArea->GetLayoutWindows().get());
}
Trace::WorkArea::MoveOrResizeStarted(m_currentWorkArea->GetLayout().get(), m_currentWorkArea->GetLayoutWindows().get());
}
else if (m_snappingMode && !isSnapping) // turn off
{
@ -183,10 +189,7 @@ void WindowDrag::SwitchSnappingMode(bool isSnapping)
}
}
if (m_currentWorkArea)
{
Trace::WorkArea::MoveOrResizeEnd(m_currentWorkArea->GetLayout().get(), m_currentWorkArea->GetLayoutWindows().get());
}
Trace::WorkArea::MoveOrResizeEnd(m_currentWorkArea->GetLayout().get(), m_currentWorkArea->GetLayoutWindows().get());
}
m_snappingMode = isSnapping;