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
qwaylandnativeinterface.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
5
#
include
"qwaylandnativeinterface_p.h"
6
#
include
"qwaylanddisplay_p.h"
7
#
include
"qwaylandwindow_p.h"
8
#
include
"qwaylandshellintegration_p.h"
9
#
include
"qwaylandsubsurface_p.h"
10
#
include
"qwaylandintegration_p.h"
11
#
include
"qwaylanddisplay_p.h"
12
#
include
"qwaylandwindowmanagerintegration_p.h"
13
#
include
"qwaylandscreen_p.h"
14
#
include
"qwaylandinputdevice_p.h"
15
#
include
<
QtCore
/
qbytearrayview
.
h
>
16
#
include
<
QtCore
/
private
/
qnativeinterface_p
.
h
>
17
#
include
<
QtGui
/
private
/
qguiapplication_p
.
h
>
18
#
include
<
QtGui
/
QScreen
>
19
#
include
<
QtWaylandClient
/
private
/
qwaylandclientbufferintegration_p
.
h
>
20
#
if
QT_CONFIG
(
vulkan
)
21
#
include
<
QtWaylandClient
/
private
/
qwaylandvulkanwindow_p
.
h
>
22
#
endif
23
24
QT_BEGIN_NAMESPACE
25
26
namespace
QtWaylandClient
{
27
28
static
bool
equalsIgnoringCase
(QByteArrayView lhs, QByteArrayView rhs)
29
{
30
return
lhs.compare(rhs, Qt::CaseInsensitive) == 0;
31
}
32
33
QWaylandNativeInterface
::
QWaylandNativeInterface
(
QWaylandIntegration
*
integration
)
34
:
m_integration
(
integration
)
35
{
36
}
37
38
void
*
QWaylandNativeInterface
::
nativeResourceForIntegration
(
const
QByteArray
&
resourceString
)
39
{
40
if
(
equalsIgnoringCase
(
resourceString
,
"display"
)
41
||
equalsIgnoringCase
(
resourceString
,
"wl_display"
)
42
||
equalsIgnoringCase
(
resourceString
,
"nativedisplay"
)) {
43
return
m_integration
->
display
()->
wl_display
();
44
}
45
if
(
equalsIgnoringCase
(
resourceString
,
"compositor"
)) {
46
if
(
auto
compositor
=
m_integration
->
display
()->
compositor
())
47
return
compositor
->
object
();
48
}
49
if
(
equalsIgnoringCase
(
resourceString
,
"server_buffer_integration"
))
50
return
m_integration
->
serverBufferIntegration
();
51
52
if
(
equalsIgnoringCase
(
resourceString
,
"egldisplay"
) &&
m_integration
->
clientBufferIntegration
())
53
return
m_integration
->
clientBufferIntegration
()->
nativeResource
(
QWaylandClientBufferIntegration
::
EglDisplay
);
54
55
if
(
equalsIgnoringCase
(
resourceString
,
"wl_seat"
))
56
return
m_integration
->
display
()->
defaultInputDevice
()->
wl_seat
();
57
if
(
equalsIgnoringCase
(
resourceString
,
"wl_keyboard"
)) {
58
auto
*
keyboard
=
m_integration
->
display
()->
defaultInputDevice
()->
keyboard
();
59
if
(
keyboard
)
60
return
keyboard
->
wl_keyboard
();
61
return
nullptr
;
62
}
63
if
(
equalsIgnoringCase
(
resourceString
,
"wl_pointer"
)) {
64
auto
*
pointer
=
m_integration
->
display
()->
defaultInputDevice
()->
pointer
();
65
if
(
pointer
)
66
return
pointer
->
wl_pointer
();
67
return
nullptr
;
68
}
69
if
(
equalsIgnoringCase
(
resourceString
,
"wl_touch"
)) {
70
auto
*
touch
=
m_integration
->
display
()->
defaultInputDevice
()->
touch
();
71
if
(
touch
)
72
return
touch
->
wl_touch
();
73
return
nullptr
;
74
}
75
#
if
QT_CONFIG
(
xkbcommon
)
76
if
(
equalsIgnoringCase
(
resourceString
,
"xkb_context"
)) {
77
return
m_integration
->
display
()->
xkbContext
();
78
}
79
#
endif
80
if
(
equalsIgnoringCase
(
resourceString
,
"serial"
))
81
return
reinterpret_cast
<
void
*>(
quintptr
(
m_integration
->
display
()->
defaultInputDevice
()->
serial
()));
82
83
return
nullptr
;
84
}
85
86
wl_display
*
QtWaylandClient
::
QWaylandNativeInterface
::
display
()
const
87
{
88
return
m_integration
->
display
()->
wl_display
();
89
}
90
91
wl_compositor
*
QtWaylandClient
::
QWaylandNativeInterface
::
compositor
()
const
92
{
93
if
(
auto
compositor
=
m_integration
->
display
()->
compositor
())
94
return
compositor
->
object
();
95
return
nullptr
;
96
}
97
98
wl_seat
*
QtWaylandClient
::
QWaylandNativeInterface
::
seat
()
const
99
{
100
if
(
auto
inputDevice
=
m_integration
->
display
()->
defaultInputDevice
()) {
101
return
inputDevice
->
wl_seat
();
102
}
103
return
nullptr
;
104
}
105
106
wl_keyboard
*
QtWaylandClient
::
QWaylandNativeInterface
::
keyboard
()
const
107
{
108
if
(
auto
inputDevice
=
m_integration
->
display
()->
defaultInputDevice
())
109
if
(
auto
keyboard
=
inputDevice
->
keyboard
())
110
return
keyboard
->
wl_keyboard
();
111
return
nullptr
;
112
}
113
114
wl_pointer
*
QtWaylandClient
::
QWaylandNativeInterface
::
pointer
()
const
115
{
116
if
(
auto
inputDevice
=
m_integration
->
display
()->
defaultInputDevice
())
117
if
(
auto
pointer
=
inputDevice
->
pointer
())
118
return
pointer
->
wl_pointer
();
119
return
nullptr
;
120
}
121
122
wl_touch
*
QtWaylandClient
::
QWaylandNativeInterface
::
touch
()
const
123
{
124
if
(
auto
inputDevice
=
m_integration
->
display
()->
defaultInputDevice
())
125
if
(
auto
touch
=
inputDevice
->
touch
())
126
return
touch
->
wl_touch
();
127
return
nullptr
;
128
}
129
130
uint
QtWaylandClient
::
QWaylandNativeInterface
::
lastInputSerial
()
const
131
{
132
return
m_integration
->
display
()->
lastInputSerial
();
133
}
134
135
wl_seat
*
QtWaylandClient
::
QWaylandNativeInterface
::
lastInputSeat
()
const
136
{
137
if
(
auto
inputDevice
=
m_integration
->
display
()->
lastInputDevice
())
138
return
inputDevice
->
wl_seat
();
139
return
nullptr
;
140
}
141
142
#
if
QT_CONFIG
(
xkbcommon
)
143
struct
xkb_context
*
QtWaylandClient
::
QWaylandNativeInterface
::
xkbContext
()
const
144
{
145
return
m_integration
->
display
()->
xkbContext
();
146
}
147
#
endif
148
149
void
*
QWaylandNativeInterface
::
nativeResourceForWindow
(
const
QByteArray
&
resourceString
,
QWindow
*
window
)
150
{
151
if
(
equalsIgnoringCase
(
resourceString
,
"display"
))
152
return
m_integration
->
display
()->
wl_display
();
153
if
(
equalsIgnoringCase
(
resourceString
,
"compositor"
)) {
154
if
(
auto
compositor
=
m_integration
->
display
()->
compositor
())
155
return
compositor
->
object
();
156
}
157
if
(
equalsIgnoringCase
(
resourceString
,
"surface"
)) {
158
QWaylandWindow
*
w
=
static_cast
<
QWaylandWindow
*>(
window
->
handle
());
159
return
w
?
w
->
wlSurface
() :
nullptr
;
160
}
161
162
if
(
equalsIgnoringCase
(
resourceString
,
"egldisplay"
) &&
m_integration
->
clientBufferIntegration
())
163
return
m_integration
->
clientBufferIntegration
()->
nativeResource
(
QWaylandClientBufferIntegration
::
EglDisplay
);
164
165
#
if
QT_CONFIG
(
vulkan
)
166
if
(
equalsIgnoringCase
(
resourceString
,
"vksurface"
)) {
167
if
(
window
->
surfaceType
() ==
QSurface
::
VulkanSurface
&&
window
->
handle
()) {
168
// return a pointer to the VkSurfaceKHR value, not the value itself
169
return
static_cast
<
QWaylandVulkanWindow
*>(
window
->
handle
())->
vkSurface
();
170
}
171
}
172
#
endif
173
174
QWaylandWindow
*
platformWindow
=
static_cast
<
QWaylandWindow
*>(
window
->
handle
());
175
if
(
platformWindow
&&
platformWindow
->
shellIntegration
())
176
return
platformWindow
->
shellIntegration
()->
nativeResourceForWindow
(
resourceString
,
window
);
177
178
return
nullptr
;
179
}
180
181
void
*
QWaylandNativeInterface
::
nativeResourceForScreen
(
const
QByteArray
&
resourceString
,
QScreen
*
screen
)
182
{
183
if
(
equalsIgnoringCase
(
resourceString
,
"output"
) && !
screen
->
handle
()->
isPlaceholder
())
184
return
((
QWaylandScreen
*)
screen
->
handle
())->
output
();
185
186
return
nullptr
;
187
}
188
189
#
if
QT_CONFIG
(
opengl
)
190
void
*
QWaylandNativeInterface
::
nativeResourceForContext
(
const
QByteArray
&
resource
,
QOpenGLContext
*
context
)
191
{
192
#
if
QT_CONFIG
(
opengl
)
193
if
(
equalsIgnoringCase
(
resource
,
"eglconfig"
) &&
m_integration
->
clientBufferIntegration
())
194
return
m_integration
->
clientBufferIntegration
()->
nativeResourceForContext
(
QWaylandClientBufferIntegration
::
EglConfig
,
context
->
handle
());
195
196
if
(
equalsIgnoringCase
(
resource
,
"eglcontext"
) &&
m_integration
->
clientBufferIntegration
())
197
return
m_integration
->
clientBufferIntegration
()->
nativeResourceForContext
(
QWaylandClientBufferIntegration
::
EglContext
,
context
->
handle
());
198
199
if
(
equalsIgnoringCase
(
resource
,
"egldisplay"
) &&
m_integration
->
clientBufferIntegration
())
200
return
m_integration
->
clientBufferIntegration
()->
nativeResourceForContext
(
QWaylandClientBufferIntegration
::
EglDisplay
,
context
->
handle
());
201
#
endif
202
203
return
nullptr
;
204
}
205
#
endif
// opengl
206
207
QPlatformNativeInterface
::
NativeResourceForWindowFunction
QWaylandNativeInterface
::
nativeResourceFunctionForWindow
(
const
QByteArray
&
resource
)
208
{
209
if
(
equalsIgnoringCase
(
resource
,
"setmargins"
)) {
210
return
NativeResourceForWindowFunction
(
reinterpret_cast
<
void
*>(
setWindowMargins
));
211
}
212
213
return
nullptr
;
214
}
215
216
QVariantMap
QWaylandNativeInterface
::
windowProperties
(
QPlatformWindow
*
window
)
const
217
{
218
QWaylandWindow
*
waylandWindow
=
static_cast
<
QWaylandWindow
*>(
window
);
219
return
waylandWindow
->
properties
();
220
}
221
222
QVariant
QWaylandNativeInterface
::
windowProperty
(
QPlatformWindow
*
window
,
const
QString
&
name
)
const
223
{
224
QWaylandWindow
*
waylandWindow
=
static_cast
<
QWaylandWindow
*>(
window
);
225
return
waylandWindow
->
property
(
name
);
226
}
227
228
QVariant
QWaylandNativeInterface
::
windowProperty
(
QPlatformWindow
*
window
,
const
QString
&
name
,
const
QVariant
&
defaultValue
)
const
229
{
230
QWaylandWindow
*
waylandWindow
=
static_cast
<
QWaylandWindow
*>(
window
);
231
return
waylandWindow
->
property
(
name
,
defaultValue
);
232
}
233
234
void
QWaylandNativeInterface
::
setWindowProperty
(
QPlatformWindow
*
window
,
const
QString
&
name
,
const
QVariant
&
value
)
235
{
236
QWaylandWindow
*
wlWindow
=
static_cast
<
QWaylandWindow
*>(
window
);
237
wlWindow
->
sendProperty
(
name
,
value
);
238
}
239
240
void
QWaylandNativeInterface
::
emitWindowPropertyChanged
(
QPlatformWindow
*
window
,
const
QString
&
name
)
241
{
242
emit
windowPropertyChanged
(
window
,
name
);
243
}
244
245
void
QWaylandNativeInterface
::
setWindowMargins
(
QWindow
*
window
,
const
QMargins
&
margins
)
246
{
247
QWaylandWindow
*
wlWindow
=
static_cast
<
QWaylandWindow
*>(
window
->
handle
());
248
wlWindow
->
setCustomMargins
(
margins
);
249
}
250
251
}
252
253
QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
QtWaylandClient
Definition
qwaylandclientextension.h:16
QtWaylandClient::equalsIgnoringCase
static bool equalsIgnoringCase(QByteArrayView lhs, QByteArrayView rhs)
Definition
qwaylandnativeinterface.cpp:28
qtbase
src
plugins
platforms
wayland
qwaylandnativeinterface.cpp
Generated on
for Qt by
1.18.0