diff options
Diffstat (limited to 'src/plugins/platforms/xlib')
-rw-r--r-- | src/plugins/platforms/xlib/qglxintegration.cpp | 225 | ||||
-rw-r--r-- | src/plugins/platforms/xlib/qglxintegration.h | 9 | ||||
-rw-r--r-- | src/plugins/platforms/xlib/qxlibintegration.cpp | 20 | ||||
-rw-r--r-- | src/plugins/platforms/xlib/qxlibintegration.h | 7 | ||||
-rw-r--r-- | src/plugins/platforms/xlib/qxlibnativeinterface.cpp | 133 | ||||
-rw-r--r-- | src/plugins/platforms/xlib/qxlibnativeinterface.h | 75 | ||||
-rw-r--r-- | src/plugins/platforms/xlib/qxlibscreen.cpp | 5 | ||||
-rw-r--r-- | src/plugins/platforms/xlib/qxlibscreen.h | 8 | ||||
-rw-r--r-- | src/plugins/platforms/xlib/qxlibwindow.cpp | 15 | ||||
-rw-r--r-- | src/plugins/platforms/xlib/xlib.pro | 7 |
10 files changed, 261 insertions, 243 deletions
diff --git a/src/plugins/platforms/xlib/qglxintegration.cpp b/src/plugins/platforms/xlib/qglxintegration.cpp index 80011d9..7a0f36d 100644 --- a/src/plugins/platforms/xlib/qglxintegration.cpp +++ b/src/plugins/platforms/xlib/qglxintegration.cpp @@ -51,6 +51,7 @@ #include <X11/Xlib.h> #include <X11/Xutil.h> #include <GL/glx.h> +#include "qglxconvenience.h" #include "qglxintegration.h" @@ -60,184 +61,6 @@ QT_BEGIN_NAMESPACE -QMutex QGLXContext::m_defaultSharedContextMutex(QMutex::Recursive); - -QVector<int> QGLXContext::buildSpec(const QPlatformWindowFormat &format) -{ - QVector<int> spec(48); - int i = 0; - - spec[i++] = GLX_LEVEL; - spec[i++] = 0; - spec[i++] = GLX_DRAWABLE_TYPE; spec[i++] = GLX_WINDOW_BIT; - - if (format.rgba()) { - spec[i++] = GLX_RENDER_TYPE; spec[i++] = GLX_RGBA_BIT; - spec[i++] = GLX_RED_SIZE; spec[i++] = (format.redBufferSize() == -1) ? 1 : format.redBufferSize(); - spec[i++] = GLX_GREEN_SIZE; spec[i++] = (format.greenBufferSize() == -1) ? 1 : format.greenBufferSize(); - spec[i++] = GLX_BLUE_SIZE; spec[i++] = (format.blueBufferSize() == -1) ? 1 : format.blueBufferSize(); - if (format.alpha()) { - spec[i++] = GLX_ALPHA_SIZE; spec[i++] = (format.alphaBufferSize() == -1) ? 1 : format.alphaBufferSize(); - } - - spec[i++] = GLX_ACCUM_RED_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize(); - spec[i++] = GLX_ACCUM_GREEN_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize(); - spec[i++] = GLX_ACCUM_BLUE_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize(); - - if (format.alpha()) { - spec[i++] = GLX_ACCUM_ALPHA_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize(); - } - - } else { - spec[i++] = GLX_RENDER_TYPE; spec[i++] = GLX_COLOR_INDEX_BIT; //I'm really not sure if this works.... - spec[i++] = GLX_BUFFER_SIZE; spec[i++] = 8; - } - - spec[i++] = GLX_DOUBLEBUFFER; spec[i++] = format.doubleBuffer() ? True : False; - spec[i++] = GLX_STEREO; spec[i++] = format.stereo() ? True : False; - - if (format.depth()) { - spec[i++] = GLX_DEPTH_SIZE; spec[i++] = (format.depthBufferSize() == -1) ? 1 : format.depthBufferSize(); - } - - if (format.stencil()) { - spec[i++] = GLX_STENCIL_SIZE; spec[i++] = (format.stencilBufferSize() == -1) ? 1 : format.stencilBufferSize(); - } - if (format.sampleBuffers()) { - spec[i++] = GLX_SAMPLE_BUFFERS_ARB; - spec[i++] = 1; - spec[i++] = GLX_SAMPLES_ARB; - spec[i++] = format.samples() == -1 ? 4 : format.samples(); - } - - spec[i++] = XNone; - return spec; -} - -GLXFBConfig QGLXContext::findConfig(const QXlibScreen *screen, const QPlatformWindowFormat &format) -{ - bool reduced = true; - GLXFBConfig chosenConfig = 0; - QPlatformWindowFormat reducedFormat = format; - while (!chosenConfig && reduced) { - QVector<int> spec = buildSpec(reducedFormat); - int confcount = 0; - GLXFBConfig *configs; - configs = glXChooseFBConfig(screen->display()->nativeDisplay(),screen->xScreenNumber(),spec.constData(),&confcount); - if (confcount) - { - for (int i = 0; i < confcount; i++) { - chosenConfig = configs[i]; - // Make sure we try to get an ARGB visual if the format asked for an alpha: - if (reducedFormat.alpha()) { - int alphaSize; - glXGetFBConfigAttrib(screen->display()->nativeDisplay(),configs[i],GLX_ALPHA_SIZE,&alphaSize); - if (alphaSize > 0) - break; - } else { - break; // Just choose the first in the list if there's no alpha requested - } - } - - XFree(configs); - } - reducedFormat = reducePlatformWindowFormat(reducedFormat,&reduced); - } - - if (!chosenConfig) - qWarning("Warning no context created"); - - return chosenConfig; -} - -XVisualInfo *QGLXContext::findVisualInfo(const QXlibScreen *screen, const QPlatformWindowFormat &format) -{ - GLXFBConfig config = QGLXContext::findConfig(screen,format); - XVisualInfo *visualInfo = glXGetVisualFromFBConfig(screen->display()->nativeDisplay(),config); - return visualInfo; -} - -QPlatformWindowFormat QGLXContext::platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext ctx) -{ - QPlatformWindowFormat format; - int redSize = 0; - int greenSize = 0; - int blueSize = 0; - int alphaSize = 0; - int depthSize = 0; - int stencilSize = 0; - int sampleBuffers = 0; - int sampleCount = 0; - int level = 0; - int rgba = 0; - int stereo = 0; - int accumSizeA = 0; - int accumSizeR = 0; - int accumSizeG = 0; - int accumSizeB = 0; - - XVisualInfo *vi = glXGetVisualFromFBConfig(display,config); - glXGetConfig(display,vi,GLX_RGBA,&rgba); - XFree(vi); - glXGetFBConfigAttrib(display, config, GLX_RED_SIZE, &redSize); - glXGetFBConfigAttrib(display, config, GLX_GREEN_SIZE, &greenSize); - glXGetFBConfigAttrib(display, config, GLX_BLUE_SIZE, &blueSize); - glXGetFBConfigAttrib(display, config, GLX_ALPHA_SIZE, &alphaSize); - glXGetFBConfigAttrib(display, config, GLX_DEPTH_SIZE, &depthSize); - glXGetFBConfigAttrib(display, config, GLX_STENCIL_SIZE, &stencilSize); - glXGetFBConfigAttrib(display, config, GLX_SAMPLES, &sampleBuffers); - glXGetFBConfigAttrib(display, config, GLX_LEVEL, &level); - glXGetFBConfigAttrib(display, config, GLX_STEREO, &stereo); - glXGetFBConfigAttrib(display, config, GLX_ACCUM_ALPHA_SIZE, &accumSizeA); - glXGetFBConfigAttrib(display, config, GLX_ACCUM_RED_SIZE, &accumSizeR); - glXGetFBConfigAttrib(display, config, GLX_ACCUM_GREEN_SIZE, &accumSizeG); - glXGetFBConfigAttrib(display, config, GLX_ACCUM_BLUE_SIZE, &accumSizeB); - - format.setRedBufferSize(redSize); - format.setGreenBufferSize(greenSize); - format.setBlueBufferSize(blueSize); - format.setAlphaBufferSize(alphaSize); - format.setDepthBufferSize(depthSize); - format.setStencilBufferSize(stencilSize); - format.setSampleBuffers(sampleBuffers); - if (format.sampleBuffers()) { - glXGetFBConfigAttrib(display, config, GLX_SAMPLES_ARB, &sampleCount); - format.setSamples(sampleCount); - } - - format.setDirectRendering(glXIsDirect(display, ctx)); - format.setRgba(rgba); - format.setStereo(stereo); - format.setAccumBufferSize(accumSizeB); - - return format; -} - -QPlatformWindowFormat QGLXContext::reducePlatformWindowFormat(const QPlatformWindowFormat &format, bool *reduced) -{ - QPlatformWindowFormat retFormat = format; - *reduced = true; - - if (retFormat.sampleBuffers()) { - retFormat.setSampleBuffers(false); - } else if (retFormat.stereo()) { - retFormat.setStereo(false); - } else if (retFormat.accum()) { - retFormat.setAccum(false); - }else if (retFormat.stencil()) { - retFormat.setStencil(false); - }else if (retFormat.alpha()) { - retFormat.setAlpha(false); - }else if (retFormat.depth()) { - retFormat.setDepth(false); - }else if (retFormat.doubleBuffer()) { - retFormat.setDoubleBuffer(false); - }else{ - *reduced = false; - } - return retFormat; -} - QGLXContext::QGLXContext(Window window, QXlibScreen *screen, const QPlatformWindowFormat &format) : QPlatformGLContext() , m_screen(screen) @@ -246,27 +69,14 @@ QGLXContext::QGLXContext(Window window, QXlibScreen *screen, const QPlatformWind { const QPlatformGLContext *sharePlatformContext; - if (format.useDefaultSharedContext()) { - if (!QPlatformGLContext::defaultSharedContext()) { - if (m_defaultSharedContextMutex.tryLock()){ - createDefaultSharedContex(screen); - m_defaultSharedContextMutex.unlock(); - } else { - m_defaultSharedContextMutex.lock(); //wait to the the shared context is created - m_defaultSharedContextMutex.unlock(); - } - } - sharePlatformContext = QPlatformGLContext::defaultSharedContext(); - } else { - sharePlatformContext = format.sharedGLContext(); - } + sharePlatformContext = format.sharedGLContext(); GLXContext shareGlxContext = 0; if (sharePlatformContext) shareGlxContext = static_cast<const QGLXContext*>(sharePlatformContext)->glxContext(); - GLXFBConfig config = findConfig(screen,format); + GLXFBConfig config = qglx_findConfig(screen->display()->nativeDisplay(),screen->xScreenNumber(),format); m_context = glXCreateNewContext(screen->display()->nativeDisplay(),config,GLX_RGBA_TYPE,shareGlxContext,TRUE); - m_windowFormat = QGLXContext::platformWindowFromGLXFBConfig(screen->display()->nativeDisplay(),config,m_context); + m_windowFormat = qglx_platformWindowFromGLXFBConfig(screen->display()->nativeDisplay(),config,m_context); #ifdef MYX11_DEBUG qDebug() << "QGLXGLContext::create context" << m_context; @@ -287,33 +97,6 @@ QGLXContext::~QGLXContext() } } -void QGLXContext::createDefaultSharedContex(QXlibScreen *screen) -{ - int x = 0; - int y = 0; - int w = 3; - int h = 3; - - QPlatformWindowFormat format = QPlatformWindowFormat::defaultFormat(); - GLXContext context; - GLXFBConfig config = findConfig(screen,format); - if (config) { - XVisualInfo *visualInfo = glXGetVisualFromFBConfig(screen->display()->nativeDisplay(),config); - Colormap cmap = XCreateColormap(screen->display()->nativeDisplay(),screen->rootWindow(),visualInfo->visual,AllocNone); - XSetWindowAttributes a; - a.colormap = cmap; - Window sharedWindow = XCreateWindow(screen->display()->nativeDisplay(), screen->rootWindow(),x, y, w, h, - 0, visualInfo->depth, InputOutput, visualInfo->visual, - CWColormap, &a); - - context = glXCreateNewContext(screen->display()->nativeDisplay(),config,GLX_RGBA_TYPE,0,TRUE); - QPlatformGLContext *sharedContext = new QGLXContext(screen,sharedWindow,context); - QPlatformGLContext::setDefaultSharedContext(sharedContext); - } else { - qWarning("Warning no shared context created"); - } -} - void QGLXContext::makeCurrent() { QPlatformGLContext::makeCurrent(); diff --git a/src/plugins/platforms/xlib/qglxintegration.h b/src/plugins/platforms/xlib/qglxintegration.h index dbb5c2e..57c716b 100644 --- a/src/plugins/platforms/xlib/qglxintegration.h +++ b/src/plugins/platforms/xlib/qglxintegration.h @@ -69,22 +69,13 @@ public: QPlatformWindowFormat platformWindowFormat() const; - static XVisualInfo *findVisualInfo(const QXlibScreen *xd, const QPlatformWindowFormat &format); private: - static GLXFBConfig findConfig(const QXlibScreen *xd,const QPlatformWindowFormat &format); - static QVector<int> buildSpec(const QPlatformWindowFormat &format); - static QPlatformWindowFormat platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext context); - static QPlatformWindowFormat reducePlatformWindowFormat(const QPlatformWindowFormat &format, bool *reduced); - - QXlibScreen *m_screen; Drawable m_drawable; GLXContext m_context; QPlatformWindowFormat m_windowFormat; QGLXContext (QXlibScreen *screen, Drawable drawable, GLXContext context); - static QMutex m_defaultSharedContextMutex; - static void createDefaultSharedContex(QXlibScreen *xd); }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/xlib/qxlibintegration.cpp b/src/plugins/platforms/xlib/qxlibintegration.cpp index 6733ed1..78f907a 100644 --- a/src/plugins/platforms/xlib/qxlibintegration.cpp +++ b/src/plugins/platforms/xlib/qxlibintegration.cpp @@ -49,6 +49,7 @@ #include "qxlibscreen.h" #include "qxlibclipboard.h" #include "qxlibdisplay.h" +#include "qxlibnativeinterface.h" #if !defined(QT_NO_OPENGL) #if !defined(QT_OPENGL_ES_2) @@ -66,11 +67,21 @@ QXlibIntegration::QXlibIntegration(bool useOpenGL) : mUseOpenGL(useOpenGL) , mFontDb(new QGenericUnixFontDatabase()) , mClipboard(0) + , mNativeInterface(new QXlibNativeInterface) { mPrimaryScreen = new QXlibScreen(); mScreens.append(mPrimaryScreen); } +bool QXlibIntegration::hasCapability(QPlatformIntegration::Capability cap) const +{ + switch (cap) { + case ThreadedPixmaps: return true; + case OpenGL: return hasOpenGL(); + default: return QPlatformIntegration::hasCapability(cap); + } +} + QPixmapData *QXlibIntegration::createPixmapData(QPixmapData::PixelType type) const { #ifndef QT_NO_OPENGL @@ -130,6 +141,11 @@ QPlatformClipboard * QXlibIntegration::clipboard() const return mClipboard; } +QPlatformNativeInterface * QXlibIntegration::nativeInterface() const +{ + return mNativeInterface; +} + bool QXlibIntegration::hasOpenGL() const { #if !defined(QT_NO_OPENGL) @@ -141,11 +157,12 @@ bool QXlibIntegration::hasOpenGL() const static bool wasEglInitialized = false; if (!eglHasbeenInitialized) { eglHasbeenInitialized = true; - const QXlibScreen *screen = static_cast<const QXlibScreen *>(mScreens.at(0)); + QXlibScreen *screen = static_cast<QXlibScreen *>(mScreens.at(0)); EGLint major, minor; eglBindAPI(EGL_OPENGL_ES_API); EGLDisplay disp = eglGetDisplay(screen->display()->nativeDisplay()); wasEglInitialized = eglInitialize(disp,&major,&minor); + screen->setEglDisplay(disp); } return wasEglInitialized; #endif @@ -153,5 +170,4 @@ bool QXlibIntegration::hasOpenGL() const return false; } - QT_END_NAMESPACE diff --git a/src/plugins/platforms/xlib/qxlibintegration.h b/src/plugins/platforms/xlib/qxlibintegration.h index 3bbf897..1a2515a 100644 --- a/src/plugins/platforms/xlib/qxlibintegration.h +++ b/src/plugins/platforms/xlib/qxlibintegration.h @@ -47,6 +47,7 @@ #include <QtGui/QPlatformIntegration> #include <QtGui/QPlatformScreen> +#include <QtGui/QPlatformNativeInterface> #include "qxlibstatic.h" @@ -59,6 +60,7 @@ class QXlibIntegration : public QPlatformIntegration public: QXlibIntegration(bool useOpenGL = false); + bool hasCapability(Capability cap) const; QPixmapData *createPixmapData(QPixmapData::PixelType type) const; QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const; QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const; @@ -70,14 +72,17 @@ public: QPlatformFontDatabase *fontDatabase() const; QPlatformClipboard *clipboard() const; - bool hasOpenGL() const; + QPlatformNativeInterface *nativeInterface() const; private: + bool hasOpenGL() const; + bool mUseOpenGL; QXlibScreen *mPrimaryScreen; QList<QPlatformScreen *> mScreens; QPlatformFontDatabase *mFontDb; QPlatformClipboard *mClipboard; + QPlatformNativeInterface *mNativeInterface; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/xlib/qxlibnativeinterface.cpp b/src/plugins/platforms/xlib/qxlibnativeinterface.cpp new file mode 100644 index 0000000..4e950ff --- /dev/null +++ b/src/plugins/platforms/xlib/qxlibnativeinterface.cpp @@ -0,0 +1,133 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qxlibnativeinterface.h" + +#include "qxlibdisplay.h" +#include <QtGui/private/qapplication_p.h> + +class QXlibResourceMap : public QMap<QByteArray, QXlibNativeInterface::ResourceType> +{ +public: + QXlibResourceMap() + :QMap<QByteArray, QXlibNativeInterface::ResourceType>() + { + insert("display",QXlibNativeInterface::Display); + insert("egldisplay",QXlibNativeInterface::EglDisplay); + insert("connection",QXlibNativeInterface::Connection); + insert("screen",QXlibNativeInterface::Screen); + insert("graphicsdevice",QXlibNativeInterface::GraphicsDevice); + insert("eglcontext",QXlibNativeInterface::EglContext); + } +}; + +Q_GLOBAL_STATIC(QXlibResourceMap, qXlibResourceMap) + + +void * QXlibNativeInterface::nativeResourceForWidget(const QByteArray &resourceString, QWidget *widget) +{ + QByteArray lowerCaseResource = resourceString.toLower(); + ResourceType resource = qXlibResourceMap()->value(lowerCaseResource); + void *result = 0; + switch(resource) { + case Display: + result = displayForWidget(widget); + break; + case EglDisplay: + result = eglDisplayForWidget(widget); + break; + case Connection: + result = connectionForWidget(widget); + break; + case Screen: + result = reinterpret_cast<void *>(qPlatformScreenForWidget(widget)->xScreenNumber()); + break; + case GraphicsDevice: + result = graphicsDeviceForWidget(widget); + break; + case EglContext: + result = eglContextForWidget(widget); + break; + default: + result = 0; + } + return result; +} + +void * QXlibNativeInterface::displayForWidget(QWidget *widget) +{ + return qPlatformScreenForWidget(widget)->display()->nativeDisplay(); +} + +void * QXlibNativeInterface::eglDisplayForWidget(QWidget *widget) +{ + Q_UNUSED(widget); + return 0; +} + +void * QXlibNativeInterface::screenForWidget(QWidget *widget) +{ + Q_UNUSED(widget); + return 0; +} + +void * QXlibNativeInterface::graphicsDeviceForWidget(QWidget *widget) +{ + Q_UNUSED(widget); + return 0; +} + +void * QXlibNativeInterface::eglContextForWidget(QWidget *widget) +{ + Q_UNUSED(widget); + return 0; +} + +QXlibScreen * QXlibNativeInterface::qPlatformScreenForWidget(QWidget *widget) +{ + QXlibScreen *screen; + if (widget) { + screen = static_cast<QXlibScreen *>(QPlatformScreen::platformScreenForWidget(widget)); + }else { + screen = static_cast<QXlibScreen *>(QApplicationPrivate::platformIntegration()->screens()[0]); + } + return screen; +} diff --git a/src/plugins/platforms/xlib/qxlibnativeinterface.h b/src/plugins/platforms/xlib/qxlibnativeinterface.h new file mode 100644 index 0000000..5ba0768 --- /dev/null +++ b/src/plugins/platforms/xlib/qxlibnativeinterface.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QXLIBNATIVEINTERFACE_H +#define QXLIBNATIVEINTERFACE_H + +#include "qxlibscreen.h" + +#include <QtGui/QPlatformNativeInterface> + +class QXlibNativeInterface : public QPlatformNativeInterface +{ +public: + enum ResourceType { + Display, + EglDisplay, + Connection, + Screen, + GraphicsDevice, + EglContext + }; + + void *nativeResourceForWidget(const QByteArray &resourceString, QWidget *widget); + + void *displayForWidget(QWidget *widget); + void *eglDisplayForWidget(QWidget *widget); + void *connectionForWidget(QWidget *widget); + void *screenForWidget(QWidget *widget); + void *graphicsDeviceForWidget(QWidget *widget); + void *eglContextForWidget(QWidget *widget); + +private: + static QXlibScreen *qPlatformScreenForWidget(QWidget *widget); +}; + + +#endif // QXLIBNATIVEINTERFACE_H diff --git a/src/plugins/platforms/xlib/qxlibscreen.cpp b/src/plugins/platforms/xlib/qxlibscreen.cpp index 23a2d07..7c8a367 100644 --- a/src/plugins/platforms/xlib/qxlibscreen.cpp +++ b/src/plugins/platforms/xlib/qxlibscreen.cpp @@ -191,6 +191,9 @@ qDebug() << "qt_x_errhandler" << err->error_code; QXlibScreen::QXlibScreen() : mFormat(QImage::Format_RGB32) +#if !defined(QT_NO_OPENGL) && defined(QT_OPENGL_ES_2) + , mEGLDisplay(0) +#endif { char *display_name = getenv("DISPLAY"); Display *display = XOpenDisplay(display_name); @@ -467,7 +470,7 @@ int QXlibScreen::xScreenNumber() const Visual * QXlibScreen::defaultVisual() const { - DefaultVisual(display()->nativeDisplay(), xScreenNumber()); + return DefaultVisual(display()->nativeDisplay(), xScreenNumber()); } QXlibKeyboard * QXlibScreen::keyboard() const diff --git a/src/plugins/platforms/xlib/qxlibscreen.h b/src/plugins/platforms/xlib/qxlibscreen.h index 35c0141..8c04c0f 100644 --- a/src/plugins/platforms/xlib/qxlibscreen.h +++ b/src/plugins/platforms/xlib/qxlibscreen.h @@ -82,6 +82,11 @@ public: QXlibKeyboard *keyboard() const; +#if !defined(QT_NO_OPENGL) && defined(QT_OPENGL_ES_2) + void *eglDisplay() const { return mEGLDisplay; } + void setEglDisplay(void *display) { mEGLDisplay = display; } +#endif + public slots: void eventDispatcher(); @@ -96,6 +101,9 @@ private: QXlibKeyboard *mKeyboard; QXlibDisplay * mDisplay; +#if !defined(QT_NO_OPENGL) && defined(QT_OPENGL_ES_2) + void *mEGLDisplay; +#endif int mScreen; }; diff --git a/src/plugins/platforms/xlib/qxlibwindow.cpp b/src/plugins/platforms/xlib/qxlibwindow.cpp index a7bc53c..9a05fc6 100644 --- a/src/plugins/platforms/xlib/qxlibwindow.cpp +++ b/src/plugins/platforms/xlib/qxlibwindow.cpp @@ -58,6 +58,7 @@ #if !defined(QT_NO_OPENGL) #if !defined(QT_OPENGL_ES_2) #include "qglxintegration.h" +#include "qglxconvenience.h" #else #include "../eglconvenience/qeglconvenience.h" #include "../eglconvenience/qeglplatformcontext.h" @@ -80,16 +81,16 @@ QXlibWindow::QXlibWindow(QWidget *window) int h = window->height(); if(window->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL - && QApplicationPrivate::platformIntegration()->hasOpenGL() ) { + && QApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL) ) { #if !defined(QT_NO_OPENGL) #if !defined(QT_OPENGL_ES_2) - XVisualInfo *visualInfo = QGLXContext::findVisualInfo(mScreen,window->platformWindowFormat()); + XVisualInfo *visualInfo = qglx_findVisualInfo(mScreen->display()->nativeDisplay(),mScreen->xScreenNumber(),window->platformWindowFormat()); #else QPlatformWindowFormat windowFormat = correctColorBuffers(window->platformWindowFormat()); - EGLDisplay eglDisplay = eglGetDisplay(mScreen->display()->nativeDisplay()); + EGLDisplay eglDisplay = mScreen->eglDisplay(); EGLConfig eglConfig = q_configFromQPlatformWindowFormat(eglDisplay,windowFormat); - VisualID id = QXlibEglIntegration::getCompatibleVisualId(mScreen->display()->nativeDisplay(),eglConfig); + VisualID id = QXlibEglIntegration::getCompatibleVisualId(mScreen->display()->nativeDisplay(), eglDisplay, eglConfig); XVisualInfo visualInfoTemplate; memset(&visualInfoTemplate, 0, sizeof(XVisualInfo)); @@ -136,7 +137,7 @@ QXlibWindow::QXlibWindow(QWidget *window) int n = 0; protocols[n++] = QXlibStatic::atom(QXlibStatic::WM_DELETE_WINDOW); // support del window protocol protocols[n++] = QXlibStatic::atom(QXlibStatic::WM_TAKE_FOCUS); // support take focus window protocol - protocols[n++] = QXlibStatic::atom(QXlibStatic::_NET_WM_PING); // support _NET_WM_PING protocol +// protocols[n++] = QXlibStatic::atom(QXlibStatic::_NET_WM_PING); // support _NET_WM_PING protocol #ifndef QT_NO_XSYNC protocols[n++] = QXlibStatic::atom(QXlibStatic::_NET_WM_SYNC_REQUEST); // support _NET_WM_SYNC_REQUEST protocol #endif // QT_NO_XSYNC @@ -655,7 +656,7 @@ void QXlibWindow::setCursor(const Cursor &cursor) QPlatformGLContext *QXlibWindow::glContext() const { - if (!QApplicationPrivate::platformIntegration()->hasOpenGL()) + if (!QApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)) return 0; if (!mGLContext) { QXlibWindow *that = const_cast<QXlibWindow *>(this); @@ -663,7 +664,7 @@ QPlatformGLContext *QXlibWindow::glContext() const #if !defined(QT_OPENGL_ES_2) that->mGLContext = new QGLXContext(x_window, mScreen,widget()->platformWindowFormat()); #else - EGLDisplay display = eglGetDisplay(mScreen->display()->nativeDisplay()); + EGLDisplay display = mScreen->eglDisplay(); QPlatformWindowFormat windowFormat = correctColorBuffers(widget()->platformWindowFormat()); diff --git a/src/plugins/platforms/xlib/xlib.pro b/src/plugins/platforms/xlib/xlib.pro index 159fdbe..ea77a29 100644 --- a/src/plugins/platforms/xlib/xlib.pro +++ b/src/plugins/platforms/xlib/xlib.pro @@ -14,7 +14,8 @@ SOURCES = \ qxlibclipboard.cpp \ qxlibmime.cpp \ qxlibstatic.cpp \ - qxlibdisplay.cpp + qxlibdisplay.cpp \ + qxlibnativeinterface.cpp HEADERS = \ qxlibintegration.h \ @@ -26,7 +27,8 @@ HEADERS = \ qxlibclipboard.h \ qxlibmime.h \ qxlibstatic.h \ - qxlibdisplay.h + qxlibdisplay.h \ + qxlibnativeinterface.h LIBS += -lX11 -lXext @@ -39,6 +41,7 @@ include (../fontdatabases/genericunix/genericunix.pri) contains(QT_CONFIG, opengl) { QT += opengl !contains(QT_CONFIG, opengles2) { + include (../glxconvenience/glxconvenience.pri) HEADERS += qglxintegration.h SOURCES += qglxintegration.cpp } else { # There is no easy way to detect if we'r suppose to use glx or not |