[-]
[+]
|
Changed |
libkscreen.spec
|
|
[-]
[+]
|
Deleted |
libkscreen-5.0.95.tar.xz/backends/abstractbackend.h
^
|
@@ -1,81 +0,0 @@
-/*************************************************************************************
- * Copyright (C) 2012 by Alejandro Fiestas Olivares <afiestas@kde.org> *
- * *
- * This library is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * This library 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 *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this library; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
- *************************************************************************************/
-
-#ifndef ABSTRACT_BACKEND_H
-#define ABSTRACT_BACKEND_H
-
-#include <QtCore/QString>
-#include <QtCore/QObject>
-
-namespace KScreen {
- class Config;
- class Edid;
-}
-/** Abstract class for backends.
- *
- * The returned objects are expected to be memory-managed by the users. After creation,
- * the backend assumes no ownership of the backends.
- *
- * This means that we can not keep track of objects after we returned them, as the user
- * might have deleted the object.
- */
-class AbstractBackend
-{
- public:
- virtual ~AbstractBackend() {}
- virtual QString name() const = 0;
-
- /** Returns a new Config object, holding Screen, Output objects, etc..
- *
- * The receiver of the Config* object is expected to manage its lifetime, and
- * the lifetime of its outputs.
- *
- * @return Config object for the system.
- */
- virtual KScreen::Config* config() const = 0;
-
- /** Apply a config object to the system.
- */
- virtual void setConfig(KScreen::Config* config) const = 0;
-
- virtual bool isValid() const = 0;
-
- /** Returns an Edid object for a given output.
- *
- * The receiver of the Edid* object is expected to manage its lifetime.
- *
- * @return Edid object for an output, or zero if no output exists.
- */
- virtual KScreen::Edid* edid(int outputId) const = 0;
-
- /** This method is called from the ConfigMonitor instance.
- *
- * This is how it works:
- * The backend notes a change, for example a screen has been added. It updates
- * its internal data, then calls ConfigMonitor::instance()->notifyUpdate. The
- * ConfigMonitor holds a pointer to the Config that is used and passes this into
- * the backend's updateConfig(Config*) function (i.e. this method).
- *
- * Your reimplementation of this method should update the configuration's outputs,
- * screen, etc..
- */
- virtual void updateConfig(KScreen::Config* config) const = 0;
-};
-
-Q_DECLARE_INTERFACE(AbstractBackend, "org.kde.libkscreen")
-#endif //ABSTRACT_BACKEND_H
|
[-]
[+]
|
Deleted |
libkscreen-5.0.95.tar.xz/cmake
^
|
-(directory)
|
[-]
[+]
|
Deleted |
libkscreen-5.0.95.tar.xz/cmake/modules
^
|
-(directory)
|
[-]
[+]
|
Deleted |
libkscreen-5.0.95.tar.xz/cmake/modules/COPYING-CMAKE-SCRIPTS
^
|
@@ -1,22 +0,0 @@
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-
-1. Redistributions of source code must retain the copyright
- notice, this list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
[-]
[+]
|
Deleted |
libkscreen-5.0.95.tar.xz/cmake/modules/FindX11_XCB.cmake
^
|
@@ -1,31 +0,0 @@
-# - Try to find libX11-xcb
-# Once done this will define
-#
-# X11_XCB_FOUND - system has libX11-xcb
-# X11_XCB_LIBRARIES - Link these to use libX11-xcb
-# X11_XCB_INCLUDE_DIR - the libX11-xcb include dir
-# X11_XCB_DEFINITIONS - compiler switches required for using libX11-xcb
-
-# Copyright (c) 2012 Fredrik Höglund <fredrik@kde.org>
-# Copyright (c) 2008 Helio Chissini de Castro, <helio@kde.org>
-# Copyright (c) 2007 Matthias Kretz, <kretz@kde.org>
-#
-# Redistribution and use is allowed according to the terms of the BSD license.
-# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
-
-IF (NOT WIN32)
-# use pkg-config to get the directories and then use these values
-# in the FIND_PATH() and FIND_LIBRARY() calls
-FIND_PACKAGE(PkgConfig)
-PKG_CHECK_MODULES(PKG_X11_XCB QUIET x11-xcb)
-
-SET(X11_XCB_DEFINITIONS ${PKG_X11_XCB_CFLAGS})
-
-FIND_PATH(X11_XCB_INCLUDE_DIR NAMES X11/Xlib-xcb.h HINTS ${PKG_X11_XCB_INCLUDE_DIRS})
-FIND_LIBRARY(X11_XCB_LIBRARIES NAMES X11-xcb HINTS ${PKG_X11_XCB_LIBRARY_DIRS})
-
-include(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(X11_XCB DEFAULT_MSG X11_XCB_LIBRARIES X11_XCB_INCLUDE_DIR)
-
-MARK_AS_ADVANCED(X11_XCB_INCLUDE_DIR X11_XCB_LIBRARIES)
-ENDIF (NOT WIN32)
\ No newline at end of file
|
[-]
[+]
|
Deleted |
libkscreen-5.0.95.tar.xz/cmake/modules/FindXCB.cmake
^
|
@@ -1,111 +0,0 @@
-# Try to find XCB on a Unix system
-#
-# This will define:
-#
-# XCB_FOUND - True if xcb is available
-# XCB_LIBRARIES - Link these to use xcb
-# XCB_INCLUDE_DIR - Include directory for xcb
-# XCB_DEFINITIONS - Compiler flags for using xcb
-#
-# In addition the following more fine grained variables will be defined:
-#
-# XCB_XCB_FOUND XCB_XCB_INCLUDE_DIR XCB_XCB_LIBRARIES
-# XCB_COMPOSITE_FOUND XCB_COMPOSITE_INCLUDE_DIR XCB_COMPOSITE_LIBRARIES
-# XCB_DAMAGE_FOUND XCB_DAMAGE_INCLUDE_DIR XCB_DAMAGE_LIBRARIES
-# XCB_XFIXES_FOUND XCB_XFIXES_INCLUDE_DIR XCB_XFIXES_LIBRARIES
-# XCB_RENDER_FOUND XCB_RENDER_INCLUDE_DIR XCB_RENDER_LIBRARIES
-# XCB_RANDR_FOUND XCB_RANDR_INCLUDE_DIR XCB_RANDR_LIBRARIES
-# XCB_SHAPE_FOUND XCB_SHAPE_INCLUDE_DIR XCB_SHAPE_LIBRARIES
-# XCB_SHM_FOUND XCB_SHM_INCLUDE_DIR XCB_SHM_LIBRARIES
-# XCB_SYNC_FOUND XCB_SYNC_INCLUDE_DIR XCB_SYNC_LIBRARIES
-# XCB_IMAGE_FOUND XCB_IMAGE_INCLUDE_DIR XCB_IMAGE_LIBRARIES
-# XCB_RENDERUTIL_FOUND XCB_RENDERUTIL_INCLUDE_DIR XCB_RENDERUTIL_LIBRARIES
-#
-# Copyright (c) 2012 Fredrik Höglund <fredrik@kde.org>
-#
-# Redistribution and use is allowed according to the terms of the BSD license.
-# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
-
-
-IF (NOT WIN32)
- IF (XCB_INCLUDE_DIR AND XCB_LIBRARIES)
- # In the cache already
- SET(XCB_FIND_QUIETLY TRUE)
- ENDIF (XCB_INCLUDE_DIR AND XCB_LIBRARIES)
-
- # Use pkg-config to get the directories and then use these values
- # in the FIND_PATH() and FIND_LIBRARY() calls
- FIND_PACKAGE(PkgConfig)
- PKG_CHECK_MODULES(PKG_XCB QUIET xcb xcb-util xcb-composite xcb-xfixes xcb-damage xcb-render xcb-randr
- xcb-shape xcb-dri2 xcb-glx xcb-shm xcb-xv xcb-sync
- xcb-xtest xcb-icccm xcb-ewmh xcb-image xcb-renderutil)
-
- SET(XCB_DEFINITIONS ${PKG_XCB_CFLAGS})
-
- FIND_PATH(XCB_XCB_INCLUDE_DIR NAMES xcb/xcb.h HINTS ${PKG_XCB_INCLUDE_DIRS})
- FIND_PATH(XCB_COMPOSITE_INCLUDE_DIR NAMES xcb/composite.h HINTS ${PKG_XCB_INCLUDE_DIRS})
- FIND_PATH(XCB_XFIXES_INCLUDE_DIR NAMES xcb/xfixes.h HINTS ${PKG_XCB_INCLUDE_DIRS})
- FIND_PATH(XCB_DAMAGE_INCLUDE_DIR NAMES xcb/damage.h HINTS ${PKG_XCB_INCLUDE_DIRS})
- FIND_PATH(XCB_RENDER_INCLUDE_DIR NAMES xcb/render.h HINTS ${PKG_XCB_INCLUDE_DIRS})
- FIND_PATH(XCB_RANDR_INCLUDE_DIR NAMES xcb/randr.h HINTS ${PKG_XCB_INCLUDE_DIRS})
- FIND_PATH(XCB_SHAPE_INCLUDE_DIR NAMES xcb/shape.h HINTS ${PKG_XCB_INCLUDE_DIRS})
- FIND_PATH(XCB_SHM_INCLUDE_DIR NAMES xcb/shm.h HINTS ${PKG_XCB_INCLUDE_DIRS})
- FIND_PATH(XCB_SYNC_INCLUDE_DIR NAMES xcb/sync.h HINTS ${PKG_XCB_INCLUDE_DIRS})
- FIND_PATH(XCB_IMAGE_INCLUDE_DIR NAMES xcb/xcb_image.h HINTS ${PKG_XCB_INCLUDE_DIRS})
- FIND_PATH(XCB_RENDERUTIL_INCLUDE_DIR NAMES xcb/xcb_renderutil.h HINTS ${PKG_XCB_INCLUDE_DIRS})
-
- FIND_LIBRARY(XCB_XCB_LIBRARIES NAMES xcb HINTS ${PKG_XCB_LIBRARY_DIRS})
- FIND_LIBRARY(XCB_COMPOSITE_LIBRARIES NAMES xcb-composite HINTS ${PKG_XCB_LIBRARY_DIRS})
- FIND_LIBRARY(XCB_DAMAGE_LIBRARIES NAMES xcb-damage HINTS ${PKG_XCB_LIBRARY_DIRS})
- FIND_LIBRARY(XCB_XFIXES_LIBRARIES NAMES xcb-xfixes HINTS ${PKG_XCB_LIBRARY_DIRS})
- FIND_LIBRARY(XCB_RENDER_LIBRARIES NAMES xcb-render HINTS ${PKG_XCB_LIBRARY_DIRS})
- FIND_LIBRARY(XCB_RANDR_LIBRARIES NAMES xcb-randr HINTS ${PKG_XCB_LIBRARY_DIRS})
- FIND_LIBRARY(XCB_SHAPE_LIBRARIES NAMES xcb-shape HINTS ${PKG_XCB_LIBRARY_DIRS})
- FIND_LIBRARY(XCB_SHM_LIBRARIES NAMES xcb-shm HINTS ${PKG_XCB_LIBRARY_DIRS})
- FIND_LIBRARY(XCB_SYNC_LIBRARIES NAMES xcb-sync HINTS ${PKG_XCB_LIBRARY_DIRS})
- FIND_LIBRARY(XCB_IMAGE_LIBRARIES NAMES xcb-image HINTS ${PKG_XCB_LIBRARY_DIRS})
- FIND_LIBRARY(XCB_RENDERUTIL_LIBRARIES NAMES xcb-render-util HINTS ${PKG_XCB_LIBRARY_DIRS})
-
- set(XCB_INCLUDE_DIR ${XCB_XCB_INCLUDE_DIR} ${XCB_COMPOSITE_INCLUDE_DIR} ${XCB_XFIXES_INCLUDE_DIR}
- ${XCB_DAMAGE_INCLUDE_DIR} ${XCB_RENDER_INCLUDE_DIR} ${XCB_RANDR_INCLUDE_DIR}
- ${XCB_SHAPE_INCLUDE_DIR} ${XCB_SHM_INCLUDE_DIR} ${XCB_SYNC_INCLUDE_DIR}
- ${XCB_IMAGE_INCLUDE_DIR} ${XCB_RENDERUTIL_INCLUDE_DIR})
-
- set(XCB_LIBRARIES ${XCB_XCB_LIBRARIES} ${XCB_COMPOSITE_LIBRARIES} ${XCB_XFIXES_LIBRARIES}
- ${XCB_DAMAGE_LIBRARIES} ${XCB_RENDER_LIBRARIES} ${XCB_RANDR_LIBRARIES}
- ${XCB_SHAPE_LIBRARIES} ${XCB_SHM_LIBRARIES} ${XCB_SYNC_LIBRARIES}
- ${XCB_IMAGE_LIBRARIES} ${XCB_RENDERUTIL_LIBRARIES})
-
- list(REMOVE_DUPLICATES XCB_INCLUDE_DIR)
-
- include(FindPackageHandleStandardArgs)
-
- FIND_PACKAGE_HANDLE_STANDARD_ARGS(XCB_XCB DEFAULT_MSG XCB_XCB_LIBRARIES XCB_XCB_INCLUDE_DIR)
- FIND_PACKAGE_HANDLE_STANDARD_ARGS(XCB_COMPOSITE DEFAULT_MSG XCB_COMPOSITE_LIBRARIES XCB_COMPOSITE_INCLUDE_DIR)
- FIND_PACKAGE_HANDLE_STANDARD_ARGS(XCB_DAMAGE DEFAULT_MSG XCB_DAMAGE_LIBRARIES XCB_DAMAGE_INCLUDE_DIR)
- FIND_PACKAGE_HANDLE_STANDARD_ARGS(XCB_XFIXES DEFAULT_MSG XCB_XFIXES_LIBRARIES XCB_XFIXES_INCLUDE_DIR)
- FIND_PACKAGE_HANDLE_STANDARD_ARGS(XCB_RENDER DEFAULT_MSG XCB_RENDER_LIBRARIES XCB_RENDER_INCLUDE_DIR)
- FIND_PACKAGE_HANDLE_STANDARD_ARGS(XCB_RANDR DEFAULT_MSG XCB_RANDR_LIBRARIES XCB_RANDR_INCLUDE_DIR)
- FIND_PACKAGE_HANDLE_STANDARD_ARGS(XCB_SHAPE DEFAULT_MSG XCB_SHAPE_LIBRARIES XCB_SHAPE_INCLUDE_DIR)
- FIND_PACKAGE_HANDLE_STANDARD_ARGS(XCB_SHM DEFAULT_MSG XCB_SHM_LIBRARIES XCB_SHM_INCLUDE_DIR)
- FIND_PACKAGE_HANDLE_STANDARD_ARGS(XCB_SYNC DEFAULT_MSG XCB_SYNC_LIBRARIES XCB_SYNC_INCLUDE_DIR)
- FIND_PACKAGE_HANDLE_STANDARD_ARGS(XCB_IMAGE DEFAULT_MSG XCB_IMAGE_LIBRARIES XCB_IMAGE_INCLUDE_DIR)
- FIND_PACKAGE_HANDLE_STANDARD_ARGS(XCB_RENDERUTIL DEFAULT_MSG XCB_RENDERUTIL_LIBRARIES XCB_RENDERUTIL_INCLUDE_DIR)
- FIND_PACKAGE_HANDLE_STANDARD_ARGS(XCB DEFAULT_MSG XCB_LIBRARIES XCB_INCLUDE_DIR)
-
- MARK_AS_ADVANCED(
- XCB_INCLUDE_DIR XCB_LIBRARIES
- XCB_XCB_INCLUDE_DIR XCB_XCB_LIBRARIES
- XCB_COMPOSITE_INCLUDE_DIR XCB_COMPOSITE_LIBRARIES
- XCB_DAMAGE_INCLUDE_DIR XCB_DAMAGE_LIBRARIES
- XCB_XFIXES_INCLUDE_DIR XCB_XFIXES_LIBRARIES
- XCB_RENDER_INCLUDE_DIR XCB_RENDER_LIBRARIES
- XCB_RANDR_INCLUDE_DIR XCB_RANDR_LIBRARIES
- XCB_SHAPE_INCLUDE_DIR XCB_SHAPE_LIBRARIES
- XCB_SHM_INCLUDE_DIR XCB_SHM_LIBRARIES
- XCB_SYNC_INCLUDE_DIR XCB_SYNC_LIBRARIES
- XCB_IMAGE_INCLUDE_DIR XCB_IMAGE_LIBRARIES
- XCB_RENDERUTIL_INCLUDE_DIR XCB_RENDERUTIL_LIBRARIES
- )
-
-ENDIF (NOT WIN32)
|
[-]
[+]
|
Deleted |
libkscreen-5.0.95.tar.xz/src/backendloader.cpp
^
|
@@ -1,102 +0,0 @@
-/*************************************************************************************
- * Copyright (C) 2012 by Alejandro Fiestas Olivares <afiestas@kde.org> *
- * *
- * This library is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * This library 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 *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this library; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
- *************************************************************************************/
-
-#include "backendloader.h"
-#include "debug_p.h"
-#include "backends/abstractbackend.h"
-
-#include <QtCore/QStringList>
-#include <QtCore/QCoreApplication>
-#include <QtCore/QPluginLoader>
-#include <QX11Info>
-#include <QDir>
-
-AbstractBackend* BackendLoader::s_backend = 0;
-
-
-bool BackendLoader::init()
-{
- if (s_backend) {
- return true;
- }
-
- qCDebug(KSCREEN) << "Loading backend";
-
- const QString backend = qgetenv("KSCREEN_BACKEND").constData();
- const QString backendFilter = QString::fromLatin1("KSC_%1*").arg(backend);
-
- const QStringList paths = QCoreApplication::libraryPaths();
- Q_FOREACH (const QString &path, paths) {
- const QDir dir(path + QDir::separator() + QLatin1String("/kf5/kscreen/"),
- backendFilter,
- QDir::SortFlags(QDir::QDir::NoSort),
- QDir::NoDotAndDotDot | QDir::Files);
- 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"))) {
- continue;
- }
-
- // When on X11, skip the QScreen backend, instead use the XRandR backend,
- // if not specified in KSCREEN_BACKEND
- if (backend.isEmpty() &&
- finfo.fileName().contains(QLatin1String("KSC_QScreen")) &&
- QX11Info::isPlatformX11()) {
- continue;
- }
-
- // When not on X11, skip the XRandR backend, and fall back to QSCreen
- // if not specified in KSCREEN_BACKEND
- if (backend.isEmpty() &&
- finfo.fileName().contains(QLatin1String("KSC_XRandR")) &&
- !QX11Info::isPlatformX11()) {
- continue;
- }
-
- QPluginLoader loader(finfo.filePath());
- loader.load();
- QObject *instance = loader.instance();
- if (!instance) {
- loader.unload();
- continue;
- }
-
- s_backend = qobject_cast< AbstractBackend* >(instance);
- if (s_backend) {
- if (!s_backend->isValid()) {
- qCDebug(KSCREEN) << "Skipping" << s_backend->name() << "backend";
- delete s_backend;
- s_backend = 0;
- loader.unload();
- continue;
- }
- qCDebug(KSCREEN) << "Loading" << s_backend->name() << "backend";
- return true;
- }
- }
- }
-
- qCDebug(KSCREEN) << "No backend found!";
- return false;
-}
-
-AbstractBackend* BackendLoader::backend()
-{
- return s_backend;
-}
|
[-]
[+]
|
Deleted |
libkscreen-5.0.95.tar.xz/src/backendloader.h
^
|
@@ -1,34 +0,0 @@
-/*************************************************************************************
- * Copyright (C) 2012 by Alejandro Fiestas Olivares <afiestas@kde.org> *
- * *
- * This library is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU Lesser General Public *
- * License as published by the Free Software Foundation; either *
- * version 2.1 of the License, or (at your option) any later version. *
- * *
- * This library 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 *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this library; if not, write to the Free Software *
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
- *************************************************************************************/
-
-#ifndef BACKEND_LOADER_H
-#define BACKEND_LOADER_H
-
-class AbstractBackend;
-
-class BackendLoader
-{
- public:
- static bool init();
- static AbstractBackend* backend();
-
- private:
- static AbstractBackend* s_backend;
-};
-
-#endif //BACKEND_LOADER_H
|
[-]
[+]
|
Added |
libkscreen-5.1.90.tar.xz/.gitignore
^
|
@@ -0,0 +1,4 @@
+.kdev4
+*.kdev4
+build
+build-overlay
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/CMakeLists.txt
^
|
@@ -1,4 +1,5 @@
project(libkscreen)
+set(PROJECT_VERSION "5.1.95")
cmake_minimum_required(VERSION 2.8.12)
@@ -15,7 +16,7 @@
include(CheckCXXCompilerFlag)
set(REQUIRED_QT_VERSION 5.2.0)
-find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Core Gui Test X11Extras)
+find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Core DBus Gui Test X11Extras)
find_package(XCB COMPONENTS XCB RANDR)
set_package_properties(XCB PROPERTIES
@@ -30,11 +31,11 @@
PURPOSE "Required for building XRandR 1.2 backend"
)
-set(KF5_VERSION "5.0.91") #When we are happy with the api, we can sync with frameworks
+set(KF5_VERSION ${PROJECT_VERSION}) #When we are happy with the api, we can sync with frameworks
ecm_setup_version(${KF5_VERSION} VARIABLE_PREFIX KSCREEN
VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/kscreen_version.h"
PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5ScreenConfigVersion.cmake"
- SOVERSION 5)
+ SOVERSION 6)
check_cxx_compiler_flag(-fvisibility=hidden _HAVE_VISIBILITY)
if (_HAVE_VISIBILITY AND NOT WIN32)
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/autotests/CMakeLists.txt
^
|
@@ -1,17 +1,23 @@
add_definitions(-DTEST_DATA="${CMAKE_CURRENT_SOURCE_DIR}/configs/")
-macro(KSCREEN_TESTS)
+include_directories(${CMAKE_CURRENT_BINARY_DIR})
+
+macro(KSCREEN_ADD_TEST)
foreach(_testname ${ARGN})
- add_executable(${_testname} ${_testname}.cpp)
- target_link_libraries(${_testname} Qt5::Core Qt5::Gui Qt5::Test KF5::Screen)
+ set(test_SRCS ${_testname}.cpp)
+ 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})
ecm_mark_as_test(${_testname})
endforeach(_testname)
-endmacro(KSCREEN_TESTS)
+endmacro(KSCREEN_ADD_TEST)
-KSCREEN_TESTS(testscreenconfig )
-KSCREEN_TESTS(testqscreenbackend )
+kscreen_add_test(testscreenconfig)
+kscreen_add_test(testqscreenbackend)
+kscreen_add_test(testconfigserializer)
+kscreen_add_test(testconfigmonitor)
if (ENABLE_XRANDR_TESTS)
- KSCREEN_TESTS(testxrandr )
+ kscreen_add_test(textxrandr)
endif()
|
[-]
[+]
|
Added |
libkscreen-5.1.90.tar.xz/autotests/configs/default.json
^
|
@@ -0,0 +1,660 @@
+{
+ "outputs": [
+ {
+ "clones": [
+ ],
+ "connected": true,
+ "currentModeId": "73",
+ "enabled": false,
+ "icon": "",
+ "id": 66,
+ "modes": [
+ {
+ "id": "73",
+ "name": "1920x1080",
+ "refreshRate": 60.06005859375,
+ "size": {
+ "height": 1080,
+ "width": 1920
+ }
+ },
+ {
+ "id": "74",
+ "name": "1400x1050",
+ "refreshRate": 59.975616455078125,
+ "size": {
+ "height": 1050,
+ "width": 1400
+ }
+ },
+ {
+ "id": "75",
+ "name": "1280x1024",
+ "refreshRate": 60.019741058349609,
+ "size": {
+ "height": 1024,
+ "width": 1280
+ }
+ },
+ {
+ "id": "76",
+ "name": "1280x960",
+ "refreshRate": 60,
+ "size": {
+ "height": 960,
+ "width": 1280
+ }
+ },
+ {
+ "id": "77",
+ "name": "1024x768",
+ "refreshRate": 60.003841400146484,
+ "size": {
+ "height": 768,
+ "width": 1024
+ }
+ },
+ {
+ "id": "78",
+ "name": "800x600",
+ "refreshRate": 60.316539764404297,
+ "size": {
+ "height": 600,
+ "width": 800
+ }
+ },
+ {
+ "id": "79",
+ "name": "800x600",
+ "refreshRate": 56.25,
+ "size": {
+ "height": 600,
+ "width": 800
+ }
+ },
+ {
+ "id": "80",
+ "name": "640x480",
+ "refreshRate": 59.940475463867188,
+ "size": {
+ "height": 480,
+ "width": 640
+ }
+ }
+ ],
+ "name": "eDP1",
+ "pos": {
+ "x": 0,
+ "y": 0
+ },
+ "preferredModes": [
+ "73"
+ ],
+ "primary": false,
+ "rotation": 1,
+ "sizeMM": {
+ "height": 193,
+ "width": 344
+ },
+ "type": 7
+ },
+ {
+ "clones": [
+ ],
+ "connected": true,
+ "currentModeId": "869",
+ "enabled": true,
+ "icon": "",
+ "id": 67,
+ "modes": [
+ {
+ "id": "75",
+ "name": "1280x1024",
+ "refreshRate": 60.019741058349609,
+ "size": {
+ "height": 1024,
+ "width": 1280
+ }
+ },
+ {
+ "id": "76",
+ "name": "1280x960",
+ "refreshRate": 60,
+ "size": {
+ "height": 960,
+ "width": 1280
+ }
+ },
+ {
+ "id": "77",
+ "name": "1024x768",
+ "refreshRate": 60.003841400146484,
+ "size": {
+ "height": 768,
+ "width": 1024
+ }
+ },
+ {
+ "id": "78",
+ "name": "800x600",
+ "refreshRate": 60.316539764404297,
+ "size": {
+ "height": 600,
+ "width": 800
+ }
+ },
+ {
+ "id": "79",
+ "name": "800x600",
+ "refreshRate": 56.25,
+ "size": {
+ "height": 600,
+ "width": 800
+ }
+ },
+ {
+ "id": "854",
+ "name": "1280x1024",
+ "refreshRate": 75.024673461914062,
+ "size": {
+ "height": 1024,
+ "width": 1280
+ }
+ },
+ {
+ "id": "855",
+ "name": "1440x900",
+ "refreshRate": 59.887443542480469,
+ "size": {
+ "height": 900,
+ "width": 1440
+ }
+ },
+ {
+ "id": "856",
+ "name": "1280x800",
+ "refreshRate": 59.810325622558594,
+ "size": {
+ "height": 800,
+ "width": 1280
+ }
+ },
+ {
+ "id": "857",
+ "name": "1152x864",
+ "refreshRate": 75,
+ "size": {
+ "height": 864,
+ "width": 1152
+ }
+ },
+ {
+ "id": "859",
+ "name": "1024x768",
+ "refreshRate": 75.076217651367188,
+ "size": {
+ "height": 768,
+ "width": 1024
+ }
+ },
|
[-]
[+]
|
Added |
libkscreen-5.1.90.tar.xz/autotests/testconfigmonitor.cpp
^
|
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2014 Daniel Vratil <dvratil@redhat.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#include <QObject>
+#include <QtTest>
+#include <QSignalSpy>
+
+#include "../src/config.h"
+#include "../src/output.h"
+#include "../src/configmonitor.h"
+#include "../src/getconfigoperation.h"
+#include "../src/backendmanager_p.h"
+#include <QtTest/qsignalspy.h>
+
+#include "fakebackendinterface.h"
+
+class TestConfigMonitor : public QObject
+{
+ Q_OBJECT
+public:
+ TestConfigMonitor()
+ {
+ }
+
+ KScreen::ConfigPtr getConfig()
+ {
+ KScreen::GetConfigOperation *op = new KScreen::GetConfigOperation();
+ if (!op->exec()) {
+ qWarning("Failed to retrieve backend: %s", qPrintable(op->errorString()));
+ return KScreen::ConfigPtr();
+ }
+
+ return op->config();
+ }
+
+private Q_SLOTS:
+ void initTestCase()
+ {
+ setenv("KSCREEN_BACKEND", "Fake", 1);
+ KScreen::BackendManager::instance()->shutdownBackend();
+ }
+
+ void cleanupTestCase()
+ {
+ KScreen::BackendManager::instance()->shutdownBackend();
+ }
+
+ void testChangeNotify()
+ {
+ //json file for the fake backend
+ QByteArray path(TEST_DATA);
+ path.append("/singleoutput.json");
+ setenv("TEST_DATA", path, 1);
+
+ // Prepare monitor
+ KScreen::ConfigMonitor *monitor = KScreen::ConfigMonitor::instance();
+ QSignalSpy spy(monitor, SIGNAL(configurationChanged()));
+
+ // Get config and let it monitored
+ KScreen::ConfigPtr config = getConfig();
+ monitor->addConfig(config);
+ QSignalSpy enabledSpy(config->output(1).data(), SIGNAL(isEnabledChanged()));
+
+
+ auto iface = new org::kde::kscreen::FakeBackend(QLatin1String("org.kde.KScreen.Backend.Fake"),
+ QLatin1String("/fake"),
+ QDBusConnection::sessionBus());
+ QVERIFY(iface->isValid());
+
+ iface->setEnabled(1, false).waitForFinished();
+
+ QTRY_VERIFY(!spy.isEmpty());
+
+ QCOMPARE(spy.size(), 1);
+ QCOMPARE(enabledSpy.size(), 1);
+ QCOMPARE(config->output(1)->isEnabled(), false);
+
+ }
+
+};
+
+QTEST_MAIN(TestConfigMonitor)
+
+#include "testconfigmonitor.moc"
|
[-]
[+]
|
Added |
libkscreen-5.1.90.tar.xz/autotests/testconfigserializer.cpp
^
|
@@ -0,0 +1,191 @@
+/*
+ * Copyright (C) 2014 Daniel Vratil <dvratil@redhat.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#include <QObject>
+#include <QtTest>
+
+#include "../src/types.h"
+#include "../src/configserializer_p.h"
+#include "../src/screen.h"
+#include "../src/mode.h"
+#include "../src/output.h"
+
+class TestConfigSerializer : public QObject
+{
+ Q_OBJECT
+
+public:
+ TestConfigSerializer()
+ {
+ }
+
+
+private Q_SLOTS:
+ void testSerializePoint()
+ {
+ const QPoint point(42, 24);
+
+ const QJsonObject obj = KScreen::ConfigSerializer::serializePoint(point);
+ QVERIFY(!obj.isEmpty());
+
+ QCOMPARE(obj[QLatin1String("x")].toInt(), point.x());
+ QCOMPARE(obj[QLatin1String("y")].toInt(), point.y());
+ }
+
+ void testSerializeSize()
+ {
+ const QSize size(800, 600);
+
+ const QJsonObject obj = KScreen::ConfigSerializer::serializeSize(size);
+ QVERIFY(!obj.isEmpty());
+
+ QCOMPARE(obj[QLatin1String("width")].toInt(), size.width());
+ QCOMPARE(obj[QLatin1String("height")].toInt(), size.height());
+ }
+
+ void testSerializeList()
+ {
+ QStringList stringList;
+ stringList << QLatin1String("Item 1")
+ << QLatin1String("Item 2")
+ << QLatin1String("Item 3")
+ << QLatin1String("Item 4");
+
+ QJsonArray arr = KScreen::ConfigSerializer::serializeList<QString>(stringList);
+ QCOMPARE(arr.size(), stringList.size());
+
+ for (int i = 0; i < arr.size(); ++i) {
+ QCOMPARE(arr.at(i).toString(), stringList.at(i));
+ }
+
+
+
+ QList<int> intList;
+ intList << 4 << 3 << 2 << 1;
+
+ arr = KScreen::ConfigSerializer::serializeList<int>(intList);
+ QCOMPARE(arr.size(), intList.size());
+
+ for (int i = 0; i < arr.size(); ++i) {
+ QCOMPARE(arr.at(i).toInt(), intList[i]);
+ }
+ }
+
+ void testSerializeScreen()
+ {
+ KScreen::ScreenPtr screen(new KScreen::Screen);
+ screen->setId(12);
+ screen->setMinSize(QSize(360, 360));
+ screen->setMaxSize(QSize(8192, 8192));
+ screen->setCurrentSize(QSize(3600, 1280));
+ screen->setMaxActiveOutputsCount(3);
+
+ const QJsonObject obj = KScreen::ConfigSerializer::serializeScreen(screen);
+ QVERIFY(!obj.isEmpty());
+
+ QCOMPARE(obj[QLatin1String("id")].toInt(), screen->id());
+ QCOMPARE(obj[QLatin1String("maxActiveOutputsCount")].toInt(), screen->maxActiveOutputsCount());
+ const QJsonObject minSize = obj[QLatin1String("minSize")].toObject();
+ QCOMPARE(minSize[QLatin1String("width")].toInt(), screen->minSize().width());
+ QCOMPARE(minSize[QLatin1String("height")].toInt(), screen->minSize().height());
+ const QJsonObject maxSize = obj[QLatin1String("maxSize")].toObject();
+ QCOMPARE(maxSize[QLatin1String("width")].toInt(), screen->maxSize().width());
+ QCOMPARE(maxSize[QLatin1String("height")].toInt(), screen->maxSize().height());
+ const QJsonObject currSize = obj[QLatin1String("currentSize")].toObject();
+ QCOMPARE(currSize[QLatin1String("width")].toInt(), screen->currentSize().width());
+ QCOMPARE(currSize[QLatin1String("height")].toInt(), screen->currentSize().height());
+ }
+
+ void testSerializeMode()
+ {
+ KScreen::ModePtr mode(new KScreen::Mode);
+ mode->setId(QLatin1String("755"));
+ mode->setName(QLatin1String("1280x1024"));
+ mode->setRefreshRate(50.666);
+ mode->setSize(QSize(1280, 1024));
+
+ const QJsonObject obj = KScreen::ConfigSerializer::serializeMode(mode);
+ QVERIFY(!obj.isEmpty());
+
+ QCOMPARE(obj[QLatin1String("id")].toString(), mode->id());
+ QCOMPARE(obj[QLatin1String("name")].toString(), mode->name());
+ QCOMPARE((float) obj[QLatin1String("refreshRate")].toDouble(), mode->refreshRate());
+ const QJsonObject size = obj[QLatin1String("size")].toObject();
+ QCOMPARE(size[QLatin1String("width")].toInt(), mode->size().width());
+ QCOMPARE(size[QLatin1String("height")].toInt(), mode->size().height());
+ }
+
+ void testSerializeOutput()
+ {
+ KScreen::ModeList modes;
+ KScreen::ModePtr mode(new KScreen::Mode);
+ mode->setId(QLatin1String("1"));
+ mode->setName(QLatin1String("800x600"));
+ mode->setSize(QSize(800, 600));
+ mode->setRefreshRate(50.4);
+ modes.insert(mode->id(), mode);
+
+ KScreen::OutputPtr output(new KScreen::Output);
+ output->setId(60);
+ output->setName(QLatin1String("LVDS-0"));
+ output->setType(KScreen::Output::Panel);
+ output->setIcon(QString());
+ output->setModes(modes);
+ output->setPos(QPoint(1280, 0));
+ output->setRotation(KScreen::Output::None);
+ output->setCurrentModeId(QLatin1String("1"));
+ output->setPreferredModes(QStringList() << QLatin1String("1"));
+ output->setConnected(true);
+ output->setEnabled(true);
+ output->setPrimary(true);
+ output->setClones(QList<int>() << 50 << 60);
+ output->setSizeMm(QSize(310, 250));
+
+ const QJsonObject obj = KScreen::ConfigSerializer::serializeOutput(output);
+ QVERIFY(!obj.isEmpty());
+
+ QCOMPARE(obj[QLatin1String("id")].toInt(), output->id());
+ QCOMPARE(obj[QLatin1String("name")].toString(), output->name());
+ QCOMPARE(static_cast<KScreen::Output::Type>(obj[QLatin1String("type")].toInt()), output->type());
+ QCOMPARE(obj[QLatin1String("icon")].toString(), output->icon());
+ const QJsonArray arr = obj[QLatin1String("modes")].toArray();
+ QCOMPARE(arr.size(), output->modes().count());
+
+ const QJsonObject pos = obj[QLatin1String("pos")].toObject();
+ QCOMPARE(pos[QLatin1String("x")].toInt(), output->pos().x());
+ QCOMPARE(pos[QLatin1String("y")].toInt(), output->pos().y());
+ QCOMPARE(static_cast<KScreen::Output::Rotation>(obj[QLatin1String("rotation")].toInt()), output->rotation());
+ QCOMPARE(obj[QLatin1String("currentModeId")].toString(), output->currentModeId());
+ QCOMPARE(obj[QLatin1String("connected")].toBool(), output->isConnected());
+ QCOMPARE(obj[QLatin1String("enabled")].toBool(), output->isEnabled());
+ QCOMPARE(obj[QLatin1String("primary")].toBool(), output->isPrimary());
+ const QJsonArray clones = obj[QLatin1String("clones")].toArray();
+ QCOMPARE(clones.size(), output->clones().count());
+ for (int i = 0; i < clones.size(); ++i) {
+ QCOMPARE(clones[i].toInt(), output->clones()[i]);
+ }
+ const QJsonObject sizeMm = obj[QLatin1String("sizeMM")].toObject();
+ QCOMPARE(sizeMm[QLatin1String("width")].toInt(), output->sizeMm().width());
+ QCOMPARE(sizeMm[QLatin1String("height")].toInt(), output->sizeMm().height());
+ }
+};
+
+QTEST_MAIN(TestConfigSerializer)
+
+#include "testconfigserializer.moc"
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/autotests/testqscreenbackend.cpp
^
|
@@ -26,6 +26,8 @@
#include "../src/output.h"
#include "../src/mode.h"
#include "../src/edid.h"
+#include "../src/getconfigoperation.h"
+#include "../src/backendmanager_p.h"
Q_LOGGING_CATEGORY(KSCREEN_QSCREEN, "kscreen.qscreen");
@@ -46,22 +48,26 @@
private:
QProcess m_process;
- Config *m_config;
+ ConfigPtr m_config;
QString m_backend;
};
void testQScreenBackend::initTestCase()
{
- setenv("KSCREEN_BACKEND", "qscreen", 1);
+ setenv("KSCREEN_BACKEND", "qscreen", 1);
+ KScreen::BackendManager::instance()->shutdownBackend();
+
// setenv("KSCREEN_BACKEND", "xrandr", 1);
m_backend = qgetenv("KSCREEN_BACKEND").constData();
- m_config = Config::current();
+ GetConfigOperation *op = new GetConfigOperation();
+ op->exec();
+ m_config = op->config();
}
void testQScreenBackend::verifyConfig()
{
- QVERIFY(m_config != 0);
+ QVERIFY(!m_config.isNull());
if (!m_config) {
QSKIP("QScreenbackend invalid", SkipAll);
}
@@ -69,7 +75,7 @@
void testQScreenBackend::verifyScreen()
{
- Screen *screen = m_config->screen();
+ ScreenPtr screen = m_config->screen();
QVERIFY(screen->minSize().width() <= screen->maxSize().width());
QVERIFY(screen->minSize().height() <= screen->maxSize().height());
@@ -87,7 +93,7 @@
{
bool primaryFound = false;
- foreach (const KScreen::Output* op, m_config->outputs()) {
+ foreach (const KScreen::OutputPtr &op, m_config->outputs()) {
qDebug() << "CHecking at all";
if (op->isPrimary()) {
primaryFound = true;
@@ -99,7 +105,7 @@
QCOMPARE(m_config->outputs().count(), QGuiApplication::screens().count());
}
- KScreen::Output *primary = m_config->primaryOutput();
+ const KScreen::OutputPtr primary = m_config->primaryOutput();
qDebug() << "ppp" << primary;
QVERIFY(primary->isEnabled());
QVERIFY(primary->isConnected());
@@ -108,7 +114,7 @@
QList<int> ids;
- foreach (auto output, m_config->outputs()) {
+ foreach (const KScreen::OutputPtr &output, m_config->outputs()) {
qDebug() << " _____________________ Output: " << output;
qDebug() << " output name: " << output->name();
qDebug() << " output modes: " << output->modes().count() << output->modes();
@@ -131,12 +137,12 @@
void testQScreenBackend::verifyModes()
{
- KScreen::Output *primary = m_config->primaryOutput();
+ const KScreen::OutputPtr primary = m_config->primaryOutput();
QVERIFY(primary);
QVERIFY(primary->modes().count() > 0);
- foreach (auto output, m_config->outputs()) {
- foreach (auto mode, output->modes()) {
+ foreach (const KScreen::OutputPtr &output, m_config->outputs()) {
+ foreach (const KScreen::ModePtr &mode, output->modes()) {
qDebug() << " Mode : " << mode->name();
QVERIFY(!mode->name().isEmpty());
QVERIFY(mode->refreshRate() > 0);
@@ -147,10 +153,13 @@
void testQScreenBackend::commonUsagePattern()
{
- KScreen::OutputList outputs = KScreen::Config::current()->outputs();
+ GetConfigOperation *op = new GetConfigOperation();
+ op->exec();
+
+ const KScreen::OutputList outputs = op->config()->outputs();
QVariantList outputList;
- Q_FOREACH(KScreen::Output *output, outputs) {
+ Q_FOREACH(const KScreen::OutputPtr &output, outputs) {
if (!output->isConnected()) {
continue;
}
@@ -168,7 +177,7 @@
info["pos"] = pos;
if (output->isEnabled()) {
- KScreen::Mode *mode = output->currentMode();
+ const KScreen::ModePtr mode = output->currentMode();
if (!mode) {
//qWarning() << "CurrentMode is null" << output->name();
return;
@@ -191,7 +200,7 @@
void testQScreenBackend::cleanupTestCase()
{
- delete m_config;
+ KScreen::BackendManager::instance()->shutdownBackend();
qApp->exit(0);
}
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/autotests/testscreenconfig.cpp
^
|
@@ -23,6 +23,8 @@
#include "../src/config.h"
#include "../src/output.h"
#include "../src/mode.h"
+#include "../src/getconfigoperation.h"
+#include "../src/backendmanager_p.h"
using namespace KScreen;
@@ -30,6 +32,9 @@
{
Q_OBJECT
+private:
+ KScreen::ConfigPtr getConfig();
+
private Q_SLOTS:
void initTestCase();
void singleOutput();
@@ -37,13 +42,33 @@
void multiOutput();
void clonesOutput();
void configCanBeApplied();
+ void cleanupTestCase();
};
+ConfigPtr testScreenConfig::getConfig()
+{
+ GetConfigOperation *op = new GetConfigOperation();
+ if (!op->exec()) {
+ qWarning("GetConfigOperation error: %s", qPrintable(op->errorString()));
+ return ConfigPtr();
+ }
+
+ BackendManager::instance()->shutdownBackend();
+
+ return op->config();
+}
+
+
void testScreenConfig::initTestCase()
{
setenv("KSCREEN_BACKEND", "Fake", 1);
}
+void testScreenConfig::cleanupTestCase()
+{
+ BackendManager::instance()->shutdownBackend();
+}
+
void testScreenConfig::singleOutput()
{
//json file for the fake backend
@@ -55,9 +80,12 @@
// QVERIFY2(!kscreen->backend().isEmpty(), "No backend loaded");
- Config *config = Config::current();
- Screen* screen = config->screen();
+
+ const ConfigPtr config = getConfig();
+ QVERIFY(!config.isNull());
+ const ScreenPtr screen = config->screen();
+ QVERIFY(!screen.isNull());
QCOMPARE(screen->minSize(), QSize(320, 200));
QCOMPARE(screen->maxSize(), QSize(8192, 8192));
@@ -65,7 +93,8 @@
QCOMPARE(config->outputs().count(), 1);
- Output *output = config->outputs().take(1);
+ const OutputPtr output = config->outputs().take(1);
+ QVERIFY(!output.isNull());
QCOMPARE(output->name(), QString("LVDS1"));
QCOMPARE(output->type(), Output::Panel);
@@ -81,7 +110,7 @@
//QCOMPARE(output->isEmbedded(), true);
QVERIFY2(output->clones().isEmpty(), "In singleOutput is impossible to have clones");
- Mode* mode = output->currentMode();
+ const ModePtr mode = output->currentMode();
QCOMPARE(mode->size(), QSize(1280, 800));
QCOMPARE(mode->refreshRate(), (float)59.9);
}
@@ -92,8 +121,10 @@
path.append("/singleOutputWithoutPreferred.json");
setenv("TEST_DATA", path, 1);
- Config* config = Config::current();
- Output* output = config->outputs().take(1);
+ const ConfigPtr config = getConfig();
+ QVERIFY(!config.isNull());
+ const OutputPtr output = config->outputs().take(1);
+ QVERIFY(!output.isNull());
QVERIFY(output->preferredModes().isEmpty());
QCOMPARE(output->preferredModeId(), QLatin1String("3"));
@@ -105,9 +136,10 @@
path.append("/multipleoutput.json");
setenv("TEST_DATA", path, 1);
- Config *config = Config::current();
-
- Screen* screen = config->screen();
+ const ConfigPtr config = getConfig();
+ QVERIFY(!config.isNull());
+ const ScreenPtr screen = config->screen();
+ QVERIFY(!screen.isNull());
QCOMPARE(screen->minSize(), QSize(320, 200));
QCOMPARE(screen->maxSize(), QSize(8192, 8192));
@@ -115,7 +147,8 @@
QCOMPARE(config->outputs().count(), 2);
- Output *output = config->outputs().take(2);
+ const OutputPtr output = config->outputs().take(2);
+ QVERIFY(!output.isNull());
QCOMPARE(output->name(), QString("HDMI1"));
QCOMPARE(output->type(), Output::HDMI);
@@ -130,7 +163,8 @@
QCOMPARE(output->isPrimary(), false);
QVERIFY2(output->clones().isEmpty(), "This simulates extended output, no clones");
- Mode* mode = output->currentMode();
+ const ModePtr mode = output->currentMode();
+ QVERIFY(!mode.isNull());
QCOMPARE(mode->size(), QSize(1920, 1080));
QCOMPARE(mode->refreshRate(), (float)60.0);
}
@@ -141,15 +175,17 @@
path.append("/multipleclone.json");
setenv("TEST_DATA", path, 1);
- Config *config = Config::current();
- Screen* screen = config->screen();
+ const ConfigPtr config = getConfig();
+ QVERIFY(!config.isNull());
+ const ScreenPtr screen = config->screen();
+ QVERIFY(!screen.isNull());
QCOMPARE(screen->minSize(), QSize(320, 200));
QCOMPARE(screen->maxSize(), QSize(8192, 8192));
QCOMPARE(screen->currentSize(), QSize(1024, 768));
- Output* one = config->outputs()[1];
- Output* two = config->outputs()[2];
+ const OutputPtr one = config->outputs()[1];
+ const OutputPtr two = config->outputs()[2];
QCOMPARE(one->currentMode()->size(), two->currentMode()->size());
QCOMPARE(one->clones().count(), 1);
@@ -162,15 +198,17 @@
QByteArray path(TEST_DATA);
path.append("/singleoutputBroken.json");
setenv("TEST_DATA", path, 1);
- Config* brokenConfig = Config::current();
+ const ConfigPtr brokenConfig = getConfig();
path = TEST_DATA;
path.append("/singleoutput.json");
setenv("TEST_DATA", path, 1);
- Config* currentConfig = Config::current();
-
- Output* primaryBroken = brokenConfig->outputs()[2];
- Output* currentPrimary = currentConfig->outputs()[1];
+ const ConfigPtr currentConfig = getConfig();
+ QVERIFY(!currentConfig.isNull());
+ const OutputPtr primaryBroken = brokenConfig->outputs()[2];
+ QVERIFY(!primaryBroken.isNull());
+ const OutputPtr currentPrimary = currentConfig->outputs()[1];
+ QVERIFY(!currentPrimary.isNull());
QVERIFY(!Config::canBeApplied(brokenConfig));
primaryBroken->setId(currentPrimary->id());
@@ -188,16 +226,17 @@
path = TEST_DATA;
path.append("/tooManyOutputs.json");
setenv("TEST_DATA", path, 1);
- brokenConfig = Config::current();
+ const ConfigPtr brokenConfig2 = getConfig();
+ QVERIFY(!brokenConfig2.isNull());
int enabledOutputsCount = 0;
- Q_FOREACH (Output *output, brokenConfig->outputs()) {
+ Q_FOREACH (const OutputPtr &output, brokenConfig2->outputs()) {
if (output->isEnabled()) {
++enabledOutputsCount;
}
}
- QVERIFY(brokenConfig->screen()->maxActiveOutputsCount() < enabledOutputsCount);
- QVERIFY(!Config::canBeApplied(brokenConfig));
+ QVERIFY(brokenConfig2->screen()->maxActiveOutputsCount() < enabledOutputsCount);
+ QVERIFY(!Config::canBeApplied(brokenConfig2));
}
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/autotests/testxrandr.cpp
^
|
@@ -24,6 +24,7 @@
#include "../src/config.h"
#include "../src/output.h"
#include "../src/mode.h"
+#include "../src/getconfigoperation.h"
using namespace KScreen;
@@ -46,14 +47,18 @@
void testXRandR::singleOutput()
{
setenv("KSCREEN_BACKEND", "XRandR", 1);
- Config *config = Config::current();
+
+ GetConfigOperation *op = new GetConfigOperation();
+ QVERIFY(op->exec());
+
+ const ConfigPtr config = op->config();
if (!config) {
QSKIP("XRandR X extension is not available", SkipAll);
}
QCOMPARE(config->outputs().count(), 1);
- Output *output = config->outputs().take(327);
+ const OutputPtr output = config->outputs().take(327);
QCOMPARE(output->name(), QString("default"));
QCOMPARE(output->type(), Output::Unknown);
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/backends/fake/CMakeLists.txt
^
|
@@ -1,5 +1,6 @@
include_directories(${CMAKE_SOURCE_DIR}/src
${CMAKE_BUILD_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}
)
set(fake_SRCS
@@ -7,11 +8,17 @@
parser.cpp
)
+qt5_add_dbus_adaptor(fake_SRCS ${CMAKE_SOURCE_DIR}/interfaces/org.kde.KScreen.FakeBackend.xml
+ fake.h Fake
+)
+
add_library(KSC_Fake MODULE ${fake_SRCS})
set_target_properties(KSC_Fake PROPERTIES PREFIX "")
-target_link_libraries(KSC_Fake Qt5::Core
- KF5::Screen
+target_link_libraries(KSC_Fake
+ Qt5::Core
+ Qt5::DBus
+ KF5::Screen
)
install(TARGETS KSC_Fake DESTINATION ${PLUGIN_INSTALL_DIR}/kf5/kscreen/)
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/backends/fake/fake.cpp
^
|
@@ -21,28 +21,41 @@
#include "config.h"
#include "edid.h"
+#include <output.h>
#include <stdlib.h>
-#include <QtCore/QFile>
-#include <QtCore/qplugin.h>
+#include <QFile>
+#include <QTimer>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
+#include <QDBusConnection>
+
+#include "fakebackendadaptor.h"
+
using namespace KScreen;
Q_LOGGING_CATEGORY(KSCREEN_FAKE, "kscreen.fake")
-Fake::Fake(QObject* parent): QObject(parent)
+Fake::Fake()
+ : KScreen::AbstractBackend()
{
QLoggingCategory::setFilterRules(QStringLiteral("kscreen.fake.debug = true"));
+
+ QTimer::singleShot(0, this, SLOT(delayedInit()));
}
-Fake::~Fake()
+void Fake::delayedInit()
{
+ new FakeBackendAdaptor(this);
+ QDBusConnection::sessionBus().registerObject(QLatin1String("/fake"), this);
+}
+Fake::~Fake()
+{
}
QString Fake::name() const
@@ -50,12 +63,25 @@
return QString("Fake");
}
-Config* Fake::config() const
+QString Fake::serviceName() const
{
- return Parser::fromJson(QString(qgetenv("TEST_DATA")));
+ 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");
}
-void Fake::setConfig(Config* config) const
+ConfigPtr Fake::config() const
+{
+ if (mConfig.isNull()) {
+ mConfig = Parser::fromJson(QString(qgetenv("TEST_DATA")));
+ }
+
+ return mConfig;
+}
+
+void Fake::setConfig(const ConfigPtr &config)
{
Q_UNUSED(config)
}
@@ -65,31 +91,85 @@
return true;
}
-Edid *Fake::edid(int outputId) const
+QByteArray Fake::edid(int outputId) const
{
Q_UNUSED(outputId);
QFile file(QString(qgetenv("TEST_DATA")));
file.open(QIODevice::ReadOnly);
- QJsonDocument jsonDoc = QJsonDocument::fromJson(file.readAll());
- QJsonObject json = jsonDoc.object();
+ const QJsonDocument jsonDoc = QJsonDocument::fromJson(file.readAll());
+ const QJsonObject json = jsonDoc.object();
- QJsonArray outputs = json["outputs"].toArray();
+ const QJsonArray outputs = json["outputs"].toArray();
Q_FOREACH(const QJsonValue &value, outputs) {
- QVariantMap output = value.toObject().toVariantMap();
+ const QVariantMap output = value.toObject().toVariantMap();
if (output["id"].toInt() != outputId) {
continue;
}
- QByteArray data = QByteArray::fromBase64(output["edid"].toByteArray());
- return new Edid((quint8*)data.data(), data.length());
+ return QByteArray::fromBase64(output["edid"].toByteArray());
}
- return 0;
+ return QByteArray();
}
-void Fake::updateConfig(Config *config) const
+void Fake::setConnected(int outputId, bool connected)
{
- Q_UNUSED(config);
+ KScreen::OutputPtr output = config()->output(outputId);
+ if (output->isConnected() == connected) {
+ return;
+ }
+
+ output->setConnected(connected);
+ Q_EMIT configChanged(mConfig);
}
-#include "fake.moc"
+void Fake::setEnabled(int outputId, bool enabled)
+{
+ KScreen::OutputPtr output = config()->output(outputId);
+ if (output->isEnabled() == enabled) {
+ return;
+ }
+
+ output->setEnabled(enabled);
+ Q_EMIT configChanged(mConfig);
+}
+
+void Fake::setPrimary(int outputId, bool primary)
+{
+ KScreen::OutputPtr output = config()->output(outputId);
+ if (output->isPrimary() == primary) {
+ return;
+ }
+
+ Q_FOREACH (KScreen::OutputPtr output, config()->outputs()) {
+ if (output->id() == outputId) {
+ output->setPrimary(primary);
+ } else {
+ output->setPrimary(false);
+ }
+ }
+ Q_EMIT configChanged(mConfig);
+}
+
+void Fake::setCurrentModeId(int outputId, const QString &modeId)
+{
+ KScreen::OutputPtr output = config()->output(outputId);
+ if (output->currentModeId() == modeId) {
+ return;
+ }
+
+ output->setCurrentModeId(modeId);
+ Q_EMIT configChanged(mConfig);
+}
+
+void Fake::setRotation(int outputId, int rotation)
+{
+ KScreen::OutputPtr output = config()->output(outputId);
+ const KScreen::Output::Rotation rot = static_cast<KScreen::Output::Rotation>(rotation);
+ if (output->rotation() == rot) {
+ return;
+ }
+
+ output->setRotation(rot);
+ Q_EMIT configChanged(mConfig);
+}
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/backends/fake/fake.h
^
|
@@ -19,26 +19,39 @@
#ifndef FAKE_BACKEND_H
#define FAKE_BACKEND_H
-#include "../abstractbackend.h"
+#include "abstractbackend.h"
+
#include <QtCore/QObject>
#include <QLoggingCategory>
-class Fake : public QObject, public AbstractBackend
+class Fake : public KScreen::AbstractBackend
{
Q_OBJECT
- Q_INTERFACES(AbstractBackend)
Q_PLUGIN_METADATA(IID "org.kf5.kscreen.backends.fake")
- public:
- explicit Fake(QObject* parent = 0);
- virtual ~Fake();
-
- virtual QString name() const;
- virtual KScreen::Config* config() const;
- virtual void setConfig(KScreen::Config* config) const;
- virtual bool isValid() const;
- virtual KScreen::Edid *edid(int outputId) const;
- virtual void updateConfig(KScreen::Config *config) const;
+public:
+ explicit Fake();
+ virtual ~Fake();
+
+ QString name() const;
+ QString serviceName() const;
+ KScreen::ConfigPtr config() const;
+ void setConfig(const KScreen::ConfigPtr &config);
+ QByteArray edid(int outputId) const;
+ bool isValid() const;
+
+ void setConnected(int outputId, bool connected);
+ void setEnabled(int outputId, bool enabled);
+ void setPrimary(int outputId, bool primary);
+ void setCurrentModeId(int outputId, const QString &modeId);
+ void setRotation(int outputId, int rotation);
+
+private Q_SLOTS:
+ void delayedInit();
+
+
+private:
+ mutable KScreen::ConfigPtr mConfig;
};
Q_DECLARE_LOGGING_CATEGORY(KSCREEN_FAKE)
#endif //FAKE_BACKEND_H
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/backends/fake/parser.cpp
^
|
@@ -19,7 +19,8 @@
#include "parser.h"
#include "fake.h"
-#include <config.h>
+#include "config.h"
+#include "output.h"
#include <QtCore/QFile>
#include <QLoggingCategory>
@@ -29,42 +30,45 @@
using namespace KScreen;
-Config* Parser::fromJson(const QByteArray& data)
+ConfigPtr Parser::fromJson(const QByteArray& data)
{
- Config *config = new Config();
+ ConfigPtr config(new Config);
- QJsonObject json = QJsonDocument::fromJson(data).object();
+ const QJsonObject json = QJsonDocument::fromJson(data).object();
- Screen* screen = Parser::screenFromJson(json["screen"].toObject().toVariantMap());
+ ScreenPtr screen = Parser::screenFromJson(json["screen"].toObject().toVariantMap());
+ config->setScreen(screen);
- QVariantList outputs = json["outputs"].toArray().toVariantList();
+ const QVariantList outputs = json["outputs"].toArray().toVariantList();
if (outputs.isEmpty()) {
return config;
}
- Output *output;
OutputList outputList;
Q_FOREACH(const QVariant &value, outputs) {
- output = Parser::outputFromJson(value.toMap());
+ const OutputPtr output = Parser::outputFromJson(value.toMap());
outputList.insert(output->id(), output);
}
- config->setScreen(screen);
config->setOutputs(outputList);
return config;
}
-Config* Parser::fromJson(const QString& path)
+ConfigPtr Parser::fromJson(const QString& path)
{
QFile file(path);
- file.open(QIODevice::ReadOnly);
+ if (!file.open(QIODevice::ReadOnly)) {
+ qWarning() << file.errorString();
+ qWarning() << "File: " << path;
+ return ConfigPtr();
+ }
return Parser::fromJson(file.readAll());
}
-Screen* Parser::screenFromJson(const QVariantMap &data)
+ScreenPtr Parser::screenFromJson(const QVariantMap &data)
{
- Screen* screen = new Screen;
+ ScreenPtr screen(new Screen);
screen->setId(data["id"].toInt());
screen->setMinSize(Parser::sizeFromJson(data["minSize"].toMap()));
screen->setMaxSize(Parser::sizeFromJson(data["maxSize"].toMap()));
@@ -78,7 +82,7 @@
{
for ( QVariantMap::const_iterator iter = variant.begin(); iter != variant.end(); ++iter )
{
- QVariant property = object->property( iter.key().toLatin1() );
+ const QVariant property = object->property( iter.key().toLatin1() );
Q_ASSERT( property.isValid() );
if ( property.isValid() )
{
@@ -94,24 +98,23 @@
}
}
-Output* Parser::outputFromJson(QMap< QString, QVariant > map)
+OutputPtr Parser::outputFromJson(QMap< QString, QVariant > map)
{
- Output *output = new Output;
+ OutputPtr output(new Output);
output->setId(map["id"].toInt());
QStringList preferredModes;
- QVariantList modes = map["preferredModes"].toList();
- Q_FOREACH(const QVariant &mode, modes) {
+ const QVariantList prefModes = map["preferredModes"].toList();
+ Q_FOREACH(const QVariant &mode, prefModes) {
preferredModes.append(mode.toString());
}
output->setPreferredModes(preferredModes);
map.remove(QLatin1Literal("preferredModes"));
- Mode *mode;
ModeList modelist;
- modes = map["modes"].toList();
+ const QVariantList modes = map["modes"].toList();
Q_FOREACH(const QVariant &modeValue, modes) {
- mode = Parser::modeFromJson(modeValue);
+ const ModePtr mode = Parser::modeFromJson(modeValue);
modelist.insert(mode->id(), mode);
}
output->setModes(modelist);
@@ -127,7 +130,7 @@
map.remove(QLatin1Literal("clones"));
}
- QString type = map["type"].toByteArray().toUpper();
+ const QString type = map["type"].toByteArray().toUpper();
if (type.contains("LVDS") || type.contains("EDP") || type.contains("IDP")) {
output->setType(Output::Panel);
} else if (type.contains("VGA")) {
@@ -173,15 +176,15 @@
//Remove some extra properties that we do not want or need special treatment
map.remove(QLatin1Literal("edid"));
- Parser::qvariant2qobject(map, output);
+ Parser::qvariant2qobject(map, output.data());
return output;
}
-Mode* Parser::modeFromJson(const QVariant& data)
+ModePtr Parser::modeFromJson(const QVariant& data)
{
- QVariantMap map = data.toMap();
- Mode *mode = new Mode;
- Parser::qvariant2qobject(map, mode);
+ const QVariantMap map = data.toMap();
+ ModePtr mode(new Mode);
+ Parser::qvariant2qobject(map, mode.data());
mode->setSize(Parser::sizeFromJson(map["size"].toMap()));
@@ -190,7 +193,7 @@
QSize Parser::sizeFromJson(const QVariant& data)
{
- QVariantMap map = data.toMap();
+ const QVariantMap map = data.toMap();
QSize size;
size.setWidth(map["width"].toInt());
@@ -201,7 +204,7 @@
QPoint Parser::pointFromJson(const QVariant& data)
{
- QVariantMap map = data.toMap();
+ const QVariantMap map = data.toMap();
QPoint point;
point.setX(map["x"].toInt());
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/backends/fake/parser.h
^
|
@@ -19,32 +19,28 @@
#ifndef PARSER_H
#define PARSER_H
-#include <QtCore/QByteArray>
-#include <QtCore/QString>
-#include <QtCore/QVariant>
-#include <QtCore/QSize>
-#include <QtCore/QRect>
-#include <QtCore/QPoint>
+#include <QByteArray>
+#include <QString>
+#include <QVariant>
+#include <QSize>
+#include <QRect>
+#include <QPoint>
+
+#include "types.h"
-namespace KScreen {
- class Config;
- class Screen;
- class Output;
- class Mode;
-}
class Parser
{
public:
- static KScreen::Config* fromJson(const QByteArray &data);
- static KScreen::Config* fromJson(const QString &path);
+ static KScreen::ConfigPtr fromJson(const QByteArray &data);
+ static KScreen::ConfigPtr fromJson(const QString &path);
static bool validate(const QByteArray &data);
static bool validate(const QString &data);
private:
static void qvariant2qobject(const QVariantMap& variant, QObject* object);
- static KScreen::Screen* screenFromJson(const QMap<QString, QVariant>& data);
- static KScreen::Output* outputFromJson(QMap<QString, QVariant> data);
- static KScreen::Mode* modeFromJson(const QVariant& data);
+ static KScreen::ScreenPtr screenFromJson(const QMap<QString, QVariant>& data);
+ static KScreen::OutputPtr outputFromJson(QMap<QString, QVariant> data /* sic */);
+ static KScreen::ModePtr modeFromJson(const QVariant& data);
static QSize sizeFromJson(const QVariant& data);
static QRect rectFromJson(const QVariant& data);
static QPoint pointFromJson(const QVariant& data);
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/backends/qscreen/qscreenbackend.cpp
^
|
@@ -22,22 +22,22 @@
#include "qscreenconfig.h"
#include "qscreenoutput.h"
-#include <configmonitor.h>
-
using namespace KScreen;
Q_LOGGING_CATEGORY(KSCREEN_QSCREEN, "kscreen.qscreen");
QScreenConfig *QScreenBackend::s_internalConfig = 0;
-QScreenBackend::QScreenBackend(QObject *parent)
- : QObject(parent)
+QScreenBackend::QScreenBackend()
+ : KScreen::AbstractBackend()
, m_isValid(true)
{
QLoggingCategory::setFilterRules(QLatin1Literal("kscreen.qscreen.debug = true"));
if (s_internalConfig == 0) {
s_internalConfig = new QScreenConfig();
+ connect(s_internalConfig, &QScreenConfig::configChanged,
+ this, &QScreenBackend::configChanged);
}
}
@@ -50,12 +50,18 @@
return QString("QScreen");
}
-Config *QScreenBackend::config() const
+QString QScreenBackend::serviceName() const
+{
+ return QLatin1Literal("org.kde.KScreen.Backend.QScreen");
+}
+
+
+ConfigPtr QScreenBackend::config() const
{
return s_internalConfig->toKScreenConfig();
}
-void QScreenBackend::setConfig(Config *config) const
+void QScreenBackend::setConfig(const ConfigPtr &config)
{
if (!config) {
return;
@@ -66,25 +72,7 @@
qWarning() << "You can force another backend using the KSCREEN_BACKEND env var.";
}
-Edid *QScreenBackend::edid(int outputId) const
-{
- QScreenOutput *output = s_internalConfig->outputMap().value(outputId);
- if (!output) {
- return 0;
- }
- return output->edid();
-}
-
bool QScreenBackend::isValid() const
{
return m_isValid;
}
-
-void QScreenBackend::updateConfig(Config *config) const
-{
- Q_ASSERT(config != 0);
- s_internalConfig->updateKScreenConfig(config);
-}
-
-#include "qscreenbackend.moc"
-
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/backends/qscreen/qscreenbackend.h
^
|
@@ -21,7 +21,7 @@
#ifndef QSCREEN_BACKEND_H
#define QSCREEN_BACKEND_H
-#include "../abstractbackend.h"
+#include "abstractbackend.h"
#include <QLoggingCategory>
@@ -30,22 +30,20 @@
class Output;
class QScreenConfig;
-class QScreenBackend : public QObject, public AbstractBackend
+class QScreenBackend : public KScreen::AbstractBackend
{
Q_OBJECT
- Q_INTERFACES(AbstractBackend)
Q_PLUGIN_METADATA(IID "org.kf5.kscreen.backends.qscreen")
public:
- explicit QScreenBackend(QObject *parent = 0);
+ explicit QScreenBackend();
virtual ~QScreenBackend();
virtual QString name() const;
- virtual KScreen::Config *config() const;
- virtual void setConfig(KScreen::Config *config) const;
+ virtual QString serviceName() const;
+ virtual KScreen::ConfigPtr config() const;
+ virtual void setConfig(const KScreen::ConfigPtr &config);
virtual bool isValid() const;
- virtual KScreen::Edid *edid(int outputId) const;
- virtual void updateConfig(KScreen::Config *config) const;
private:
bool m_isValid;
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/backends/qscreen/qscreenconfig.cpp
^
|
@@ -21,7 +21,6 @@
#include "qscreenscreen.h"
#include "qscreenbackend.h"
-#include <configmonitor.h>
#include <mode.h>
#include <QtCore/QRect>
@@ -49,10 +48,10 @@
}
}
-Config *QScreenConfig::toKScreenConfig() const
+ConfigPtr QScreenConfig::toKScreenConfig() const
{
- Config *config = new Config();
- config->setScreen(m_screen->toKScreenScreen(config));
+ ConfigPtr config(new Config);
+ config->setScreen(m_screen->toKScreenScreen());
updateKScreenConfig(config);
return config;
}
@@ -79,7 +78,7 @@
connect(qscreen, &QObject::destroyed, this, &QScreenConfig::screenDestroyed);
if (!m_blockSignals) {
- KScreen::ConfigMonitor::instance()->notifyUpdate();
+ Q_EMIT configChanged(toKScreenConfig());
}
}
@@ -95,40 +94,41 @@
delete output;
}
}
- KScreen::ConfigMonitor::instance()->notifyUpdate();
+ Q_EMIT configChanged(toKScreenConfig());
}
-void QScreenConfig::updateKScreenConfig(Config *config) const
+void QScreenConfig::updateKScreenConfig(ConfigPtr &config) const
{
- m_screen->updateKScreenScreen(config->screen());
+ KScreen::ScreenPtr screen = config->screen();
+ m_screen->updateKScreenScreen(screen);
+ config->setScreen(screen);
//Removing removed outputs
KScreen::OutputList outputs = config->outputs();
- Q_FOREACH(KScreen::Output * output, outputs) {
+ Q_FOREACH(const KScreen::OutputPtr &output, outputs) {
if (!m_outputMap.keys().contains(output->id())) {
config->removeOutput(output->id());
}
}
// Add KScreen::Outputs that aren't in the list yet, handle primaryOutput
- foreach(auto output, m_outputMap.values()) {
-
- KScreen::Output *kscreenOutput = config->output(output->id());
+ KScreen::OutputList kscreenOutputs = config->outputs();
+ foreach(QScreenOutput *output, m_outputMap.values()) {
+ KScreen::OutputPtr kscreenOutput = kscreenOutputs[output->id()];
if (!kscreenOutput) {
- kscreenOutput = output->toKScreenOutput(config);
- config->addOutput(kscreenOutput);
+ kscreenOutput = output->toKScreenOutput();
+ kscreenOutputs.insert(kscreenOutput->id(), kscreenOutput);
}
output->updateKScreenOutput(kscreenOutput);
if (QGuiApplication::primaryScreen() == output->qscreen()) {
config->setPrimaryOutput(kscreenOutput);
}
}
+ config->setOutputs(kscreenOutputs);
}
QMap< int, QScreenOutput * > QScreenConfig::outputMap() const
{
return m_outputMap;
}
-
-#include "qscreenconfig.moc"
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/backends/qscreen/qscreenconfig.h
^
|
@@ -19,7 +19,6 @@
#ifndef QSCREEN_CONFIG_H
#define QSCREEN_CONFIG_H
-#include "../abstractbackend.h"
#include "config.h"
#include <QScreen>
@@ -38,8 +37,8 @@
explicit QScreenConfig(QObject *parent = 0);
virtual ~QScreenConfig();
- KScreen::Config *toKScreenConfig() const;
- void updateKScreenConfig(KScreen::Config *config) const;
+ KScreen::ConfigPtr toKScreenConfig() const;
+ void updateKScreenConfig(KScreen::ConfigPtr &config) const;
QMap<int, QScreenOutput *> outputMap() const;
int outputId(const QScreen *qscreen);
@@ -48,6 +47,9 @@
void screenAdded(const QScreen *qscreen);
void screenDestroyed(QObject *qscreen = 0);
+Q_SIGNALS:
+ void configChanged(const KScreen::ConfigPtr &config);
+
private:
QMap<int, QScreenOutput *> m_outputMap;
QScreenScreen *m_screen;
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/backends/qscreen/qscreenoutput.cpp
^
|
@@ -49,29 +49,21 @@
m_id = newId;
}
-KScreen::Edid *QScreenOutput::edid()
-{
- if (!m_edid) {
- m_edid = new KScreen::Edid(0, 0, this);
- }
- return m_edid;
-}
-
const QScreen *QScreenOutput::qscreen() const
{
return m_qscreen;
}
-Output *QScreenOutput::toKScreenOutput(Config *parent) const
+OutputPtr QScreenOutput::toKScreenOutput() const
{
- Output *output = new Output(parent);
+ OutputPtr output(new Output);
output->setId(m_id);
output->setName(m_qscreen->name());
updateKScreenOutput(output);
return output;
}
-void QScreenOutput::updateKScreenOutput(Output *output) const
+void QScreenOutput::updateKScreenOutput(OutputPtr &output) const
{
// Initialize primary output
output->setEnabled(true);
@@ -102,7 +94,7 @@
output->setPos(m_qscreen->availableGeometry().topLeft());
// Modes: we create a single default mode and go with that
- Mode *mode = new Mode(output);
+ ModePtr mode(new Mode);
const QString modeid = QStringLiteral("defaultmode");
mode->setId(modeid);
mode->setRefreshRate(m_qscreen->refreshRate());
@@ -117,5 +109,3 @@
output->setModes(modes);
output->setCurrentModeId(modeid);
}
-
-#include "qscreenoutput.moc"
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/backends/qscreen/qscreenoutput.h
^
|
@@ -19,13 +19,14 @@
#ifndef QSCREEN_OUTPUT_H
#define QSCREEN_OUTPUT_H
-#include "../abstractbackend.h"
#include "qscreenconfig.h"
#include "config.h"
#include "output.h"
+#include "edid.h"
#include <QScreen>
+#include <QPointer>
namespace KScreen
{
@@ -38,15 +39,8 @@
explicit QScreenOutput(const QScreen *qscreen, QObject *parent = 0);
virtual ~QScreenOutput();
- KScreen::Output *toKScreenOutput(KScreen::Config *parent) const;
- void updateKScreenOutput(KScreen::Output *output) const;
-
- /** QScreen doesn't support querying for the EDID, this function centralizes
- * creating the EDID per output, anyway, so a drop-in solution will "just work".
- *
- * This function returns 0.
- */
- KScreen::Edid *edid();
+ KScreen::OutputPtr toKScreenOutput() const;
+ void updateKScreenOutput(KScreen::OutputPtr &output) const;
int id() const;
void setId(const int newId);
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/backends/qscreen/qscreenscreen.cpp
^
|
@@ -37,14 +37,14 @@
{
}
-Screen *QScreenScreen::toKScreenScreen(Config *parent) const
+ScreenPtr QScreenScreen::toKScreenScreen() const
{
- KScreen::Screen *kscreenScreen = new KScreen::Screen(parent);
+ KScreen::ScreenPtr kscreenScreen(new KScreen::Screen);
updateKScreenScreen(kscreenScreen);
return kscreenScreen;
}
-void QScreenScreen::updateKScreenScreen(Screen *screen) const
+void QScreenScreen::updateKScreenScreen(ScreenPtr &screen) const
{
auto primary = QGuiApplication::primaryScreen();
QSize _s = primary->availableVirtualGeometry().size();
@@ -56,6 +56,3 @@
screen->setCurrentSize(_s);
screen->setMaxActiveOutputsCount(QGuiApplication::screens().count());
}
-
-#include "qscreenscreen.moc"
-
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/backends/qscreen/qscreenscreen.h
^
|
@@ -19,7 +19,6 @@
#ifndef QSCREEN_SCREEN_H
#define QSCREEN_SCREEN_H
-#include "../abstractbackend.h"
#include "config.h"
#include "screen.h"
@@ -40,8 +39,8 @@
explicit QScreenScreen(QScreenConfig *config);
virtual ~QScreenScreen();
- KScreen::Screen *toKScreenScreen(KScreen::Config *parent) const;
- void updateKScreenScreen(KScreen::Screen *screen) const;
+ KScreen::ScreenPtr toKScreenScreen() const;
+ void updateKScreenScreen(KScreen::ScreenPtr &screen) const;
};
} // namespace
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/backends/xrandr/xrandr.cpp
^
|
@@ -24,7 +24,6 @@
#include "config.h"
#include "output.h"
#include "edid.h"
-#include "configmonitor.h"
#include <QtCore/QFile>
#include <QtCore/qplugin.h>
@@ -50,8 +49,8 @@
Q_LOGGING_CATEGORY(KSCREEN_XRANDR, "kscreen.xrandr");
-XRandR::XRandR(QObject* parent)
- : QObject(parent)
+XRandR::XRandR()
+ : KScreen::AbstractBackend()
, m_x11Helper(0)
, m_isValid(false)
{
@@ -115,15 +114,21 @@
return QString("XRandR");
}
+QString XRandR::serviceName() const
+{
+ return QLatin1Literal("org.kde.KScreen.Backend.XRandR");
+}
+
+
void XRandR::updateConfig()
{
s_internalConfig->update();
- KScreen::ConfigMonitor::instance()->notifyUpdate();
+ Q_EMIT configChanged(config());
}
void XRandR::outputRemovedSlot()
{
- KScreen::ConfigMonitor::instance()->notifyUpdate();
+ Q_EMIT configChanged(config());
}
void XRandR::updateOutput(RROutput output)
@@ -139,7 +144,7 @@
}
}
- KScreen::ConfigMonitor::instance()->notifyUpdate();
+ Q_EMIT configChanged(config());
}
void XRandR::updateCrtc(RRCrtc crtc)
@@ -151,32 +156,35 @@
}
XRRFreeCrtcInfo(crtcInfo);
- KScreen::ConfigMonitor::instance()->notifyUpdate();
+ Q_EMIT configChanged(config());
}
-Config* XRandR::config() const
+ConfigPtr XRandR::config() const
{
return s_internalConfig->toKScreenConfig();
}
-void XRandR::setConfig(Config* config) const
+void XRandR::setConfig(const ConfigPtr &config)
{
if (!config) {
return;
}
+ qCDebug(KSCREEN_XRANDR) << "XRandR::setConfig";
s_internalConfig->applyKScreenConfig(config);
+ qCDebug(KSCREEN_XRANDR) << "XRandR::setConfig done!";
}
-Edid *XRandR::edid(int outputId) const
+QByteArray XRandR::edid(int outputId) const
{
- XRandROutput::Map outputs = s_internalConfig->outputs();
- XRandROutput *output = outputs.value(outputId);
+ const XRandROutput::Map outputs = s_internalConfig->outputs();
+ const XRandROutput *output = outputs.value(outputId);
if (!output) {
return 0;
}
- return output->edid();
+ const QByteArray rawEdid = output->edid();
+ return rawEdid;
}
bool XRandR::isValid() const
@@ -184,13 +192,6 @@
return m_isValid;
}
-void XRandR::updateConfig(Config *config) const
-{
- Q_ASSERT(config != 0);
-
- s_internalConfig->updateKScreenConfig(config);
-}
-
quint8* XRandR::getXProperty(Display *dpy, RROutput output, Atom atom, size_t &len)
{
unsigned char *prop = 0;
@@ -219,7 +220,7 @@
quint8 *XRandR::outputEdid(int outputId, size_t &len)
{
- Atom edid_atom;
+ Atom edid_atom;
quint8 *result;
edid_atom = XInternAtom(QX11Info::display(), RR_PROPERTY_RANDR_EDID, false);
@@ -265,7 +266,7 @@
XRRCrtcInfo *crtc;
for (int i = 0; i < outputInfo->ncrtc; ++i)
{
- RRCrtc crtcId = outputInfo->crtcs[i];
+ const RRCrtc crtcId = outputInfo->crtcs[i];
crtc = XRRCrtc(crtcId);
if (!crtc->noutput) {
qCDebug(KSCREEN_XRANDR) << "Found free CRTC" << crtcId;
@@ -334,5 +335,3 @@
{
return s_screen;
}
-
-#include "xrandr.moc"
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/backends/xrandr/xrandr.h
^
|
@@ -21,7 +21,7 @@
#define XRANDR_BACKEND_H
#include "xlibandxrandr.h"
-#include "../abstractbackend.h"
+#include "abstractbackend.h"
#include <QtCore/QSize>
#include <QLoggingCategory>
@@ -32,22 +32,21 @@
class Output;
}
-class XRandR : public QObject, public AbstractBackend
+class XRandR : public KScreen::AbstractBackend
{
Q_OBJECT
- Q_INTERFACES(AbstractBackend)
Q_PLUGIN_METADATA(IID "org.kf5.kscreen.backends.xrandr")
public:
- explicit XRandR(QObject* parent = 0);
+ explicit XRandR();
virtual ~XRandR();
virtual QString name() const;
- virtual KScreen::Config* config() const;
- virtual void setConfig(KScreen::Config* config) const;
+ virtual QString serviceName() const;
+ virtual KScreen::ConfigPtr config() const;
+ virtual void setConfig(const KScreen::ConfigPtr &config);
virtual bool isValid() const;
- virtual KScreen::Edid *edid(int outputId) const;
- virtual void updateConfig(KScreen::Config *config) const;
+ virtual QByteArray edid(int outputId) const;
static RRCrtc outputCrtc(int outputId);
static quint8 *outputEdid(int outputId, size_t &len);
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/backends/xrandr/xrandrconfig.cpp
^
|
@@ -38,10 +38,9 @@
{
XRRScreenResources* resources = XRandR::screenResources();
- RROutput id, primary;
- primary = XRRGetOutputPrimary(XRandR::display(), XRandR::rootWindow());
+ const RROutput primary = XRRGetOutputPrimary(XRandR::display(), XRandR::rootWindow());
- XRandROutput::Map outputs;
+ RROutput id;
for (int i = 0; i < resources->noutput; ++i)
{
id = resources->outputs[i];
@@ -64,11 +63,10 @@
{
m_screen->update();
- RROutput primary = XRRGetOutputPrimary(XRandR::display(), XRandR::rootWindow());
+ const RROutput primary = XRRGetOutputPrimary(XRandR::display(), XRandR::rootWindow());
m_primaryOutput = -1;
- XRandROutput::Map::Iterator iter;
- for (iter = m_outputs.begin(); iter != m_outputs.end(); ++iter) {
+ for (auto iter = m_outputs.begin(); iter != m_outputs.end(); ++iter) {
XRandROutput *output = iter.value();
output->update((iter.key() == (int) primary) ? XRandROutput::SetPrimary : XRandROutput::UnsetPrimary);
if (iter.key() == (int) primary) {
@@ -84,8 +82,7 @@
void XRandRConfig::addNewOutput(const RROutput id)
{
- RROutput primary;
- primary = XRRGetOutputPrimary(XRandR::display(), XRandR::rootWindow());
+ const RROutput primary = XRRGetOutputPrimary(XRandR::display(), XRandR::rootWindow());
XRandROutput *output = createNewOutput(id, (id == primary));
m_outputs.insert(id, output);
if (id == primary) {
@@ -107,22 +104,21 @@
Q_EMIT outputRemoved(id);
}
-KScreen::Config *XRandRConfig::toKScreenConfig() const
+KScreen::ConfigPtr XRandRConfig::toKScreenConfig() const
{
- KScreen::Config *config = new KScreen::Config();
+ KScreen::ConfigPtr config(new KScreen::Config);
KScreen::OutputList kscreenOutputs;
- XRandROutput::Map::ConstIterator iter;
- for (iter = m_outputs.constBegin(); iter != m_outputs.constEnd(); ++iter) {
+ for (auto iter = m_outputs.constBegin(); iter != m_outputs.constEnd(); ++iter) {
XRandROutput *output = iter.value();
//FIXME XRandR backend should keep updated itself
output->update(XRandROutput::NoChange);
- KScreen::Output *kscreenOutput = output->toKScreenOutput(config);
+ KScreen::OutputPtr kscreenOutput = output->toKScreenOutput();
kscreenOutputs.insert(kscreenOutput->id(), kscreenOutput);
}
config->setOutputs(kscreenOutputs);
- config->setScreen(m_screen->toKScreenScreen(config));
+ config->setScreen(m_screen->toKScreenScreen());
if (m_primaryOutput != -1 && (!config->primaryOutput() || config->primaryOutput()->id() != m_primaryOutput)) {
config->setPrimaryOutput(kscreenOutputs.value(m_primaryOutput));
}
@@ -130,46 +126,60 @@
return config;
}
-void XRandRConfig::updateKScreenConfig(Config *config) const
+void XRandRConfig::updateKScreenConfig(ConfigPtr &config) const
{
- KScreen::Screen *kscreenScreen = config->screen();
+ KScreen::ScreenPtr kscreenScreen = config->screen();
m_screen->updateKScreenScreen(kscreenScreen);
+ config->setScreen(kscreenScreen);
//Removing removed outputs
KScreen::OutputList outputs = config->outputs();
- Q_FOREACH(KScreen::Output *output, outputs) {
+ Q_FOREACH(const KScreen::OutputPtr &output, outputs) {
if (!m_outputs.contains(output->id())) {
config->removeOutput(output->id());
}
}
XRandROutput::Map::ConstIterator iter;
+ KScreen::OutputList kscreenOutputs = config->outputs();
for (iter = m_outputs.constBegin(); iter != m_outputs.constEnd(); ++iter) {
XRandROutput *output = iter.value();
- KScreen::Output *kscreenOutput = config->output(output->id());
+ KScreen::OutputPtr kscreenOutput = kscreenOutputs[output->id()];
if (!kscreenOutput) {
- config->addOutput(output->toKScreenOutput(config));
+ kscreenOutput = output->toKScreenOutput();
+ kscreenOutputs.insert(kscreenOutput->id(), kscreenOutput);
continue;
}
output->updateKScreenOutput(kscreenOutput);
}
+ config->setOutputs(kscreenOutputs);
if (!config->primaryOutput() || config->primaryOutput()->id() != m_primaryOutput) {
config->setPrimaryOutput(config->output(m_primaryOutput));
}
}
-void XRandRConfig::applyKScreenConfig(KScreen::Config *config)
+void XRandRConfig::applyKScreenConfig(const KScreen::ConfigPtr &config)
{
KScreen::OutputList outputs = config->outputs();
QSize newSize = screenSize(config);
+ const QSize currentScreenSize = m_screen->currentSize();
int neededCrtc = 0;
int primaryOutput = 0;
+ int oldPrimary = 0;
+
+ Q_FOREACH (const XRandROutput *xrandrOutput, m_outputs) {
+ if (xrandrOutput->isPrimary()) {
+ oldPrimary = xrandrOutput->id();
+ break;
+ }
+ }
+
KScreen::OutputList toDisable, toEnable, toChange;
QHash<int, int> currentCrtc;
- Q_FOREACH(KScreen::Output *output, outputs) {
+ Q_FOREACH(const KScreen::OutputPtr &output, outputs) {
XRandROutput *currentOutput = m_outputs.value(output->id());
currentOutput->update(currentOutput->isPrimary() ? XRandROutput::SetPrimary : XRandROutput::UnsetPrimary);
@@ -257,7 +267,7 @@
}
}//Q_FOREACH(KScreen::Output *output, outputs)
- KScreen::Screen* screen = config->screen();
+ const KScreen::ScreenPtr screen = config->screen();
if (newSize.width() > screen->maxSize().width() ||
newSize.height() > screen->maxSize().height()) {
qCDebug(KSCREEN_XRANDR) << "The new size is too big: " << newSize << " - " << screen->maxSize();
@@ -275,9 +285,9 @@
qCDebug(KSCREEN_XRANDR) << "Actions to perform: ";
qCDebug(KSCREEN_XRANDR) << "\t Primary Output: " << primaryOutput;
- qCDebug(KSCREEN_XRANDR) << "\t Screen Size: " << (newSize != m_screen->currentSize());
- if (newSize != m_screen->currentSize()) {
- qCDebug(KSCREEN_XRANDR) << "\t Old: " << m_screen->currentSize();
+ qCDebug(KSCREEN_XRANDR) << "\t Change Screen Size: " << (newSize != currentScreenSize);
+ if (newSize != currentScreenSize) {
+ qCDebug(KSCREEN_XRANDR) << "\t Old: " << currentScreenSize;
qCDebug(KSCREEN_XRANDR) << "\t New: " << newSize;
}
qCDebug(KSCREEN_XRANDR) << "\t Disable outputs: " << !toDisable.isEmpty();
@@ -293,55 +303,62 @@
qCDebug(KSCREEN_XRANDR) << "\t\t" << toEnable.keys();
}
- setPrimaryOutput(primaryOutput);
+ XGrabServer(XRandR::display());
//If there is nothing to do, not even bother
- if (toDisable.isEmpty() && toEnable.isEmpty() && toChange.isEmpty()) {
- if (newSize != m_screen->currentSize()) {
+ if (oldPrimary == primaryOutput && toDisable.isEmpty() && toEnable.isEmpty() && toChange.isEmpty()) {
+ if (newSize != currentScreenSize) {
setScreenSize(newSize);
}
+ XUngrabServer(XRandR::display());
return;
}
- Q_FOREACH(KScreen::Output* output, toDisable) {
+ Q_FOREACH(const KScreen::OutputPtr &output, toDisable) {
disableOutput(output);
}
- if (newSize != m_screen->currentSize()) {
+ if (newSize != currentScreenSize) {
setScreenSize(newSize);
}
bool forceScreenSizeUpdate = false;
- Q_FOREACH(KScreen::Output* output, toChange) {
+ Q_FOREACH(const KScreen::OutputPtr &output, toChange) {
if (!changeOutput(output, currentCrtc[output->id()])) {
/* If we disabled the output before changing it and XRandR failed
* to re-enable it, then update screen size too */
if (toDisable.contains(output->id())) {
- output->setEnabled(false);
+ //output->setEnabled(false);
qCDebug(KSCREEN_XRANDR) << "Output failed to change: " << output->name();
forceScreenSizeUpdate = true;
}
}
}
- Q_FOREACH(KScreen::Output* output, toEnable) {
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/backends/xrandr/xrandrconfig.h
^
|
@@ -42,9 +42,9 @@
XRandROutput::Map outputs() const;
void addNewOutput(const RROutput id);
- KScreen::Config *toKScreenConfig() const;
- void updateKScreenConfig(KScreen::Config *config) const;
- void applyKScreenConfig(KScreen::Config *config);
+ KScreen::ConfigPtr toKScreenConfig() const;
+ void updateKScreenConfig(KScreen::ConfigPtr &config) const;
+ void applyKScreenConfig(const KScreen::ConfigPtr &config);
int m_primaryOutput;
private:
@@ -52,14 +52,14 @@
* We need to print stuff to discover the damn bug
* where currentMode is null
*/
- void printConfig(KScreen::Config* config) const;
+ void printConfig(const KScreen::ConfigPtr &config) const;
void printInternalCond() const;
- QSize screenSize(KScreen::Config* config) const;
+ QSize screenSize(const KScreen::ConfigPtr &config) const;
bool setScreenSize(const QSize& size) const;
void setPrimaryOutput(int outputId) const;
- bool disableOutput(KScreen::Output* output) const;
- bool enableOutput(KScreen::Output* output) const;
- bool changeOutput(KScreen::Output* output, int crtcId) const;
+ bool disableOutput(const KScreen::OutputPtr &output) const;
+ bool enableOutput(const KScreen::OutputPtr &output) const;
+ bool changeOutput(const KScreen::OutputPtr &output, int crtcId) const;
XRandROutput* createNewOutput(RROutput id, bool primary);
XRandROutput::Map m_outputs;
XRandRScreen *m_screen;
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/backends/xrandr/xrandrmode.cpp
^
|
@@ -35,9 +35,9 @@
{
}
-KScreen::Mode *XRandRMode::toKScreenMode(KScreen::Output *parent)
+KScreen::ModePtr XRandRMode::toKScreenMode()
{
- KScreen::Mode *kscreenMode = new KScreen::Mode(parent);
+ KScreen::ModePtr kscreenMode(new KScreen::Mode);
kscreenMode->setId(QString::number(m_id));
kscreenMode->setName(m_name);
@@ -66,5 +66,3 @@
{
return m_name;
}
-
-#include "xrandrmode.moc"
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/backends/xrandr/xrandrmode.h
^
|
@@ -24,6 +24,7 @@
#include <QVariant>
#include <QSize>
+#include "types.h"
#include "xlibandxrandr.h"
class XRandROutput;
@@ -43,7 +44,7 @@
explicit XRandRMode(XRRModeInfo* modeInfo, XRandROutput *output);
virtual ~XRandRMode();
- KScreen::Mode* toKScreenMode(KScreen::Output *parent);
+ KScreen::ModePtr toKScreenMode();
int id() const;
QSize size() const;
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/backends/xrandr/xrandroutput.cpp
^
|
@@ -23,7 +23,6 @@
#include "xrandr.h"
#include "output.h"
#include "config.h"
-#include "edid.h"
#include <QRect>
@@ -37,7 +36,6 @@
, m_connected(0)
, m_enabled(0)
, m_primary(0)
- , m_edid(0)
, m_changedProperties(0)
{
XRROutputInfo *outputInfo = XRandR::XRROutput(m_id);
@@ -54,7 +52,6 @@
XRandROutput::~XRandROutput()
{
- delete m_edid;
}
int XRandROutput::id() const
@@ -107,16 +104,16 @@
return m_rotation;
}
-KScreen::Edid *XRandROutput::edid() const
+QByteArray XRandROutput::edid() const
{
- if (!m_edid) {
+ if (m_edid.isNull()) {
size_t len;
quint8 *data = XRandR::outputEdid(m_id, len);
if (data) {
- m_edid = new KScreen::Edid(data, len, 0);
+ m_edid = QByteArray((char *) data, len);
delete[] data;
} else {
- m_edid = new KScreen::Edid(0, 0, 0);
+ m_edid = QByteArray();
}
}
@@ -136,7 +133,7 @@
updateOutput(outputInfo);
if (primary != NoChange) {
- bool setPrimary = (primary == SetPrimary);
+ const bool setPrimary = (primary == SetPrimary);
if (m_primary != setPrimary) {
m_primary = setPrimary;
m_changedProperties |= PropertyPrimary;
@@ -152,7 +149,7 @@
void XRandROutput::updateOutput(const XRROutputInfo *outputInfo)
{
- bool isConnected = (outputInfo->connection == RR_Connected);
+ const bool isConnected = (outputInfo->connection == RR_Connected);
if (m_name != outputInfo->name) {
m_name = outputInfo->name;
@@ -202,10 +199,11 @@
m_connected = isConnected;
if (!m_connected) {
m_preferredModes.clear();
+ m_enabled = false;
qDeleteAll(m_modes);
m_modes.clear();
- delete m_edid;
- m_changedProperties |= PropertyConnected | PropertyModes | PropertyEdid | PropertyPreferredMode;
+ m_edid.clear();
+ m_changedProperties |= PropertyConnected | PropertyEnabled | PropertyModes | PropertyEdid | PropertyPreferredMode;
} else {
updateModes(outputInfo);
m_changedProperties |= PropertyConnected | PropertyModes | PropertyPreferredMode;
@@ -245,7 +243,7 @@
void XRandROutput::fetchType()
{
- QByteArray type = typeFromProperty();
+ const QByteArray type = typeFromProperty();
if (type.isEmpty()) {
m_type = typeFromName();
return;
@@ -308,7 +306,7 @@
{
QByteArray type;
- Atom atomType = XInternAtom (XRandR::display(), RR_PROPERTY_CONNECTOR_TYPE, True);
+ const Atom atomType = XInternAtom (XRandR::display(), RR_PROPERTY_CONNECTOR_TYPE, True);
if (atomType == None) {
return type;
}
@@ -319,7 +317,7 @@
Atom actualType;
char *connectorType;
- if (XRRGetOutputProperty (XRandR::display(), m_id, atomType, 0, 100, False,
+ if (XRRGetOutputProperty(XRandR::display(), m_id, atomType, 0, 100, False,
False, AnyPropertyType, &actualType, &actualFormat, &nitems,
&bytes_after, &prop) != Success) {
@@ -342,9 +340,9 @@
return type;
}
-KScreen::Output *XRandROutput::toKScreenOutput(KScreen::Config *parent) const
+KScreen::OutputPtr XRandROutput::toKScreenOutput() const
{
- KScreen::Output *kscreenOutput = new KScreen::Output(parent);
+ KScreen::OutputPtr kscreenOutput(new KScreen::Output);
m_changedProperties = 0;
kscreenOutput->setId(m_id);
@@ -355,7 +353,7 @@
return kscreenOutput;
}
-void XRandROutput::updateKScreenOutput(KScreen::Output *output) const
+void XRandROutput::updateKScreenOutput(KScreen::OutputPtr &output) const
{
if (!m_changedProperties || (m_changedProperties & PropertyName)) {
output->setName(m_name);
@@ -402,15 +400,11 @@
}
if (!m_changedProperties || (m_changedProperties & PropertyModes)) {
- XRandRMode::Map::ConstIterator iter;
KScreen::ModeList kscreenModes;
- for (iter = m_modes.constBegin(); iter != m_modes.constEnd(); ++iter) {
+ for (auto iter = m_modes.constBegin(); iter != m_modes.constEnd(); ++iter) {
XRandRMode *mode = iter.value();
- KScreen::Mode *kscreenMode = mode->toKScreenMode(output);
- kscreenModes.insert(QString::number(iter.key()), kscreenMode);
+ kscreenModes.insert(QString::number(iter.key()), mode->toKScreenMode());
}
output->setModes(kscreenModes);
}
}
-
-#include "xrandroutput.moc"
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/backends/xrandr/xrandroutput.h
^
|
@@ -33,7 +33,6 @@
{
class Config;
class Output;
-class Edid;
}
class XRandROutput : public QObject
@@ -84,10 +83,10 @@
XRandRMode* currentMode() const;
KScreen::Output::Rotation rotation() const;
inline bool isHorizontal() const { return ((m_rotation == KScreen::Output::None) || (m_rotation == KScreen::Output::Inverted)); }
- KScreen::Edid* edid() const;
+ QByteArray edid() const;
- KScreen::Output* toKScreenOutput(KScreen::Config *parent) const;
- void updateKScreenOutput(KScreen::Output *output) const;
+ KScreen::OutputPtr toKScreenOutput() const;
+ void updateKScreenOutput(KScreen::OutputPtr &output) const;
void updateModes(const XRROutputInfo *outputInfo);
void addNewOutput(const RROutput output);
@@ -114,7 +113,7 @@
bool m_enabled;
bool m_primary;
QList<int> m_clones;
- mutable QPointer<KScreen::Edid> m_edid;
+ mutable QByteArray m_edid;
unsigned int m_widthMm;
unsigned int m_heightMm;
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/backends/xrandr/xrandrscreen.cpp
^
|
@@ -38,8 +38,8 @@
void XRandRScreen::update()
{
Display *display = QX11Info::display();
- int screen = DefaultScreen(display);
- Window rootWindow = XRootWindow(display, screen);
+ const int screen = DefaultScreen(display);
+ const Window rootWindow = XRootWindow(display, screen);
XRRGetScreenSizeRange (display, rootWindow,
&m_minSize.rwidth(), &m_minSize.rheight(),
@@ -53,9 +53,9 @@
return m_currentSize;
}
-KScreen::Screen *XRandRScreen::toKScreenScreen(KScreen::Config *parent) const
+KScreen::ScreenPtr XRandRScreen::toKScreenScreen() const
{
- KScreen::Screen *kscreenScreen = new KScreen::Screen(parent);
+ KScreen::ScreenPtr kscreenScreen(new KScreen::Screen);
kscreenScreen->setId(m_id);
kscreenScreen->setMaxSize(m_maxSize);
kscreenScreen->setMinSize(m_minSize);
@@ -65,10 +65,7 @@
return kscreenScreen;
}
-void XRandRScreen::updateKScreenScreen(KScreen::Screen *screen) const
+void XRandRScreen::updateKScreenScreen(KScreen::ScreenPtr &screen) const
{
screen->setCurrentSize(m_currentSize);
}
-
-
-#include "xrandrscreen.moc"
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/backends/xrandr/xrandrscreen.h
^
|
@@ -22,6 +22,8 @@
#include <QObject>
#include <QSize>
+#include "types.h"
+
class XRandRConfig;
namespace KScreen
{
@@ -37,8 +39,8 @@
explicit XRandRScreen(XRandRConfig *config = 0);
virtual ~XRandRScreen();
- KScreen::Screen *toKScreenScreen(KScreen::Config *parent) const;
- void updateKScreenScreen(KScreen::Screen *screen) const;
+ KScreen::ScreenPtr toKScreenScreen() const;
+ void updateKScreenScreen(KScreen::ScreenPtr &screen) const;
void update();
QSize currentSize();
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/backends/xrandr/xrandrxcbhelper.cpp
^
|
@@ -270,5 +270,3 @@
return false;
}
-
-#include "xrandrxcbhelper.moc"
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/backends/xrandr1.1/CMakeLists.txt
^
|
@@ -1,4 +1,4 @@
-find_package(XCB REQUIRED)
+find_package(XCB REQUIRED COMPONENTS XCB RANDR)
include_directories(${CMAKE_SOURCE_DIR}/src
${KDE4_INCLUDES}
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/backends/xrandr1.1/wrapper.h
^
|
@@ -102,18 +102,18 @@
return *this;
}
- inline const Reply *operator->() {
+ inline const Reply *operator->() const {
getReply();
return m_reply;
}
- inline bool isNull() {
+ inline bool isNull() const {
getReply();
return m_reply == NULL;
}
- inline operator bool() {
+ inline operator bool() const {
return !isNull();
}
- inline const Reply *data() {
+ inline const Reply *data() const {
getReply();
return m_reply;
}
@@ -139,7 +139,7 @@
}
protected:
- void getReply() {
+ void getReply() const {
if (m_retrieved || !m_cookie.sequence) {
return;
}
@@ -164,10 +164,10 @@
other.m_window = XCB_WINDOW_NONE;
}
}
- bool m_retrieved;
+ mutable bool m_retrieved;
Cookie m_cookie;
WindowId m_window;
- Reply *m_reply;
+ mutable Reply *m_reply;
};
typedef Wrapper<xcb_randr_get_screen_size_range_reply_t, xcb_randr_get_screen_size_range_cookie_t, &xcb_randr_get_screen_size_range_reply, &xcb_randr_get_screen_size_range> ScreenSize;
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/backends/xrandr1.1/xrandr11.cpp
^
|
@@ -22,7 +22,7 @@
#include "config.h"
#include "edid.h"
-#include "configmonitor.h"
+#include "output.h"
#include <xcb/xcb.h>
#include <xcb/randr.h>
@@ -33,11 +33,11 @@
Q_LOGGING_CATEGORY(KSCREEN_XRANDR11, "kscreen.xrandr11")
-XRandR11::XRandR11(QObject* parent)
- : QObject(parent)
+XRandR11::XRandR11()
+ : KScreen::AbstractBackend()
, m_valid(false)
, m_x11Helper(0)
- , m_currentConfig(0)
+ , m_currentConfig(new KScreen::Config)
, m_currentTimestamp(0)
{
QLoggingCategory::setFilterRules(QLatin1Literal("kscreen.xrandr11.debug = true"));
@@ -66,34 +66,39 @@
XRandR11::~XRandR11()
{
closeConnection();
- delete m_currentConfig;
delete m_x11Helper;
}
QString XRandR11::name() const
{
- return "XRandR 1.1";
+ return QLatin1Literal("XRandR 1.1");
}
+QString XRandR11::serviceName() const
+{
+ return QLatin1Literal("org.kde.KScreen.Backend.XRandR11");
+}
+
+
bool XRandR11::isValid() const
{
return m_valid;
}
-KScreen::Config* XRandR11::config() const
+KScreen::ConfigPtr XRandR11::config() const
{
- KScreen::Config* config = new KScreen::Config();
+ KScreen::ConfigPtr config(new KScreen::Config);
- int screenId = QX11Info::appScreen();
+ const int screenId = QX11Info::appScreen();
xcb_screen_t* xcbScreen = screen_of_display(connection(), screenId);
- ScreenInfo info(xcbScreen->root);
- ScreenSize size(xcbScreen->root);
+ const ScreenInfo info(xcbScreen->root);
+ const ScreenSize size(xcbScreen->root);
if (info->config_timestamp == m_currentTimestamp) {
return m_currentConfig;
}
- KScreen::Screen* screen = new KScreen::Screen();
+ KScreen::ScreenPtr screen(new KScreen::Screen);
screen->setId(screenId);
screen->setCurrentSize(QSize(xcbScreen->width_in_pixels, xcbScreen->height_in_pixels));
screen->setMaxSize(QSize(size->max_width, size->max_height));
@@ -103,7 +108,7 @@
config->setScreen(screen);
KScreen::OutputList outputs;
- KScreen::Output* output = new KScreen::Output();
+ KScreen::OutputPtr output(new KScreen::Output);
output->setId(1);
output->setConnected(true);
@@ -117,19 +122,17 @@
outputs.insert(1, output);
config->setOutputs(outputs);
- KScreen::Mode *mode = 0;
+ KScreen::ModePtr mode;
KScreen::ModeList modes;
- int nrates;
- uint16_t* rates;
xcb_randr_refresh_rates_iterator_t ite = xcb_randr_get_screen_info_rates_iterator(info.data());
xcb_randr_screen_size_t* sizes = xcb_randr_get_screen_info_sizes(info.data());
for (int x = 0; x < info->nSizes; x++) {
- rates = xcb_randr_refresh_rates_rates(ite.data);
- nrates = xcb_randr_refresh_rates_rates_length(ite.data);
+ const uint16_t* rates = xcb_randr_refresh_rates_rates(ite.data);
+ const int nrates = xcb_randr_refresh_rates_rates_length(ite.data);
for (int j = 0; j < nrates; j++) {
- mode = new KScreen::Mode();
+ mode = KScreen::ModePtr(new KScreen::Mode);
mode->setId(QString::number(x) + "-" + QString::number(j));
mode->setSize(QSize(sizes[x].width, sizes[x].height));
mode->setRefreshRate((float) rates[j]);
@@ -148,45 +151,28 @@
return config;
}
-void XRandR11::setConfig(KScreen::Config* config) const
+void XRandR11::setConfig(const KScreen::ConfigPtr &config)
{
- KScreen::Output* output = config->outputs().take(1);
- KScreen::Mode *mode = output->currentMode();
+ const KScreen::OutputPtr output = config->outputs().take(1);
+ const KScreen::ModePtr mode = output->currentMode();
- int screenId = QX11Info::appScreen();
+ const int screenId = QX11Info::appScreen();
xcb_screen_t* xcbScreen = screen_of_display(connection(), screenId);
- ScreenInfo info(xcbScreen->root);
+ const ScreenInfo info(xcbScreen->root);
xcb_generic_error_t *err;
xcb_randr_set_screen_config_cookie_t cookie;
xcb_randr_set_screen_config_reply_t *result;
- int sizeId = mode->id().split("-").first().toInt();
+ const int sizeId = mode->id().split("-").first().toInt();
cookie = xcb_randr_set_screen_config(connection(), xcbScreen->root, CurrentTime, info->config_timestamp, sizeId,
- (short) output->rotation(), mode->refreshRate());
+ (short) output->rotation(), mode->refreshRate());
result = xcb_randr_set_screen_config_reply(connection(), cookie, &err);
delete result;
}
-KScreen::Edid* XRandR11::edid(int outputId) const
-{
- Q_UNUSED(outputId)
- return new KScreen::Edid();
-}
-
-void XRandR11::updateConfig(KScreen::Config* config) const
-{
- KScreen::Output* output = config->output(1);
- KScreen::Output *current = m_currentConfig->output(1);
- output->setCurrentModeId(current->currentModeId());
- output->setRotation(current->rotation());
-}
-
void XRandR11::updateConfig()
{
- delete m_currentConfig;
m_currentConfig = config();
- KScreen::ConfigMonitor::instance()->notifyUpdate();
+ Q_EMIT configChanged(m_currentConfig);
}
-
-#include "xrandr11.moc"
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/backends/xrandr1.1/xrandr11.h
^
|
@@ -20,28 +20,26 @@
#define XRANDR11_BACKEND_H
#include "xlibandxcb.h"
-#include "../abstractbackend.h"
+#include "abstractbackend.h"
#include <QtCore/QObject>
#include <QLoggingCategory>
class XRandRXCBHelper;
-class XRandR11 : public QObject, public AbstractBackend
+class XRandR11 : public KScreen::AbstractBackend
{
Q_OBJECT
- Q_INTERFACES(AbstractBackend)
Q_PLUGIN_METADATA(IID "org.kf5.kscreen.backends.xrandr11")
public:
- explicit XRandR11(QObject* parent = 0);
+ explicit XRandR11();
virtual ~XRandR11();
virtual QString name() const;
- virtual KScreen::Config* config() const;
- virtual void setConfig(KScreen::Config* config) const;
+ virtual QString serviceName() const;
+ virtual KScreen::ConfigPtr config() const;
+ virtual void setConfig(const KScreen::ConfigPtr &config);
virtual bool isValid() const;
- virtual KScreen::Edid *edid(int outputId) const;
- virtual void updateConfig(KScreen::Config *config) const;
private Q_SLOTS:
void updateConfig();
@@ -49,7 +47,7 @@
private:
bool m_valid;
XRandRXCBHelper* m_x11Helper;
- KScreen::Config* m_currentConfig;
+ KScreen::ConfigPtr m_currentConfig;
xcb_timestamp_t m_currentTimestamp;
};
|
[-]
[+]
|
Added |
libkscreen-5.1.90.tar.xz/interfaces
^
|
+(directory)
|
[-]
[+]
|
Added |
libkscreen-5.1.90.tar.xz/interfaces/org.kde.KScreen.Backend.xml
^
|
@@ -0,0 +1,26 @@
+<!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.Backend">
+ <method name="getConfig">
+ <arg type="a{sv}" direction="out" />
+ <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap" />
+ </method>
+ <method name="setConfig">
+ <arg type="a{sv}" direction="in" />
+ <arg type="a{sv}" direction="out" />
+ <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QVariantMap" />
+ <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap" />
+ </method>
+ <signal name="configChanged">
+ <arg type="a{sv}" direction="out" />
+ <annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="QVariantMap" />
+ </signal>
+
+ <method name="getEdid">
+ <arg type="i" direction="in" />
+ <arg type="ay" direction="out" />
+ </method>
+
+ <method name="quit" />
+ </interface>
+</node>
|
[-]
[+]
|
Added |
libkscreen-5.1.90.tar.xz/interfaces/org.kde.KScreen.FakeBackend.xml
^
|
@@ -0,0 +1,25 @@
+<!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.FakeBackend">
+ <method name="setConnected">
+ <arg type="i" name="outputId" direction="in" />
+ <arg type="b" name="connected" direction="in" />
+ </method>
+ <method name="setEnabled">
+ <arg type="i" name="outputId" direction="in" />
+ <arg type="b" name="enabled" direction="in" />
+ </method>
+ <method name="setPrimary">
+ <arg type="i" name="outputId" direction="in" />
+ <arg type="b" name="primary" direction="in" />
+ </method>
+ <method name="setCurrentModeId">
+ <arg type="i" name="outputId" direction="in" />
+ <arg type="s" name="currentModeId" direction="in" />
+ </method>
+ <method name="setRotation">
+ <arg type="i" name="outputId" direction="in" />
+ <arg type="i" name="rotation" direction="in" />
+ </method>
+ </interface>
+</node>
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/src/CMakeLists.txt
^
|
@@ -1,9 +1,18 @@
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
- backendloader.cpp
+ abstractbackend.cpp
+ backendmanager.cpp
config.cpp
+ configoperation.cpp
+ getconfigoperation.cpp
+ setconfigoperation.cpp
configmonitor.cpp
+ configserializer.cpp
screen.cpp
output.cpp
edid.cpp
@@ -11,9 +20,17 @@
debug_p.cpp
)
+qt5_add_dbus_interface(libkscreen_SRCS ${CMAKE_SOURCE_DIR}/interfaces/org.kde.KScreen.Backend.xml backendinterface)
+
add_library(KF5Screen SHARED ${libkscreen_SRCS})
-target_link_libraries(KF5Screen PUBLIC Qt5::Core PRIVATE Qt5::X11Extras)
+target_link_libraries(KF5Screen
+ PUBLIC
+ Qt5::Core
+ PRIVATE
+ Qt5::DBus
+ Qt5::X11Extras
+)
set_target_properties(KF5Screen PROPERTIES
VERSION "${KSCREEN_VERSION_STRING}"
@@ -34,6 +51,10 @@
Screen
Config
ConfigMonitor
+ ConfigOperation
+ GetConfigOperation
+ SetConfigOperation
+ Types
PREFIX KScreen
REQUIRED_HEADERS KScreen_REQ_HEADERS
)
@@ -42,8 +63,9 @@
DESTINATION ${KF5_INCLUDE_INSTALL_DIR}/KScreen/KScreen
COMPONENT Devel)
install(FILES kscreen_export.h
- ${KScreen_REQ_HEADERS}
- DESTINATION ${KF5_INCLUDE_INSTALL_DIR}/KScreen/kscreen)
+ backendmanager_p.h # needed for unit-tests in KScreen
+ ${KScreen_REQ_HEADERS}
+ DESTINATION ${KF5_INCLUDE_INSTALL_DIR}/KScreen/kscreen)
if(NOT WIN32)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/kscreen2.pc.in ${CMAKE_CURRENT_BINARY_DIR}/kscreen2.pc @ONLY)
|
[-]
[+]
|
Added |
libkscreen-5.1.90.tar.xz/src/abstractbackend.cpp
^
|
@@ -0,0 +1,26 @@
+/*************************************************************************************
+ * Copyright (C) 2014 by Daniel Vrátil <dvratil@redhat.com> *
+ * *
+ * This library is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * This library 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this library; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
+ *************************************************************************************/
+
+
+#include "abstractbackend.h"
+
+QByteArray KScreen::AbstractBackend::edid(int outputId) const
+{
+ Q_UNUSED(outputId);
+ return QByteArray();
+}
|
[-]
[+]
|
Added |
libkscreen-5.1.90.tar.xz/src/abstractbackend.h
^
|
@@ -0,0 +1,105 @@
+/*************************************************************************************
+ * Copyright (C) 2012 by Alejandro Fiestas Olivares <afiestas@kde.org> *
+ * Copyright (C) 2014 by Daniel Vrátil <dvratil@redhat.com> *
+ * *
+ * This library is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * This library 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this library; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
+ *************************************************************************************/
+
+#ifndef ABSTRACT_BACKEND_H
+#define ABSTRACT_BACKEND_H
+
+#include "kscreen_export.h"
+#include "types.h"
+
+#include <QString>
+#include <QObject>
+
+namespace KScreen {
+ class Config;
+ class Edid;
+
+/**
+ * Abstract class for backends.
+ */
+class KSCREEN_EXPORT AbstractBackend : public QObject
+{
+ Q_OBJECT
+
+public:
+ virtual ~AbstractBackend() {}
+
+ /**
+ * Returns user-friendly name of the backend
+ */
+ virtual QString name() const = 0;
+
+ /**
+ * Returns name of DBus service that should be used for this backend
+ *
+ * Each backend must have unique service name (usually something like
+ * org.kde.KScreen.Backend.%backendName% to allow multiple different backends
+ * running concurrently.
+ */
+ virtual QString serviceName() const = 0;
+
+ /**
+ * Returns a new Config object, holding Screen, Output objects, etc
+ *
+ * @return Config object for the system.
+ */
+ virtual KScreen::ConfigPtr config() const = 0;
+
+ /**
+ * Apply a config object to the system.
+ *
+ * @param config Configuration to apply
+ */
+ virtual void setConfig(const KScreen::ConfigPtr &config) = 0;
+
+ /**
+ * Returns whether the backend is in valid state.
+ *
+ * Backends should use this to tell BackendLauncher whether they are capable
+ * of operating on current platform
+ */
+ virtual bool isValid() const = 0;
+
+ /**
+ * Returns encoded EDID data for given output
+ *
+ * Default implementation does nothing and returns null QByteArray. Backends
+ * that don't support EDID don't have to reimplement this method.
+ *
+ * @param outputd ID of output to return EDID data for
+ */
+ virtual QByteArray edid(int outputId) const;
+
+Q_SIGNALS:
+ /**
+ * Emitted when backend detects a change in configuration
+ *
+ * It's OK to emit signal for every single change. The emissions are aggregated
+ * in backend launcher, so that the backend does not spam DBus and client
+ * applications
+ *
+ * @param config New configuration
+ */
+ void configChanged(const KScreen::ConfigPtr &config);
+
+};
+
+} // namespace KScreen
+
+#endif //ABSTRACT_BACKEND_H
|
[-]
[+]
|
Added |
libkscreen-5.1.90.tar.xz/src/backendlauncher
^
|
+(directory)
|
[-]
[+]
|
Added |
libkscreen-5.1.90.tar.xz/src/backendlauncher/CMakeLists.txt
^
|
@@ -0,0 +1,25 @@
+include_directories(${CMAKE_SOURCE_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}/..
+ ${CMAKE_CURRENT_SOURCE_DIR}/..
+)
+
+set(backendlauncher_SRCS
+ main.cpp
+ backendloader.cpp
+ backenddbuswrapper.cpp
+)
+
+qt5_add_dbus_adaptor(backendlauncher_SRCS ${CMAKE_SOURCE_DIR}/interfaces/org.kde.KScreen.Backend.xml
+ backenddbuswrapper.h BackendDBusWrapper backendadaptor BackendAdaptor)
+
+add_executable(kscreen_backend_launcher ${backendlauncher_SRCS})
+
+target_link_libraries(kscreen_backend_launcher
+ KF5Screen
+ Qt5::Core
+ Qt5::Gui
+ Qt5::X11Extras
+ Qt5::DBus
+)
+
+install(TARGETS kscreen_backend_launcher DESTINATION ${CMAKE_INSTALL_FULL_LIBEXECDIR_KF5})
|
[-]
[+]
|
Added |
libkscreen-5.1.90.tar.xz/src/backendlauncher/backenddbuswrapper.cpp
^
|
@@ -0,0 +1,141 @@
+/*
+ * Copyright (C) 2014 Daniel Vratil <dvratil@redhat.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#include "backenddbuswrapper.h"
+#include "backendloader.h"
+#include "backendadaptor.h"
+#include "src/configserializer_p.h"
+#include "src/config.h"
+#include "src/abstractbackend.h"
+
+#include <QDBusConnection>
+#include <QDBusError>
+
+BackendDBusWrapper::BackendDBusWrapper(KScreen::AbstractBackend* backend)
+ : QObject()
+ , mBackend(backend)
+{
+ connect(mBackend, &KScreen::AbstractBackend::configChanged,
+ this, &BackendDBusWrapper::backendConfigChanged);
+
+ mChangeCollector.setSingleShot(true);
+ mChangeCollector.setInterval(200); // wait for 200 msecs without any change
+ // before actually emitting configChanged
+ connect(&mChangeCollector, &QTimer::timeout,
+ this, &BackendDBusWrapper::doEmitConfigChanged);
+}
+
+BackendDBusWrapper::~BackendDBusWrapper()
+{
+}
+
+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)) {
+ 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;
+}
+
+QVariantMap BackendDBusWrapper::getConfig() const
+{
+ const KScreen::ConfigPtr config = mBackend->config();
+ Q_ASSERT(!config.isNull());
+ if (!config) {
+ qCWarning(KSCREEN_BACKEND_LAUNCHER) << "Backend provided an empty config!";
+ return QVariantMap();
+ }
+
+ const QJsonObject obj = KScreen::ConfigSerializer::serializeConfig(mBackend->config());
+ Q_ASSERT(!obj.isEmpty());
+ return obj.toVariantMap();
+}
+
+QVariantMap BackendDBusWrapper::setConfig(const QVariantMap &configMap)
+{
+ if (configMap.isEmpty()) {
+ qCWarning(KSCREEN_BACKEND_LAUNCHER) << "Received an empty config map";
+ return QVariantMap();
+ }
+
+ const KScreen::ConfigPtr config = KScreen::ConfigSerializer::deserializeConfig(configMap);
+ mBackend->setConfig(config);
+
+ mCurrentConfig = mBackend->config();
+ QMetaObject::invokeMethod(this, "doEmitConfigChanged", Qt::QueuedConnection);
+
+ // TODO: setConfig should return adjusted config that was actually applied
+ const QJsonObject obj = KScreen::ConfigSerializer::serializeConfig(mCurrentConfig);
+ Q_ASSERT(!obj.isEmpty());
+ return obj.toVariantMap();
+}
+
+QByteArray BackendDBusWrapper::getEdid(int output) const
+{
+ const QByteArray edidData = mBackend->edid(output);
+ if (edidData.isEmpty()) {
+ return QByteArray();
+ }
+
+ 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());
+ if (!config) {
+ qCWarning(KSCREEN_BACKEND_LAUNCHER) << "Backend provided an empty config!";
+ return;
+ }
+
+ mCurrentConfig = config;
+ mChangeCollector.start();
+}
+
+void BackendDBusWrapper::doEmitConfigChanged()
+{
+ Q_ASSERT(!mCurrentConfig.isNull());
+ if (mCurrentConfig.isNull()) {
+ return;
+ }
+
+ const QJsonObject obj = KScreen::ConfigSerializer::serializeConfig(mCurrentConfig);
+ Q_EMIT configChanged(obj.toVariantMap());
+
+ mCurrentConfig.clear();
+ mChangeCollector.stop();
+}
+
|
[-]
[+]
|
Added |
libkscreen-5.1.90.tar.xz/src/backendlauncher/backenddbuswrapper.h
^
|
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2014 Daniel Vratil <dvratil@redhat.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifndef BACKENDDBUSWRAPPER_H
+#define BACKENDDBUSWRAPPER_H
+
+#include <QObject>
+#include <QTimer>
+
+#include "src/types.h"
+
+namespace KScreen
+{
+class AbstractBackend;
+}
+
+class BackendDBusWrapper : public QObject
+{
+ Q_OBJECT
+ Q_CLASSINFO("D-Bus Interface", "org.kde.KScreen.Backend")
+
+public:
+ explicit BackendDBusWrapper(KScreen::AbstractBackend *backend);
+ virtual ~BackendDBusWrapper();
+
+ bool init();
+
+ QVariantMap getConfig() const;
+ QVariantMap setConfig(const QVariantMap &config);
+ QByteArray getEdid(int output) const;
+
+ void quit();
+
+Q_SIGNALS:
+ void configChanged(const QVariantMap &config);
+
+private Q_SLOTS:
+ void backendConfigChanged(const KScreen::ConfigPtr &config);
+ void doEmitConfigChanged();
+
+
+private:
+ KScreen::AbstractBackend *mBackend;
+ QTimer mChangeCollector;
+ KScreen::ConfigPtr mCurrentConfig;
+
+};
+
+#endif // BACKENDDBUSWRAPPER_H
|
[-]
[+]
|
Added |
libkscreen-5.1.90.tar.xz/src/backendlauncher/backendloader.cpp
^
|
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2014 Daniel Vratil <dvratil@redhat.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#include "backendloader.h"
+#include "src/abstractbackend.h"
+
+#include <QCoreApplication>
+#include <QDBusConnectionInterface>
+#include <QDir>
+#include <QPluginLoader>
+#include <QX11Info>
+
+#include <QDBusConnection>
+#include <QDBusInterface>
+
+Q_LOGGING_CATEGORY(KSCREEN_BACKEND_LAUNCHER, "kscreen.backendLauncher")
+
+BackendLoader::BackendLoader()
+ : QObject()
+{
+}
+
+BackendLoader::~BackendLoader()
+{
+}
+
+bool BackendLoader::loadBackend(const QString& backend)
+{
+ qCDebug(KSCREEN_BACKEND_LAUNCHER) << "Requested backend:" << backend;
+ const QString backendFilter = QString::fromLatin1("KSC_%1*").arg(backend);
+ const QStringList paths = QCoreApplication::libraryPaths();
+ qCDebug(KSCREEN_BACKEND_LAUNCHER) << "Lookup paths: " << paths;
+ Q_FOREACH (const QString &path, paths) {
+ const QDir dir(path + QLatin1String("/kf5/kscreen/"),
+ backendFilter,
+ QDir::SortFlags(QDir::QDir::NoSort),
+ QDir::NoDotAndDotDot | QDir::Files);
+ 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")))) {
+ continue;
+ }
+
+ // When on X11, skip the QScreen backend, instead use the XRandR backend,
+ // if not specified in KSCREEN_BACKEND
+ if (backend.isEmpty() &&
+ finfo.fileName().contains(QLatin1String("KSC_QScreen")) &&
+ QX11Info::isPlatformX11()) {
+ continue;
+ }
+
+ // When not on X11, skip the XRandR backend, and fall back to QSCreen
+ // if not specified in KSCREEN_BACKEND
+ if (backend.isEmpty() &&
+ finfo.fileName().contains(QLatin1String("KSC_XRandR")) &&
+ !QX11Info::isPlatformX11()) {
+ continue;
+ }
+
+ qCDebug(KSCREEN_BACKEND_LAUNCHER) << "Trying" << finfo.filePath();
+ QPluginLoader loader(finfo.filePath());
+ loader.load();
+ QObject *instance = loader.instance();
+ if (!instance) {
+ qCDebug(KSCREEN_BACKEND_LAUNCHER) << loader.errorString();
+ loader.unload();
+ continue;
+ }
+
+ mBackend = qobject_cast<KScreen::AbstractBackend*>(instance);
+ if (mBackend) {
+ if (!mBackend->isValid()) {
+ qCDebug(KSCREEN_BACKEND_LAUNCHER) << "Skipping" << mBackend->name() << "backend";
+ delete mBackend;
+ mBackend = 0;
+ loader.unload();
+ continue;
+ }
+ qCDebug(KSCREEN_BACKEND_LAUNCHER) << "Loading" << mBackend->name() << "backend";
+ return true;
+ } else {
+ qCDebug(KSCREEN_BACKEND_LAUNCHER) << finfo.fileName() << "does not provide valid KScreen backend";
+ }
+ }
+ }
+
+ return false;
+}
+
+KScreen::AbstractBackend* BackendLoader::backend() const
+{
+ return mBackend;
+}
+
+bool BackendLoader::checkIsAlreadyRunning()
+{
+ return QDBusConnection::sessionBus().interface()->isServiceRegistered(mBackend->serviceName());
+}
|
[-]
[+]
|
Added |
libkscreen-5.1.90.tar.xz/src/backendlauncher/backendloader.h
^
|
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2014 Daniel Vratil <dvratil@redhat.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifndef BACKENDLAUNCHER_H
+#define BACKENDLAUNCHER_H
+
+#include <QObject>
+#include <QLoggingCategory>
+
+namespace KScreen
+{
+class AbstractBackend;
+}
+
+class BackendLoader : public QObject
+{
+ Q_OBJECT
+
+public:
+ enum State {
+ BackendLoaded = 0,
+ BackendAlreadyExists = 1,
+ BackendFailedToLoad = 2,
+ LauncherStopped = 3
+ };
+
+ explicit BackendLoader();
+ ~BackendLoader();
+
+ bool loadBackend(const QString &backendName = QString());
+ bool checkIsAlreadyRunning();
+
+ KScreen::AbstractBackend* backend() const;
+
+private:
+
+ KScreen::AbstractBackend* mBackend;
+};
+
+Q_DECLARE_LOGGING_CATEGORY(KSCREEN_BACKEND_LAUNCHER)
+
+#endif // BACKENDLAUNCHER_H
|
[-]
[+]
|
Added |
libkscreen-5.1.90.tar.xz/src/backendlauncher/main.cpp
^
|
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2014 Daniel Vratil <dvratil@redhat.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#include <QGuiApplication>
+#include <QCommandLineParser>
+#include <QDebug>
+
+#include "backendloader.h"
+#include "backenddbuswrapper.h"
+
+#include <src/abstractbackend.h>
+
+int main(int argc, char **argv)
+{
+ QGuiApplication app(argc, argv);
+
+ BackendLoader launcher;
+
+ 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 = launcher.loadBackend(parser.value(backendOption));
+ } else {
+ success = launcher.loadBackend();
+ }
+
+ // 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
+ // launcher when no other KScreen-enabled processes are running
+ BackendDBusWrapper backendWrapper(launcher.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 = launcher.checkIsAlreadyRunning();
+ if (alreadyRunning) {
+ // If it is, let caller now it's DBus service name and terminate
+ printf("%s", qPrintable(launcher.backend()->serviceName()));
+ fflush(stdout);
+ return BackendLoader::BackendAlreadyExists;
+ }
+ return BackendLoader::BackendFailedToLoad;
+ }
+
+ // Now let caller now what's our DBus service name, so it can connect to us
+ printf("%s", qPrintable(launcher.backend()->serviceName()));
+ fflush(stdout);
+
+ // And go!
+ return app.exec();
+}
|
[-]
[+]
|
Added |
libkscreen-5.1.90.tar.xz/src/backendmanager.cpp
^
|
@@ -0,0 +1,305 @@
+/*
+ * Copyright (C) 2014 Daniel Vratil <dvratil@redhat.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#include "backendmanager_p.h"
+#include "backendinterface.h"
+#include "backendlauncher/backendloader.h"
+#include "debug_p.h"
+#include "getconfigoperation.h"
+#include "configserializer_p.h"
+
+#include <QDBusConnection>
+#include <QDBusPendingCall>
+#include <QDBusPendingCallWatcher>
+#include <QDBusPendingReply>
+#include <QDBusConnectionInterface>
+#include <QStandardPaths>
+
+#include "config-libkscreen.h"
+
+#include <QProcess>
+
+#ifdef Q_OS_UNIX
+#include <sys/wait.h>
+#include <signal.h>
+#endif
+
+using namespace KScreen;
+
+Q_DECLARE_METATYPE(org::kde::kscreen::Backend*)
+
+const int BackendManager::sMaxCrashCount = 4;
+
+BackendManager *BackendManager::sInstance = 0;
+
+BackendManager *BackendManager::instance()
+{
+ if (!sInstance) {
+ sInstance = new BackendManager();
+ }
+
+ return sInstance;
+}
+
+BackendManager::BackendManager()
+ : QObject()
+ , mInterface(0)
+ , mCrashCount(0)
+ , mLauncher(0)
+ , mShuttingDown(false)
+ , mRequestsCounter(0)
+{
+ qRegisterMetaType<org::kde::kscreen::Backend*>("OrgKdeKscreenBackendInterface");
+
+ mServiceWatcher.setConnection(QDBusConnection::sessionBus());
+ connect(&mServiceWatcher, &QDBusServiceWatcher::serviceUnregistered,
+ this, &BackendManager::backendServiceUnregistered);
+
+ mResetCrashCountTimer.setSingleShot(true);
+ mResetCrashCountTimer.setInterval(60000);
+ connect(&mResetCrashCountTimer, &QTimer::timeout,
+ this, [=]() {
+ mCrashCount = 0;
+ });
+}
+
+BackendManager::~BackendManager()
+{
+}
+
+void BackendManager::requestBackend()
+{
+ if (mInterface && mInterface->isValid()) {
+ ++mRequestsCounter;
+ QMetaObject::invokeMethod(this, "emitBackendReady", Qt::QueuedConnection);
+ return;
+ }
+
+ // Another request already pending
+ if (mRequestsCounter > 0) {
+ return;
+ }
+ ++mRequestsCounter;
+
+ startBackend(QString::fromLatin1(qgetenv("KSCREEN_BACKEND")));
+}
+
+void BackendManager::emitBackendReady()
+{
+ Q_EMIT backendReady(mInterface);
+ --mRequestsCounter;
+ if (mShutdownLoop.isRunning()) {
+ mShutdownLoop.quit();
+ }
+}
+
+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)
+{
+ 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
+ invalidateInterface();
+ if (!mShuttingDown) {
+ if (++mCrashCount <= sMaxCrashCount) {
+ requestBackend();
+ } else {
+ qCWarning(KSCREEN) << "Launcher has crashed too many times: not restarting";
+ mLauncher->deleteLater();
+ mLauncher = 0;
+ }
+ }
+ mShuttingDown = false;
+ 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";
+ invalidateInterface();
+ emitBackendReady();
+ break;
+
+ case BackendLoader::BackendAlreadyExists:
+ // The launcher wrote service name to stdout, so backendReady() was emitted
|
[-]
[+]
|
Added |
libkscreen-5.1.90.tar.xz/src/backendmanager_p.h
^
|
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2014 Daniel Vratil <dvratil@redhat.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+/**
+ * WARNING: This header is *not* part of public API and is subject to change.
+ * There are not guarantees or API or ABI stability or compatibility between
+ * releases
+ */
+
+#ifndef KSCREEN_BACKENDMANAGER_H
+#define KSCREEN_BACKENDMANAGER_H
+
+#include <QObject>
+#include <QProcess>
+#include <QDBusServiceWatcher>
+#include <QTimer>
+#include <QEventLoop>
+
+#include "types.h"
+#include "kscreen_export.h"
+
+class QDBusPendingCallWatcher;
+class OrgKdeKscreenBackendInterface;
+
+namespace KScreen {
+
+class KSCREEN_EXPORT BackendManager : public QObject
+{
+ Q_OBJECT
+
+public:
+ static BackendManager *instance();
+ ~BackendManager();
+
+ void requestBackend();
+
+ 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 backendServiceUnregistered(const QString &serviceName);
+
+private:
+ void findBestBackend();
+ void invalidateInterface();
+ void backendServiceReady();
+
+
+ explicit BackendManager();
+ static BackendManager *sInstance;
+ static const int sMaxCrashCount;
+
+ OrgKdeKscreenBackendInterface *mInterface;
+ int mCrashCount;
+
+ QProcess *mLauncher;
+ QString mBackendService;
+ QDBusServiceWatcher mServiceWatcher;
+ KScreen::ConfigPtr mConfig;
+ QTimer mResetCrashCountTimer;
+ bool mShuttingDown;
+
+ int mRequestsCounter;
+ QEventLoop mShutdownLoop;
+
+};
+
+}
+
+#endif // KSCREEN_BACKENDMANAGER_H
|
[-]
[+]
|
Added |
libkscreen-5.1.90.tar.xz/src/config-libkscreen.h.cmake
^
|
@@ -0,0 +1,2 @@
+
+#define CMAKE_INSTALL_FULL_LIBEXECDIR_KF5 "${CMAKE_INSTALL_FULL_LIBEXECDIR_KF5}"
\ No newline at end of file
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/src/config.cpp
^
|
@@ -1,5 +1,6 @@
/*************************************************************************************
* Copyright (C) 2012 by Alejandro Fiestas Olivares <afiestas@kde.org> *
+ * Copyright (C) 2014 by Daniel Vrátil <dvratil@redhat.com> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
@@ -18,21 +19,20 @@
#include "config.h"
#include "output.h"
-#include "backendloader.h"
-#include "backends/abstractbackend.h"
+#include "backendmanager_p.h"
+#include "abstractbackend.h"
+#include "debug_p.h"
#include <QtCore/QDebug>
#include <QtCore/QRect>
-namespace KScreen {
+using namespace KScreen;
class Config::Private
{
public:
Private():
- valid(true),
- screen(0),
- primaryOutput(0)
+ valid(true)
{ }
Private(const Private &other):
@@ -40,54 +40,31 @@
primaryOutput(other.primaryOutput)
{
screen = other.screen->clone();
- Q_FOREACH (Output *otherOutput, other.outputs) {
+ Q_FOREACH (const OutputPtr &otherOutput, other.outputs) {
outputs.insert(otherOutput->id(), otherOutput->clone());
}
}
bool valid;
- Screen* screen;
- Output* primaryOutput;
+ ScreenPtr screen;
+ OutputPtr primaryOutput;
OutputList outputs;
};
-bool Config::loadBackend()
+bool Config::canBeApplied(const ConfigPtr &config)
{
- return BackendLoader::init();
-}
-
-Config* Config::current()
-{
- if (!BackendLoader::init()) {
- return 0;
- }
-
- return BackendLoader::backend()->config();
-}
-
-bool Config::setConfig(Config* config)
-{
- if (!BackendLoader::init()) {
+ ConfigPtr currentConfig = BackendManager::instance()->config();
+ if (!currentConfig) {
+ qCDebug(KSCREEN) << "canBeApplied: Current config not available, returning false";
return false;
}
- if (!Config::canBeApplied(config)) {
- return false;
- }
-
- BackendLoader::backend()->setConfig(config);
- return true;
-}
-
-bool Config::canBeApplied(Config* config)
-{
- Config* currentConfig = BackendLoader::backend()->config();
QRect rect;
QSize outputSize;
- Output* currentOutput = 0;
- OutputList outputs = config->outputs();
+ OutputPtr currentOutput;
+ const OutputList outputs = config->outputs();
int enabledOutputsCount = 0;
- Q_FOREACH(Output *output, outputs) {
+ Q_FOREACH(const OutputPtr &output, outputs) {
if (!output->isEnabled()) {
continue;
}
@@ -97,29 +74,29 @@
currentOutput = currentConfig->output(output->id());
//If there is no such output
if (!currentOutput) {
- qDebug() << "The output:" << output->id() << "does not exists";
+ qCDebug(KSCREEN) << "canBeApplied: The output:" << output->id() << "does not exists";
return false;
}
//If the output is not connected
if (!currentOutput->isConnected()) {
- qDebug() << "The output:" << output->id() << "is not connected";
+ qCDebug(KSCREEN) << "canBeApplied: The output:" << output->id() << "is not connected";
return false;
}
//if there is no currentMode
if (output->currentModeId().isEmpty()) {
- qDebug() << "The output:" << output->id() << "has no currentModeId";
+ qCDebug(KSCREEN) << "canBeApplied: The output:" << output->id() << "has no currentModeId";
return false;
}
//If the mode is not found in the current output
if (!currentOutput->mode(output->currentModeId())) {
- qDebug() << "The output:" << output->id() << "has no mode:" << output->currentModeId();
+ qCDebug(KSCREEN) << "canBeApplied: The output:" << output->id() << "has no mode:" << output->currentModeId();
return false;
}
- Mode *currentMode = output->currentMode();
+ const ModePtr currentMode = output->currentMode();
- QSize outputSize = currentMode->size();
+ const QSize outputSize = currentMode->size();
if (output->pos().x() < rect.x()) {
rect.setX(output->pos().x());
@@ -149,24 +126,24 @@
const int maxEnabledOutputsCount = config->screen()->maxActiveOutputsCount();
if (enabledOutputsCount > maxEnabledOutputsCount) {
- qDebug() << "Too many active screens. Requested: " << enabledOutputsCount << ", Max: " << maxEnabledOutputsCount;
+ qCDebug(KSCREEN) << "canBeApplied: Too many active screens. Requested: " << enabledOutputsCount << ", Max: " << maxEnabledOutputsCount;
return false;
}
if (rect.width() > config->screen()->maxSize().width()) {
- qDebug() << "The configuration has too much width:" << rect.width();
+ qCDebug(KSCREEN) << "canBeApplied: The configuration is too wide:" << rect.width();
return false;
}
if (rect.height() > config->screen()->maxSize().height()) {
- qDebug() << "The configuration has too much height:" << rect.height();
+ qCDebug(KSCREEN) << "canBeApplied: The configuration is too high:" << rect.height();
return false;
}
return true;
}
-Config::Config(QObject* parent)
- : QObject(parent)
+Config::Config()
+ : QObject(0)
, d(new Private())
{
}
@@ -183,47 +160,40 @@
delete d;
}
-Config *Config::clone() const
+ConfigPtr Config::clone() const
{
- Config *config = new Config(new Private(*d));
- // Set parent of the newly copied items
- config->d->screen->setParent(config);
- Q_FOREACH (Output *output, config->d->outputs) {
- output->setParent(config);
- }
-
- return config;
+ return ConfigPtr(new Config(new Private(*d)));
}
-Screen* Config::screen() const
+ScreenPtr Config::screen() const
{
return d->screen;
}
-void Config::setScreen(Screen* screen)
+void Config::setScreen(const ScreenPtr &screen)
{
d->screen = screen;
}
-Output* Config::output(int outputId) const
+OutputPtr Config::output(int outputId) const
{
if (!d->outputs.contains(outputId)) {
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/src/config.h
^
|
@@ -1,5 +1,6 @@
/*************************************************************************************
* Copyright (C) 2012 by Alejandro Fiestas Olivares <afiestas@kde.org> *
+ * Copyright (C) 2014 by Daniel Vrátil <dvratil@redhat.com> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
@@ -20,13 +21,14 @@
#define KSCREEN_CONFIG_H
#include "screen.h"
-#include "output.h"
+#include "types.h"
#include "kscreen_export.h"
#include <QtCore/QHash>
#include <QtCore/QObject>
#include <QtCore/QMetaType>
+
namespace KScreen {
/**
@@ -44,39 +46,11 @@
class KSCREEN_EXPORT Config : public QObject
{
Q_OBJECT
- Q_PROPERTY(Screen* screen READ screen)
+ Q_PROPERTY(ScreenPtr screen READ screen)
Q_PROPERTY(OutputList outputs READ outputs)
public:
/**
- * Tries to load a backend (it might be already loaded)
- *
- * @return true if there is a working backend, false if none are found or work
- */
- static bool loadBackend();
-
- /**
- * Gets the current system configuration
- *
- * The returned config is a representation of the current system setup, for
- * example if your screens a currently cloned, it will show that.
- *
- * @return the current system config, or null on error
- */
- static Config* current();
-
- /**
- * Sets the given config to the system
- *
- * The config will first be validated via canBeApplied(), then
- * it will be applied to the system.
- *
- * @arg config to be applied
- * @return true if everything went well, false if something failed
- */
- static bool setConfig(Config* config);
-
- /**
* Validates that a config can be applied in the current system
*
* Each system has different constrains, this method will test
@@ -86,7 +60,7 @@
* @arg config to be checked
* @return true if the configuration can be applied, false if not.
*/
- static bool canBeApplied(Config* config);
+ static bool canBeApplied(const ConfigPtr &config);
/**
* Instance an empty config
@@ -98,7 +72,7 @@
* So usually what you do is call current() and then modify
* whatever you need.
*/
- explicit Config(QObject *parent = 0);
+ explicit Config();
virtual ~Config();
/**
@@ -106,27 +80,30 @@
*
* @return a new Config instance with same property values
*/
- Config* clone() const;
+ ConfigPtr clone() const;
- Screen* screen() const;
- void setScreen(Screen* screen);
+ ScreenPtr screen() const;
+ void setScreen(const ScreenPtr &screen);
- Output* output(int outputId) const;
- QHash<int, Output*> outputs() const;
- QHash<int, Output*> connectedOutputs() const;
- Output* primaryOutput() const;
- void setPrimaryOutput(Output *output);
- void addOutput(Output *output);
+ OutputPtr output(int outputId) const;
+ OutputList outputs() const;
+ OutputList connectedOutputs() const;
+ OutputPtr primaryOutput() const;
+ void setPrimaryOutput(const OutputPtr &output);
+ void addOutput(const OutputPtr &output);
void removeOutput(int outputId);
void setOutputs(OutputList outputs);
bool isValid() const;
void setValid(bool valid);
+ void apply(const ConfigPtr &other);
+
Q_SIGNALS:
- void outputAdded(KScreen::Output *output);
+ void outputAdded(const KScreen::OutputPtr &output);
void outputRemoved(int outputId);
- void primaryOutputChanged(KScreen::Output *output);
+ void primaryOutputChanged(const KScreen::OutputPtr &output);
+
private:
Q_DISABLE_COPY(Config)
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/src/configmonitor.cpp
^
|
@@ -1,5 +1,5 @@
/*************************************************************************************
- * Copyright 2012, 2013 Daniel Vrátil <dvratil@redhat.com> *
+ * Copyright 2012 - 2014 Daniel Vrátil <dvratil@redhat.com> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
@@ -17,45 +17,185 @@
*************************************************************************************/
#include "configmonitor.h"
-#include "backendloader.h"
-#include "backends/abstractbackend.h"
+#include "backendmanager_p.h"
+#include "backendinterface.h"
+#include "abstractbackend.h"
+#include "configserializer_p.h"
+#include "getconfigoperation.h"
+#include "debug_p.h"
+#include "output.h"
+
+#include <QDBusPendingCallWatcher>
using namespace KScreen;
-class ConfigMonitor::Private
+class ConfigMonitor::Private : public QObject
{
- public:
- Private(ConfigMonitor *q)
- : backend(BackendLoader::backend())
- , m_q(q)
- { }
+ Q_OBJECT
- void updateConfigs();
- void _k_configurationDestroyed(QObject* removedConfig);
+public:
+ Private(ConfigMonitor *q);
- QList< KScreen::Config* > watchedConfigs;
- AbstractBackend* backend;
- ConfigMonitor *m_q;
+ void updateConfigs();
+ void onBackendReady(org::kde::kscreen::Backend *backend);
+ void backendConfigChanged(const QVariantMap &config);
+ void configDestroyed(QObject* removedConfig);
+ void getConfigFinished(ConfigOperation *op);
+ void updateConfigs(const KScreen::ConfigPtr &newConfig);
+ void edidReady(QDBusPendingCallWatcher *watcher);
+
+ QList<QWeakPointer<KScreen::Config>> watchedConfigs;
+
+ QPointer<org::kde::kscreen::Backend> mBackend;
+ bool mFirstBackend;
+
+ QSet<int> mPendingEDIDRequests;
+ KScreen::ConfigPtr mPendingConfigUpdate;
+private:
+ ConfigMonitor *q;
};
-void ConfigMonitor::Private::updateConfigs()
+ConfigMonitor::Private::Private(ConfigMonitor *q)
+ : QObject(q)
+ , q(q)
+ , mFirstBackend(true)
{
- Q_FOREACH( Config *config, watchedConfigs) {
- if (config) {
- backend->updateConfig(config);
+}
+
+void ConfigMonitor::Private::onBackendReady(org::kde::kscreen::Backend *backend)
+{
+ if (backend == mBackend) {
+ return;
+ }
+
+ if (mBackend) {
+ disconnect(mBackend.data(), &org::kde::kscreen::Backend::configChanged,
+ this, &ConfigMonitor::Private::backendConfigChanged);
+ }
+
+ mBackend = QPointer<org::kde::kscreen::Backend>(backend);
+ // If we received a new backend interface, then it's very likely that it is
+ // because the backend process has crashed - just to be sure we haven't missed
+ // any change, request the current config now and update our watched configs
+ //
+ // Only request the config if this is not initial backend request, because it
+ // can happen that if a change happened before now, or before we get the config,
+ // the result will be invalid. This can happen when KScreen KDED launches and
+ // detects changes need to be done.
+ if (!mFirstBackend && !watchedConfigs.isEmpty()) {
+ connect(new GetConfigOperation(), &GetConfigOperation::finished,
+ this, &Private::getConfigFinished);
+ }
+ mFirstBackend = false;
+
+ connect(mBackend.data(), &org::kde::kscreen::Backend::configChanged,
+ this, &ConfigMonitor::Private::backendConfigChanged);
+
+}
+
+void ConfigMonitor::Private::getConfigFinished(ConfigOperation* op)
+{
+ if (op->hasError()) {
+ qCWarning(KSCREEN) << "Failed to retrieve current config: " << op->errorString();
+ return;
+ }
+
+ const KScreen::ConfigPtr config = qobject_cast<GetConfigOperation*>(op)->config();
+ updateConfigs(config);
+}
+
+
+void ConfigMonitor::Private::backendConfigChanged(const QVariantMap &configMap)
+{
+ ConfigPtr newConfig = ConfigSerializer::deserializeConfig(configMap);
+ if (!newConfig) {
+ qCWarning(KSCREEN) << "Failed to deserialize config from DBus change notification";
+ return;
+ }
+
+ Q_FOREACH (OutputPtr output, newConfig->connectedOutputs()) {
+ if (!output->edid() && output->isConnected()) {
+ QDBusPendingReply<QByteArray> reply = mBackend->getEdid(output->id());
+ mPendingEDIDRequests.insert(output->id());
+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply);
+ watcher->setProperty("outputId", output->id());
+ connect(watcher, &QDBusPendingCallWatcher::finished,
+ this, &ConfigMonitor::Private::edidReady);
}
}
+
+ if (!mPendingEDIDRequests.isEmpty()) {
+ qCDebug(KSCREEN) << "Requesting missing EDID for outputs" << mPendingEDIDRequests;
+ mPendingConfigUpdate = newConfig;
+ } else {
+ updateConfigs(newConfig);
+ }
}
-void ConfigMonitor::Private::_k_configurationDestroyed(QObject *removedConfig)
+void ConfigMonitor::Private::edidReady(QDBusPendingCallWatcher* watcher)
{
- m_q->removeConfig(static_cast<Config*>(removedConfig));
+ const int outputId = watcher->property("outputId").toInt();
+ Q_ASSERT(!mPendingConfigUpdate.isNull());
+ Q_ASSERT(mPendingEDIDRequests.contains(outputId));
+
+ watcher->deleteLater();
+
+ mPendingEDIDRequests.remove(watcher->property("outputId").toInt());
+
+ const QDBusPendingReply<QByteArray> reply = *watcher;
+ if (reply.isError()) {
+ qCWarning(KSCREEN) << "Error when retrieving EDID: " << reply.error().message();
+ if (mPendingEDIDRequests.isEmpty()) {
+ updateConfigs(mPendingConfigUpdate);
+ }
+ return;
+ }
+
+ const QByteArray edid = reply.argumentAt<0>();
+ if (!edid.isEmpty()) {
+ OutputPtr output = mPendingConfigUpdate->output(outputId);
+ output->setEdid(edid);
+ }
+
+ if (mPendingEDIDRequests.isEmpty()) {
+ const KScreen::ConfigPtr config = mPendingConfigUpdate;
+ mPendingConfigUpdate.clear();
+ updateConfigs(config);
+ }
+}
+
+
+void ConfigMonitor::Private::updateConfigs(const KScreen::ConfigPtr &newConfig)
+{
+ QMutableListIterator<QWeakPointer<Config>> iter(watchedConfigs);
+ while (iter.hasNext()) {
+ KScreen::ConfigPtr config = iter.next().toStrongRef();
+ if (!config) {
+ iter.remove();
+ continue;
+ }
+
+ config->apply(newConfig);
+ iter.setValue(config.toWeakRef());
+ }
+
+ Q_EMIT q->configurationChanged();
+}
+
+void ConfigMonitor::Private::configDestroyed(QObject *removedConfig)
+{
+ for (auto iter = watchedConfigs.begin(); iter != watchedConfigs.end(); ++iter) {
+ if (iter->data() == removedConfig) {
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/src/configmonitor.h
^
|
@@ -1,5 +1,5 @@
/*************************************************************************************
- * Copyright 2012, 2013 Daniel Vrátil <dvratil@redhat.com> *
+ * Copyright 2012 - 2014 Daniel Vrátil <dvratil@redhat.com> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
@@ -25,7 +25,6 @@
#include "config.h"
#include "kscreen_export.h"
-
namespace KScreen
{
@@ -36,11 +35,8 @@
public:
static ConfigMonitor* instance();
- void addConfig(KScreen::Config *config);
- void removeConfig(KScreen::Config *config);
-
-public Q_SLOTS:
- void notifyUpdate();
+ void addConfig(const KScreen::ConfigPtr &config);
+ void removeConfig(const KScreen::ConfigPtr &config);
Q_SIGNALS:
void configurationChanged();
@@ -53,7 +49,7 @@
class Private;
Private * const d;
- Q_PRIVATE_SLOT(d, void _k_configurationDestroyed(QObject *))
+
};
} /* namespace KScreen */
|
[-]
[+]
|
Added |
libkscreen-5.1.90.tar.xz/src/configoperation.cpp
^
|
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2014 Daniel Vratil <dvratil@redhat.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#include "configoperation.h"
+#include "configoperation_p.h"
+#include "backendmanager_p.h"
+
+using namespace KScreen;
+
+ConfigOperationPrivate::ConfigOperationPrivate(ConfigOperation* qq)
+ : QObject(0)
+ , q_ptr(qq)
+{
+}
+
+ConfigOperationPrivate::~ConfigOperationPrivate()
+{
+}
+
+void ConfigOperationPrivate::requestBackend()
+{
+ connect(BackendManager::instance(), &BackendManager::backendReady,
+ this, &ConfigOperationPrivate::backendReady);
+ BackendManager::instance()->requestBackend();
+}
+
+void ConfigOperationPrivate::backendReady(org::kde::kscreen::Backend *backend)
+{
+ Q_UNUSED(backend);
+
+ disconnect(BackendManager::instance(), &BackendManager::backendReady,
+ this, &ConfigOperationPrivate::backendReady);
+}
+
+void ConfigOperationPrivate::doEmitResult()
+{
+ Q_Q(ConfigOperation);
+
+ Q_EMIT q->finished(q);
+ q->deleteLater();
+}
+
+ConfigOperation::ConfigOperation(ConfigOperationPrivate* dd, QObject* parent)
+ : QObject(parent)
+ , d_ptr(dd)
+{
+ const bool ok = QMetaObject::invokeMethod(this, "start", Qt::QueuedConnection);
+ Q_ASSERT(ok);
+ Q_UNUSED(ok);
+}
+
+ConfigOperation::~ConfigOperation()
+{
+ delete d_ptr;
+}
+
+bool ConfigOperation::hasError() const
+{
+ Q_D(const ConfigOperation);
+ return !d->error.isEmpty();
+}
+
+QString ConfigOperation::errorString() const
+{
+ Q_D(const ConfigOperation);
+ return d->error;
+}
+
+void ConfigOperation::setError(const QString& error)
+{
+ Q_D(ConfigOperation);
+ d->error = error;
+}
+
+void ConfigOperation::emitResult()
+{
+ Q_D(ConfigOperation);
+ const bool ok = QMetaObject::invokeMethod(d, "doEmitResult", Qt::QueuedConnection);
+ Q_ASSERT(ok);
+ Q_UNUSED(ok);
+}
+
+bool ConfigOperation::exec()
+{
+ QEventLoop loop;
+ connect(this, &ConfigOperation::finished,
+ [&](ConfigOperation *op) {
+ Q_UNUSED(op);
+ loop.quit();
+ });
+ loop.exec();
+
+ return !hasError();
+}
|
[-]
[+]
|
Added |
libkscreen-5.1.90.tar.xz/src/configoperation.h
^
|
@@ -0,0 +1,61 @@
+/*
+ * <one line to give the library's name and an idea of what it does.>
+ * Copyright (C) 2014 Daniel Vratil <dvratil@redhat.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifndef KSCREEN_CONFIGOPERATION_H
+#define KSCREEN_CONFIGOPERATION_H
+
+#include <QtCore/QObject>
+
+#include "kscreen_export.h"
+
+namespace KScreen {
+
+class ConfigOperationPrivate;
+
+class KSCREEN_EXPORT ConfigOperation : public QObject
+{
+ Q_OBJECT
+
+public:
+ virtual ~ConfigOperation();
+
+ bool hasError() const;
+ QString errorString() const;
+
+ bool exec();
+Q_SIGNALS:
+ void finished(ConfigOperation *operation);
+
+protected:
+ explicit ConfigOperation(ConfigOperationPrivate *dd, QObject *parent = 0);
+
+ void setError(const QString &error);
+ void emitResult();
+
+protected Q_SLOTS:
+ virtual void start() = 0;
+
+protected:
+ ConfigOperationPrivate * const d_ptr;
+ Q_DECLARE_PRIVATE(ConfigOperation);
+};
+}
+
+#endif // KSCREEN_CONFIGOPERATION_H
|
[-]
[+]
|
Added |
libkscreen-5.1.90.tar.xz/src/configoperation_p.h
^
|
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2014 Daniel Vratil <dvratil@redhat.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#include <QObject>
+
+#include "configoperation.h"
+#include "backendinterface.h"
+
+namespace KScreen
+{
+
+class ConfigOperationPrivate : public QObject
+{
+ Q_OBJECT
+
+public:
+ ConfigOperationPrivate(ConfigOperation *qq);
+ virtual ~ConfigOperationPrivate();
+
+ void requestBackend();
+ virtual void backendReady(org::kde::kscreen::Backend *backend);
+
+public Q_SLOTS:
+ void doEmitResult();
+
+private:
+ QString error;
+
+protected:
+ ConfigOperation * const q_ptr;
+ Q_DECLARE_PUBLIC(ConfigOperation)
+
+};
+
+}
|
[-]
[+]
|
Added |
libkscreen-5.1.90.tar.xz/src/configserializer.cpp
^
|
@@ -0,0 +1,317 @@
+/*
+ * Copyright (C) 2014 Daniel Vratil <dvratil@redhat.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#include "configserializer_p.h"
+
+#include "config.h"
+#include "mode.h"
+#include "output.h"
+#include "screen.h"
+#include "edid.h"
+#include "debug_p.h"
+
+#include <QtDBus/QDBusArgument>
+#include <QJsonDocument>
+#include <QFile>
+
+using namespace KScreen;
+
+QJsonObject ConfigSerializer::serializePoint(const QPoint &point)
+{
+ QJsonObject obj;
+ obj[QLatin1String("x")] = point.x();
+ obj[QLatin1String("y")] = point.y();
+ return obj;
+}
+
+QJsonObject ConfigSerializer::serializeSize(const QSize &size)
+{
+ QJsonObject obj;
+ obj[QLatin1String("width")] = size.width();
+ obj[QLatin1String("height")] = size.height();
+ return obj;
+}
+
+QJsonObject ConfigSerializer::serializeConfig(const ConfigPtr &config)
+{
+ QJsonObject obj;
+
+ QJsonArray outputs;
+ Q_FOREACH (const OutputPtr &output, config->outputs()) {
+ outputs.append(serializeOutput(output));
+ }
+ obj[QLatin1String("outputs")] = outputs;
+ if (config->screen()) {
+ obj[QLatin1String("screen")] = serializeScreen(config->screen());
+ }
+
+ return obj;
+}
+
+QJsonObject ConfigSerializer::serializeOutput(const OutputPtr &output)
+{
+ QJsonObject obj;
+
+ obj[QLatin1String("id")] = output->id();
+ obj[QLatin1String("name")] = output->name();
+ obj[QLatin1String("type")] = static_cast<int>(output->type());
+ obj[QLatin1String("icon")] = output->icon();
+ obj[QLatin1String("pos")] = serializePoint(output->pos());
+ obj[QLatin1String("rotation")] = static_cast<int>(output->rotation());
+ obj[QLatin1String("currentModeId")] = output->currentModeId();
+ obj[QLatin1String("preferredModes")] = serializeList(output->preferredModes());
+ obj[QLatin1String("connected")] = output->isConnected();
+ obj[QLatin1String("enabled")] = output->isEnabled();
+ obj[QLatin1String("primary")] = output->isPrimary();
+ obj[QLatin1String("clones")] = serializeList(output->clones());
+ //obj[QLatin1String("edid")] = output->edid()->raw();
+ obj[QLatin1String("sizeMM")] = serializeSize(output->sizeMm());
+
+ QJsonArray modes;
+ Q_FOREACH (const ModePtr &mode, output->modes()) {
+ modes.append(serializeMode(mode));
+ }
+ obj[QLatin1String("modes")] = modes;
+
+ return obj;
+}
+
+QJsonObject ConfigSerializer::serializeMode(const ModePtr &mode)
+{
+ QJsonObject obj;
+
+ obj[QLatin1String("id")] = mode->id();
+ obj[QLatin1String("name")] = mode->name();
+ obj[QLatin1String("size")] = serializeSize(mode->size());
+ obj[QLatin1String("refreshRate")] = mode->refreshRate();
+
+ return obj;
+}
+
+QJsonObject ConfigSerializer::serializeScreen(const ScreenPtr &screen)
+{
+ QJsonObject obj;
+
+ obj[QLatin1String("id")] = screen->id();
+ obj[QLatin1String("currentSize")] = serializeSize(screen->currentSize());
+ obj[QLatin1String("maxSize")] = serializeSize(screen->maxSize());
+ obj[QLatin1String("minSize")] = serializeSize(screen->minSize());
+ obj[QLatin1String("maxActiveOutputsCount")] = screen->maxActiveOutputsCount();
+
+ return obj;
+}
+
+QPoint ConfigSerializer::deserializePoint(const QDBusArgument &arg)
+{
+ int x = 0, y = 0;
+ arg.beginMap();
+ while (!arg.atEnd()) {
+ QString key;
+ QVariant value;
+ arg.beginMapEntry();
+ arg >> key >> value;
+ if (key == QLatin1String("x")) {
+ x = value.toInt();
+ } else if (key == QLatin1String("y")) {
+ y = value.toInt();
+ } else {
+ qCWarning(KSCREEN) << "Invalid key in Point map: " << key;
+ return QPoint();
+ }
+ arg.endMapEntry();
+ }
+ arg.endMap();
+ return QPoint(x, y);
+}
+
+QSize ConfigSerializer::deserializeSize(const QDBusArgument &arg)
+{
+ int w = 0, h = 0;
+ arg.beginMap();
+ while (!arg.atEnd()) {
+ QString key;
+ QVariant value;
+ arg.beginMapEntry();
+ arg >> key >> value;
+ if (key == QLatin1String("width")) {
+ w = value.toInt();
+ } else if (key == QLatin1String("height")) {
+ h = value.toInt();
+ } else {
+ qCWarning(KSCREEN) << "Invalid key in size struct: " << key;
+ return QSize();
+ }
+ arg.endMapEntry();
+ }
+
+ return QSize(w, h);
+}
+
+ConfigPtr ConfigSerializer::deserializeConfig(const QVariantMap &map)
+{
+ ConfigPtr config(new Config);
+
+ if (map.contains(QLatin1String("outputs"))) {
+ const QDBusArgument &outputsArg = map[QLatin1String("outputs")].value<QDBusArgument>();
+ outputsArg.beginArray();
+ OutputList outputs;
+ while (!outputsArg.atEnd()) {
+ QVariant value;
+ outputsArg >> value;
+ const KScreen::OutputPtr output = deserializeOutput(value.value<QDBusArgument>());
+ if (!output) {
+ return ConfigPtr();
+ }
+ outputs.insert(output->id(), output);
+ }
+ outputsArg.endArray();
+ config->setOutputs(outputs);
+ }
+
+ if (map.contains(QLatin1String("screen"))) {
+ const QDBusArgument &screenArg = map[QLatin1String("screen")].value<QDBusArgument>();
+ const KScreen::ScreenPtr screen = deserializeScreen(screenArg);
+ if (!screen) {
+ return ConfigPtr();
+ }
+ config->setScreen(screen);
+ }
+
+ return config;
+}
+
+OutputPtr ConfigSerializer::deserializeOutput(const QDBusArgument &arg)
|
[-]
[+]
|
Added |
libkscreen-5.1.90.tar.xz/src/configserializer_p.h
^
|
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2014 Daniel Vratil <dvratil@redhat.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifndef CONFIGSERIALIZER_H
+#define CONFIGSERIALIZER_H
+
+#include <QJsonObject>
+#include <QJsonArray>
+#include <QVariant>
+#include <QDBusArgument>
+
+#include "types.h"
+#include "kscreen_export.h"
+
+namespace KScreen
+{
+
+namespace ConfigSerializer
+{
+
+KSCREEN_EXPORT QJsonObject serializePoint(const QPoint &point);
+KSCREEN_EXPORT QJsonObject serializeSize(const QSize &size);
+template<typename T>
+KSCREEN_EXPORT QJsonArray serializeList(const QList<T> &list)
+{
+ QJsonArray arr;
+ Q_FOREACH (const T &t, list) {
+ arr.append(t);
+ }
+ return arr;
+}
+
+KSCREEN_EXPORT QJsonObject serializeConfig(const KScreen::ConfigPtr &config);
+KSCREEN_EXPORT QJsonObject serializeOutput(const KScreen::OutputPtr &output);
+KSCREEN_EXPORT QJsonObject serializeMode(const KScreen::ModePtr &mode);
+KSCREEN_EXPORT QJsonObject serializeScreen(const KScreen::ScreenPtr &screen);
+
+KSCREEN_EXPORT QPoint deserializePoint(const QDBusArgument &map);
+KSCREEN_EXPORT QSize deserializeSize(const QDBusArgument &map);
+template<typename T>
+KSCREEN_EXPORT QList<T> deserializeList(const QDBusArgument &arg)
+{
+ QList<T> list;
+ arg.beginArray();
+ while (!arg.atEnd()) {
+ QVariant v;
+ arg >> v;
+ list.append(v.value<T>());
+ }
+ arg.endArray();
+ return list;
+}
+KSCREEN_EXPORT KScreen::ConfigPtr deserializeConfig(const QVariantMap &map);
+KSCREEN_EXPORT KScreen::OutputPtr deserializeOutput(const QDBusArgument &output);
+KSCREEN_EXPORT KScreen::ModePtr deserializeMode(const QDBusArgument &mode);
+KSCREEN_EXPORT KScreen::ScreenPtr deserializeScreen(const QDBusArgument &screen);
+
+}
+
+}
+
+#endif // CONFIGSERIALIZER_H
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/src/edid.cpp
^
|
@@ -1,6 +1,6 @@
/*************************************************************************************
* Copyright (C) 2012 by Daniel Nicoletti <dantti12@gmail.com> *
- * (C) 2012, 2013 by Daniel Vrátil <dvratil@redhat.com> *
+ * (C) 2012 - 2014 by Daniel Vrátil <dvratil@redhat.com> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
@@ -43,8 +43,7 @@
#define PNP_IDS "/usr/share/hwdata/pnp.ids"
-namespace KScreen {
-
+using namespace KScreen;
class Edid::Private
{
@@ -74,7 +73,7 @@
{
}
- bool parse(const quint8 *data, size_t length);
+ bool parse(const QByteArray &data);
int edidGetBit(int in, int bit) const;
int edidGetBits(int in, int begin, int end) const;
double edidDecodeFraction(int high, int low) const;
@@ -103,11 +102,11 @@
{
}
-Edid::Edid(const quint8 *data, size_t length, QObject *parent)
+Edid::Edid(const QByteArray &data, QObject *parent)
: QObject(parent)
, d(new Private())
{
- d->parse(data, length);
+ d->parse(data);
}
Edid::Edid(Edid::Private *dd)
@@ -240,9 +239,11 @@
return d->white;
}
-bool Edid::Private::parse(const quint8 *data, size_t length)
+bool Edid::Private::parse(const QByteArray &rawData)
{
quint32 serial;
+ const quint8 *data = (quint8*) rawData.constData();
+ size_t length = rawData.length();
/* check header */
if (length < 128) {
@@ -416,7 +417,3 @@
return text;
}
-
-} /* namespace KScreen */
-
-#include "edid.moc"
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/src/edid.h
^
|
@@ -50,7 +50,7 @@
public:
explicit Edid();
- explicit Edid(const quint8 *data, size_t length, QObject *parent = 0);
+ explicit Edid(const QByteArray &data, QObject *parent = 0);
virtual ~Edid();
Edid* clone() const;
|
[-]
[+]
|
Added |
libkscreen-5.1.90.tar.xz/src/getconfigoperation.cpp
^
|
@@ -0,0 +1,162 @@
+/*
+ * Copyright (C) 2014 Daniel Vratil <dvratil@redhat.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#include "getconfigoperation.h"
+#include "configoperation_p.h"
+#include "config.h"
+#include "output.h"
+#include "backendmanager_p.h"
+#include "configserializer_p.h"
+#include "backendinterface.h"
+
+using namespace KScreen;
+
+namespace KScreen
+{
+
+class GetConfigOperationPrivate : public ConfigOperationPrivate
+{
+ Q_OBJECT
+
+public:
+ GetConfigOperationPrivate(GetConfigOperation::Options options, GetConfigOperation *qq);
+
+ virtual void backendReady(org::kde::kscreen::Backend* backend);
+ void onConfigReceived(QDBusPendingCallWatcher *watcher);
+ void onEDIDReceived(QDBusPendingCallWatcher *watcher);
+
+public:
+ GetConfigOperation::Options options;
+ ConfigPtr config;
+ int pendingEDIDs;
+
+private:
+ Q_DECLARE_PUBLIC(GetConfigOperation)
+};
+
+}
+
+GetConfigOperationPrivate::GetConfigOperationPrivate(GetConfigOperation::Options options, GetConfigOperation* qq)
+ : ConfigOperationPrivate(qq)
+ , options(options)
+{
+}
+
+void GetConfigOperationPrivate::backendReady(org::kde::kscreen::Backend* backend)
+{
+ ConfigOperationPrivate::backendReady(backend);
+
+ Q_Q(GetConfigOperation);
+
+ if (!backend) {
+ q->setError(tr("Failed to prepare backend"));
+ q->emitResult();
+ return;
+ }
+
+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(backend->getConfig(), this);
+ watcher->setProperty("backend", QVariant::fromValue(backend));
+ connect(watcher, &QDBusPendingCallWatcher::finished,
+ this, &GetConfigOperationPrivate::onConfigReceived);
+}
+
+void GetConfigOperationPrivate::onConfigReceived(QDBusPendingCallWatcher *watcher)
+{
+ Q_Q(GetConfigOperation);
+
+ QDBusPendingReply<QVariantMap> reply = *watcher;
+ watcher->deleteLater();
+ if (reply.isError()) {
+ q->setError(reply.error().message());
+ q->emitResult();
+ return;
+ }
+
+ config = ConfigSerializer::deserializeConfig(reply.value());
+ if (!config) {
+ q->setError(tr("Failed to deserialize backend response"));
+ q->emitResult();
+ return;
+ }
+
+ if (options & GetConfigOperation::NoEDID || config->outputs().isEmpty()) {
+ q->emitResult();
+ return;
+ }
+
+ pendingEDIDs = 0;
+ org::kde::kscreen::Backend *backend = watcher->property("backend").value<org::kde::kscreen::Backend*>();
+ Q_FOREACH (const OutputPtr &output, config->outputs()) {
+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(backend->getEdid(output->id()), this);
+ watcher->setProperty("outputId", output->id());
+ connect(watcher, &QDBusPendingCallWatcher::finished,
+ this, &GetConfigOperationPrivate::onEDIDReceived);
+ ++pendingEDIDs;
+ }
+}
+
+void GetConfigOperationPrivate::onEDIDReceived(QDBusPendingCallWatcher* watcher)
+{
+ Q_Q(GetConfigOperation);
+
+ QDBusPendingReply<QByteArray> reply = *watcher;
+ watcher->deleteLater();
+ if (reply.isError()) {
+ q->setError(reply.error().message());
+ q->emitResult();
+ return;
+ }
+
+ const QByteArray edidData = reply.value();
+ const int outputId = watcher->property("outputId").toInt();
+
+ OutputList outputs = config->outputs();
+ outputs[outputId]->setEdid(edidData);
+ config->setOutputs(outputs);
+
+ if (--pendingEDIDs == 0) {
+ q->emitResult();
+ }
+}
+
+
+
+GetConfigOperation::GetConfigOperation(Options options, QObject* parent)
+ : ConfigOperation(new GetConfigOperationPrivate(options, this), parent)
+{
+}
+
+GetConfigOperation::~GetConfigOperation()
+{
+}
+
+KScreen::ConfigPtr GetConfigOperation::config() const
+{
+ Q_D(const GetConfigOperation);
+ return d->config;
+}
+
+void GetConfigOperation::start()
+{
+ Q_D(GetConfigOperation);
+ d->requestBackend();
+}
+
+
+#include "getconfigoperation.moc"
|
[-]
[+]
|
Added |
libkscreen-5.1.90.tar.xz/src/getconfigoperation.h
^
|
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2014 Daniel Vratil <dvratil@redhat.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifndef KSCREEN_GETCONFIGOPERATION_H
+#define KSCREEN_GETCONFIGOPERATION_H
+
+#include "configoperation.h"
+#include "types.h"
+#include "kscreen_export.h"
+
+class QDBusPendingCallWatcher;
+class OrgKdeKscreenBackend;
+
+namespace KScreen {
+
+class GetConfigOperationPrivate;
+
+class KSCREEN_EXPORT GetConfigOperation : public KScreen::ConfigOperation
+{
+ Q_OBJECT
+
+public:
+ enum Option {
+ NoOptions,
+ NoEDID
+ };
+ Q_DECLARE_FLAGS(Options, Option)
+
+ explicit GetConfigOperation(Options options = NoOptions, QObject* parent = 0);
+ ~GetConfigOperation();
+
+ KScreen::ConfigPtr config() const;
+
+protected:
+ void start();
+
+private:
+ Q_DECLARE_PRIVATE(GetConfigOperation)
+};
+}
+
+#endif // KSCREEN_GETCONFIGOPERATION_H
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/src/mode.cpp
^
|
@@ -1,5 +1,6 @@
/*************************************************************************************
* Copyright (C) 2012 by Alejandro Fiestas Olivares <afiestas@kde.org> *
+ * Copyright (C) 2014 by Daniel Vrátil <dvratil@redhat.com> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
@@ -18,8 +19,7 @@
#include "mode.h"
-namespace KScreen {
-
+using namespace KScreen;
class Mode::Private
{
public:
@@ -41,8 +41,8 @@
float rate;
};
-Mode::Mode(QObject *parent)
- : QObject(parent)
+Mode::Mode()
+ : QObject(0)
, d(new Private())
{
@@ -59,9 +59,9 @@
delete d;
}
-Mode *Mode::clone() const
+ModePtr Mode::clone() const
{
- return new Mode(new Private(*d));
+ return ModePtr(new Mode(new Private(*d)));
}
const QString Mode::id() const
@@ -129,13 +129,13 @@
Q_EMIT modeChanged();
}
-} //KScreen namespace
-QDebug operator<<(QDebug dbg, const KScreen::Mode *mode)
+QDebug operator<<(QDebug dbg, const KScreen::ModePtr &mode)
{
- dbg << "KScreen::Mode(Id:" << mode->id() << ", Size:" << mode->size() << ")";
+ if (mode) {
+ dbg << "KScreen::Mode(Id:" << mode->id() << ", Size:" << mode->size() << ")";
+ } else {
+ dbg << "KScreen::Mode(NULL)";
+ }
return dbg;
}
-
-
-#include "mode.moc"
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/src/mode.h
^
|
@@ -1,5 +1,6 @@
/*************************************************************************************
* Copyright (C) 2012 by Alejandro Fiestas Olivares <afiestas@kde.org> *
+ * Copyright (C) 2014 by Daniel Vrátil <dvratil@redhat.com> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
@@ -20,12 +21,12 @@
#define MODE_CONFIG_H
#include "kscreen_export.h"
+#include "types.h"
-#include <QtCore/QSize>
-#include <QtCore/QHash>
-#include <QtCore/QObject>
-#include <QtCore/QMetaType>
-#include <QtCore/QDebug>
+#include <QObject>
+#include <QSize>
+#include <QMetaType>
+#include <QDebug>
namespace KScreen {
@@ -38,10 +39,10 @@
Q_PROPERTY(float refreshRate READ refreshRate WRITE setRefreshRate NOTIFY modeChanged)
public:
- explicit Mode(QObject *parent = 0);
+ explicit Mode();
virtual ~Mode();
- Mode* clone() const;
+ ModePtr clone() const;
const QString id() const;
void setId(const QString &id);
@@ -59,17 +60,17 @@
void modeChanged();
private:
+ Q_DISABLE_COPY(Mode)
+
class Private;
Private * const d;
Mode(Private *dd);
};
-typedef QHash<QString, Mode*> ModeList;
-
} //KSCreen namespace
-KSCREEN_EXPORT QDebug operator<<(QDebug dbg, const KScreen::Mode *mode);
+KSCREEN_EXPORT QDebug operator<<(QDebug dbg, const KScreen::ModePtr &mode);
Q_DECLARE_METATYPE(KScreen::ModeList)
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/src/output.cpp
^
|
@@ -1,5 +1,6 @@
/*************************************************************************************
* Copyright (C) 2012 by Alejandro Fiestas Olivares <afiestas@kde.org> *
+ * Copyright (C) 2014 by Daniel Vrátil <dvratil@redhat.com> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
@@ -19,13 +20,15 @@
#include "output.h"
#include "mode.h"
#include "edid.h"
-#include "backendloader.h"
-#include <backends/abstractbackend.h>
+#include "abstractbackend.h"
+#include "backendmanager_p.h"
+#include "debug_p.h"
-#include <QtCore/QStringList>
+#include <QStringList>
+#include <QPointer>
#include <QRect>
-namespace KScreen {
+using namespace KScreen;
class Output::Private
{
@@ -57,7 +60,7 @@
enabled(other.enabled),
primary(other.primary)
{
- Q_FOREACH (Mode *otherMode, other.modeList) {
+ Q_FOREACH (const ModePtr &otherMode, other.modeList) {
modeList.insert(otherMode->id(), otherMode->clone());
}
if (other.edid) {
@@ -90,8 +93,8 @@
QString Output::Private::biggestMode(const ModeList& modes) const
{
int area, total = 0;
- KScreen::Mode* biggest = 0;
- Q_FOREACH(KScreen::Mode* mode, modes) {
+ KScreen::ModePtr biggest;
+ Q_FOREACH(const KScreen::ModePtr &mode, modes) {
area = mode->size().width() * mode->size().height();
if (area < total) {
continue;
@@ -115,8 +118,8 @@
return biggest->id();
}
-Output::Output(QObject *parent)
- : QObject(parent)
+Output::Output()
+ : QObject(0)
, d(new Private())
{
@@ -133,18 +136,9 @@
delete d;
}
-Output *Output::clone() const
+OutputPtr Output::clone() const
{
- Output *output = new Output(new Private(*d));
- // Make sure the new output takes ownership of the cloned modes
- Q_FOREACH (Mode *mode, output->d->modeList) {
- mode->setParent(output);
- }
- if (output->d->edid) {
- output->d->edid->setParent(output);
- }
-
- return output;
+ return OutputPtr(new Output(new Private(*d)));
}
int Output::id() const
@@ -211,25 +205,22 @@
Q_EMIT outputChanged();
}
-Mode* Output::mode(const QString& id) const
+ModePtr Output::mode(const QString& id) const
{
if (!d->modeList.contains(id)) {
- return 0;
+ return ModePtr();
}
return d->modeList[id];
}
-QHash< QString, Mode* > Output::modes() const
+ModeList Output::modes() const
{
return d->modeList;
}
-void Output::setModes(ModeList modes)
+void Output::setModes(const ModeList &modes)
{
- if (!d->modeList.isEmpty()) {
- qDeleteAll(d->modeList);
- }
d->modeList = modes;
}
@@ -249,7 +240,7 @@
Q_EMIT currentModeIdChanged();
}
-Mode *Output::currentMode() const
+ModePtr Output::currentMode() const
{
return d->modeList.value(d->currentMode);
}
@@ -275,8 +266,8 @@
}
int area, total = 0;
- KScreen::Mode* biggest = 0;
- KScreen::Mode* candidateMode = 0;
+ KScreen::ModePtr biggest;
+ KScreen::ModePtr candidateMode;
Q_FOREACH(const QString &modeId, d->preferredModes) {
candidateMode = mode(modeId);
area = candidateMode->size().width() * candidateMode->size().height();
@@ -301,7 +292,7 @@
return d->preferredMode;
}
-Mode* Output::preferredMode() const
+ModePtr Output::preferredMode() const
{
return d->modeList.value(preferredModeId());
}
@@ -402,13 +393,15 @@
Q_EMIT clonesChanged();
}
-Edid *Output::edid() const
+void Output::setEdid(const QByteArray& rawData)
{
- if (d->edid == 0) {
- AbstractBackend *backend = BackendLoader::backend();
- d->edid = backend->edid(d->id);
- }
+ Q_ASSERT(d->edid == 0);
+
+ d->edid = new Edid(rawData);
+}
+Edid *Output::edid() const
+{
return d->edid;
}
@@ -424,12 +417,88 @@
QRect Output::geometry() const
{
+ if (!currentMode()) {
+ return QRect();
+ }
+
return QRect(pos(), currentMode()->size());
}
-} //KScreen namespace
+void Output::apply(const OutputPtr& other)
+{
+ typedef void (KScreen::Output::*ChangeSignal)();
+ QList<ChangeSignal> changes;
-QDebug operator<<(QDebug dbg, const KScreen::Output *output)
+ // We block all signals, and emit them only after we have set up everything
+ // This is necessary in order to prevent clients from accessig inconsistent
+ // outputs from intermediate change signals
+ const bool keepBlocked = signalsBlocked();
+ blockSignals(true);
+ if (d->name != other->d->name) {
+ changes << &Output::outputChanged;
+ setName(other->d->name);
+ }
+ if (d->type != other->d->type) {
+ changes << &Output::outputChanged;
+ setType(other->d->type);
+ }
+ if (d->icon != other->d->icon) {
+ changes << &Output::outputChanged;
+ setIcon(other->d->icon);
+ }
+ if (d->pos != other->d->pos) {
+ changes << &Output::posChanged;
+ setPos(other->pos());
+ }
+ if (d->rotation != other->d->rotation) {
+ changes << &Output::rotationChanged;
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/src/output.h
^
|
@@ -1,5 +1,6 @@
/*************************************************************************************
* Copyright (C) 2012 by Alejandro Fiestas Olivares <afiestas@kde.org> *
+ * Copyright (C) 2014 by Daniel Vrátil <dvratil@redhat.com> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
@@ -20,15 +21,15 @@
#define OUTPUT_CONFIG_H
#include "mode.h"
+#include "types.h"
#include "kscreen_export.h"
-#include <QtCore/QSize>
-#include <QtCore/QPoint>
-#include <QtCore/QObject>
-#include <QtCore/QMetaType>
-#include <QtCore/QPointer>
-#include <QtCore/QStringList>
-#include <QtCore/QDebug>
+#include <QObject>
+#include <QSize>
+#include <QPoint>
+#include <QMetaType>
+#include <QStringList>
+#include <QDebug>
namespace KScreen {
@@ -41,7 +42,7 @@
public:
Q_ENUMS(Rotation)
Q_ENUMS(Type)
- Q_PROPERTY(int id READ id WRITE setId NOTIFY outputChanged)
+ Q_PROPERTY(int id READ id CONSTANT)
Q_PROPERTY(QString name READ name WRITE setName NOTIFY outputChanged)
Q_PROPERTY(Type type READ type WRITE setType NOTIFY outputChanged)
Q_PROPERTY(QString icon READ icon WRITE setIcon NOTIFY outputChanged)
@@ -82,10 +83,10 @@
Right = 8
};
- explicit Output(QObject *parent = 0);
+ explicit Output();
virtual ~Output();
- Output* clone() const;
+ OutputPtr clone() const;
int id() const;
void setId(int id);
@@ -99,13 +100,13 @@
QString icon() const;
void setIcon(const QString& icon);
- Q_INVOKABLE Mode* mode(const QString &id) const;
- QHash<QString, Mode*> modes() const;
- void setModes(ModeList modes);
+ Q_INVOKABLE ModePtr mode(const QString &id) const;
+ ModeList modes() const;
+ void setModes(const ModeList &modes);
QString currentModeId() const;
void setCurrentModeId(const QString& mode);
- Q_INVOKABLE Mode* currentMode() const;
+ Q_INVOKABLE ModePtr currentMode() const;
void setPreferredModes(const QStringList &modes);
QStringList preferredModes() const;
@@ -116,7 +117,7 @@
/**
* Returns KScreen::Mode associated with preferredModeId()
*/
- Q_INVOKABLE Mode* preferredMode() const;
+ Q_INVOKABLE ModePtr preferredMode() const;
QPoint pos() const;
void setPos(const QPoint& pos);
@@ -143,6 +144,7 @@
QList<int> clones() const;
void setClones(QList<int> outputlist);
+ void setEdid(const QByteArray &rawData);
Edid* edid() const;
QSize sizeMm() const;
@@ -153,6 +155,7 @@
*/
QRect geometry() const;
+ void apply(const OutputPtr &other);
Q_SIGNALS:
void outputChanged();
void posChanged();
@@ -173,11 +176,9 @@
};
-typedef QHash<int, Output*> OutputList;
-
} //KScreen namespace
-KSCREEN_EXPORT QDebug operator<<(QDebug dbg, const KScreen::Output *output);
+KSCREEN_EXPORT QDebug operator<<(QDebug dbg, const KScreen::OutputPtr &output);
Q_DECLARE_METATYPE(KScreen::OutputList)
Q_DECLARE_METATYPE(KScreen::Output::Rotation)
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/src/screen.cpp
^
|
@@ -1,5 +1,6 @@
/*************************************************************************************
* Copyright (C) 2012 by Alejandro Fiestas Olivares <afiestas@kde.org> *
+ * Copyright (C) 2014 by Daniel Vrátil <dvratil@redhat.com> *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
@@ -18,7 +19,7 @@
#include "screen.h"
-namespace KScreen {
+using namespace KScreen;
class Screen::Private
{
@@ -44,8 +45,8 @@
QSize maxSize;
};
-Screen::Screen(QObject *parent)
- : QObject(parent)
+Screen::Screen()
+ : QObject(0)
, d(new Private())
{
}
@@ -62,9 +63,9 @@
delete d;
}
-Screen *Screen::clone() const
+ScreenPtr Screen::clone() const
{
- return new Screen(new Private(*d));
+ return ScreenPtr(new Screen(new Private(*d)));
}
@@ -124,6 +125,8 @@
d->maxActiveOutputsCount = maxActiveOutputsCount;
}
-} //KScreen namespace
-
-#include "screen.moc"
+void Screen::apply(const ScreenPtr &other)
+{
+ // Only set values that can change
+ setMaxActiveOutputsCount(other->d->maxActiveOutputsCount);
+}
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/src/screen.h
^
|
@@ -19,10 +19,11 @@
#ifndef SCREEN_CONFIG_H
#define SCREEN_CONFIG_H
+#include "types.h"
#include "kscreen_export.h"
-#include <QtCore/QSize>
-#include <QtCore/QObject>
+#include <QSize>
+#include <QObject>
namespace KScreen {
@@ -37,10 +38,10 @@
Q_PROPERTY(QSize maxSize READ maxSize CONSTANT)
Q_PROPERTY(int maxActiveOutputsCount READ maxActiveOutputsCount CONSTANT)
- explicit Screen(QObject *parent = 0);
+ explicit Screen();
virtual ~Screen();
- Screen* clone() const;
+ ScreenPtr clone() const;
int id() const;
void setId(int id);
@@ -57,6 +58,8 @@
int maxActiveOutputsCount() const;
void setMaxActiveOutputsCount(int maxActiveOutputsCount);
+ void apply(const ScreenPtr &other);
+
Q_SIGNALS:
void currentSizeChanged();
|
[-]
[+]
|
Added |
libkscreen-5.1.90.tar.xz/src/setconfigoperation.cpp
^
|
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2014 Daniel Vratil <dvratil@redhat.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#include "setconfigoperation.h"
+#include "configoperation_p.h"
+#include "config.h"
+#include "configserializer_p.h"
+
+#include <QDBusPendingCallWatcher>
+#include <QDBusPendingCall>
+
+using namespace KScreen;
+
+namespace KScreen
+{
+
+class SetConfigOperationPrivate : public ConfigOperationPrivate
+{
+ Q_OBJECT
+
+public:
+ explicit SetConfigOperationPrivate(const KScreen::ConfigPtr &config, ConfigOperation* qq);
+
+ void backendReady(org::kde::kscreen::Backend* backend);
+ void onConfigSet(QDBusPendingCallWatcher *watcher);
+
+ KScreen::ConfigPtr config;
+
+private:
+ Q_DECLARE_PUBLIC(SetConfigOperation)
+};
+
+}
+
+SetConfigOperationPrivate::SetConfigOperationPrivate(const ConfigPtr &config, ConfigOperation* qq)
+ : ConfigOperationPrivate(qq)
+ , config(config)
+{
+}
+
+void SetConfigOperationPrivate::backendReady(org::kde::kscreen::Backend* backend)
+{
+ ConfigOperationPrivate::backendReady(backend);
+
+ Q_Q(SetConfigOperation);
+
+ if (!backend) {
+ q->setError(tr("Failed to prepare backend"));
+ q->emitResult();
+ return;
+ }
+
+ const QVariantMap map = ConfigSerializer::serializeConfig(config).toVariantMap();
+ if (map.isEmpty()) {
+ q->setError(tr("Failed to serialize request"));
+ q->emitResult();
+ return;
+ }
+
+ QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(backend->setConfig(map), this);
+ connect(watcher, &QDBusPendingCallWatcher::finished,
+ this, &SetConfigOperationPrivate::onConfigSet);
+}
+
+void SetConfigOperationPrivate::onConfigSet(QDBusPendingCallWatcher *watcher)
+{
+ Q_Q(SetConfigOperation);
+
+ QDBusPendingReply<QVariantMap> reply = *watcher;
+ watcher->deleteLater();
+
+ if (reply.isError()) {
+ q->setError(reply.error().message());
+ q->emitResult();
+ return;
+ }
+
+ config = ConfigSerializer::deserializeConfig(reply.value());
+ if (!config) {
+ q->setError(tr("Failed to deserialize backend response"));
+ }
+
+ q->emitResult();
+}
+
+
+SetConfigOperation::SetConfigOperation(const ConfigPtr &config, QObject* parent)
+ : ConfigOperation(new SetConfigOperationPrivate(config, this), parent)
+{
+}
+
+SetConfigOperation::~SetConfigOperation()
+{
+}
+
+ConfigPtr SetConfigOperation::config() const
+{
+ Q_D(const SetConfigOperation);
+ return d->config;
+}
+
+
+void SetConfigOperation::start()
+{
+ Q_D(SetConfigOperation);
+ d->requestBackend();
+}
+
+#include "setconfigoperation.moc"
|
[-]
[+]
|
Added |
libkscreen-5.1.90.tar.xz/src/setconfigoperation.h
^
|
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2014 Daniel Vratil <dvratil@redhat.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifndef KSCREEN_SETCONFIGOPERATION_H
+#define KSCREEN_SETCONFIGOPERATION_H
+
+#include "configoperation.h"
+#include "types.h"
+#include "kscreen_export.h"
+
+namespace KScreen {
+
+class SetConfigOperationPrivate;
+
+class KSCREEN_EXPORT SetConfigOperation : public KScreen::ConfigOperation
+{
+ Q_OBJECT
+public:
+ explicit SetConfigOperation(const KScreen::ConfigPtr &config, QObject* parent = 0);
+ ~SetConfigOperation();
+
+ KScreen::ConfigPtr config() const;
+
+protected:
+ void start();
+
+private:
+ Q_DECLARE_PRIVATE(SetConfigOperation)
+};
+
+}
+
+#endif // KSCREEN_SETCONFIGOPERATION_H
|
[-]
[+]
|
Added |
libkscreen-5.1.90.tar.xz/src/types.h
^
|
@@ -0,0 +1,42 @@
+/*************************************************************************************
+ * Copyright 2014 Daniel Vrátil <dvratil@redhat.com> *
+ * *
+ * This library is free software; you can redistribute it and/or *
+ * modify it under the terms of the GNU Lesser General Public *
+ * License as published by the Free Software Foundation; either *
+ * version 2.1 of the License, or (at your option) any later version. *
+ * *
+ * This library 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 *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this library; if not, write to the Free Software *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
+ *************************************************************************************/
+
+#ifndef KSCREEN_TYPES_H
+#define KSCREEN_TYPES_H
+
+#include <QSharedPointer>
+#include <QMap>
+
+namespace KScreen
+{
+
+class Config;
+typedef QSharedPointer<Config> ConfigPtr;
+class Screen;
+typedef QSharedPointer<Screen> ScreenPtr;
+class Output;
+typedef QSharedPointer<Output> OutputPtr;
+typedef QMap<int, OutputPtr> OutputList;
+
+class Mode;
+typedef QSharedPointer<Mode> ModePtr;
+typedef QMap<QString, ModePtr> ModeList;
+
+}
+
+#endif
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/tests/testplugandplay.cpp
^
|
@@ -27,8 +27,6 @@
{
QGuiApplication app(argc, argv);
- new TestPnp();
-
QCommandLineOption input = QCommandLineOption(QStringList() << QStringLiteral("m") << "monitor",
QStringLiteral("Keep running monitoring for changes"));
QCommandLineParser parser;
@@ -36,10 +34,6 @@
parser.addOption(input);
parser.process(app);
- if (parser.isSet(input)) {
- return app.exec();
- } else {
- return 0;
- }
-
-}
\ No newline at end of file
+ new TestPnp(parser.isSet(input));
+ return app.exec();
+}
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/tests/testpnp.cpp
^
|
@@ -24,6 +24,8 @@
#include "../src/edid.h"
#include "../src/mode.h"
#include "../src/output.h"
+#include "../src/screen.h"
+#include "../src/getconfigoperation.h"
#include <QGuiApplication>
#include <QRect>
@@ -69,11 +71,11 @@
};
}
-TestPnp::TestPnp(QObject *parent)
+TestPnp::TestPnp(bool monitor, QObject *parent)
: QObject(parent)
+ , m_monitor(monitor)
{
init();
- print();
}
TestPnp::~TestPnp()
@@ -82,17 +84,30 @@
void TestPnp::init()
{
- m_config = KScreen::Config::current();
+ connect(new KScreen::GetConfigOperation(), &KScreen::GetConfigOperation::finished,
+ this, &TestPnp::configReady);
+}
+
+void TestPnp::configReady(KScreen::ConfigOperation *op)
+{
+ m_config = qobject_cast<KScreen::GetConfigOperation*>(op)->config();
if (!m_config) {
qDebug() << "Config is invalid, probably backend couldn't load";
qApp->quit();
+ return;
}
if (!m_config->screen()) {
qDebug() << "No screen in the configuration, broken backend";
qApp->quit();
+ return;
}
- ConfigMonitor::instance()->addConfig(m_config);
+ print();
+ if (m_monitor) {
+ ConfigMonitor::instance()->addConfig(m_config);
+ } else {
+ qApp->quit();
+ }
}
void TestPnp::print()
@@ -102,8 +117,8 @@
qDebug() << "\tminSize:" << m_config->screen()->minSize();
qDebug() << "\tcurrentSize:" << m_config->screen()->currentSize();
- OutputList outputs = m_config->outputs();
- Q_FOREACH(Output *output, outputs) {
+ const OutputList outputs = m_config->outputs();
+ Q_FOREACH(const OutputPtr &output, outputs) {
qDebug() << "\n-----------------------------------------------------\n";
qDebug() << "Id: " << output->id();
qDebug() << "Name: " << output->name();
@@ -130,12 +145,12 @@
qDebug() << "Preferred modes: " << output->preferredModes();
qDebug() << "Modes: ";
- ModeList modes = output->modes();
- Q_FOREACH(Mode* mode, modes) {
+ const ModeList modes = output->modes();
+ Q_FOREACH(const ModePtr &mode, modes) {
qDebug() << "\t" << mode->id() << " " << mode->name() << " " << mode->size() << " " << mode->refreshRate();
}
- Edid* edid = output->edid();
+ const Edid * const edid = output->edid();
qDebug() << "EDID Info: ";
if (edid && edid->isValid()) {
qDebug() << "\tDevice ID: " << edid->deviceId();
@@ -156,7 +171,3 @@
}
}
}
-
-
-#include "testpnp.moc"
-
|
[-]
[+]
|
Changed |
libkscreen-5.1.90.tar.xz/tests/testpnp.h
^
|
@@ -28,21 +28,24 @@
{
class Output;
class QScreenOutput;
+class ConfigOperation;
class TestPnp : public QObject
{
Q_OBJECT
public:
- explicit TestPnp(QObject *parent = 0);
+ explicit TestPnp(bool monitor, QObject *parent = 0);
virtual ~TestPnp();
private Q_SLOTS:
void init();
+ void configReady(KScreen::ConfigOperation *op);
void print();
private:
- Config *m_config;
+ ConfigPtr m_config;
+ bool m_monitor;
};
} // namespace
|
[-]
[+]
|
Changed |
libkscreen.yaml
^
|
@@ -1,6 +1,6 @@
Name : libkscreen
-Version : 5.0.95
-Release : 1
+Version : 5.1.90
+Release : 8
Group : System/Base
License : LGPLv2.1+
Summary : API to control screen settings
@@ -47,6 +47,7 @@
- "%doc COPYING COPYING.LIB"
- "%{_kf5_libdir}/libKF5Screen.so.*"
- "%{_kf5_plugindir}/*"
+ - "%{_kf5_libdir}/libexec/kf5/kscreen_backend_launcher"
SubPackages:
- Name: devel
|