Commit 83003f0c authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

Re-initialize colord integration when colord daemon is restarted

We need to re-create all colord devices in case colord daemon is reloaded.
parent 3a7bce69
......@@ -12,6 +12,7 @@
#include "platform.h"
#include <QDBusPendingCallWatcher>
#include <QDBusServiceWatcher>
namespace KWin
{
......@@ -21,6 +22,22 @@ ColordIntegration::ColordIntegration(QObject *parent)
{
qDBusRegisterMetaType<CdStringMap>();
auto watcher = new QDBusServiceWatcher(QStringLiteral("org.freedesktop.ColorManager"),
QDBusConnection::systemBus(),
QDBusServiceWatcher::WatchForRegistration |
QDBusServiceWatcher::WatchForUnregistration, this);
connect(watcher, &QDBusServiceWatcher::serviceRegistered, this, &ColordIntegration::initialize);
connect(watcher, &QDBusServiceWatcher::serviceUnregistered, this, &ColordIntegration::teardown);
QDBusConnectionInterface *interface = QDBusConnection::systemBus().interface();
if (interface->isServiceRegistered(QStringLiteral("org.freedesktop.ColorManager"))) {
initialize();
}
}
void ColordIntegration::initialize()
{
const Platform *platform = kwinApp()->platform();
m_colordInterface = new CdInterface(QStringLiteral("org.freedesktop.ColorManager"),
......@@ -36,6 +53,22 @@ ColordIntegration::ColordIntegration(QObject *parent)
connect(platform, &Platform::outputRemoved, this, &ColordIntegration::handleOutputRemoved);
}
void ColordIntegration::teardown()
{
const Platform *platform = kwinApp()->platform();
const QVector<AbstractOutput *> outputs = platform->outputs();
for (AbstractOutput *output : outputs) {
handleOutputRemoved(output);
}
delete m_colordInterface;
m_colordInterface = nullptr;
disconnect(platform, &Platform::outputAdded, this, &ColordIntegration::handleOutputAdded);
disconnect(platform, &Platform::outputRemoved, this, &ColordIntegration::handleOutputRemoved);
}
void ColordIntegration::handleOutputAdded(AbstractOutput *output)
{
ColordDevice *device = new ColordDevice(output, this);
......
......@@ -30,6 +30,9 @@ private Q_SLOTS:
void handleOutputRemoved(AbstractOutput *output);
private:
void initialize();
void teardown();
QHash<AbstractOutput *, ColordDevice *> m_outputToDevice;
CdInterface *m_colordInterface;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment