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
4
#
include
"qwaylandnativeinterface_p.h"
5
#
include
"qwaylanddisplay_p.h"
6
#
include
"qwaylandwindow_p.h"
7
#
include
"qwaylandshellintegration_p.h"
8
#
include
"qwaylandsubsurface_p.h"
9
#
include
"qwaylandintegration_p.h"
10
#
include
"qwaylanddisplay_p.h"
11
#
include
"qwaylandwindowmanagerintegration_p.h"
12
#
include
"qwaylandscreen_p.h"
13
#
include
"qwaylandinputdevice_p.h"
14
#
include
<
QtCore
/
private
/
qnativeinterface_p
.
h
>
15
#
include
<
QtGui
/
private
/
qguiapplication_p
.
h
>
16
#
include
<
QtGui
/
QScreen
>
17
#
include
<
QtWaylandClient
/
private
/
qwaylandclientbufferintegration_p
.
h
>
18
#
if
QT_CONFIG
(
vulkan
)
19
#
include
<
QtWaylandClient
/
private
/
qwaylandvulkanwindow_p
.
h
>
20
#
endif
21
22
QT_BEGIN_NAMESPACE
23
24
namespace
QtWaylandClient
{
25
26
QWaylandNativeInterface
::
QWaylandNativeInterface
(
QWaylandIntegration
*
integration
)
27
:
m_integration
(
integration
)
28
{
29
}
30
31
void
*
QWaylandNativeInterface
::
nativeResourceForIntegration
(
const
QByteArray
&
resourceString
)
32
{
33
QByteArray
lowerCaseResource
=
resourceString
.
toLower
();
34
35
if
(
lowerCaseResource
==
"display"
||
lowerCaseResource
==
"wl_display"
||
lowerCaseResource
==
"nativedisplay"
)
36
return
m_integration
->
display
()->
wl_display
();
37
if
(
lowerCaseResource
==
"compositor"
) {
38
if
(
auto
compositor
=
m_integration
->
display
()->
compositor
())
39
return
compositor
->
object
();
40
}
41
if
(
lowerCaseResource
==
"server_buffer_integration"
)
42
return
m_integration
->
serverBufferIntegration
();
43
44
if
(
lowerCaseResource
==
"egldisplay"
&&
m_integration
->
clientBufferIntegration
())
45
return
m_integration
->
clientBufferIntegration
()->
nativeResource
(
QWaylandClientBufferIntegration
::
EglDisplay
);
46
47
if
(
lowerCaseResource
==
"wl_seat"
)
48
return
m_integration
->
display
()->
defaultInputDevice
()->
wl_seat
();
49
if
(
lowerCaseResource
==
"wl_keyboard"
) {
50
auto
*
keyboard
=
m_integration
->
display
()->
defaultInputDevice
()->
keyboard
();
51
if
(
keyboard
)
52
return
keyboard
->
wl_keyboard
();
53
return
nullptr
;
54
}
55
if
(
lowerCaseResource
==
"wl_pointer"
) {
56
auto
*
pointer
=
m_integration
->
display
()->
defaultInputDevice
()->
pointer
();
57
if
(
pointer
)
58
return
pointer
->
wl_pointer
();
59
return
nullptr
;
60
}
61
if
(
lowerCaseResource
==
"wl_touch"
) {
62
auto
*
touch
=
m_integration
->
display
()->
defaultInputDevice
()->
touch
();
63
if
(
touch
)
64
return
touch
->
wl_touch
();
65
return
nullptr
;
66
}
67
#
if
QT_CONFIG
(
xkbcommon
)
68
if
(
lowerCaseResource
==
"xkb_context"
) {
69
return
m_integration
->
display
()->
xkbContext
();
70
}
71
#
endif
72
if
(
lowerCaseResource
==
"serial"
)
73
return
reinterpret_cast
<
void
*>(
quintptr
(
m_integration
->
display
()->
defaultInputDevice
()->
serial
()));
74
75
return
nullptr
;
76
}
77
78
wl_display
*
QtWaylandClient
::
QWaylandNativeInterface
::
display
()
const
79
{
80
return
m_integration
->
display
()->
wl_display
();
81
}
82
83
wl_compositor
*
QtWaylandClient
::
QWaylandNativeInterface
::
compositor
()
const
84
{
85
if
(
auto
compositor
=
m_integration
->
display
()->
compositor
())
86
return
compositor
->
object
();
87
return
nullptr
;
88
}
89
90
wl_seat
*
QtWaylandClient
::
QWaylandNativeInterface
::
seat
()
const
91
{
92
if
(
auto
inputDevice
=
m_integration
->
display
()->
defaultInputDevice
()) {
93
return
inputDevice
->
wl_seat
();
94
}
95
return
nullptr
;
96
}
97
98
wl_keyboard
*
QtWaylandClient
::
QWaylandNativeInterface
::
keyboard
()
const
99
{
100
if
(
auto
inputDevice
=
m_integration
->
display
()->
defaultInputDevice
())
101
if
(
auto
keyboard
=
inputDevice
->
keyboard
())
102
return
keyboard
->
wl_keyboard
();
103
return
nullptr
;
104
}
105
106
wl_pointer
*
QtWaylandClient
::
QWaylandNativeInterface
::
pointer
()
const
107
{
108
if
(
auto
inputDevice
=
m_integration
->
display
()->
defaultInputDevice
())
109
if
(
auto
pointer
=
inputDevice
->
pointer
())
110
return
pointer
->
wl_pointer
();
111
return
nullptr
;
112
}
113
114
wl_touch
*
QtWaylandClient
::
QWaylandNativeInterface
::
touch
()
const
115
{
116
if
(
auto
inputDevice
=
m_integration
->
display
()->
defaultInputDevice
())
117
if
(
auto
touch
=
inputDevice
->
touch
())
118
return
touch
->
wl_touch
();
119
return
nullptr
;
120
}
121
122
uint
QtWaylandClient
::
QWaylandNativeInterface
::
lastInputSerial
()
const
123
{
124
return
m_integration
->
display
()->
lastInputSerial
();
125
}
126
127
wl_seat
*
QtWaylandClient
::
QWaylandNativeInterface
::
lastInputSeat
()
const
128
{
129
if
(
auto
inputDevice
=
m_integration
->
display
()->
lastInputDevice
())
130
return
inputDevice
->
wl_seat
();
131
return
nullptr
;
132
}
133
134
#
if
QT_CONFIG
(
xkbcommon
)
135
struct
xkb_context
*
QtWaylandClient
::
QWaylandNativeInterface
::
xkbContext
()
const
136
{
137
return
m_integration
->
display
()->
xkbContext
();
138
}
139
#
endif
140
141
void
*
QWaylandNativeInterface
::
nativeResourceForWindow
(
const
QByteArray
&
resourceString
,
QWindow
*
window
)
142
{
143
QByteArray
lowerCaseResource
=
resourceString
.
toLower
();
144
145
if
(
lowerCaseResource
==
"display"
)
146
return
m_integration
->
display
()->
wl_display
();
147
if
(
lowerCaseResource
==
"compositor"
) {
148
if
(
auto
compositor
=
m_integration
->
display
()->
compositor
())
149
return
compositor
->
object
();
150
}
151
if
(
lowerCaseResource
==
"surface"
) {
152
QWaylandWindow
*
w
=
static_cast
<
QWaylandWindow
*>(
window
->
handle
());
153
return
w
?
w
->
wlSurface
() :
nullptr
;
154
}
155
156
if
(
lowerCaseResource
==
"egldisplay"
&&
m_integration
->
clientBufferIntegration
())
157
return
m_integration
->
clientBufferIntegration
()->
nativeResource
(
QWaylandClientBufferIntegration
::
EglDisplay
);
158
159
#
if
QT_CONFIG
(
vulkan
)
160
if
(
lowerCaseResource
==
"vksurface"
) {
161
if
(
window
->
surfaceType
() ==
QSurface
::
VulkanSurface
&&
window
->
handle
()) {
162
// return a pointer to the VkSurfaceKHR value, not the value itself
163
return
static_cast
<
QWaylandVulkanWindow
*>(
window
->
handle
())->
vkSurface
();
164
}
165
}
166
#
endif
167
168
QWaylandWindow
*
platformWindow
=
static_cast
<
QWaylandWindow
*>(
window
->
handle
());
169
if
(
platformWindow
&&
platformWindow
->
shellIntegration
())
170
return
platformWindow
->
shellIntegration
()->
nativeResourceForWindow
(
resourceString
,
window
);
171
172
return
nullptr
;
173
}
174
175
void
*
QWaylandNativeInterface
::
nativeResourceForScreen
(
const
QByteArray
&
resourceString
,
QScreen
*
screen
)
176
{
177
QByteArray
lowerCaseResource
=
resourceString
.
toLower
();
178
179
if
(
lowerCaseResource
==
"output"
&& !
screen
->
handle
()->
isPlaceholder
())
180
return
((
QWaylandScreen
*)
screen
->
handle
())->
output
();
181
182
return
nullptr
;
183
}
184
185
#
if
QT_CONFIG
(
opengl
)
186
void
*
QWaylandNativeInterface
::
nativeResourceForContext
(
const
QByteArray
&
resource
,
QOpenGLContext
*
context
)
187
{
188
#
if
QT_CONFIG
(
opengl
)
189
QByteArray
lowerCaseResource
=
resource
.
toLower
();
190
191
if
(
lowerCaseResource
==
"eglconfig"
&&
m_integration
->
clientBufferIntegration
())
192
return
m_integration
->
clientBufferIntegration
()->
nativeResourceForContext
(
QWaylandClientBufferIntegration
::
EglConfig
,
context
->
handle
());
193
194
if
(
lowerCaseResource
==
"eglcontext"
&&
m_integration
->
clientBufferIntegration
())
195
return
m_integration
->
clientBufferIntegration
()->
nativeResourceForContext
(
QWaylandClientBufferIntegration
::
EglContext
,
context
->
handle
());
196
197
if
(
lowerCaseResource
==
"egldisplay"
&&
m_integration
->
clientBufferIntegration
())
198
return
m_integration
->
clientBufferIntegration
()->
nativeResourceForContext
(
QWaylandClientBufferIntegration
::
EglDisplay
,
context
->
handle
());
199
#
endif
200
201
return
nullptr
;
202
}
203
#
endif
// opengl
204
205
QPlatformNativeInterface
::
NativeResourceForWindowFunction
QWaylandNativeInterface
::
nativeResourceFunctionForWindow
(
const
QByteArray
&
resource
)
206
{
207
QByteArray
lowerCaseResource
=
resource
.
toLower
();
208
209
if
(
lowerCaseResource
==
"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
QPlatformGraphicsBufferHelper
\inmodule QtGui
QtWaylandClient
Definition
qwaylandclientextension.h:15
qtbase
src
plugins
platforms
wayland
qwaylandnativeinterface.cpp
Generated on
for Qt by
1.14.0