summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
authorNorwegian Rock Cat <qt-info@nokia.com>2009-04-15 10:11:39 (GMT)
committerNorwegian Rock Cat <qt-info@nokia.com>2009-04-15 10:17:06 (GMT)
commitb4234ab3f4dbd8c7017d749888b2d8effd3c5983 (patch)
tree6be863fea37b64cb9950da2274cbe6a4423ab401 /src/opengl
parenta55f477b2a40b89e690fe6b61509cf665e96243b (diff)
downloadQt-b4234ab3f4dbd8c7017d749888b2d8effd3c5983.zip
Qt-b4234ab3f4dbd8c7017d749888b2d8effd3c5983.tar.gz
Qt-b4234ab3f4dbd8c7017d749888b2d8effd3c5983.tar.bz2
BT: Fix Cocoa bug w/OpenGL widgets in dock widgets would disappear.
The NSOpenGLContext seems to be tied to the window. So if the view changes from one window to another, the OpenGL context needs to be cleared. We can do this by hooking into the viewWillChangeWindow and viewDidChangeWindow events and clear and reset the drawable respectively. We also found out that QCocoaOpenGLView was not being used at all, so just remove it to get rid of any confusion. Task-number: 250066 Reviewed-by: Trond
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/qgl.cpp4
-rw-r--r--src/opengl/qgl_mac.mm28
-rw-r--r--src/opengl/qgl_p.h1
3 files changed, 10 insertions, 23 deletions
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index 6d75d02..b4a0e5c 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -3234,6 +3234,10 @@ bool QGLWidget::event(QEvent *e)
update();
}
return true;
+# if defined(QT_MAC_USE_COCOA)
+ } else if (e->type() == QEvent::MacGLClearDrawable) {
+ d->glcx->d_ptr->clearDrawable();
+# endif
}
#endif
diff --git a/src/opengl/qgl_mac.mm b/src/opengl/qgl_mac.mm
index 314c659..3dbdaec 100644
--- a/src/opengl/qgl_mac.mm
+++ b/src/opengl/qgl_mac.mm
@@ -87,29 +87,6 @@ QT_FORWARD_DECLARE_CLASS(QWidget)
QT_FORWARD_DECLARE_CLASS(QWidgetPrivate)
QT_FORWARD_DECLARE_CLASS(QGLWidgetPrivate)
-@interface QT_MANGLE_NAMESPACE(QCocoaOpenGLView) : QT_MANGLE_NAMESPACE(QCocoaView)
-{
-}
-- (id)initWithQWidget:(QWidget *)widget widgetPrivate:(QWidgetPrivate *)widgetprivate;
-@end
-
-@implementation QT_MANGLE_NAMESPACE(QCocoaOpenGLView)
-- (id)initWithQWidget:(QWidget *)widget widgetPrivate:(QWidgetPrivate *)widgetprivate
-{
- self = [super initWithQWidget:widget widgetPrivate:widgetprivate];
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(_surfaceNeedsUpdate:)
- name:NSViewGlobalFrameDidChangeNotification
- object:self];
- return self;
-}
-
-- (void) _surfaceNeedsUpdate:(NSNotification*)notification
-{
- Q_UNUSED(notification);
- static_cast<QGLWidgetPrivate *>(qwidgetprivate)->glcx->updatePaintDevice();
-}
-@end
QT_BEGIN_NAMESPACE
void *qt_current_nsopengl_context()
@@ -435,6 +412,11 @@ void *QGLContextPrivate::tryFormat(const QGLFormat &format)
#endif
}
+void QGLContextPrivate::clearDrawable()
+{
+ [static_cast<NSOpenGLContext *>(cx) clearDrawable];
+}
+
/*!
\bold{Mac OS X only:} This virtual function tries to find a visual that
matches the format, reducing the demands if the original request
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h
index b8bbeaf..16aaa96 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -234,6 +234,7 @@ public:
#if defined(Q_WS_MAC)
bool update;
void *tryFormat(const QGLFormat &format);
+ void clearDrawable();
#endif
QGLFormat glFormat;
QGLFormat reqFormat;