mirror of
https://github.com/microsoft/PowerToys
synced 2025-08-31 14:35:18 +00:00
Improve FancyZones window filtering (#856)
Improve FancyZones window filtering and filter out dialog windows
This commit is contained in:
committed by
GitHub
parent
3a65d5ce23
commit
fed81c8e22
@@ -24,7 +24,10 @@ private:
|
||||
// List of HWNDs that are not interesting - like desktop, cortana, etc
|
||||
std::vector<HWND> invalid_hwnds = { GetDesktopWindow(), GetShellWindow() };
|
||||
// List of invalid window basic styles
|
||||
std::vector<LONG> invalid_basic_styles = { WS_CHILD, WS_DISABLED };
|
||||
std::vector<LONG> invalid_basic_styles = { WS_CHILD, WS_DISABLED, DS_ABSALIGN, DS_SYSMODAL, DS_LOCALEDIT,
|
||||
DS_SETFONT, DS_MODALFRAME, DS_NOIDLEMSG, DS_SETFOREGROUND, DS_3DLOOK,
|
||||
DS_FIXEDSYS, DS_NOFAILCREATE, DS_CONTROL, DS_CENTER, DS_CENTERMOUSE,
|
||||
DS_CONTEXTHELP, DS_SHELLFONT };
|
||||
// List of invalid window extended styles
|
||||
std::vector<LONG> invalid_ext_styles = { WS_EX_TOOLWINDOW, WS_EX_NOACTIVATE };
|
||||
// List of invalid window classes - things like start menu, etc.
|
||||
|
@@ -199,11 +199,25 @@ public:
|
||||
private:
|
||||
bool IsInterestingWindow(HWND window)
|
||||
{
|
||||
auto style = GetWindowLongPtr(window, GWL_STYLE);
|
||||
auto exStyle = GetWindowLongPtr(window, GWL_EXSTYLE);
|
||||
// Ignore:
|
||||
if (GetAncestor(window, GA_ROOT) != window || // windows that are not top-level
|
||||
GetWindow(window, GW_OWNER) != nullptr || // windows that have an owner - like Save As dialogs
|
||||
(style & WS_CHILD) != 0 || // windows that are child elements of other windows - like buttons
|
||||
(style & WS_DISABLED) != 0 || // windows that are disabled
|
||||
(exStyle & WS_EX_TOOLWINDOW) != 0 || // toolbar windows
|
||||
!IsWindowVisible(window)) // invisible windows
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// Filter some windows like the Start menu or Cortana
|
||||
auto windowAndPath = get_filtered_base_window_and_path(window);
|
||||
if (windowAndPath.hwnd == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// Filter out user specified apps
|
||||
CharUpperBuffW(windowAndPath.process_path.data(), (DWORD)windowAndPath.process_path.length());
|
||||
if (m_settings)
|
||||
{
|
||||
@@ -215,9 +229,7 @@ private:
|
||||
}
|
||||
}
|
||||
}
|
||||
// Don't zone child windows and tool window
|
||||
return (GetWindowLongPtr(window, GWL_STYLE) & WS_CHILD) == 0 &&
|
||||
(GetWindowLongPtr(window, GWL_EXSTYLE) & WS_EX_TOOLWINDOW) == 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Disable(bool const traceEvent)
|
||||
|
Reference in New Issue
Block a user