/* SPDX-FileCopyrightText: 2016 Marco Martin SPDX-License-Identifier: LGPL-2.0-or-later */ #pragma once #include #include #include #include #include #include #include #include class QScreen; class PrimaryOutputWatcher; class ScreenPool : public QObject { Q_OBJECT public: explicit ScreenPool(const KSharedConfig::Ptr &config, QObject *parent = nullptr); void load(); ~ScreenPool() override; QString primaryConnector() const; int id(const QString &connector) const; QString connector(int id) const; // all ids that are known, included screens not enabled at the moment QList knownIds() const; // QScreen API QList screens() const; QScreen *primaryScreen() const; QScreen *screenForId(int id) const; QScreen *screenForConnector(const QString &connector); bool noRealOutputsConnected() const; Q_SIGNALS: void screenAdded(QScreen *screen); void screenRemoved(QScreen *screen); void primaryScreenChanged(QScreen *oldPrimary, QScreen *newPrimary); private: void save(); void setPrimaryConnector(const QString &primary); void insertScreenMapping(int id, const QString &connector); int firstAvailableId() const; QScreen *outputRedundantTo(QScreen *screen) const; void reconsiderOutputs(); bool isOutputFake(QScreen *screen) const; void insertSortedScreen(QScreen *screen); void handleScreenAdded(QScreen *screen); void handleScreenRemoved(QScreen *screen); void handlePrimaryOutputNameChanged(const QString &oldOutputName, const QString &newOutputName); void screenInvariants(); KConfigGroup m_configGroup; QString m_primaryConnector; // order is important QMap m_connectorForId; QHash m_idForConnector; // List correspondent to qGuiApp->screens(), but sorted first by size then by Id, // determines the screen importance while figuring out the reduntant ones QList m_allSortedScreens; // m_availableScreens + m_redundantOutputs + m_fakeOutputs == qGuiApp->screens() QList m_availableScreens; // Those are all the screen that are available to Corona QHash m_redundantScreens; QSet m_fakeScreens; QTimer m_reconsiderOutputsTimer; QTimer m_configSaveTimer; PrimaryOutputWatcher *const m_primaryWatcher; friend QDebug operator<<(QDebug d, const ScreenPool *pool); }; QDebug operator<<(QDebug d, const ScreenPool *pool);