File indexing completed on 2024-12-22 05:09:24
0001 /* 0002 SPDX-FileCopyrightText: 2015 Marco Martin <notmart@gmail.com> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 #ifndef KWAYLAND_CLIENT_SLIDE_H 0007 #define KWAYLAND_CLIENT_SLIDE_H 0008 0009 #include <QObject> 0010 0011 #include "KWayland/Client/kwaylandclient_export.h" 0012 0013 struct org_kde_kwin_slide_manager; 0014 struct org_kde_kwin_slide; 0015 0016 namespace KWayland 0017 { 0018 namespace Client 0019 { 0020 class EventQueue; 0021 class Slide; 0022 class Surface; 0023 0024 /** 0025 * @short Wrapper for the org_kde_kwin_slide_manager interface. 0026 * 0027 * This class provides a convenient wrapper for the org_kde_kwin_slide_manager interface. 0028 * 0029 * Ask the compositor to move the surface from a location 0030 * to another with a slide animation. 0031 * 0032 * The from argument provides a clue about where the slide 0033 * animation begins, offset is the distance from screen 0034 * edge to begin the animation. 0035 * 0036 * To use this class one needs to interact with the Registry. There are two 0037 * possible ways to create the SlideManager interface: 0038 * @code 0039 * SlideManager *c = registry->createSlideManager(name, version); 0040 * @endcode 0041 * 0042 * This creates the SlideManager and sets it up directly. As an alternative this 0043 * can also be done in a more low level way: 0044 * @code 0045 * SlideManager *c = new SlideManager; 0046 * c->setup(registry->bindSlideManager(name, version)); 0047 * @endcode 0048 * 0049 * The SlideManager can be used as a drop-in replacement for any org_kde_kwin_slide_manager 0050 * pointer as it provides matching cast operators. 0051 * 0052 * @see Registry 0053 **/ 0054 class KWAYLANDCLIENT_EXPORT SlideManager : public QObject 0055 { 0056 Q_OBJECT 0057 public: 0058 /** 0059 * Creates a new SlideManager. 0060 * Note: after constructing the SlideManager it is not yet valid and one needs 0061 * to call setup. In order to get a ready to use SlideManager prefer using 0062 * Registry::createSlideManager. 0063 **/ 0064 explicit SlideManager(QObject *parent = nullptr); 0065 ~SlideManager() override; 0066 0067 /** 0068 * Setup this SlideManager to manage the @p slidemanager. 0069 * When using Registry::createSlideManager there is no need to call this 0070 * method. 0071 **/ 0072 void setup(org_kde_kwin_slide_manager *slidemanager); 0073 /** 0074 * @returns @c true if managing a org_kde_kwin_slide_manager. 0075 **/ 0076 bool isValid() const; 0077 /** 0078 * Releases the org_kde_kwin_slide_manager interface. 0079 * After the interface has been released the SlideManager instance is no 0080 * longer valid and can be setup with another org_kde_kwin_slide_manager interface. 0081 **/ 0082 void release(); 0083 /** 0084 * Destroys the data held by this SlideManager. 0085 * This method is supposed to be used when the connection to the Wayland 0086 * server goes away. If the connection is not valid anymore, it's not 0087 * possible to call release anymore as that calls into the Wayland 0088 * connection and the call would fail. This method cleans up the data, so 0089 * that the instance can be deleted or set up to a new org_kde_kwin_slide_manager interface 0090 * once there is a new connection available. 0091 * 0092 * This method is automatically invoked when the Registry which created this 0093 * SlideManager gets destroyed. 0094 * 0095 * @see release 0096 **/ 0097 void destroy(); 0098 0099 /** 0100 * Sets the @p queue to use for creating objects with this SlideManager. 0101 **/ 0102 void setEventQueue(EventQueue *queue); 0103 /** 0104 * @returns The event queue to use for creating objects with this SlideManager. 0105 **/ 0106 EventQueue *eventQueue(); 0107 0108 Slide *createSlide(Surface *surface, QObject *parent = nullptr); 0109 0110 void removeSlide(Surface *surface); 0111 0112 operator org_kde_kwin_slide_manager *(); 0113 operator org_kde_kwin_slide_manager *() const; 0114 0115 Q_SIGNALS: 0116 /** 0117 * The corresponding global for this interface on the Registry got removed. 0118 * 0119 * This signal gets only emitted if the SlideManager got created by 0120 * Registry::createSlideManager 0121 **/ 0122 void removed(); 0123 0124 private: 0125 class Private; 0126 QScopedPointer<Private> d; 0127 }; 0128 0129 /** 0130 * TODO 0131 */ 0132 class KWAYLANDCLIENT_EXPORT Slide : public QObject 0133 { 0134 Q_OBJECT 0135 public: 0136 enum Location { 0137 Left = 0, /**< Slide from the left edge of the screen */ 0138 Top, /**< Slide from the top edge of the screen */ 0139 Right, /**< Slide from the bottom edge of the screen */ 0140 Bottom, /**< Slide from the bottom edge of the screen */ 0141 }; 0142 0143 ~Slide() override; 0144 0145 /** 0146 * Setup this Slide to manage the @p slide. 0147 * When using SlideManager::createSlide there is no need to call this 0148 * method. 0149 **/ 0150 void setup(org_kde_kwin_slide *slide); 0151 0152 /** 0153 * @returns @c true if managing a org_kde_kwin_slide. 0154 **/ 0155 bool isValid() const; 0156 0157 /** 0158 * Releases the org_kde_kwin_slide interface. 0159 * After the interface has been released the Slide instance is no 0160 * longer valid and can be setup with another org_kde_kwin_slide interface. 0161 **/ 0162 void release(); 0163 0164 /** 0165 * Destroys the data held by this Slide. 0166 * This method is supposed to be used when the connection to the Wayland 0167 * server goes away. If the connection is not valid anymore, it's not 0168 * possible to call release anymore as that calls into the Wayland 0169 * connection and the call would fail. This method cleans up the data, so 0170 * that the instance can be deleted or set up to a new org_kde_kwin_slide interface 0171 * once there is a new connection available. 0172 * 0173 * It is suggested to connect this method to ConnectionThread::connectionDied: 0174 * @code 0175 * connect(connection, &ConnectionThread::connectionDied, slide, &Slide::destroy); 0176 * @endcode 0177 * 0178 * @see release 0179 **/ 0180 void destroy(); 0181 0182 void commit(); 0183 0184 /** 0185 * Set the location of the screen to slide the window from 0186 */ 0187 void setLocation(Slide::Location location); 0188 0189 /** 0190 * Set the offset from the screen edge 0191 * to make the window slide from 0192 */ 0193 void setOffset(qint32 offset); 0194 0195 operator org_kde_kwin_slide *(); 0196 operator org_kde_kwin_slide *() const; 0197 0198 private: 0199 friend class SlideManager; 0200 explicit Slide(QObject *parent = nullptr); 0201 class Private; 0202 QScopedPointer<Private> d; 0203 }; 0204 0205 } 0206 } 0207 0208 #endif