Commit 82d28604 authored by Roman Gilg's avatar Roman Gilg

[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
parent c9023582
......@@ -471,6 +471,9 @@ set(kwin_KDEINIT_SRCS
xkb.cpp
gestures.cpp
popup_input_filter.cpp
colorcorrection/manager.cpp
colorcorrection/colorcorrectdbusinterface.cpp
colorcorrection/suncalc.cpp
abstract_opengl_context_attribute_builder.cpp
egl_context_attribute_builder.cpp
was_user_interaction_x11_filter.cpp
......@@ -481,6 +484,18 @@ set(kwin_KDEINIT_SRCS
idle_inhibition.cpp
)
include(ECMQtDeclareLoggingCategory)
ecm_qt_declare_logging_category(kwin_KDEINIT_SRCS
HEADER
colorcorrect_logging.h
IDENTIFIER
KWIN_COLORCORRECTION
CATEGORY_NAME
kwin_colorcorrection
DEFAULT_SEVERITY
Critical
)
if(KWIN_BUILD_TABBOX)
set(
kwin_KDEINIT_SRCS ${kwin_KDEINIT_SRCS}
......@@ -528,9 +543,11 @@ if(HAVE_INPUT)
endif()
kconfig_add_kcfg_files(kwin_KDEINIT_SRCS settings.kcfgc)
kconfig_add_kcfg_files(kwin_KDEINIT_SRCS colorcorrection/colorcorrect_settings.kcfgc)
qt5_add_dbus_adaptor( kwin_KDEINIT_SRCS org.kde.KWin.xml dbusinterface.h KWin::DBusInterface )
qt5_add_dbus_adaptor( kwin_KDEINIT_SRCS org.kde.kwin.Compositing.xml dbusinterface.h KWin::CompositorDBusInterface )
qt5_add_dbus_adaptor( kwin_KDEINIT_SRCS org.kde.kwin.ColorCorrect.xml colorcorrection/colorcorrectdbusinterface.h KWin::ColorCorrect::ColorCorrectDBusInterface )
qt5_add_dbus_adaptor( kwin_KDEINIT_SRCS ${kwin_effects_dbus_xml} effects.h KWin::EffectsHandlerImpl )
qt5_add_dbus_interface( kwin_KDEINIT_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/org.freedesktop.ScreenSaver.xml screenlocker_interface)
......@@ -668,11 +685,13 @@ add_subdirectory(plugins)
########### install files ###############
install( FILES kwin.kcfg DESTINATION ${KCFG_INSTALL_DIR} RENAME ${KWIN_NAME}.kcfg )
install( FILES colorcorrection/colorcorrect_settings.kcfg DESTINATION ${KCFG_INSTALL_DIR} RENAME ${KWIN_NAME}_colorcorrect.kcfg )
install( FILES kwin.notifyrc DESTINATION ${KNOTIFYRC_INSTALL_DIR} RENAME ${KWIN_NAME}.notifyrc)
install(
FILES
org.kde.KWin.xml
org.kde.kwin.Compositing.xml
org.kde.kwin.ColorCorrect.xml
org.kde.kwin.Effects.xml
DESTINATION
${KDE_INSTALL_DBUSINTERFACEDIR}
......
......@@ -54,6 +54,7 @@ integrationTest(WAYLAND_ONLY NAME testKWinBindings SRCS kwinbindings_test.cpp)
integrationTest(WAYLAND_ONLY NAME testVirtualDesktop SRCS virtual_desktop_test.cpp)
integrationTest(WAYLAND_ONLY NAME testShellClientRules SRCS shell_client_rules_test.cpp)
integrationTest(WAYLAND_ONLY NAME testIdleInhibition SRCS idle_inhibition_test.cpp)
integrationTest(WAYLAND_ONLY NAME testColorCorrectNightColor SRCS colorcorrect_nightcolor_test.cpp)
if (XCB_ICCCM_FOUND)
integrationTest(NAME testMoveResize SRCS move_resize_window_test.cpp LIBS XCB::ICCCM)
......
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright 2017 Roman Gilg <subdiff@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "kwin_wayland_test.h"
#include "platform.h"
#include "wayland_server.h"
#include "colorcorrection/manager.h"
#include "colorcorrection/constants.h"
#include <KConfigGroup>
using namespace KWin;
static const QString s_socketName = QStringLiteral("wayland_test_kwin_colorcorrect_nightcolor-0");
class ColorCorrectNightColorTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void initTestCase();
void init();
void cleanup();
void testConfigRead_data();
void testConfigRead();
void testChangeConfiguration_data();
void testChangeConfiguration();
void testAutoLocationUpdate();
};
void ColorCorrectNightColorTest::initTestCase()
{
QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated);
QVERIFY(workspaceCreatedSpy.isValid());
QMetaObject::invokeMethod(kwinApp()->platform(), "setOutputCount", Qt::DirectConnection, Q_ARG(int, 2));
QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit()));
kwinApp()->setConfig(KSharedConfig::openConfig(QString(), KConfig::SimpleConfig));
kwinApp()->start();
QVERIFY(workspaceCreatedSpy.wait());
waylandServer()->initWorkspace();
}
void ColorCorrectNightColorTest::init()
{
}
void ColorCorrectNightColorTest::cleanup()
{
}
void ColorCorrectNightColorTest::testConfigRead_data()
{
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;
QTest::newRow("notActiveMode2") << "false" << 2 << 5000 << 90. << -180. << "0600" << "1800" << 1 << true;
QTest::newRow("wrongData1") << "fa" << 3 << 7000 << 91. << -181. << "060" << "800" << 999999 << false;
QTest::newRow("wrongData2") << "fa" << 3 << 7000 << 91. << -181. << "060" << "800" << -2 << false;
}
void ColorCorrectNightColorTest::testConfigRead()
{
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;
const int nightTemperatureUpperEnd = ColorCorrect::NEUTRAL_TEMPERATURE;
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);
ColorCorrect::Manager *manager = kwinApp()->platform()->colorCorrectManager();
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);
}
}
void ColorCorrectNightColorTest::testChangeConfiguration_data()
{
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;
QTest::newRow("wrongData0") << true << 3 << 4500 << 0. << 0. << QTime(6,0,0) << QTime(18,0,0) << 30 << false;
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;
}
void ColorCorrectNightColorTest::testChangeConfiguration()
{
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;
const int nightTemperatureDefault = ColorCorrect::DEFAULT_NIGHT_TEMPERATURE;
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);
};
ColorCorrect::Manager *manager = kwinApp()->platform()->colorCorrectManager();
// 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());
}
void ColorCorrectNightColorTest::testAutoLocationUpdate()
{
ColorCorrect::Manager *manager = kwinApp()->platform()->colorCorrectManager();
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.);
}
WAYLANDTEST_MAIN(ColorCorrectNightColorTest)
#include "colorcorrect_nightcolor_test.moc"
<?xml version="1.0" encoding="UTF-8" ?>
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile arg="true" />
<group name="NightColor">
<entry name="ActiveEnabled" type="Bool">
<default>true</default>
</entry>
<entry name="Active" type="Bool">
<default>false</default>
</entry>
<entry name="ModeEnabled" type="Bool">
<default>true</default>
</entry>
<entry name="Mode" type="Enum">
<choices name="KWin::ColorCorrect::NightColorMode">
<choice name="Automatic"/>
<choice name="Location"/>
<choice name="Times"/>
</choices>
<default>NightColorMode::Automatic</default>
</entry>
<entry name="NightTemperatureEnabled" type="Bool">
<default>true</default>
</entry>
<entry name="NightTemperature" type="Int">
<default>4500</default>
</entry>
<entry name="LatitudeAuto" type="Double">
<default>0.</default>
</entry>
<entry name="LongitudeAuto" type="Double">
<default>0.</default>
</entry>
<entry name="LocationEnabled" type="Bool">
<default>true</default>
</entry>
<entry name="LatitudeFixed" type="Double">
<default>0.</default>
</entry>
<entry name="LongitudeFixed" type="Double">
<default>0.</default>
</entry>
<entry name="MorningBeginFixed" type="String">
<default>"0600"</default>
</entry>
<entry name="EveningBeginFixed" type="String">
<default>"1800"</default>
</entry>
<entry name="TransitionTime" type="Int">
<default>30</default>
</entry>
</group>
</kcfg>
File=colorcorrect_settings.kcfg
NameSpace=KWin::ColorCorrect
ClassName=Settings
Singleton=true
Mutators=true
# manager.h is needed for NightColorMode
IncludeFiles=colorcorrection/manager.h
UseEnumTypes=true
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright 2017 Roman Gilg <subdiff@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "colorcorrectdbusinterface.h"
#include "colorcorrectadaptor.h"
#include "manager.h"
namespace KWin {
namespace ColorCorrect {
ColorCorrectDBusInterface::ColorCorrectDBusInterface(Manager *parent)
: QObject(parent)
, m_manager(parent)
{
connect(m_manager, &Manager::configChange, this, &ColorCorrectDBusInterface::nightColorConfigChanged);
new ColorCorrectAdaptor(this);
QDBusConnection::sessionBus().registerObject(QStringLiteral("/ColorCorrect"), this);
}
QHash<QString, QVariant> ColorCorrectDBusInterface::nightColorInfo()
{
return m_manager->info();
}
bool ColorCorrectDBusInterface::setNightColorConfig(QHash<QString, QVariant> data)
{
return m_manager->changeConfiguration(data);
}
void ColorCorrectDBusInterface::nightColorAutoLocationUpdate(double latitude, double longitude)
{
m_manager->autoLocationUpdate(latitude, longitude);
}
}
}
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright 2017 Roman Gilg <subdiff@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#ifndef KWIN_NIGHTCOLOR_DBUS_INTERFACE_H
#define KWIN_NIGHTCOLOR_DBUS_INTERFACE_H
#include <QObject>
#include <QtDBus/QtDBus>
namespace KWin
{
namespace ColorCorrect
{
class Manager;
class ColorCorrectDBusInterface : public QObject
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.kwin.ColorCorrect")
public:
explicit ColorCorrectDBusInterface(Manager *parent);
virtual ~ColorCorrectDBusInterface() = default;
public Q_SLOTS:
/**
* @brief Gives information about the current state of Night Color.
*
* The returned variant hash has always the fields:
* - ActiveEnabled
* - Active
* - Mode
* - NightTemperatureEnabled
* - NightTemperature
* - Running
* - CurrentColorTemperature
* - LatitudeAuto
* - LongitudeAuto
* - LocationEnabled
* - LatitudeFixed
* - LongitudeFixed
* - TimingsEnabled
* - MorningBeginFixed
* - EveningBeginFixed