-
Notifications
You must be signed in to change notification settings - Fork 2
/
embeddedshellsurface.cpp
188 lines (155 loc) · 6.13 KB
/
embeddedshellsurface.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
// SPDX-License-Identifier: LGPL-3.0-only
#include "embeddedshellsurface.h"
#include "embeddedshellsurface_p.h"
#include <QtWaylandClient/private/qwaylandwindow_p.h>
#include <qpa/qplatformwindow.h>
#include <qpa/qwindowsysteminterface.h>
EmbeddedShellSurface::EmbeddedShellSurface(
struct ::embedded_shell_surface *shell_surface,
QtWaylandClient::QWaylandWindow *window, const QSize &size, EmbeddedShellTypes::Anchor anchor,
uint32_t margin, uint32_t sort_index)
: d_ptr(new EmbeddedShellSurfacePrivate(shell_surface, window, size, anchor,
margin, sort_index)) {}
EmbeddedShellSurface::~EmbeddedShellSurface() {}
EmbeddedShellSurfacePrivate::EmbeddedShellSurfacePrivate(
struct ::embedded_shell_surface *shell_surface,
QtWaylandClient::QWaylandWindow *window, const QSize &size, EmbeddedShellTypes::Anchor anchor,
uint32_t margin, uint32_t sort_index)
: QWaylandShellSurface(window), QtWayland::embedded_shell_surface(
shell_surface),
m_size(size), m_anchor(anchor), m_margin(margin), m_sort_index(sort_index) {}
EmbeddedShellSurfacePrivate::~EmbeddedShellSurfacePrivate() {}
QSize EmbeddedShellSurface::getSize() const {
Q_D(const EmbeddedShellSurface);
return d->m_size;
}
EmbeddedShellTypes::Anchor EmbeddedShellSurface::getAnchor() const {
Q_D(const EmbeddedShellSurface);
return d->m_anchor;
}
unsigned int EmbeddedShellSurface::getSortIndex() const {
Q_D(const EmbeddedShellSurface);
return d->m_sort_index;
}
void EmbeddedShellSurfacePrivate::applyConfigure() {
window()->resizeFromApplyConfigure(m_pendingSize);
}
void EmbeddedShellSurfacePrivate::embedded_shell_surface_configure(
int32_t width, int32_t height) {
m_pendingSize = {width, height};
window()->applyConfigureWhenPossible();
}
EmbeddedShellSurfaceView *EmbeddedShellSurface::createView(const QString &label,
const QString &icon,
uint32_t sort_index)
{
return createView(QString(), QString(), QString(), label, icon, sort_index);
}
EmbeddedShellSurfaceView *EmbeddedShellSurface::createView(const QString &appId,
const QString &label,
const QString &icon,
uint32_t sort_index)
{
return createView(appId, QString(), QString(), label, icon, sort_index);
}
EmbeddedShellSurfaceView *EmbeddedShellSurface::createView(const QString &appId,
const QString &appLabel,
const QString &appIcon,
const QString &label,
const QString &icon,
uint32_t sort_index)
{
Q_D(EmbeddedShellSurface);
auto view =
d->view_create(d->embedded_shell_surface::object(), appId, appLabel, appIcon, label, icon, sort_index);
auto ret = new EmbeddedShellSurfaceView(view, this);
auto *viewPrivate = EmbeddedShellSurfaceViewPrivate::get(ret);
viewPrivate->m_appLabel = appLabel;
viewPrivate->m_appIcon = appIcon;
viewPrivate->m_label = label;
viewPrivate->m_icon = icon;
return ret;
}
QtWaylandClient::QWaylandShellSurface *EmbeddedShellSurface::shellSurface() {
return d_ptr.data();
}
void EmbeddedShellSurface::sendSize(const QSize &size) {
Q_D(EmbeddedShellSurface);
// Check version here if it were versioned.
d->set_size(size.width(), size.height());
}
void EmbeddedShellSurface::sendAnchor(EmbeddedShellTypes::Anchor anchor) {
Q_D(EmbeddedShellSurface);
d->set_anchor(static_cast<embedded_shell_anchor_border>(anchor));
}
void EmbeddedShellSurface::sendMargin(int margin) {
Q_D(EmbeddedShellSurface);
d->set_margin(margin);
}
void EmbeddedShellSurface::sendSortIndex(unsigned int sortIndex) {
Q_D(EmbeddedShellSurface);
d->set_sort_index(sortIndex);
}
EmbeddedShellSurfaceViewPrivate::EmbeddedShellSurfaceViewPrivate(
EmbeddedShellSurfaceView *q, ::surface_view *view,
EmbeddedShellSurface *surf)
: QObject(surf), QtWayland::surface_view(view), q_ptr(q) {}
EmbeddedShellSurfaceViewPrivate::~EmbeddedShellSurfaceViewPrivate() {
destroy();
}
EmbeddedShellSurfaceViewPrivate *EmbeddedShellSurfaceViewPrivate::get(EmbeddedShellSurfaceView *q)
{
return q->d_func();
}
EmbeddedShellSurfaceView::EmbeddedShellSurfaceView(::surface_view *view,
EmbeddedShellSurface *surf)
: d_ptr(new EmbeddedShellSurfaceViewPrivate(this, view, surf)) {}
EmbeddedShellSurfaceView::~EmbeddedShellSurfaceView() {}
QString EmbeddedShellSurfaceView::appLabel() const {
Q_D(const EmbeddedShellSurfaceView);
return d->m_appLabel;
}
void EmbeddedShellSurfaceView::setAppLabel(const QString &appLabel) {
Q_D(EmbeddedShellSurfaceView);
if (d->m_appLabel == appLabel)
return;
d->m_appLabel = appLabel;
d->set_app_label(appLabel);
Q_EMIT appLabelChanged(appLabel);
}
QString EmbeddedShellSurfaceView::appIcon() const {
Q_D(const EmbeddedShellSurfaceView);
return d->m_appIcon;
}
void EmbeddedShellSurfaceView::setAppIcon(const QString &appIcon) {
Q_D(EmbeddedShellSurfaceView);
if (d->m_appIcon == appIcon)
return;
d->m_appIcon = appIcon;
d->set_app_icon(appIcon);
Q_EMIT appIconChanged(appIcon);
}
QString EmbeddedShellSurfaceView::label() const {
Q_D(const EmbeddedShellSurfaceView);
return d->m_label;
}
void EmbeddedShellSurfaceView::setLabel(const QString &label) {
Q_D(EmbeddedShellSurfaceView);
if (d->m_label == label)
return;
d->m_label = label;
d->set_label(label);
Q_EMIT labelChanged(label);
}
QString EmbeddedShellSurfaceView::icon() const {
Q_D(const EmbeddedShellSurfaceView);
return d->m_icon;
}
void EmbeddedShellSurfaceView::setIcon(const QString &icon) {
Q_D(EmbeddedShellSurfaceView);
if (d->m_icon == icon)
return;
d->m_icon = icon;
d->set_icon(icon);
Q_EMIT iconChanged(icon);
}