mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
Move window filter to separate function, filter more windows.
This commit is contained in:
committed by
Bartosz Sosnowski
parent
a54e4299aa
commit
487c485911
@@ -31,6 +31,34 @@ std::optional<POINT> get_mouse_pos() {
|
||||
return point;
|
||||
}
|
||||
}
|
||||
|
||||
HWND get_filtered_active_window() {
|
||||
static auto desktop = GetDesktopWindow();
|
||||
static auto shell = GetShellWindow();
|
||||
auto active_window = GetForegroundWindow();
|
||||
active_window = GetAncestor(active_window, GA_ROOT);
|
||||
if (active_window == desktop || active_window == shell) {
|
||||
return nullptr;
|
||||
}
|
||||
auto window_styles = GetWindowLong(active_window, GWL_STYLE);
|
||||
if ((window_styles & WS_CHILD) || (window_styles & WS_DISABLED)) {
|
||||
return nullptr;
|
||||
}
|
||||
window_styles = GetWindowLong(active_window, GWL_EXSTYLE);
|
||||
if ((window_styles & WS_EX_TOOLWINDOW) ||(window_styles & WS_EX_NOACTIVATE)) {
|
||||
return nullptr;
|
||||
}
|
||||
char class_name[256] = "";
|
||||
GetClassNameA(active_window, class_name, 256);
|
||||
if (strcmp(class_name, "SysListView32") == 0 ||
|
||||
strcmp(class_name, "WorkerW") == 0 ||
|
||||
strcmp(class_name, "Shell_TrayWnd") == 0 ||
|
||||
strcmp(class_name, "Shell_SecondaryTrayWnd") == 0 ||
|
||||
strcmp(class_name, "Progman") == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
return active_window;
|
||||
}
|
||||
|
||||
int width(const RECT& rect) {
|
||||
return rect.right - rect.left;
|
||||
|
||||
Reference in New Issue
Block a user