Skip to content

Add dynamic transparency for maximized windows and update default settings - #62

Open
fredmdz wants to merge 2 commits into
m417z:mainfrom
fredmdz:feature/maximize-transparency-control
Open

Add dynamic transparency for maximized windows and update default settings#62
fredmdz wants to merge 2 commits into
m417z:mainfrom
fredmdz:feature/maximize-transparency-control

Conversation

@fredmdz

@fredmdz fredmdz commented Apr 28, 2026

Copy link
Copy Markdown

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 onlyWhenMaximized toggle 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:

  • Modified setting loading process to correctly scope accent colors and variables in memory.
  • Enforced boundary checks on numeric settings to prevent invalid layout states.
  • Decoupled the monitoring thread initializer from single-setting dependencies.

Tests Performed:

  • General Customization (Light/Dark Mode): Verified that the transparency levels safely adapt based on the current system design schema.
  • Maximized State Logic: Successfully tested real-time taskbar transition cycles while expanding windows to full dimensions.
  • Safe Parameter Guarding: Ensured data constraints prevent standard memory bounds issues across system architecture.
  • Secondary monitor support: Validated visual integrity scaling across active display extensions.

Behavior:

  • If useMaximizedTransparency is disabled, behavior is identical to the current version (full backward compatibility).
  • If useMaximizedTransparency is enabled:
    • When onlyWhenMaximized = true: The existing apply/reset logic is preserved; maximizedTransparency overrides the alpha when applying.
    • When onlyWhenMaximized = false: The style is always applied, but the alpha channel dynamically switches between the normal transparency and maximizedTransparency based on whether a maximized window exists.
  • Special view modes (Peek, Multitasking View / Win+Tab) are respected — they temporarily force the non-maximized transparency.
  • The monitoring thread is now also started when useMaximizedTransparency is enabled (previously only started for onlyWhenMaximized).

Default value changes:

  • onlyWhenMaximized: truefalse
  • color (red, green, blue): 255/127/390/0/0
  • transparency: 1280

These defaults apply to both the general and dark mode color sections.


Compatibility by background style:

  • Blur — 🚫 (Transparency levels are not supported by the base Blur style implementation)
  • Acrylic Blur — ✅
  • Color — ✅

Note on Blur style: The "Blur" background style does not natively support adjustable transparency levels in this mod's base implementation. While the new dynamic logic is applied, the visual transparency level will remain constant for this specific style. However, the feature works perfectly for both Acrylic Blur and Color modes.


Demos:

… 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.
Copilot AI review requested due to automatic review settings April 28, 2026 08:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 maximizedTransparency when 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.

Comment thread mods/taskbar-background-helper.wh.cpp Outdated
Comment on lines 1237 to 1240
if (!NeedsMonitoringThread() || g_winEventHookThread) {
return;
}

Copilot AI Apr 28, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
if (!NeedsMonitoringThread() || g_winEventHookThread) {
return;
}
if (g_winEventHookThread) {
return;
}
if (!NeedsMonitoringThread()) {
return;
}

Copilot uses AI. Check for mistakes.
Comment on lines 673 to 686
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);
}

Copilot AI Apr 28, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
- 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants