Debian Codegraph @

panel/backends/wayland/wlroots/workspace.hpp

raw
1 #pragma once
2
3 #include <QObject>
4 #include <QString>
5 #include <QList>
6 #include <QScreen>
7 #include <QPointer>
8
9 #include <string>
10 #include "wayland-ext-workspace-v1-client-protocol.h"
11 #include "qwayland-ext-workspace-v1.h"
12
13 #include <QWaylandClientExtension>
14
15 struct wl_registry;
16
17 namespace LXQt
18 {
19 namespace Taskbar
20 {
21 class WorkspaceManagerV1;
22 class WorkspaceGroupHandleV1;
23 class WorkspaceHandleV1;
24 }
25 }
26
27 class LXQt::Taskbar::WorkspaceManagerV1 : public QWaylandClientExtensionTemplate<LXQt::Taskbar::WorkspaceManagerV1>,
28 public QtWayland::ext_workspace_manager_v1
29 {
30 Q_OBJECT
31
32 public:
33 static constexpr int version = 16;
34
35 WorkspaceManagerV1();
36 virtual ~WorkspaceManagerV1();
37
38 int workspaceCount(QScreen *screen = nullptr);
39 int currentWorkspaceIndex(QScreen *screen = nullptr);
40 QString workspaceName(int idx, const QString &sceenName);
41 void setCurrentWorkspaceIndex(int idx = 0, QScreen *screen = nullptr);
42
43 Q_SIGNAL void workspaceGroupAdded(WorkspaceGroupHandleV1 *workspace_group);
44 Q_SIGNAL void workspaceAdded(WorkspaceHandleV1 *workspace);
45 Q_SIGNAL void workspaceRemoved(WorkspaceHandleV1 *workspace);
46 Q_SIGNAL void nameChanged();
47
48 /** A workspace became active or inactive. */
49 Q_SIGNAL void currentWorkspaceChanged(const QList<QScreen*> &screens);
50 Q_SIGNAL void activation();
51
52 Q_SIGNAL void done();
53 Q_SIGNAL void finished();
54
55 protected:
56 virtual void ext_workspace_manager_v1_workspace_group(
57 struct ::ext_workspace_group_handle_v1 *workspace_group);
58 virtual void ext_workspace_manager_v1_workspace(struct ::ext_workspace_handle_v1 *workspace);
59 virtual void ext_workspace_manager_v1_done();
60 virtual void ext_workspace_manager_v1_finished();
61 };
62
63 class LXQt::Taskbar::WorkspaceGroupHandleV1 : public QObject, public QtWayland::ext_workspace_group_handle_v1
64 {
65 Q_OBJECT
66
67 public:
68 WorkspaceGroupHandleV1(struct ::ext_workspace_group_handle_v1 *object);
69 virtual ~WorkspaceGroupHandleV1();
70
71 bool canCreateWorkspace() const;
72
73 QList<struct ::wl_output*> outputs() const {
74 return m_outputs;
75 }
76
77 QList<QPointer<WorkspaceHandleV1>> workspaces() const {
78 return m_workspaces;
79 }
80
81 /**
82 * Note: QtWayland::ext_workspace_group_handle_v1 has following member functions:
83 * - create_workspace( QString )
84 * - destroy()
85 * - object() -> struct ::ext_workspace_group_handle_v1 *
86 * These functions are complete, and we do not have to re-implement them here.
87 */
88
89 Q_SIGNAL void capabilities(uint32_t capabilities);
90 Q_SIGNAL void outputEnter(struct ::wl_output *output);
91 Q_SIGNAL void outputLeave(struct ::wl_output *output);
92 Q_SIGNAL void workspaceAdded(WorkspaceHandleV1 *workspace);
93 Q_SIGNAL void workspaceRemoved(WorkspaceHandleV1 *workspace);
94 Q_SIGNAL void removed();
95
96 protected:
97 virtual void ext_workspace_group_handle_v1_capabilities(uint32_t capabilities);
98 virtual void ext_workspace_group_handle_v1_output_enter(struct ::wl_output *output);
99 virtual void ext_workspace_group_handle_v1_output_leave(struct ::wl_output *output);
100 virtual void ext_workspace_group_handle_v1_workspace_enter(struct ::ext_workspace_handle_v1 *workspace);
101 virtual void ext_workspace_group_handle_v1_workspace_leave(struct ::ext_workspace_handle_v1 *workspace);
102 virtual void ext_workspace_group_handle_v1_removed();
103
104 private:
105 /** Track on which outputs this workspace group is visible */
106 QList<struct ::wl_output*> m_outputs;
107
108 /** Store the capabilities */
109 uint32_t m_supported_capabilities;
110
111 /** Track workspaces that are a part of this workspace group */
112 QList<QPointer<WorkspaceHandleV1>> m_workspaces;
113 };
114
115 class LXQt::Taskbar::WorkspaceHandleV1 : public QObject, public QtWayland::ext_workspace_handle_v1
116 {
117 Q_OBJECT
118
119 public:
120 WorkspaceHandleV1(struct ::ext_workspace_handle_v1 *object, int index);
121 virtual ~WorkspaceHandleV1();
122
123 /**
124 * Note: QtWayland::ext_workspace_group_handle_v1 has following member functions:
125 * - object() -> struct ::ext_workspace_group_handle_v1 *
126 * - destroy();
127 * - activate();
128 * - deactivate();
129 * - assign(struct ::ext_workspace_group_handle_v1 *workspace_group);
130 * - remove();
131 * These functions are complete, and we do not have to re-implement them here.
132 */
133
134 QString id() const;
135 QString name() const;
136 QList<int> coordinates() const;
137 uint32_t state() const;
138 uint32_t capabilities() const;
139
140 Q_SIGNAL void idChanged(const QString& id);
141 Q_SIGNAL void nameChanged(const QString& name);
142 Q_SIGNAL void coordinatesChanged(QList<int> coordinates);
143 Q_SIGNAL void stateChanged(uint32_t state);
144 Q_SIGNAL void capabilitiesChanged(uint32_t capabilities);
145 Q_SIGNAL void removed();
146
147 /** This workspace just became active */
148 Q_SIGNAL void activated();
149
150 /** This workspace was just deactived */
151 Q_SIGNAL void deactivated();
152
153 protected:
154 virtual void ext_workspace_handle_v1_id(const QString& id);
155 virtual void ext_workspace_handle_v1_name(const QString& name);
156 virtual void ext_workspace_handle_v1_coordinates(wl_array *coordinates);
157 virtual void ext_workspace_handle_v1_state(uint32_t state);
158 virtual void ext_workspace_handle_v1_capabilities(uint32_t capabilities);
159 virtual void ext_workspace_handle_v1_removed();
160
161 private:
162 QString m_id;
163 QString m_name;
164 QList<int> m_coordinates;
165 uint32_t m_state = 0;
166 uint32_t m_capabilities;
167 };