Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwaylanddecorationhandler.cpp
Go to the documentation of this file.
1// Copyright (C) 2025
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
6
14
15#include <QtGui/QImage>
16#include <QtGui/QPainter>
17#include <QtCore/QThread>
18#include <QtGui/private/qguiapplication_p.h>
19#include <QGuiApplication>
20
21QT_BEGIN_NAMESPACE
22
23using namespace Qt::StringLiterals;
24
25namespace QtWaylandClient {
26
28{
29 if (!subsurface)
30 return;
31
33 delete subsurface;
34}
35
40
44
55
60
62{
64 "QWaylandDecorationHandler::createDecoration", "not called from main thread");
66 return;
67
68 static bool decorationPluginFailed = false;
69 bool decoration = false;
70 switch (mWindow->window()->type()) {
71 case Qt::Window:
72 case Qt::Widget:
73 case Qt::Dialog:
74 case Qt::Tool:
75 case Qt::Drawer:
76 decoration = true;
77 break;
78 default:
79 break;
80 }
82 decoration = false;
84 decoration = false;
86 decoration = false;
88 decoration = false;
89
94 }
95
97 if (decorations.empty()) {
98 qWarning() << "No decoration plugins available. Running with no decorations.";
100 return;
101 }
102
104
105 QByteArray decorationPluginName = qgetenv("QT_WAYLAND_DECORATION");
109 qWarning() << "Requested decoration " << targetKey << " not found, falling back to default";
110 targetKey = QString(); // fallthrough
111 }
112 }
113
114 if (targetKey.isEmpty()) {
115 auto unixServices = dynamic_cast<QDesktopUnixServices *>(
118 if (desktopNames.contains("GNOME")) {
119 if (decorations.contains("adwaita"_L1))
120 targetKey = "adwaita"_L1;
121 else if (decorations.contains("gnome"_L1))
122 targetKey = "gnome"_L1;
123 } else {
124 // Do not use Adwaita/GNOME decorations on other DEs
125 decorations.removeAll("adwaita"_L1);
126 decorations.removeAll("gnome"_L1);
127 }
128 }
129
130 if (targetKey.isEmpty())
131 targetKey = decorations.first(); // first come, first served.
132
134 if (!mWindowDecoration) {
135 qWarning() << "Could not create decoration from factory! Running with no decorations.";
137 return;
138 }
139
142 }
143 } else {
144 reset();
145 }
146
147 return;
148}
149
150
152{
155 if (!decoration->isDirty())
156 return;
157
158 auto margins = decoration->margins();
160 const int top = margins.top();
161 const int bottom = margins.bottom();
162 const int left = margins.left();
163 const int right = margins.right();
164 const int sideHeight = mWindow->geometry().height();
165
168 QRect(0, 0, imageSize.width(), top),
171 QRect(-left, 0, left, sideHeight),
172 QRect(0, top, left, sideHeight),
182
183 const auto paintTile = [](const std::unique_ptr<QWaylandDecorationSurface> &surface) {
184 return !surface || surface->paint();
185 };
186
187 // if any buffer is busy, try again later
193 return;
194 }
195
197}
198
199
201 const QRect &windowGeometry,
202 const QRect &paintGeometry,
204{
205 if (paintGeometry.isEmpty()) {
206 surface.reset();
207 return;
208 }
209
210 if (!surface)
212
214}
215
233
237
247
249{
250 auto *buffer = mBackBuffer.get();
251 if (!buffer) {
252 return true;
253 }
254 if (buffer->busy())
255 return false;
256
259 switch (mPart) {
260 case Part::Top:
262 break;
263 case Part::Left:
265 break;
266 case Part::Right:
268 break;
269 case Part::Bottom:
271 break;
272 }
273 painter.end();
274
277 mSurface->commit();
279 return true;
280}
281
283{
285 qreal scale = 1.0;
286 if (mViewport)
288
289 const QSize bufferSize = size * scale;
291 return;
292 }
295}
296
305
310
311
312
313} // namespace QtWaylandClient
314
315QT_END_NAMESPACE