Skip to content

Commit

Permalink
Taskbar Background Helper v1.0.3
Browse files Browse the repository at this point in the history
* Fixed the mod always thinking there's a maximized window in some cases.
  • Loading branch information
m417z committed Nov 3, 2024
1 parent 25345e4 commit 40a2815
Showing 1 changed file with 15 additions and 7 deletions.
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

0 comments on commit 40a2815

Please sign in to comment.