Reintroduce QWindow::SurfaceType
authorMorten Sorvig <morten.sorvig@nokia.com>
Wed, 22 Jun 2011 11:33:27 +0000 (13:33 +0200)
committerMorten Sorvig <morten.sorvig@nokia.com>
Wed, 22 Jun 2011 12:10:26 +0000 (14:10 +0200)
On Cocoa it makes sense to distinguish between the
two window types.

Reviewed-by: Samuel
examples/opengl/hellowindow/hellowindow.cpp
src/gui/kernel/qwindow.cpp
src/gui/kernel/qwindow.h
src/gui/kernel/qwindow_p.h
src/opengl/qgl_qpa.cpp

index afdf080..9575d3e 100644 (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());
index d060adf..7fa9316 100644 (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);
index 20b6074..67330e5 100644 (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;
 
index a8b1183..cca20bc 100644 (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;
index 661f120..7a4fb2c 100644 (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();