diff options
Diffstat (limited to 'src/platformsupport/eglconvenience/qeglplatformintegration.cpp')
-rw-r--r-- | src/platformsupport/eglconvenience/qeglplatformintegration.cpp | 82 |
1 files changed, 75 insertions, 7 deletions
diff --git a/src/platformsupport/eglconvenience/qeglplatformintegration.cpp b/src/platformsupport/eglconvenience/qeglplatformintegration.cpp index b48f993436..67064f63b5 100644 --- a/src/platformsupport/eglconvenience/qeglplatformintegration.cpp +++ b/src/platformsupport/eglconvenience/qeglplatformintegration.cpp @@ -43,6 +43,7 @@ #include <QtGui/QOpenGLContext> #include <QtGui/QOffscreenSurface> #include <QtGui/QGuiApplication> +#include <QtGui/private/qguiapplication_p.h> #include <qpa/qwindowsysteminterface.h> #include <qpa/qplatforminputcontextfactory_p.h> @@ -57,6 +58,8 @@ #include <QtPlatformSupport/private/qevdevtouch_p.h> #endif +#include <QtPlatformHeaders/qeglfsfunctions.h> + #include "qeglplatformintegration_p.h" #include "qeglplatformcontext_p.h" #include "qeglplatformwindow_p.h" @@ -93,7 +96,8 @@ QEGLPlatformIntegration::QEGLPlatformIntegration() m_display(EGL_NO_DISPLAY), m_inputContext(0), m_fontDb(new QGenericUnixFontDatabase), - m_services(new QGenericUnixServices) + m_services(new QGenericUnixServices), + m_kbdMgr(0) { } @@ -158,9 +162,14 @@ QPlatformOpenGLContext *QEGLPlatformIntegration::createPlatformOpenGLContext(QOp // If there is a "root" window into which raster and QOpenGLWidget content is // composited, all other contexts must share with its context. QOpenGLContext *compositingContext = screen ? screen->compositingContext() : 0; - return createContext(context->format(), - compositingContext ? compositingContext->handle() : context->shareHandle(), - display()); + QPlatformOpenGLContext *share = compositingContext ? compositingContext->handle() : context->shareHandle(); + QVariant nativeHandle = context->nativeHandle(); + QPlatformOpenGLContext *platformContext = createContext(context->format(), + share, + display(), + &nativeHandle); + context->setNativeHandle(nativeHandle); + return platformContext; } QPlatformOffscreenSurface *QEGLPlatformIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface) const @@ -189,7 +198,10 @@ QPlatformNativeInterface *QEGLPlatformIntegration::nativeInterface() const enum ResourceType { EglDisplay, EglWindow, - EglContext + EglContext, + EglConfig, + NativeDisplay, + Display }; static int resourceType(const QByteArray &key) @@ -197,7 +209,10 @@ static int resourceType(const QByteArray &key) static const QByteArray names[] = { // match ResourceType QByteArrayLiteral("egldisplay"), QByteArrayLiteral("eglwindow"), - QByteArrayLiteral("eglcontext") + QByteArrayLiteral("eglcontext"), + QByteArrayLiteral("eglconfig"), + QByteArrayLiteral("nativedisplay"), + QByteArrayLiteral("display") }; const QByteArray *end = names + sizeof(names) / sizeof(names[0]); const QByteArray *result = std::find(names, end, key); @@ -214,6 +229,26 @@ void *QEGLPlatformIntegration::nativeResourceForIntegration(const QByteArray &re case EglDisplay: result = m_screen->display(); break; + case NativeDisplay: + result = reinterpret_cast<void*>(nativeDisplay()); + break; + default: + break; + } + + return result; +} + +void *QEGLPlatformIntegration::nativeResourceForScreen(const QByteArray &resource, QScreen *) +{ + void *result = 0; + + switch (resourceType(resource)) { + case Display: + // Play nice when using the x11 hooks: Be compatible with xcb that allows querying + // the X Display pointer, which is nothing but our native display. + result = reinterpret_cast<void*>(nativeDisplay()); + break; default: break; } @@ -252,6 +287,14 @@ void *QEGLPlatformIntegration::nativeResourceForContext(const QByteArray &resour if (context->handle()) result = static_cast<QEGLPlatformContext *>(context->handle())->eglContext(); break; + case EglConfig: + if (context->handle()) + result = static_cast<QEGLPlatformContext *>(context->handle())->eglConfig(); + break; + case EglDisplay: + if (context->handle()) + result = static_cast<QEGLPlatformContext *>(context->handle())->eglDisplay(); + break; default: break; } @@ -279,10 +322,35 @@ QPlatformNativeInterface::NativeResourceForContextFunction QEGLPlatformIntegrati return 0; } +QFunctionPointer QEGLPlatformIntegration::platformFunction(const QByteArray &function) const +{ +#if !defined(QT_NO_EVDEV) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK)) + if (function == QEglFSFunctions::loadKeymapTypeIdentifier()) + return QFunctionPointer(loadKeymapStatic); +#else + Q_UNUSED(function) +#endif + + return 0; +} + +void QEGLPlatformIntegration::loadKeymapStatic(const QString &filename) +{ +#if !defined(QT_NO_EVDEV) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK)) + QEGLPlatformIntegration *self = static_cast<QEGLPlatformIntegration *>(QGuiApplicationPrivate::platformIntegration()); + if (self->m_kbdMgr) + self->m_kbdMgr->loadKeymap(filename); + else + qWarning("QEGLPlatformIntegration: Cannot load keymap, no keyboard handler found"); +#else + Q_UNUSED(filename); +#endif +} + void QEGLPlatformIntegration::createInputHandlers() { #if !defined(QT_NO_EVDEV) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK)) - new QEvdevKeyboardManager(QLatin1String("EvdevKeyboard"), QString() /* spec */, this); + m_kbdMgr = new QEvdevKeyboardManager(QLatin1String("EvdevKeyboard"), QString() /* spec */, this); QEvdevMouseManager *mouseMgr = new QEvdevMouseManager(QLatin1String("EvdevMouse"), QString() /* spec */, this); Q_FOREACH (QScreen *screen, QGuiApplication::screens()) { QEGLPlatformCursor *cursor = static_cast<QEGLPlatformCursor *>(screen->handle()->cursor()); |