Changeset View
Changeset View
Standalone View
Standalone View
backends/kwayland/plugins/kwayland/kwayland_interface.h
- This file was added.
1 | /************************************************************************* | ||||
---|---|---|---|---|---|
2 | Copyright © 2014-2015 Sebastian Kügler <sebas@kde.org> | ||||
3 | Copyright © 2019-2020 Roman Gilg <subdiff@gmail.com> | ||||
4 | | ||||
5 | This library is free software; you can redistribute it and/or | ||||
6 | modify it under the terms of the GNU Lesser General Public | ||||
7 | License as published by the Free Software Foundation; either | ||||
8 | version 2.1 of the License, or (at your option) any later version. | ||||
9 | | ||||
10 | This library is distributed in the hope that it will be useful, | ||||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
13 | Lesser General Public License for more details. | ||||
14 | | ||||
15 | You should have received a copy of the GNU Lesser General Public | ||||
16 | License along with this library; if not, write to the Free Software | ||||
17 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||||
18 | **************************************************************************/ | ||||
19 | #pragma once | ||||
20 | | ||||
21 | #include "wayland_interface.h" | ||||
22 | #include "config.h" | ||||
23 | | ||||
24 | namespace KWayland | ||||
25 | { | ||||
26 | namespace Client | ||||
27 | { | ||||
28 | class ConnectionThread; | ||||
29 | class EventQueue; | ||||
30 | class Registry; | ||||
31 | class OutputManagement; | ||||
32 | } | ||||
33 | } | ||||
34 | | ||||
35 | namespace KScreen | ||||
36 | { | ||||
37 | class Output; | ||||
38 | class KWaylandOutput; | ||||
39 | class WaylandOutput; | ||||
40 | class WaylandScreen; | ||||
41 | | ||||
42 | class KWaylandFactory : public WaylandFactory | ||||
43 | { | ||||
44 | Q_OBJECT | ||||
45 | Q_PLUGIN_METADATA(IID "org.kde.libkscreen.waylandinterface" FILE "kwayland.json") | ||||
46 | | ||||
47 | public: | ||||
48 | WaylandInterface* createInterface(QObject *parent = nullptr) override; | ||||
49 | }; | ||||
50 | | ||||
51 | class KWaylandInterface : public WaylandInterface | ||||
52 | { | ||||
53 | Q_OBJECT | ||||
54 | | ||||
55 | public: | ||||
56 | explicit KWaylandInterface(QObject *parent = nullptr); | ||||
57 | ~KWaylandInterface() override = default; | ||||
58 | bool isInitialized() const override; | ||||
59 | | ||||
60 | QMap<int, WaylandOutput*> outputMap() const override; | ||||
61 | | ||||
62 | void applyConfig(const KScreen::ConfigPtr &newConfig) override; | ||||
63 | void updateConfig(KScreen::ConfigPtr &config) override; | ||||
64 | | ||||
65 | protected: | ||||
66 | void initConnection(QThread *thread) override; | ||||
67 | void insertOutput(WaylandOutput *output) override; | ||||
68 | WaylandOutput* takeOutput(WaylandOutput *output) override; | ||||
69 | void handleDisconnect() override; | ||||
70 | | ||||
71 | private: | ||||
72 | void setupRegistry(); | ||||
73 | void addOutputDevice(quint32 name, quint32 version); | ||||
74 | void tryPendingConfig(); | ||||
75 | | ||||
76 | KWayland::Client::ConnectionThread *m_connection; | ||||
77 | KWayland::Client::EventQueue *m_queue; | ||||
78 | | ||||
79 | KWayland::Client::Registry *m_registry; | ||||
80 | KWayland::Client::OutputManagement *m_outputManagement; | ||||
81 | | ||||
82 | // KWayland names as keys | ||||
83 | QMap<int, KWaylandOutput*> m_outputMap; | ||||
84 | | ||||
85 | // KWayland names | ||||
86 | int m_lastOutputId = -1; | ||||
87 | | ||||
88 | bool m_registryInitialized; | ||||
89 | bool m_blockSignals; | ||||
90 | KScreen::ConfigPtr m_kscreenPendingConfig; | ||||
91 | }; | ||||
92 | | ||||
93 | } |