Skip to content

[macOS] Fix pop-out applet panel white background via WA_StyledBackground#2190

Merged
ten9876 merged 1 commit intoten9876:mainfrom
M7HNF-Ian:fix/macos-floating-window-dark-theme
May 1, 2026
Merged

[macOS] Fix pop-out applet panel white background via WA_StyledBackground#2190
ten9876 merged 1 commit intoten9876:mainfrom
M7HNF-Ian:fix/macos-floating-window-dark-theme

Conversation

@M7HNF-Ian
Copy link
Copy Markdown
Contributor

Problem

On macOS, all applets in the floating/pop-out applet panel render with a white background when using official DMG builds. This has been reproducible across multiple consecutive releases. When docked in the main panel the dark theme is correct — the issue only affects floating windows.

Root cause

PR #2096 (565bb06) correctly added setStyleSheet(darkThemeStylesheet()) to both floating window constructors, and the stylesheet is compiled into the official binary (verified via strings). The issue is that on macOS, QWidget subclasses used as top-level windows require setAttribute(Qt::WA_StyledBackground, true) for background-color in a stylesheet to actually paint. Without it, Qt defers to the native macOS window background (white), even when a stylesheet is explicitly set.

This attribute is already correctly set in ContainerTitleBar.cpp:36 — it was simply missing from the floating window classes themselves.

Why it only affects DMG builds

The CI-built libqcocoa.dylib bundled in the DMG handles stylesheet propagation more strictly than the standard Homebrew Qt 6.11.0 build:

libqcocoa.dylib size Source
Official DMG 969 KB CI release build
Homebrew Qt 6.11.0 1.2 MB standard build

Both report Qt 6.11.0 but the CI binary is ~230KB smaller, indicating different compile flags or SDK options. Homebrew's plugin propagates the background without WA_StyledBackground; the CI build does not. A local build from the same tagged source against Homebrew Qt works correctly on the same machine, ruling out any macOS version or hardware dependency.

Fix

Add setAttribute(Qt::WA_StyledBackground, true) immediately before setStyleSheet() in all three floating window sites:

src/gui/containers/FloatingContainerWindow.cpp

+ setAttribute(Qt::WA_StyledBackground, true);
  setStyleSheet(darkThemeStylesheet());

src/gui/PanFloatingWindow.cpp

+ setAttribute(Qt::WA_StyledBackground, true);
  setStyleSheet(darkThemeStylesheet());

src/gui/MainWindow.cpp (floatAppletPanel() — not covered by #2096)

+ m_appletPanelFloatWindow->setAttribute(Qt::WA_StyledBackground, true);
  m_appletPanelFloatWindow->setStyleSheet(darkThemeStylesheet());

Testing

  • Built from source against Homebrew Qt 6.11.0 on Apple Silicon macOS
  • Pop-out applet panel renders with correct dark theme after fix
  • No regression in docked applet panel or main window styling
  • Confirmed fix matches existing pattern in ContainerTitleBar.cpp:36

Notes

A separate issue has been filed regarding the CI libqcocoa.dylib size discrepancy — the WA_StyledBackground fix is the correct defensive fix regardless, but the CI pipeline should also be investigated to prevent similar regressions.

…ound

On macOS, QWidget top-level windows require WA_StyledBackground=true for
stylesheet background-color rules to paint. Without it Qt defers to the
native macOS window background (white), even when setStyleSheet() is called
explicitly.

PR ten9876#2096 added darkThemeStylesheet() to FloatingContainerWindow and
PanFloatingWindow but omitted this attribute. The stylesheet is confirmed
present in the binary (verified via strings) — the attribute was the
missing piece. Also adds the stylesheet and attribute to the inline
QWidget created in MainWindow::floatAppletPanel(), which is a third
floating window not covered by the previous fix.

The issue only manifests with the CI-built libqcocoa.dylib bundled in
official DMG releases (~969KB vs Homebrew's ~1.2MB for the same Qt 6.11.0),
which handles stylesheet inheritance more strictly. Local builds against
Homebrew Qt work without this fix, which is why it was not caught earlier.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Copy link
Copy Markdown
Contributor

@aethersdr-agent aethersdr-agent Bot left a comment

Choose a reason for hiding this comment

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

Looks good. Clean, minimal fix that follows the existing pattern in ContainerTitleBar.cpp:36.

A few observations:

  1. Scope is tight — 4 additions across 3 files, all directly related to the stated problem. No extraneous changes.

  2. MainWindow.cpp addition is correctfloatAppletPanel() on main was missing both WA_StyledBackground and setStyleSheet(darkThemeStylesheet()). PR #2096 only covered PanFloatingWindow and FloatingContainerWindow constructors but missed this call site. This PR fills that gap and adds the attribute to the two constructors that were already calling setStyleSheet without it.

  3. Attribute ordering is correctWA_StyledBackground is set before setStyleSheet() in all three sites, which is what Qt needs to pick up the background-color rule.

  4. No convention concerns — uses AppSettings (via darkThemeStylesheet()), no raw QSettings, no new allocations or ownership changes.

No issues found. Nice debugging work on the CI libqcocoa.dylib discrepancy — the write-up in the PR description is thorough and will be useful context if similar platform-specific styling issues come up.

Thanks @Chaosuk97!

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