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
qunixnativeinterface.cpp
Go to the documentation of this file.
1// Copyright (C) 2020 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 <QtGui/private/qtguiglobal_p.h>
6
7#if QT_CONFIG(opengl)
8# include <QtGui/private/qopenglcontext_p.h>
9#endif
10#include <QtGui/private/qguiapplication_p.h>
11
12#include <qpa/qplatformopenglcontext.h>
13#include <qpa/qplatformintegration.h>
14#include <qpa/qplatformscreen_p.h>
15#include <qpa/qplatformwindow_p.h>
16
17#include <QtGui/private/qkeymapper_p.h>
18
19QT_BEGIN_NAMESPACE
20
21using namespace QNativeInterface::Private;
22
23#ifndef QT_NO_OPENGL
24
25#if QT_CONFIG(xcb_glx_plugin)
26
27/*!
28 \class QNativeInterface::QGLXContext
29 \since 6.0
30 \brief Native interface to a GLX context.
31
32 Accessed through QOpenGLContext::nativeInterface().
33
34 \inmodule QtGui
35 \inheaderfile QOpenGLContext
36 \ingroup native-interfaces
37 \ingroup native-interfaces-qopenglcontext
38*/
39
40/*!
41 \fn QOpenGLContext *QNativeInterface::QGLXContext::fromNative(GLXContext configBasedContext, QOpenGLContext *shareContext = nullptr)
42
43 \brief Adopts a GLXContext \a configBasedContext created from an FBConfig.
44
45 The context must be created from a framebuffer configuration, using the \c glXCreateNewContext function.
46
47 Ownership of the created QOpenGLContext \a shareContext is transferred to the caller.
48*/
49
50/*!
51 \fn QOpenGLContext *QNativeInterface::QGLXContext::fromNative(GLXContext visualBasedContext, void *visualInfo, QOpenGLContext *shareContext = nullptr)
52
53 \brief Adopts a GLXContext created from an X visual.
54
55 The context must be created from a visual, using the \c glXCreateContext function.
56 The same visual must be passed as a pointer to an \c XVisualInfo struct, in the \a visualInfo argument.
57
58 Ownership of the created QOpenGLContext is transferred to the caller.
59*/
60
61/*!
62 \fn GLXContext QNativeInterface::QGLXContext::nativeContext() const
63
64 \return the underlying GLXContext.
65*/
66
67QT_DEFINE_NATIVE_INTERFACE(QGLXContext);
68QT_DEFINE_PRIVATE_NATIVE_INTERFACE(QGLXIntegration);
69
70QOpenGLContext *QNativeInterface::QGLXContext::fromNative(GLXContext configBasedContext, QOpenGLContext *shareContext)
71{
72 return QGuiApplicationPrivate::platformIntegration()->call<
73 &QGLXIntegration::createOpenGLContext>(configBasedContext, nullptr, shareContext);
74}
75
76QOpenGLContext *QNativeInterface::QGLXContext::fromNative(GLXContext visualBasedContext, void *visualInfo, QOpenGLContext *shareContext)
77{
78 return QGuiApplicationPrivate::platformIntegration()->call<
79 &QGLXIntegration::createOpenGLContext>(visualBasedContext, visualInfo, shareContext);
80}
81#endif // QT_CONFIG(xcb_glx_plugin)
82
83#if QT_CONFIG(egl)
84
85/*!
86 \class QNativeInterface::QEGLContext
87 \since 6.0
88 \brief Native interface to an EGL context.
89
90 Accessed through QOpenGLContext::nativeInterface().
91
92 \inmodule QtGui
93 \inheaderfile QOpenGLContext
94 \ingroup native-interfaces
95 \ingroup native-interfaces-qopenglcontext
96*/
97
98/*!
99 \fn QOpenGLContext *QNativeInterface::QEGLContext::fromNative(EGLContext context, EGLDisplay display, QOpenGLContext *shareContext = nullptr)
100
101 \brief Adopts an EGLContext \a context.
102
103 The same \c EGLDisplay passed to \c eglCreateContext must be passed as the \a display argument.
104
105 Ownership of the created QOpenGLContext \a shareContext is transferred
106 to the caller.
107*/
108
109/*!
110 \fn EGLContext QNativeInterface::QEGLContext::nativeContext() const
111
112 \return the underlying EGLContext.
113*/
114
115/*!
116 \fn EGLConfig QNativeInterface::QEGLContext::config() const
117 \since 6.3
118 \return the EGLConfig associated with the underlying EGLContext.
119*/
120
121/*!
122 \fn EGLDisplay QNativeInterface::QEGLContext::display() const
123 \since 6.3
124 \return the EGLDisplay associated with the underlying EGLContext.
125*/
126
127
128/*!
129 \fn void QNativeInterface::QEGLContext::invalidateContext()
130 \since 6.5
131 \brief Marks the context as invalid
132
133 If this context is used by the Qt Quick scenegraph, this will trigger the
134 SceneGraph to destroy this context and create a new one.
135
136 Similarly to QPlatformWindow::invalidateSurface(),
137 this function can only be expected to have an effect on certain platforms,
138 such as eglfs.
139
140 \sa QOpenGLContext::isValid(), QPlatformWindow::invalidateSurface()
141*/
142
143QT_DEFINE_NATIVE_INTERFACE(QEGLContext);
144QT_DEFINE_PRIVATE_NATIVE_INTERFACE(QEGLIntegration);
145
146QOpenGLContext *QNativeInterface::QEGLContext::fromNative(EGLContext context, EGLDisplay display, QOpenGLContext *shareContext)
147{
148 return QGuiApplicationPrivate::platformIntegration()->call<
149 &QEGLIntegration::createOpenGLContext>(context, display, shareContext);
150}
151#endif // QT_CONFIG(egl)
152
153#endif // QT_NO_OPENGL
154
155#if QT_CONFIG(xcb)
156
157/*!
158 \class QNativeInterface::Private::QXcbScreen
159 \since 6.0
160 \internal
161 \brief Native interface to QPlatformScreen.
162 \inmodule QtGui
163 \ingroup native-interfaces
164*/
165
166QT_DEFINE_PRIVATE_NATIVE_INTERFACE(QXcbScreen);
167
168/*!
169 \class QNativeInterface::Private::QXcbWindow
170 \since 6.0
171 \internal
172 \brief Native interface to QPlatformWindow.
173 \inmodule QtGui
174 \ingroup native-interfaces
175*/
176
177QT_DEFINE_PRIVATE_NATIVE_INTERFACE(QXcbWindow);
178
179/*!
180 \class QNativeInterface::QX11Application
181 \since 6.2
182 \brief Native interface to an X11 application.
183
184 Accessed through QGuiApplication::nativeInterface().
185
186 \inmodule QtGui
187 \inheaderfile QGuiApplication
188 \ingroup native-interfaces
189 \ingroup native-interfaces-qguiapplication
190*/
191
192/*!
193 \fn Display *QNativeInterface::QX11Application::display() const
194
195 \return the X display of the application, for use with Xlib.
196
197 \sa connection()
198*/
199
200/*!
201 \fn xcb_connection_t *QNativeInterface::QX11Application::connection() const
202
203 \return the X connection of the application, for use with XCB.
204
205 \sa display()
206*/
207
208QT_DEFINE_NATIVE_INTERFACE(QX11Application);
209
210#endif // QT_CONFIG(xcb)
211
212#if QT_CONFIG(vsp2)
213QT_DEFINE_PRIVATE_NATIVE_INTERFACE(QVsp2Screen);
214#endif
215
216#ifdef Q_OS_WEBOS
217QT_DEFINE_PRIVATE_NATIVE_INTERFACE(QWebOSScreen);
218#endif
219
220#if QT_CONFIG(evdev)
221
222/*!
223 \class QNativeInterface::Private::QEvdevKeyMapper
224 \since 6.0
225 \internal
226 \brief Native interface to QKeyMapper.
227 \inmodule QtGui
228 \ingroup native-interfaces
229*/
230
231QT_DEFINE_PRIVATE_NATIVE_INTERFACE(QEvdevKeyMapper);
232
233#endif // QT_CONFIG(evdev)
234
235#if QT_CONFIG(vxworksevdev)
236
237/*!
238 \class QNativeInterface::Private::QVxKeyMapper
239 \since 6.8
240 \internal
241 \brief Native interface to QKeyMapper.
242 \inmodule QtGui
243 \ingroup native-interfaces
244*/
245
246QT_DEFINE_PRIVATE_NATIVE_INTERFACE(QVxKeyMapper);
247
248#endif // QT_CONFIG(vxworksevdev)
249
250#if QT_CONFIG(wayland)
251
252/*!
253 \class QNativeInterface::QWaylandApplication
254 \inheaderfile QGuiApplication
255 \since 6.5
256 \brief Native interface to a Wayland application.
257
258 Accessed through QGuiApplication::nativeInterface().
259 \inmodule QtGui
260 \ingroup native-interfaces
261 \ingroup native-interfaces-qguiapplication
262*/
263/*!
264 \fn wl_display *QNativeInterface::QWaylandApplication::display() const
265 \return the wl_display that the application is using.
266*/
267/*!
268 \fn wl_compositor *QNativeInterface::QWaylandApplication::compositor() const
269 \return the wl_compositor that the application is using.
270*/
271/*!
272 \fn wl_keyboard *QNativeInterface::QWaylandApplication::keyboard() const
273 \return the wl_keyboard belonging to seat() if available.
274*/
275/*!
276 \fn wl_pointer *QNativeInterface::QWaylandApplication::pointer() const
277 \return the wl_pointer belonging to seat() if available.
278*/
279/*!
280 \fn wl_touch *QNativeInterface::QWaylandApplication::touch() const
281 \return the wl_touch belonging to seat() if available.
282*/
283/*!
284 \fn uint *QNativeInterface::QWaylandApplication::lastInputSerial() const
285 \return the serial of the last input event on any seat.
286*/
287/*!
288 \fn wl_seat *QNativeInterface::QWaylandApplication::lastInputSeat() const
289 \return the seat on which the last input event happened.
290*/
291/*!
292 \fn wl_seat *QNativeInterface::QWaylandApplication::seat() const
293 \return the seat associated with the default input device.
294*/
295
296/*!
297 \fn struct xkb_context *QNativeInterface::QWaylandApplication::xkbContext() const
298 \return the XKB context associated with the application.
299*/
300
301QT_DEFINE_NATIVE_INTERFACE(QWaylandApplication);
302
303/*!
304 \class QNativeInterface::QWaylandScreen
305 \since 6.7
306 \brief Native interface to a screen on Wayland.
307
308 Accessed through QScreen::nativeInterface().
309 \inmodule QtGui
310 \ingroup native-interfaces
311 \ingroup native-interfaces-qscreen
312*/
313/*!
314 \fn wl_output *QNativeInterface::QWaylandScreen::output() const
315 \return the underlying wl_output of this QScreen.
316*/
317QT_DEFINE_NATIVE_INTERFACE(QWaylandScreen);
318
319/*!
320 \class QNativeInterface::QWaylandWindow
321 \since 6.5
322 \internal
323 \brief Native interface to a Wayland window.
324 \inmodule QtGui
325 \ingroup native-interfaces
326*/
327
328QT_DEFINE_PRIVATE_NATIVE_INTERFACE(QWaylandWindow);
329
330#endif // QT_CONFIG(wayland)
331
332QT_END_NAMESPACE