FZ: fix incorrect snapping zoning behavior caused by calling MessageBox from LLKBHook cb (#8473)

* Revert "add logging to hide/show window and shift press (#8392)"

This reverts commit df3d007a1b.

* FZ: fix incorrect snapping zoning behavior caused by calling MessageBox from LLKBHook cb
This commit is contained in:
Andrey Nekrasov 2020-12-08 15:16:06 +03:00 committed by GitHub
parent 292939c4a1
commit 9d0d5db948
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 20 deletions

View file

@ -2,7 +2,6 @@
#include <common/common.h> #include <common/common.h>
#include <common/dpi_aware.h> #include <common/dpi_aware.h>
#include <common/logger/logger.h>
#include <common/on_thread_executor.h> #include <common/on_thread_executor.h>
#include <common/window_helpers.h> #include <common/window_helpers.h>
@ -535,9 +534,6 @@ FancyZones::OnKeyDown(PKBDLLHOOKSTRUCT info) noexcept
bool const win = GetAsyncKeyState(VK_LWIN) & 0x8000 || GetAsyncKeyState(VK_RWIN) & 0x8000; bool const win = GetAsyncKeyState(VK_LWIN) & 0x8000 || GetAsyncKeyState(VK_RWIN) & 0x8000;
bool const alt = GetAsyncKeyState(VK_MENU) & 0x8000; bool const alt = GetAsyncKeyState(VK_MENU) & 0x8000;
bool const ctrl = GetAsyncKeyState(VK_CONTROL) & 0x8000; bool const ctrl = GetAsyncKeyState(VK_CONTROL) & 0x8000;
Logger::trace("OnKeyDown: shift {}", shift);
if ((win && !shift && !ctrl) || (win && ctrl && alt)) if ((win && !shift && !ctrl) || (win && ctrl && alt))
{ {
// Temporarily disable Win+Ctrl+Number functionality // Temporarily disable Win+Ctrl+Number functionality
@ -574,10 +570,8 @@ FancyZones::OnKeyDown(PKBDLLHOOKSTRUCT info) noexcept
if (m_windowMoveHandler.IsDragEnabled() && shift) if (m_windowMoveHandler.IsDragEnabled() && shift)
{ {
Logger::trace("OnKeyDown: drag enabled -> return true");
return true; return true;
} }
Logger::trace("OnKeyDown: return false");
return false; return false;
} }
@ -697,10 +691,16 @@ void FancyZones::ToggleEditor() noexcept
if (showDpiWarning) if (showDpiWarning)
{ {
MessageBoxW(NULL, // We must show the message box in a separate thread, since this code is called from a low-level
GET_RESOURCE_STRING(IDS_SPAN_ACROSS_ZONES_WARNING).c_str(), // keyboard hook callback, and launching messageboxes from it has unexpected side effects,
GET_RESOURCE_STRING(IDS_POWERTOYS_FANCYZONES).c_str(), // like triggering EVENT_SYSTEM_MOVESIZEEND prematurely.
MB_OK | MB_ICONWARNING); // 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(); const auto& fancyZonesData = FancyZonesDataInstance();
@ -1294,7 +1294,6 @@ bool FancyZones::IsSplashScreen(HWND window)
void FancyZones::OnEditorExitEvent() noexcept void FancyZones::OnEditorExitEvent() noexcept
{ {
Logger::trace("OnEditorExitEvent");
// Collect information about changes in zone layout after editor exited. // Collect information about changes in zone layout after editor exited.
FancyZonesDataInstance().ParseDataFromTmpFiles(); FancyZonesDataInstance().ParseDataFromTmpFiles();

View file

@ -1,7 +1,6 @@
#include "pch.h" #include "pch.h"
#include <common/common.h> #include <common/common.h>
#include <common/logger/logger.h>
#include <common/on_thread_executor.h> #include <common/on_thread_executor.h>
#include "FancyZonesData.h" #include "FancyZonesData.h"
@ -319,11 +318,9 @@ ZoneWindow::SaveWindowProcessToZoneIndex(HWND window) noexcept
IFACEMETHODIMP_(void) IFACEMETHODIMP_(void)
ZoneWindow::ShowZoneWindow() noexcept ZoneWindow::ShowZoneWindow() noexcept
{ {
Logger::trace("ShowZoneWindow: Enter");
auto window = m_window.get(); auto window = m_window.get();
if (!window) if (!window)
{ {
Logger::trace("ShowZoneWindow: no window");
return; return;
} }
@ -345,16 +342,11 @@ ZoneWindow::HideZoneWindow() noexcept
{ {
if (m_window) if (m_window)
{ {
Logger::trace("HideZoneWindow: hiding");
m_zoneWindowDrawing->Hide(); m_zoneWindowDrawing->Hide();
m_keyLast = 0; m_keyLast = 0;
m_windowMoveSize = nullptr; m_windowMoveSize = nullptr;
m_highlightZone = {}; m_highlightZone = {};
} }
else
{
Logger::trace("HideZoneWindow: no window");
}
} }
IFACEMETHODIMP_(void) IFACEMETHODIMP_(void)