Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taskbar Background Helper v1.0.3 #1195

Merged
merged 1 commit into from
Nov 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions mods/taskbar-background-helper.wh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// @id taskbar-background-helper
// @name Taskbar Background Helper
// @description Sets the taskbar background for the transparent parts, always or only when there's a maximized window, designed to be used with Windows 11 Taskbar Styler
// @version 1.0.2
// @version 1.0.3
// @author m417z
// @github https://github.com/m417z
// @twitter https://twitter.com/m417z
Expand Down Expand Up @@ -216,7 +216,7 @@ bool IsWindowsDarkModeEnabled() {
}

// https://devblogs.microsoft.com/oldnewthing/20200302-00/?p=103507
BOOL IsWindowCloaked(HWND hwnd) {
bool IsWindowCloaked(HWND hwnd) {
BOOL isCloaked = FALSE;
return SUCCEEDED(DwmGetWindowAttribute(hwnd, DWMWA_CLOAKED, &isCloaked,
sizeof(isCloaked))) &&
Expand Down Expand Up @@ -319,13 +319,15 @@ bool DoesMonitorHaveMaximizedWindow(HMONITOR monitor) {
};
GetMonitorInfo(monitor, &monitorInfo);

auto enumWindowsProc = [monitor, &monitorInfo,
&hasMaximized](HWND hWnd) -> BOOL {
HWND hShellWindow = GetShellWindow();

auto enumWindowsProc = [&](HWND hWnd) -> BOOL {
if (MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST) != monitor) {
return TRUE;
}

if (!IsWindowVisible(hWnd) || IsWindowCloaked(hWnd) || IsIconic(hWnd)) {
if (hWnd == hShellWindow || GetProp(hWnd, L"DesktopWindow") ||
!IsWindowVisible(hWnd) || IsWindowCloaked(hWnd) || IsIconic(hWnd)) {
return TRUE;
}

Expand Down Expand Up @@ -369,11 +371,17 @@ void CALLBACK WinEventProc(HWINEVENTHOOK hWinEventHook,
LONG idChild,
DWORD dwEventThread,
DWORD dwmsEventTime) {
if (idObject != OBJID_WINDOW) {
if (idObject != OBJID_WINDOW ||
(GetWindowLong(hWnd, GWL_STYLE) & WS_CHILD)) {
return;
}

Wh_Log(L">");
HWND hParentWnd = GetAncestor(hWnd, GA_PARENT);
if (hParentWnd && hParentWnd != GetDesktopWindow()) {
return;
}

Wh_Log(L"> %08X", (DWORD)(ULONG_PTR)hWnd);

HMONITOR monitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
g_pendingMonitors.insert(monitor);
Expand Down