diff options
author | Samuel Rødal <samuel.rodal@nokia.com> | 2011-04-26 16:21:58 +0200 |
---|---|---|
committer | Samuel Rødal <samuel.rodal@nokia.com> | 2011-04-28 15:38:51 +0200 |
commit | ef77e8b65149a29a541044239fccf5e14b95e94d (patch) | |
tree | 8182a140efbb517407f1039b6795c67819a31405 /src | |
parent | fbef41167aa4aede67bc1ec904142e2e5e12c7fc (diff) |
Added QWindowContext and got wiggly up and running with xcb.
(cherry picked from commit c980e4ef4ebc7699a6c3a7529d3f08ebafc21ffe)
Diffstat (limited to 'src')
27 files changed, 646 insertions, 434 deletions
diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index daf9c9405e..71a6a24fa9 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -221,6 +221,7 @@ qpa { kernel/qplatformintegrationplugin_qpa.h \ kernel/qplatformwindow_qpa.h \ kernel/qplatformglcontext_qpa.h \ + kernel/qwindowcontext_qpa.h \ kernel/qdesktopwidget_qpa_p.h \ kernel/qplatformeventloopintegration_qpa.h \ kernel/qplatformcursor_qpa.h \ @@ -248,6 +249,7 @@ qpa { kernel/qplatformwindow_qpa.cpp \ kernel/qplatformeventloopintegration_qpa.cpp \ kernel/qplatformglcontext_qpa.cpp \ + kernel/qwindowcontext_qpa.cpp \ kernel/qplatformcursor_qpa.cpp \ kernel/qplatformclipboard_qpa.cpp \ kernel/qplatformnativeinterface_qpa.cpp \ diff --git a/src/gui/kernel/qplatformglcontext_qpa.cpp b/src/gui/kernel/qplatformglcontext_qpa.cpp index 181053223f..2177a01d9b 100644 --- a/src/gui/kernel/qplatformglcontext_qpa.cpp +++ b/src/gui/kernel/qplatformglcontext_qpa.cpp @@ -41,134 +41,6 @@ #include "qplatformglcontext_qpa.h" -#include <QtCore/QThreadStorage> -#include <QtCore/QThread> - -#include <QDebug> - -class QPlatformGLThreadContext -{ -public: - ~QPlatformGLThreadContext() { - if (context) - context->doneCurrent(); - } - QPlatformGLContext *context; -}; - -static QThreadStorage<QPlatformGLThreadContext *> qplatformgl_context_storage; - -class QPlatformGLContextPrivate -{ -public: - QPlatformGLContextPrivate() - :qGLContextHandle(0) - { - } - - virtual ~QPlatformGLContextPrivate() - { - //do not delete the QGLContext handle here as it is deleted in - //QWidgetPrivate::deleteTLSysExtra() - } - void *qGLContextHandle; - void (*qGLContextDeleteFunction)(void *handle); - static QPlatformGLContext *staticSharedContext; - - static void setCurrentContext(QPlatformGLContext *context); -}; - -QPlatformGLContext *QPlatformGLContextPrivate::staticSharedContext = 0; - -void QPlatformGLContextPrivate::setCurrentContext(QPlatformGLContext *context) -{ - QPlatformGLThreadContext *threadContext = qplatformgl_context_storage.localData(); - if (!threadContext) { - if (!QThread::currentThread()) { - qWarning("No QTLS available. currentContext wont work"); - return; - } - threadContext = new QPlatformGLThreadContext; - qplatformgl_context_storage.setLocalData(threadContext); - } - threadContext->context = context; -} - -/*! - Returns the last context which called makeCurrent. This function is thread aware. -*/ -const QPlatformGLContext* QPlatformGLContext::currentContext() -{ - QPlatformGLThreadContext *threadContext = qplatformgl_context_storage.localData(); - if(threadContext) { - return threadContext->context; - } - return 0; -} - -/*! - All subclasses needs to specify the platformWindow. It can be a null window. -*/ -QPlatformGLContext::QPlatformGLContext() - :d_ptr(new QPlatformGLContextPrivate()) -{ -} - -/*! - If this is the current context for the thread, doneCurrent is called -*/ -QPlatformGLContext::~QPlatformGLContext() -{ - if (QPlatformGLContext::currentContext() == this) { - doneCurrent(); - } - -} - -/*! - Reimplement in subclass to do makeCurrent on native GL context -*/ -void QPlatformGLContext::makeCurrent() -{ - QPlatformGLContextPrivate::setCurrentContext(this); -} - -/*! - Reimplement in subclass to release current context. - Typically this is calling makeCurrent with 0 "surface" -*/ -void QPlatformGLContext::doneCurrent() -{ - QPlatformGLContextPrivate::setCurrentContext(0); -} - -/* - internal: Needs to have a pointer to qGLContext. But since this is in QtGui we cant - have any type information. -*/ -void *QPlatformGLContext::qGLContextHandle() const -{ - Q_D(const QPlatformGLContext); - return d->qGLContextHandle; -} - -void QPlatformGLContext::setQGLContextHandle(void *handle,void (*qGLContextDeleteFunction)(void *)) -{ - Q_D(QPlatformGLContext); - d->qGLContextHandle = handle; - d->qGLContextDeleteFunction = qGLContextDeleteFunction; -} - -void QPlatformGLContext::deleteQGLContext() -{ - Q_D(QPlatformGLContext); - if (d->qGLContextDeleteFunction && d->qGLContextHandle) { - d->qGLContextDeleteFunction(d->qGLContextHandle); - d->qGLContextDeleteFunction = 0; - d->qGLContextHandle = 0; - } -} - /*! \class QPlatformGLContext \since 4.8 diff --git a/src/gui/kernel/qplatformglcontext_qpa.h b/src/gui/kernel/qplatformglcontext_qpa.h index 5a22bc769a..fbd43b2b48 100644 --- a/src/gui/kernel/qplatformglcontext_qpa.h +++ b/src/gui/kernel/qplatformglcontext_qpa.h @@ -43,7 +43,7 @@ #define QPLATFORM_GL_CONTEXT_H #include <QtCore/qnamespace.h> -#include <QtGui/QWindowFormat> +#include <QtGui/qwindowformat_qpa.h> QT_BEGIN_HEADER @@ -51,36 +51,17 @@ QT_BEGIN_NAMESPACE QT_MODULE(Gui) -class QPlatformGLContextPrivate; - -class Q_OPENGL_EXPORT QPlatformGLContext +class Q_GUI_EXPORT QPlatformGLContext { -Q_DECLARE_PRIVATE(QPlatformGLContext); - public: - explicit QPlatformGLContext(); - virtual ~QPlatformGLContext(); + virtual ~QPlatformGLContext() {} - virtual void makeCurrent(); - virtual void doneCurrent(); + virtual void makeCurrent() = 0; + virtual void doneCurrent() = 0; virtual void swapBuffers() = 0; - virtual void* getProcAddress(const QString& procName) = 0; + virtual void *getProcAddress(const QString& procName) = 0; virtual QWindowFormat windowFormat() const = 0; - - const static QPlatformGLContext *currentContext(); - -protected: - QScopedPointer<QPlatformGLContextPrivate> d_ptr; - -private: - //hack to make it work with QGLContext::CurrentContext - friend class QGLContext; - friend class QWidgetPrivate; - void *qGLContextHandle() const; - void setQGLContextHandle(void *handle,void (*qGLContextDeleteFunction)(void *)); - void deleteQGLContext(); - Q_DISABLE_COPY(QPlatformGLContext); }; QT_END_NAMESPACE @@ -88,4 +69,4 @@ QT_END_NAMESPACE QT_END_HEADER -#endif // QPLATFORM_GL_INTEGRATION_P_H +#endif // QPLATFORM_GL_CONTEXT_H diff --git a/src/gui/kernel/qplatformintegration_qpa.h b/src/gui/kernel/qplatformintegration_qpa.h index 1517fc4fce..43080d297a 100644 --- a/src/gui/kernel/qplatformintegration_qpa.h +++ b/src/gui/kernel/qplatformintegration_qpa.h @@ -77,7 +77,7 @@ public: // GraphicsSystem functions virtual QPixmapData *createPixmapData(QPixmapData::PixelType type) const = 0; - virtual QPlatformWindow *createPlatformWindow(QWindow *window, const QWindowFormat &format) const = 0; + virtual QPlatformWindow *createPlatformWindow(QWindow *window) const = 0; virtual QWindowSurface *createWindowSurface(QWindow *window, WId winId) const = 0; // Window System functions diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index f153860ba9..d1abc8f96f 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -1761,10 +1761,6 @@ void QWidgetPrivate::createTLExtra() static int count = 0; qDebug() << "tlextra" << ++count; #endif -#if defined(Q_WS_QPA) - x->window = 0; - x->screenIndex = 0; -#endif } } diff --git a/src/gui/kernel/qwidget_qpa.cpp b/src/gui/kernel/qwidget_qpa.cpp index b5a75155da..efecb4407c 100644 --- a/src/gui/kernel/qwidget_qpa.cpp +++ b/src/gui/kernel/qwidget_qpa.cpp @@ -90,24 +90,24 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO return; // we only care about real toplevels QWindowSurface *surface = q->windowSurface(); -// QPlatformWindow *platformWindow = q->platformWindow(); -// if (!platformWindow) { -// platformWindow = QApplicationPrivate::platformIntegration()->createPlatformWindow(q); -// } -// Q_ASSERT(platformWindow); + QWindow *win = topData()->window; -// if (!surface ) { -// if (platformWindow && q->platformWindowFormat().hasWindowSurface()) { -// surface = QApplicationPrivate::platformIntegration()->createWindowSurface(q,platformWindow->winId()); -// } else { -// q->setAttribute(Qt::WA_PaintOnScreen,true); -// } -// } + // translate window type +// window->setWindowType(); + win->create(); + + if (!surface ) { + if (win) { + surface = QApplicationPrivate::platformIntegration()->createWindowSurface(win, win->winId()); + } else { + q->setAttribute(Qt::WA_PaintOnScreen,true); + } + } // data.window_flags = q->windowHandle()->setWindowFlags(data.window_flags); -// setWinId(q->platformWindow()->winId()); + setWinId(win->winId()); //first check children. and create them if necessary // q_createNativeChildrenAndSetParent(q->platformWindow(),q); @@ -211,7 +211,7 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) //qDebug() << "setParent_sys" << q << newparent << hex << f; // if (QPlatformWindow *window = q->platformWindow()) // data.window_flags = window->setWindowFlags(data.window_flags); - Q_ASSERT(false); +// Q_ASSERT(false); } if (q->isWindow() || (!newparent || newparent->isVisible()) || explicitlyHidden) @@ -705,6 +705,10 @@ void QWidgetPrivate::deleteSysExtra() void QWidgetPrivate::createTLSysExtra() { + Q_Q(QWidget); + extra->topextra->screenIndex = 0; + extra->topextra->window = new QWindow; + extra->topextra->window->setWidget(q); } void QWidgetPrivate::deleteTLSysExtra() diff --git a/src/gui/kernel/qwindow_qpa.cpp b/src/gui/kernel/qwindow_qpa.cpp index 15b0f9cd38..ad16179383 100644 --- a/src/gui/kernel/qwindow_qpa.cpp +++ b/src/gui/kernel/qwindow_qpa.cpp @@ -43,6 +43,8 @@ #include "qplatformwindow_qpa.h" #include "qwindowformat_qpa.h" +#include "qplatformglcontext_qpa.h" +#include "qwindowcontext_qpa.h" #include "qapplication_p.h" @@ -53,9 +55,10 @@ QT_BEGIN_NAMESPACE class QWindowPrivate : public QObjectPrivate { public: - QWindowPrivate(QWindow::WindowTypes types) + QWindowPrivate() : QObjectPrivate() - , windowTypes(types) + , windowType(QWindow::Window) + , surfaceType(QWindow::RasterSurface) , platformWindow(0) , glContext(0) , widget(0) @@ -68,19 +71,25 @@ public: } - QWindow::WindowTypes windowTypes; + QWindow::WindowType windowType; + QWindow::SurfaceType surfaceType; + QPlatformWindow *platformWindow; QWindowFormat requestedFormat; QString windowTitle; QRect geometry; - QGLContext *glContext; + QWindowContext *glContext; QWidget *widget; }; -QWindow::QWindow(WindowTypes types, QWindow *parent) - : QObject(*new QWindowPrivate(types), parent) +QWindow::QWindow(QWindow *parent) + : QObject(*new QWindowPrivate(), parent) { +} +QWindow::~QWindow() +{ + destroy(); } QWidget *QWindow::widget() const @@ -107,17 +116,16 @@ void QWindow::setVisible(bool visible) void QWindow::create() { Q_D(QWindow); - d->platformWindow = QApplicationPrivate::platformIntegration()->createPlatformWindow(this,d->requestedFormat); + d->platformWindow = QApplicationPrivate::platformIntegration()->createPlatformWindow(this); Q_ASSERT(d->platformWindow); } WId QWindow::winId() const { Q_D(const QWindow); - if(d->platformWindow) { - return d->platformWindow->winId(); - } - return 0; + if(!d->platformWindow) + const_cast<QWindow *>(this)->create(); + return d->platformWindow->winId(); } void QWindow::setParent(const QWindow *parent) @@ -148,14 +156,31 @@ QWindowFormat QWindow::requestedWindowFormat() const QWindowFormat QWindow::actualWindowFormat() const { + return glContext()->handle()->windowFormat(); +} + +void QWindow::setSurfaceType(SurfaceType type) +{ + Q_D(QWindow); + d->surfaceType = type; +} + +QWindow::SurfaceType QWindow::surfaceType() const +{ Q_D(const QWindow); - return d->requestedFormat; + return d->surfaceType; +} + +void QWindow::setWindowType(WindowType type) +{ + Q_D(QWindow); + d->windowType = type; } -QWindow::WindowTypes QWindow::types() const +QWindow::WindowType QWindow::type() const { Q_D(const QWindow); - return d->windowTypes; + return d->windowType; } void QWindow::setWindowTitle(const QString &title) @@ -262,9 +287,11 @@ void QWindow::setWindowIcon(const QImage &icon) const qDebug() << "unimplemented:" << __FILE__ << __LINE__; } -QGLContext * QWindow::glContext() const +QWindowContext * QWindow::glContext() const { Q_D(const QWindow); + if (!d->glContext) + const_cast<QWindowPrivate *>(d)->glContext = new QWindowContext(const_cast<QWindow *>(this)); return d->glContext; } @@ -281,13 +308,22 @@ QWindowFormat QWindow::format() const void QWindow::destroy() { + Q_D(QWindow); //JA, this will be solved later.... // if (QGLContext *context = extra->topextra->window->glContext()) { // context->deleteQGLContext(); Q_ASSERT(false); + delete d->glContext; + d->glContext = 0; // } } +QPlatformWindow *QWindow::handle() const +{ + Q_D(const QWindow); + return d->platformWindow; +} + void QWindow::showMinimized() { qDebug() << "unimplemented:" << __FILE__ << __LINE__; diff --git a/src/gui/kernel/qwindow_qpa.h b/src/gui/kernel/qwindow_qpa.h index d745fb0b4c..d9bd2950d1 100644 --- a/src/gui/kernel/qwindow_qpa.h +++ b/src/gui/kernel/qwindow_qpa.h @@ -53,7 +53,6 @@ QT_BEGIN_NAMESPACE QT_MODULE(Gui) class QWindowPrivate; -class QGLContext; class QWidget; class QResizeEvent; @@ -66,6 +65,9 @@ class QMouseEvent; class QWheelEvent; #endif +class QPlatformWindow; +class QWindowContext; + class Q_GUI_EXPORT QWindow : public QObject { Q_OBJECT @@ -75,16 +77,25 @@ class Q_GUI_EXPORT QWindow : public QObject public: enum WindowType { - Window = 0x00000001, - Dialog = 0x00000002, - Popup = 0x00000004, - ToolTip = 0x00000008 + Window, + Dialog, + Popup, + Tool, + SplashScreen, + ToolTip, + Sheet, + Drawer + }; + + enum SurfaceType { + RasterSurface, + OpenGLSurface }; - Q_DECLARE_FLAGS(WindowTypes, WindowType) - QWindow(QWindow::WindowTypes types = Window, QWindow *parent = 0); + QWindow(QWindow *parent = 0); + virtual ~QWindow(); - // to be removed at some poitn in the future + // to be removed at some point in the future QWidget *widget() const; void setWidget(QWidget *widget); @@ -98,7 +109,11 @@ public: QWindowFormat requestedWindowFormat() const; QWindowFormat actualWindowFormat() const; - WindowTypes types() const; + void setSurfaceType(SurfaceType type); + SurfaceType surfaceType() const; + + void setWindowType(WindowType type); + WindowType type() const; QString windowTitle() const; @@ -119,13 +134,15 @@ public: void setWindowIcon(const QImage &icon) const; - QGLContext *glContext() const; + QWindowContext *glContext() const; void setRequestFormat(const QWindowFormat &format); QWindowFormat format() const; void destroy(); + QPlatformWindow *handle() const; + public Q_SLOTS: inline void show() { setVisible(true); } inline void hide() { setVisible(false); } @@ -166,8 +183,6 @@ private: Q_DISABLE_COPY(QWindow) }; -Q_DECLARE_OPERATORS_FOR_FLAGS(QWindow::WindowTypes) - QT_END_NAMESPACE QT_END_HEADER diff --git a/src/gui/kernel/qwindowcontext_qpa.cpp b/src/gui/kernel/qwindowcontext_qpa.cpp new file mode 100644 index 0000000000..3dd48704ce --- /dev/null +++ b/src/gui/kernel/qwindowcontext_qpa.cpp @@ -0,0 +1,200 @@ +/**************************************************************************** +** +** 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 QtOpenGL module 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 "qplatformglcontext_qpa.h" +#include "qwindowcontext_qpa.h" + +#include <QtCore/QThreadStorage> +#include <QtCore/QThread> + +#include <QDebug> + +class QWindowThreadContext +{ +public: + ~QWindowThreadContext() { + if (context) + context->doneCurrent(); + } + QWindowContext *context; +}; + +static QThreadStorage<QWindowThreadContext *> qwindow_context_storage; + +class QWindowContextPrivate +{ +public: + QWindowContextPrivate() + :qGLContextHandle(0) + { + } + + virtual ~QWindowContextPrivate() + { + //do not delete the QGLContext handle here as it is deleted in + //QWidgetPrivate::deleteTLSysExtra() + } + void *qGLContextHandle; + void (*qGLContextDeleteFunction)(void *handle); + QPlatformGLContext *platformGLContext; + static QWindowContext *staticSharedContext; + + static void setCurrentContext(QWindowContext *context); +}; + +QWindowContext *QWindowContextPrivate::staticSharedContext = 0; + +void QWindowContextPrivate::setCurrentContext(QWindowContext *context) +{ + QWindowThreadContext *threadContext = qwindow_context_storage.localData(); + if (!threadContext) { + if (!QThread::currentThread()) { + qWarning("No QTLS available. currentContext wont work"); + return; + } + threadContext = new QWindowThreadContext; + qwindow_context_storage.setLocalData(threadContext); + } + threadContext->context = context; +} + +/*! + Returns the last context which called makeCurrent. This function is thread aware. +*/ +QWindowContext* QWindowContext::currentContext() +{ + QWindowThreadContext *threadContext = qwindow_context_storage.localData(); + if(threadContext) { + return threadContext->context; + } + return 0; +} + +QPlatformGLContext *QWindowContext::handle() const +{ + Q_D(const QWindowContext); + return d->platformGLContext; +} + +/*! + All subclasses needs to specify the platformWindow. It can be a null window. +*/ +QWindowContext::QWindowContext(QWindow *window) + :d_ptr(new QWindowContextPrivate()) +{ + Q_D(QWindowContext); + Q_ASSERT(window); + if (!window->handle()) + window->create(); + d->platformGLContext = window->handle()->glContext(); +} + +/*! + If this is the current context for the thread, doneCurrent is called +*/ +QWindowContext::~QWindowContext() +{ + if (QWindowContext::currentContext() == this) { + doneCurrent(); + } + +} + +/*! + Reimplement in subclass to do makeCurrent on native GL context +*/ +void QWindowContext::makeCurrent() +{ + Q_D(QWindowContext); + QWindowContextPrivate::setCurrentContext(this); + d->platformGLContext->makeCurrent(); +} + +/*! + Reimplement in subclass to release current context. + Typically this is calling makeCurrent with 0 "surface" +*/ +void QWindowContext::doneCurrent() +{ + Q_D(QWindowContext); + d->platformGLContext->doneCurrent(); + QWindowContextPrivate::setCurrentContext(0); +} + +void QWindowContext::swapBuffers() +{ + Q_D(QWindowContext); + d->platformGLContext->swapBuffers(); +} + +void (*QWindowContext::getProcAddress(const QByteArray &procName)) () +{ + Q_D(QWindowContext); + void *result = d->platformGLContext->getProcAddress(QString::fromAscii(procName.constData())); + return (void (*)())result; +} + +/* + internal: Needs to have a pointer to qGLContext. But since this is in QtGui we cant + have any type information. +*/ +void *QWindowContext::qGLContextHandle() const +{ + Q_D(const QWindowContext); + return d->qGLContextHandle; +} + +void QWindowContext::setQGLContextHandle(void *handle,void (*qGLContextDeleteFunction)(void *)) +{ + Q_D(QWindowContext); + d->qGLContextHandle = handle; + d->qGLContextDeleteFunction = qGLContextDeleteFunction; +} + +void QWindowContext::deleteQGLContext() +{ + Q_D(QWindowContext); + if (d->qGLContextDeleteFunction && d->qGLContextHandle) { + d->qGLContextDeleteFunction(d->qGLContextHandle); + d->qGLContextDeleteFunction = 0; + d->qGLContextHandle = 0; + } +} diff --git a/src/gui/kernel/qwindowcontext_qpa.h b/src/gui/kernel/qwindowcontext_qpa.h new file mode 100644 index 0000000000..c16666a7f4 --- /dev/null +++ b/src/gui/kernel/qwindowcontext_qpa.h @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** 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 QtOpenGL module 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 QWINDOWCONTEXT_H +#define QWINDOWCONTEXT_H + +#include <QtCore/qnamespace.h> + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Gui) + +class QWindowContextPrivate; +class QPlatformGLContext; + +class Q_GUI_EXPORT QWindowContext +{ +Q_DECLARE_PRIVATE(QWindowContext); +public: + ~QWindowContext(); + + void makeCurrent(); + void doneCurrent(); + void swapBuffers(); + void (*getProcAddress(const QByteArray &procName)) (); + + static QWindowContext *currentContext(); + + QPlatformGLContext *handle() const; + +private: + QWindowContext(QWindow *window); + + QScopedPointer<QWindowContextPrivate> d_ptr; + + //hack to make it work with QGLContext::CurrentContext + friend class QGLContext; + friend class QWidgetPrivate; + friend class QWindow; + void *qGLContextHandle() const; + void setQGLContextHandle(void *handle,void (*qGLContextDeleteFunction)(void *)); + void deleteQGLContext(); + Q_DISABLE_COPY(QWindowContext); +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QWINDOWCONTEXT_H diff --git a/src/gui/kernel/qwindowformat_qpa.cpp b/src/gui/kernel/qwindowformat_qpa.cpp index 831e1a91b8..03ccba7b07 100644 --- a/src/gui/kernel/qwindowformat_qpa.cpp +++ b/src/gui/kernel/qwindowformat_qpa.cpp @@ -41,6 +41,8 @@ #include "qwindowformat_qpa.h" +#include "qplatformglcontext_qpa.h" + #include <QtCore/QDebug> class QWindowFormatPrivate @@ -49,9 +51,13 @@ public: QWindowFormatPrivate() : ref(1) , opts(QWindowFormat::DoubleBuffer | QWindowFormat::WindowSurface) + , redBufferSize(-1) + , greenBufferSize(-1) + , blueBufferSize(-1) + , alphaBufferSize(-1) , depthSize(-1) , stencilSize(-1) - , colorFormat(QWindowFormat::RGB888) + , swapBehavior(QWindowFormat::DefaultSwapBehavior) , numSamples(-1) , sharedContext(0) { @@ -60,9 +66,12 @@ public: QWindowFormatPrivate(const QWindowFormatPrivate *other) : ref(1), opts(other->opts), + redBufferSize(other->redBufferSize), + greenBufferSize(other->greenBufferSize), + blueBufferSize(other->blueBufferSize), + alphaBufferSize(other->alphaBufferSize), depthSize(other->depthSize), stencilSize(other->stencilSize), - colorFormat(other->colorFormat), swapBehavior(other->swapBehavior), numSamples(other->numSamples), sharedContext(other->sharedContext) @@ -70,12 +79,15 @@ public: } QAtomicInt ref; QWindowFormat::FormatOptions opts; + int redBufferSize; + int greenBufferSize; + int blueBufferSize; + int alphaBufferSize; int depthSize; int stencilSize; - QWindowFormat::ColorFormat colorFormat; QWindowFormat::SwapBehavior swapBehavior; int numSamples; - QPlatformGLContext *sharedContext; + QWindowContext *sharedContext; }; QWindowFormat::QWindowFormat() @@ -193,12 +205,12 @@ void QWindowFormat::setSamples(int numSamples) -void QWindowFormat::setSharedContext(QPlatformGLContext *context) +void QWindowFormat::setSharedContext(QWindowContext *context) { d->sharedContext = context; } -QPlatformGLContext *QWindowFormat::sharedGLContext() const +QWindowContext *QWindowFormat::sharedContext() const { return d->sharedContext; } @@ -268,15 +280,19 @@ int QWindowFormat::depthBufferSize() const return d->depthSize; } -void QWindowFormat::setColorFormat(ColorFormat format) +void QWindowFormat::setSwapBehavior(SwapBehavior behavior) { - detach(); - d->colorFormat = format; + d->swapBehavior = behavior; +} + +QWindowFormat::SwapBehavior QWindowFormat::swapBehavior() const +{ + return d->swapBehavior; } -QWindowFormat::ColorFormat QWindowFormat::colorFormat() const +bool QWindowFormat::hasAlpha() const { - return d->colorFormat; + return d->alphaBufferSize > 0; } /*! @@ -300,12 +316,55 @@ int QWindowFormat::stencilBufferSize() const return d->stencilSize; } +int QWindowFormat::redBufferSize() const +{ + return d->redBufferSize; +} + +int QWindowFormat::greenBufferSize() const +{ + return d->greenBufferSize; +} + +int QWindowFormat::blueBufferSize() const +{ + return d->blueBufferSize; +} + +int QWindowFormat::alphaBufferSize() const +{ + return d->alphaBufferSize; +} + +void QWindowFormat::setRedBufferSize(int size) +{ + d->redBufferSize = size; +} + +void QWindowFormat::setGreenBufferSize(int size) +{ + d->greenBufferSize = size; +} + +void QWindowFormat::setBlueBufferSize(int size) +{ + d->blueBufferSize = size; +} + +void QWindowFormat::setAlphaBufferSize(int size) +{ + d->alphaBufferSize = size; +} + bool operator==(const QWindowFormat& a, const QWindowFormat& b) { return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts && a.d->stencilSize == b.d->stencilSize + && a.d->redBufferSize == b.d->redBufferSize + && a.d->greenBufferSize == b.d->greenBufferSize + && a.d->blueBufferSize == b.d->blueBufferSize + && a.d->alphaBufferSize == b.d->alphaBufferSize && a.d->depthSize == b.d->depthSize - && a.d->colorFormat == b.d->colorFormat && a.d->numSamples == b.d->numSamples && a.d->swapBehavior == b.d->swapBehavior && a.d->sharedContext == b.d->sharedContext); @@ -332,8 +391,11 @@ QDebug operator<<(QDebug dbg, const QWindowFormat &f) dbg.nospace() << "QWindowFormat(" << "options " << d->opts << ", depthBufferSize " << d->depthSize + << ", redBufferSize " << d->redBufferSize + << ", greenBufferSize " << d->greenBufferSize + << ", blueBufferSize " << d->blueBufferSize + << ", alphaBufferSize " << d->alphaBufferSize << ", stencilBufferSize " << d->stencilSize - << ", colorFormat " << d->colorFormat << ", samples " << d->numSamples << ", swapBehavior " << d->swapBehavior << ", sharedContext " << d->sharedContext diff --git a/src/gui/kernel/qwindowformat_qpa.h b/src/gui/kernel/qwindowformat_qpa.h index a1fdc9f576..9bc2ccdfaa 100644 --- a/src/gui/kernel/qwindowformat_qpa.h +++ b/src/gui/kernel/qwindowformat_qpa.h @@ -49,6 +49,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Gui) +class QWindowContext; class QWindowFormatPrivate; class Q_GUI_EXPORT QWindowFormat @@ -60,15 +61,6 @@ public: }; Q_DECLARE_FLAGS(FormatOptions, FormatOption) - enum ColorFormat { - InvalidColorFormat, - RGB565, - RGBA5658, - RGBA5551, - RGB888, - RGBA8888 - }; - enum SwapBehavior { DefaultSwapBehavior, SingleBuffer, @@ -94,20 +86,28 @@ public: void setStencilBufferSize(int size); int stencilBufferSize() const; + void setRedBufferSize(int size); + int redBufferSize() const; + void setGreenBufferSize(int size); + int greenBufferSize() const; + void setBlueBufferSize(int size); + int blueBufferSize() const; + void setAlphaBufferSize(int size); + int alphaBufferSize() const; + void setSamples(int numSamples); int samples() const; void setSwapBehavior(SwapBehavior behavior); SwapBehavior swapBehavior() const; - void setColorFormat(ColorFormat format); - ColorFormat colorFormat() const; + bool hasAlpha() const; void setProfile(OpenGLContextProfile profile); OpenGLContextProfile profile() const; - void setSharedContext(QPlatformGLContext *context); - QPlatformGLContext *sharedGLContext() const; + void setSharedContext(QWindowContext *context); + QWindowContext *sharedContext() const; bool stereo() const; void setStereo(bool enable); diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 057fb55e2c..64e711fe00 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1707,7 +1707,7 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format) vi = 0; #endif #if defined(Q_WS_QPA) - platformContext = 0; + windowContext = 0; #endif #if !defined(QT_NO_EGL) ownsEglContext = false; @@ -3313,7 +3313,7 @@ bool QGLContext::create(const QGLContext* shareContext) { Q_D(QGLContext); #ifdef Q_WS_QPA - if (!d->paintDevice && !d->platformContext) + if (!d->paintDevice && !d->windowContext) #else if (!d->paintDevice) #endif @@ -3403,8 +3403,8 @@ void QGLContext::setInitialized(bool on) const QGLContext* QGLContext::currentContext() { #ifdef Q_WS_QPA - if (const QPlatformGLContext *threadContext = QPlatformGLContext::currentContext()) { - return QGLContext::fromPlatformGLContext(const_cast<QPlatformGLContext *>(threadContext)); + if (const QWindowContext *threadContext = QWindowContext::currentContext()) { + return QGLContext::fromWindowContext(const_cast<QWindowContext *>(threadContext)); } return 0; #else diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h index c57995d8d0..55a06b5483 100644 --- a/src/opengl/qgl.h +++ b/src/opengl/qgl.h @@ -49,7 +49,7 @@ #include <QtCore/qscopedpointer.h> #ifdef Q_WS_QPA -#include <QtGui/QPlatformWindowFormat> +#include <QtGui/QWindowFormat> #endif QT_BEGIN_HEADER @@ -283,8 +283,8 @@ public: static OpenGLVersionFlags openGLVersionFlags(); #if defined(Q_WS_QPA) - static QGLFormat fromPlatformWindowFormat(const QPlatformWindowFormat &format); - static QPlatformWindowFormat toPlatformWindowFormat(const QGLFormat &format); + static QGLFormat fromWindowFormat(const QWindowFormat &format); + static QWindowFormat toWindowFormat(const QGLFormat &format); #endif private: QGLFormatPrivate *d; @@ -393,7 +393,7 @@ public: static const QGLContext* currentContext(); #ifdef Q_WS_QPA - static QGLContext *fromPlatformGLContext(QPlatformGLContext *platformContext); + static QGLContext *fromWindowContext(QWindowContext *platformContext); #endif protected: virtual bool chooseContext(const QGLContext* shareContext = 0); @@ -425,7 +425,7 @@ protected: private: #ifdef Q_WS_QPA - QGLContext(QPlatformGLContext *platformContext); + QGLContext(QWindowContext *windowContext); #endif QScopedPointer<QGLContextPrivate> d_ptr; diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 50d13c9540..4733a163e5 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -69,7 +69,7 @@ #endif #if defined(Q_WS_QPA) -#include <QtGui/QPlatformGLContext> +#include <QtGui/QWindowContext> #endif QT_BEGIN_NAMESPACE @@ -374,7 +374,7 @@ public: #endif #if defined(Q_WS_QPA) - QPlatformGLContext *platformContext; + QWindowContext *windowContext; void setupSharing(); #elif defined(Q_WS_X11) || defined(Q_WS_MAC) diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp index 994344c6eb..004d6c8314 100644 --- a/src/opengl/qgl_qpa.cpp +++ b/src/opengl/qgl_qpa.cpp @@ -45,81 +45,68 @@ #include <QDebug> #include <QtGui/private/qapplication_p.h> +#include <QtGui/QPlatformGLContext> #include <QtGui/QPlatformWindow> +#include <QtGui/QWindowContext> #include "qgl.h" #include "qgl_p.h" QT_BEGIN_NAMESPACE -QGLFormat QGLFormat::fromPlatformWindowFormat(const QPlatformWindowFormat &format) +QGLFormat QGLFormat::fromWindowFormat(const QWindowFormat &format) { QGLFormat retFormat; - retFormat.setAccum(format.accum()); - if (format.accumBufferSize() >= 0) - retFormat.setAccumBufferSize(format.accumBufferSize()); - retFormat.setAlpha(format.alpha()); if (format.alphaBufferSize() >= 0) retFormat.setAlphaBufferSize(format.alphaBufferSize()); if (format.blueBufferSize() >= 0) retFormat.setBlueBufferSize(format.blueBufferSize()); - retFormat.setDepth(format.depth()); - if (format.depthBufferSize() >= 0) - retFormat.setDepthBufferSize(format.depthBufferSize()); - retFormat.setDirectRendering(format.directRendering()); - retFormat.setDoubleBuffer(format.doubleBuffer()); if (format.greenBufferSize() >= 0) retFormat.setGreenBufferSize(format.greenBufferSize()); if (format.redBufferSize() >= 0) retFormat.setRedBufferSize(format.redBufferSize()); - retFormat.setRgba(format.rgba()); - retFormat.setSampleBuffers(format.sampleBuffers()); - retFormat.setSamples(format.sampleBuffers()); - retFormat.setStencil(format.stencil()); - if (format.stencilBufferSize() >= 0) + if (format.depthBufferSize() >= 0) + retFormat.setDepthBufferSize(format.depthBufferSize()); + if (format.samples() > 1) { + retFormat.setSampleBuffers(format.samples()); + retFormat.setSamples(true); + } + if (format.stencilBufferSize() > 0) { + retFormat.setStencil(true); retFormat.setStencilBufferSize(format.stencilBufferSize()); + } + retFormat.setDoubleBuffer(format.swapBehavior() != QWindowFormat::SingleBuffer); retFormat.setStereo(format.stereo()); - retFormat.setSwapInterval(format.swapInterval()); return retFormat; } -QPlatformWindowFormat QGLFormat::toPlatformWindowFormat(const QGLFormat &format) +QWindowFormat QGLFormat::toWindowFormat(const QGLFormat &format) { - QPlatformWindowFormat retFormat; - retFormat.setAccum(format.accum()); - if (format.accumBufferSize() >= 0) - retFormat.setAccumBufferSize(format.accumBufferSize()); - retFormat.setAlpha(format.alpha()); + QWindowFormat retFormat; if (format.alphaBufferSize() >= 0) retFormat.setAlphaBufferSize(format.alphaBufferSize()); if (format.blueBufferSize() >= 0) retFormat.setBlueBufferSize(format.blueBufferSize()); - retFormat.setDepth(format.depth()); - if (format.depthBufferSize() >= 0) - retFormat.setDepthBufferSize(format.depthBufferSize()); - retFormat.setDirectRendering(format.directRendering()); - retFormat.setDoubleBuffer(format.doubleBuffer()); if (format.greenBufferSize() >= 0) retFormat.setGreenBufferSize(format.greenBufferSize()); if (format.redBufferSize() >= 0) retFormat.setRedBufferSize(format.redBufferSize()); - retFormat.setRgba(format.rgba()); - retFormat.setSampleBuffers(format.sampleBuffers()); - if (format.samples() >= 0) + if (format.depthBufferSize() >= 0) + retFormat.setDepthBufferSize(format.depthBufferSize()); + retFormat.setSwapBehavior(format.doubleBuffer() ? QWindowFormat::DoubleBuffer : QWindowFormat::DefaultSwapBehavior); + if (format.sampleBuffers() && format.samples() > 1) retFormat.setSamples(format.samples()); - retFormat.setStencil(format.stencil()); - if (format.stencilBufferSize() >= 0) + if (format.stencil() && format.stencilBufferSize() > 0) retFormat.setStencilBufferSize(format.stencilBufferSize()); retFormat.setStereo(format.stereo()); - retFormat.setSwapInterval(format.swapInterval()); return retFormat; } void QGLContextPrivate::setupSharing() { Q_Q(QGLContext); - QPlatformGLContext *sharedPlatformGLContext = platformContext->platformWindowFormat().sharedGLContext(); - if (sharedPlatformGLContext) { - QGLContext *actualSharedContext = QGLContext::fromPlatformGLContext(sharedPlatformGLContext); + QWindowContext *sharedContext = windowContext->handle()->windowFormat().sharedContext(); + if (sharedContext) { + QGLContext *actualSharedContext = QGLContext::fromWindowContext(sharedContext); sharing = true; QGLContextGroup::addShare(q,actualSharedContext); } @@ -144,23 +131,23 @@ bool QGLContext::chooseContext(const QGLContext* shareContext) d->valid = false; }else { QWidget *widget = static_cast<QWidget *>(d->paintDevice); - if (!widget->platformWindow()){ + if (!widget->windowHandle()->handle()) { QGLFormat glformat = format(); - QPlatformWindowFormat winFormat = QGLFormat::toPlatformWindowFormat(glformat); + QWindowFormat winFormat = QGLFormat::toWindowFormat(glformat); if (shareContext) { - winFormat.setSharedContext(shareContext->d_func()->platformContext); + winFormat.setSharedContext(shareContext->d_func()->windowContext); } - winFormat.setWindowApi(QPlatformWindowFormat::OpenGL); + widget->windowHandle()->setSurfaceType(QWindow::OpenGLSurface); winFormat.setWindowSurface(false); - widget->setPlatformWindowFormat(winFormat); + widget->windowHandle()->setWindowFormat(winFormat); widget->winId();//make window } - d->platformContext = widget->platformWindow()->glContext(); - Q_ASSERT(d->platformContext); - d->glFormat = QGLFormat::fromPlatformWindowFormat(d->platformContext->platformWindowFormat()); - d->valid =(bool) d->platformContext; + d->windowContext = widget->windowHandle()->glContext(); + Q_ASSERT(d->windowContext); + d->glFormat = QGLFormat::fromWindowFormat(d->windowContext->handle()->windowFormat()); + d->valid =(bool) d->windowContext; if (d->valid) { - d->platformContext->setQGLContextHandle(this,qDeleteQGLContext); + d->windowContext->setQGLContextHandle(this,qDeleteQGLContext); } d->setupSharing(); } @@ -182,15 +169,15 @@ void QGLContext::reset() d->transpColor = QColor(); d->initDone = false; QGLContextGroup::removeShare(this); - if (d->platformContext) { - d->platformContext->setQGLContextHandle(0,0); + if (d->windowContext) { + d->windowContext->setQGLContextHandle(0,0); } } void QGLContext::makeCurrent() { Q_D(QGLContext); - d->platformContext->makeCurrent(); + d->windowContext->makeCurrent(); if (!d->workaroundsCached) { d->workaroundsCached = true; @@ -205,19 +192,19 @@ void QGLContext::makeCurrent() void QGLContext::doneCurrent() { Q_D(QGLContext); - d->platformContext->doneCurrent(); + d->windowContext->doneCurrent(); } void QGLContext::swapBuffers() const { Q_D(const QGLContext); - d->platformContext->swapBuffers(); + d->windowContext->swapBuffers(); } void *QGLContext::getProcAddress(const QString &procName) const { Q_D(const QGLContext); - return d->platformContext->getProcAddress(procName); + return (void *)d->windowContext->getProcAddress(procName.toAscii()); } void QGLWidget::setContext(QGLContext *context, @@ -275,33 +262,32 @@ void QGLContext::generateFontDisplayLists(const QFont & fnt, int listBase) class QGLTemporaryContextPrivate { public: - QWidget *widget; - QPlatformGLContext *context; + QWindow *window; + QWindowContext *context; }; QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *) : d(new QGLTemporaryContextPrivate) { - d->context = const_cast<QPlatformGLContext *>(QPlatformGLContext::currentContext()); + d->context = const_cast<QWindowContext *>(QWindowContext::currentContext()); if (d->context) d->context->doneCurrent(); - d->widget = new QWidget; - d->widget->setGeometry(0,0,3,3); - QPlatformWindowFormat format = d->widget->platformWindowFormat(); - format.setWindowApi(QPlatformWindowFormat::OpenGL); - format.setWindowSurface(false); - d->widget->setPlatformWindowFormat(format); - d->widget->winId(); - - d->widget->platformWindow()->glContext()->makeCurrent(); + + d->window = new QWindow; + d->window->setGeometry(QRect(0, 0, 3, 3)); + d->window->setSurfaceType(QWindow::OpenGLSurface); + d->window->create(); + + d->window->glContext()->makeCurrent(); } QGLTemporaryContext::~QGLTemporaryContext() { - d->widget->platformWindow()->glContext()->doneCurrent(); if (d->context) d->context->makeCurrent(); - delete d->widget; + else + d->window->glContext()->doneCurrent(); + delete d->window; } @@ -367,25 +353,25 @@ void QGLWidget::setColormap(const QGLColormap & c) Q_UNUSED(c); } -QGLContext::QGLContext(QPlatformGLContext *platformContext) +QGLContext::QGLContext(QWindowContext *windowContext) : d_ptr(new QGLContextPrivate(this)) { Q_D(QGLContext); - d->init(0,QGLFormat::fromPlatformWindowFormat(platformContext->platformWindowFormat())); - d->platformContext = platformContext; - d->platformContext->setQGLContextHandle(this,qDeleteQGLContext); + d->init(0,QGLFormat::fromWindowFormat(windowContext->handle()->windowFormat())); + d->windowContext = windowContext; + d->windowContext->setQGLContextHandle(this,qDeleteQGLContext); d->valid = true; d->setupSharing(); } -QGLContext *QGLContext::fromPlatformGLContext(QPlatformGLContext *platformContext) +QGLContext *QGLContext::fromWindowContext(QWindowContext *windowContext) { - if (!platformContext) + if (!windowContext) return 0; - if (platformContext->qGLContextHandle()) { - return reinterpret_cast<QGLContext *>(platformContext->qGLContextHandle()); + if (windowContext->qGLContextHandle()) { + return reinterpret_cast<QGLContext *>(windowContext->qGLContextHandle()); } - QGLContext *glContext = new QGLContext(platformContext); + QGLContext *glContext = new QGLContext(windowContext); //Dont call create on context. This can cause the platformFormat to be set on the widget, which //will cause the platformWindow to be recreated. return glContext; diff --git a/src/plugins/platforms/glxconvenience/qglxconvenience.cpp b/src/plugins/platforms/glxconvenience/qglxconvenience.cpp index 7cee3e2ea1..abf7b83e04 100644 --- a/src/plugins/platforms/glxconvenience/qglxconvenience.cpp +++ b/src/plugins/platforms/glxconvenience/qglxconvenience.cpp @@ -66,7 +66,7 @@ enum { #undef FontChange #endif -QVector<int> qglx_buildSpec(const QPlatformWindowFormat &format, int drawableBit) +QVector<int> qglx_buildSpec(const QWindowFormat &format, int drawableBit) { QVector<int> spec(48); int i = 0; @@ -75,54 +75,37 @@ QVector<int> qglx_buildSpec(const QPlatformWindowFormat &format, int drawableBit spec[i++] = 0; spec[i++] = GLX_DRAWABLE_TYPE; spec[i++] = drawableBit; - 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_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.hasAlpha()) { + spec[i++] = GLX_ALPHA_SIZE; spec[i++] = (format.alphaBufferSize() == -1) ? 1 : format.alphaBufferSize(); } - spec[i++] = GLX_DOUBLEBUFFER; spec[i++] = format.doubleBuffer() ? True : False; + spec[i++] = GLX_DOUBLEBUFFER; spec[i++] = format.swapBehavior() != QWindowFormat::SingleBuffer ? 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(); - } + 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_STENCIL_SIZE; spec[i++] = (format.stencilBufferSize() == -1) ? 1 : format.stencilBufferSize(); + + if (format.samples() > 1) { spec[i++] = GLX_SAMPLE_BUFFERS_ARB; spec[i++] = 1; spec[i++] = GLX_SAMPLES_ARB; - spec[i++] = format.samples() == -1 ? 4 : format.samples(); + spec[i++] = format.samples(); } spec[i++] = XNone; return spec; } -GLXFBConfig qglx_findConfig(Display *display, int screen , const QPlatformWindowFormat &format, int drawableBit) +GLXFBConfig qglx_findConfig(Display *display, int screen , const QWindowFormat &format, int drawableBit) { bool reduced = true; GLXFBConfig chosenConfig = 0; - QPlatformWindowFormat reducedFormat = format; + QWindowFormat reducedFormat = format; while (!chosenConfig && reduced) { QVector<int> spec = qglx_buildSpec(reducedFormat, drawableBit); int confcount = 0; @@ -133,7 +116,7 @@ GLXFBConfig qglx_findConfig(Display *display, int screen , const QPlatformWindow 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()) { + if (reducedFormat.hasAlpha()) { int alphaSize; glXGetFBConfigAttrib(display,configs[i],GLX_ALPHA_SIZE,&alphaSize); if (alphaSize > 0) @@ -145,7 +128,7 @@ GLXFBConfig qglx_findConfig(Display *display, int screen , const QPlatformWindow XFree(configs); } - reducedFormat = qglx_reducePlatformWindowFormat(reducedFormat,&reduced); + reducedFormat = qglx_reduceWindowFormat(reducedFormat,&reduced); } if (!chosenConfig) @@ -154,16 +137,16 @@ GLXFBConfig qglx_findConfig(Display *display, int screen , const QPlatformWindow return chosenConfig; } -XVisualInfo *qglx_findVisualInfo(Display *display, int screen, const QPlatformWindowFormat &format) +XVisualInfo *qglx_findVisualInfo(Display *display, int screen, const QWindowFormat &format) { GLXFBConfig config = qglx_findConfig(display,screen,format); XVisualInfo *visualInfo = glXGetVisualFromFBConfig(display,config); return visualInfo; } -QPlatformWindowFormat qglx_platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext ctx) +QWindowFormat qglx_platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext) { - QPlatformWindowFormat format; + QWindowFormat format; int redSize = 0; int greenSize = 0; int blueSize = 0; @@ -172,16 +155,9 @@ QPlatformWindowFormat qglx_platformWindowFromGLXFBConfig(Display *display, GLXFB 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); @@ -190,12 +166,7 @@ QPlatformWindowFormat qglx_platformWindowFromGLXFBConfig(Display *display, GLXFB 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); @@ -203,39 +174,31 @@ QPlatformWindowFormat qglx_platformWindowFromGLXFBConfig(Display *display, GLXFB format.setAlphaBufferSize(alphaSize); format.setDepthBufferSize(depthSize); format.setStencilBufferSize(stencilSize); - format.setSampleBuffers(sampleBuffers); - if (format.sampleBuffers()) { + if (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 qglx_reducePlatformWindowFormat(const QPlatformWindowFormat &format, bool *reduced) +QWindowFormat qglx_reduceWindowFormat(const QWindowFormat &format, bool *reduced) { - QPlatformWindowFormat retFormat = format; + QWindowFormat retFormat = format; *reduced = true; - if (retFormat.sampleBuffers()) { - retFormat.setSampleBuffers(false); + if (retFormat.samples() > 1) { + retFormat.setSamples(0); } 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 if (retFormat.stencilBufferSize() > 0) { + retFormat.setStencilBufferSize(0); + }else if (retFormat.hasAlpha()) { + retFormat.setAlphaBufferSize(0); + }else if (retFormat.depthBufferSize() > 0) { + retFormat.setDepthBufferSize(0); }else{ *reduced = false; } diff --git a/src/plugins/platforms/glxconvenience/qglxconvenience.h b/src/plugins/platforms/glxconvenience/qglxconvenience.h index 2c59dbb324..765a08a39d 100644 --- a/src/plugins/platforms/glxconvenience/qglxconvenience.h +++ b/src/plugins/platforms/glxconvenience/qglxconvenience.h @@ -42,15 +42,15 @@ #ifndef QGLXCONVENIENCE_H #define QGLXCONVENIENCE_H -#include <QPlatformWindowFormat> +#include <QWindowFormat> #include <X11/Xlib.h> #include <GL/glx.h> -XVisualInfo *qglx_findVisualInfo(Display *display, int screen, const QPlatformWindowFormat &format); -GLXFBConfig qglx_findConfig(Display *display, int screen, const QPlatformWindowFormat &format, int drawableBit = GLX_WINDOW_BIT); -QPlatformWindowFormat qglx_platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext context); -QVector<int> qglx_buildSpec(const QPlatformWindowFormat &format, int drawableBit = GLX_WINDOW_BIT); -QPlatformWindowFormat qglx_reducePlatformWindowFormat(const QPlatformWindowFormat &format, bool *reduced); +XVisualInfo *qglx_findVisualInfo(Display *display, int screen, const QWindowFormat &format); +GLXFBConfig qglx_findConfig(Display *display, int screen, const QWindowFormat &format, int drawableBit = GLX_WINDOW_BIT); +QWindowFormat qglx_platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext context); +QVector<int> qglx_buildSpec(const QWindowFormat &format, int drawableBit = GLX_WINDOW_BIT); +QWindowFormat qglx_reduceWindowFormat(const QWindowFormat &format, bool *reduced); #endif // QGLXCONVENIENCE_H diff --git a/src/plugins/platforms/xcb/qglxintegration.cpp b/src/plugins/platforms/xcb/qglxintegration.cpp index 190221c5f4..3af627c324 100644 --- a/src/plugins/platforms/xcb/qglxintegration.cpp +++ b/src/plugins/platforms/xcb/qglxintegration.cpp @@ -50,6 +50,8 @@ #include <X11/Xutil.h> #include <GL/glx.h> +#include <QtGui/QWindowContext> + #include "qglxintegration.h" #include "qglxconvenience.h" @@ -57,18 +59,17 @@ #include <dlfcn.h> #endif -QGLXContext::QGLXContext(Window window, QXcbScreen *screen, const QPlatformWindowFormat &format) +QGLXContext::QGLXContext(Window window, QXcbScreen *screen, const QWindowFormat &format) : QPlatformGLContext() , m_screen(screen) , m_drawable((Drawable)window) , m_context(0) { Q_XCB_NOOP(m_screen->connection()); - const QPlatformGLContext *sharePlatformContext; - sharePlatformContext = format.sharedGLContext(); + const QWindowContext *shareContext = format.sharedContext(); GLXContext shareGlxContext = 0; - if (sharePlatformContext) - shareGlxContext = static_cast<const QGLXContext*>(sharePlatformContext)->glxContext(); + if (shareContext) + shareGlxContext = static_cast<const QGLXContext*>(shareContext->handle())->glxContext(); GLXFBConfig config = qglx_findConfig(DISPLAY_FROM_XCB(screen),screen->screenNumber(),format); m_context = glXCreateNewContext(DISPLAY_FROM_XCB(screen), config, GLX_RGBA_TYPE, shareGlxContext, TRUE); @@ -148,7 +149,7 @@ void* QGLXContext::getProcAddress(const QString& procName) return glXGetProcAddressARB(reinterpret_cast<const GLubyte *>(procName.toLatin1().data())); } -QPlatformWindowFormat QGLXContext::platformWindowFormat() const +QWindowFormat QGLXContext::windowFormat() const { return m_windowFormat; } diff --git a/src/plugins/platforms/xcb/qglxintegration.h b/src/plugins/platforms/xcb/qglxintegration.h index 99b72a04b5..4450083959 100644 --- a/src/plugins/platforms/xcb/qglxintegration.h +++ b/src/plugins/platforms/xcb/qglxintegration.h @@ -45,7 +45,7 @@ #include "qxcbwindow.h" #include <QtGui/QPlatformGLContext> -#include <QtGui/QPlatformWindowFormat> +#include <QtGui/QWindowFormat> #include <QtCore/QMutex> @@ -54,7 +54,7 @@ class QGLXContext : public QPlatformGLContext { public: - QGLXContext(Window window, QXcbScreen *xd, const QPlatformWindowFormat &format); + QGLXContext(Window window, QXcbScreen *xd, const QWindowFormat &format); ~QGLXContext(); virtual void makeCurrent(); @@ -64,13 +64,13 @@ public: GLXContext glxContext() const { return m_context; } - QPlatformWindowFormat platformWindowFormat() const; + QWindowFormat windowFormat() const; private: QXcbScreen *m_screen; Drawable m_drawable; GLXContext m_context; - QPlatformWindowFormat m_windowFormat; + QWindowFormat m_windowFormat; QGLXContext (QXcbScreen *screen, Drawable drawable, GLXContext context); }; diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index 7ad12fe8b1..bae02fda2e 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -147,15 +147,16 @@ QXcbWindow *platformWindowFromId(xcb_window_t id) { QWidget *widget = QWidget::find(id); if (widget) - return static_cast<QXcbWindow *>(widget->platformWindow()); + return static_cast<QXcbWindow *>(widget->windowHandle()->handle()); return 0; } -#define HANDLE_PLATFORM_WINDOW_EVENT(event_t, window, handler) \ +#define HANDLE_PLATFORM_WINDOW_EVENT(event_t, windowMember, handler) \ { \ event_t *e = (event_t *)event; \ - if (QXcbWindow *platformWindow = platformWindowFromId(e->window)) { \ - QObjectPrivate *d = QObjectPrivate::get(platformWindow->widget()); \ + if (QXcbWindow *platformWindow = platformWindowFromId(e->windowMember)) { \ + QWindow *windowHandle = platformWindow->window(); \ + QObjectPrivate *d = QObjectPrivate::get(windowHandle->widget()); \ if (!d->wasDeleted) \ platformWindow->handler(e); \ } \ @@ -166,7 +167,7 @@ break; { \ event_t *e = (event_t *)event; \ if (QXcbWindow *platformWindow = platformWindowFromId(e->event)) \ - m_keyboard->handler(platformWindow->widget(), e); \ + m_keyboard->handler(platformWindow->window()->widget(), e); \ } \ break; diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp index 9df5f14114..80f375c6b2 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.cpp +++ b/src/plugins/platforms/xcb/qxcbintegration.cpp @@ -87,16 +87,15 @@ QPixmapData *QXcbIntegration::createPixmapData(QPixmapData::PixelType type) cons return new QRasterPixmapData(type); } -QPlatformWindow *QXcbIntegration::createPlatformWindow(QWidget *widget, WId winId) const +QPlatformWindow *QXcbIntegration::createPlatformWindow(QWindow *window) const { - Q_UNUSED(winId); - return new QXcbWindow(widget); + return new QXcbWindow(window); } -QWindowSurface *QXcbIntegration::createWindowSurface(QWidget *widget, WId winId) const +QWindowSurface *QXcbIntegration::createWindowSurface(QWindow *window, WId winId) const { Q_UNUSED(winId); - return new QXcbWindowSurface(widget); + return new QXcbWindowSurface(window->widget()); } QList<QPlatformScreen *> QXcbIntegration::screens() const diff --git a/src/plugins/platforms/xcb/qxcbintegration.h b/src/plugins/platforms/xcb/qxcbintegration.h index d27fd716ab..0de6f15657 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.h +++ b/src/plugins/platforms/xcb/qxcbintegration.h @@ -57,8 +57,8 @@ public: 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; + QPlatformWindow *createPlatformWindow(QWindow *window) const; + QWindowSurface *createWindowSurface(QWindow *window, WId winId) const; QList<QPlatformScreen *> screens() const; void moveToScreen(QWidget *window, int screen); diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp index b2ca1beb6e..bef2d573d0 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp @@ -48,6 +48,8 @@ #include <QtCore/QDebug> +#include <QtGui/qwindowcontext_qpa.h> + #if defined(XCB_USE_EGL) #include "../eglconvenience/qeglplatformcontext.h" #elif defined (XCB_USE_DRI2) @@ -162,14 +164,14 @@ void *QXcbNativeInterface::graphicsDeviceForWidget(QWidget *widget) void * QXcbNativeInterface::eglContextForWidget(QWidget *widget) { Q_ASSERT(widget); - if (!widget->platformWindow()) { + if (!widget->windowHandle()) { qDebug() << "QPlatformWindow does not exist for widget" << widget << "cannot return EGLContext"; return 0; } - QPlatformGLContext *platformContext = widget->platformWindow()->glContext(); + QPlatformGLContext *platformContext = widget->windowHandle()->glContext()->handle(); if (!platformContext) { - qDebug() << "QPlatformWindow" << widget->platformWindow() << "does not have a glContext" + qDebug() << "QWindow" << widget->windowHandle() << "does not have a glContext" << "cannot return EGLContext"; return 0; } diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 0456638ab9..bc794446b2 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -85,10 +85,11 @@ static inline bool isTransient(const QWidget *w) && !w->testAttribute(Qt::WA_X11BypassTransientForHint)); } -QXcbWindow::QXcbWindow(QWidget *tlw) - : QPlatformWindow(tlw) +QXcbWindow::QXcbWindow(QWindow *window) + : QPlatformWindow(window) , m_context(0) { + QWidget *tlw = window->widget(); m_screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWidget(tlw)); setConnection(m_screen->connection()); @@ -112,14 +113,14 @@ QXcbWindow::QXcbWindow(QWidget *tlw) }; #if defined(XCB_USE_GLX) || defined(XCB_USE_EGL) - if (tlw->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL + if (window->surfaceType() == QWindow::OpenGLSurface && QApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)) { #if defined(XCB_USE_GLX) - XVisualInfo *visualInfo = qglx_findVisualInfo(DISPLAY_FROM_XCB(m_screen),m_screen->screenNumber(), tlw->platformWindowFormat()); + XVisualInfo *visualInfo = qglx_findVisualInfo(DISPLAY_FROM_XCB(m_screen),m_screen->screenNumber(), window->requestedWindowFormat()); #elif defined(XCB_USE_EGL) EGLDisplay eglDisplay = connection()->egl_display(); - EGLConfig eglConfig = q_configFromQPlatformWindowFormat(eglDisplay,tlw->platformWindowFormat(),true); + EGLConfig eglConfig = q_configFromQPlatformWindowFormat(eglDisplay,window->requestedWindowFormat(),true); VisualID id = QXlibEglIntegration::getCompatibleVisualId(DISPLAY_FROM_XCB(this), eglDisplay, eglConfig); XVisualInfo visualInfoTemplate; @@ -243,7 +244,8 @@ void QXcbWindow::setVisible(bool visible) { xcb_wm_hints_t hints; if (visible) { - if (widget()->isMinimized()) + // TODO: QWindow::isMinimized() or similar + if (window()->widget()->isMinimized()) xcb_wm_hints_set_iconic(&hints); else xcb_wm_hints_set_normal(&hints); @@ -453,7 +455,7 @@ WId QXcbWindow::winId() const void QXcbWindow::setParent(const QPlatformWindow *parent) { QPoint topLeft = geometry().topLeft(); - Q_XCB_CALL(xcb_reparent_window(xcb_connection(), window(), static_cast<const QXcbWindow *>(parent)->window(), topLeft.x(), topLeft.y())); + Q_XCB_CALL(xcb_reparent_window(xcb_connection(), xcb_window(), static_cast<const QXcbWindow *>(parent)->xcb_window(), topLeft.x(), topLeft.y())); } void QXcbWindow::setWindowTitle(const QString &title) @@ -498,10 +500,10 @@ QPlatformGLContext *QXcbWindow::glContext() const if (!m_context) { #if defined(XCB_USE_GLX) QXcbWindow *that = const_cast<QXcbWindow *>(this); - that->m_context = new QGLXContext(m_window, m_screen, widget()->platformWindowFormat()); + that->m_context = new QGLXContext(m_window, m_screen, window()->requestedWindowFormat()); #elif defined(XCB_USE_EGL) EGLDisplay display = connection()->egl_display(); - EGLConfig config = q_configFromQPlatformWindowFormat(display,widget()->platformWindowFormat(),true); + EGLConfig config = q_configFromQPlatformWindowFormat(display,window()->requestedWindowFormat(),true); QVector<EGLint> eglContextAttrs; eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION); eglContextAttrs.append(2); @@ -520,11 +522,11 @@ QPlatformGLContext *QXcbWindow::glContext() const void QXcbWindow::handleExposeEvent(const xcb_expose_event_t *event) { - QWindowSurface *surface = widget()->windowSurface(); + QWindowSurface *surface = window()->widget()->windowSurface(); if (surface) { QRect rect(event->x, event->y, event->width, event->height); - surface->flush(widget(), rect, QPoint()); + surface->flush(window()->widget(), rect, QPoint()); } } @@ -532,7 +534,7 @@ void QXcbWindow::handleClientMessageEvent(const xcb_client_message_event_t *even { if (event->format == 32 && event->type == atom(QXcbAtom::WM_PROTOCOLS)) { if (event->data.data32[0] == atom(QXcbAtom::WM_DELETE_WINDOW)) { - QWindowSystemInterface::handleCloseEvent(widget()); + QWindowSystemInterface::handleCloseEvent(window()->widget()); } else if (event->data.data32[0] == atom(QXcbAtom::_NET_WM_PING)) { xcb_client_message_event_t reply = *event; @@ -568,7 +570,7 @@ void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t * return; QPlatformWindow::setGeometry(rect); - QWindowSystemInterface::handleGeometryChange(widget(), rect); + QWindowSystemInterface::handleGeometryChange(window()->widget(), rect); #if XCB_USE_DRI2 if (m_context) @@ -616,7 +618,7 @@ void QXcbWindow::handleButtonPressEvent(const xcb_button_press_event_t *event) && (modifiers & Qt::AltModifier)) || (event->detail == 6 || event->detail == 7)); - QWindowSystemInterface::handleWheelEvent(widget(), event->time, + QWindowSystemInterface::handleWheelEvent(window()->widget(), event->time, local, global, delta, hor ? Qt::Horizontal : Qt::Vertical); return; } @@ -647,22 +649,22 @@ void QXcbWindow::handleMouseEvent(xcb_button_t detail, uint16_t state, xcb_times buttons ^= button; // X event uses state *before*, Qt uses state *after* - QWindowSystemInterface::handleMouseEvent(widget(), time, local, global, buttons); + QWindowSystemInterface::handleMouseEvent(window()->widget(), time, local, global, buttons); } void QXcbWindow::handleEnterNotifyEvent(const xcb_enter_notify_event_t *) { - QWindowSystemInterface::handleEnterEvent(widget()); + QWindowSystemInterface::handleEnterEvent(window()->widget()); } void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *) { - QWindowSystemInterface::handleLeaveEvent(widget()); + QWindowSystemInterface::handleLeaveEvent(window()->widget()); } void QXcbWindow::handleFocusInEvent(const xcb_focus_in_event_t *) { - QWindowSystemInterface::handleWindowActivated(widget()); + QWindowSystemInterface::handleWindowActivated(window()->widget()); } void QXcbWindow::handleFocusOutEvent(const xcb_focus_out_event_t *) diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index e049837253..3ed58b33d3 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -43,7 +43,7 @@ #define QXCBWINDOW_H #include <QtGui/QPlatformWindow> -#include <QtGui/QPlatformWindowFormat> +#include <QtGui/QWindowFormat> #include <xcb/xcb.h> #include <xcb/sync.h> @@ -55,7 +55,7 @@ class QXcbScreen; class QXcbWindow : public QXcbObject, public QPlatformWindow { public: - QXcbWindow(QWidget *tlw); + QXcbWindow(QWindow *window); ~QXcbWindow(); void setGeometry(const QRect &rect); @@ -73,7 +73,7 @@ public: QPlatformGLContext *glContext() const; - xcb_window_t window() const { return m_window; } + xcb_window_t xcb_window() const { return m_window; } void handleExposeEvent(const xcb_expose_event_t *event); void handleClientMessageEvent(const xcb_client_message_event_t *event); diff --git a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp index 718f09383c..89e6bd7ed7 100644 --- a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp +++ b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp @@ -204,14 +204,14 @@ void QXcbWindowSurface::flush(QWidget *widget, const QRegion ®ion, const QPoi Q_XCB_NOOP(connection()); - QXcbWindow *window = static_cast<QXcbWindow *>(widget->window()->platformWindow()); + QXcbWindow *window = static_cast<QXcbWindow *>(widget->windowHandle()->handle()); extern QWidgetData* qt_widget_data(QWidget *); QPoint widgetOffset = qt_qwidget_data(widget)->wrect.topLeft(); QVector<QRect> rects = region.rects(); for (int i = 0; i < rects.size(); ++i) - m_image->put(window->window(), rects.at(i).topLeft() - widgetOffset, rects.at(i).translated(offset)); + m_image->put(window->xcb_window(), rects.at(i).topLeft() - widgetOffset, rects.at(i).translated(offset)); Q_XCB_NOOP(connection()); |