Hello community,

here is the log from the commit of package libkscreen2 for openSUSE:Factory 
checked in at 2015-12-29 12:57:07
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/libkscreen2 (Old)
 and      /work/SRC/openSUSE:Factory/.libkscreen2.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "libkscreen2"

Changes:
--------
--- /work/SRC/openSUSE:Factory/libkscreen2/libkscreen2.changes  2015-11-24 
22:27:15.000000000 +0100
+++ /work/SRC/openSUSE:Factory/.libkscreen2.new/libkscreen2.changes     
2015-12-29 12:57:08.000000000 +0100
@@ -1,0 +2,16 @@
+Tue Dec 15 17:49:56 UTC 2015 - hrvoje.sen...@gmail.com
+
+- Update to 5.5.1:
+  * Bugfix release
+  * For more details please see:
+    https://www.kde.org/announcements/plasma-5.5.1.php
+
+-------------------------------------------------------------------
+Sat Dec 12 17:32:08 UTC 2015 - hrvoje.sen...@gmail.com
+
+- Update to 5.5.0:
+  * For more details please see:
+    https://dot.kde.org/2015/12/08/plasma-55-beautiful-new-artwork
+- Move to cmake(...) BuildRequires where possible
+
+-------------------------------------------------------------------

Old:
----
  libkscreen-5.4.3.tar.xz

New:
----
  libkscreen-5.5.1.tar.xz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ libkscreen2.spec ++++++
--- /var/tmp/diff_new_pack.A7BzyC/_old  2015-12-29 12:57:09.000000000 +0100
+++ /var/tmp/diff_new_pack.A7BzyC/_new  2015-12-29 12:57:09.000000000 +0100
@@ -19,23 +19,19 @@
 %define lname   libKF5Screen6
 %define plasma_version 5.0.0
 Name:           libkscreen2
-Version:        5.4.3
+Version:        5.5.1
 Release:        0
 BuildRequires:  cmake >= 2.8.12
-BuildRequires:  extra-cmake-modules >= 0.0.12
+BuildRequires:  extra-cmake-modules >= 5.14.0
 BuildRequires:  fdupes
 BuildRequires:  kf5-filesystem
-BuildRequires:  libxcb-devel
-BuildRequires:  xcb-util-devel
-BuildRequires:  pkgconfig(Qt5Core) >= 5.4.0
-BuildRequires:  pkgconfig(Qt5DBus) >= 5.4.0
-BuildRequires:  pkgconfig(Qt5Gui) >= 5.4.0
-BuildRequires:  pkgconfig(Qt5Test) >= 5.4.0
-BuildRequires:  pkgconfig(Qt5X11Extras) >= 5.4.0
-BuildRequires:  pkgconfig(xcb-image)
-BuildRequires:  pkgconfig(xcb-keysyms)
-BuildRequires:  pkgconfig(xcursor)
-BuildRequires:  pkgconfig(xrandr)
+BuildRequires:  cmake(Qt5Core) >= 5.4.0
+BuildRequires:  cmake(Qt5DBus) >= 5.4.0
+BuildRequires:  cmake(Qt5Gui) >= 5.4.0
+BuildRequires:  cmake(Qt5Test) >= 5.4.0
+BuildRequires:  cmake(Qt5X11Extras) >= 5.4.0
+BuildRequires:  pkgconfig(xcb)
+BuildRequires:  pkgconfig(xcb-randr)
 Summary:        KDE's screen management library
 License:        GPL-2.0+
 Group:          System/GUI/KDE
@@ -59,7 +55,7 @@
 Summary:        KDE's screen management library (development package)
 Group:          Development/Libraries/C and C++
 Requires:       %{lname} = %{version}
-Requires:       pkgconfig(Qt5Core) >= 5.4.0
+Requires:       cmake(Qt5Core) >= 5.4.0
 
 %description devel
 Development files belonging to libkscreen, dynamic display management in KDE
@@ -92,6 +88,7 @@
 %doc COPYING*
 %{_kf5_plugindir}/
 %{_kf5_libexecdir}/
+%{_kf5_sharedir}/dbus-1/services/org.kde.kscreen.service
 
 %files -n %{lname}
 %defattr(-,root,root)

++++++ libkscreen-5.4.3.tar.xz -> libkscreen-5.5.1.tar.xz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libkscreen-5.4.3/CMakeLists.txt 
new/libkscreen-5.5.1/CMakeLists.txt
--- old/libkscreen-5.4.3/CMakeLists.txt 2015-11-05 13:40:57.000000000 +0100
+++ new/libkscreen-5.5.1/CMakeLists.txt 2015-12-15 11:26:53.000000000 +0100
@@ -1,9 +1,9 @@
-project(libkscreen)
-set(PROJECT_VERSION "5.4.3")
-
 cmake_minimum_required(VERSION 2.8.12)
 
-find_package(ECM 1.3.0 REQUIRED NO_MODULE)
+project(libkscreen)
+set(PROJECT_VERSION "5.5.1")
+
+find_package(ECM 5.14.0 REQUIRED NO_MODULE)
 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} 
${ECM_KDE_MODULE_DIR})
 include(KDEInstallDirs)
 include(KDECompilerSettings)
@@ -12,6 +12,7 @@
 include(ECMPackageConfigHelpers)
 include(ECMMarkAsTest)
 include(ECMGenerateHeaders)
+include(ECMQtDeclareLoggingCategory)
 include(FeatureSummary)
 include(CheckCXXCompilerFlag)
 
@@ -40,8 +41,6 @@
   endif (_HAVE_VISIBILITY_INLINES)
 endif (_HAVE_VISIBILITY AND NOT WIN32)
 
-# include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} 
${CMAKE_CURRENT_BINARY_DIR})
-
 add_subdirectory(src)
 add_subdirectory(backends)
 add_subdirectory(autotests)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libkscreen-5.4.3/autotests/CMakeLists.txt 
new/libkscreen-5.5.1/autotests/CMakeLists.txt
--- old/libkscreen-5.4.3/autotests/CMakeLists.txt       2015-11-05 
13:40:57.000000000 +0100
+++ new/libkscreen-5.5.1/autotests/CMakeLists.txt       2015-12-15 
11:26:53.000000000 +0100
@@ -8,7 +8,9 @@
         qt5_add_dbus_interface(test_SRCS 
${CMAKE_SOURCE_DIR}/interfaces/org.kde.KScreen.FakeBackend.xml 
fakebackendinterface)
         add_executable(${_testname} ${test_SRCS})
         target_link_libraries(${_testname} Qt5::Core Qt5::Gui Qt5::Test 
Qt5::DBus KF5::Screen)
-        add_test(kscreen-${_testname} ${_testname})
+        add_test(NAME kscreen-${_testname}
+                 COMMAND dbus-launch $<TARGET_FILE:${_testname}>
+        )
         ecm_mark_as_test(${_testname})
     endforeach(_testname)
 endmacro(KSCREEN_ADD_TEST)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libkscreen-5.4.3/autotests/testconfigmonitor.cpp 
new/libkscreen-5.5.1/autotests/testconfigmonitor.cpp
--- old/libkscreen-5.4.3/autotests/testconfigmonitor.cpp        2015-11-05 
13:40:57.000000000 +0100
+++ new/libkscreen-5.5.1/autotests/testconfigmonitor.cpp        2015-12-15 
11:26:53.000000000 +0100
@@ -64,9 +64,7 @@
     void testChangeNotify()
     {
         //json file for the fake backend
-        QByteArray path(TEST_DATA);
-        path.append("/singleoutput.json");
-        setenv("TEST_DATA", path, 1);
+        qputenv("KSCREEN_BACKEND_ARGS", "TEST_DATA=" TEST_DATA 
"singleoutput.json");
 
         // Prepare monitor
         KScreen::ConfigMonitor *monitor = KScreen::ConfigMonitor::instance();
@@ -78,7 +76,7 @@
         QSignalSpy enabledSpy(config->output(1).data(), 
SIGNAL(isEnabledChanged()));
 
 
-        auto iface = new 
org::kde::kscreen::FakeBackend(QLatin1String("org.kde.KScreen.Backend.Fake"),
+        auto iface = new 
org::kde::kscreen::FakeBackend(QLatin1String("org.kde.KScreen"),
                                                         QLatin1String("/fake"),
                                                         
QDBusConnection::sessionBus());
         QVERIFY(iface->isValid());
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libkscreen-5.4.3/autotests/testscreenconfig.cpp 
new/libkscreen-5.5.1/autotests/testscreenconfig.cpp
--- old/libkscreen-5.4.3/autotests/testscreenconfig.cpp 2015-11-05 
13:40:57.000000000 +0100
+++ new/libkscreen-5.5.1/autotests/testscreenconfig.cpp 2015-12-15 
11:26:53.000000000 +0100
@@ -50,6 +50,7 @@
     GetConfigOperation *op = new GetConfigOperation();
     if (!op->exec()) {
         qWarning("GetConfigOperation error: %s", 
qPrintable(op->errorString()));
+        BackendManager::instance()->shutdownBackend();
         return ConfigPtr();
     }
 
@@ -72,9 +73,7 @@
 void testScreenConfig::singleOutput()
 {
     //json file for the fake backend
-    QByteArray path(TEST_DATA);
-    path.append("/singleoutput.json");
-    setenv("TEST_DATA", path, 1);
+    qputenv("KSCREEN_BACKEND_ARGS", "TEST_DATA=" TEST_DATA 
"singleoutput.json");
 
 //     QVERIFY2(kscreen, KScreen::errorString().toLatin1());
 
@@ -117,9 +116,7 @@
 
 void testScreenConfig::singleOutputWithoutPreferred()
 {
-    QByteArray path(TEST_DATA);
-    path.append("/singleOutputWithoutPreferred.json");
-    setenv("TEST_DATA", path, 1);
+    qputenv("KSCREEN_BACKEND_ARGS", "TEST_DATA=" TEST_DATA 
"singleOutputWithoutPreferred.json");
 
     const ConfigPtr config = getConfig();
     QVERIFY(!config.isNull());
@@ -132,9 +129,7 @@
 
 void testScreenConfig::multiOutput()
 {
-    QByteArray path(TEST_DATA);
-    path.append("/multipleoutput.json");
-    setenv("TEST_DATA", path, 1);
+    qputenv("KSCREEN_BACKEND_ARGS", "TEST_DATA=" TEST_DATA 
"multipleoutput.json");
 
     const ConfigPtr config = getConfig();
     QVERIFY(!config.isNull());
@@ -171,9 +166,7 @@
 
 void testScreenConfig::clonesOutput()
 {
-    QByteArray path(TEST_DATA);
-    path.append("/multipleclone.json");
-    setenv("TEST_DATA", path, 1);
+    qputenv("KSCREEN_BACKEND_ARGS", "TEST_DATA=" TEST_DATA 
"multipleclone.json");
 
     const ConfigPtr config = getConfig();
     QVERIFY(!config.isNull());
@@ -195,14 +188,10 @@
 
 void testScreenConfig::configCanBeApplied()
 {
-    QByteArray path(TEST_DATA);
-    path.append("/singleoutputBroken.json");
-    setenv("TEST_DATA", path, 1);
+    qputenv("KSCREEN_BACKEND_ARGS", "TEST_DATA=" TEST_DATA 
"singleoutputBroken.json");
     const ConfigPtr brokenConfig = getConfig();
 
-    path = TEST_DATA;
-    path.append("/singleoutput.json");
-    setenv("TEST_DATA", path, 1);
+    qputenv("KSCREEN_BACKEND_ARGS", "TEST_DATA=" TEST_DATA 
"singleoutput.json");
     const ConfigPtr currentConfig = getConfig();
     QVERIFY(!currentConfig.isNull());
     const OutputPtr primaryBroken = brokenConfig->outputs()[2];
@@ -223,9 +212,7 @@
     QVERIFY(Config::canBeApplied(brokenConfig));
 
 
-    path = TEST_DATA;
-    path.append("/tooManyOutputs.json");
-    setenv("TEST_DATA", path, 1);
+    qputenv("KSCREEN_BACKEND_ARGS", "TEST_DATA=" TEST_DATA 
"tooManyOutputs.json");
     const ConfigPtr brokenConfig2 = getConfig();
     QVERIFY(!brokenConfig2.isNull());
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libkscreen-5.4.3/backends/fake/fake.cpp 
new/libkscreen-5.5.1/backends/fake/fake.cpp
--- old/libkscreen-5.4.3/backends/fake/fake.cpp 2015-11-05 13:40:57.000000000 
+0100
+++ new/libkscreen-5.5.1/backends/fake/fake.cpp 2015-12-15 11:26:53.000000000 
+0100
@@ -48,6 +48,12 @@
     QTimer::singleShot(0, this, SLOT(delayedInit()));
 }
 
+void Fake::init(const QVariantMap &arguments)
+{
+    mConfigFile = arguments[QStringLiteral("TEST_DATA")].toString();
+    qCDebug(KSCREEN_FAKE) << "Fake profile file:" << mConfigFile;
+}
+
 void Fake::delayedInit()
 {
     new FakeBackendAdaptor(this);
@@ -65,17 +71,13 @@
 
 QString Fake::serviceName() const
 {
-    if (!qgetenv("KSCREEN_TEST_INSTANCE").isEmpty()) {
-        return QString::fromLatin1("org.kde.KScreen.Backend.Fake.") + 
QString::fromLatin1(qgetenv("KSCREEN_TEST_INSTANCE"));
-    }
-
     return QLatin1Literal("org.kde.KScreen.Backend.Fake");
 }
 
 ConfigPtr Fake::config() const
 {
     if (mConfig.isNull()) {
-        mConfig = Parser::fromJson(QString(qgetenv("TEST_DATA")));
+        mConfig = Parser::fromJson(mConfigFile);
     }
 
     return mConfig;
@@ -94,7 +96,7 @@
 QByteArray Fake::edid(int outputId) const
 {
     Q_UNUSED(outputId);
-    QFile file(QString(qgetenv("TEST_DATA")));
+    QFile file(mConfigFile);
     file.open(QIODevice::ReadOnly);
 
     const QJsonDocument jsonDoc = QJsonDocument::fromJson(file.readAll());
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libkscreen-5.4.3/backends/fake/fake.h 
new/libkscreen-5.5.1/backends/fake/fake.h
--- old/libkscreen-5.4.3/backends/fake/fake.h   2015-11-05 13:40:57.000000000 
+0100
+++ new/libkscreen-5.5.1/backends/fake/fake.h   2015-12-15 11:26:53.000000000 
+0100
@@ -33,6 +33,8 @@
     explicit Fake();
     virtual ~Fake();
 
+    void init(const QVariantMap &arguments) Q_DECL_OVERRIDE;
+
     QString name() const;
     QString serviceName() const;
     KScreen::ConfigPtr config() const;
@@ -53,6 +55,7 @@
 
 
 private:
+    QString mConfigFile;
     mutable KScreen::ConfigPtr mConfig;
 };
 Q_DECLARE_LOGGING_CATEGORY(KSCREEN_FAKE)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libkscreen-5.4.3/backends/xrandr/xrandroutput.cpp 
new/libkscreen-5.5.1/backends/xrandr/xrandroutput.cpp
--- old/libkscreen-5.4.3/backends/xrandr/xrandroutput.cpp       2015-11-05 
13:40:57.000000000 +0100
+++ new/libkscreen-5.5.1/backends/xrandr/xrandroutput.cpp       2015-12-15 
11:26:53.000000000 +0100
@@ -213,12 +213,12 @@
 void XRandROutput::updateModes(const XCB::OutputInfo &outputInfo)
 {
     /* Init modes */
-    auto screenResources = XRandR::screenResources();
+    XCB::ScopedPointer<xcb_randr_get_screen_resources_reply_t> 
screenResources(XRandR::screenResources());
     Q_ASSERT(screenResources);
     if (!screenResources) {
         return;
     }
-    xcb_randr_mode_info_t *modes = 
xcb_randr_get_screen_resources_modes(screenResources);
+    xcb_randr_mode_info_t *modes = 
xcb_randr_get_screen_resources_modes(screenResources.data());
     xcb_randr_mode_t *outputModes = 
xcb_randr_get_output_info_modes(outputInfo.data());
 
     m_preferredModes.clear();
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libkscreen-5.4.3/backends/xrandr/xrandrscreen.cpp 
new/libkscreen-5.5.1/backends/xrandr/xrandrscreen.cpp
--- old/libkscreen-5.4.3/backends/xrandr/xrandrscreen.cpp       2015-11-05 
13:40:57.000000000 +0100
+++ new/libkscreen-5.5.1/backends/xrandr/xrandrscreen.cpp       2015-12-15 
11:26:53.000000000 +0100
@@ -62,7 +62,9 @@
     kscreenScreen->setMaxSize(m_maxSize);
     kscreenScreen->setMinSize(m_minSize);
     kscreenScreen->setCurrentSize(m_currentSize);
-    
kscreenScreen->setMaxActiveOutputsCount(XRandR::screenResources()->num_crtcs);
+
+    XCB::ScopedPointer<xcb_randr_get_screen_resources_reply_t> 
screenResources(XRandR::screenResources());
+    kscreenScreen->setMaxActiveOutputsCount(screenResources->num_crtcs);
 
     return kscreenScreen;
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/libkscreen-5.4.3/interfaces/org.kde.KScreen.Backend.xml 
new/libkscreen-5.5.1/interfaces/org.kde.KScreen.Backend.xml
--- old/libkscreen-5.4.3/interfaces/org.kde.KScreen.Backend.xml 2015-11-05 
13:40:57.000000000 +0100
+++ new/libkscreen-5.5.1/interfaces/org.kde.KScreen.Backend.xml 2015-12-15 
11:26:53.000000000 +0100
@@ -21,6 +21,5 @@
       <arg type="ay" direction="out" />
     </method>
 
-    <method name="quit" />
   </interface>
 </node>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libkscreen-5.4.3/interfaces/org.kde.KScreen.xml 
new/libkscreen-5.5.1/interfaces/org.kde.KScreen.xml
--- old/libkscreen-5.4.3/interfaces/org.kde.KScreen.xml 1970-01-01 
01:00:00.000000000 +0100
+++ new/libkscreen-5.5.1/interfaces/org.kde.KScreen.xml 2015-12-15 
11:26:53.000000000 +0100
@@ -0,0 +1,16 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" 
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd";>
+<node>
+  <interface name="org.kde.KScreen">
+    <method name="backend">
+      <arg type="s" direction="out" />
+    </method>
+    <method name="requestBackend">
+      <arg type="s" direction="in" />
+      <arg type="a{sv}" direction="in" />
+      <arg type="b" direction="out" />
+      <annotation name="org.qtproject.QtDBus.QtTypeName.In1" 
value="QVariantMap"/>
+    </method>
+
+    <method name="quit" />
+  </interface>
+</node>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libkscreen-5.4.3/src/CMakeLists.txt 
new/libkscreen-5.5.1/src/CMakeLists.txt
--- old/libkscreen-5.4.3/src/CMakeLists.txt     2015-11-05 13:40:57.000000000 
+0100
+++ new/libkscreen-5.5.1/src/CMakeLists.txt     2015-12-15 11:26:53.000000000 
+0100
@@ -1,7 +1,5 @@
 include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} 
${CMAKE_CURRENT_BINARY_DIR} ${QT_INCLUDES})
 
-configure_file(config-libkscreen.h.cmake 
${CMAKE_CURRENT_BINARY_DIR}/config-libkscreen.h)
-
 add_subdirectory(backendlauncher)
 
 set(libkscreen_SRCS
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libkscreen-5.4.3/src/abstractbackend.cpp 
new/libkscreen-5.5.1/src/abstractbackend.cpp
--- old/libkscreen-5.4.3/src/abstractbackend.cpp        2015-11-05 
13:40:57.000000000 +0100
+++ new/libkscreen-5.5.1/src/abstractbackend.cpp        2015-12-15 
11:26:53.000000000 +0100
@@ -19,6 +19,11 @@
 
 #include "abstractbackend.h"
 
+void KScreen::AbstractBackend::init(const QVariantMap &arguments)
+{
+    Q_UNUSED(arguments);
+}
+
 QByteArray KScreen::AbstractBackend::edid(int outputId) const
 {
     Q_UNUSED(outputId);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libkscreen-5.4.3/src/abstractbackend.h 
new/libkscreen-5.5.1/src/abstractbackend.h
--- old/libkscreen-5.4.3/src/abstractbackend.h  2015-11-05 13:40:57.000000000 
+0100
+++ new/libkscreen-5.5.1/src/abstractbackend.h  2015-12-15 11:26:53.000000000 
+0100
@@ -41,6 +41,16 @@
     virtual ~AbstractBackend() {}
 
     /**
+     * This is where the backend should perform all initialization. This method
+     * is always called right after the backend is created.
+     *
+     * Default implementation does nothing.
+     *
+     * @p arguments Optional arguments passed by caller. Used mostly for 
unit-testing.
+     */
+    virtual void init(const QVariantMap &arguments);
+
+    /**
      * Returns user-friendly name of the backend
      */
     virtual QString name() const = 0;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libkscreen-5.4.3/src/backendlauncher/CMakeLists.txt 
new/libkscreen-5.5.1/src/backendlauncher/CMakeLists.txt
--- old/libkscreen-5.4.3/src/backendlauncher/CMakeLists.txt     2015-11-05 
13:40:57.000000000 +0100
+++ new/libkscreen-5.5.1/src/backendlauncher/CMakeLists.txt     2015-12-15 
11:26:53.000000000 +0100
@@ -9,8 +9,16 @@
     backenddbuswrapper.cpp
 )
 
+ecm_qt_declare_logging_category(backendlauncher_SRCS
+                                HEADER debug_p.h
+                                IDENTIFIER KSCREEN_BACKEND_LAUNCHER
+                                CATEGORY_NAME kscreen.backendLauncher
+)
+
 qt5_add_dbus_adaptor(backendlauncher_SRCS 
${CMAKE_SOURCE_DIR}/interfaces/org.kde.KScreen.Backend.xml
                      backenddbuswrapper.h BackendDBusWrapper backendadaptor 
BackendAdaptor)
+qt5_add_dbus_adaptor(backendlauncher_SRCS 
${CMAKE_SOURCE_DIR}/interfaces/org.kde.KScreen.xml
+                     backendloader.h BackendLoader backendloaderadaptor 
BackendLoaderAdaptor)
 
 add_executable(kscreen_backend_launcher ${backendlauncher_SRCS})
 
@@ -22,4 +30,13 @@
     Qt5::DBus
 )
 
-install(TARGETS kscreen_backend_launcher DESTINATION 
${CMAKE_INSTALL_FULL_LIBEXECDIR_KF5})
+install(TARGETS kscreen_backend_launcher
+        DESTINATION ${CMAKE_INSTALL_FULL_LIBEXECDIR_KF5}
+)
+
+configure_file(org.kde.kscreen.service.cmake
+               ${CMAKE_CURRENT_BINARY_DIR}/org.kde.kscreen.service @ONLY
+)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/org.kde.kscreen.service
+        DESTINATION ${KDE_INSTALL_DBUSSERVICEDIR}
+)
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/libkscreen-5.4.3/src/backendlauncher/backenddbuswrapper.cpp 
new/libkscreen-5.5.1/src/backendlauncher/backenddbuswrapper.cpp
--- old/libkscreen-5.4.3/src/backendlauncher/backenddbuswrapper.cpp     
2015-11-05 13:40:57.000000000 +0100
+++ new/libkscreen-5.5.1/src/backendlauncher/backenddbuswrapper.cpp     
2015-12-15 11:26:53.000000000 +0100
@@ -20,6 +20,8 @@
 #include "backenddbuswrapper.h"
 #include "backendloader.h"
 #include "backendadaptor.h"
+#include "debug_p.h"
+
 #include "src/configserializer_p.h"
 #include "src/config.h"
 #include "src/abstractbackend.h"
@@ -48,14 +50,8 @@
 bool BackendDBusWrapper::init()
 {
     QDBusConnection dbus = QDBusConnection::sessionBus();
-    if (!dbus.registerService(mBackend->serviceName())) {
-        qCWarning(KSCREEN_BACKEND_LAUNCHER) << "Failed to register as DBus 
service: another launcher already running?";
-        qCWarning(KSCREEN_BACKEND_LAUNCHER) << dbus.lastError().message();
-        return false;
-    }
-
     new BackendAdaptor(this);
-    if (!dbus.registerObject(QLatin1String("/"), this, 
QDBusConnection::ExportAdaptors)) {
+    if (!dbus.registerObject(QLatin1String("/backend"), this, 
QDBusConnection::ExportAdaptors)) {
         qCWarning(KSCREEN_BACKEND_LAUNCHER) << "Failed to export backend to 
DBus: another launcher already running?";
         qCWarning(KSCREEN_BACKEND_LAUNCHER) << dbus.lastError().message();
         return false;
@@ -107,12 +103,6 @@
     return edidData;
 }
 
-void BackendDBusWrapper::quit()
-{
-    qCDebug(KSCREEN_BACKEND_LAUNCHER) << "Launcher termination requested";
-    qApp->exit(BackendLoader::LauncherStopped);
-}
-
 void BackendDBusWrapper::backendConfigChanged(const KScreen::ConfigPtr &config)
 {
     Q_ASSERT(!config.isNull());
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/libkscreen-5.4.3/src/backendlauncher/backenddbuswrapper.h 
new/libkscreen-5.5.1/src/backendlauncher/backenddbuswrapper.h
--- old/libkscreen-5.4.3/src/backendlauncher/backenddbuswrapper.h       
2015-11-05 13:40:57.000000000 +0100
+++ new/libkscreen-5.5.1/src/backendlauncher/backenddbuswrapper.h       
2015-12-15 11:26:53.000000000 +0100
@@ -45,7 +45,7 @@
     QVariantMap setConfig(const QVariantMap &config);
     QByteArray getEdid(int output) const;
 
-    void quit();
+    inline KScreen::AbstractBackend *backend() const { return mBackend; }
 
 Q_SIGNALS:
     void configChanged(const QVariantMap &config);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/libkscreen-5.4.3/src/backendlauncher/backendloader.cpp 
new/libkscreen-5.5.1/src/backendlauncher/backendloader.cpp
--- old/libkscreen-5.4.3/src/backendlauncher/backendloader.cpp  2015-11-05 
13:40:57.000000000 +0100
+++ new/libkscreen-5.5.1/src/backendlauncher/backendloader.cpp  2015-12-15 
11:26:53.000000000 +0100
@@ -18,6 +18,9 @@
  */
 
 #include "backendloader.h"
+#include "backendloaderadaptor.h"
+#include "backenddbuswrapper.h"
+#include "debug_p.h"
 #include "src/abstractbackend.h"
 
 #include <QCoreApplication>
@@ -31,8 +34,6 @@
 #include <QDBusConnection>
 #include <QDBusInterface>
 
-Q_LOGGING_CATEGORY(KSCREEN_BACKEND_LAUNCHER, "kscreen.backendLauncher")
-
 void pluginDeleter(QPluginLoader *p)
 {
     if (p) {
@@ -44,8 +45,9 @@
 
 BackendLoader::BackendLoader()
     : QObject()
-    , mLoader(0)
-    , mBackend(0)
+    , QDBusContext()
+    , mLoader(Q_NULLPTR)
+    , mBackend(Q_NULLPTR)
 {
 }
 
@@ -56,10 +58,64 @@
     qCDebug(KSCREEN_BACKEND_LAUNCHER) << "Backend loader destroyed";
 }
 
-bool BackendLoader::loadBackend(const QString& backend)
+bool BackendLoader::init()
+{
+    QDBusConnection dbus = QDBusConnection::sessionBus();
+    new BackendLoaderAdaptor(this);
+    if (!dbus.registerObject(QLatin1String("/"), this, 
QDBusConnection::ExportAdaptors)) {
+        qCWarning(KSCREEN_BACKEND_LAUNCHER) << "Failed to export backend to 
DBus: another launcher already running?";
+        qCWarning(KSCREEN_BACKEND_LAUNCHER) << dbus.lastError().message();
+        return false;
+    }
+
+    return true;
+}
+
+QString BackendLoader::backend() const
 {
-    qCDebug(KSCREEN_BACKEND_LAUNCHER) << "Requested backend:" << backend;
-    const QString backendFilter = QString::fromLatin1("KSC_%1*").arg(backend);
+    if (mBackend) {
+        return mBackend->backend()->name();
+    }
+
+    return QString();
+}
+
+bool BackendLoader::requestBackend(const QString &backendName, const 
QVariantMap &arguments)
+{
+    if (mBackend) {
+        // If an backend is already loaded, but it's not the same as the one
+        // requested, then it's an error
+        if (!backendName.isEmpty() && mBackend->backend()->name() != 
backendName) {
+            sendErrorReply(QDBusError::Failed, QStringLiteral("Another backend 
is already active"));
+            return false;
+        } else {
+            // If caller requested the same one as already loaded, or did not
+            // request a specific backend, hapilly reuse the existing one
+            return true;
+        }
+    }
+
+    KScreen::AbstractBackend *backend = loadBackend(backendName, arguments);
+    if (!backend) {
+        return false;
+    }
+
+    mBackend = new BackendDBusWrapper(backend);
+    if (!mBackend->init()) {
+        delete mBackend;
+        mBackend = Q_NULLPTR;
+        pluginDeleter(mLoader);
+        mLoader = Q_NULLPTR;
+        return false;
+    }
+    return true;
+}
+
+KScreen::AbstractBackend *BackendLoader::loadBackend(const QString &name,
+                                                     const QVariantMap 
&arguments)
+{
+    qCDebug(KSCREEN_BACKEND_LAUNCHER) << "Requested backend:" << name;
+    const QString backendFilter = QString::fromLatin1("KSC_%1*").arg(name);
     const QStringList paths = QCoreApplication::libraryPaths();
     qCDebug(KSCREEN_BACKEND_LAUNCHER) << "Lookup paths: " << paths;
     Q_FOREACH (const QString &path, paths) {
@@ -70,13 +126,13 @@
         const QFileInfoList finfos = dir.entryInfoList();
         Q_FOREACH (const QFileInfo &finfo, finfos) {
             // Skip "Fake" backend unless explicitly specified via 
KSCREEN_BACKEND
-            if (backend.isEmpty() && 
(finfo.fileName().contains(QLatin1String("KSC_Fake")) || 
finfo.fileName().contains(QLatin1String("KSC_FakeUI")))) {
+            if (name.isEmpty() && 
(finfo.fileName().contains(QLatin1String("KSC_Fake")) || 
finfo.fileName().contains(QLatin1String("KSC_FakeUI")))) {
                 continue;
             }
 
             // When on X11, skip the QScreen backend, instead use the XRandR 
backend,
             // if not specified in KSCREEN_BACKEND
-            if (backend.isEmpty() &&
+            if (name.isEmpty() &&
                     finfo.fileName().contains(QLatin1String("KSC_QScreen")) &&
                     QX11Info::isPlatformX11()) {
                 continue;
@@ -84,7 +140,7 @@
 
             // When not on X11, skip the XRandR backend, and fall back to 
QSCreen
             // if not specified in KSCREEN_BACKEND
-            if (backend.isEmpty() &&
+            if (name.isEmpty() &&
                     finfo.fileName().contains(QLatin1String("KSC_XRandR")) &&
                     !QX11Info::isPlatformX11()) {
                 continue;
@@ -99,35 +155,30 @@
                 continue;
             }
 
-            mBackend = qobject_cast<KScreen::AbstractBackend*>(instance);
-            if (mBackend) {
-                if (!mBackend->isValid()) {
-                    qCDebug(KSCREEN_BACKEND_LAUNCHER) << "Skipping" << 
mBackend->name() << "backend";
-                    delete mBackend;
-                    mBackend = 0;
+            auto backend = qobject_cast<KScreen::AbstractBackend*>(instance);
+            if (backend) {
+                backend->init(arguments);
+                if (!backend->isValid()) {
+                    qCDebug(KSCREEN_BACKEND_LAUNCHER) << "Skipping" << 
backend->name() << "backend";
+                    delete backend;
                     continue;
                 }
 
                 // This is the only case we don't want to unload() and delete 
the loader, instead
                 // we store it and unload it when the backendloader terminates.
                 mLoader = loader.release();
-                qCDebug(KSCREEN_BACKEND_LAUNCHER) << "Loading" << 
mBackend->name() << "backend";
-                return true;
+                qCDebug(KSCREEN_BACKEND_LAUNCHER) << "Loading" << 
backend->name() << "backend";
+                return backend;
             } else {
                 qCDebug(KSCREEN_BACKEND_LAUNCHER) << finfo.fileName() << "does 
not provide valid KScreen backend";
             }
         }
     }
 
-    return false;
-}
-
-KScreen::AbstractBackend* BackendLoader::backend() const
-{
-    return mBackend;
+    return Q_NULLPTR;
 }
 
-bool BackendLoader::checkIsAlreadyRunning()
+void BackendLoader::quit()
 {
-    return 
QDBusConnection::sessionBus().interface()->isServiceRegistered(mBackend->serviceName());
+    qApp->quit();
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libkscreen-5.4.3/src/backendlauncher/backendloader.h 
new/libkscreen-5.5.1/src/backendlauncher/backendloader.h
--- old/libkscreen-5.4.3/src/backendlauncher/backendloader.h    2015-11-05 
13:40:57.000000000 +0100
+++ new/libkscreen-5.5.1/src/backendlauncher/backendloader.h    2015-12-15 
11:26:53.000000000 +0100
@@ -21,40 +21,38 @@
 #define BACKENDLAUNCHER_H
 
 #include <QObject>
-#include <QLoggingCategory>
-
-class QPluginLoader;
+#include <QDBusContext>
 
 namespace KScreen
 {
 class AbstractBackend;
 }
 
+class QPluginLoader;
+class BackendDBusWrapper;
+
 class BackendLoader : public QObject
+                    , protected QDBusContext
 {
     Q_OBJECT
+    Q_CLASSINFO("D-Bus Interface", "org.kde.KScreen")
 
 public:
-    enum State {
-        BackendLoaded = 0,
-        BackendAlreadyExists = 1,
-        BackendFailedToLoad = 2,
-        LauncherStopped = 3
-    };
-
     explicit BackendLoader();
     ~BackendLoader();
 
-    bool loadBackend(const QString &backendName = QString());
-    bool checkIsAlreadyRunning();
+    bool init();
+
+    Q_INVOKABLE QString backend() const;
+    Q_INVOKABLE bool requestBackend(const QString &name, const QVariantMap 
&arguments);
+    Q_INVOKABLE void quit();
 
-    KScreen::AbstractBackend* backend() const;
+private:
+    KScreen::AbstractBackend *loadBackend(const QString &name, const 
QVariantMap &arguments);
 
 private:
     QPluginLoader *mLoader;
-    KScreen::AbstractBackend* mBackend;
+    BackendDBusWrapper *mBackend;
 };
 
-Q_DECLARE_LOGGING_CATEGORY(KSCREEN_BACKEND_LAUNCHER)
-
 #endif // BACKENDLAUNCHER_H
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libkscreen-5.4.3/src/backendlauncher/main.cpp 
new/libkscreen-5.5.1/src/backendlauncher/main.cpp
--- old/libkscreen-5.4.3/src/backendlauncher/main.cpp   2015-11-05 
13:40:57.000000000 +0100
+++ new/libkscreen-5.5.1/src/backendlauncher/main.cpp   2015-12-15 
11:26:53.000000000 +0100
@@ -18,68 +18,30 @@
  */
 
 #include <QGuiApplication>
-#include <QCommandLineParser>
-#include <QDebug>
+#include <QDBusConnection>
 
+#include "debug_p.h"
 #include "backendloader.h"
-#include "backenddbuswrapper.h"
-
-#include <src/abstractbackend.h>
 
 int main(int argc, char **argv)
 {
     QGuiApplication::setDesktopSettingsAware(false);
     QGuiApplication app(argc, argv);
 
-    BackendLoader *loader = new BackendLoader;
-
-    QCommandLineOption backendOption(QLatin1String("backend"),
-                                     QLatin1String("Backend to load. When not 
specified, BackendLauncher will "
-                                                   "try to load the best 
backend for current platform."),
-                                     QLatin1String("backend"));
-    QCommandLineParser parser;
-    parser.addOption(backendOption);
-    parser.addHelpOption();
-
-    parser.process(app);
-
-    bool success = false;
-    if (parser.isSet(backendOption)) {
-        success = loader->loadBackend(parser.value(backendOption));
-    } else {
-        success = loader->loadBackend();
+    if 
(!QDBusConnection::sessionBus().registerService(QStringLiteral("org.kde.KScreen")))
 {
+        qCWarning(KSCREEN_BACKEND_LAUNCHER) << "Cannot register 
org.kde.KScreen service. Another launcher already running?";
+        return -1;
     }
 
-    // We failed to load any backend: abort immediatelly
-    if (!success) {
-        return BackendLoader::BackendFailedToLoad;
-    }
-
-    // Create BackendDBusWrapper that takes implements the DBus interface and 
translates
-    // DBus calls to backend implementations. It will also take care of 
terminating this
-    // loader when no other KScreen-enabled processes are running
-    BackendDBusWrapper backendWrapper(loader->backend());
-    if (!backendWrapper.init()) {
-        // Loading failed, maybe it failed because another process is already 
running; if so we still want to print the path before we exit
-        // Check if another Backend Launcher with this particular backend is 
already running
-        const bool alreadyRunning = loader->checkIsAlreadyRunning();
-        if (alreadyRunning) {
-            // If it is, let caller now it's DBus service name and terminate
-            printf("%s", qPrintable(loader->backend()->serviceName()));
-            fflush(stdout);
-            return BackendLoader::BackendAlreadyExists;
-        }
-        return BackendLoader::BackendFailedToLoad;
+    BackendLoader *loader = new BackendLoader;
+    if (!loader->init()) {
+        return -2;
     }
 
-    // Now let caller now what's our DBus service name, so it can connect to us
-    printf("%s", qPrintable(loader->backend()->serviceName()));
-    fflush(stdout);
-
-    // And go!
     const int ret = app.exec();
 
-    // Make sure the backend is destroyed and unloaded before we return
+    // Make sure the backend is destroyed and unloaded before we return (i.e.
+    // as long as QApplication object and it's XCB connection still exist
     delete loader;
 
     return ret;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/libkscreen-5.4.3/src/backendlauncher/org.kde.kscreen.service.cmake 
new/libkscreen-5.5.1/src/backendlauncher/org.kde.kscreen.service.cmake
--- old/libkscreen-5.4.3/src/backendlauncher/org.kde.kscreen.service.cmake      
1970-01-01 01:00:00.000000000 +0100
+++ new/libkscreen-5.5.1/src/backendlauncher/org.kde.kscreen.service.cmake      
2015-12-15 11:26:53.000000000 +0100
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.kde.KScreen
+Exec=@CMAKE_INSTALL_FULL_LIBEXECDIR_KF5@/kscreen_backend_launcher
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libkscreen-5.4.3/src/backendmanager.cpp 
new/libkscreen-5.5.1/src/backendmanager.cpp
--- old/libkscreen-5.4.3/src/backendmanager.cpp 2015-11-05 13:40:57.000000000 
+0100
+++ new/libkscreen-5.5.1/src/backendmanager.cpp 2015-12-15 11:26:53.000000000 
+0100
@@ -19,7 +19,6 @@
 
 #include "backendmanager_p.h"
 #include "backendinterface.h"
-#include "backendlauncher/backendloader.h"
 #include "debug_p.h"
 #include "getconfigoperation.h"
 #include "configserializer_p.h"
@@ -30,15 +29,7 @@
 #include <QDBusPendingReply>
 #include <QDBusConnectionInterface>
 #include <QStandardPaths>
-
-#include "config-libkscreen.h"
-
-#include <QProcess>
-
-#ifdef Q_OS_UNIX
-#include <sys/wait.h>
-#include <signal.h>
-#endif
+#include <QThread>
 
 using namespace KScreen;
 
@@ -61,7 +52,6 @@
     : QObject()
     , mInterface(0)
     , mCrashCount(0)
-    , mLauncher(0)
     , mShuttingDown(false)
     , mRequestsCounter(0)
 {
@@ -97,7 +87,20 @@
     }
     ++mRequestsCounter;
 
-    startBackend(QString::fromLatin1(qgetenv("KSCREEN_BACKEND")));
+    const QByteArray args = qgetenv("KSCREEN_BACKEND_ARGS");
+    QVariantMap arguments;
+    if (!args.isEmpty()) {
+        QList<QByteArray> arglist = args.split(';');
+        Q_FOREACH (const QByteArray &arg, arglist) {
+            const int pos = arg.indexOf('=');
+            if (pos == -1) {
+                continue;
+            }
+            arguments.insert(arg.left(pos), arg.mid(pos + 1));
+        }
+    }
+
+    startBackend(QString::fromLatin1(qgetenv("KSCREEN_BACKEND")), arguments);
 }
 
 void BackendManager::emitBackendReady()
@@ -109,139 +112,65 @@
     }
 }
 
-void BackendManager::startBackend(const QString &backend)
-{
-    if (mLauncher && mLauncher->state() == QProcess::Running) {
-        mLauncher->terminate();
-    }
-
-    mLauncher = new QProcess(this);
-    connect(mLauncher, 
static_cast<void(QProcess::*)(int,QProcess::ExitStatus)>(&QProcess::finished),
-            this, &BackendManager::launcherFinished);
-    connect(mLauncher, &QProcess::readyReadStandardOutput,
-            this, &BackendManager::launcherDataAvailable);
-
-    QString launcher = QString::fromLatin1(CMAKE_INSTALL_FULL_LIBEXECDIR_KF5 
"/kscreen_backend_launcher");
-    if (!QFile::exists(launcher)) {
-        launcher = QStandardPaths::findExecutable("kscreen_backend_launcher");
-        if (launcher.isEmpty()) {
-            qCWarning(KSCREEN) << "Failed to locate kscreen_backend_launcher, 
KScreen will be useless";
-            invalidateInterface();
-            delete mLauncher;
-            mLauncher = 0;
-            QMetaObject::invokeMethod(this, "emitBackendReady", 
Qt::QueuedConnection);
-            return;
-        }
-    }
-
-    mLauncher->setProgram(launcher);
-    if (!backend.isEmpty()) {
-        mLauncher->setArguments(QStringList() << "--backend" << backend);
-    }
-
-    mLauncher->start();
-    if (!qgetenv("KSCREEN_BACKEND_DEBUG").isEmpty()) {
-        pid_t pid = mLauncher->pid();
-        qCDebug(KSCREEN) << "==================================";
-        qCDebug(KSCREEN) << "KScreen BackendManager: Suspending backend 
launcher";
-        qCDebug(KSCREEN) << "'gdb --pid" << pid << "' to debug";
-        qCDebug(KSCREEN) << "'kill -SIGCONT" << pid << "' to continue";
-        qCDebug(KSCREEN) << "==================================";
-        qCDebug(KSCREEN);
-        kill(pid, SIGSTOP);
-    }
-
-    mResetCrashCountTimer.start();
-}
-
-void BackendManager::launcherFinished(int exitCode, QProcess::ExitStatus 
exitStatus)
+void BackendManager::startBackend(const QString &backend, const QVariantMap 
&arguments)
 {
-    qCDebug(KSCREEN) << "Launcher finished with exit code" << exitCode << ", 
status" << exitStatus;
-
-    // Stop the timer if it's running, otherwise the number would get reset to 0
-    // anyway even if we reached the sMaxCrashCount, and then the backend would
-    // be restarted again anyway.
-    mResetCrashCountTimer.stop();
-
-    if (exitStatus == QProcess::CrashExit) {
-        // Backend has crashed: restart it
+    // This will autostart the launcher if it's not running already, calling
+    // requestBackend(backend) will:
+    //   a) if the launcher is started it will force it to load the correct 
backend,
+    //   b) if the launcher is already running it will make sure it's running 
with
+    //      the same backend as the one we requested and send an error 
otherwise
+    QDBusConnection conn = QDBusConnection::sessionBus();
+    QDBusMessage call = 
QDBusMessage::createMethodCall(QStringLiteral("org.kde.KScreen"),
+                                                       QStringLiteral("/"),
+                                                       
QStringLiteral("org.kde.KScreen"),
+                                                       
QStringLiteral("requestBackend"));
+    call.setArguments({ backend, arguments });
+    QDBusPendingCall pending = conn.asyncCall(call);
+    QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pending);
+    connect(watcher, &QDBusPendingCallWatcher::finished,
+            this, &BackendManager::onBackendRequestDone);
+}
+
+void BackendManager::onBackendRequestDone(QDBusPendingCallWatcher *watcher)
+{
+    watcher->deleteLater();
+    QDBusPendingReply<bool> reply = *watcher;
+    // Most probably we requested an explicit backend that is different than 
the
+    // one already loaded in the launcher
+    if (reply.isError()) {
+        qCWarning(KSCREEN) << "Failed to request backend:" << 
reply.error().name() << ":" << reply.error().message();
         invalidateInterface();
-        if (!mShuttingDown) {
-            if (++mCrashCount <= sMaxCrashCount) {
-                requestBackend();
-            } else {
-                qCWarning(KSCREEN) << "Launcher has crashed too many times: 
not restarting";
-                mLauncher->deleteLater();
-                mLauncher = 0;
-            }
-        }
-        mShuttingDown = false;
+        emitBackendReady();
         return;
     }
 
-    switch (exitCode) {
-    case BackendLoader::BackendLoaded:
-        // This means that the launcher has terminated successfully after doing
-        // what it was asked to do, so delete the interface, but don't emit 
signals
-        invalidateInterface();
-        break;
-
-    case BackendLoader::BackendFailedToLoad:
-        // Launcher terminated immediatelly because there was no backend, this
-        // means that we didn't try before and someone is probably waiting for
-        // the signal
-        qCWarning(KSCREEN) << "Launcher failed to load any backend: KScreen 
will be useless";
+    // Most probably request and explicit backend which is not available or 
failed
+    // to initialize, or the launcher did not find any suitable backend for the
+    // current platform.
+    if (!reply.value()) {
+        qCWarning(KSCREEN) << "Failed to request backend: unknown error";
         invalidateInterface();
         emitBackendReady();
-        break;
+        return;
+    }
 
-    case BackendLoader::BackendAlreadyExists:
-        // The launcher wrote service name to stdout, so backendReady() was 
emitted
-        // from launcherDataAvailable(), nothing else to do here
-        qCDebug(KSCREEN) << "Service for requested backend already running";
-        break;
-
-    case BackendLoader::LauncherStopped:
-        // The launcher has been stopped on request, probably by someone 
calling
-        // shutdownBackend()
-        qCDebug(KSCREEN) << "Backend launcher terminated on requested";
+    // The launcher has successfully loaded the backend we wanted and 
registered
+    // it to DBus (hopefuly), let's try to get an interface for the backend.
+    if (mInterface) {
         invalidateInterface();
-        break;
     }
-
-    mShuttingDown = false;
-    mLauncher->deleteLater();
-    mLauncher = 0;
-};
-
-void BackendManager::launcherDataAvailable()
-{
-    mLauncher->setReadChannel(QProcess::StandardOutput);
-    const QByteArray service = mLauncher->readLine();
-    qCDebug(KSCREEN) << "launcherDataAvailable:" << service;
-    mBackendService = QString::fromLatin1(service);
-
-    mInterface = new org::kde::kscreen::Backend(mBackendService,
-                                                QLatin1String("/"),
-                                                QDBusConnection::sessionBus(),
-                                                this);
+    mInterface = new 
org::kde::kscreen::Backend(QStringLiteral("org.kde.KScreen"),
+                                                QStringLiteral("/backend"),
+                                                QDBusConnection::sessionBus());
     if (!mInterface->isValid()) {
-        QDBusServiceWatcher *watcher = new QDBusServiceWatcher(mBackendService,
-                                                               
QDBusConnection::sessionBus());
-        connect(watcher, &QDBusServiceWatcher::serviceOwnerChanged,
-                [&](const QString &service, const QString &oldOwner, const 
QString &newOwner) {
-                    qDebug() << service << newOwner << oldOwner;
-                    if (newOwner == mBackendService) {
-                        backendServiceReady();
-                    }
-                });
+        qCWarning(KSCREEN) << "Backend successfully requested, but we failed 
to obtain a valid DBus interface for it";
+        invalidateInterface();
+        emitBackendReady();
         return;
     }
-    backendServiceReady();
-}
 
-void BackendManager::backendServiceReady()
-{
+    // The backend is GO, so let's watch for it's possible disappearance, so we
+    // can invalidate the interface
     mServiceWatcher.addWatchedService(mBackendService);
 
     // Immediatelly request config
@@ -249,6 +178,7 @@
             [&](ConfigOperation *op) {
                 mConfig = qobject_cast<GetConfigOperation*>(op)->config();
             });
+    // And listen for its change.
     connect(mInterface, &org::kde::kscreen::Backend::configChanged,
             [&](const QVariantMap &newConfig) {
                 mConfig = 
KScreen::ConfigSerializer::deserializeConfig(newConfig);
@@ -283,23 +213,24 @@
         return;
     }
 
+    // If there are some currently pending requests, then wait for them to
+    // finish before quitting
     while (mRequestsCounter > 0) {
         mShutdownLoop.exec();
     }
 
     mServiceWatcher.removeWatchedService(mBackendService);
     mShuttingDown = true;
-    const QDBusReply<uint> reply = 
QDBusConnection::sessionBus().interface()->servicePid(mInterface->service());
 
+    QDBusMessage call = 
QDBusMessage::createMethodCall(QStringLiteral("org.kde.KScreen"),
+                                                       QStringLiteral("/"),
+                                                       
QStringLiteral("org.kde.KScreen"),
+                                                       QStringLiteral("quit"));
     // Call synchronously
-    mInterface->quit().waitForFinished();
+    QDBusConnection::sessionBus().call(call);
     invalidateInterface();
 
-    if (mLauncher) {
-        mLauncher->waitForFinished(5000);
-        // This will ensure that launcherFinished() is called, which will take 
care
-        // of deleting the QProcess
-    } else {
-        // ... ?
+    while 
(QDBusConnection::sessionBus().interface()->isServiceRegistered(QStringLiteral("org.kde.KScreen")))
 {
+        QThread::msleep(100);
     }
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libkscreen-5.4.3/src/backendmanager_p.h 
new/libkscreen-5.5.1/src/backendmanager_p.h
--- old/libkscreen-5.4.3/src/backendmanager_p.h 2015-11-05 13:40:57.000000000 
+0100
+++ new/libkscreen-5.5.1/src/backendmanager_p.h 2015-12-15 11:26:53.000000000 
+0100
@@ -49,27 +49,23 @@
     ~BackendManager();
 
     void requestBackend();
+    void shutdownBackend();
 
     KScreen::ConfigPtr config() const;
 
-    void shutdownBackend();
-
 Q_SIGNALS:
     void backendReady(OrgKdeKscreenBackendInterface *backend);
 
-
 private Q_SLOTS:
     void emitBackendReady();
 
-    void startBackend(const QString &backend = QString());
-
-    void launcherFinished(int existCode, QProcess::ExitStatus exitStatus);
-    void launcherDataAvailable();
+    void startBackend(const QString &backend = QString(),
+                      const QVariantMap &arguments = QVariantMap());
+    void onBackendRequestDone(QDBusPendingCallWatcher *watcher);
 
     void backendServiceUnregistered(const QString &serviceName);
 
 private:
-    void findBestBackend();
     void invalidateInterface();
     void backendServiceReady();
 
@@ -81,7 +77,6 @@
     OrgKdeKscreenBackendInterface *mInterface;
     int mCrashCount;
 
-    QProcess *mLauncher;
     QString mBackendService;
     QDBusServiceWatcher mServiceWatcher;
     KScreen::ConfigPtr mConfig;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libkscreen-5.4.3/src/config-libkscreen.h.cmake 
new/libkscreen-5.5.1/src/config-libkscreen.h.cmake
--- old/libkscreen-5.4.3/src/config-libkscreen.h.cmake  2015-11-05 
13:40:57.000000000 +0100
+++ new/libkscreen-5.5.1/src/config-libkscreen.h.cmake  1970-01-01 
01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-
-#define CMAKE_INSTALL_FULL_LIBEXECDIR_KF5 
"${CMAKE_INSTALL_FULL_LIBEXECDIR_KF5}"
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libkscreen-5.4.3/src/config.cpp 
new/libkscreen-5.5.1/src/config.cpp
--- old/libkscreen-5.4.3/src/config.cpp 2015-11-05 13:40:57.000000000 +0100
+++ new/libkscreen-5.5.1/src/config.cpp 2015-12-15 11:26:53.000000000 +0100
@@ -267,9 +267,9 @@
         return;
     }
 
-    qDebug(KSCREEN) << "Primary output changed from" << primaryOutput()
-                    << "(" << (primaryOutput().isNull() ? "none" : 
primaryOutput()->name()) << ") to"
-                    << newPrimary << "(" << (newPrimary.isNull() ? "none" : 
newPrimary->name()) << ")";
+    qCDebug(KSCREEN) << "Primary output changed from" << primaryOutput()
+                     << "(" << (primaryOutput().isNull() ? "none" : 
primaryOutput()->name()) << ") to"
+                     << newPrimary << "(" << (newPrimary.isNull() ? "none" : 
newPrimary->name()) << ")";
 
     for (OutputPtr &output : d->outputs) {
         disconnect(output.data(), &KScreen::Output::isPrimaryChanged,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libkscreen-5.4.3/src/getconfigoperation.cpp 
new/libkscreen-5.5.1/src/getconfigoperation.cpp
--- old/libkscreen-5.4.3/src/getconfigoperation.cpp     2015-11-05 
13:40:57.000000000 +0100
+++ new/libkscreen-5.5.1/src/getconfigoperation.cpp     2015-12-15 
11:26:53.000000000 +0100
@@ -46,6 +46,8 @@
     ConfigPtr config;
     int pendingEDIDs;
 
+    QPointer<org::kde::kscreen::Backend> mBackend;
+
 private:
     Q_DECLARE_PUBLIC(GetConfigOperation)
 };
@@ -58,7 +60,7 @@
 {
 }
 
-void GetConfigOperationPrivate::backendReady(org::kde::kscreen::Backend* 
backend)
+void GetConfigOperationPrivate::backendReady(org::kde::kscreen::Backend 
*backend)
 {
     ConfigOperationPrivate::backendReady(backend);
 
@@ -70,10 +72,8 @@
         return;
     }
 
-    QDBusPendingCallWatcher *watcher = new 
QDBusPendingCallWatcher(backend->getConfig(), this);
-
-    const auto backendPointer = QPointer<org::kde::kscreen::Backend>(backend);
-    watcher->setProperty("backend", QVariant::fromValue(backendPointer));
+    mBackend = backend;
+    QDBusPendingCallWatcher *watcher = new 
QDBusPendingCallWatcher(mBackend->getConfig(), this);
     connect(watcher, &QDBusPendingCallWatcher::finished,
             this, &GetConfigOperationPrivate::onConfigReceived);
 }
@@ -103,8 +103,7 @@
     }
 
     pendingEDIDs = 0;
-    auto backend = 
watcher->property("backend").value<QPointer<org::kde::kscreen::Backend>>();
-    if (!backend) {
+    if (!mBackend) {
         q->setError(tr("Backend invalidated"));
         q->emitResult();
         return;
@@ -114,7 +113,7 @@
             continue;
         }
 
-        QDBusPendingCallWatcher *watcher = new 
QDBusPendingCallWatcher(backend->getEdid(output->id()), this);
+        QDBusPendingCallWatcher *watcher = new 
QDBusPendingCallWatcher(mBackend->getEdid(output->id()), this);
         watcher->setProperty("outputId", output->id());
         connect(watcher, &QDBusPendingCallWatcher::finished,
                 this, &GetConfigOperationPrivate::onEDIDReceived);


Reply via email to