File indexing completed on 2022-09-27 16:03:55

0001 /*
0002     SPDX-FileCopyrightText: 2021 Aleix Pol Gonzalez <aleixpol@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef PRIMARYOUTPUTWATCHER_H
0008 #define PRIMARYOUTPUTWATCHER_H
0009 
0010 #include <QAbstractNativeEventFilter>
0011 #include <QObject>
0012 
0013 namespace KWayland
0014 {
0015 namespace Client
0016 {
0017 class Registry;
0018 class ConnectionThread;
0019 }
0020 }
0021 
0022 class QScreen;
0023 
0024 class PrimaryOutputWatcher : public QObject, public QAbstractNativeEventFilter
0025 {
0026     Q_OBJECT
0027 public:
0028     PrimaryOutputWatcher(QObject *parent);
0029     QScreen *primaryScreen() const;
0030     QScreen *screenForName(const QString &outputName) const;
0031 
0032 Q_SIGNALS:
0033     void primaryOutputNameChanged(const QString &oldOutputName, const QString &newOutputName);
0034 
0035 protected:
0036     friend class WaylandOutputDevice;
0037     void setPrimaryOutputName(const QString &outputName);
0038 
0039 private:
0040     void setupRegistry();
0041 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
0042     bool nativeEventFilter(const QByteArray &eventType, void *message, long *result) override;
0043 #else
0044     bool nativeEventFilter(const QByteArray &eventType, void *message, qintptr *result) override;
0045 #endif
0046 
0047     // All
0048     QString m_primaryOutputName;
0049 
0050     // Wayland
0051     KWayland::Client::Registry *m_registry = nullptr;
0052     QString m_primaryOutputWayland;
0053 
0054     // Xrandr
0055     int m_xrandrExtensionOffset;
0056 };
0057 
0058 #endif // PRIMARYOUTPUTWATCHER_H