Cocoa: Add window fullscreen button on OS X Lion.
authorMorten Johan Sorvig <morten.sorvig@nokia.com>
Wed, 21 Mar 2012 13:58:20 +0000 (14:58 +0100)
committerQt by Nokia <qt-info@nokia.com>
Fri, 23 Mar 2012 08:48:04 +0000 (09:48 +0100)
Use the heuristic that windows that are not an
NSPanel and has the MaximizedButtonHint get the
fullscreen button.

Change-Id: I9a3520b7e4cd1833421d5d2f5b73da7edbfc3e74
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
src/plugins/platforms/cocoa/qcocoawindow.mm

index b4c4e31..b5e8ff2 100644 (file)
@@ -382,6 +382,15 @@ NSWindow * QCocoaWindow::createNSWindow()
                                          defer:NO]; // Deferring window creation breaks OpenGL (the GL context is set up
                                                     // before the window is shown and needs a proper window.).
         window->m_cocoaPlatformWindow = this;
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
+    if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
+        // All windows with the WindowMaximizeButtonHint set also get a full-screen button.
+        if (flags & Qt::WindowMaximizeButtonHint)
+            [window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
+    }
+#endif
+
         createdWindow = window;
     }
     return createdWindow;