[macOS] Fix pop-out applet panel white background via WA_StyledBackground#2190
Conversation
…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]>
There was a problem hiding this comment.
Looks good. Clean, minimal fix that follows the existing pattern in ContainerTitleBar.cpp:36.
A few observations:
-
Scope is tight — 4 additions across 3 files, all directly related to the stated problem. No extraneous changes.
-
MainWindow.cpp addition is correct —
floatAppletPanel()onmainwas missing bothWA_StyledBackgroundandsetStyleSheet(darkThemeStylesheet()). PR #2096 only coveredPanFloatingWindowandFloatingContainerWindowconstructors but missed this call site. This PR fills that gap and adds the attribute to the two constructors that were already callingsetStyleSheetwithout it. -
Attribute ordering is correct —
WA_StyledBackgroundis set beforesetStyleSheet()in all three sites, which is what Qt needs to pick up the background-color rule. -
No convention concerns — uses
AppSettings(viadarkThemeStylesheet()), no rawQSettings, 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!
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 addedsetStyleSheet(darkThemeStylesheet())to both floating window constructors, and the stylesheet is compiled into the official binary (verified viastrings). The issue is that on macOS,QWidgetsubclasses used as top-level windows requiresetAttribute(Qt::WA_StyledBackground, true)forbackground-colorin 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.dylibbundled in the DMG handles stylesheet propagation more strictly than the standard Homebrew Qt 6.11.0 build:libqcocoa.dylibsizeBoth 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 beforesetStyleSheet()in all three floating window sites:src/gui/containers/FloatingContainerWindow.cppsrc/gui/PanFloatingWindow.cppsrc/gui/MainWindow.cpp(floatAppletPanel()— not covered by #2096)Testing
ContainerTitleBar.cpp:36Notes
A separate issue has been filed regarding the CI
libqcocoa.dylibsize discrepancy — theWA_StyledBackgroundfix is the correct defensive fix regardless, but the CI pipeline should also be investigated to prevent similar regressions.