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

source code of qtbase/src/gui/platform/unix/qunixnativeinterface.cpp