Reintroduce QWindow::SurfaceType

On Cocoa it makes sense to distinguish between the
two window types.

Reviewed-by: Samuel
This commit is contained in:
Morten Sorvig 2011-06-22 13:33:27 +02:00
parent 0e4844aa24
commit def5901955
5 changed files with 22 additions and 0 deletions

View File

@ -24,6 +24,7 @@ HelloWindow::HelloWindow(Renderer *renderer)
: m_colorIndex(0)
, m_renderer(renderer)
{
setSurfaceType(QWindow::OpenGLSurface);
setWindowTitle(QLatin1String("Hello Window"));
setFormat(renderer->format());

View File

@ -72,6 +72,18 @@ QWindow::~QWindow()
destroy();
}
void QWindow::setSurfaceType(SurfaceType surfaceType)
{
Q_D(QWindow);
d->surfaceType = surfaceType;
}
QWindow::SurfaceType QWindow::surfaceType() const
{
Q_D(const QWindow);
return d->surfaceType;
}
void QWindow::setVisible(bool visible)
{
Q_D(QWindow);

View File

@ -100,9 +100,14 @@ class Q_GUI_EXPORT QWindow : public QObject, public QSurface
Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle)
public:
enum SurfaceType { RasterSurface, OpenGLSurface };
QWindow(QWindow *parent = 0);
virtual ~QWindow();
void setSurfaceType(SurfaceType surfaceType);
SurfaceType surfaceType() const;
void setVisible(bool visible);
bool visible() const;

View File

@ -59,6 +59,7 @@ class Q_GUI_EXPORT QWindowPrivate : public QObjectPrivate
public:
QWindowPrivate()
: QObjectPrivate()
, surfaceType(QWindow::RasterSurface)
, windowFlags(Qt::Window)
, parentWindow(0)
, platformWindow(0)
@ -75,6 +76,7 @@ public:
{
}
QWindow::SurfaceType surfaceType;
Qt::WindowFlags windowFlags;
QWindow *parentWindow;
QPlatformWindow *platformWindow;

View File

@ -143,6 +143,7 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
winFormat.setAlphaBufferSize(qMax(winFormat.alphaBufferSize(), 8));
if (!widget->windowHandle()->handle()) {
widget->windowHandle()->setSurfaceType(QWindow::OpenGLSurface);
widget->windowHandle()->setFormat(winFormat);
widget->winId();//make window
}
@ -294,6 +295,7 @@ QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *)
d->oldContext = const_cast<QGLContext *>(QGLContext::currentContext());
d->window = new QWindow;
d->window->setSurfaceType(QWindow::OpenGLSurface);
d->window->setGeometry(QRect(0, 0, 3, 3));
d->window->create();