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