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
1 change: 1 addition & 0 deletions src/plugin-display/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ set(Display_Libraries
${QT_NS}::Concurrent
${DTK_NS}::Core
dcc-wallpaper-utils
dcc-shared-utils
)

target_link_libraries(${Display_Name} PRIVATE
Expand Down
35 changes: 35 additions & 0 deletions src/plugin-display/operation/private/displayworker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
#include "displayworker.h"

#include "displaymodel.h"
#include "wallpaperthumbnailutils.h"

Check warning on line 7 in src/plugin-display/operation/private/displayworker.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "wallpaperthumbnailutils.h" not found.
#include "wallpapersync.h"

Check warning on line 8 in src/plugin-display/operation/private/displayworker.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "wallpapersync.h" not found.

#include <OutputManager.h>

Check warning on line 10 in src/plugin-display/operation/private/displayworker.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <OutputManager.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <TreeLandOutputManager.h>

Check warning on line 11 in src/plugin-display/operation/private/displayworker.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <TreeLandOutputManager.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <VirtualOutputManager.h>
#include <WallpaperManager.h>
#include <WayQtUtils.h>
Expand Down Expand Up @@ -147,6 +148,11 @@
m_wallpaperMgr = new WQt::WallpaperManager(this);
connect(m_wallpaperMgr, &WQt::WallpaperManager::activeChanged, this, &DisplayWorker::onWallpaperManagerActive);

if (auto *wallpaperSync = WallpaperSync::instance()) {
connect(wallpaperSync, &WallpaperSync::wallpaperChanged,
this, &DisplayWorker::onSyncedWallpaperChanged, Qt::QueuedConnection);
}

// wl_output 的生命周期由 Qt 平台插件维护,跟随 QScreen 即可
connect(qApp, &QGuiApplication::screenAdded, this, &DisplayWorker::screenAdded);
connect(qApp, &QGuiApplication::screenRemoved, this, &DisplayWorker::screenRemoved);
Expand Down Expand Up @@ -196,6 +202,9 @@
// m_model->setResolutionRefreshEnable(m_dccSettings->get(GSETTINGS_SHOW_MUTILSCREEN).toBool());
// m_model->setBrightnessEnable(m_dccSettings->get(GSETTINGS_BRIGHTNESS_ENABLE).toBool());
}
else {
rebindWallpaperContexts();
}
}

void DisplayWorker::saveChanges()
Expand Down Expand Up @@ -405,6 +414,17 @@
ensureWallpaperContext(screen);
}

void DisplayWorker::rebindWallpaperContexts()
{
for (auto *screen : QGuiApplication::screens()) {
auto *output = m_screen_outputs.value(screen);
if (output && m_wallpaperMgr)
m_wallpaperMgr->removeWallpaper(output);

ensureWallpaperContext(screen);
}
}

void DisplayWorker::ensureWallpaperContext(QScreen *screen)
{
if (!screen || !m_wallpaperMgr || !m_wallpaperMgr->isActive())
Expand Down Expand Up @@ -460,6 +480,21 @@
}
}

void DisplayWorker::onSyncedWallpaperChanged(const QString &monitorName, const QString &source, uint sourceType)
{
for (auto it(m_wl_monitors.cbegin()); it != m_wl_monitors.cend(); ++it) {
if (it.key()->name() != monitorName)
continue;

QString wallpaper = source;
if (sourceType == WallpaperSync::VideoSourceType)
wallpaper = resolveVideoThumbnail(source, it.key());

it.key()->setWallpaper(wallpaper);
break;
}
}

void DisplayWorker::updateVirtualOutputs()
{
if (!m_virtualOutputMgr)
Expand Down
2 changes: 2 additions & 0 deletions src/plugin-display/operation/private/displayworker.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,10 @@ private Q_SLOTS:
void updateWallpaper();
void updateMonitorWallpaper(Monitor *mon);
void updateWallpaperFromWayland();
void rebindWallpaperContexts();
void ensureWallpaperContext(QScreen *screen);
void onWallpaperChanged(const QString &fileSource, uint32_t sourceType, uint32_t role);
void onSyncedWallpaperChanged(const QString &monitorName, const QString &source, uint sourceType);
void updateVirtualOutputs();

void onBrightnessChanged(WQt::ColorControl *colorControl, double brightness);
Expand Down
1 change: 1 addition & 0 deletions src/plugin-personalization/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ set(Personalization_Libraries
${QT_NS}::WaylandClientPrivate
${QT_NS}::Concurrent
dcc-wallpaper-utils
dcc-shared-utils
)

target_include_directories(${LIB_NAME} PUBLIC
Expand Down
10 changes: 10 additions & 0 deletions src/plugin-personalization/operation/treelandworker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
#include <private/qwaylandintegration_p.h>
#include <private/qwaylandwindow_p.h>
#include "treelandworker.h"
#include "operation/personalizationworker.h"

Check warning on line 24 in src/plugin-personalization/operation/treelandworker.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "operation/personalizationworker.h" not found.
#include "operation/model/thememodel.h"

Check warning on line 25 in src/plugin-personalization/operation/treelandworker.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "operation/model/thememodel.h" not found.
#include "operation/personalizationexport.hpp"

Check warning on line 26 in src/plugin-personalization/operation/treelandworker.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "operation/personalizationexport.hpp" not found.
#include "wallpapersync.h"

Check warning on line 27 in src/plugin-personalization/operation/treelandworker.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "wallpapersync.h" not found.

#define TYPEWALLPAPER "wallpaper"
#define TYPEGREETERBACKGROUND "greeterbackground"
Expand Down Expand Up @@ -450,6 +451,15 @@
}
}

if (role == WallpaperContext::wallpaper_role_desktop) {
if (auto *wallpaperSync = WallpaperSync::instance()) {
QMetaObject::invokeMethod(wallpaperSync, "setWallpaper", Qt::QueuedConnection,
Q_ARG(QString, monitorName),
Q_ARG(QString, dest),
Q_ARG(uint, type));
}
}

return true;
}

Expand Down
2 changes: 2 additions & 0 deletions src/shared-utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ set(DCC_SHARED_UTILS_SOURCES
"dcclocale.cpp"
"dccdsappletmanager.h"
"dccdsappletmanager.cpp"
"wallpapersync.h"
"wallpapersync.cpp"
)

target_sources(dcc-shared-utils PRIVATE
Expand Down
60 changes: 60 additions & 0 deletions src/shared-utils/wallpapersync.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#include "wallpapersync.h"

#include <QCoreApplication>

Check warning on line 7 in src/shared-utils/wallpapersync.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QCoreApplication> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QPointer>

Check warning on line 8 in src/shared-utils/wallpapersync.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <QPointer> not found. Please note: Cppcheck does not need standard library headers to get proper results.
#include <QThread>

namespace {
QPointer<WallpaperSync> wallpaperSyncInstance;
} // namespace

WallpaperSync *WallpaperSync::instance()
{
if (wallpaperSyncInstance)
return wallpaperSyncInstance;

auto *application = QCoreApplication::instance();
if (!application)
return nullptr;

// The lambda is defined inside this static member function, so it inherits
// WallpaperSync's access rights and may invoke the private constructor.
auto create = [application]() {
if (!wallpaperSyncInstance)
wallpaperSyncInstance = new WallpaperSync(application);
};

if (QThread::currentThread() == application->thread()) {
create();
} else {
QMetaObject::invokeMethod(application, create, Qt::BlockingQueuedConnection);
}

return wallpaperSyncInstance;
}

QVariantMap WallpaperSync::wallpaperMap() const
{
return m_wallpaperMap;
}

void WallpaperSync::setWallpaper(const QString &monitorName, const QString &source, uint sourceType)
{
const QVariantMap wallpaper{ { QStringLiteral("source"), source },
{ QStringLiteral("sourceType"), sourceType } };

if (m_wallpaperMap.value(monitorName) == wallpaper)
return;

m_wallpaperMap.insert(monitorName, wallpaper);
Q_EMIT wallpaperChanged(monitorName, source, sourceType);
}

WallpaperSync::WallpaperSync(QObject *parent)
: QObject(parent)
{
}
31 changes: 31 additions & 0 deletions src/shared-utils/wallpapersync.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd.
//
// SPDX-License-Identifier: GPL-3.0-or-later

#pragma once

#include <QObject>
#include <QVariantMap>

class WallpaperSync : public QObject
{
Q_OBJECT
public:
static constexpr uint ImageSourceType = 0;
static constexpr uint VideoSourceType = 1;

static WallpaperSync *instance();

QVariantMap wallpaperMap() const;

public Q_SLOTS:
void setWallpaper(const QString &monitorName, const QString &source, uint sourceType);

Q_SIGNALS:
void wallpaperChanged(const QString &monitorName, const QString &source, uint sourceType);

private:
explicit WallpaperSync(QObject *parent = nullptr);

QVariantMap m_wallpaperMap;
};
Loading