diff --git a/backends/kwayland/waylandconfig.h b/backends/kwayland/waylandconfig.h index eb9e868..50be411 100644 --- a/backends/kwayland/waylandconfig.h +++ b/backends/kwayland/waylandconfig.h @@ -1,122 +1,121 @@ /************************************************************************************* * Copyright 2014-2015 Sebastian Kügler * * * * 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_WAYLAND_CONFIG_H #define KSCREEN_WAYLAND_CONFIG_H #include "abstractbackend.h" #include "config.h" #include #include #include #include #include #include #include namespace KWayland { namespace Client { class ConnectionThread; class EventQueue; - class OutputDevice; class Registry; class OutputManagement; } } namespace KScreen { class Output; class WaylandOutput; class WaylandScreen; /** * @class WaylandConfig * * This class holds the basic skeleton of the configuration and takes care of * fetching the information from the Wayland server and synchronizing the * configuration out to the "clients" that receive the config from the backend. * We initialize a wayland connection, using a threaded event queue when * querying the wayland server for data. * Initially, the creation of a WaylandConfig blocks until all data has been * received, signalled by the initialized() signal. This means that the * wayland client has received information about all interfaces, and that all * outputs are completely initialized. From then on, we properly notifyUpdate(). */ class WaylandConfig : public QObject { Q_OBJECT public: explicit WaylandConfig(QObject *parent = nullptr); ~WaylandConfig() override; KScreen::ConfigPtr toKScreenConfig(); void updateKScreenConfig(KScreen::ConfigPtr &config) const; QMap outputMap() const; void addOutput(quint32 name, quint32 version); void removeOutput(quint32 name); void applyConfig(const KScreen::ConfigPtr &newConfig); Q_SIGNALS: void configChanged(const KScreen::ConfigPtr &config); void initialized(); void gone(); private Q_SLOTS: void setupRegistry(); void checkInitialized(); void disconnected(); private: void initConnection(); void blockSignals(); void unblockSignals(); void tryPendingConfig(); KWayland::Client::ConnectionThread *m_connection; KWayland::Client::EventQueue *m_queue; QThread *m_thread; KWayland::Client::Registry *m_registry; KWayland::Client::OutputManagement *m_outputManagement; QMap m_outputMap; // Map between kwayland's outputdevice names and kscreen output ids // key: wayland's name, value: kscreen id QMap m_outputIds; QList m_initializingOutputs; bool m_registryInitialized; int m_lastOutputId = -1; bool m_blockSignals; QEventLoop m_syncLoop; int m_newOutputId; KScreen::ConfigPtr m_kscreenConfig; KScreen::ConfigPtr m_kscreenPendingConfig; WaylandScreen *m_screen; }; } // namespace #endif // KSCREEN_WAYLAND_CONFIG_H diff --git a/backends/qscreen/qscreenbackend.h b/backends/qscreen/qscreenbackend.h index 18f1fec..49a948c 100644 --- a/backends/qscreen/qscreenbackend.h +++ b/backends/qscreen/qscreenbackend.h @@ -1,56 +1,55 @@ /************************************************************************************* * Copyright (C) 2012 by Alejandro Fiestas Olivares * * Copyright (C) 2012, 2013 by Daniel Vrátil * * Copyright 2014 Sebastian Kügler * * * * 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 QSCREEN_BACKEND_H #define QSCREEN_BACKEND_H #include "abstractbackend.h" #include namespace KScreen { -class Output; class QScreenConfig; class QScreenBackend : public KScreen::AbstractBackend { Q_OBJECT Q_PLUGIN_METADATA(IID "org.kf5.kscreen.backends.qscreen") public: explicit QScreenBackend(); ~QScreenBackend() override; QString name() const override; QString serviceName() const override; KScreen::ConfigPtr config() const override; void setConfig(const KScreen::ConfigPtr &config) override; bool isValid() const override; private: bool m_isValid; static KScreen::QScreenConfig *s_internalConfig; }; } // namespace Q_DECLARE_LOGGING_CATEGORY(KSCREEN_QSCREEN) #endif //QSCREEN_BACKEND_H diff --git a/backends/qscreen/qscreenscreen.h b/backends/qscreen/qscreenscreen.h index 38dd54b..b1aaf72 100644 --- a/backends/qscreen/qscreenscreen.h +++ b/backends/qscreen/qscreenscreen.h @@ -1,48 +1,47 @@ /************************************************************************************* * Copyright 2014 Sebastian Kügler * * * * 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 QSCREEN_SCREEN_H #define QSCREEN_SCREEN_H #include "config.h" #include "screen.h" #include #include #include namespace KScreen { class Output; -class QScreenOutput; class QScreenScreen : public QObject { Q_OBJECT public: explicit QScreenScreen(QScreenConfig *config); ~QScreenScreen() override; KScreen::ScreenPtr toKScreenScreen() const; void updateKScreenScreen(KScreen::ScreenPtr &screen) const; }; } // namespace #endif // QSCREEN_SCREEN_H diff --git a/backends/xrandr/xrandr.h b/backends/xrandr/xrandr.h index 213f541..8d19e80 100644 --- a/backends/xrandr/xrandr.h +++ b/backends/xrandr/xrandr.h @@ -1,96 +1,95 @@ /************************************************************************************* * Copyright (C) 2012 by Alejandro Fiestas Olivares * * Copyright (C) 2012, 2013 by Daniel Vrátil * * * * 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 XRANDR_BACKEND_H #define XRANDR_BACKEND_H #include "abstractbackend.h" #include #include #include "../xcbwrapper.h" class QRect; class QTimer; class XCBEventListener; class XRandRConfig; namespace KScreen { - class Output; } class XRandR : public KScreen::AbstractBackend { Q_OBJECT Q_PLUGIN_METADATA(IID "org.kf5.kscreen.backends.xrandr") public: explicit XRandR(); ~XRandR() override; QString name() const override; QString serviceName() const override; KScreen::ConfigPtr config() const override; void setConfig(const KScreen::ConfigPtr &config) override; bool isValid() const override; QByteArray edid(int outputId) const override; static QByteArray outputEdid(xcb_randr_output_t outputId); static xcb_randr_get_screen_resources_reply_t* screenResources(); static xcb_screen_t* screen(); static xcb_window_t rootWindow(); static bool hasProperty(xcb_randr_output_t outputId, const QByteArray &name); private Q_SLOTS: void outputChanged(xcb_randr_output_t output, xcb_randr_crtc_t crtc, xcb_randr_mode_t mode, xcb_randr_connection_t connection); void crtcChanged(xcb_randr_crtc_t crtc, xcb_randr_mode_t mode, xcb_randr_rotation_t rotation, const QRect &geom); void screenChanged(xcb_randr_rotation_t rotation, const QSize &sizePx, const QSize &sizeMm); private: static quint8* getXProperty(xcb_randr_output_t output, xcb_atom_t atom, size_t &len); static xcb_screen_t *s_screen; static xcb_window_t s_rootWindow; static XRandRConfig *s_internalConfig; static int s_randrBase; static int s_randrError; static bool s_monitorInitialized; static bool s_has_1_3; static bool s_xorgCacheInitialized; XCBEventListener *m_x11Helper; bool m_isValid; QTimer *m_configChangeCompressor; }; Q_DECLARE_LOGGING_CATEGORY(KSCREEN_XRANDR) #endif //XRandR_BACKEND_H diff --git a/src/abstractbackend.h b/src/abstractbackend.h index 2693968..0f27a31 100644 --- a/src/abstractbackend.h +++ b/src/abstractbackend.h @@ -1,115 +1,114 @@ /************************************************************************************* * Copyright (C) 2012 by Alejandro Fiestas Olivares * * Copyright (C) 2014 by Daniel Vrátil * * * * 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 #include namespace KScreen { class Config; - class Edid; /** * Abstract class for backends. */ class KSCREEN_EXPORT AbstractBackend : public QObject { Q_OBJECT public: ~AbstractBackend() override {} /** * This is where the backend should perform all initialization. This method * is always called right after the backend is created. * * Default implementation does nothing. * * @p arguments Optional arguments passed by caller. Used mostly for unit-testing. */ virtual void init(const QVariantMap &arguments); /** * Returns a user-friendly name of the backend. */ virtual QString name() const = 0; /** * Returns the name of the DBus service that should be used for this backend. * * Each backend must have an 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 the 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 this signal for every single change. The emissions are aggregated * in the 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 diff --git a/src/doctor/dpmsclient.h b/src/doctor/dpmsclient.h index 48be41c..1a5b493 100644 --- a/src/doctor/dpmsclient.h +++ b/src/doctor/dpmsclient.h @@ -1,77 +1,76 @@ /************************************************************************************* * Copyright 2016 Sebastian Kügler * * * * 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_DPMSCLIENT_H #define KSCREEN_DPMSCLIENT_H #include #include #include "../config.h" #include #include class QThread; namespace KWayland { namespace Client { class ConnectionThread; } } namespace KScreen { -class ConfigOperation; class DpmsClient : public QObject { Q_OBJECT public: explicit DpmsClient(QObject *parent = nullptr); ~DpmsClient() override; void connect(); void off(); void on(); Q_SIGNALS: void ready(); void finished(); private Q_SLOTS: void connected(); void modeChanged(); private: void changeMode(KWayland::Client::Dpms::Mode mode); QThread *m_thread; KWayland::Client::ConnectionThread *m_connection = nullptr; KWayland::Client::DpmsManager *m_dpmsManager = nullptr; KWayland::Client::Registry m_registry; bool m_setOff = true; bool m_setOn = false; bool m_supportedOututCount = 0; int m_modeChanges = 0; }; } // namespace #endif // KSCREEN_DPSMCLIENT_H diff --git a/src/getconfigoperation.h b/src/getconfigoperation.h index 9be449b..6b3a412 100644 --- a/src/getconfigoperation.h +++ b/src/getconfigoperation.h @@ -1,53 +1,51 @@ /* * Copyright (C) 2014 Daniel Vratil * * 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: explicit GetConfigOperation(Options options = NoOptions, QObject* parent = nullptr); ~GetConfigOperation() override; KScreen::ConfigPtr config() const override; protected: void start() override; private: Q_DECLARE_PRIVATE(GetConfigOperation) }; } #endif // KSCREEN_GETCONFIGOPERATION_H diff --git a/tests/kwayland/waylandtestserver.h b/tests/kwayland/waylandtestserver.h index 51e8fa6..f848223 100644 --- a/tests/kwayland/waylandtestserver.h +++ b/tests/kwayland/waylandtestserver.h @@ -1,88 +1,86 @@ /************************************************************************************* * Copyright 2014-2015 Sebastian Kügler * * * * 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_WAYLAND_TESTSERVER_H #define KSCREEN_WAYLAND_TESTSERVER_H #include // KWayland #include #include #include #include #include #include #include #include namespace KScreen { -class WaylandConfig; -class WaylandOutput; static const QString s_socketName = QStringLiteral("libkscreen-test-wayland-backend-0"); using namespace KWayland::Server; class WaylandTestServer : public QObject { Q_OBJECT public: explicit WaylandTestServer(QObject *parent = nullptr); ~WaylandTestServer() override; void setConfig(const QString &configfile); void start(); void stop(); void pickupConfigFile(const QString &configfile); void showOutputs(); KWayland::Server::Display* display(); QList outputs() const; int outputCount() const; void suspendChanges(bool suspend); Q_SIGNALS: void outputsChanged(); void started(); void configReceived(); void configChanged(); private Q_SLOTS: void configurationChangeRequested(KWayland::Server::OutputConfigurationInterface *configurationInterface); private: static QString modeString(KWayland::Server::OutputDeviceInterface* outputdevice, int mid); QString m_configFile; KWayland::Server::Display *m_display; QList m_outputs; KWayland::Server::OutputManagementInterface *m_outputManagement; KWayland::Server::DpmsManagerInterface *m_dpmsManager; bool m_suspendChanges; KWayland::Server::OutputConfigurationInterface *m_waiting; }; } // namespace #endif // KSCREEN_WAYLAND_SCREEN_H diff --git a/tests/testpnp.h b/tests/testpnp.h index 3e76598..603c235 100644 --- a/tests/testpnp.h +++ b/tests/testpnp.h @@ -1,53 +1,52 @@ /************************************************************************************* * Copyright 2014 Sebastian Kügler * * * * 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_TESTPNP_H #define KSCREEN_TESTPNP_H #include "../src/config.h" #include "../src/screen.h" #include namespace KScreen { class Output; -class QScreenOutput; class ConfigOperation; class TestPnp : public QObject { Q_OBJECT public: explicit TestPnp(bool monitor, QObject *parent = nullptr); ~TestPnp() override; private Q_SLOTS: void init(); void configReady(KScreen::ConfigOperation *op); void print(); private: ConfigPtr m_config; bool m_monitor; }; } // namespace #endif // KSCREEN_TESTPNP_H