File indexing completed on 2025-04-13 05:00:14
0001 /* 0002 SPDX-FileCopyrightText: 2018 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 #pragma once 0007 0008 #include "kwin_export.h" 0009 0010 #include <QObject> 0011 #include <memory> 0012 0013 namespace KWin 0014 { 0015 class Display; 0016 class PlasmaVirtualDesktopInterface; 0017 class PlasmaVirtualDesktopInterfacePrivate; 0018 class PlasmaVirtualDesktopManagementInterfacePrivate; 0019 0020 /** 0021 * @short Wrapper for the org_kde_plasma_virtual_desktop_management interface. 0022 * 0023 * This class provides a convenient wrapper for the org_kde_plasma_virtual_desktop_management interface. 0024 */ 0025 class KWIN_EXPORT PlasmaVirtualDesktopManagementInterface : public QObject 0026 { 0027 Q_OBJECT 0028 0029 public: 0030 explicit PlasmaVirtualDesktopManagementInterface(Display *display, QObject *parent = nullptr); 0031 ~PlasmaVirtualDesktopManagementInterface() override; 0032 0033 /** 0034 * Sets how many rows the virtual desktops should be laid into 0035 */ 0036 void setRows(quint32 rows); 0037 0038 /** 0039 * @returns A desktop identified uniquely by this id. 0040 * If not found, nullptr will be returned. 0041 * @see createDesktop 0042 */ 0043 PlasmaVirtualDesktopInterface *desktop(const QString &id); 0044 0045 /** 0046 * @returns A desktop identified uniquely by this id, if not found 0047 * a new desktop will be created for this id at a given position. 0048 * @param id the id for the desktop 0049 * @param position the position the desktop will be in, if not provided, 0050 * it will be appended at the end. If the desktop was already 0051 * existing, position is ignored. 0052 */ 0053 PlasmaVirtualDesktopInterface *createDesktop(const QString &id, quint32 position = std::numeric_limits<uint32_t>::max()); 0054 0055 /** 0056 * Removed and destroys the desktop identified by id, if present 0057 */ 0058 void removeDesktop(const QString &id); 0059 0060 /** 0061 * @returns All tghe desktops present. 0062 */ 0063 QList<PlasmaVirtualDesktopInterface *> desktops() const; 0064 0065 /** 0066 * Inform the clients that all the properties have been sent, and 0067 * their client-side representation is complete. 0068 */ 0069 void sendDone(); 0070 0071 Q_SIGNALS: 0072 /** 0073 * A desktop has been activated 0074 */ 0075 void desktopActivated(const QString &id); 0076 0077 /** 0078 * The client asked to remove a desktop, It's responsibility of the server 0079 * deciding whether to remove it or not. 0080 */ 0081 void desktopRemoveRequested(const QString &id); 0082 0083 /** 0084 * The client asked to create a desktop, It's responsibility of the server 0085 * deciding whether to create it or not. 0086 * @param name The desired user readable name 0087 * @param position The desired position. Normalized, guaranteed to be in the range 0-count 0088 */ 0089 void desktopCreateRequested(const QString &name, quint32 position); 0090 0091 private: 0092 std::unique_ptr<PlasmaVirtualDesktopManagementInterfacePrivate> d; 0093 }; 0094 0095 class KWIN_EXPORT PlasmaVirtualDesktopInterface : public QObject 0096 { 0097 Q_OBJECT 0098 public: 0099 ~PlasmaVirtualDesktopInterface() override; 0100 0101 /** 0102 * @returns the unique id for this desktop. 0103 * ids are set at creation time by PlasmaVirtualDesktopManagementInterface::createDesktop 0104 * and can't be changed at runtime. 0105 */ 0106 QString id() const; 0107 0108 /** 0109 * Sets a new name for this desktop 0110 */ 0111 void setName(const QString &name); 0112 0113 /** 0114 * @returns the name for this desktop 0115 */ 0116 QString name() const; 0117 0118 /** 0119 * Set this desktop as active or not. 0120 * It's the compositor responsibility to manage the mutual exclusivity of active desktops. 0121 */ 0122 void setActive(bool active); 0123 0124 /** 0125 * @returns true if this desktop is active. Only one at a time will be. 0126 */ 0127 bool isActive() const; 0128 0129 /** 0130 * Inform the clients that all the properties have been sent, and 0131 * their client-side representation is complete. 0132 */ 0133 void sendDone(); 0134 0135 Q_SIGNALS: 0136 /** 0137 * Emitted when the client asked to activate this desktop: 0138 * it's the decision of the server whether to perform the activation or not. 0139 */ 0140 void activateRequested(); 0141 0142 private: 0143 PlasmaVirtualDesktopInterface(); 0144 friend class PlasmaVirtualDesktopManagementInterface; 0145 friend class PlasmaVirtualDesktopManagementInterfacePrivate; 0146 0147 std::unique_ptr<PlasmaVirtualDesktopInterfacePrivate> d; 0148 }; 0149 0150 }