summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoaintegration.mm
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@digia.com>2014-06-27 16:29:23 +0200
committerShawn Rutledge <shawn.rutledge@digia.com>2014-08-24 22:19:57 +0200
commit7f1051ed62ad3bc39c064af001e89ebdccc26a7e (patch)
tree5f70fb63a0e81ca3a53d4bc022c1668a7ca7301a /src/plugins/platforms/cocoa/qcocoaintegration.mm
parent3e68148a4dda31d35d12878407cf1d04451e4d3d (diff)
Cocoa: Work around faulty screen list on startup
The NSScreen API has been observed to a return a screen list with one mirrored, non-primary screen when Qt is running as a startup item. Always use the screen if there's only one screen in the list. Change-Id: I721e25bb7595599287b97f6528e04060ce5da6c1 Task-id: QTBUG-37878 Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoaintegration.mm')
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.mm8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm
index fca7fa042c..9fd05a65ee 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.mm
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm
@@ -370,11 +370,15 @@ void QCocoaIntegration::updateScreens()
return;
QSet<QCocoaScreen*> remainingScreens = QSet<QCocoaScreen*>::fromList(mScreens);
QList<QPlatformScreen *> siblings;
- for (uint i = 0; i < [screens count]; i++) {
+ uint screenCount = [screens count];
+ for (uint i = 0; i < screenCount; i++) {
NSScreen* scr = [screens objectAtIndex:i];
CGDirectDisplayID dpy = [[[scr deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue];
// If this screen is a mirror and is not the primary one of the mirror set, ignore it.
- if (CGDisplayIsInMirrorSet(dpy)) {
+ // Exception: The NSScreen API has been observed to a return a screen list with one
+ // mirrored, non-primary screen when Qt is running as a startup item. Always use the
+ // screen if there's only one screen in the list.
+ if (screenCount > 1 && CGDisplayIsInMirrorSet(dpy)) {
CGDirectDisplayID primary = CGDisplayMirrorsDisplay(dpy);
if (primary != kCGNullDirectDisplay && primary != dpy)
continue;