Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qwaylandsurface.cpp
Go to the documentation of this file.
1// Copyright (C) 2019 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
4#include "qwaylandsurface_p.h"
5#include "qwaylanddisplay_p.h"
6#include "qwaylandscreen_p.h"
7
8#include <QtGui/QGuiApplication>
9
11
12namespace QtWaylandClient {
13
15 : wl_surface(display->createSurface(this))
16{
17 connect(qApp, &QGuiApplication::screenRemoved, this, &QWaylandSurface::handleScreenRemoved);
18}
19
21{
22 destroy();
23}
24
26{
27 return m_screens.value(0, nullptr);
28}
29
31{
32 if (auto *s = QtWayland::wl_surface::fromObject(surface))
33 return static_cast<QWaylandSurface *>(s);
34 return nullptr;
35}
36
37void QWaylandSurface::handleScreenRemoved(QScreen *qScreen)
38{
39 auto *platformScreen = qScreen->handle();
40 if (platformScreen->isPlaceholder())
41 return;
42
43 auto *waylandScreen = static_cast<QWaylandScreen *>(qScreen->handle());
44 if (m_screens.removeOne(waylandScreen))
46}
47
49{
50 auto addedScreen = QWaylandScreen::fromWlOutput(output);
51
52 if (!addedScreen)
53 return;
54
55 if (m_screens.contains(addedScreen)) {
56 qCWarning(lcQpaWayland)
57 << "Ignoring unexpected wl_surface.enter received for output with id:"
58 << wl_proxy_get_id(reinterpret_cast<wl_proxy *>(output))
59 << "screen name:" << addedScreen->name() << "screen model:" << addedScreen->model()
60 << "This is most likely a bug in the compositor.";
61 return;
62 }
63
64 m_screens.append(addedScreen);
66}
67
69{
70 auto *removedScreen = QWaylandScreen::fromWlOutput(output);
71
72 if (!removedScreen)
73 return;
74
75 bool wasRemoved = m_screens.removeOne(removedScreen);
76 if (!wasRemoved) {
77 qCWarning(lcQpaWayland)
78 << "Ignoring unexpected wl_surface.leave received for output with id:"
79 << wl_proxy_get_id(reinterpret_cast<wl_proxy *>(output))
80 << "screen name:" << removedScreen->name()
81 << "screen model:" << removedScreen->model()
82 << "This is most likely a bug in the compositor.";
83 return;
84 }
86}
87
95
103
104} // namespace QtWaylandClient
105
107
108#include "moc_qwaylandsurface_p.cpp"
void screenRemoved(QScreen *screen)
This signal is emitted whenever a screen is removed from the system.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
The QScreen class is used to query screen properties. \inmodule QtGui.
Definition qscreen.h:32
QWaylandSurface()
Constructs a an uninitialized QWaylandSurface.
static QWaylandScreen * fromWlOutput(::wl_output *output)
QList< QWaylandScreen * > m_screens
void surface_enter(struct ::wl_output *output) override
std::optional< wl_output_transform > m_preferredBufferTransform
void surface_preferred_buffer_transform(uint32_t transform) override
void surface_leave(struct ::wl_output *output) override
static QWaylandSurface * fromWlSurface(::wl_surface *surface)
std::optional< int32_t > m_preferredBufferScale
void surface_preferred_buffer_scale(int32_t scale) override
#define this
Definition dialogs.cpp:9
struct wl_display * display
Definition linuxdmabuf.h:41
Combined button and popup list for selecting options.
#define qApp
#define qCWarning(category,...)
GLuint GLenum GLenum transform
GLdouble s
[6]
Definition qopenglext.h:235
GLenum GLenum GLenum GLenum GLenum scale
#define Q_EMIT
#define emit
QT_BEGIN_NAMESPACE typedef uchar * output