From 7f1051ed62ad3bc39c064af001e89ebdccc26a7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Fri, 27 Jun 2014 16:29:23 +0200 Subject: 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 --- src/plugins/platforms/cocoa/qcocoaintegration.mm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/plugins') 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 remainingScreens = QSet::fromList(mScreens); QList 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; -- cgit v1.2.3