Plasma-workspace

virtualdesktopinfo.h
1/*
2 SPDX-FileCopyrightText: 2016 Eike Hein <hein@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#pragma once
8
9#include <QObject>
10#include <qqmlregistration.h>
11
12#include "taskmanager_export.h"
13
14namespace TaskManager
15{
16/**
17 * @short Provides basic virtual desktop information. The underlying windowing
18 * system is abstracted away.
19 *
20 * This class provides basic information about the virtual desktops present
21 * in the session as a set of notifiable properties.
22 *
23 * @author Eike Hein <hein@kde.org>
24 **/
25
26class TASKMANAGER_EXPORT VirtualDesktopInfo : public QObject
27{
28 Q_OBJECT
29 QML_ELEMENT
30
31 Q_PROPERTY(QVariant currentDesktop READ currentDesktop NOTIFY currentDesktopChanged)
32 Q_PROPERTY(int numberOfDesktops READ numberOfDesktops NOTIFY numberOfDesktopsChanged)
33 Q_PROPERTY(QVariantList desktopIds READ desktopIds NOTIFY desktopIdsChanged)
34 Q_PROPERTY(QStringList desktopNames READ desktopNames NOTIFY desktopNamesChanged)
35 Q_PROPERTY(int desktopLayoutRows READ desktopLayoutRows NOTIFY desktopLayoutRowsChanged)
36 Q_PROPERTY(int navigationWrappingAround READ navigationWrappingAround NOTIFY navigationWrappingAroundChanged)
37
38public:
39 explicit VirtualDesktopInfo(QObject *parent = nullptr);
40 ~VirtualDesktopInfo() override;
41
42 /**
43 * The currently active virtual desktop.
44 *
45 * @returns the id of the currently active virtual desktop. QString on
46 * Wayland; uint >0 on X11.
47 **/
48 QVariant currentDesktop() const;
49
50 /**
51 * The number of virtual desktops present in the session.
52 *
53 * @returns the number of virtual desktops present in the session.
54 **/
55 int numberOfDesktops() const;
56
57 /**
58 * The ids of all virtual desktops present in the session.
59 *
60 * On Wayland, the ids are QString. On X11, they are uint >0.
61 *
62 * @returns a the list of ids of the virtual desktops present in the
63 * session.
64 **/
65 QVariantList desktopIds() const;
66
67 /**
68 * The names of all virtual desktops present in the session.
69 *
70 * Note that on X11, virtual desktops are indexed starting at 1, so
71 * the name for virtual desktop 1 is at index 0 in this list.
72 *
73 * @returns the list of names of the virtual desktops present in the
74 * session.
75 **/
76 QStringList desktopNames() const;
77
78 /**
79 * Returns the position of the passed-in virtual desktop.
80 * @param desktop A virtual desktop id (QString on Wayland; uint >0 on X11).
81 * @returns the position of the virtual desktop, or -1 if the desktop
82 * id is not valid.
83 **/
84 quint32 position(const QVariant &desktop) const;
85
86 /**
87 * The number of rows in the virtual desktop layout.
88 *
89 * @returns the number of rows in the virtual desktop layout.
90 **/
91 int desktopLayoutRows() const;
92
93 /**
94 * Request activating the passed-in virtual desktop.
95 *
96 * @param desktop A virtual desktop id (QString on Wayland; uint >0 on X11).
97 **/
98 void requestActivate(const QVariant &desktop);
99
100 /**
101 * Request adding a new virtual desktop at the specified position.
102 *
103 * On X11, the position parameter is ignored and the new desktop is always
104 * created at the end of the list.
105 *
106 * @param position The position of the requested new virtual desktop (ignored on X11).
107 **/
108 void requestCreateDesktop(quint32 position);
109
110 /**
111 * Request removing the virtual desktop at the specified position.
112 *
113 * On X11, the position parameter is ignored and the last desktop in the list
114 * is always the one removed.
115 *
116 * @param position The position of the virtual desktop to remove (ignored on X11).
117 **/
118 void requestRemoveDesktop(quint32 position);
119
120 /**
121 * Whether or not to wrap navigation such that activating the next virtual
122 * desktop when at the last one will go to the first one, and activating the
123 * previous virtual desktop when at the first one will go to the last one.
124 */
125 bool navigationWrappingAround() const;
126
127Q_SIGNALS:
128 void currentDesktopChanged() const;
129 void numberOfDesktopsChanged() const;
130 void desktopIdsChanged() const;
131 void desktopNamesChanged() const;
132 void desktopLayoutRowsChanged() const;
133 void navigationWrappingAroundChanged() const;
134
135private:
136 class Private;
137 class XWindowPrivate;
138 class WaylandPrivate;
139 static Private *d;
140};
141
142}
Provides basic virtual desktop information.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 12:00:00 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.