@@ -0,0 +1,73 @@
1+diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
2+index 00c3f7c22c..94d35f59d6 100644
3+--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
4++++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
5+@@ -1355,15 +1355,6 @@ QCocoaNSWindow *QCocoaWindow::createNSWindow(bool shouldBePanel)
6+ {
7+ QMacAutoReleasePool pool;
8+
9+- Qt::WindowType type = window()->type();
10+- Qt::WindowFlags flags = window()->flags();
11+-
12+- // Note: The macOS window manager has a bug, where if a screen is rotated, it will not allow
13+- // a window to be created within the area of the screen that has a Y coordinate (I quadrant)
14+- // higher than the height of the screen in its non-rotated state, unless the window is
15+- // created with the NSWindowStyleMaskBorderless style mask.
16+- NSWindowStyleMask styleMask = windowStyleMask(flags);
17+-
18+ QRect rect = geometry();
19+
20+ QScreen *targetScreen = nullptr;
21+@@ -1375,22 +1366,26 @@ QCocoaNSWindow *QCocoaWindow::createNSWindow(bool shouldBePanel)
22+ }
23+
24+ if (!targetScreen) {
25+- qCWarning(lcQpaCocoaWindow) << "Window position" << rect << "outside any known screen, using primary screen";
26++ qCWarning(lcQpaCocoaWindow) << "Window position outside any known screen, using primary screen";
27+ targetScreen = QGuiApplication::primaryScreen();
28+- // AppKit will only reposition a window that's outside the target screen area if
29+- // the window has a title bar. If left out, the window ends up with no screen.
30+- // The style mask will be corrected to the original style mask in setWindowFlags.
31+- styleMask |= NSWindowStyleMaskTitled;
32+ }
33+
34+ rect.translate(-targetScreen->geometry().topLeft());
35+ QCocoaScreen *cocoaScreen = static_cast<QCocoaScreen *>(targetScreen->handle());
36+ NSRect frame = QCocoaScreen::mapToNative(rect, cocoaScreen);
37+
38++ // Note: The macOS window manager has a bug, where if a screen is rotated, it will not allow
39++ // a window to be created within the area of the screen that has a Y coordinate (I quadrant)
40++ // higher than the height of the screen in its non-rotated state, unless the window is
41++ // created with the NSWindowStyleMaskBorderless style mask.
42++
43++ Qt::WindowType type = window()->type();
44++ Qt::WindowFlags flags = window()->flags();
45++
46+ // Create NSWindow
47+ Class windowClass = shouldBePanel ? [QNSPanel class] : [QNSWindow class];
48+ QCocoaNSWindow *nsWindow = [[windowClass alloc] initWithContentRect:frame
49+- styleMask:styleMask
50++ styleMask:windowStyleMask(flags)
51+ // Deferring window creation breaks OpenGL (the GL context is
52+ // set up before the window is shown and needs a proper window)
53+ backing:NSBackingStoreBuffered defer:NO
54+@@ -1399,9 +1394,6 @@ QCocoaNSWindow *QCocoaWindow::createNSWindow(bool shouldBePanel)
55+ Q_ASSERT_X(nsWindow.screen == cocoaScreen->nativeScreen(), "QCocoaWindow",
56+ "Resulting NSScreen should match the requested NSScreen");
57+
58+- if (targetScreen != window()->screen())
59+- QWindowSystemInterface::handleWindowScreenChanged(window(), targetScreen);
60+-
61+ nsWindow.delegate = [[QNSWindowDelegate alloc] initWithQCocoaWindow:this];
62+
63+ // Prevent Cocoa from releasing the window on close. Qt
64+@@ -1421,6 +1413,9 @@ QCocoaNSWindow *QCocoaWindow::createNSWindow(bool shouldBePanel)
65+ });
66+ }
67+
68++ if (targetScreen != window()->screen())
69++ QWindowSystemInterface::handleWindowScreenChanged(window(), targetScreen);
70++
71+ nsWindow.restorable = NO;
72+ nsWindow.level = windowLevel(flags);
73+