macOS: Deliver screen change on window creation instead of on first expose

We know the resulting screen based on the geometry mappings we now do, so
no need to wait until expose to deliver the screen change.

Change-Id: Ibb84948ab091d8f74d31cdd2d300b381e2e1e7cc
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
bb10
Tor Arne Vestbø 2017-07-10 15:23:47 +02:00
parent e7ba24bd70
commit 0721199187
1 changed files with 5 additions and 10 deletions

View File

@ -1268,6 +1268,11 @@ QCocoaNSWindow *QCocoaWindow::createNSWindow(bool shouldBePanel)
Class windowClass = shouldBePanel ? [QNSPanel class] : [QNSWindow class];
QCocoaNSWindow *nsWindow = [[windowClass alloc] initWithContentRect:frame
screen:cocoaScreen->nativeScreen() styleMask:windowStyleMask(flags) qPlatformWindow:this];
Q_ASSERT_X(nsWindow.screen == cocoaScreen->nativeScreen(), "QCocoaWindow",
"Resulting NSScreen should match the requested NSScreen");
if (targetScreen != window()->screen())
QWindowSystemInterface::handleWindowScreenChanged(window(), targetScreen);
nsWindow.restorable = NO;
nsWindow.level = windowLevel(flags);
@ -1655,16 +1660,6 @@ void QCocoaWindow::exposeWindow()
if (!isWindowExposable())
return;
if (window()->isTopLevel()) {
// 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.
if (QCocoaScreen *cocoaScreen = QCocoaIntegration::instance()->screenForNSScreen(m_view.window.screen))
window()->setScreen(cocoaScreen->screen());
}
if (!m_isExposed) {
m_isExposed = true;
m_exposedGeometry = geometry();