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) version 3, or any 8 later version accepted by the membership of KDE e.V. (or its 9 successor approved by the membership of KDE e.V.), which shall 10 act as a proxy defined in Section 6 of version 3 of the license. 11 12 This library is distributed in the hope that it will be useful, 13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 Lesser General Public License for more details. 16 17 You should have received a copy of the GNU Lesser General Public 18 License along with this library. If not, see <http://www.gnu.org/licenses/>. 19 *********************************************************************/ 20 #pragma once 21 22 #include <QObject> 23 #include <QSize> 24 #include <QVector> 25 // STD 26 #include <Wrapland/Client/wraplandclient_export.h> 27 #include <memory> 28 29 struct zwlr_output_head_v1; 30 struct zwlr_output_manager_v1; 31 struct zwlr_output_mode_v1; 32 33 namespace Wrapland 34 { 35 namespace Client 36 { 37 38 class EventQueue; 39 class WlrOutputConfigurationV1; 40 class WlrOutputHeadV1; 41 42 /** 43 * @short Wrapper for the zwlr_output_manager_v1 interface. 44 * 45 * This class provides a convenient wrapper for the zwlr_output_manager_v1 interface. 46 * 47 * To use this class one needs to interact with the Registry. There are two 48 * possible ways to create the WlrOutputManagerV1 interface: 49 * @code 50 * WlrOutputManagerV1 *c = registry->createWlrOutputManagerV1(name, version); 51 * @endcode 52 * 53 * This creates the WlrOutputManagerV1 and sets it up directly. As an alternative this 54 * can also be done in a more low level way: 55 * @code 56 * WlrOutputManagerV1 *c = new WlrOutputManagerV1; 57 * c->setup(registry->bindWlrOutputManagerV1(name, version)); 58 * @endcode 59 * 60 * The WlrOutputManagerV1 can be used as a drop-in replacement for any zwlr_output_manager_v1 61 * pointer as it provides matching cast operators. 62 * 63 * @see Registry 64 * @since 0.519.0 65 */ 66 class WRAPLANDCLIENT_EXPORT WlrOutputManagerV1 : public QObject 67 { 68 Q_OBJECT 69 public: 70 /** 71 * Creates a new WlrOutputManagerV1. 72 * Note: after constructing the WlrOutputManagerV1 it is not yet valid and one needs 73 * to call setup. In order to get a ready to use WlrOutputManagerV1 prefer using 74 * Registry::createWlrOutputManagerV1. 75 */ 76 explicit WlrOutputManagerV1(QObject* parent = nullptr); 77 ~WlrOutputManagerV1() override; 78 79 /** 80 * Setup this WlrOutputManagerV1 to manage the @p WlrOutputManagerV1. 81 * When using Registry::createWlrOutputManagerV1 there is no need to call this 82 * method. 83 */ 84 void setup(zwlr_output_manager_v1* outputManager); 85 /** 86 * @returns @c true if managing a zwlr_output_manager_v1. 87 */ 88 bool isValid() const; 89 /** 90 * Releases the zwlr_output_manager_v1 interface. 91 * After the interface has been released the WlrOutputManager instance is no 92 * longer valid and can be setup with another zwlr_output_manager_v1 interface. 93 */ 94 void release(); 95 96 /** 97 * Sets the @p queue to use for creating objects with this WlrOutputManager. 98 */ 99 void setEventQueue(EventQueue* queue); 100 /** 101 * @returns The event queue to use for creating objects with this WlrOutputManager. 102 */ 103 EventQueue* eventQueue(); 104 105 /** 106 * Create a configuration object ready for being used in a configure operation. 107 * @param parent 108 * @return configuration object. 109 */ 110 WlrOutputConfigurationV1* createConfiguration(QObject* parent = nullptr); 111 112 operator zwlr_output_manager_v1*(); 113 operator zwlr_output_manager_v1*() const; 114 115 Q_SIGNALS: 116 /** 117 * A new output head appeared. 118 * @param head 119 */ 120 void head(WlrOutputHeadV1* head); 121 /** 122 * All information has been sent. 123 */ 124 void done(); 125 126 /** 127 * The corresponding global for this interface on the Registry got removed. 128 * 129 * This signal gets only emitted if the WlrOutputManager got created by 130 * Registry::createWlrOutputManagerV1 131 */ 132 void removed(); 133 134 private: 135 class Private; 136 std::unique_ptr<Private> d; 137 }; 138 139 class WRAPLANDCLIENT_EXPORT WlrOutputModeV1 : public QObject 140 { 141 Q_OBJECT 142 public: 143 ~WlrOutputModeV1() override; 144 145 QSize size() const; 146 int refresh() const; 147 bool preferred() const; 148 149 operator zwlr_output_mode_v1*(); 150 operator zwlr_output_mode_v1*() const; 151 152 Q_SIGNALS: 153 void removed(); 154 155 private: 156 explicit WlrOutputModeV1(zwlr_output_mode_v1* mode, QObject* parent = nullptr); 157 friend class WlrOutputHeadV1; 158 159 class Private; 160 std::unique_ptr<Private> d; 161 }; 162 163 class WRAPLANDCLIENT_EXPORT WlrOutputHeadV1 : public QObject 164 { 165 Q_OBJECT 166 public: 167 enum class Transform { 168 Normal, 169 Rotated90, 170 Rotated180, 171 Rotated270, 172 Flipped, 173 Flipped90, 174 Flipped180, 175 Flipped270, 176 }; 177 ~WlrOutputHeadV1() override; 178 179 QString name() const; 180 QString description() const; 181 182 QString make() const; 183 QString model() const; 184 QString serialNumber() const; 185 186 QSize physicalSize() const; 187 188 bool enabled() const; 189 190 QVector<WlrOutputModeV1*> modes() const; 191 WlrOutputModeV1* currentMode() const; 192 193 QPoint position() const; 194 Transform transform() const; 195 double scale() const; 196 197 operator zwlr_output_head_v1*(); 198 operator zwlr_output_head_v1*() const; 199 200 Q_SIGNALS: 201 void changed(); 202 void removed(); 203 204 private: 205 explicit WlrOutputHeadV1(zwlr_output_head_v1* head, QObject* parent = nullptr); 206 friend class WlrOutputManagerV1; 207 208 class Private; 209 std::unique_ptr<Private> d; 210 }; 211 212 } 213 } 214