| 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 | |
| 18 | QT_BEGIN_NAMESPACE |
| 19 | |
| 20 | using 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 | |
| 66 | QT_DEFINE_NATIVE_INTERFACE(QGLXContext); |
| 67 | QT_DEFINE_PRIVATE_NATIVE_INTERFACE(QGLXIntegration); |
| 68 | |
| 69 | QOpenGLContext *QNativeInterface::QGLXContext::fromNative(GLXContext configBasedContext, QOpenGLContext *shareContext) |
| 70 | { |
| 71 | return QGuiApplicationPrivate::platformIntegration()->call< |
| 72 | &QGLXIntegration::createOpenGLContext>(args: configBasedContext, args: nullptr, args: shareContext); |
| 73 | } |
| 74 | |
| 75 | QOpenGLContext *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 | |
| 142 | QT_DEFINE_NATIVE_INTERFACE(QEGLContext); |
| 143 | QT_DEFINE_PRIVATE_NATIVE_INTERFACE(QEGLIntegration); |
| 144 | |
| 145 | QOpenGLContext *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 | |
| 165 | QT_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 | |
| 176 | QT_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 | |
| 207 | QT_DEFINE_NATIVE_INTERFACE(QX11Application); |
| 208 | |
| 209 | #endif // QT_CONFIG(xcb) |
| 210 | |
| 211 | #if QT_CONFIG(vsp2) |
| 212 | QT_DEFINE_PRIVATE_NATIVE_INTERFACE(QVsp2Screen); |
| 213 | #endif |
| 214 | |
| 215 | #ifdef Q_OS_WEBOS |
| 216 | QT_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 | |
| 230 | QT_DEFINE_PRIVATE_NATIVE_INTERFACE(QEvdevKeyMapper); |
| 231 | |
| 232 | #endif // QT_CONFIG(evdev) |
| 233 | |
| 234 | #if QT_CONFIG(wayland) |
| 235 | |
| 236 | /*! |
| 237 | \class QNativeInterface::QWaylandApplication |
| 238 | \inheaderfile QGuiApplication |
| 239 | \since 6.5 |
| 240 | \brief Native interface to a Wayland application. |
| 241 | |
| 242 | Accessed through QGuiApplication::nativeInterface(). |
| 243 | \inmodule QtGui |
| 244 | \ingroup native-interfaces |
| 245 | \ingroup native-interfaces-qguiapplication |
| 246 | */ |
| 247 | /*! |
| 248 | \fn wl_display *QNativeInterface::QWaylandApplication::display() const |
| 249 | \return the wl_display that the application is using. |
| 250 | */ |
| 251 | /*! |
| 252 | \fn wl_compositor *QNativeInterface::QWaylandApplication::compositor() const |
| 253 | \return the wl_compositor that the application is using. |
| 254 | */ |
| 255 | /*! |
| 256 | \fn wl_keyboard *QNativeInterface::QWaylandApplication::keyboard() const |
| 257 | \return the wl_keyboard belonging to seat() if available. |
| 258 | */ |
| 259 | /*! |
| 260 | \fn wl_pointer *QNativeInterface::QWaylandApplication::pointer() const |
| 261 | \return the wl_pointer belonging to seat() if available. |
| 262 | */ |
| 263 | /*! |
| 264 | \fn wl_touch *QNativeInterface::QWaylandApplication::touch() const |
| 265 | \return the wl_touch belonging to seat() if available. |
| 266 | */ |
| 267 | /*! |
| 268 | \fn uint *QNativeInterface::QWaylandApplication::lastInputSerial() const |
| 269 | \return the serial of the last input event on any seat. |
| 270 | */ |
| 271 | /*! |
| 272 | \fn wl_seat *QNativeInterface::QWaylandApplication::lastInputSeat() const |
| 273 | \return the seat on which the last input event happened. |
| 274 | */ |
| 275 | /*! |
| 276 | \fn wl_seat *QNativeInterface::QWaylandApplication::seat() const |
| 277 | \return the seat associated with the default input device. |
| 278 | */ |
| 279 | |
| 280 | QT_DEFINE_NATIVE_INTERFACE(QWaylandApplication); |
| 281 | |
| 282 | /*! |
| 283 | \class QNativeInterface::QWaylandScreen |
| 284 | \since 6.7 |
| 285 | \brief Native interface to a screen on Wayland. |
| 286 | |
| 287 | Accessed through QScreen::nativeInterface(). |
| 288 | \inmodule QtGui |
| 289 | \ingroup native-interfaces |
| 290 | \ingroup native-interfaces-qscreen |
| 291 | */ |
| 292 | /*! |
| 293 | \fn wl_output *QNativeInterface::QWaylandScreen::output() const |
| 294 | \return the underlying wl_output of this QScreen. |
| 295 | */ |
| 296 | QT_DEFINE_NATIVE_INTERFACE(QWaylandScreen); |
| 297 | |
| 298 | /*! |
| 299 | \class QNativeInterface::QWaylandWindow |
| 300 | \since 6.5 |
| 301 | \internal |
| 302 | \brief Native interface to a Wayland window. |
| 303 | \inmodule QtGui |
| 304 | \ingroup native-interfaces |
| 305 | */ |
| 306 | |
| 307 | QT_DEFINE_PRIVATE_NATIVE_INTERFACE(QWaylandWindow); |
| 308 | |
| 309 | #endif // QT_CONFIG(wayland) |
| 310 | |
| 311 | QT_END_NAMESPACE |
| 312 | |