From db2675d6fdb0d44fe1b040eda47f75e8bb35ce7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Thu, 10 Sep 2015 11:16:38 +0200 Subject: [PATCH] Cocoa: Update QWindow::screen() on expose/show. This is needed to correctly handle show on non-primary screens. Change-Id: I80b13372b3a92786987a66f0da385af6b4a6a863 Task-number: QTBUG-47950 Reviewed-by: Timur Pocheptsov --- src/plugins/platforms/cocoa/qcocoawindow.mm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 3b5909a37e2..00cb43c9405 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -1775,6 +1775,18 @@ void QCocoaWindow::exposeWindow() if (!isWindowExposable()) return; + // Update the QWindow's screen property. This property is set + // to QGuiApplication::primaryScreen() at QWindow construciton + // time, and we won't get a NSWindowDidChangeScreenNotification + // on show. The case where the window is initially displayed + // on a non-primary screen needs special handling here. + NSUInteger screenIndex = [[NSScreen screens] indexOfObject:m_nsWindow.screen]; + if (screenIndex != NSNotFound) { + QCocoaScreen *cocoaScreen = QCocoaIntegration::instance()->screenAtIndex(screenIndex); + if (cocoaScreen) + window()->setScreen(cocoaScreen->screen()); + } + if (!m_isExposed) { m_isExposed = true; m_exposedGeometry = geometry();