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 <timur.pocheptsov@theqtcompany.com>
This commit is contained in:
Morten Johan Sørvig 2015-09-10 11:16:38 +02:00 committed by Simon Hausmann
parent 7dceb22748
commit db2675d6fd

View File

@ -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();