File indexing completed on 2024-05-19 16:35:24
0001 /* 0002 SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 #pragma once 0007 0008 #include "kwin_export.h" 0009 0010 #include <QObject> 0011 #include <memory> 0012 0013 class QSize; 0014 0015 namespace KWaylandServer 0016 { 0017 class Display; 0018 class OutputInterface; 0019 class PlasmaWindowActivationFeedbackInterfacePrivate; 0020 class PlasmaWindowInterface; 0021 class PlasmaVirtualDesktopManagementInterface; 0022 class PlasmaWindowActivationInterfacePrivate; 0023 class PlasmaWindowManagementInterfacePrivate; 0024 class PlasmaWindowInterfacePrivate; 0025 class SurfaceInterface; 0026 0027 class KWIN_EXPORT PlasmaWindowActivationInterface 0028 { 0029 public: 0030 ~PlasmaWindowActivationInterface(); 0031 0032 void sendAppId(const QString &id); 0033 0034 private: 0035 friend class PlasmaWindowActivationFeedbackInterface; 0036 explicit PlasmaWindowActivationInterface(); 0037 0038 std::unique_ptr<PlasmaWindowActivationInterfacePrivate> d; 0039 }; 0040 0041 class KWIN_EXPORT PlasmaWindowActivationFeedbackInterface : public QObject 0042 { 0043 Q_OBJECT 0044 0045 public: 0046 explicit PlasmaWindowActivationFeedbackInterface(Display *display, QObject *parent = nullptr); 0047 ~PlasmaWindowActivationFeedbackInterface() override; 0048 0049 /** 0050 * Notify about a new application with @p app_id being started 0051 * 0052 * @returns an instance of @class PlasmaWindowActivationInterface to 0053 * be destroyed as the activation process ends. 0054 */ 0055 std::unique_ptr<PlasmaWindowActivationInterface> createActivation(const QString &app_id); 0056 0057 private: 0058 std::unique_ptr<PlasmaWindowActivationFeedbackInterfacePrivate> d; 0059 }; 0060 0061 class KWIN_EXPORT PlasmaWindowManagementInterface : public QObject 0062 { 0063 Q_OBJECT 0064 0065 public: 0066 explicit PlasmaWindowManagementInterface(Display *display, QObject *parent = nullptr); 0067 ~PlasmaWindowManagementInterface() override; 0068 enum class ShowingDesktopState { 0069 Disabled, 0070 Enabled, 0071 }; 0072 void setShowingDesktopState(ShowingDesktopState state); 0073 0074 PlasmaWindowInterface *createWindow(QObject *parent, const QUuid &uuid); 0075 QList<PlasmaWindowInterface *> windows() const; 0076 0077 /** 0078 * Associate a PlasmaVirtualDesktopManagementInterface to this window management. 0079 * It's necessary to associate one in orderto use the plasma virtual desktop features 0080 * of PlasmaWindowInterface, as a window must know what are the deasktops available 0081 */ 0082 void setPlasmaVirtualDesktopManagementInterface(PlasmaVirtualDesktopManagementInterface *manager); 0083 0084 /** 0085 * @returns the PlasmaVirtualDesktopManagementInterface associated to this PlasmaWindowManagementInterface 0086 */ 0087 PlasmaVirtualDesktopManagementInterface *plasmaVirtualDesktopManagementInterface() const; 0088 0089 /** 0090 * Associate stacking order to this window management 0091 */ 0092 void setStackingOrder(const QVector<quint32> &stackingOrder); 0093 0094 void setStackingOrderUuids(const QVector<QString> &stackingOrderUuids); 0095 0096 Q_SIGNALS: 0097 void requestChangeShowingDesktop(ShowingDesktopState requestedState); 0098 0099 private: 0100 std::unique_ptr<PlasmaWindowManagementInterfacePrivate> d; 0101 }; 0102 0103 /** 0104 * @todo Add documentation 0105 */ 0106 class KWIN_EXPORT PlasmaWindowInterface : public QObject 0107 { 0108 Q_OBJECT 0109 public: 0110 ~PlasmaWindowInterface() override; 0111 0112 void setTitle(const QString &title); 0113 void setAppId(const QString &appId); 0114 void setPid(quint32 pid); 0115 void setActive(bool set); 0116 void setMinimized(bool set); 0117 void setMaximized(bool set); 0118 void setFullscreen(bool set); 0119 void setKeepAbove(bool set); 0120 void setKeepBelow(bool set); 0121 void setOnAllDesktops(bool set); 0122 void setDemandsAttention(bool set); 0123 void setCloseable(bool set); 0124 void setMinimizeable(bool set); 0125 void setMaximizeable(bool set); 0126 void setFullscreenable(bool set); 0127 void setSkipTaskbar(bool skip); 0128 void setSkipSwitcher(bool skip); 0129 void setShadeable(bool set); 0130 void setShaded(bool set); 0131 void setMovable(bool set); 0132 void setResizable(bool set); 0133 void setResourceName(const QString &resourceName); 0134 /** 0135 * FIXME: still relevant with new desktops? 0136 */ 0137 void setVirtualDesktopChangeable(bool set); 0138 0139 /** 0140 * This method removes the Window and the Client is supposed to release the resource 0141 * bound for this Window. 0142 * 0143 * No more events should be sent afterwards. 0144 */ 0145 void unmap(); 0146 0147 /** 0148 * @returns Geometries of the taskbar entries, indicized by the 0149 * surface of the panels 0150 */ 0151 QHash<SurfaceInterface *, QRect> minimizedGeometries() const; 0152 0153 /** 0154 * Sets this PlasmaWindowInterface as a transient window to @p parentWindow. 0155 * If @p parentWindow is @c nullptr, the PlasmaWindowInterface is a toplevel 0156 * window and does not have a parent window. 0157 */ 0158 void setParentWindow(PlasmaWindowInterface *parentWindow); 0159 0160 /** 0161 * Sets the window @p geometry of this PlasmaWindow. 0162 * 0163 * @param geometry The geometry in absolute coordinates 0164 */ 0165 void setGeometry(const QRect &geometry); 0166 0167 /** 0168 * Set the icon of the PlasmaWindowInterface. 0169 * 0170 * In case the icon has a themed name, only the name is sent to the client. 0171 * Otherwise the client is only informed that there is an icon and the client 0172 * can request the icon in an asynchronous way by passing a file descriptor 0173 * into which the icon will be serialized. 0174 * 0175 * @param icon The new icon 0176 */ 0177 void setIcon(const QIcon &icon); 0178 0179 /** 0180 * Adds a new desktop to this window: a window can be on 0181 * an arbitrary subset of virtual desktops. 0182 * If it's on none it will be considered on all desktops. 0183 */ 0184 void addPlasmaVirtualDesktop(const QString &id); 0185 0186 /** 0187 * Removes a visrtual desktop from a window 0188 */ 0189 void removePlasmaVirtualDesktop(const QString &id); 0190 0191 /** 0192 * The ids of all the desktops currently associated with this window. 0193 * When a desktop is deleted it will be automatically removed from this list 0194 */ 0195 QStringList plasmaVirtualDesktops() const; 0196 0197 /** 0198 * Adds an activity to this window: a window can be on 0199 * an arbitrary subset of activities. 0200 * If it's on none it will be considered on all activities. 0201 */ 0202 void addPlasmaActivity(const QString &id); 0203 0204 /** 0205 * Removes an activity from a window 0206 */ 0207 void removePlasmaActivity(const QString &id); 0208 0209 /** 0210 * The ids of all the activities currently associated with this window. 0211 * When an activity is deleted it will be automatically removed from this list 0212 */ 0213 QStringList plasmaActivities() const; 0214 0215 /** 0216 * Set the application menu D-BUS service name and object path for the window. 0217 */ 0218 void setApplicationMenuPaths(const QString &serviceName, const QString &objectPath); 0219 0220 /** 0221 * Return the window internal id 0222 */ 0223 quint32 internalId() const; 0224 0225 /** 0226 * @return a unique string that identifies this window 0227 */ 0228 QString uuid() const; 0229 0230 Q_SIGNALS: 0231 void closeRequested(); 0232 void moveRequested(); 0233 void resizeRequested(); 0234 void activeRequested(bool set); 0235 void minimizedRequested(bool set); 0236 void maximizedRequested(bool set); 0237 void fullscreenRequested(bool set); 0238 void keepAboveRequested(bool set); 0239 void keepBelowRequested(bool set); 0240 void demandsAttentionRequested(bool set); 0241 void closeableRequested(bool set); 0242 void minimizeableRequested(bool set); 0243 void maximizeableRequested(bool set); 0244 void fullscreenableRequested(bool set); 0245 void skipTaskbarRequested(bool set); 0246 void skipSwitcherRequested(bool set); 0247 QRect minimizedGeometriesChanged(); 0248 void shadeableRequested(bool set); 0249 void shadedRequested(bool set); 0250 void movableRequested(bool set); 0251 void resizableRequested(bool set); 0252 /** 0253 * FIXME: still relevant with new virtual desktops? 0254 */ 0255 void virtualDesktopChangeableRequested(bool set); 0256 0257 /** 0258 * Emitted when the client wishes this window to enter in a new virtual desktop. 0259 * The server will decide whether to consent this request 0260 */ 0261 void enterPlasmaVirtualDesktopRequested(const QString &desktop); 0262 0263 /** 0264 * Emitted when the client wishes this window to enter in 0265 * a new virtual desktop to be created for it. 0266 * The server will decide whether to consent this request 0267 */ 0268 void enterNewPlasmaVirtualDesktopRequested(); 0269 0270 /** 0271 * Emitted when the client wishes to remove this window from a virtual desktop. 0272 * The server will decide whether to consent this request 0273 */ 0274 void leavePlasmaVirtualDesktopRequested(const QString &desktop); 0275 0276 /** 0277 * Emitted when the client wishes this window to enter an activity. 0278 * The server will decide whether to consent this request 0279 */ 0280 void enterPlasmaActivityRequested(const QString &activity); 0281 0282 /** 0283 * Emitted when the client wishes to remove this window from an activity. 0284 * The server will decide whether to consent this request 0285 */ 0286 void leavePlasmaActivityRequested(const QString &activity); 0287 0288 /** 0289 * Requests sending the window to @p output 0290 */ 0291 void sendToOutput(KWaylandServer::OutputInterface *output); 0292 0293 private: 0294 friend class PlasmaWindowManagementInterface; 0295 friend class PlasmaWindowInterfacePrivate; 0296 friend class PlasmaWindowManagementInterfacePrivate; 0297 explicit PlasmaWindowInterface(PlasmaWindowManagementInterface *wm, QObject *parent); 0298 0299 std::unique_ptr<PlasmaWindowInterfacePrivate> d; 0300 }; 0301 0302 } 0303 0304 Q_DECLARE_METATYPE(KWaylandServer::PlasmaWindowManagementInterface::ShowingDesktopState)