[Development] Detecting full-screen mode on the Mac

Jake Petroules jake.petroules at petroules.com
Tue Jun 24 01:41:39 CEST 2014

On 2014-06-23, at 06:28 PM, Ben Medina <ben.medina at gmail.com> wrote:

> Hello all,
> I'm attempting a fix for this bug:
> https://bugreports.qt-project.org/browse/QTBUG-39403
> Our app currently uses 5.2.1, so that's the context. As you can see from my post, using the qt_mac_app_fullscreen Boolean seems to no longer work. So I attempted to look at the QWindow's visibility property, like this:
> QRect QScreen::availableGeometry() const
> {
>     Q_D(const QScreen);
> #ifdef Q_OS_MAC
>     foreach (QWindow* window, QGuiApplication::allWindows())
>     {
>         // If we're in fullscreen mode on the Mac, we don't have to account for space
>         // taken up by the Dock and menu bar, so we can use the full screen geometry.
>         if (window->visibility() == QWindow::FullScreen)
>             return d->geometry;
>     }
> #endif
>     return d->availableGeometry;
> }
> But even when in full-screen mode, I never get QWindow::FullScreen. Does anyone know how to detect if the application is in fullscreen mode on the Mac?
> Thanks,
> Ben
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development

That code is probably from the pre-Lion days when OS X didn't have a native fullscreen mode and I'm guessing we don't properly set the window's visibility to FullScreen on Lion+ when the window is actually fullscreen. The way to detect fullscreen mode for a given window on OS X is:

    (([nswindow styleMask] & NSFullScreenWindowMask) == NSFullScreenWindowMask)

You can also find additional documentation here: https://developer.apple.com/library/mac/documentation/General/Conceptual/MOSXAppProgrammingGuide/FullScreenApp/FullScreenApp.html
Jake Petroules - jake.petroules at petroules.com
Chief Technology Officer - Petroules Corporation
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20140623/bf8c802c/attachment.html>

More information about the Development mailing list