diff --git a/src/modules/fancyzones/FancyZonesLib/FancyZones.cpp b/src/modules/fancyzones/FancyZonesLib/FancyZones.cpp index e7f45d34be..caa77429de 100644 --- a/src/modules/fancyzones/FancyZonesLib/FancyZones.cpp +++ b/src/modules/fancyzones/FancyZonesLib/FancyZones.cpp @@ -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) diff --git a/src/modules/fancyzones/FancyZonesLib/WindowDrag.cpp b/src/modules/fancyzones/FancyZonesLib/WindowDrag.cpp index 916d49efd5..dd3320a1e0 100644 --- a/src/modules/fancyzones/FancyZonesLib/WindowDrag.cpp +++ b/src/modules/fancyzones/FancyZonesLib/WindowDrag.cpp @@ -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;