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

KDE's Doxygen guidelines are available online.