1 /********************************************************************
2 Copyright © 2015  Sebastian Kügler <sebas@kde.org>
3 Copyright © 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) version 3, or any
9 later version accepted by the membership of KDE e.V. (or its
10 successor approved by the membership of KDE e.V.), which shall
11 act as a proxy defined in Section 6 of version 3 of the license.
12 
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 Lesser General Public License for more details.
17 
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library.  If not, see <http://www.gnu.org/licenses/>.
20 *********************************************************************/
21 #pragma once
22 
23 #include <QObject>
24 // STD
25 #include <Wrapland/Client/wraplandclient_export.h>
26 #include <memory>
27 
28 struct zkwinft_output_configuration_v1;
29 struct zkwinft_output_management_v1;
30 
31 namespace Wrapland
32 {
33 namespace Client
34 {
35 
36 class EventQueue;
37 class OutputConfigurationV1;
38 class OutputDeviceV1;
39 
40 /**
41  * @short Wrapper for the zkwinft_output_management_v1 interface.
42  *
43  * This class provides a convenient wrapper for the zkwinft_output_management_v1 interface.
44  *
45  * To use this class one needs to interact with the Registry. There are two
46  * possible ways to create the OutputManagementV1 interface:
47  * @code
48  * OutputManagementV1 *c = registry->createOutputManagementV1(name, version);
49  * @endcode
50  *
51  * This creates the OutputManagementV1 and sets it up directly. As an alternative this
52  * can also be done in a more low level way:
53  * @code
54  * OutputManagementV1 *c = new OutputManagementV1;
55  * c->setup(registry->bindOutputManagementV1(name, version));
56  * @endcode
57  *
58  * The OutputManagementV1 can be used as a drop-in replacement for any zkwinft_output_management_v1
59  * pointer as it provides matching cast operators.
60  *
61  * @see Registry
62  * @since 5.5
63  **/
64 class WRAPLANDCLIENT_EXPORT OutputManagementV1 : public QObject
65 {
66     Q_OBJECT
67 public:
68     /**
69      * Creates a new OutputManagementV1.
70      * Note: after constructing the OutputManagementV1 it is not yet valid and one needs
71      * to call setup. In order to get a ready to use OutputManagementV1 prefer using
72      * Registry::createOutputManagementV1.
73      **/
74     explicit OutputManagementV1(QObject* parent = nullptr);
75     ~OutputManagementV1() override;
76 
77     /**
78      * Setup this OutputManagementV1 to manage the @p OutputManagementV1.
79      * When using Registry::createOutputManagementV1 there is no need to call this
80      * method.
81      **/
82     void setup(zkwinft_output_management_v1* outputManagement);
83     /**
84      * @returns @c true if managing a zkwinft_output_management_v1.
85      **/
86     bool isValid() const;
87     /**
88      * Releases the zkwinft_output_management_v1 interface.
89      * After the interface has been released the OutputManagement instance is no
90      * longer valid and can be setup with another zkwinft_output_management_v1 interface.
91      **/
92     void release();
93 
94     /**
95      * Sets the @p queue to use for creating objects with this OutputManagement.
96      **/
97     void setEventQueue(EventQueue* queue);
98     /**
99      * @returns The event queue to use for creating objects with this OutputManagement.
100      **/
101     EventQueue* eventQueue();
102 
103     OutputConfigurationV1* createConfiguration(QObject* parent = nullptr);
104 
105     operator zkwinft_output_management_v1*();
106     operator zkwinft_output_management_v1*() const;
107 
108 Q_SIGNALS:
109     /**
110      * The corresponding global for this interface on the Registry got removed.
111      *
112      * This signal gets only emitted if the OutputManagement got created by
113      * Registry::createOutputManagement
114      **/
115     void removed();
116 
117 private:
118     class Private;
119     std::unique_ptr<Private> d;
120 };
121 
122 }
123 }
124