Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
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
// Qt-Security score:significant reason:default
4
5
#
include
"qwaylandsurface_p.h"
6
#
include
"qwaylanddisplay_p.h"
7
#
include
"qwaylandscreen_p.h"
8
9
#
include
<
QtGui
/
QGuiApplication
>
10
11
QT_BEGIN_NAMESPACE
12
13
namespace
QtWaylandClient
{
14
15
QWaylandSurface
::QWaylandSurface(QWaylandDisplay *display)
16
: wl_surface(display->createSurface(
this
))
17
{
18
connect(qApp, &QGuiApplication::screenRemoved,
this
, &QWaylandSurface::handleScreenRemoved);
19
connect(qApp, &QGuiApplication::screenAdded,
this
, &QWaylandSurface::screensChanged);
20
}
21
22
QWaylandSurface
::~
QWaylandSurface
()
23
{
24
destroy();
25
}
26
27
QWaylandScreen *
QWaylandSurface
::
oldestEnteredScreen
()
28
{
29
for
(
auto
*screen : std::as_const(m_screens)) {
30
// only report valid screens
31
// we can have some ouptuts waiting for xdg output information
32
// that are valid QPlatformScreens, but not valid QScreens
33
if
(screen->screen())
34
return
screen;
35
}
36
return
nullptr
;
37
}
38
39
QWaylandSurface
*
QWaylandSurface
::fromWlSurface(::wl_surface *surface)
40
{
41
if
(
auto
*s = QtWayland::wl_surface::fromObject(surface))
42
return
static_cast
<
QWaylandSurface
*>(s);
43
return
nullptr
;
44
}
45
46
void
QWaylandSurface
::handleScreenRemoved(QScreen *qScreen)
47
{
48
auto
*platformScreen = qScreen->handle();
49
if
(platformScreen->isPlaceholder())
50
return
;
51
52
auto
*waylandScreen =
static_cast
<QWaylandScreen *>(qScreen->handle());
53
if
(m_screens.removeOne(waylandScreen))
54
emit screensChanged();
55
}
56
57
void
QWaylandSurface
::surface_enter(wl_output *output)
58
{
59
if
(!output)
60
return
;
61
62
auto
addedScreen = QWaylandScreen::fromWlOutput(output);
63
if
(!addedScreen)
64
return
;
65
66
if
(m_screens.contains(addedScreen)) {
67
qCWarning(lcQpaWayland)
68
<<
"Ignoring unexpected wl_surface.enter received for output with id:"
69
<< wl_proxy_get_id(
reinterpret_cast
<wl_proxy *>(output))
70
<<
"screen name:"
<< addedScreen->name() <<
"screen model:"
<< addedScreen->model()
71
<<
"This is most likely a bug in the compositor."
;
72
return
;
73
}
74
75
m_screens.append(addedScreen);
76
emit screensChanged();
77
}
78
79
void
QWaylandSurface
::surface_leave(wl_output *output)
80
{
81
if
(!output)
82
return
;
83
84
auto
*removedScreen = QWaylandScreen::fromWlOutput(output);
85
if
(!removedScreen)
86
return
;
87
88
bool
wasRemoved = m_screens.removeOne(removedScreen);
89
if
(!wasRemoved) {
90
qCWarning(lcQpaWayland)
91
<<
"Ignoring unexpected wl_surface.leave received for output with id:"
92
<< wl_proxy_get_id(
reinterpret_cast
<wl_proxy *>(output))
93
<<
"screen name:"
<< removedScreen->name()
94
<<
"screen model:"
<< removedScreen->model()
95
<<
"This is most likely a bug in the compositor."
;
96
return
;
97
}
98
emit screensChanged();
99
}
100
101
void
QWaylandSurface
::
surface_preferred_buffer_scale
(int32_t scale)
102
{
103
if
(m_preferredBufferScale == scale)
104
return
;
105
m_preferredBufferScale = scale;
106
Q_EMIT preferredBufferScaleChanged();
107
}
108
109
void
QWaylandSurface
::
surface_preferred_buffer_transform
(uint32_t transform)
110
{
111
if
(m_preferredBufferTransform == transform)
112
return
;
113
m_preferredBufferTransform =
static_cast
<wl_output_transform>(transform);
114
Q_EMIT preferredBufferTransformChanged();
115
}
116
117
}
// namespace QtWaylandClient
118
119
QT_END_NAMESPACE
120
121
#
include
"moc_qwaylandsurface_p.cpp"
QtWaylandClient::QWaylandSurface
Definition
qwaylandsurface_p.h:37
QtWaylandClient::QWaylandSurface::~QWaylandSurface
~QWaylandSurface() override
Definition
qwaylandsurface.cpp:22
QtWaylandClient::QWaylandSurface::surface_preferred_buffer_transform
void surface_preferred_buffer_transform(uint32_t transform) override
Definition
qwaylandsurface.cpp:109
QtWaylandClient::QWaylandSurface::oldestEnteredScreen
QWaylandScreen * oldestEnteredScreen()
Definition
qwaylandsurface.cpp:27
QtWaylandClient::QWaylandSurface::surface_preferred_buffer_scale
void surface_preferred_buffer_scale(int32_t scale) override
Definition
qwaylandsurface.cpp:101
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
QtWaylandClient
Definition
qwaylandclientextension.h:16
qtbase
src
plugins
platforms
wayland
qwaylandsurface.cpp
Generated on
for Qt by
1.18.0