From 0e2d93c63066425a198d0f9026f4b9866bdd3966 Mon Sep 17 00:00:00 2001 From: Bartosz Sosnowski Date: Tue, 3 Dec 2019 18:13:46 +0100 Subject: [PATCH] Make FancyZones not zone invisible, child and tool windows Fixes "Move newly created windows to their last known zone" --- src/common/hwnd_data_cache.cpp | 7 ++++--- src/modules/fancyzones/dll/dllmain.cpp | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/common/hwnd_data_cache.cpp b/src/common/hwnd_data_cache.cpp index 53dbc520bd..fffb1f67e0 100644 --- a/src/common/hwnd_data_cache.cpp +++ b/src/common/hwnd_data_cache.cpp @@ -18,9 +18,10 @@ HWND HWNDDataCache::get_window(HWND hwnd) { WindowAndProcPath* HWNDDataCache::get_internal(HWND hwnd) { auto root = GetAncestor(hwnd, GA_ROOT); // Filter the fast and easy cases - if (is_invalid_hwnd(root) || - is_invalid_class(root) || - is_invalid_style(root)) { + if (!IsWindowVisible(root) || + is_invalid_hwnd(root) || + is_invalid_class(root) || + is_invalid_style(root)) { return nullptr; } // Get the HWND process path from the cache diff --git a/src/modules/fancyzones/dll/dllmain.cpp b/src/modules/fancyzones/dll/dllmain.cpp index e651885ea5..6154a6acb7 100644 --- a/src/modules/fancyzones/dll/dllmain.cpp +++ b/src/modules/fancyzones/dll/dllmain.cpp @@ -215,7 +215,9 @@ private: } } } - return true; + // Don't zone child windows and tool window + return (GetWindowLongPtr(window, GWL_STYLE) & WS_CHILD) == 0 && + (GetWindowLongPtr(window, GWL_EXSTYLE) & WS_EX_TOOLWINDOW) == 0; } void Disable(bool const traceEvent)