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
qwaylandscreen.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
6
11
12#include <QtGui/QGuiApplication>
13
14#include <qpa/qwindowsysteminterface.h>
15#include <qpa/qplatformwindow.h>
16
18
19namespace QtWaylandClient {
20
25
30
33 , m_outputId(id)
35 , mOutputName(QStringLiteral("Screen%1").arg(id))
36{
39
41 qCWarning(lcQpaWayland) << "wl_output done event not supported by compositor,"
42 << "QScreen may not work correctly";
43 mWaylandDisplay->forceRoundTrip(); // Give the compositor a chance to send geometry etc.
44 mProcessedEvents |= OutputDoneEvent; // Fake the done event
46 }
47}
48
58
60{
62
66
67 // For objects version 3 onwards, zxdg_output_v1.done is deprecated.
70 }
71 return ret;
72}
73
89
98
100{
101 return mWaylandDisplay;
102}
103
105{
106 return mManufacturer;
107}
108
110{
111 return mModel;
112}
113
115{
117
118 // Workaround for Gnome bug
119 // https://gitlab.gnome.org/GNOME/mutter/-/issues/2631
120 // which sends an incorrect xdg geometry
121 const bool xdgGeometryIsBogus = mScale > 1 && mXdgGeometry.size() == mGeometry.size();
122
123 if (!xdgGeometryIsBogus) {
124 return mXdgGeometry;
125 }
126 }
127 // Scale geometry for QScreen. This makes window and screen
128 // geometry be in the same coordinate system.
130}
131
133{
134 return mDepth;
135}
136
138{
139 return mFormat;
140}
141
143{
146 else
147 return mPhysicalSize;
148}
149
151{
152 static bool physicalDpi = qEnvironmentVariable("QT_WAYLAND_FORCE_DPI") == QStringLiteral("physical");
153 if (physicalDpi)
154 return QPlatformScreen::logicalDpi();
155
156 static int forceDpi = qgetenv("QT_WAYLAND_FORCE_DPI").toInt();
157 if (forceDpi)
158 return QDpi(forceDpi, forceDpi);
159
160 return QDpi(96, 96);
161}
162
164{
168
169 list.reserve(screens.size() + (placeholder ? 1 : 0));
170
172 if (screen->screen())
173 list << screen;
174 }
175
176 if (placeholder)
177 list << placeholder;
178
179 return list;
180}
181
186
188{
189 return mScale;
190}
191
193{
194 return qreal(mScale);
195}
196
198{
199 return mRefreshRate / 1000.f;
200}
201
202#if QT_CONFIG(cursor)
204{
206}
207#endif // QT_CONFIG(cursor)
208
234
242
244{
245 if (auto *o = QtWayland::wl_output::fromObject(output))
246 return static_cast<QWaylandScreen *>(o);
247 return nullptr;
248}
249
278
280{
282 return;
283
285 if (size != mGeometry.size())
287
288 if (refresh != mRefreshRate)
290}
291
308
313
326
328{
330 qCWarning(lcQpaWayland) << "wl_output.name received after output has been initialized, this is most likely a bug in the compositor";
331 return;
332 }
333
335 qCWarning(lcQpaWayland) << "wl_output.name received more than once, this is most likely a bug in the compositor";
336 return;
337 }
338
339 if (!name.isEmpty())
341
343}
344
363
364
369
374
376{
378 qCWarning(lcQpaWayland) << "zxdg_output_v1.done received on version 3 or newer, this is most likely a bug in the compositor";
379
381 if (mInitialized)
383 else
385}
386
388{
390 qCWarning(lcQpaWayland) << "zxdg_output_v1.name received after output has been initialized, this is most likely a bug in the compositor";
391
393 qCWarning(lcQpaWayland) << "zxdg_output_v1.name received more than once, this is most likely a bug in the compositor";
394 return;
395 }
396
397 // This event is deprecated, instead clients should use wl_output.name.
399 if (!name.isEmpty())
401 }
402
404}
405
412
413} // namespace QtWaylandClient
414
415QT_END_NAMESPACE
Combined button and popup list for selecting options.