File indexing completed on 2024-05-05 05:38:37
0001 /* 0002 SPDX-FileCopyrightText: 2016 Eike Hein <hein@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #pragma once 0008 0009 #include <QObject> 0010 0011 #include "taskmanager_export.h" 0012 0013 namespace TaskManager 0014 { 0015 /** 0016 * @short Provides basic virtual desktop information. The underlying windowing 0017 * system is abstracted away. 0018 * 0019 * This class provides basic information about the virtual desktops present 0020 * in the session as a set of notifiable properties. 0021 * 0022 * @author Eike Hein <hein@kde.org> 0023 **/ 0024 0025 class TASKMANAGER_EXPORT VirtualDesktopInfo : public QObject 0026 { 0027 Q_OBJECT 0028 0029 Q_PROPERTY(QVariant currentDesktop READ currentDesktop NOTIFY currentDesktopChanged) 0030 Q_PROPERTY(int numberOfDesktops READ numberOfDesktops NOTIFY numberOfDesktopsChanged) 0031 Q_PROPERTY(QVariantList desktopIds READ desktopIds NOTIFY desktopIdsChanged) 0032 Q_PROPERTY(QStringList desktopNames READ desktopNames NOTIFY desktopNamesChanged) 0033 Q_PROPERTY(int desktopLayoutRows READ desktopLayoutRows NOTIFY desktopLayoutRowsChanged) 0034 Q_PROPERTY(int navigationWrappingAround READ navigationWrappingAround NOTIFY navigationWrappingAroundChanged) 0035 0036 public: 0037 explicit VirtualDesktopInfo(QObject *parent = nullptr); 0038 ~VirtualDesktopInfo() override; 0039 0040 /** 0041 * The currently active virtual desktop. 0042 * 0043 * @returns the id of the currently active virtual desktop. QString on 0044 * Wayland; uint >0 on X11. 0045 **/ 0046 QVariant currentDesktop() const; 0047 0048 /** 0049 * The number of virtual desktops present in the session. 0050 * 0051 * @returns the number of virtual desktops present in the session. 0052 **/ 0053 int numberOfDesktops() const; 0054 0055 /** 0056 * The ids of all virtual desktops present in the session. 0057 * 0058 * On Wayland, the ids are QString. On X11, they are uint >0. 0059 * 0060 * @returns a the list of ids of the virtual desktops present in the 0061 * session. 0062 **/ 0063 QVariantList desktopIds() const; 0064 0065 /** 0066 * The names of all virtual desktops present in the session. 0067 * 0068 * Note that on X11, virtual desktops are indexed starting at 1, so 0069 * the name for virtual desktop 1 is at index 0 in this list. 0070 * 0071 * @returns the list of names of the virtual desktops present in the 0072 * session. 0073 **/ 0074 QStringList desktopNames() const; 0075 0076 /** 0077 * Returns the position of the passed-in virtual desktop. 0078 * @param desktop A virtual desktop id (QString on Wayland; uint >0 on X11). 0079 * @returns the position of the virtual desktop, or -1 if the desktop 0080 * id is not valid. 0081 **/ 0082 quint32 position(const QVariant &desktop) const; 0083 0084 /** 0085 * The number of rows in the virtual desktop layout. 0086 * 0087 * @returns the number of rows in the virtual desktop layout. 0088 **/ 0089 int desktopLayoutRows() const; 0090 0091 /** 0092 * Request activating the passed-in virtual desktop. 0093 * 0094 * @param desktop A virtual desktop id (QString on Wayland; uint >0 on X11). 0095 **/ 0096 void requestActivate(const QVariant &desktop); 0097 0098 /** 0099 * Request adding a new virtual desktop at the specified position. 0100 * 0101 * On X11, the position parameter is ignored and the new desktop is always 0102 * created at the end of the list. 0103 * 0104 * @param position The position of the requested new virtual desktop (ignored on X11). 0105 **/ 0106 void requestCreateDesktop(quint32 position); 0107 0108 /** 0109 * Request removing the virtual desktop at the specified position. 0110 * 0111 * On X11, the position parameter is ignored and the last desktop in the list 0112 * is always the one removed. 0113 * 0114 * @param position The position of the virtual desktop to remove (ignored on X11). 0115 **/ 0116 void requestRemoveDesktop(quint32 position); 0117 0118 /** 0119 * Whether or not to wrap navigation such that activating the next virtual 0120 * desktop when at the last one will go to the first one, and activating the 0121 * previous virtual desktop when at the first one will go to the last one. 0122 */ 0123 bool navigationWrappingAround() const; 0124 0125 Q_SIGNALS: 0126 void currentDesktopChanged() const; 0127 void numberOfDesktopsChanged() const; 0128 void desktopIdsChanged() const; 0129 void desktopNamesChanged() const; 0130 void desktopLayoutRowsChanged() const; 0131 void navigationWrappingAroundChanged() const; 0132 0133 private: 0134 class Private; 0135 class XWindowPrivate; 0136 class WaylandPrivate; 0137 static Private *d; 0138 }; 0139 0140 }