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
|
|
|
#include "kwin_wayland_test.h"
|
|
|
|
#include "platform.h"
|
|
|
|
#include "wayland_server.h"
|
2020-11-25 19:11:48 +00:00
|
|
|
|
|
|
|
#include "plugins/nightcolor/nightcolormanager.h"
|
|
|
|
#include "plugins/nightcolor/constants.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 <KConfigGroup>
|
|
|
|
|
|
|
|
using namespace KWin;
|
|
|
|
|
2020-11-25 19:11:48 +00:00
|
|
|
static const QString s_socketName = QStringLiteral("wayland_test_kwin_nightcolor-0");
|
[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
|
|
|
class NightColorTest : public QObject
|
[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
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
private Q_SLOTS:
|
|
|
|
void initTestCase();
|
|
|
|
void init();
|
|
|
|
void cleanup();
|
|
|
|
|
|
|
|
void testConfigRead_data();
|
|
|
|
void testConfigRead();
|
|
|
|
void testChangeConfiguration_data();
|
|
|
|
void testChangeConfiguration();
|
|
|
|
void testAutoLocationUpdate();
|
|
|
|
};
|
|
|
|
|
2020-11-25 19:11:48 +00:00
|
|
|
void NightColorTest::initTestCase()
|
[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-07-07 09:32:29 +00:00
|
|
|
QSignalSpy applicationStartedSpy(kwinApp(), &Application::started);
|
|
|
|
QVERIFY(applicationStartedSpy.isValid());
|
[autotests] Fix failing autotests
Summary:
After recent output-related changes testIdleInhibition and
testColorCorrectionNightColor started failing with the following output:
❯ dbus-run-session bin/testIdleInhibition
********* Start testing of TestIdleInhibition *********
Config: Using QtTest library 5.13.0, Qt 5.13.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 9.1.0)
QFATAL : TestIdleInhibition::initTestCase() ASSERT: "mode.size.isValid()" in file /home/vlad/Workspace/KDE/src/frameworks/kwayland/src/server/outputdevice_interface.cpp, line 188
FAIL! : TestIdleInhibition::initTestCase() Received a fatal error.
Loc: [Unknown file(0)]
Totals: 0 passed, 1 failed, 0 skipped, 0 blacklisted, 13ms
********* Finished testing of TestIdleInhibition ********
Apparently, they both don't initialize virtual outputs properly.
Reviewers: #kwin, romangg
Reviewed By: #kwin, romangg
Subscribers: romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D23539
2019-08-28 16:05:59 +00:00
|
|
|
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
|
2020-12-09 13:06:15 +00:00
|
|
|
QVERIFY(waylandServer()->init(s_socketName));
|
2019-08-26 21:16:53 +00:00
|
|
|
QMetaObject::invokeMethod(kwinApp()->platform(), "setVirtualOutputs", Qt::DirectConnection, Q_ARG(int, 2));
|
[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
|
|
|
|
|
|
|
kwinApp()->setConfig(KSharedConfig::openConfig(QString(), KConfig::SimpleConfig));
|
|
|
|
|
|
|
|
kwinApp()->start();
|
2020-07-07 09:32:29 +00:00
|
|
|
QVERIFY(applicationStartedSpy.wait());
|
2021-05-08 00:08:22 +00:00
|
|
|
Test::initWaylandWorkspace();
|
2020-11-25 19:11:48 +00:00
|
|
|
|
|
|
|
NightColorManager *manager = NightColorManager::self();
|
|
|
|
QVERIFY(manager);
|
[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
|
|
|
void NightColorTest::init()
|
[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
|
|
|
{
|
2018-11-30 11:36:57 +00:00
|
|
|
QVERIFY(Test::setupWaylandConnection());
|
[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
|
|
|
void NightColorTest::cleanup()
|
[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
|
|
|
{
|
2018-11-30 11:36:57 +00:00
|
|
|
Test::destroyWaylandConnection();
|
[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
|
|
|
void NightColorTest::testConfigRead_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
|
|
|
{
|
|
|
|
QTest::addColumn<QString>("active");
|
|
|
|
QTest::addColumn<int>("mode");
|
|
|
|
QTest::addColumn<int>("nightTemperature");
|
|
|
|
QTest::addColumn<double>("latitudeFixed");
|
|
|
|
QTest::addColumn<double>("longitudeFixed");
|
|
|
|
QTest::addColumn<QString>("morningBeginFixed");
|
|
|
|
QTest::addColumn<QString>("eveningBeginFixed");
|
|
|
|
QTest::addColumn<int>("transitionTime");
|
|
|
|
QTest::addColumn<bool>("success");
|
|
|
|
|
|
|
|
QTest::newRow("activeMode0") << "true" << 0 << 4500 << 45.5 << 35.1 << "0600" << "1800" << 30 << true;
|
|
|
|
QTest::newRow("activeMode1") << "true" << 1 << 2500 << -10.5 << -8. << "0020" << "2000" << 60 << true;
|
[colorcorrection] Add "Constant" mode
Summary:
Currently, the Night Color manager supports three operation modes:
* Automatic: in this mode, screen color temperature is computed based on
the current position of the Sun. In order to calculate sunrise & sunset
times, the manager needs coordinates of the user, which are provided by
Plasma;
* Location: this mode is very similar to the Automatic, except one minor
detail: user needs to provide his/her/their location. This mode can be
very useful if coordinates provided by Plasma are incorrect;
* Timings: unfortunately we can't compute timings of the Sun for people
living near Earth poles. This mode allows the user to specify timings of
sunrise and sunset as well the transition time.
This change introduces another mode, called Constant. With this mode the
screen color temperature is constant throughout the day. The new mode
can be useful for people wishing constant screen color temperature or
just for people living near Earth's North or South poles.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: ngraham, davidedmundson, romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D21948
2019-07-21 21:30:38 +00:00
|
|
|
QTest::newRow("activeMode2") << "true" << 3 << 3500 << 45.5 << 35.1 << "0600" << "1800" << 60 << true;
|
[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
|
|
|
QTest::newRow("notActiveMode2") << "false" << 2 << 5000 << 90. << -180. << "0600" << "1800" << 1 << true;
|
[colorcorrection] Add "Constant" mode
Summary:
Currently, the Night Color manager supports three operation modes:
* Automatic: in this mode, screen color temperature is computed based on
the current position of the Sun. In order to calculate sunrise & sunset
times, the manager needs coordinates of the user, which are provided by
Plasma;
* Location: this mode is very similar to the Automatic, except one minor
detail: user needs to provide his/her/their location. This mode can be
very useful if coordinates provided by Plasma are incorrect;
* Timings: unfortunately we can't compute timings of the Sun for people
living near Earth poles. This mode allows the user to specify timings of
sunrise and sunset as well the transition time.
This change introduces another mode, called Constant. With this mode the
screen color temperature is constant throughout the day. The new mode
can be useful for people wishing constant screen color temperature or
just for people living near Earth's North or South poles.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: ngraham, davidedmundson, romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D21948
2019-07-21 21:30:38 +00:00
|
|
|
QTest::newRow("wrongData1") << "fa" << 4 << 7000 << 91. << -181. << "060" << "800" << 999999 << false;
|
|
|
|
QTest::newRow("wrongData2") << "fa" << 4 << 7000 << 91. << -181. << "060" << "800" << -2 << false;
|
[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
|
|
|
void NightColorTest::testConfigRead()
|
[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
|
|
|
{
|
|
|
|
QFETCH(QString, active);
|
|
|
|
QFETCH(int, mode);
|
|
|
|
QFETCH(int, nightTemperature);
|
|
|
|
QFETCH(double, latitudeFixed);
|
|
|
|
QFETCH(double, longitudeFixed);
|
|
|
|
QFETCH(QString, morningBeginFixed);
|
|
|
|
QFETCH(QString, eveningBeginFixed);
|
|
|
|
QFETCH(int, transitionTime);
|
|
|
|
QFETCH(bool, success);
|
|
|
|
|
|
|
|
const bool activeDefault = true;
|
|
|
|
const int modeDefault = 0;
|
2020-11-25 19:11:48 +00:00
|
|
|
const int nightTemperatureUpperEnd = NEUTRAL_TEMPERATURE;
|
[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
|
|
|
const double latitudeFixedDefault = 0;
|
|
|
|
const double longitudeFixedDefault = 0;
|
|
|
|
const QTime morningBeginFixedDefault = QTime(6,0,0);
|
|
|
|
const QTime eveningBeginFixedDefault = QTime(18,0,0);
|
|
|
|
const int transitionTimeDefault = 30;
|
|
|
|
|
|
|
|
KConfigGroup cfgGroup = kwinApp()->config()->group("NightColor");
|
|
|
|
|
|
|
|
cfgGroup.writeEntry("Active", activeDefault);
|
|
|
|
cfgGroup.writeEntry("Mode", modeDefault);
|
|
|
|
cfgGroup.writeEntry("NightTemperature", nightTemperatureUpperEnd);
|
|
|
|
cfgGroup.writeEntry("LatitudeFixed", latitudeFixedDefault);
|
|
|
|
cfgGroup.writeEntry("LongitudeFixed", longitudeFixedDefault);
|
|
|
|
cfgGroup.writeEntry("MorningBeginFixed", morningBeginFixedDefault.toString("hhmm"));
|
|
|
|
cfgGroup.writeEntry("EveningBeginFixed", eveningBeginFixedDefault.toString("hhmm"));
|
|
|
|
cfgGroup.writeEntry("TransitionTime", transitionTimeDefault);
|
|
|
|
|
2020-11-25 19:11:48 +00:00
|
|
|
NightColorManager *manager = NightColorManager::self();
|
[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
|
|
|
manager->reparseConfigAndReset();
|
|
|
|
auto info = manager->info();
|
|
|
|
QVERIFY(!info.isEmpty());
|
|
|
|
|
|
|
|
QCOMPARE(info.value("Active").toBool(), activeDefault);
|
|
|
|
QCOMPARE(info.value("Mode").toInt(), modeDefault);
|
|
|
|
QCOMPARE(info.value("NightTemperature").toInt(), nightTemperatureUpperEnd);
|
|
|
|
QCOMPARE(info.value("LatitudeFixed").toDouble(), latitudeFixedDefault);
|
|
|
|
QCOMPARE(info.value("LongitudeFixed").toDouble(), longitudeFixedDefault);
|
|
|
|
QCOMPARE(QTime::fromString(info.value("MorningBeginFixed").toString(), Qt::ISODate), morningBeginFixedDefault);
|
|
|
|
QCOMPARE(QTime::fromString(info.value("EveningBeginFixed").toString(), Qt::ISODate), eveningBeginFixedDefault);
|
|
|
|
QCOMPARE(info.value("TransitionTime").toInt(), transitionTimeDefault);
|
|
|
|
|
|
|
|
cfgGroup.writeEntry("Active", active);
|
|
|
|
cfgGroup.writeEntry("Mode", mode);
|
|
|
|
cfgGroup.writeEntry("NightTemperature", nightTemperature);
|
|
|
|
cfgGroup.writeEntry("LatitudeFixed", latitudeFixed);
|
|
|
|
cfgGroup.writeEntry("LongitudeFixed", longitudeFixed);
|
|
|
|
cfgGroup.writeEntry("MorningBeginFixed", morningBeginFixed);
|
|
|
|
cfgGroup.writeEntry("EveningBeginFixed", eveningBeginFixed);
|
|
|
|
cfgGroup.writeEntry("TransitionTime", transitionTime);
|
|
|
|
|
|
|
|
manager->reparseConfigAndReset();
|
|
|
|
info = manager->info();
|
|
|
|
QVERIFY(!info.isEmpty());
|
|
|
|
|
|
|
|
if (success) {
|
|
|
|
QCOMPARE(info.value("Active").toBool() ? QString("true") : QString("false"), active);
|
|
|
|
QCOMPARE(info.value("Mode").toInt(), mode);
|
|
|
|
QCOMPARE(info.value("NightTemperature").toInt(), nightTemperature);
|
|
|
|
QCOMPARE(info.value("LatitudeFixed").toDouble(), latitudeFixed);
|
|
|
|
QCOMPARE(info.value("LongitudeFixed").toDouble(), longitudeFixed);
|
|
|
|
QCOMPARE(QTime::fromString(info.value("MorningBeginFixed").toString(), Qt::ISODate), QTime::fromString(morningBeginFixed, "hhmm"));
|
|
|
|
QCOMPARE(QTime::fromString(info.value("EveningBeginFixed").toString(), Qt::ISODate), QTime::fromString(eveningBeginFixed, "hhmm"));
|
|
|
|
QCOMPARE(info.value("TransitionTime").toInt(), transitionTime);
|
|
|
|
} else {
|
|
|
|
QCOMPARE(info.value("Active").toBool(), activeDefault);
|
|
|
|
QCOMPARE(info.value("Mode").toInt(), modeDefault);
|
|
|
|
QCOMPARE(info.value("NightTemperature").toInt(), nightTemperatureUpperEnd);
|
|
|
|
QCOMPARE(info.value("LatitudeFixed").toDouble(), latitudeFixedDefault);
|
|
|
|
QCOMPARE(info.value("LongitudeFixed").toDouble(), longitudeFixedDefault);
|
|
|
|
QCOMPARE(QTime::fromString(info.value("MorningBeginFixed").toString(), Qt::ISODate), morningBeginFixedDefault);
|
|
|
|
QCOMPARE(QTime::fromString(info.value("EveningBeginFixed").toString(), Qt::ISODate), eveningBeginFixedDefault);
|
|
|
|
QCOMPARE(info.value("TransitionTime").toInt(), transitionTimeDefault);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-25 19:11:48 +00:00
|
|
|
void NightColorTest::testChangeConfiguration_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
|
|
|
{
|
|
|
|
QTest::addColumn<bool>("activeReadIn");
|
|
|
|
QTest::addColumn<int>("modeReadIn");
|
|
|
|
QTest::addColumn<int>("nightTemperatureReadIn");
|
|
|
|
QTest::addColumn<double>("latitudeFixedReadIn");
|
|
|
|
QTest::addColumn<double>("longitudeFixedReadIn");
|
|
|
|
QTest::addColumn<QTime>("morBeginFixedReadIn");
|
|
|
|
QTest::addColumn<QTime>("eveBeginFixedReadIn");
|
|
|
|
QTest::addColumn<int>("transitionTimeReadIn");
|
|
|
|
QTest::addColumn<bool>("successReadIn");
|
|
|
|
|
|
|
|
QTest::newRow("data0") << true << 0 << 4500 << 45.5 << 35.1 << QTime(6,0,0) << QTime(18,0,0) << 30 << true;
|
|
|
|
QTest::newRow("data1") << true << 1 << 2500 << -10.5 << -8. << QTime(0,2,0) << QTime(20,0,0) << 60 << true;
|
|
|
|
QTest::newRow("data2") << false << 2 << 5000 << 90. << -180. << QTime(6,0,0) << QTime(19,1,1) << 1 << true;
|
[colorcorrection] Add "Constant" mode
Summary:
Currently, the Night Color manager supports three operation modes:
* Automatic: in this mode, screen color temperature is computed based on
the current position of the Sun. In order to calculate sunrise & sunset
times, the manager needs coordinates of the user, which are provided by
Plasma;
* Location: this mode is very similar to the Automatic, except one minor
detail: user needs to provide his/her/their location. This mode can be
very useful if coordinates provided by Plasma are incorrect;
* Timings: unfortunately we can't compute timings of the Sun for people
living near Earth poles. This mode allows the user to specify timings of
sunrise and sunset as well the transition time.
This change introduces another mode, called Constant. With this mode the
screen color temperature is constant throughout the day. The new mode
can be useful for people wishing constant screen color temperature or
just for people living near Earth's North or South poles.
Reviewers: #kwin, davidedmundson
Reviewed By: #kwin, davidedmundson
Subscribers: ngraham, davidedmundson, romangg, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D21948
2019-07-21 21:30:38 +00:00
|
|
|
QTest::newRow("data3") << false << 3 << 2000 << 90. << -180. << QTime(6,0,0) << QTime(18,0,0) << 1 << true;
|
|
|
|
QTest::newRow("wrongData0") << true << 4 << 4500 << 0. << 0. << QTime(6,0,0) << QTime(18,0,0) << 30 << false;
|
[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
|
|
|
QTest::newRow("wrongData1") << true << 0 << 500 << 0. << 0. << QTime(6,0,0) << QTime(18,0,0) << 30 << false;
|
|
|
|
QTest::newRow("wrongData2") << true << 0 << 7000 << 0. << 0. << QTime(6,0,0) << QTime(18,0,0) << 30 << false;
|
|
|
|
QTest::newRow("wrongData3") << true << 0 << 4500 << 91. << -181. << QTime(6,0,0) << QTime(18,0,0) << 30 << false;
|
|
|
|
QTest::newRow("wrongData4") << true << 0 << 4500 << 0. << 0. << QTime(18,0,0) << QTime(6,0,0) << 30 << false;
|
|
|
|
QTest::newRow("wrongData5") << true << 0 << 4500 << 0. << 0. << QTime(6,0,0) << QTime(18,0,0) << 0 << false;
|
|
|
|
QTest::newRow("wrongData6") << true << 0 << 4500 << 0. << 0. << QTime(6,0,0) << QTime(18,0,0) << -1 << false;
|
|
|
|
QTest::newRow("wrongData7") << true << 0 << 4500 << 0. << 0. << QTime(12,0,0) << QTime(12,30,0) << 30 << false;
|
|
|
|
QTest::newRow("wrongData8") << true << 0 << 4500 << 0. << 0. << QTime(1,0,0) << QTime(23,30,0) << 90 << false;
|
|
|
|
}
|
|
|
|
|
2020-11-25 19:11:48 +00:00
|
|
|
void NightColorTest::testChangeConfiguration()
|
[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
|
|
|
{
|
|
|
|
QFETCH(bool, activeReadIn);
|
|
|
|
QFETCH(int, modeReadIn);
|
|
|
|
QFETCH(int, nightTemperatureReadIn);
|
|
|
|
QFETCH(double, latitudeFixedReadIn);
|
|
|
|
QFETCH(double, longitudeFixedReadIn);
|
|
|
|
QFETCH(QTime, morBeginFixedReadIn);
|
|
|
|
QFETCH(QTime, eveBeginFixedReadIn);
|
|
|
|
QFETCH(int, transitionTimeReadIn);
|
|
|
|
QFETCH(bool, successReadIn);
|
|
|
|
|
|
|
|
const bool activeDefault = true;
|
|
|
|
const int modeDefault = 0;
|
2020-11-25 19:11:48 +00:00
|
|
|
const int nightTemperatureDefault = DEFAULT_NIGHT_TEMPERATURE;
|
[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
|
|
|
const double latitudeFixedDefault = 0;
|
|
|
|
const double longitudeFixedDefault = 0;
|
|
|
|
const QTime morningBeginFixedDefault = QTime(6,0,0);
|
|
|
|
const QTime eveningBeginFixedDefault = QTime(18,0,0);
|
|
|
|
const int transitionTimeDefault = 30;
|
|
|
|
|
|
|
|
// init with default values
|
|
|
|
bool active = activeDefault;
|
|
|
|
int mode = modeDefault;
|
|
|
|
int nightTemperature = nightTemperatureDefault;
|
|
|
|
double latitudeFixed = latitudeFixedDefault;
|
|
|
|
double longitudeFixed = longitudeFixedDefault;
|
|
|
|
QTime morningBeginFixed = morningBeginFixedDefault;
|
|
|
|
QTime eveningBeginFixed = eveningBeginFixedDefault;
|
|
|
|
int transitionTime = transitionTimeDefault;
|
|
|
|
|
|
|
|
bool activeExpect = activeDefault;
|
|
|
|
int modeExpect = modeDefault;
|
|
|
|
int nightTemperatureExpect = nightTemperatureDefault;
|
|
|
|
double latitudeFixedExpect = latitudeFixedDefault;
|
|
|
|
double longitudeFixedExpect = longitudeFixedDefault;
|
|
|
|
QTime morningBeginFixedExpect = morningBeginFixedDefault;
|
|
|
|
QTime eveningBeginFixedExpect = eveningBeginFixedDefault;
|
|
|
|
int transitionTimeExpect = transitionTimeDefault;
|
|
|
|
|
|
|
|
QHash<QString, QVariant> data;
|
|
|
|
|
|
|
|
auto setData = [&active, &mode, &nightTemperature,
|
|
|
|
&latitudeFixed, &longitudeFixed,
|
|
|
|
&morningBeginFixed, &eveningBeginFixed, &transitionTime,
|
|
|
|
&data]() {
|
|
|
|
data["Active"] = active;
|
|
|
|
data["Mode"] = mode;
|
|
|
|
data["NightTemperature"] = nightTemperature;
|
|
|
|
|
|
|
|
data["LatitudeFixed"] = latitudeFixed;
|
|
|
|
data["LongitudeFixed"] = longitudeFixed;
|
|
|
|
|
|
|
|
data["MorningBeginFixed"] = morningBeginFixed.toString(Qt::ISODate);
|
|
|
|
data["EveningBeginFixed"] = eveningBeginFixed.toString(Qt::ISODate);
|
|
|
|
data["TransitionTime"] = transitionTime;
|
|
|
|
};
|
|
|
|
|
|
|
|
auto compareValues = [&activeExpect, &modeExpect, &nightTemperatureExpect,
|
|
|
|
&latitudeFixedExpect, &longitudeFixedExpect,
|
|
|
|
&morningBeginFixedExpect, &eveningBeginFixedExpect,
|
|
|
|
&transitionTimeExpect](QHash<QString, QVariant> info) {
|
|
|
|
QCOMPARE(info.value("Active").toBool(), activeExpect);
|
|
|
|
QCOMPARE(info.value("Mode").toInt(), modeExpect);
|
|
|
|
QCOMPARE(info.value("NightTemperature").toInt(), nightTemperatureExpect);
|
|
|
|
QCOMPARE(info.value("LatitudeFixed").toDouble(), latitudeFixedExpect);
|
|
|
|
QCOMPARE(info.value("LongitudeFixed").toDouble(), longitudeFixedExpect);
|
|
|
|
QCOMPARE(info.value("MorningBeginFixed").toString(), morningBeginFixedExpect.toString(Qt::ISODate));
|
|
|
|
QCOMPARE(info.value("EveningBeginFixed").toString(), eveningBeginFixedExpect.toString(Qt::ISODate));
|
|
|
|
QCOMPARE(info.value("TransitionTime").toInt(), transitionTimeExpect);
|
|
|
|
};
|
|
|
|
|
2020-11-25 19:11:48 +00:00
|
|
|
NightColorManager *manager = NightColorManager::self();
|
[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
|
|
|
|
|
|
|
// test with default values
|
|
|
|
setData();
|
|
|
|
manager->changeConfiguration(data);
|
|
|
|
compareValues(manager->info());
|
|
|
|
|
|
|
|
// set to test values
|
|
|
|
active = activeReadIn;
|
|
|
|
mode = modeReadIn;
|
|
|
|
nightTemperature = nightTemperatureReadIn;
|
|
|
|
latitudeFixed = latitudeFixedReadIn;
|
|
|
|
longitudeFixed = longitudeFixedReadIn;
|
|
|
|
morningBeginFixed = morBeginFixedReadIn;
|
|
|
|
eveningBeginFixed = eveBeginFixedReadIn;
|
|
|
|
transitionTime = transitionTimeReadIn;
|
|
|
|
|
|
|
|
if (successReadIn) {
|
|
|
|
activeExpect = activeReadIn;
|
|
|
|
modeExpect = modeReadIn;
|
|
|
|
nightTemperatureExpect = nightTemperatureReadIn;
|
|
|
|
latitudeFixedExpect = latitudeFixedReadIn;
|
|
|
|
longitudeFixedExpect = longitudeFixedReadIn;
|
|
|
|
morningBeginFixedExpect = morBeginFixedReadIn;
|
|
|
|
eveningBeginFixedExpect = eveBeginFixedReadIn;
|
|
|
|
transitionTimeExpect = transitionTimeReadIn;
|
|
|
|
}
|
|
|
|
|
|
|
|
// test with test values
|
|
|
|
setData();
|
|
|
|
QCOMPARE(manager->changeConfiguration(data), successReadIn);
|
|
|
|
compareValues(manager->info());
|
|
|
|
}
|
|
|
|
|
2020-11-25 19:11:48 +00:00
|
|
|
void NightColorTest::testAutoLocationUpdate()
|
[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
|
|
|
NightColorManager *manager = NightColorManager::self();
|
[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
|
|
|
auto info = manager->info();
|
|
|
|
QCOMPARE(info.value("LatitudeAuto").toDouble(), 0.);
|
|
|
|
QCOMPARE(info.value("LongitudeAuto").toDouble(), 0.);
|
|
|
|
|
|
|
|
// wrong latitude value
|
|
|
|
manager->autoLocationUpdate(91, 15);
|
|
|
|
info = manager->info();
|
|
|
|
QCOMPARE(info.value("LatitudeAuto").toDouble(), 0.);
|
|
|
|
QCOMPARE(info.value("LongitudeAuto").toDouble(), 0.);
|
|
|
|
|
|
|
|
// wrong longitude value
|
|
|
|
manager->autoLocationUpdate(50, -181);
|
|
|
|
info = manager->info();
|
|
|
|
QCOMPARE(info.value("LatitudeAuto").toDouble(), 0.);
|
|
|
|
QCOMPARE(info.value("LongitudeAuto").toDouble(), 0.);
|
|
|
|
|
|
|
|
// change
|
|
|
|
manager->autoLocationUpdate(50, -180);
|
|
|
|
info = manager->info();
|
|
|
|
QCOMPARE(info.value("LatitudeAuto").toDouble(), 50.);
|
|
|
|
QCOMPARE(info.value("LongitudeAuto").toDouble(), -180.);
|
|
|
|
|
|
|
|
// small deviation only
|
|
|
|
manager->autoLocationUpdate(51.5, -179.5);
|
|
|
|
info = manager->info();
|
|
|
|
QCOMPARE(info.value("LongitudeAuto").toDouble(), -180.);
|
|
|
|
QCOMPARE(info.value("LatitudeAuto").toDouble(), 50.);
|
|
|
|
}
|
|
|
|
|
2020-11-25 19:11:48 +00:00
|
|
|
WAYLANDTEST_MAIN(NightColorTest)
|
|
|
|
#include "nightcolor_test.moc"
|