From da384d3d6510a7a0aecfe144e4aa99bcf14e8ef2 Mon Sep 17 00:00:00 2001 From: Andrey Nekrasov Date: Tue, 8 Dec 2020 15:15:57 +0300 Subject: [PATCH] FZ: fix incorrect snapping zoning behavior caused by calling MessageBox from LLKBHook cb (#8476) --- src/modules/fancyzones/lib/FancyZones.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/modules/fancyzones/lib/FancyZones.cpp b/src/modules/fancyzones/lib/FancyZones.cpp index 8b7203a069..98703af5a8 100644 --- a/src/modules/fancyzones/lib/FancyZones.cpp +++ b/src/modules/fancyzones/lib/FancyZones.cpp @@ -634,7 +634,7 @@ void FancyZones::ToggleEditor() noexcept const bool spanZonesAcrossMonitors = m_settings->GetSettings()->spanZonesAcrossMonitors; params += std::to_wstring(spanZonesAcrossMonitors) + divider; /* Span zones */ - + std::vector> allMonitors; allMonitors = FancyZonesUtils::GetAllMonitorInfo<&MONITORINFOEX::rcWork>(); @@ -691,10 +691,16 @@ void FancyZones::ToggleEditor() noexcept if (showDpiWarning) { - MessageBoxW(NULL, - GET_RESOURCE_STRING(IDS_SPAN_ACROSS_ZONES_WARNING).c_str(), - GET_RESOURCE_STRING(IDS_POWERTOYS_FANCYZONES).c_str(), - MB_OK | MB_ICONWARNING); + // We must show the message box in a separate thread, since this code is called from a low-level + // keyboard hook callback, and launching messageboxes from it has unexpected side effects, + // like triggering EVENT_SYSTEM_MOVESIZEEND prematurely. + // TODO: understand the root cause of this, until then it's commented out. + //std::thread{ [] { + // MessageBoxW(nullptr, + // GET_RESOURCE_STRING(IDS_SPAN_ACROSS_ZONES_WARNING).c_str(), + // GET_RESOURCE_STRING(IDS_POWERTOYS_FANCYZONES).c_str(), + // MB_OK | MB_ICONWARNING); + //} }.detach(); } const auto& fancyZonesData = FancyZonesDataInstance();