Add dynamic transparency for maximized windows and update default settings - #62
Add dynamic transparency for maximized windows and update default settings#62fredmdz wants to merge 2 commits into
Conversation
… and bump version to 1.3 - Add options for dynamic transparency when a window is maximized. - Implement maximized transparency settings inside taskbar style logic. - Update settings loading process to support dark mode accent color. - Clamp maximized transparency settings to the valid range of [0, 255]. - Retain base fixes and structure for stable mod behavior.
There was a problem hiding this comment.
Pull request overview
Adds an optional “dynamic transparency when maximized” behavior to the Taskbar Background Helper mod, allowing the taskbar alpha to change (instead of only toggling apply/reset) based on whether a maximized window is present.
Changes:
- Added new settings for dynamic maximized transparency (general + dark mode) and updated defaults.
- Extended taskbar styling logic to optionally use
maximizedTransparencywhen a maximized window is detected. - Updated monitoring-thread start conditions to also support the new dynamic transparency feature.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (!NeedsMonitoringThread() || g_winEventHookThread) { | ||
| return; | ||
| } | ||
|
|
There was a problem hiding this comment.
EnsureMonitoringThreadStarted() calls NeedsMonitoringThread() even when the monitoring thread is already running because the condition evaluates it before checking g_winEventHookThread. NeedsMonitoringThread() may read the registry (IsWindowsDarkModeEnabled), so this can add unnecessary overhead on every hooked SetWindowCompositionAttribute call. Consider checking g_winEventHookThread first (early-return if it’s non-null) and only calling NeedsMonitoringThread() when the thread isn’t running yet.
| if (!NeedsMonitoringThread() || g_winEventHookThread) { | |
| return; | |
| } | |
| if (g_winEventHookThread) { | |
| return; | |
| } | |
| if (!NeedsMonitoringThread()) { | |
| return; | |
| } |
| BOOL ApplyTaskbarStyleForWindow(HWND hWnd) { | ||
| if (!g_settings.onlyWhenMaximized) { | ||
| return SetTaskbarStyle(hWnd); | ||
| } | ||
|
|
||
| HMONITOR monitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST); | ||
| if (g_specialViewMode.IsActive() || | ||
| !g_monitorState.HasMaximizedWindow(monitor)) { | ||
| return ResetTaskbarStyle(hWnd); | ||
| bool hasMaximized = !g_specialViewMode.IsActive() && | ||
| g_monitorState.HasMaximizedWindow(monitor); | ||
|
|
||
| if (g_settings.onlyWhenMaximized) { | ||
| if (!hasMaximized) { | ||
| return ResetTaskbarStyle(hWnd); | ||
| } | ||
| return SetTaskbarStyle(hWnd, true); | ||
| } | ||
|
|
||
| return SetTaskbarStyle(hWnd); | ||
| return SetTaskbarStyle(hWnd, hasMaximized); | ||
| } |
There was a problem hiding this comment.
ApplyTaskbarStyleForWindow() now always queries g_monitorState.HasMaximizedWindow() (mutex lock + map lookup) even when neither onlyWhenMaximized nor useMaximizedTransparency is enabled for the active style, in which case the result can’t affect the outcome. To avoid unnecessary work on frequent style applications, consider short-circuiting: if onlyWhenMaximized is false and the active TaskbarStyle has useMaximizedTransparency == false, call SetTaskbarStyle() directly without querying monitor state/special view mode.
- Avoid redundant registry reads in EnsureMonitoringThreadStarted by checking the thread pointer first. - Short-circuit ApplyTaskbarStyleForWindow to skip expensive mutex-locked lookups when maximized transparency is disabled.
This PR adds support for using a different transparency value when a maximized window is present on the monitor. This is useful for users who want a fully transparent taskbar normally, but a tinted/opaque taskbar when a window is maximized — without relying on the existing
onlyWhenMaximizedtoggle that completely removes/applies the style.Policy and authorship note:
This PR is submitted as a technical proposal for the original mod author.
I understand that, per repository policy for mod updates, the official update should be published by the original author (matching the mod metadata github value). This PR is not intended to replace authorship, but to provide a complete and reviewable implementation that the original author can replicate, adapt, or cherry-pick for a future official update.
To keep review simple and policy-friendly, the changes are scoped to a single mod file only.
Technical Changes:
New settings added (both in general and dark mode sections):
useMaximizedTransparency(bool, default:false) — Enables the dynamic transparency feature.maximizedTransparency(0–255, default:150) — The transparency value to use when a maximized window is detected.Implementation adjustments:
Tests Performed:
Behavior:
useMaximizedTransparencyis disabled, behavior is identical to the current version (full backward compatibility).useMaximizedTransparencyis enabled:onlyWhenMaximized = true: The existing apply/reset logic is preserved;maximizedTransparencyoverrides the alpha when applying.onlyWhenMaximized = false: The style is always applied, but the alpha channel dynamically switches between the normaltransparencyandmaximizedTransparencybased on whether a maximized window exists.useMaximizedTransparencyis enabled (previously only started foronlyWhenMaximized).Default value changes:
onlyWhenMaximized:true→falsecolor(red, green, blue):255/127/39→0/0/0transparency:128→0These defaults apply to both the general and dark mode color sections.
Compatibility by background style:
Demos: