Make QtGui compile again....

Comment out stuff in QWidget::create_sys
(cherry picked from commit 1bbc6a6bb2bf1175080e7a5ba6834ff642fd47ab)
This commit is contained in:
Jørgen Lind 2011-04-26 12:43:11 +02:00 committed by Samuel Rødal
parent 25028e3b14
commit fbef41167a
12 changed files with 230 additions and 929 deletions

View File

@ -220,14 +220,14 @@ qpa {
kernel/qplatformintegrationfactory_qpa_p.h \ kernel/qplatformintegrationfactory_qpa_p.h \
kernel/qplatformintegrationplugin_qpa.h \ kernel/qplatformintegrationplugin_qpa.h \
kernel/qplatformwindow_qpa.h \ kernel/qplatformwindow_qpa.h \
kernel/qwindowformat_qpa.h \
kernel/qplatformglcontext_qpa.h \ kernel/qplatformglcontext_qpa.h \
kernel/qdesktopwidget_qpa_p.h \ kernel/qdesktopwidget_qpa_p.h \
kernel/qplatformeventloopintegration_qpa.h \ kernel/qplatformeventloopintegration_qpa.h \
kernel/qplatformcursor_qpa.h \ kernel/qplatformcursor_qpa.h \
kernel/qplatformclipboard_qpa.h \ kernel/qplatformclipboard_qpa.h \
kernel/qplatformnativeinterface_qpa.h \ kernel/qplatformnativeinterface_qpa.h \
kernel/qwindow_qpa.cpp kernel/qwindowformat_qpa.h \
kernel/qwindow_qpa.h
SOURCES += \ SOURCES += \
kernel/qapplication_qpa.cpp \ kernel/qapplication_qpa.cpp \
@ -246,13 +246,13 @@ qpa {
kernel/qplatformintegrationfactory_qpa.cpp \ kernel/qplatformintegrationfactory_qpa.cpp \
kernel/qplatformintegrationplugin_qpa.cpp \ kernel/qplatformintegrationplugin_qpa.cpp \
kernel/qplatformwindow_qpa.cpp \ kernel/qplatformwindow_qpa.cpp \
kernel/qwindowformat_qpa.cpp \
kernel/qplatformeventloopintegration_qpa.cpp \ kernel/qplatformeventloopintegration_qpa.cpp \
kernel/qplatformglcontext_qpa.cpp \ kernel/qplatformglcontext_qpa.cpp \
kernel/qplatformcursor_qpa.cpp \ kernel/qplatformcursor_qpa.cpp \
kernel/qplatformclipboard_qpa.cpp \ kernel/qplatformclipboard_qpa.cpp \
kernel/qplatformnativeinterface_qpa.cpp \ kernel/qplatformnativeinterface_qpa.cpp \
kernel/qsessionmanager_qpa.cpp \ kernel/qsessionmanager_qpa.cpp \
kernel/qwindowformat_qpa.cpp \
kernel/qwindow_qpa.cpp kernel/qwindow_qpa.cpp
contains(QT_CONFIG, glib) { contains(QT_CONFIG, glib) {

View File

@ -43,7 +43,7 @@
#define QPLATFORM_GL_CONTEXT_H #define QPLATFORM_GL_CONTEXT_H
#include <QtCore/qnamespace.h> #include <QtCore/qnamespace.h>
#include <QtGui/QPlatformWindowFormat> #include <QtGui/QWindowFormat>
QT_BEGIN_HEADER QT_BEGIN_HEADER
@ -66,7 +66,7 @@ public:
virtual void swapBuffers() = 0; virtual void swapBuffers() = 0;
virtual void* getProcAddress(const QString& procName) = 0; virtual void* getProcAddress(const QString& procName) = 0;
virtual QPlatformWindowFormat platformWindowFormat() const = 0; virtual QWindowFormat windowFormat() const = 0;
const static QPlatformGLContext *currentContext(); const static QPlatformGLContext *currentContext();

View File

@ -46,7 +46,7 @@
class QPlatformWindowPrivate class QPlatformWindowPrivate
{ {
QWidget *tlw; QWindow *window;
QRect rect; QRect rect;
Qt::WindowFlags flags; Qt::WindowFlags flags;
friend class QPlatformWindow; friend class QPlatformWindow;
@ -56,12 +56,11 @@ class QPlatformWindowPrivate
Constructs a platform window with the given top level widget. Constructs a platform window with the given top level widget.
*/ */
QPlatformWindow::QPlatformWindow(QWidget *tlw) QPlatformWindow::QPlatformWindow(QWindow *window)
: d_ptr(new QPlatformWindowPrivate) : d_ptr(new QPlatformWindowPrivate)
{ {
Q_D(QPlatformWindow); Q_D(QPlatformWindow);
d->tlw = tlw; d->window = window;
tlw->setPlatformWindow(this);
} }
/*! /*!
@ -74,10 +73,10 @@ QPlatformWindow::~QPlatformWindow()
/*! /*!
Returnes the widget which belongs to the QPlatformWindow Returnes the widget which belongs to the QPlatformWindow
*/ */
QWidget *QPlatformWindow::widget() const QWindow *QPlatformWindow::window() const
{ {
Q_D(const QPlatformWindow); Q_D(const QPlatformWindow);
return d->tlw; return d->window;
} }
/*! /*!
@ -186,7 +185,7 @@ void QPlatformWindow::setOpacity(qreal level)
*/ */
void QPlatformWindow::requestActivateWindow() void QPlatformWindow::requestActivateWindow()
{ {
QWindowSystemInterface::handleWindowActivated(widget()); QWindowSystemInterface::handleWindowActivated(window()->widget());
} }
/*! /*!

View File

@ -55,18 +55,17 @@ QT_BEGIN_NAMESPACE
QT_MODULE(Gui) QT_MODULE(Gui)
class QPlatformWindowPrivate; class QPlatformWindowPrivate;
class QWidget; class QWindow;
class QPlatformGLContext; class QPlatformGLContext;
class Q_GUI_EXPORT QPlatformWindow class Q_GUI_EXPORT QPlatformWindow
{ {
Q_DECLARE_PRIVATE(QPlatformWindow) Q_DECLARE_PRIVATE(QPlatformWindow)
public: public:
QPlatformWindow(QWidget *tlw); QPlatformWindow(QWindow *window);
QPlatformWindow(Qt::HANDLE , QWidget *tlw);
virtual ~QPlatformWindow(); virtual ~QPlatformWindow();
QWidget *widget() const; QWindow *window() const;
virtual void setGeometry(const QRect &rect); virtual void setGeometry(const QRect &rect);
virtual QRect geometry() const; virtual QRect geometry() const;

View File

@ -1762,8 +1762,7 @@ void QWidgetPrivate::createTLExtra()
qDebug() << "tlextra" << ++count; qDebug() << "tlextra" << ++count;
#endif #endif
#if defined(Q_WS_QPA) #if defined(Q_WS_QPA)
x->platformWindow = 0; x->window = 0;
x->platformWindowFormat = QPlatformWindowFormat::defaultFormat();
x->screenIndex = 0; x->screenIndex = 0;
#endif #endif
} }

View File

@ -57,6 +57,7 @@
#include <QtGui/qkeysequence.h> #include <QtGui/qkeysequence.h>
#ifdef Q_WS_QPA //should this go somewhere else? #ifdef Q_WS_QPA //should this go somewhere else?
#include <QtGui/qwindow_qpa.h>
#include <QtGui/qwindowformat_qpa.h> #include <QtGui/qwindowformat_qpa.h>
#endif #endif
@ -635,11 +636,8 @@ public:
QWindowSurface *windowSurface() const; QWindowSurface *windowSurface() const;
#if defined(Q_WS_QPA) #if defined(Q_WS_QPA)
void setPlatformWindow(QPlatformWindow *window); void setWindowHandle(QWindow *window);
QPlatformWindow *platformWindow() const; QWindow *windowHandle() const;
void setPlatformWindowFormat(const QPlatformWindowFormat &format);
QPlatformWindowFormat platformWindowFormat() const;
friend class QDesktopScreenWidget; friend class QDesktopScreenWidget;
#endif #endif

View File

@ -103,7 +103,7 @@ class QWSManager;
class QCoreGraphicsPaintEnginePrivate; class QCoreGraphicsPaintEnginePrivate;
#endif #endif
#if defined(Q_WS_QPA) #if defined(Q_WS_QPA)
class QPlatformWindow; class QWindow;
#endif #endif
class QPaintEngine; class QPaintEngine;
class QPixmap; class QPixmap;
@ -233,8 +233,7 @@ struct QTLWExtra {
uint inExpose : 1; // Prevents drawing recursion uint inExpose : 1; // Prevents drawing recursion
uint nativeWindowTransparencyEnabled : 1; // Tracks native window transparency uint nativeWindowTransparencyEnabled : 1; // Tracks native window transparency
#elif defined(Q_WS_QPA) #elif defined(Q_WS_QPA)
QPlatformWindow *platformWindow; QWindow *window;
QPlatformWindowFormat platformWindowFormat;
quint32 screenIndex; // index in qplatformscreenlist quint32 screenIndex; // index in qplatformscreenlist
#endif #endif
}; };

View File

@ -54,7 +54,7 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
void q_createNativeChildrenAndSetParent(QPlatformWindow *parentWindow, const QWidget *parentWidget) void q_createNativeChildrenAndSetParent(QWindow *parentWindow, const QWidget *parentWidget)
{ {
QObjectList children = parentWidget->children(); QObjectList children = parentWidget->children();
for (int i = 0; i < children.size(); i++) { for (int i = 0; i < children.size(); i++) {
@ -62,11 +62,11 @@ void q_createNativeChildrenAndSetParent(QPlatformWindow *parentWindow, const QWi
const QWidget *childWidget = qobject_cast<const QWidget *>(children.at(i)); const QWidget *childWidget = qobject_cast<const QWidget *>(children.at(i));
if (childWidget) { // should not be necessary if (childWidget) { // should not be necessary
if (childWidget->testAttribute(Qt::WA_NativeWindow)) { if (childWidget->testAttribute(Qt::WA_NativeWindow)) {
if (!childWidget->platformWindow()) if (!childWidget->windowHandle())
childWidget->winId(); childWidget->winId();
} }
if (childWidget->platformWindow()) { if (childWidget->windowHandle()) {
childWidget->platformWindow()->setParent(parentWindow); childWidget->windowHandle()->setParent(parentWindow);
} else { } else {
q_createNativeChildrenAndSetParent(parentWindow,childWidget); q_createNativeChildrenAndSetParent(parentWindow,childWidget);
} }
@ -90,36 +90,36 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO
return; // we only care about real toplevels return; // we only care about real toplevels
QWindowSurface *surface = q->windowSurface(); QWindowSurface *surface = q->windowSurface();
QPlatformWindow *platformWindow = q->platformWindow(); // QPlatformWindow *platformWindow = q->platformWindow();
if (!platformWindow) { // if (!platformWindow) {
platformWindow = QApplicationPrivate::platformIntegration()->createPlatformWindow(q); // platformWindow = QApplicationPrivate::platformIntegration()->createPlatformWindow(q);
} // }
Q_ASSERT(platformWindow); // Q_ASSERT(platformWindow);
if (!surface ) { // if (!surface ) {
if (platformWindow && q->platformWindowFormat().hasWindowSurface()) { // if (platformWindow && q->platformWindowFormat().hasWindowSurface()) {
surface = QApplicationPrivate::platformIntegration()->createWindowSurface(q,platformWindow->winId()); // surface = QApplicationPrivate::platformIntegration()->createWindowSurface(q,platformWindow->winId());
} else { // } else {
q->setAttribute(Qt::WA_PaintOnScreen,true); // q->setAttribute(Qt::WA_PaintOnScreen,true);
} // }
} // }
data.window_flags = q->platformWindow()->setWindowFlags(data.window_flags); // data.window_flags = q->windowHandle()->setWindowFlags(data.window_flags);
setWinId(q->platformWindow()->winId()); // setWinId(q->platformWindow()->winId());
//first check children. and create them if necessary //first check children. and create them if necessary
q_createNativeChildrenAndSetParent(q->platformWindow(),q); // q_createNativeChildrenAndSetParent(q->platformWindow(),q);
//if we we have a parent, then set correct parent; // //if we we have a parent, then set correct parent;
if (!q->isWindow()) { // if (!q->isWindow()) {
if (QWidget *nativeParent = q->nativeParentWidget()) { // if (QWidget *nativeParent = q->nativeParentWidget()) {
if (nativeParent->platformWindow()) { // if (nativeParent->platformWindow()) {
platformWindow->setParent(nativeParent->platformWindow()); // platformWindow->setParent(nativeParent->platformWindow());
} // }
} // }
} // }
QApplicationPrivate::platformIntegration()->moveToScreen(q, topData()->screenIndex); QApplicationPrivate::platformIntegration()->moveToScreen(q, topData()->screenIndex);
// qDebug() << "create_sys" << q << q->internalWinId(); // qDebug() << "create_sys" << q << q->internalWinId();
@ -142,7 +142,7 @@ void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
for (int i = 0; i < childList.size(); i++) { for (int i = 0; i < childList.size(); i++) {
QWidget *widget = qobject_cast<QWidget *>(childList.at(i)); QWidget *widget = qobject_cast<QWidget *>(childList.at(i));
if (widget && widget->testAttribute(Qt::WA_NativeWindow)) { if (widget && widget->testAttribute(Qt::WA_NativeWindow)) {
if (widget->platformWindow()) { if (widget->windowHandle()) {
widget->destroy(); widget->destroy();
} }
} }
@ -177,10 +177,10 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f)
if (parent != newparent) { if (parent != newparent) {
QObjectPrivate::setParent_helper(newparent); //### why does this have to be done in the _sys function??? QObjectPrivate::setParent_helper(newparent); //### why does this have to be done in the _sys function???
if (q->platformWindow() && newparent) { if (q->windowHandle() && newparent) {
QWidget * parentWithWindow = newparent->platformWindow()? newparent : newparent->nativeParentWidget(); QWidget * parentWithWindow = newparent->windowHandle()? newparent : newparent->nativeParentWidget();
if (parentWithWindow && parentWithWindow->platformWindow()) { if (parentWithWindow && parentWithWindow->windowHandle()) {
q->platformWindow()->setParent(parentWithWindow->platformWindow()); q->windowHandle()->setParent(parentWithWindow->windowHandle());
} }
} }
@ -209,8 +209,9 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f)
if (f & Qt::Window) { if (f & Qt::Window) {
//qDebug() << "setParent_sys" << q << newparent << hex << f; //qDebug() << "setParent_sys" << q << newparent << hex << f;
if (QPlatformWindow *window = q->platformWindow()) // if (QPlatformWindow *window = q->platformWindow())
data.window_flags = window->setWindowFlags(data.window_flags); // data.window_flags = window->setWindowFlags(data.window_flags);
Q_ASSERT(false);
} }
if (q->isWindow() || (!newparent || newparent->isVisible()) || explicitlyHidden) if (q->isWindow() || (!newparent || newparent->isVisible()) || explicitlyHidden)
@ -284,7 +285,7 @@ void QWidgetPrivate::setWindowTitle_sys(const QString &caption)
if (!q->isWindow()) if (!q->isWindow())
return; return;
if (QPlatformWindow *window = q->platformWindow()) if (QWindow *window = q->windowHandle())
window->setWindowTitle(caption); window->setWindowTitle(caption);
} }
@ -371,8 +372,8 @@ QWidget *QWidget::keyboardGrabber()
void QWidget::activateWindow() void QWidget::activateWindow()
{ {
if (platformWindow()) if (windowHandle())
platformWindow()->requestActivateWindow(); windowHandle()->requestActivateWindow();
} }
void QWidgetPrivate::show_sys() void QWidgetPrivate::show_sys()
@ -386,7 +387,7 @@ void QWidgetPrivate::show_sys()
QApplication::postEvent(q, new QUpdateLaterEvent(q->rect())); QApplication::postEvent(q, new QUpdateLaterEvent(q->rect()));
QPlatformWindow *window = q->platformWindow(); QWindow *window = q->windowHandle();
if (window) { if (window) {
QRect geomRect = q->geometry(); QRect geomRect = q->geometry();
if (!q->isWindow()) { if (!q->isWindow()) {
@ -419,7 +420,7 @@ void QWidgetPrivate::hide_sys()
} }
return; return;
} }
if (QPlatformWindow *window = q->platformWindow()) { if (QWindow *window = q->windowHandle()) {
window->setVisible(false); window->setVisible(false);
} }
@ -526,7 +527,7 @@ void QWidgetPrivate::raise_sys()
{ {
Q_Q(QWidget); Q_Q(QWidget);
if (q->isWindow()) { if (q->isWindow()) {
q->platformWindow()->raise(); q->windowHandle()->raise();
} }
} }
@ -535,7 +536,7 @@ void QWidgetPrivate::lower_sys()
Q_Q(QWidget); Q_Q(QWidget);
if (q->isWindow()) { if (q->isWindow()) {
Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); Q_ASSERT(q->testAttribute(Qt::WA_WState_Created));
q->platformWindow()->lower(); q->windowHandle()->lower();
} else if (QWidget *p = q->parentWidget()) { } else if (QWidget *p = q->parentWidget()) {
setDirtyOpaqueRegion(); setDirtyOpaqueRegion();
p->d_func()->invalidateBuffer(effectiveRectFor(q->geometry())); p->d_func()->invalidateBuffer(effectiveRectFor(q->geometry()));
@ -585,12 +586,12 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
data.crect = r; data.crect = r;
if (q->isVisible()) { if (q->isVisible()) {
if (q->platformWindow()) { if (q->windowHandle()) {
if (q->isWindow()) { if (q->isWindow()) {
q->platformWindow()->setGeometry(q->geometry()); q->windowHandle()->setGeometry(q->geometry());
} else { } else {
QPoint posInNativeParent = q->mapTo(q->nativeParentWidget(),QPoint()); QPoint posInNativeParent = q->mapTo(q->nativeParentWidget(),QPoint());
q->platformWindow()->setGeometry(QRect(posInNativeParent,r.size())); q->windowHandle()->setGeometry(QRect(posInNativeParent,r.size()));
} }
const QWidgetBackingStore *bs = maybeBackingStore(); const QWidgetBackingStore *bs = maybeBackingStore();
if (bs->windowSurface) { if (bs->windowSurface) {
@ -611,7 +612,7 @@ void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
if (isResize) { if (isResize) {
QResizeEvent e(r.size(), olds); QResizeEvent e(r.size(), olds);
QApplication::sendEvent(q, &e); QApplication::sendEvent(q, &e);
if (q->platformWindow()) if (q->windowHandle())
q->update(); q->update();
} }
} else { // not visible } else { // not visible
@ -678,67 +679,21 @@ int QWidget::metric(PaintDeviceMetric m) const
return val; return val;
} }
/*!
\preliminary
Sets the window to be the \a window specified.
The QWidget takes ownership of the \a surface.
*/
void QWidget::setPlatformWindow(QPlatformWindow *window)
{
Q_D(QWidget);
QTLWExtra *topData = d->topData();
if (topData->platformWindow == window)
return;
delete topData->platformWindow;
topData->platformWindow = window;
}
/*! /*!
\preliminary \preliminary
Returns the QPlatformWindow this widget will be drawn into. Returns the QPlatformWindow this widget will be drawn into.
*/ */
QPlatformWindow *QWidget::platformWindow() const QWindow *QWidget::windowHandle() const
{ {
Q_D(const QWidget); Q_D(const QWidget);
QTLWExtra *extra = d->maybeTopData(); QTLWExtra *extra = d->maybeTopData();
if (extra && extra->platformWindow) if (extra && extra->window)
return extra->platformWindow; return extra->window;
return 0; return 0;
} }
void QWidget::setPlatformWindowFormat(const QPlatformWindowFormat &format)
{
if (isWindow() || testAttribute(Qt::WA_NativeWindow)) {
Q_D(QWidget);
QTLWExtra *topData = d->topData();
topData->platformWindowFormat = format;
if (testAttribute(Qt::WA_WState_Created)) {
bool wasVisible = testAttribute(Qt::WA_WState_Visible);
destroy();
d->create_sys(0,true,true);
if (wasVisible)
topData->platformWindow->setVisible(true);
}
}
}
QPlatformWindowFormat QWidget::platformWindowFormat() const
{
Q_D(const QWidget);
QTLWExtra *extra = d->maybeTopData();
if (extra){
return extra->platformWindowFormat;
} else {
return QPlatformWindowFormat::defaultFormat();
}
}
void QWidgetPrivate::createSysExtra() void QWidgetPrivate::createSysExtra()
{ {
} }
@ -759,14 +714,13 @@ void QWidgetPrivate::deleteTLSysExtra()
//delete the qglcontext before we delete the qplatformglcontext. //delete the qglcontext before we delete the qplatformglcontext.
//One unfortunate thing about this is that we potentially create a glContext just to //One unfortunate thing about this is that we potentially create a glContext just to
//delete it straight afterwards. //delete it straight afterwards.
if (extra->topextra->platformWindow) { if (extra->topextra->window) {
if (QPlatformGLContext *context = extra->topextra->platformWindow->glContext()) { extra->topextra->window->destroy();
context->deleteQGLContext();
}
} }
setWinId(0); setWinId(0);
delete extra->topextra->platformWindow; //hmmm. should we delete window..
extra->topextra->platformWindow = 0; delete extra->topextra->window;
extra->topextra->window = 0;
} }
} }
@ -789,7 +743,7 @@ void QWidgetPrivate::updateFrameStrut()
void QWidgetPrivate::setWindowOpacity_sys(qreal level) void QWidgetPrivate::setWindowOpacity_sys(qreal level)
{ {
Q_Q(QWidget); Q_Q(QWidget);
q->platformWindow()->setOpacity(level); q->windowHandle()->setOpacity(level);
} }
void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect) void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect)
@ -807,10 +761,8 @@ QPaintEngine *QWidget::paintEngine() const
QWindowSurface *QWidgetPrivate::createDefaultWindowSurface_sys() QWindowSurface *QWidgetPrivate::createDefaultWindowSurface_sys()
{ {
Q_Q(QWidget); //This function should not be called.
if (q->platformWindowFormat().hasWindowSurface()) Q_ASSERT(false);
return QApplicationPrivate::platformIntegration()->createWindowSurface(q,0);
else
return 0; return 0;
} }

View File

@ -50,12 +50,15 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QWindowPrivate : public QObjectPrivate{ class QWindowPrivate : public QObjectPrivate
QWindowPrivate() {
public:
QWindowPrivate(QWindow::WindowTypes types)
: QObjectPrivate() : QObjectPrivate()
, types(0) , windowTypes(types)
, platformWindow(0) , platformWindow(0)
, glContext(0) , glContext(0)
, widget(0)
{ {
} }
@ -65,20 +68,31 @@ class QWindowPrivate : public QObjectPrivate{
} }
private:
QWindow::WindowTypes windowTypes; QWindow::WindowTypes windowTypes;
QPlatformWindow *platformWindow; QPlatformWindow *platformWindow;
QWindowFormat requestedFormat; QWindowFormat requestedFormat;
QString windowTitle; QString windowTitle;
QRect geometry; QRect geometry;
QGLContext *glContext; QGLContext *glContext;
QWidget *widget;
}; };
QWindow::QWindow(WindowTypes types, QWindow *parent) QWindow::QWindow(WindowTypes types, QWindow *parent)
: QObject(*new QWindowPrivate(format), parent) : QObject(*new QWindowPrivate(types), parent)
{
}
QWidget *QWindow::widget() const
{
Q_D(const QWindow);
return d->widget;
}
void QWindow::setWidget(QWidget *widget)
{ {
Q_D(QWindow); Q_D(QWindow);
d->windowTypes = types; d->widget = widget;
} }
void QWindow::setVisible(bool visible) void QWindow::setVisible(bool visible)
@ -99,7 +113,7 @@ void QWindow::create()
WId QWindow::winId() const WId QWindow::winId() const
{ {
Q_D(QWindow); Q_D(const QWindow);
if(d->platformWindow) { if(d->platformWindow) {
return d->platformWindow->winId(); return d->platformWindow->winId();
} }
@ -111,7 +125,7 @@ void QWindow::setParent(const QWindow *parent)
Q_D(QWindow); Q_D(QWindow);
//How should we support lazy init when setting parent //How should we support lazy init when setting parent
if (!parent->d_func()->platformWindow) { if (!parent->d_func()->platformWindow) {
parent->create(); const_cast<QWindow *>(parent)->create();
} }
if(!d->platformWindow) { if(!d->platformWindow) {
@ -138,7 +152,7 @@ QWindowFormat QWindow::actualWindowFormat() const
return d->requestedFormat; return d->requestedFormat;
} }
WindowTypes QWindow::types() const QWindow::WindowTypes QWindow::types() const
{ {
Q_D(const QWindow); Q_D(const QWindow);
return d->windowTypes; return d->windowTypes;
@ -194,30 +208,36 @@ void QWindow::requestActivateWindow()
Qt::WindowStates QWindow::windowState() const Qt::WindowStates QWindow::windowState() const
{ {
qDebug() << "unimplemented:" << __FILE__ << __LINE__; qDebug() << "unimplemented:" << __FILE__ << __LINE__;
return Qt::WindowNoState;
} }
void QWindow::setWindowState(Qt::WindowStates state) void QWindow::setWindowState(Qt::WindowStates state)
{ {
Q_UNUSED(state);
qDebug() << "unimplemented:" << __FILE__ << __LINE__; qDebug() << "unimplemented:" << __FILE__ << __LINE__;
} }
QSize QWindow::minimumSize() const QSize QWindow::minimumSize() const
{ {
qDebug() << "unimplemented:" << __FILE__ << __LINE__; qDebug() << "unimplemented:" << __FILE__ << __LINE__;
return QSize();
} }
QSize QWindow::maximumSize() const QSize QWindow::maximumSize() const
{ {
qDebug() << "unimplemented:" << __FILE__ << __LINE__; qDebug() << "unimplemented:" << __FILE__ << __LINE__;
return QSize();
} }
void QWindow::setMinimumSize(const QSize &size) const void QWindow::setMinimumSize(const QSize &size) const
{ {
Q_UNUSED(size);
qDebug() << "unimplemented:" << __FILE__ << __LINE__; qDebug() << "unimplemented:" << __FILE__ << __LINE__;
} }
void QWindow::setMaximumSize(const QSize &size) const void QWindow::setMaximumSize(const QSize &size) const
{ {
Q_UNUSED(size);
qDebug() << "unimplemented:" << __FILE__ << __LINE__; qDebug() << "unimplemented:" << __FILE__ << __LINE__;
} }
@ -238,15 +258,36 @@ QRect QWindow::geometry() const
void QWindow::setWindowIcon(const QImage &icon) const void QWindow::setWindowIcon(const QImage &icon) const
{ {
Q_UNUSED(icon);
qDebug() << "unimplemented:" << __FILE__ << __LINE__; qDebug() << "unimplemented:" << __FILE__ << __LINE__;
} }
QGLContext * QWindow::glContext() const QGLContext * QWindow::glContext() const
{ {
Q_D(QWindow); Q_D(const QWindow);
return d->glContext; return d->glContext;
} }
void QWindow::setRequestFormat(const QWindowFormat &format)
{
Q_D(QWindow);
d->requestedFormat = format;
}
QWindowFormat QWindow::format() const
{
return QWindowFormat();
}
void QWindow::destroy()
{
//JA, this will be solved later....
// if (QGLContext *context = extra->topextra->window->glContext()) {
// context->deleteQGLContext();
Q_ASSERT(false);
// }
}
void QWindow::showMinimized() void QWindow::showMinimized()
{ {
qDebug() << "unimplemented:" << __FILE__ << __LINE__; qDebug() << "unimplemented:" << __FILE__ << __LINE__;
@ -271,6 +312,7 @@ bool QWindow::close()
{ {
//should we have close? //should we have close?
qDebug() << "unimplemented:" << __FILE__ << __LINE__; qDebug() << "unimplemented:" << __FILE__ << __LINE__;
return true;
} }
void QWindow::resizeEvent(QResizeEvent *) void QWindow::resizeEvent(QResizeEvent *)
@ -291,6 +333,7 @@ void QWindow::hideEvent(QHideEvent *)
bool QWindow::event(QEvent *) bool QWindow::event(QEvent *)
{ {
qDebug() << "unimplemented:" << __FILE__ << __LINE__; qDebug() << "unimplemented:" << __FILE__ << __LINE__;
return false;
} }
void QWindow::keyPressEvent(QKeyEvent *) void QWindow::keyPressEvent(QKeyEvent *)

View File

@ -42,8 +42,8 @@
#ifndef QWINDOW_QPA_H #ifndef QWINDOW_QPA_H
#define QWINDOW_QPA_H #define QWINDOW_QPA_H
#include <QObject> #include <QtCore/QObject>
#include <QtCore/QEvent>
#include <QtGui/qwindowformat_qpa.h> #include <QtGui/qwindowformat_qpa.h>
QT_BEGIN_HEADER QT_BEGIN_HEADER
@ -54,6 +54,17 @@ QT_MODULE(Gui)
class QWindowPrivate; class QWindowPrivate;
class QGLContext; class QGLContext;
class QWidget;
class QResizeEvent;
class QShowEvent;
class QHideEvent;
class QKeyEvent;
class QInputMethodEvent;
class QMouseEvent;
#ifndef QT_NO_WHEELEVENT
class QWheelEvent;
#endif
class Q_GUI_EXPORT QWindow : public QObject class Q_GUI_EXPORT QWindow : public QObject
{ {
@ -71,7 +82,12 @@ public:
}; };
Q_DECLARE_FLAGS(WindowTypes, WindowType) Q_DECLARE_FLAGS(WindowTypes, WindowType)
QWindow(WindowTypes types = Window, QWindow *parent = 0); QWindow(QWindow::WindowTypes types = Window, QWindow *parent = 0);
// to be removed at some poitn in the future
QWidget *widget() const;
void setWidget(QWidget *widget);
void setVisible(bool visible); void setVisible(bool visible);
void create(); void create();
@ -105,6 +121,11 @@ public:
QGLContext *glContext() const; QGLContext *glContext() const;
void setRequestFormat(const QWindowFormat &format);
QWindowFormat format() const;
void destroy();
public Q_SLOTS: public Q_SLOTS:
inline void show() { setVisible(true); } inline void show() { setVisible(true); }
inline void hide() { setVisible(false); } inline void hide() { setVisible(false); }

View File

@ -43,196 +43,59 @@
#include <QtCore/QDebug> #include <QtCore/QDebug>
Q_GLOBAL_STATIC(QPlatformWindowFormat, q_platformwindow_default_format); class QWindowFormatPrivate
class QPlatformWindowFormatPrivate
{ {
public: public:
QPlatformWindowFormatPrivate() QWindowFormatPrivate()
: ref(1) : ref(1)
, opts(QPlatformWindowFormat::DoubleBuffer | QPlatformWindowFormat::DepthBuffer , opts(QWindowFormat::DoubleBuffer | QWindowFormat::WindowSurface)
| QPlatformWindowFormat::Rgba | QPlatformWindowFormat::DirectRendering
| QPlatformWindowFormat::StencilBuffer | QPlatformWindowFormat::DeprecatedFunctions
| QPlatformWindowFormat::HasWindowSurface)
, depthSize(-1) , depthSize(-1)
, accumSize(-1)
, stencilSize(-1) , stencilSize(-1)
, redSize(-1) , colorFormat(QWindowFormat::RGB888)
, greenSize(-1)
, blueSize(-1)
, alphaSize(-1)
, numSamples(-1) , numSamples(-1)
, swapInterval(-1)
, windowApi(QPlatformWindowFormat::Raster)
, sharedContext(0) , sharedContext(0)
{ {
} }
QPlatformWindowFormatPrivate(const QPlatformWindowFormatPrivate *other) QWindowFormatPrivate(const QWindowFormatPrivate *other)
: ref(1), : ref(1),
opts(other->opts), opts(other->opts),
depthSize(other->depthSize), depthSize(other->depthSize),
accumSize(other->accumSize),
stencilSize(other->stencilSize), stencilSize(other->stencilSize),
redSize(other->redSize), colorFormat(other->colorFormat),
greenSize(other->greenSize), swapBehavior(other->swapBehavior),
blueSize(other->blueSize),
alphaSize(other->alphaSize),
numSamples(other->numSamples), numSamples(other->numSamples),
swapInterval(other->swapInterval),
windowApi(other->windowApi),
sharedContext(other->sharedContext) sharedContext(other->sharedContext)
{ {
} }
QAtomicInt ref; QAtomicInt ref;
QPlatformWindowFormat::FormatOptions opts; QWindowFormat::FormatOptions opts;
int depthSize; int depthSize;
int accumSize;
int stencilSize; int stencilSize;
int redSize; QWindowFormat::ColorFormat colorFormat;
int greenSize; QWindowFormat::SwapBehavior swapBehavior;
int blueSize;
int alphaSize;
int numSamples; int numSamples;
int swapInterval;
QPlatformWindowFormat::WindowApi windowApi;
QPlatformGLContext *sharedContext; QPlatformGLContext *sharedContext;
}; };
/*! QWindowFormat::QWindowFormat()
\class QPlatformWindowFormat
\brief The QPlatformWindowFormat class specifies the display format of an OpenGL
rendering context and if possible attributes of the corresponding QPlatformWindow.
\ingroup painting
QWidget has a setter and getter function for QPlatformWindowFormat. These functions can be used
by the application programmer to signal what kind of format he wants to the window and glcontext
should have. However, it is not always possible to fulfill these requirements. The application
programmer should therefore check the resulting QPlatformWindowFormat from QPlatformGLContext
to see the format that was actually created.
A display format has several characteristics:
\list
\i \link setDoubleBuffer() Double or single buffering.\endlink
\i \link setDepth() Depth buffer.\endlink
\i \link setRgba() RGBA or color index mode.\endlink
\i \link setAlpha() Alpha channel.\endlink
\i \link setAccum() Accumulation buffer.\endlink
\i \link setStencil() Stencil buffer.\endlink
\i \link setStereo() Stereo buffers.\endlink
\i \link setDirectRendering() Direct rendering.\endlink
\i \link setOverlay() Presence of an overlay.\endlink
\i \link setPlane() Plane of an overlay.\endlink
\i \link setSampleBuffers() Multisample buffers.\endlink
\endlist
You can also specify preferred bit depths for the color buffer,
depth buffer, alpha buffer, accumulation buffer and the stencil
buffer with the functions: setRedBufferSize(), setGreenBufferSize(),
setBlueBufferSize(), setDepthBufferSize(), setAlphaBufferSize(),
setAccumBufferSize() and setStencilBufferSize().
Note that even if you specify that you prefer a 32 bit depth
buffer (e.g. with setDepthBufferSize(32)), the format that is
chosen may not have a 32 bit depth buffer, even if there is a
format available with a 32 bit depth buffer. The main reason for
this is how the system dependant picking algorithms work on the
different platforms, and some format options may have higher
precedence than others.
You create and tell a QPlatformWindowFormat object what rendering options you
want from an OpenGL rendering context.
OpenGL drivers or accelerated hardware may or may not support
advanced features such as alpha channel or stereographic viewing.
If you request some features that the driver/hardware does not
provide when you create a QGLWidget, you will get a rendering
context with the nearest subset of features.
There are different ways to define the display characteristics of
a rendering context. One is to create a QPlatformWindowFormat and make it the
default for the entire application:
\snippet doc/src/snippets/code/src_opengl_qgl.cpp 0
Or you can specify the desired format when creating an object of
your QGLWidget subclass:
\snippet doc/src/snippets/code/src_opengl_qgl.cpp 1
After the widget has been created, you can find out which of the
requested features the system was able to provide:
\snippet doc/src/snippets/code/src_opengl_qgl.cpp 2
\legalese
OpenGL is a trademark of Silicon Graphics, Inc. in the
United States and other countries.
\endlegalese
\sa QPlatformContext, QWidget
*/
/*!
Constructs a QPlatformWindowFormat object with the following default settings:
\list
\i \link setDoubleBuffer() Double buffer:\endlink Enabled.
\i \link setDepth() Depth buffer:\endlink Enabled.
\i \link setRgba() RGBA:\endlink Enabled (i.e., color index disabled).
\i \link setAlpha() Alpha channel:\endlink Disabled.
\i \link setAccum() Accumulator buffer:\endlink Disabled.
\i \link setStencil() Stencil buffer:\endlink Enabled.
\i \link setStereo() Stereo:\endlink Disabled.
\i \link setDirectRendering() Direct rendering:\endlink Enabled.
\i \link setOverlay() Overlay:\endlink Disabled.
\i \link setPlane() Plane:\endlink 0 (i.e., normal plane).
\i \link setSampleBuffers() Multisample buffers:\endlink Disabled.
\endlist
*/
QPlatformWindowFormat::QPlatformWindowFormat()
{ {
d = new QPlatformWindowFormatPrivate; d = new QWindowFormatPrivate;
} }
QWindowFormat::QWindowFormat(QWindowFormat::FormatOptions options)
/*!
Creates a QPlatformWindowFormat object that is a copy of the current
defaultFormat().
If \a options is not 0, the default format is modified by the
specified format options. The \a options parameter should be
QGL::FormatOption values OR'ed together.
This constructor makes it easy to specify a certain desired format
in classes derived from QGLWidget, for example:
\snippet doc/src/snippets/code/src_opengl_qgl.cpp 3
Note that there are QGL::FormatOption values to turn format settings
both on and off, e.g. QGL::DepthBuffer and QGL::NoDepthBuffer,
QGL::DirectRendering and QGL::IndirectRendering, etc.
The \a plane parameter defaults to 0 and is the plane which this
format should be associated with. Not all OpenGL implementations
supports overlay/underlay rendering planes.
\sa defaultFormat(), setOption(), setPlane()
*/
QPlatformWindowFormat::QPlatformWindowFormat(QPlatformWindowFormat::FormatOptions options)
{ {
d = new QPlatformWindowFormatPrivate; d = new QWindowFormatPrivate;
QPlatformWindowFormat::FormatOptions newOpts = options; d->opts = options;
d->opts = defaultFormat().d->opts;
d->opts |= (newOpts & 0xffff);
d->opts &= ~(newOpts >> 16);
} }
/*! /*!
\internal \internal
*/ */
void QPlatformWindowFormat::detach() void QWindowFormat::detach()
{ {
if (d->ref != 1) { if (d->ref != 1) {
QPlatformWindowFormatPrivate *newd = new QPlatformWindowFormatPrivate(d); QWindowFormatPrivate *newd = new QWindowFormatPrivate(d);
if (!d->ref.deref()) if (!d->ref.deref())
delete d; delete d;
d = newd; d = newd;
@ -243,7 +106,7 @@ void QPlatformWindowFormat::detach()
Constructs a copy of \a other. Constructs a copy of \a other.
*/ */
QPlatformWindowFormat::QPlatformWindowFormat(const QPlatformWindowFormat &other) QWindowFormat::QWindowFormat(const QWindowFormat &other)
{ {
d = other.d; d = other.d;
d->ref.ref(); d->ref.ref();
@ -253,7 +116,7 @@ QPlatformWindowFormat::QPlatformWindowFormat(const QPlatformWindowFormat &other)
Assigns \a other to this object. Assigns \a other to this object.
*/ */
QPlatformWindowFormat &QPlatformWindowFormat::operator=(const QPlatformWindowFormat &other) QWindowFormat &QWindowFormat::operator=(const QWindowFormat &other)
{ {
if (d != other.d) { if (d != other.d) {
other.d->ref.ref(); other.d->ref.ref();
@ -265,190 +128,16 @@ QPlatformWindowFormat &QPlatformWindowFormat::operator=(const QPlatformWindowFor
} }
/*! /*!
Destroys the QPlatformWindowFormat. Destroys the QWindowFormat.
*/ */
QPlatformWindowFormat::~QPlatformWindowFormat() QWindowFormat::~QWindowFormat()
{ {
if (!d->ref.deref()) if (!d->ref.deref())
delete d; delete d;
} }
/*! /*!
\fn bool QPlatformWindowFormat::doubleBuffer() const \fn bool QWindowFormat::stereo() const
Returns true if double buffering is enabled; otherwise returns
false. Double buffering is enabled by default.
\sa setDoubleBuffer()
*/
/*!
If \a enable is true sets double buffering; otherwise sets single
buffering.
Double buffering is enabled by default.
Double buffering is a technique where graphics are rendered on an
off-screen buffer and not directly to the screen. When the drawing
has been completed, the program calls a swapBuffers() function to
exchange the screen contents with the buffer. The result is
flicker-free drawing and often better performance.
\sa doubleBuffer(), QGLContext::swapBuffers(),
QGLWidget::swapBuffers()
*/
void QPlatformWindowFormat::setDoubleBuffer(bool enable)
{
setOption(enable ? QPlatformWindowFormat::DoubleBuffer : QPlatformWindowFormat::SingleBuffer);
}
/*!
\fn bool QPlatformWindowFormat::depth() const
Returns true if the depth buffer is enabled; otherwise returns
false. The depth buffer is enabled by default.
\sa setDepth(), setDepthBufferSize()
*/
/*!
If \a enable is true enables the depth buffer; otherwise disables
the depth buffer.
The depth buffer is enabled by default.
The purpose of a depth buffer (or Z-buffering) is to remove hidden
surfaces. Pixels are assigned Z values based on the distance to
the viewer. A pixel with a high Z value is closer to the viewer
than a pixel with a low Z value. This information is used to
decide whether to draw a pixel or not.
\sa depth(), setDepthBufferSize()
*/
void QPlatformWindowFormat::setDepth(bool enable)
{
setOption(enable ? QPlatformWindowFormat::DepthBuffer : QPlatformWindowFormat::NoDepthBuffer);
}
/*!
\fn bool QPlatformWindowFormat::rgba() const
Returns true if RGBA color mode is set. Returns false if color
index mode is set. The default color mode is RGBA.
\sa setRgba()
*/
/*!
If \a enable is true sets RGBA mode. If \a enable is false sets
color index mode.
The default color mode is RGBA.
RGBA is the preferred mode for most OpenGL applications. In RGBA
color mode you specify colors as red + green + blue + alpha
quadruplets.
In color index mode you specify an index into a color lookup
table.
\sa rgba()
*/
void QPlatformWindowFormat::setRgba(bool enable)
{
setOption(enable ? QPlatformWindowFormat::Rgba : QPlatformWindowFormat::ColorIndex);
}
/*!
\fn bool QPlatformWindowFormat::alpha() const
Returns true if the alpha buffer in the framebuffer is enabled;
otherwise returns false. The alpha buffer is disabled by default.
\sa setAlpha(), setAlphaBufferSize()
*/
/*!
If \a enable is true enables the alpha buffer; otherwise disables
the alpha buffer.
The alpha buffer is disabled by default.
The alpha buffer is typically used for implementing transparency
or translucency. The A in RGBA specifies the transparency of a
pixel.
\sa alpha(), setAlphaBufferSize()
*/
void QPlatformWindowFormat::setAlpha(bool enable)
{
setOption(enable ? QPlatformWindowFormat::AlphaChannel : QPlatformWindowFormat::NoAlphaChannel);
}
/*!
\fn bool QPlatformWindowFormat::accum() const
Returns true if the accumulation buffer is enabled; otherwise
returns false. The accumulation buffer is disabled by default.
\sa setAccum(), setAccumBufferSize()
*/
/*!
If \a enable is true enables the accumulation buffer; otherwise
disables the accumulation buffer.
The accumulation buffer is disabled by default.
The accumulation buffer is used to create blur effects and
multiple exposures.
\sa accum(), setAccumBufferSize()
*/
void QPlatformWindowFormat::setAccum(bool enable)
{
setOption(enable ? QPlatformWindowFormat::AccumBuffer : QPlatformWindowFormat::NoAccumBuffer);
}
/*!
\fn bool QPlatformWindowFormat::stencil() const
Returns true if the stencil buffer is enabled; otherwise returns
false. The stencil buffer is enabled by default.
\sa setStencil(), setStencilBufferSize()
*/
/*!
If \a enable is true enables the stencil buffer; otherwise
disables the stencil buffer.
The stencil buffer is enabled by default.
The stencil buffer masks certain parts of the drawing area so that
masked parts are not drawn on.
\sa stencil(), setStencilBufferSize()
*/
void QPlatformWindowFormat::setStencil(bool enable)
{
setOption(enable ? QPlatformWindowFormat::StencilBuffer: QPlatformWindowFormat::NoStencilBuffer);
}
/*!
\fn bool QPlatformWindowFormat::stereo() const
Returns true if stereo buffering is enabled; otherwise returns Returns true if stereo buffering is enabled; otherwise returns
false. Stereo buffering is disabled by default. false. Stereo buffering is disabled by default.
@ -468,61 +157,13 @@ void QPlatformWindowFormat::setStencil(bool enable)
\sa stereo() \sa stereo()
*/ */
void QPlatformWindowFormat::setStereo(bool enable) void QWindowFormat::setStereo(bool enable)
{ {
setOption(enable ? QPlatformWindowFormat::StereoBuffers : QPlatformWindowFormat::NoStereoBuffers); if (enable) {
d->opts |= QWindowFormat::StereoBuffers;
} else {
d->opts &= ~QWindowFormat::StereoBuffers;
} }
/*!
\fn bool QPlatformWindowFormat::directRendering() const
Returns true if direct rendering is enabled; otherwise returns
false.
Direct rendering is enabled by default.
\sa setDirectRendering()
*/
/*!
If \a enable is true enables direct rendering; otherwise disables
direct rendering.
Direct rendering is enabled by default.
Enabling this option will make OpenGL bypass the underlying window
system and render directly from hardware to the screen, if this is
supported by the system.
\sa directRendering()
*/
void QPlatformWindowFormat::setDirectRendering(bool enable)
{
setOption(enable ? QPlatformWindowFormat::DirectRendering : QPlatformWindowFormat::IndirectRendering);
}
/*!
\fn bool QPlatformWindowFormat::sampleBuffers() const
Returns true if multisample buffer support is enabled; otherwise
returns false.
The multisample buffer is disabled by default.
\sa setSampleBuffers()
*/
/*!
If \a enable is true, a GL context with multisample buffer support
is picked; otherwise ignored.
\sa sampleBuffers(), setSamples(), samples()
*/
void QPlatformWindowFormat::setSampleBuffers(bool enable)
{
setOption(enable ? QPlatformWindowFormat::SampleBuffers : QPlatformWindowFormat::NoSampleBuffers);
} }
/*! /*!
@ -532,7 +173,7 @@ void QPlatformWindowFormat::setSampleBuffers(bool enable)
\sa setSampleBuffers(), sampleBuffers(), setSamples() \sa setSampleBuffers(), sampleBuffers(), setSamples()
*/ */
int QPlatformWindowFormat::samples() const int QWindowFormat::samples() const
{ {
return d->numSamples; return d->numSamples;
} }
@ -544,75 +185,26 @@ int QPlatformWindowFormat::samples() const
\sa setSampleBuffers(), sampleBuffers(), samples() \sa setSampleBuffers(), sampleBuffers(), samples()
*/ */
void QPlatformWindowFormat::setSamples(int numSamples) void QWindowFormat::setSamples(int numSamples)
{ {
detach(); detach();
if (numSamples < 0) {
qWarning("QPlatformWindowFormat::setSamples: Cannot have negative number of samples per pixel %d", numSamples);
return;
}
d->numSamples = numSamples; d->numSamples = numSamples;
setSampleBuffers(numSamples > 0);
} }
/*!
\since 4.2
Set the preferred swap interval. This can be used to sync the GL
drawing into a system window to the vertical refresh of the screen.
Setting an \a interval value of 0 will turn the vertical refresh syncing
off, any value higher than 0 will turn the vertical syncing on.
Under Windows and under X11, where the \c{WGL_EXT_swap_control} void QWindowFormat::setSharedContext(QPlatformGLContext *context)
and \c{GLX_SGI_video_sync} extensions are used, the \a interval
parameter can be used to set the minimum number of video frames
that are displayed before a buffer swap will occur. In effect,
setting the \a interval to 10, means there will be 10 vertical
retraces between every buffer swap.
Under Windows the \c{WGL_EXT_swap_control} extension has to be present,
and under X11 the \c{GLX_SGI_video_sync} extension has to be present.
*/
void QPlatformWindowFormat::setSwapInterval(int interval)
{
detach();
d->swapInterval = interval;
}
/*!
\since 4.2
Returns the currently set swap interval. -1 is returned if setting
the swap interval isn't supported in the system GL implementation.
*/
int QPlatformWindowFormat::swapInterval() const
{
return d->swapInterval;
}
void QPlatformWindowFormat::setWindowApi(QPlatformWindowFormat::WindowApi api)
{
detach();
d->windowApi = api;
}
QPlatformWindowFormat::WindowApi QPlatformWindowFormat::windowApi() const
{
return d->windowApi;
}
void QPlatformWindowFormat::setSharedContext(QPlatformGLContext *context)
{ {
d->sharedContext = context; d->sharedContext = context;
} }
QPlatformGLContext *QPlatformWindowFormat::sharedGLContext() const QPlatformGLContext *QWindowFormat::sharedGLContext() const
{ {
return d->sharedContext; return d->sharedContext;
} }
/*! /*!
\fn bool QPlatformWindowFormat::hasWindowSurface() const \fn bool QWindowFormat::hasWindowSurface() const
Returns true if the corresponding widget has an instance of QWindowSurface. Returns true if the corresponding widget has an instance of QWindowSurface.
@ -623,19 +215,13 @@ QPlatformGLContext *QPlatformWindowFormat::sharedGLContext() const
\sa setOverlay() \sa setOverlay()
*/ */
/*! void QWindowFormat::setWindowSurface(bool enable)
If \a enable is true a top level QWidget will create a QWindowSurface at creation;
otherwise the QWidget will only have a QPlatformWindow.
This is useful for ie. QGLWidget where the QPlatformGLContext controls the surface.
\sa hasOverlay()
*/
void QPlatformWindowFormat::setWindowSurface(bool enable)
{ {
setOption(enable ? QPlatformWindowFormat::HasWindowSurface : QPlatformWindowFormat::NoWindowSurface); if (enable) {
d->opts |= QWindowFormat::WindowSurface;
} else {
d->opts &= ~QWindowFormat::WindowSurface;
}
} }
/*! /*!
@ -644,29 +230,21 @@ void QPlatformWindowFormat::setWindowSurface(bool enable)
\sa testOption() \sa testOption()
*/ */
void QPlatformWindowFormat::setOption(QPlatformWindowFormat::FormatOptions opt) void QWindowFormat::setOption(QWindowFormat::FormatOptions opt)
{ {
detach(); detach();
if (opt & 0xffff)
d->opts |= opt; d->opts |= opt;
else
d->opts &= ~(opt >> 16);
} }
/*! /*!
Returns true if format option \a opt is set; otherwise returns false. Returns true if format option \a opt is set; otherwise returns false.
\sa setOption() \sa setOption()
*/ */
bool QPlatformWindowFormat::testOption(QPlatformWindowFormat::FormatOptions opt) const bool QWindowFormat::testOption(QWindowFormat::FormatOptions opt) const
{ {
if (opt & 0xffff) return d->opts & opt;
return (d->opts & opt) != 0;
else
return (d->opts & (opt >> 16)) == 0;
} }
/*! /*!
@ -674,15 +252,10 @@ bool QPlatformWindowFormat::testOption(QPlatformWindowFormat::FormatOptions opt)
\sa depthBufferSize(), setDepth(), depth() \sa depthBufferSize(), setDepth(), depth()
*/ */
void QPlatformWindowFormat::setDepthBufferSize(int size) void QWindowFormat::setDepthBufferSize(int size)
{ {
detach(); detach();
if (size < 0) {
qWarning("QPlatformWindowFormat::setDepthBufferSize: Cannot set negative depth buffer size %d", size);
return;
}
d->depthSize = size; d->depthSize = size;
setDepth(size > 0);
} }
/*! /*!
@ -690,150 +263,20 @@ void QPlatformWindowFormat::setDepthBufferSize(int size)
\sa depth(), setDepth(), setDepthBufferSize() \sa depth(), setDepth(), setDepthBufferSize()
*/ */
int QPlatformWindowFormat::depthBufferSize() const int QWindowFormat::depthBufferSize() const
{ {
return d->depthSize; return d->depthSize;
} }
/*! void QWindowFormat::setColorFormat(ColorFormat format)
\since 4.2
Set the preferred red buffer size to \a size.
\sa setGreenBufferSize(), setBlueBufferSize(), setAlphaBufferSize()
*/
void QPlatformWindowFormat::setRedBufferSize(int size)
{ {
detach(); detach();
if (size < 0) { d->colorFormat = format;
qWarning("QPlatformWindowFormat::setRedBufferSize: Cannot set negative red buffer size %d", size);
return;
}
d->redSize = size;
} }
/*! QWindowFormat::ColorFormat QWindowFormat::colorFormat() const
\since 4.2
Returns the red buffer size.
\sa setRedBufferSize()
*/
int QPlatformWindowFormat::redBufferSize() const
{ {
return d->redSize; return d->colorFormat;
}
/*!
\since 4.2
Set the preferred green buffer size to \a size.
\sa setRedBufferSize(), setBlueBufferSize(), setAlphaBufferSize()
*/
void QPlatformWindowFormat::setGreenBufferSize(int size)
{
detach();
if (size < 0) {
qWarning("QPlatformWindowFormat::setGreenBufferSize: Cannot set negative green buffer size %d", size);
return;
}
d->greenSize = size;
}
/*!
\since 4.2
Returns the green buffer size.
\sa setGreenBufferSize()
*/
int QPlatformWindowFormat::greenBufferSize() const
{
return d->greenSize;
}
/*!
\since 4.2
Set the preferred blue buffer size to \a size.
\sa setRedBufferSize(), setGreenBufferSize(), setAlphaBufferSize()
*/
void QPlatformWindowFormat::setBlueBufferSize(int size)
{
detach();
if (size < 0) {
qWarning("QPlatformWindowFormat::setBlueBufferSize: Cannot set negative blue buffer size %d", size);
return;
}
d->blueSize = size;
}
/*!
\since 4.2
Returns the blue buffer size.
\sa setBlueBufferSize()
*/
int QPlatformWindowFormat::blueBufferSize() const
{
return d->blueSize;
}
/*!
Set the preferred alpha buffer size to \a size.
This function implicitly enables the alpha channel.
\sa setRedBufferSize(), setGreenBufferSize(), alphaBufferSize()
*/
void QPlatformWindowFormat::setAlphaBufferSize(int size)
{
detach();
if (size < 0) {
qWarning("QPlatformWindowFormat::setAlphaBufferSize: Cannot set negative alpha buffer size %d", size);
return;
}
d->alphaSize = size;
setAlpha(size > 0);
}
/*!
Returns the alpha buffer size.
\sa alpha(), setAlpha(), setAlphaBufferSize()
*/
int QPlatformWindowFormat::alphaBufferSize() const
{
return d->alphaSize;
}
/*!
Set the preferred accumulation buffer size, where \a size is the
bit depth for each RGBA component.
\sa accum(), setAccum(), accumBufferSize()
*/
void QPlatformWindowFormat::setAccumBufferSize(int size)
{
detach();
if (size < 0) {
qWarning("QPlatformWindowFormat::setAccumBufferSize: Cannot set negative accumulate buffer size %d", size);
return;
}
d->accumSize = size;
setAccum(size > 0);
}
/*!
Returns the accumulation buffer size.
\sa setAccumBufferSize(), accum(), setAccum()
*/
int QPlatformWindowFormat::accumBufferSize() const
{
return d->accumSize;
} }
/*! /*!
@ -841,15 +284,10 @@ int QPlatformWindowFormat::accumBufferSize() const
\sa stencilBufferSize(), setStencil(), stencil() \sa stencilBufferSize(), setStencil(), stencil()
*/ */
void QPlatformWindowFormat::setStencilBufferSize(int size) void QWindowFormat::setStencilBufferSize(int size)
{ {
detach(); detach();
if (size < 0) {
qWarning("QPlatformWindowFormat::setStencilBufferSize: Cannot set negative stencil buffer size %d", size);
return;
}
d->stencilSize = size; d->stencilSize = size;
setStencil(size > 0);
} }
/*! /*!
@ -857,150 +295,48 @@ void QPlatformWindowFormat::setStencilBufferSize(int size)
\sa stencil(), setStencil(), setStencilBufferSize() \sa stencil(), setStencil(), setStencilBufferSize()
*/ */
int QPlatformWindowFormat::stencilBufferSize() const int QWindowFormat::stencilBufferSize() const
{ {
return d->stencilSize; return d->stencilSize;
} }
/*! bool operator==(const QWindowFormat& a, const QWindowFormat& b)
Returns the default QPlatformWindowFormat for the application. All QGLWidget
objects that are created use this format unless another format is
specified, e.g. when they are constructed.
If no special default format has been set using
setDefaultFormat(), the default format is the same as that created
with QPlatformWindowFormat().
\sa setDefaultFormat()
*/
QPlatformWindowFormat QPlatformWindowFormat::defaultFormat()
{
return *q_platformwindow_default_format();
}
/*!
Sets a new default QPlatformWindowFormat for the application to \a f. For
example, to set single buffering as the default instead of double
buffering, your main() might contain code like this:
\snippet doc/src/snippets/code/src_opengl_qgl.cpp 4
\sa defaultFormat()
*/
void QPlatformWindowFormat::setDefaultFormat(const QPlatformWindowFormat &f)
{
*q_platformwindow_default_format() = f;
}
/*!
Returns the default QPlatformWindowFormat for overlay contexts.
The default overlay format is:
\list
\i \link setDoubleBuffer() Double buffer:\endlink Disabled.
\i \link setDepth() Depth buffer:\endlink Disabled.
\i \link setRgba() RGBA:\endlink Disabled (i.e., color index enabled).
\i \link setAlpha() Alpha channel:\endlink Disabled.
\i \link setAccum() Accumulator buffer:\endlink Disabled.
\i \link setStencil() Stencil buffer:\endlink Disabled.
\i \link setStereo() Stereo:\endlink Disabled.
\i \link setDirectRendering() Direct rendering:\endlink Enabled.
\i \link setOverlay() Overlay:\endlink Disabled.
\i \link setSampleBuffers() Multisample buffers:\endlink Disabled.
\i \link setPlane() Plane:\endlink 1 (i.e., first overlay plane).
\endlist
\sa setDefaultFormat()
*/
//QPlatformWindowFormat QPlatformWindowFormat::defaultOverlayFormat()
//{
// return *defaultOverlayFormatInstance();
//}
///*!
// Sets a new default QPlatformWindowFormat for overlay contexts to \a f. This
// format is used whenever a QGLWidget is created with a format that
// hasOverlay() enabled.
// For example, to get a double buffered overlay context (if
// available), use code like this:
// \snippet doc/src/snippets/code/src_opengl_qgl.cpp 5
// As usual, you can find out after widget creation whether the
// underlying OpenGL system was able to provide the requested
// specification:
// \snippet doc/src/snippets/code/src_opengl_qgl.cpp 6
// \sa defaultOverlayFormat()
//*/
//void QPlatformWindowFormat::setDefaultOverlayFormat(const QPlatformWindowFormat &f)
//{
// QPlatformWindowFormat *defaultFormat = defaultOverlayFormatInstance();
// *defaultFormat = f;
// // Make sure the user doesn't request that the overlays themselves
// // have overlays, since it is unlikely that the system supports
// // infinitely many planes...
// defaultFormat->setOverlay(false);
//}
/*!
Returns true if all the options of the two QPlatformWindowFormat objects
\a a and \a b are equal; otherwise returns false.
\relates QPlatformWindowFormat
*/
bool operator==(const QPlatformWindowFormat& a, const QPlatformWindowFormat& b)
{ {
return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts
&& a.d->alphaSize == b.d->alphaSize
&& a.d->accumSize == b.d->accumSize
&& a.d->stencilSize == b.d->stencilSize && a.d->stencilSize == b.d->stencilSize
&& a.d->depthSize == b.d->depthSize && a.d->depthSize == b.d->depthSize
&& a.d->redSize == b.d->redSize && a.d->colorFormat == b.d->colorFormat
&& a.d->greenSize == b.d->greenSize
&& a.d->blueSize == b.d->blueSize
&& a.d->numSamples == b.d->numSamples && a.d->numSamples == b.d->numSamples
&& a.d->swapInterval == b.d->swapInterval && a.d->swapBehavior == b.d->swapBehavior
&& a.d->windowApi == b.d->windowApi); && a.d->sharedContext == b.d->sharedContext);
} }
/*! /*!
Returns false if all the options of the two QPlatformWindowFormat objects Returns false if all the options of the two QWindowFormat objects
\a a and \a b are equal; otherwise returns true. \a a and \a b are equal; otherwise returns true.
\relates QPlatformWindowFormat \relates QWindowFormat
*/ */
bool operator!=(const QPlatformWindowFormat& a, const QPlatformWindowFormat& b) bool operator!=(const QWindowFormat& a, const QWindowFormat& b)
{ {
return !(a == b); return !(a == b);
} }
#ifndef QT_NO_DEBUG_STREAM #ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug dbg, const QPlatformWindowFormat &f) QDebug operator<<(QDebug dbg, const QWindowFormat &f)
{ {
const QPlatformWindowFormatPrivate * const d = f.d; const QWindowFormatPrivate * const d = f.d;
dbg.nospace() << "QGLFormat(" dbg.nospace() << "QWindowFormat("
<< "options " << d->opts << "options " << d->opts
<< ", depthBufferSize " << d->depthSize << ", depthBufferSize " << d->depthSize
<< ", accumBufferSize " << d->accumSize
<< ", stencilBufferSize " << d->stencilSize << ", stencilBufferSize " << d->stencilSize
<< ", redBufferSize " << d->redSize << ", colorFormat " << d->colorFormat
<< ", greenBufferSize " << d->greenSize
<< ", blueBufferSize " << d->blueSize
<< ", alphaBufferSize " << d->alphaSize
<< ", samples " << d->numSamples << ", samples " << d->numSamples
<< ", swapInterval " << d->swapInterval << ", swapBehavior " << d->swapBehavior
<< ", sharedContext " << d->sharedContext
<< ')'; << ')';
return dbg.space(); return dbg.space();

View File

@ -66,7 +66,7 @@ public:
RGBA5658, RGBA5658,
RGBA5551, RGBA5551,
RGB888, RGB888,
RGBA5658, RGBA8888
}; };
enum SwapBehavior { enum SwapBehavior {
@ -109,13 +109,9 @@ public:
void setSharedContext(QPlatformGLContext *context); void setSharedContext(QPlatformGLContext *context);
QPlatformGLContext *sharedGLContext() const; QPlatformGLContext *sharedGLContext() const;
bool depth() const;
void setDepth(bool enable);
bool stencil() const;
void setStencil(bool enable);
bool stereo() const; bool stereo() const;
void setStereo(bool enable); void setStereo(bool enable);
bool hasWindowSurface() const; bool windowSurface() const;
void setWindowSurface(bool enable); void setWindowSurface(bool enable);
void setOption(QWindowFormat::FormatOptions opt); void setOption(QWindowFormat::FormatOptions opt);
@ -141,56 +137,15 @@ Q_OPENGL_EXPORT QDebug operator<<(QDebug, const QWindowFormat &);
#endif #endif
Q_DECLARE_OPERATORS_FOR_FLAGS(QWindowFormat::FormatOptions) Q_DECLARE_OPERATORS_FOR_FLAGS(QWindowFormat::FormatOptions)
Q_DECLARE_OPERATORS_FOR_FLAGS(QWindowFormat::WindowTypes)
inline bool QWindowFormat::doubleBuffer() const
{
return testOption(QWindowFormat::DoubleBuffer);
}
inline bool QWindowFormat::depth() const
{
return testOption(QWindowFormat::DepthBuffer);
}
inline bool QWindowFormat::rgba() const
{
return testOption(QWindowFormat::Rgba);
}
inline bool QWindowFormat::alpha() const
{
return testOption(QWindowFormat::AlphaChannel);
}
inline bool QWindowFormat::accum() const
{
return testOption(QWindowFormat::AccumBuffer);
}
inline bool QWindowFormat::stencil() const
{
return testOption(QWindowFormat::StencilBuffer);
}
inline bool QWindowFormat::stereo() const inline bool QWindowFormat::stereo() const
{ {
return testOption(QWindowFormat::StereoBuffers); return testOption(QWindowFormat::StereoBuffers);
} }
inline bool QWindowFormat::directRendering() const inline bool QWindowFormat::windowSurface() const
{ {
return testOption(QWindowFormat::DirectRendering); return testOption(QWindowFormat::WindowSurface);
}
inline bool QWindowFormat::hasWindowSurface() const
{
return testOption(QWindowFormat::HasWindowSurface);
}
inline bool QWindowFormat::sampleBuffers() const
{
return testOption(QWindowFormat::SampleBuffers);
} }
QT_END_NAMESPACE QT_END_NAMESPACE