fix(wallpaper): switching wallpapers is too slow.#1003
Conversation
Add synchronization for wallpaper loading and surface commit completion. Refine the wallpaper disposal logic to prevent memory and video memory leaks, and avoid incorrect video decoding resource usage that causes video stuttering. Added `WallpaperSwitcherItem` to encapsulate the desktop wallpaper switching animation. Log: fix switching wallpapers is too slow PMS: BUG-363035 Influence: Wallpaper display and updates
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: zccrs, zzxyb 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 |
There was a problem hiding this comment.
Pull request overview
EN: This PR targets slow wallpaper switching by synchronizing “wallpaper file loaded” with compositor-side surface readiness, refining lifecycle/disposal to reduce memory/VRAM leaks and stutter, and introducing a dedicated QML item to drive wallpaper cross-fade transitions.
ZH: 本 PR 通过引入“壁纸文件加载完成”与合成器侧 surface 就绪的同步机制、优化资源释放以减少内存/显存泄漏与卡顿,并新增专用的壁纸切换动画组件来改善切换速度与稳定性。
Changes:
- EN: Add a “loaded/ready” handshake between wallpaper-factory client and compositor wallpaper surface; ZH: 增加 loaded/ready 同步握手以保证加载与提交完成后再进入切换流程。
- EN: Rework desktop wallpaper switching from two QML
Wallpaperitems to a C++WallpaperSwitcherItem; ZH: 用 C++WallpaperSwitcherItem封装桌面壁纸切换动画逻辑,替代旧的双WallpaperQML 方案。 - EN: Improve runtime behavior (async image loading, logging integration); ZH: 增强运行时表现(图片异步加载、日志接入)。
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
wallpaper-factory/wallpaperwindow.h |
Add loaded state API/signals for load synchronization. |
wallpaper-factory/wallpaperwindow.cpp |
Track per-window loaded flag and manage shell integration lifetime. |
wallpaper-factory/treelandwallpapernotifierclient.cpp |
Mark wallpaper “loaded” on image/video readiness; track source via dynamic property. |
wallpaper-factory/qwaylandwallpapersurface.cpp |
Send protocol ready() only after file loaded (and protocol version supports it). |
wallpaper-factory/qwaylandwallpapersurface_p.h |
Add slot for handling file-loaded notification. |
wallpaper-factory/qwaylandwallpapershellintegration.cpp |
Simplify teardown via destroy(). |
wallpaper-factory/main.cpp |
Register DTK journal logging appender. |
wallpaper-factory/Image.qml |
Enable asynchronous image loading. |
wallpaper-factory/CMakeLists.txt |
Add Dtk6::Core dependency for logging. |
src/wallpaper/wallpaperswitcheritem.h |
Introduce WallpaperSwitcherItem QML element API. |
src/wallpaper/wallpaperswitcheritem.cpp |
Implement slot-based wallpaper cross-fade and readiness-gated fade-in. |
src/wallpaper/wallpaperitem.h |
Remove switching-related properties/signals; add updateSurface() API and protected ctor. |
src/wallpaper/wallpaperitem.cpp |
Adjust update scheduling to be readiness-driven; add surface-added handling. |
src/seat/helper.h |
Grant WallpaperSwitcherItem friend access (for manager interactions). |
src/modules/wallpaper/wallpapershellinterfacev1.h |
Add ready signal + wallpaperReady(); adjust destroy notification signal shape. |
src/modules/wallpaper/wallpapershellinterfacev1.cpp |
Track wallpaper readiness and emit ready after initial mapping/commit. |
src/core/qml/PrimaryOutput.qml |
Switch desktop wallpaper QML to use WallpaperSwitcher. |
src/CMakeLists.txt |
Build and export the new wallpaper switcher QML type. |
| WallpaperSwitcherItem::WallpaperSwitcherItem(QQuickItem *parent) | ||
| : QQuickItem(parent) | ||
| { | ||
| m_currentSlot = new WallpaperSlot(parentItem()); | ||
|
|
||
| connect(Helper::instance()->m_wallpaperManager, | ||
| &WallpaperManager::updateWallpaper, | ||
| this, | ||
| &WallpaperSwitcherItem::handleWallpaperUpdate); | ||
| connect(Helper::instance()->shellHandler()->wallpaperShell(), | ||
| &TreelandWallpaperShellInterfaceV1::wallpaperSurfaceAdded, | ||
| this, | ||
| &WallpaperSwitcherItem::handleWallpaperUpdate); | ||
| connect(Helper::instance()->workspace(), | ||
| &Workspace::workspaceAdded, | ||
| this, | ||
| &WallpaperSwitcherItem::handleWorkspaceAdded); | ||
| } |
| void WallpaperSwitcherItem::switchToNewSlot(const QString &targetSource) | ||
| { | ||
| auto *newSlot = new WallpaperSlot(parentItem()); | ||
| newSlot->setOpacity(0); | ||
| newSlot->setOutput(m_output); | ||
| newSlot->setWorkspace(m_workspace); | ||
|
|
| connect(fadeOut, &QPropertyAnimation::finished, this, &WallpaperSwitcherItem::onAnimationFinished); | ||
| QObject::connect(fadeOut, &QPropertyAnimation::finished, fadeOut, &QObject::deleteLater); | ||
| fadeOut->start(QAbstractAnimation::DeleteWhenStopped); |
| QObject::connect(anim, &QPropertyAnimation::finished, anim, &QObject::deleteLater); | ||
| anim->start(QAbstractAnimation::DeleteWhenStopped); |
| connect(image, | ||
| &QQuickAnimatedImage::statusChanged, | ||
| window, [window](QQuickImageBase::Status status){ | ||
| if (status == QQuickImageBase::Ready) | ||
| Q_EMIT window->setLoaded(true); | ||
| }); |
| connect(video, | ||
| &MpvVideoItem::fileLoaded, | ||
| window,[window]() { | ||
| Q_EMIT window->setLoaded(true); | ||
| }, Qt::SingleShotConnection); |
| void TreelandWallpaperSurfaceInterfaceV1Private::ready(Resource *resource) | ||
| { | ||
| if (wallpaperReady) { | ||
| return; | ||
| } | ||
|
|
||
| if (q->wSurface()->mapped()) { | ||
| wallpaperReady = true; | ||
| Q_EMIT q->ready(); | ||
| } else { | ||
| QObject::connect(q->wSurface(), &WSurface::commit, q, [this](quint32 committedState) { | ||
| wallpaperReady = true; | ||
| Q_EMIT q->ready(); | ||
| }, Qt::SingleShotConnection); | ||
| } | ||
| } |
Add synchronization for wallpaper loading and surface commit completion.
Refine the wallpaper disposal logic to prevent memory and video memory leaks, and avoid incorrect video
decoding resource usage that causes video stuttering. Added
WallpaperSwitcherItemto encapsulate the desktop wallpaper switching animation.Log: fix switching wallpapers is too slow
PMS: BUG-363035
Influence: Wallpaper display and updates