2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
[colorcorrection] Night Color - blue light filter at nighttime
With Wayland KWin needs to provide certain services, which were provided
before that by the Xserver. One of these is gamma correction, which includes
the - by many people beloved - functionality to reduce the blue light at
nighttime. This patch provides the KWin part of that. It is self contained,
but in the end will work in tandem with a lib in Plasma Workspace and a KCM
in Plasma Desktop, which can be used to configure Night Color.
* Three modi:
** Automatic: The location and sun timings are determined automatically
(location data updates will be provided by the workspace)
** Location: The sun timings are determined by fixed location data
** Timings: The sun timings are set manually by the user
* Color temperature value changes are smoothly applied:
** Configuration changes, which lead to other current values are changed
in a quick way over a few seconds
** Changes on sunrise and sunset are applied slowly over the course of few
minutes till several hours depending on the configuration
* The current color value is set immediately at startup or after suspend
phases and VT switches. There is no flickering.
* All configuration is done via a DBus interface, changed values are tested
on correctness and applied atomically
* Self contained mechanism, speaks directly to the hardware by setting the
gamma ramps on the CRTC
* Currently working on DRM backend, extensible to other platform backends in
the future
* The code is written in a way to make the classes later easily extendable to
also provide normal color correction, as it's currently done by KGamma on X
Test Plan:
Manually with the workspace parts and added integration tests in KWin using
the virtual backend.
BUG:371494
Reviewers: #kwin, graesslin
Subscribers: kwin, plasma-devel, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D5928
2017-12-11 09:43:12 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2017 Roman Gilg <subdiff@gmail.com>
|
[colorcorrection] Night Color - blue light filter at nighttime
With Wayland KWin needs to provide certain services, which were provided
before that by the Xserver. One of these is gamma correction, which includes
the - by many people beloved - functionality to reduce the blue light at
nighttime. This patch provides the KWin part of that. It is self contained,
but in the end will work in tandem with a lib in Plasma Workspace and a KCM
in Plasma Desktop, which can be used to configure Night Color.
* Three modi:
** Automatic: The location and sun timings are determined automatically
(location data updates will be provided by the workspace)
** Location: The sun timings are determined by fixed location data
** Timings: The sun timings are set manually by the user
* Color temperature value changes are smoothly applied:
** Configuration changes, which lead to other current values are changed
in a quick way over a few seconds
** Changes on sunrise and sunset are applied slowly over the course of few
minutes till several hours depending on the configuration
* The current color value is set immediately at startup or after suspend
phases and VT switches. There is no flickering.
* All configuration is done via a DBus interface, changed values are tested
on correctness and applied atomically
* Self contained mechanism, speaks directly to the hardware by setting the
gamma ramps on the CRTC
* Currently working on DRM backend, extensible to other platform backends in
the future
* The code is written in a way to make the classes later easily extendable to
also provide normal color correction, as it's currently done by KGamma on X
Test Plan:
Manually with the workspace parts and added integration tests in KWin using
the virtual backend.
BUG:371494
Reviewers: #kwin, graesslin
Subscribers: kwin, plasma-devel, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D5928
2017-12-11 09:43:12 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
[colorcorrection] Night Color - blue light filter at nighttime
With Wayland KWin needs to provide certain services, which were provided
before that by the Xserver. One of these is gamma correction, which includes
the - by many people beloved - functionality to reduce the blue light at
nighttime. This patch provides the KWin part of that. It is self contained,
but in the end will work in tandem with a lib in Plasma Workspace and a KCM
in Plasma Desktop, which can be used to configure Night Color.
* Three modi:
** Automatic: The location and sun timings are determined automatically
(location data updates will be provided by the workspace)
** Location: The sun timings are determined by fixed location data
** Timings: The sun timings are set manually by the user
* Color temperature value changes are smoothly applied:
** Configuration changes, which lead to other current values are changed
in a quick way over a few seconds
** Changes on sunrise and sunset are applied slowly over the course of few
minutes till several hours depending on the configuration
* The current color value is set immediately at startup or after suspend
phases and VT switches. There is no flickering.
* All configuration is done via a DBus interface, changed values are tested
on correctness and applied atomically
* Self contained mechanism, speaks directly to the hardware by setting the
gamma ramps on the CRTC
* Currently working on DRM backend, extensible to other platform backends in
the future
* The code is written in a way to make the classes later easily extendable to
also provide normal color correction, as it's currently done by KGamma on X
Test Plan:
Manually with the workspace parts and added integration tests in KWin using
the virtual backend.
BUG:371494
Reviewers: #kwin, graesslin
Subscribers: kwin, plasma-devel, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D5928
2017-12-11 09:43:12 +00:00
|
|
|
|
2020-11-25 19:11:48 +00:00
|
|
|
#include "nightcolordbusinterface.h"
|
|
|
|
#include "nightcolormanager.h"
|
[colorcorrection] Night Color - blue light filter at nighttime
With Wayland KWin needs to provide certain services, which were provided
before that by the Xserver. One of these is gamma correction, which includes
the - by many people beloved - functionality to reduce the blue light at
nighttime. This patch provides the KWin part of that. It is self contained,
but in the end will work in tandem with a lib in Plasma Workspace and a KCM
in Plasma Desktop, which can be used to configure Night Color.
* Three modi:
** Automatic: The location and sun timings are determined automatically
(location data updates will be provided by the workspace)
** Location: The sun timings are determined by fixed location data
** Timings: The sun timings are set manually by the user
* Color temperature value changes are smoothly applied:
** Configuration changes, which lead to other current values are changed
in a quick way over a few seconds
** Changes on sunrise and sunset are applied slowly over the course of few
minutes till several hours depending on the configuration
* The current color value is set immediately at startup or after suspend
phases and VT switches. There is no flickering.
* All configuration is done via a DBus interface, changed values are tested
on correctness and applied atomically
* Self contained mechanism, speaks directly to the hardware by setting the
gamma ramps on the CRTC
* Currently working on DRM backend, extensible to other platform backends in
the future
* The code is written in a way to make the classes later easily extendable to
also provide normal color correction, as it's currently done by KGamma on X
Test Plan:
Manually with the workspace parts and added integration tests in KWin using
the virtual backend.
BUG:371494
Reviewers: #kwin, graesslin
Subscribers: kwin, plasma-devel, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D5928
2017-12-11 09:43:12 +00:00
|
|
|
#include "colorcorrectadaptor.h"
|
|
|
|
|
2020-01-07 15:09:55 +00:00
|
|
|
#include <QDBusMessage>
|
|
|
|
|
[colorcorrection] Night Color - blue light filter at nighttime
With Wayland KWin needs to provide certain services, which were provided
before that by the Xserver. One of these is gamma correction, which includes
the - by many people beloved - functionality to reduce the blue light at
nighttime. This patch provides the KWin part of that. It is self contained,
but in the end will work in tandem with a lib in Plasma Workspace and a KCM
in Plasma Desktop, which can be used to configure Night Color.
* Three modi:
** Automatic: The location and sun timings are determined automatically
(location data updates will be provided by the workspace)
** Location: The sun timings are determined by fixed location data
** Timings: The sun timings are set manually by the user
* Color temperature value changes are smoothly applied:
** Configuration changes, which lead to other current values are changed
in a quick way over a few seconds
** Changes on sunrise and sunset are applied slowly over the course of few
minutes till several hours depending on the configuration
* The current color value is set immediately at startup or after suspend
phases and VT switches. There is no flickering.
* All configuration is done via a DBus interface, changed values are tested
on correctness and applied atomically
* Self contained mechanism, speaks directly to the hardware by setting the
gamma ramps on the CRTC
* Currently working on DRM backend, extensible to other platform backends in
the future
* The code is written in a way to make the classes later easily extendable to
also provide normal color correction, as it's currently done by KGamma on X
Test Plan:
Manually with the workspace parts and added integration tests in KWin using
the virtual backend.
BUG:371494
Reviewers: #kwin, graesslin
Subscribers: kwin, plasma-devel, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D5928
2017-12-11 09:43:12 +00:00
|
|
|
namespace KWin {
|
|
|
|
|
2020-11-25 19:11:48 +00:00
|
|
|
NightColorDBusInterface::NightColorDBusInterface(NightColorManager *parent)
|
[colorcorrection] Night Color - blue light filter at nighttime
With Wayland KWin needs to provide certain services, which were provided
before that by the Xserver. One of these is gamma correction, which includes
the - by many people beloved - functionality to reduce the blue light at
nighttime. This patch provides the KWin part of that. It is self contained,
but in the end will work in tandem with a lib in Plasma Workspace and a KCM
in Plasma Desktop, which can be used to configure Night Color.
* Three modi:
** Automatic: The location and sun timings are determined automatically
(location data updates will be provided by the workspace)
** Location: The sun timings are determined by fixed location data
** Timings: The sun timings are set manually by the user
* Color temperature value changes are smoothly applied:
** Configuration changes, which lead to other current values are changed
in a quick way over a few seconds
** Changes on sunrise and sunset are applied slowly over the course of few
minutes till several hours depending on the configuration
* The current color value is set immediately at startup or after suspend
phases and VT switches. There is no flickering.
* All configuration is done via a DBus interface, changed values are tested
on correctness and applied atomically
* Self contained mechanism, speaks directly to the hardware by setting the
gamma ramps on the CRTC
* Currently working on DRM backend, extensible to other platform backends in
the future
* The code is written in a way to make the classes later easily extendable to
also provide normal color correction, as it's currently done by KGamma on X
Test Plan:
Manually with the workspace parts and added integration tests in KWin using
the virtual backend.
BUG:371494
Reviewers: #kwin, graesslin
Subscribers: kwin, plasma-devel, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D5928
2017-12-11 09:43:12 +00:00
|
|
|
: QObject(parent)
|
|
|
|
, m_manager(parent)
|
2020-01-07 15:09:55 +00:00
|
|
|
, m_inhibitorWatcher(new QDBusServiceWatcher(this))
|
[colorcorrection] Night Color - blue light filter at nighttime
With Wayland KWin needs to provide certain services, which were provided
before that by the Xserver. One of these is gamma correction, which includes
the - by many people beloved - functionality to reduce the blue light at
nighttime. This patch provides the KWin part of that. It is self contained,
but in the end will work in tandem with a lib in Plasma Workspace and a KCM
in Plasma Desktop, which can be used to configure Night Color.
* Three modi:
** Automatic: The location and sun timings are determined automatically
(location data updates will be provided by the workspace)
** Location: The sun timings are determined by fixed location data
** Timings: The sun timings are set manually by the user
* Color temperature value changes are smoothly applied:
** Configuration changes, which lead to other current values are changed
in a quick way over a few seconds
** Changes on sunrise and sunset are applied slowly over the course of few
minutes till several hours depending on the configuration
* The current color value is set immediately at startup or after suspend
phases and VT switches. There is no flickering.
* All configuration is done via a DBus interface, changed values are tested
on correctness and applied atomically
* Self contained mechanism, speaks directly to the hardware by setting the
gamma ramps on the CRTC
* Currently working on DRM backend, extensible to other platform backends in
the future
* The code is written in a way to make the classes later easily extendable to
also provide normal color correction, as it's currently done by KGamma on X
Test Plan:
Manually with the workspace parts and added integration tests in KWin using
the virtual backend.
BUG:371494
Reviewers: #kwin, graesslin
Subscribers: kwin, plasma-devel, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D5928
2017-12-11 09:43:12 +00:00
|
|
|
{
|
2020-01-07 15:09:55 +00:00
|
|
|
m_inhibitorWatcher->setConnection(QDBusConnection::sessionBus());
|
|
|
|
m_inhibitorWatcher->setWatchMode(QDBusServiceWatcher::WatchForUnregistration);
|
|
|
|
connect(m_inhibitorWatcher, &QDBusServiceWatcher::serviceUnregistered,
|
2020-11-25 19:11:48 +00:00
|
|
|
this, &NightColorDBusInterface::removeInhibitorService);
|
2020-01-07 15:09:55 +00:00
|
|
|
|
2020-11-25 19:11:48 +00:00
|
|
|
connect(m_manager, &NightColorManager::inhibitedChanged, this, [this] {
|
2020-01-07 15:09:55 +00:00
|
|
|
QVariantMap changedProperties;
|
|
|
|
changedProperties.insert(QStringLiteral("inhibited"), m_manager->isInhibited());
|
|
|
|
|
|
|
|
QDBusMessage message = QDBusMessage::createSignal(
|
|
|
|
QStringLiteral("/ColorCorrect"),
|
|
|
|
QStringLiteral("org.freedesktop.DBus.Properties"),
|
|
|
|
QStringLiteral("PropertiesChanged")
|
|
|
|
);
|
|
|
|
|
|
|
|
message.setArguments({
|
|
|
|
QStringLiteral("org.kde.kwin.ColorCorrect"),
|
|
|
|
changedProperties,
|
|
|
|
QStringList(), // invalidated_properties
|
|
|
|
});
|
|
|
|
|
|
|
|
QDBusConnection::sessionBus().send(message);
|
|
|
|
});
|
|
|
|
|
2020-11-25 19:11:48 +00:00
|
|
|
connect(m_manager, &NightColorManager::enabledChanged, this, [this] {
|
2020-01-07 15:11:56 +00:00
|
|
|
QVariantMap changedProperties;
|
|
|
|
changedProperties.insert(QStringLiteral("enabled"), m_manager->isEnabled());
|
|
|
|
|
|
|
|
QDBusMessage message = QDBusMessage::createSignal(
|
|
|
|
QStringLiteral("/ColorCorrect"),
|
|
|
|
QStringLiteral("org.freedesktop.DBus.Properties"),
|
|
|
|
QStringLiteral("PropertiesChanged")
|
|
|
|
);
|
|
|
|
|
|
|
|
message.setArguments({
|
|
|
|
QStringLiteral("org.kde.kwin.ColorCorrect"),
|
|
|
|
changedProperties,
|
|
|
|
QStringList(), // invalidated_properties
|
|
|
|
});
|
|
|
|
|
|
|
|
QDBusConnection::sessionBus().send(message);
|
|
|
|
});
|
|
|
|
|
2020-11-25 19:11:48 +00:00
|
|
|
connect(m_manager, &NightColorManager::runningChanged, this, [this] {
|
2020-01-07 15:11:56 +00:00
|
|
|
QVariantMap changedProperties;
|
|
|
|
changedProperties.insert(QStringLiteral("running"), m_manager->isRunning());
|
|
|
|
|
|
|
|
QDBusMessage message = QDBusMessage::createSignal(
|
|
|
|
QStringLiteral("/ColorCorrect"),
|
|
|
|
QStringLiteral("org.freedesktop.DBus.Properties"),
|
|
|
|
QStringLiteral("PropertiesChanged")
|
|
|
|
);
|
|
|
|
|
|
|
|
message.setArguments({
|
|
|
|
QStringLiteral("org.kde.kwin.ColorCorrect"),
|
|
|
|
changedProperties,
|
|
|
|
QStringList(), // invalidated_properties
|
|
|
|
});
|
|
|
|
|
|
|
|
QDBusConnection::sessionBus().send(message);
|
|
|
|
});
|
|
|
|
|
2020-11-25 19:11:48 +00:00
|
|
|
connect(m_manager, &NightColorManager::currentTemperatureChanged, this, [this] {
|
2020-01-07 15:11:56 +00:00
|
|
|
QVariantMap changedProperties;
|
|
|
|
changedProperties.insert(QStringLiteral("currentTemperature"), m_manager->currentTemperature());
|
|
|
|
|
|
|
|
QDBusMessage message = QDBusMessage::createSignal(
|
|
|
|
QStringLiteral("/ColorCorrect"),
|
|
|
|
QStringLiteral("org.freedesktop.DBus.Properties"),
|
|
|
|
QStringLiteral("PropertiesChanged")
|
|
|
|
);
|
|
|
|
|
|
|
|
message.setArguments({
|
|
|
|
QStringLiteral("org.kde.kwin.ColorCorrect"),
|
|
|
|
changedProperties,
|
|
|
|
QStringList(), // invalidated_properties
|
|
|
|
});
|
|
|
|
|
|
|
|
QDBusConnection::sessionBus().send(message);
|
|
|
|
});
|
|
|
|
|
2020-11-25 19:11:48 +00:00
|
|
|
connect(m_manager, &NightColorManager::targetTemperatureChanged, this, [this] {
|
2020-01-07 15:11:56 +00:00
|
|
|
QVariantMap changedProperties;
|
|
|
|
changedProperties.insert(QStringLiteral("targetTemperature"), m_manager->targetTemperature());
|
|
|
|
|
|
|
|
QDBusMessage message = QDBusMessage::createSignal(
|
|
|
|
QStringLiteral("/ColorCorrect"),
|
|
|
|
QStringLiteral("org.freedesktop.DBus.Properties"),
|
|
|
|
QStringLiteral("PropertiesChanged")
|
|
|
|
);
|
|
|
|
|
|
|
|
message.setArguments({
|
|
|
|
QStringLiteral("org.kde.kwin.ColorCorrect"),
|
|
|
|
changedProperties,
|
|
|
|
QStringList(), // invalidated_properties
|
|
|
|
});
|
|
|
|
|
|
|
|
QDBusConnection::sessionBus().send(message);
|
|
|
|
});
|
|
|
|
|
2020-11-25 19:11:48 +00:00
|
|
|
connect(m_manager, &NightColorManager::modeChanged, this, [this] {
|
2020-01-07 15:11:56 +00:00
|
|
|
QVariantMap changedProperties;
|
|
|
|
changedProperties.insert(QStringLiteral("mode"), uint(m_manager->mode()));
|
|
|
|
|
|
|
|
QDBusMessage message = QDBusMessage::createSignal(
|
|
|
|
QStringLiteral("/ColorCorrect"),
|
|
|
|
QStringLiteral("org.freedesktop.DBus.Properties"),
|
|
|
|
QStringLiteral("PropertiesChanged")
|
|
|
|
);
|
|
|
|
|
|
|
|
message.setArguments({
|
|
|
|
QStringLiteral("org.kde.kwin.ColorCorrect"),
|
|
|
|
changedProperties,
|
|
|
|
QStringList(), // invalidated_properties
|
|
|
|
});
|
|
|
|
|
|
|
|
QDBusConnection::sessionBus().send(message);
|
|
|
|
});
|
|
|
|
|
2020-11-25 19:11:48 +00:00
|
|
|
connect(m_manager, &NightColorManager::previousTransitionTimingsChanged, this, [this] {
|
2020-01-13 20:41:36 +00:00
|
|
|
QVariantMap changedProperties;
|
|
|
|
changedProperties.insert(QStringLiteral("previousTransitionDateTime"), previousTransitionDateTime());
|
|
|
|
changedProperties.insert(QStringLiteral("previousTransitionDuration"), previousTransitionDuration());
|
|
|
|
|
|
|
|
QDBusMessage message = QDBusMessage::createSignal(
|
|
|
|
QStringLiteral("/ColorCorrect"),
|
|
|
|
QStringLiteral("org.freedesktop.DBus.Properties"),
|
|
|
|
QStringLiteral("PropertiesChanged")
|
|
|
|
);
|
|
|
|
|
|
|
|
message.setArguments({
|
|
|
|
QStringLiteral("org.kde.kwin.ColorCorrect"),
|
|
|
|
changedProperties,
|
|
|
|
QStringList(), // invalidated_properties
|
|
|
|
});
|
|
|
|
|
|
|
|
QDBusConnection::sessionBus().send(message);
|
|
|
|
});
|
|
|
|
|
2020-11-25 19:11:48 +00:00
|
|
|
connect(m_manager, &NightColorManager::scheduledTransitionTimingsChanged, this, [this] {
|
2020-01-13 20:41:36 +00:00
|
|
|
QVariantMap changedProperties;
|
|
|
|
changedProperties.insert(QStringLiteral("scheduledTransitionDateTime"), scheduledTransitionDateTime());
|
|
|
|
changedProperties.insert(QStringLiteral("scheduledTransitionDuration"), scheduledTransitionDuration());
|
|
|
|
|
|
|
|
QDBusMessage message = QDBusMessage::createSignal(
|
|
|
|
QStringLiteral("/ColorCorrect"),
|
|
|
|
QStringLiteral("org.freedesktop.DBus.Properties"),
|
|
|
|
QStringLiteral("PropertiesChanged")
|
|
|
|
);
|
|
|
|
|
|
|
|
message.setArguments({
|
|
|
|
QStringLiteral("org.kde.kwin.ColorCorrect"),
|
|
|
|
changedProperties,
|
|
|
|
QStringList(), // invalidated_properties
|
|
|
|
});
|
|
|
|
|
|
|
|
QDBusConnection::sessionBus().send(message);
|
|
|
|
});
|
|
|
|
|
2020-11-25 19:11:48 +00:00
|
|
|
connect(m_manager, &NightColorManager::configChange, this, &NightColorDBusInterface::nightColorConfigChanged);
|
[colorcorrection] Night Color - blue light filter at nighttime
With Wayland KWin needs to provide certain services, which were provided
before that by the Xserver. One of these is gamma correction, which includes
the - by many people beloved - functionality to reduce the blue light at
nighttime. This patch provides the KWin part of that. It is self contained,
but in the end will work in tandem with a lib in Plasma Workspace and a KCM
in Plasma Desktop, which can be used to configure Night Color.
* Three modi:
** Automatic: The location and sun timings are determined automatically
(location data updates will be provided by the workspace)
** Location: The sun timings are determined by fixed location data
** Timings: The sun timings are set manually by the user
* Color temperature value changes are smoothly applied:
** Configuration changes, which lead to other current values are changed
in a quick way over a few seconds
** Changes on sunrise and sunset are applied slowly over the course of few
minutes till several hours depending on the configuration
* The current color value is set immediately at startup or after suspend
phases and VT switches. There is no flickering.
* All configuration is done via a DBus interface, changed values are tested
on correctness and applied atomically
* Self contained mechanism, speaks directly to the hardware by setting the
gamma ramps on the CRTC
* Currently working on DRM backend, extensible to other platform backends in
the future
* The code is written in a way to make the classes later easily extendable to
also provide normal color correction, as it's currently done by KGamma on X
Test Plan:
Manually with the workspace parts and added integration tests in KWin using
the virtual backend.
BUG:371494
Reviewers: #kwin, graesslin
Subscribers: kwin, plasma-devel, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D5928
2017-12-11 09:43:12 +00:00
|
|
|
new ColorCorrectAdaptor(this);
|
|
|
|
QDBusConnection::sessionBus().registerObject(QStringLiteral("/ColorCorrect"), this);
|
|
|
|
}
|
|
|
|
|
2020-11-25 19:11:48 +00:00
|
|
|
bool NightColorDBusInterface::isInhibited() const
|
2020-01-07 15:09:55 +00:00
|
|
|
{
|
|
|
|
return m_manager->isInhibited();
|
|
|
|
}
|
|
|
|
|
2020-11-25 19:11:48 +00:00
|
|
|
bool NightColorDBusInterface::isEnabled() const
|
2020-01-07 15:11:56 +00:00
|
|
|
{
|
|
|
|
return m_manager->isEnabled();
|
|
|
|
}
|
|
|
|
|
2020-11-25 19:11:48 +00:00
|
|
|
bool NightColorDBusInterface::isRunning() const
|
2020-01-07 15:11:56 +00:00
|
|
|
{
|
|
|
|
return m_manager->isRunning();
|
|
|
|
}
|
|
|
|
|
2020-11-25 19:11:48 +00:00
|
|
|
bool NightColorDBusInterface::isAvailable() const
|
2020-01-07 15:11:56 +00:00
|
|
|
{
|
|
|
|
return m_manager->isAvailable();
|
|
|
|
}
|
|
|
|
|
2020-11-25 19:11:48 +00:00
|
|
|
int NightColorDBusInterface::currentTemperature() const
|
2020-01-07 15:11:56 +00:00
|
|
|
{
|
|
|
|
return m_manager->currentTemperature();
|
|
|
|
}
|
|
|
|
|
2020-11-25 19:11:48 +00:00
|
|
|
int NightColorDBusInterface::targetTemperature() const
|
2020-01-07 15:11:56 +00:00
|
|
|
{
|
|
|
|
return m_manager->targetTemperature();
|
|
|
|
}
|
|
|
|
|
2020-11-25 19:11:48 +00:00
|
|
|
int NightColorDBusInterface::mode() const
|
2020-01-07 15:11:56 +00:00
|
|
|
{
|
|
|
|
return m_manager->mode();
|
|
|
|
}
|
|
|
|
|
2020-11-25 19:11:48 +00:00
|
|
|
quint64 NightColorDBusInterface::previousTransitionDateTime() const
|
2020-01-13 20:41:36 +00:00
|
|
|
{
|
|
|
|
const QDateTime dateTime = m_manager->previousTransitionDateTime();
|
|
|
|
if (dateTime.isValid()) {
|
|
|
|
return quint64(dateTime.toSecsSinceEpoch());
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-11-25 19:11:48 +00:00
|
|
|
quint32 NightColorDBusInterface::previousTransitionDuration() const
|
2020-01-13 20:41:36 +00:00
|
|
|
{
|
|
|
|
return quint32(m_manager->previousTransitionDuration());
|
|
|
|
}
|
|
|
|
|
2020-11-25 19:11:48 +00:00
|
|
|
quint64 NightColorDBusInterface::scheduledTransitionDateTime() const
|
2020-01-13 20:41:36 +00:00
|
|
|
{
|
|
|
|
const QDateTime dateTime = m_manager->scheduledTransitionDateTime();
|
|
|
|
if (dateTime.isValid()) {
|
|
|
|
return quint64(dateTime.toSecsSinceEpoch());
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-11-25 19:11:48 +00:00
|
|
|
quint32 NightColorDBusInterface::scheduledTransitionDuration() const
|
2020-01-13 20:41:36 +00:00
|
|
|
{
|
|
|
|
return quint32(m_manager->scheduledTransitionDuration());
|
|
|
|
}
|
|
|
|
|
2020-11-25 19:11:48 +00:00
|
|
|
QHash<QString, QVariant> NightColorDBusInterface::nightColorInfo()
|
[colorcorrection] Night Color - blue light filter at nighttime
With Wayland KWin needs to provide certain services, which were provided
before that by the Xserver. One of these is gamma correction, which includes
the - by many people beloved - functionality to reduce the blue light at
nighttime. This patch provides the KWin part of that. It is self contained,
but in the end will work in tandem with a lib in Plasma Workspace and a KCM
in Plasma Desktop, which can be used to configure Night Color.
* Three modi:
** Automatic: The location and sun timings are determined automatically
(location data updates will be provided by the workspace)
** Location: The sun timings are determined by fixed location data
** Timings: The sun timings are set manually by the user
* Color temperature value changes are smoothly applied:
** Configuration changes, which lead to other current values are changed
in a quick way over a few seconds
** Changes on sunrise and sunset are applied slowly over the course of few
minutes till several hours depending on the configuration
* The current color value is set immediately at startup or after suspend
phases and VT switches. There is no flickering.
* All configuration is done via a DBus interface, changed values are tested
on correctness and applied atomically
* Self contained mechanism, speaks directly to the hardware by setting the
gamma ramps on the CRTC
* Currently working on DRM backend, extensible to other platform backends in
the future
* The code is written in a way to make the classes later easily extendable to
also provide normal color correction, as it's currently done by KGamma on X
Test Plan:
Manually with the workspace parts and added integration tests in KWin using
the virtual backend.
BUG:371494
Reviewers: #kwin, graesslin
Subscribers: kwin, plasma-devel, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D5928
2017-12-11 09:43:12 +00:00
|
|
|
{
|
|
|
|
return m_manager->info();
|
|
|
|
}
|
|
|
|
|
2020-11-25 19:11:48 +00:00
|
|
|
bool NightColorDBusInterface::setNightColorConfig(QHash<QString, QVariant> data)
|
[colorcorrection] Night Color - blue light filter at nighttime
With Wayland KWin needs to provide certain services, which were provided
before that by the Xserver. One of these is gamma correction, which includes
the - by many people beloved - functionality to reduce the blue light at
nighttime. This patch provides the KWin part of that. It is self contained,
but in the end will work in tandem with a lib in Plasma Workspace and a KCM
in Plasma Desktop, which can be used to configure Night Color.
* Three modi:
** Automatic: The location and sun timings are determined automatically
(location data updates will be provided by the workspace)
** Location: The sun timings are determined by fixed location data
** Timings: The sun timings are set manually by the user
* Color temperature value changes are smoothly applied:
** Configuration changes, which lead to other current values are changed
in a quick way over a few seconds
** Changes on sunrise and sunset are applied slowly over the course of few
minutes till several hours depending on the configuration
* The current color value is set immediately at startup or after suspend
phases and VT switches. There is no flickering.
* All configuration is done via a DBus interface, changed values are tested
on correctness and applied atomically
* Self contained mechanism, speaks directly to the hardware by setting the
gamma ramps on the CRTC
* Currently working on DRM backend, extensible to other platform backends in
the future
* The code is written in a way to make the classes later easily extendable to
also provide normal color correction, as it's currently done by KGamma on X
Test Plan:
Manually with the workspace parts and added integration tests in KWin using
the virtual backend.
BUG:371494
Reviewers: #kwin, graesslin
Subscribers: kwin, plasma-devel, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D5928
2017-12-11 09:43:12 +00:00
|
|
|
{
|
|
|
|
return m_manager->changeConfiguration(data);
|
|
|
|
}
|
|
|
|
|
2020-11-25 19:11:48 +00:00
|
|
|
void NightColorDBusInterface::nightColorAutoLocationUpdate(double latitude, double longitude)
|
[colorcorrection] Night Color - blue light filter at nighttime
With Wayland KWin needs to provide certain services, which were provided
before that by the Xserver. One of these is gamma correction, which includes
the - by many people beloved - functionality to reduce the blue light at
nighttime. This patch provides the KWin part of that. It is self contained,
but in the end will work in tandem with a lib in Plasma Workspace and a KCM
in Plasma Desktop, which can be used to configure Night Color.
* Three modi:
** Automatic: The location and sun timings are determined automatically
(location data updates will be provided by the workspace)
** Location: The sun timings are determined by fixed location data
** Timings: The sun timings are set manually by the user
* Color temperature value changes are smoothly applied:
** Configuration changes, which lead to other current values are changed
in a quick way over a few seconds
** Changes on sunrise and sunset are applied slowly over the course of few
minutes till several hours depending on the configuration
* The current color value is set immediately at startup or after suspend
phases and VT switches. There is no flickering.
* All configuration is done via a DBus interface, changed values are tested
on correctness and applied atomically
* Self contained mechanism, speaks directly to the hardware by setting the
gamma ramps on the CRTC
* Currently working on DRM backend, extensible to other platform backends in
the future
* The code is written in a way to make the classes later easily extendable to
also provide normal color correction, as it's currently done by KGamma on X
Test Plan:
Manually with the workspace parts and added integration tests in KWin using
the virtual backend.
BUG:371494
Reviewers: #kwin, graesslin
Subscribers: kwin, plasma-devel, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D5928
2017-12-11 09:43:12 +00:00
|
|
|
{
|
|
|
|
m_manager->autoLocationUpdate(latitude, longitude);
|
|
|
|
}
|
|
|
|
|
2020-11-25 19:11:48 +00:00
|
|
|
uint NightColorDBusInterface::inhibit()
|
2020-01-07 15:09:55 +00:00
|
|
|
{
|
|
|
|
const QString serviceName = QDBusContext::message().service();
|
|
|
|
|
2020-01-19 16:13:42 +00:00
|
|
|
if (!m_inhibitors.contains(serviceName)) {
|
2020-01-07 15:09:55 +00:00
|
|
|
m_inhibitorWatcher->addWatchedService(serviceName);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_inhibitors.insert(serviceName, ++m_lastInhibitionCookie);
|
|
|
|
|
|
|
|
m_manager->inhibit();
|
|
|
|
|
|
|
|
return m_lastInhibitionCookie;
|
|
|
|
}
|
|
|
|
|
2020-11-25 19:11:48 +00:00
|
|
|
void NightColorDBusInterface::uninhibit(uint cookie)
|
2020-01-07 15:09:55 +00:00
|
|
|
{
|
|
|
|
const QString serviceName = QDBusContext::message().service();
|
|
|
|
|
|
|
|
uninhibit(serviceName, cookie);
|
|
|
|
}
|
|
|
|
|
2020-11-25 19:11:48 +00:00
|
|
|
void NightColorDBusInterface::uninhibit(const QString &serviceName, uint cookie)
|
2020-01-07 15:09:55 +00:00
|
|
|
{
|
|
|
|
const int removedCount = m_inhibitors.remove(serviceName, cookie);
|
|
|
|
if (!removedCount) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-01-19 16:13:42 +00:00
|
|
|
if (!m_inhibitors.contains(serviceName)) {
|
2020-01-07 15:09:55 +00:00
|
|
|
m_inhibitorWatcher->removeWatchedService(serviceName);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_manager->uninhibit();
|
|
|
|
}
|
|
|
|
|
2020-11-25 19:11:48 +00:00
|
|
|
void NightColorDBusInterface::removeInhibitorService(const QString &serviceName)
|
2020-01-07 15:09:55 +00:00
|
|
|
{
|
|
|
|
const auto cookies = m_inhibitors.values(serviceName);
|
|
|
|
for (const uint &cookie : cookies) {
|
|
|
|
uninhibit(serviceName, cookie);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
[colorcorrection] Night Color - blue light filter at nighttime
With Wayland KWin needs to provide certain services, which were provided
before that by the Xserver. One of these is gamma correction, which includes
the - by many people beloved - functionality to reduce the blue light at
nighttime. This patch provides the KWin part of that. It is self contained,
but in the end will work in tandem with a lib in Plasma Workspace and a KCM
in Plasma Desktop, which can be used to configure Night Color.
* Three modi:
** Automatic: The location and sun timings are determined automatically
(location data updates will be provided by the workspace)
** Location: The sun timings are determined by fixed location data
** Timings: The sun timings are set manually by the user
* Color temperature value changes are smoothly applied:
** Configuration changes, which lead to other current values are changed
in a quick way over a few seconds
** Changes on sunrise and sunset are applied slowly over the course of few
minutes till several hours depending on the configuration
* The current color value is set immediately at startup or after suspend
phases and VT switches. There is no flickering.
* All configuration is done via a DBus interface, changed values are tested
on correctness and applied atomically
* Self contained mechanism, speaks directly to the hardware by setting the
gamma ramps on the CRTC
* Currently working on DRM backend, extensible to other platform backends in
the future
* The code is written in a way to make the classes later easily extendable to
also provide normal color correction, as it's currently done by KGamma on X
Test Plan:
Manually with the workspace parts and added integration tests in KWin using
the virtual backend.
BUG:371494
Reviewers: #kwin, graesslin
Subscribers: kwin, plasma-devel, #kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D5928
2017-12-11 09:43:12 +00:00
|
|
|
}
|