Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/modules/wallpaper/wallpapershellinterfacev1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,14 @@ class TreelandWallpaperSurfaceInterfaceV1Private : public QtWaylandServer::treel
wl_resource *resource = nullptr;
WallpaperSurface *surface = nullptr;
QString wallpaperSource;
bool m_readySent = false;

protected:
void destroy_resource(Resource *resource) override;
void destroy(Resource *resource) override;
void source_failed(Resource *resource,
uint32_t error) override;
void ready(Resource *resource) override;
};

TreelandWallpaperSurfaceInterfaceV1Private::TreelandWallpaperSurfaceInterfaceV1Private(TreelandWallpaperSurfaceInterfaceV1 *_q,
Expand Down Expand Up @@ -159,6 +161,14 @@ void TreelandWallpaperSurfaceInterfaceV1Private::source_failed([[maybe_unused]]
Q_EMIT q->failed(error);
}

void TreelandWallpaperSurfaceInterfaceV1Private::ready([[maybe_unused]] Resource *resource)
{
if (!m_readySent) {
m_readySent = true;
Q_EMIT q->ready();
}
}

TreelandWallpaperSurfaceInterfaceV1::~TreelandWallpaperSurfaceInterfaceV1() = default;

WSurface *TreelandWallpaperSurfaceInterfaceV1::wSurface() const
Expand Down
1 change: 1 addition & 0 deletions src/modules/wallpaper/wallpapershellinterfacev1.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class TreelandWallpaperSurfaceInterfaceV1 : public QObject
Q_SIGNALS:
void failed(uint32_t error);
void beforeDestroy(TreelandWallpaperSurfaceInterfaceV1 *surface);
void ready();

private:
explicit TreelandWallpaperSurfaceInterfaceV1(wl_resource *surface,
Expand Down
52 changes: 43 additions & 9 deletions src/wallpaper/wallpaperitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ void WallpaperItem::updateSurface()
setSurface(interface->wSurface());
interface->wSurface()->enterOutput(output());
update();
QTimer::singleShot(2000, this, [this]{ Q_EMIT sourceChanged(); });
Q_EMIT sourceChanged();
break;
}
}
Expand All @@ -211,19 +211,53 @@ void WallpaperItem::scheduleUpdate()
}

if (wallpaperRole() != Lockscreen) {
QTimer::singleShot(3000,
this,
[this]{
updateSurface();
if (!Helper::instance()->m_greeterProxy->isLocked()) {
setPlay(false);
}
});
clearPendingUpdate();

TreelandWallpaperShellInterfaceV1 *shell = Helper::instance()->shellHandler()->wallpaperShell();
if (shell) {
const QList<QString> &produced = shell->producedWallpapers();
if (!produced.isEmpty()) {
TreelandWallpaperSurfaceInterfaceV1 *interface = TreelandWallpaperSurfaceInterfaceV1::get(produced.last());
if (interface) {
m_readyConnection = QObject::connect(interface,
&TreelandWallpaperSurfaceInterfaceV1::ready,
this,
&WallpaperItem::applyPendingUpdate);
}
}
}

m_fallbackTimer = new QTimer(this);
m_fallbackTimer->setSingleShot(true);
QObject::connect(m_fallbackTimer, &QTimer::timeout, this, &WallpaperItem::applyPendingUpdate);
m_fallbackTimer->start(500);
} else {
updateSurface();
}
}

void WallpaperItem::clearPendingUpdate()
{
if (m_readyConnection) {
QObject::disconnect(m_readyConnection);
m_readyConnection = {};
}
if (m_fallbackTimer) {
m_fallbackTimer->stop();
m_fallbackTimer->deleteLater();
m_fallbackTimer = nullptr;
}
}

void WallpaperItem::applyPendingUpdate()
{
clearPendingUpdate();
updateSurface();
if (!Helper::instance()->m_greeterProxy->isLocked()) {
setPlay(false);
}
}

void WallpaperItem::handleWorkspaceAdded()
{
if (m_disableUpdate) {
Expand Down
5 changes: 5 additions & 0 deletions src/wallpaper/wallpaperitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
Q_MOC_INCLUDE("workspace/workspace.h")

class TreelandWallpaperSurfaceInterfaceV1;
class QTimer;

WAYLIB_SERVER_BEGIN_NAMESPACE
class WOutput;
Expand Down Expand Up @@ -91,8 +92,10 @@ private Q_SLOTS:
void updateSurface();
void scheduleUpdate();
void handleWorkspaceAdded();
void applyPendingUpdate();

private:
void clearPendingUpdate();
int m_userId = -1;
QPointer<WorkspaceModel> m_workspace = nullptr;
QPointer<WOutput> m_output = nullptr;
Expand All @@ -103,4 +106,6 @@ private Q_SLOTS:
bool m_play = true;
bool m_disableUpdate = false;
bool m_forceUpdateSource = false;
QMetaObject::Connection m_readyConnection;
QTimer *m_fallbackTimer = nullptr;
};
11 changes: 11 additions & 0 deletions wallpaper-factory/qwaylandwallpapersurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,19 @@
, m_shell(shell)
, m_interface(WallpaperWindow::get(window->window()))
, m_window(window)
, m_readySent(false)
{
init(shell->get_treeland_wallpaper_surface(window->waylandSurface()->object(), m_interface->source()));

QQuickWindow *quickWindow = qobject_cast<QQuickWindow *>(window->window());

Check warning on line 21 in wallpaper-factory/qwaylandwallpapersurface.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Variable 'quickWindow' can be declared as pointer to const
if (quickWindow) {
connect(quickWindow, &QQuickWindow::afterRendering, this, [this]() {
if (!m_readySent) {
m_readySent = true;
ready();
}
}, Qt::QueuedConnection);
}
}

QWaylandWallpaperSurface::~QWaylandWallpaperSurface()
Expand Down
2 changes: 2 additions & 0 deletions wallpaper-factory/qwaylandwallpapersurface_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
#pragma once

#include "wallpaperwindow.h"
#include "qwayland-treeland-wallpaper-shell-unstable-v1.h"

Check warning on line 7 in wallpaper-factory/qwaylandwallpapersurface_p.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "qwayland-treeland-wallpaper-shell-unstable-v1.h" not found.

#include <QQuickWindow>

Check warning on line 9 in wallpaper-factory/qwaylandwallpapersurface_p.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QQuickWindow> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QtWaylandClient/private/qwaylandshellsurface_p.h>

Check warning on line 10 in wallpaper-factory/qwaylandwallpapersurface_p.h

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QtWaylandClient/private/qwaylandshellsurface_p.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.

class QWaylandWallpaperShellIntegration;

Expand Down Expand Up @@ -35,4 +36,5 @@
QString m_activationToken;

bool m_configured = true;
bool m_readySent = false;
};
Loading