Warning, file /plasma/libkscreen/backends/kwayland/waylandconfig.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 * SPDX-FileCopyrightText: 2014-2015 Sebastian Kügler <sebas@kde.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.1-or-later 0005 */ 0006 #pragma once 0007 0008 #include "abstractbackend.h" 0009 #include "config.h" 0010 0011 #include <QDir> 0012 #include <QEventLoop> 0013 #include <QLoggingCategory> 0014 #include <QScreen> 0015 #include <QSize> 0016 #include <QSocketNotifier> 0017 0018 struct kde_output_device_v2; 0019 0020 namespace KWayland 0021 { 0022 namespace Client 0023 { 0024 class ConnectionThread; 0025 class EventQueue; 0026 class Registry; 0027 class OutputManagement; 0028 } 0029 } 0030 0031 namespace KScreen 0032 { 0033 class Output; 0034 class WaylandOutputDevice; 0035 class WaylandScreen; 0036 class WaylandOutputManagement; 0037 class WaylandOutputOrder; 0038 0039 /** 0040 * @class WaylandConfig 0041 * 0042 * This class holds the basic skeleton of the configuration and takes care of 0043 * fetching the information from the Wayland server and synchronizing the 0044 * configuration out to the "clients" that receive the config from the backend. 0045 * We initialize a wayland connection, using a threaded event queue when 0046 * querying the wayland server for data. 0047 * Initially, the creation of a WaylandConfig blocks until all data has been 0048 * received, signalled by the initialized() signal. This means that the 0049 * wayland client has received information about all interfaces, and that all 0050 * outputs are completely initialized. From then on, we properly notifyUpdate(). 0051 */ 0052 class WaylandConfig : public QObject 0053 { 0054 Q_OBJECT 0055 0056 public: 0057 explicit WaylandConfig(QObject *parent = nullptr); 0058 ~WaylandConfig() override; 0059 0060 KScreen::ConfigPtr currentConfig(); 0061 QMap<int, WaylandOutputDevice *> outputMap() const; 0062 0063 void applyConfig(const KScreen::ConfigPtr &newConfig); 0064 WaylandOutputDevice *findOutputDevice(struct ::kde_output_device_v2 *outputdevice) const; 0065 0066 bool isReady() const; 0067 0068 Q_SIGNALS: 0069 void configChanged(); 0070 void initialized(); 0071 0072 private: 0073 void setupRegistry(); 0074 void checkInitialized(); 0075 void disconnected(); 0076 0077 void initKWinTabletMode(); 0078 void initConnection(); 0079 0080 void addOutput(quint32 name, quint32 version); 0081 void removeOutput(WaylandOutputDevice *output); 0082 0083 void blockSignals(); 0084 void unblockSignals(); 0085 void tryPendingConfig(); 0086 0087 KWayland::Client::ConnectionThread *m_connection; 0088 0089 KWayland::Client::Registry *m_registry; 0090 WaylandOutputManagement *m_outputManagement = nullptr; 0091 std::unique_ptr<WaylandOutputOrder> m_outputOrder; 0092 0093 // KWayland names as keys 0094 QMap<int, WaylandOutputDevice *> m_outputMap; 0095 0096 // KWayland names 0097 QList<WaylandOutputDevice *> m_initializingOutputs; 0098 int m_lastOutputId = -1; 0099 0100 bool m_registryInitialized; 0101 bool m_blockSignals; 0102 QEventLoop m_syncLoop; 0103 KScreen::ConfigPtr m_kscreenConfig; 0104 KScreen::ConfigPtr m_kscreenPendingConfig; 0105 WaylandScreen *m_screen; 0106 0107 bool m_tabletModeAvailable; 0108 bool m_tabletModeEngaged; 0109 bool m_initialized = false; 0110 }; 0111 0112 }