fix(loader): set WA_TranslucentBackground before winId() to avoid opaque plugin backgrounds on Qt >= 6.11#478
Conversation
winId() forces creation of the underlying native window. Qt::WA_Translucent- Background selects the surface format (an ARGB visual) and therefore has to be set before that window exists; setting it afterwards leaves the already-created surface opaque. The result on Qt 6.11 is that every tray plugin paints its background rectangle at all times instead of only on hover, tinted by whatever shows through from the desktop behind the dock. Latent on Qt 6.8, which is what deepin 25 ships -- as already anticipated by the comment added in linuxdeepin#383. Verified by A/B on Arch Linux with Qt 6.11.1, X11, swapping only this binary.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: svan71 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @svan71. Thanks for your PR. I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Summary
On Qt 6.11, every dock tray plugin renders its background rectangle permanently — the hover highlight is drawn at all times instead of only on mouse-over. The rectangle picks up colour from whatever shows through from the desktop behind the dock. Expected behaviour (and the behaviour on Qt 6.8) is a fully composited, invisible background until the item is hovered.
The cause is attribute-vs-window-creation ordering in
PluginItem::init().Root cause
src/loader/pluginitem.cpp:winId()forces creation of the underlying native window.Qt::WA_TranslucentBackgroundmust be set before that window is created, because it selects the surface/visual format (an ARGB visual). Setting it afterwards leaves the already-created surface opaque.This is latent on Qt 6.8 — the version Deepin 25 currently ships (
libQt6Core.so.6.8.0) — and becomes visible on Qt 6.11, where the window's surface format is finalized more strictly at creation time.This is consistent with the prediction already recorded in this file's own comment, added in #383:
Fix
void PluginItem::init() { + setAttribute(Qt::WA_TranslucentBackground); winId(); - setAttribute(Qt::WA_TranslucentBackground);Reproduction
master@b3d4784(2.0.36). Also reproduced on 2.0.35.PluginItem— observed on the power button, the circled-arrow applet, the sound applet, and the clock. The collapse chevron and the sliders applet are unaffected, presumably being rendered by the dock's own QML rather than by the loader.Testing
Verified by A/B on one machine against
master@b3d4784(2.0.36), Qt 6.11.1, CMake 4.3.4, X11 — same session, same dock, wallpaper and theme unchanged, swapping only/usr/lib/trayplugin-loaderand restartingdde-shell-plugin@org.deepin.ds.desktop.service dde-shell@DDE.service:sha256:fc782029…sha256:28c88c7e…Pristine 2.0.36 cannot be configured on Qt 6.11 at all, so the "before" binary is 2.0.36 + #477. That change touches only
find_package, so it is a faithful stand-in for stock runtime behaviour. The two binaries differ, confirming the reorder is not elided by the optimizer.The hover highlight still works with the patch applied: with the pointer resting on an XEMBED tray applet, only that one icon draws its rectangle and its tooltip appears, while every other tray item stays clean. This rules out the trivial false pass where the highlight is simply never drawn at all.
Legacy tray plugins exercised:
onboard,shutdown,sound, and an XEMBEDnm-applet.Confirmed in both directions that the running loader processes had the expected binary mapped, by hashing
/proc/<pid>/exerather than trusting the on-disk file. (The loader rewrites its own argv totray plugin: <name>, sopgrep -f trayplugin-loaderfinds nothing — match on/proc/*/exeinstead.)Caveat
This patch deliberately leaves the
QWidget::paintEvent(event)call added by #383 intact — only the two-line reorder is changed. I have not been able to test on the openSUSE configuration that #383 targeted, so I cannot positively confirm no regression there. Leaving that call in place should be the safer direction, but a reviewer familiar with #383 may want to check.References
application-trayon Qt 6.11)paintEventtransparent fill and the comment predicting this failure on newer Qt