diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index 0ec1524b4d..68cafa3e42 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -198,6 +198,7 @@ public: Q_NOTIFICATION_HANDLER(NSWindowDidMoveNotification) void windowDidMove(); Q_NOTIFICATION_HANDLER(NSWindowDidResizeNotification) void windowDidResize(); Q_NOTIFICATION_HANDLER(NSViewFrameDidChangeNotification) void viewDidChangeFrame(); + Q_NOTIFICATION_HANDLER(NSViewGlobalFrameDidChangeNotification) void viewDidChangeGlobalFrame(); Q_NOTIFICATION_HANDLER(NSWindowDidEndLiveResizeNotification) void windowDidEndLiveResize(); Q_NOTIFICATION_HANDLER(NSWindowDidBecomeKeyNotification) void windowDidBecomeKey(); Q_NOTIFICATION_HANDLER(NSWindowDidResignKeyNotification) void windowDidResignKey(); diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 524d3f0703..a44a9dff6a 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1270,6 +1270,18 @@ void QCocoaWindow::viewDidChangeFrame() [qnsview_cast(m_view) updateGeometry]; } +/*! + Callback for NSViewGlobalFrameDidChangeNotification. + + Posted whenever an NSView object that has attached surfaces (that is, + NSOpenGLContext objects) moves to a different screen, or other cases + where the NSOpenGLContext object needs to be updated. +*/ +void QCocoaWindow::viewDidChangeGlobalFrame() +{ + updateExposedGeometry(); +} + void QCocoaWindow::windowDidEndLiveResize() { if (m_synchedWindowState == Qt::WindowMaximized && ![m_nsWindow isZoomed]) { diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h index c45d7481c6..d911b804cc 100644 --- a/src/plugins/platforms/cocoa/qnsview.h +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -74,7 +74,6 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper)); QStringList *currentCustomDragTypes; bool m_sendUpAsRightButton; Qt::KeyboardModifiers currentWheelModifiers; - bool m_subscribesForGlobalFrameNotifications; #ifndef QT_NO_OPENGL QCocoaGLContext *m_glContext; bool m_shouldSetGLContextinDrawRect; diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index a2971c06b0..667a2381a0 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -149,7 +149,6 @@ static bool _q_dontOverrideCtrlLMB = false; m_acceptedMouseDowns = Qt::NoButton; m_frameStrutButtons = Qt::NoButton; m_sendKeyEvent = false; - m_subscribesForGlobalFrameNotifications = false; #ifndef QT_NO_OPENGL m_glContext = 0; m_shouldSetGLContextinDrawRect = false; @@ -181,7 +180,6 @@ static bool _q_dontOverrideCtrlLMB = false; CGImageRelease(m_maskImage); [m_trackingArea release]; m_maskImage = 0; - m_subscribesForGlobalFrameNotifications = false; [m_inputSource release]; [[NSNotificationCenter defaultCenter] removeObserver:self]; [m_mouseMoveHelper release]; @@ -235,27 +233,9 @@ static bool _q_dontOverrideCtrlLMB = false; //was unable to set view m_shouldSetGLContextinDrawRect = true; } - - if (!m_subscribesForGlobalFrameNotifications) { - // NSOpenGLContext expects us to repaint (or update) the view when - // it changes position on screen. Since this happens unnoticed for - // the view when the parent view moves, we need to register a special - // notification that lets us handle this case: - m_subscribesForGlobalFrameNotifications = true; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(globalFrameChanged:) - name:NSViewGlobalFrameDidChangeNotification - object:self]; - } } #endif -- (void) globalFrameChanged:(NSNotification*)notification -{ - Q_UNUSED(notification); - m_platformWindow->updateExposedGeometry(); -} - - (void)viewDidMoveToSuperview { if (!(m_platformWindow->m_viewIsToBeEmbedded))