diff options
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/platforms/cocoa/qnsview.h | 3 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qnsview.mm | 17 |
2 files changed, 19 insertions, 1 deletions
diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h index 67b16b4b32..20e82940bd 100644 --- a/src/plugins/platforms/cocoa/qnsview.h +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -69,6 +69,9 @@ QT_END_NAMESPACE bool m_sendUpAsRightButton; Qt::KeyboardModifiers currentWheelModifiers; bool m_subscribesForGlobalFrameNotifications; + QCocoaGLContext *m_glContext; + bool m_glContextDirty; + bool m_drawRectHasBeenCalled; } - (id)init; diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index a53d6c4e44..7868d058ae 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -85,6 +85,9 @@ static QTouchDevice *touchDevice = 0; m_buttons = Qt::NoButton; m_sendKeyEvent = false; m_subscribesForGlobalFrameNotifications = false; + m_glContext = 0; + m_glContextDirty = false; + m_drawRectHasBeenCalled = false; currentCustomDragTypes = 0; m_sendUpAsRightButton = false; @@ -150,7 +153,12 @@ static QTouchDevice *touchDevice = 0; - (void) setQCocoaGLContext:(QCocoaGLContext *)context { - [context->nsOpenGLContext() setView:self]; + m_glContext = context; + if (m_drawRectHasBeenCalled) { + [m_glContext->nsOpenGLContext() setView:self]; + } else { + m_glContextDirty = true; + } if (!m_subscribesForGlobalFrameNotifications) { // NSOpenGLContext expects us to repaint (or update) the view when // it changes position on screen. Since this happens unnoticed for @@ -344,6 +352,13 @@ static QTouchDevice *touchDevice = 0; - (void) drawRect:(NSRect)dirtyRect { + if (m_glContext && m_glContextDirty) { + [m_glContext->nsOpenGLContext() setView:self]; + m_glContextDirty = false; + } else { + m_drawRectHasBeenCalled = true; + } + if (!m_backingStore) return; |