Commit 4d1c82d1 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

Make ColorManager use outputs managed by Workspace

This removes one more dependency on Platform::enabledOutputs() and
Workspace knows better about what outputs are managed.
parent b9c00ba9
Pipeline #215664 failed with stage
in 16 minutes and 44 seconds
......@@ -8,9 +8,9 @@
#include "colordevice.h"
#include "main.h"
#include "output.h"
#include "platform.h"
#include "session.h"
#include "utils/common.h"
#include "workspace.h"
namespace KWin
{
......@@ -24,17 +24,13 @@ public:
ColorManager::ColorManager()
: d(std::make_unique<ColorManagerPrivate>())
{
Platform *platform = kwinApp()->platform();
const QVector<Output *> outputs = platform->outputs();
const QList<Output *> outputs = workspace()->outputs();
for (Output *output : outputs) {
if (output->isEnabled()) {
handleOutputEnabled(output);
}
handleOutputAdded(output);
}
connect(platform, &Platform::outputEnabled, this, &ColorManager::handleOutputEnabled);
connect(platform, &Platform::outputDisabled, this, &ColorManager::handleOutputDisabled);
connect(workspace(), &Workspace::outputAdded, this, &ColorManager::handleOutputAdded);
connect(workspace(), &Workspace::outputRemoved, this, &ColorManager::handleOutputRemoved);
connect(kwinApp()->session(), &Session::activeChanged, this, &ColorManager::handleSessionActiveChanged);
}
......@@ -56,14 +52,14 @@ ColorDevice *ColorManager::findDevice(Output *output) const
return nullptr;
}
void ColorManager::handleOutputEnabled(Output *output)
void ColorManager::handleOutputAdded(Output *output)
{
ColorDevice *device = new ColorDevice(output, this);
d->devices.append(device);
Q_EMIT deviceAdded(device);
}
void ColorManager::handleOutputDisabled(Output *output)
void ColorManager::handleOutputRemoved(Output *output)
{
auto it = std::find_if(d->devices.begin(), d->devices.end(), [&output](ColorDevice *device) {
return device->output() == output;
......
......@@ -52,8 +52,8 @@ Q_SIGNALS:
void deviceRemoved(ColorDevice *device);
private Q_SLOTS:
void handleOutputEnabled(Output *output);
void handleOutputDisabled(Output *output);
void handleOutputAdded(Output *output);
void handleOutputRemoved(Output *output);
void handleSessionActiveChanged(bool active);
private:
......
Supports Markdown
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