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