Details

    • Type: Technical task
    • Status: Closed
    • Priority: P3: Somewhat important
    • Resolution: Done
    • Fix Version/s: None
    • Component/s: Other
    • Labels:
      None

      Description

      Quote Qt5-feedback:

      That is no big deal, code-wise: Basically it boils down to setting a "window
      flag" NSWindowCollectionBehaviorFullScreenPrimary. In my own code I did this
      within a *.mm ("objective C++") file, with OS X API calls such as:

      NSView *nsview = (NSView *) mainWindow.winId();
      NSWindow *nswindow = [nsview window];
      [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];

      And that's it! Almost. It adds this "fullscreen" icon to your window title bar
      with which you can toggle into/from fullscreen.

      If you want to control this from your own code - e.g. from a separate "Window"
      or "View" menu entry - you can call the following OSX API. Inside some slot:

      QMainWindow *mainWindow = ...;
      NSView *nsview = (NSView *) mainWindow->winId();
      NSWindow *nswindow = [nsview window];
      [nswindow toggleFullScreen:nil]; // That's the magic here!

      The following code is useful to figure out the "fullscreen" state:

      QMainWindow *mainWindow = ...;
      NSView *nsview = (NSView *) mainWindow->winId();
      NSWindow *nswindow = [nsview window];
      NSUInteger masks = [nswindow styleMask];
      bool result = masks & NSFullScreenWindowMask;

      A few #ifdefs here (#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 is
      your friend), a few runtime checks there, and my code compiles and runs on both
      OS X 10.6 and 10.7 (on 10.6 off course the fallback is the available
      QWidget::showFullScreen mechanism).

      So my wish here would be that "Qt does all that for me" That is when my Qt
      application runs on Lion (runtime checks!) it would default to the "Lion
      fullscreen mode" upon QWidget::showFullScreen(), or optionally use the existing
      fullscreen approach when some additional Qt style flag would be set (like
      "PlatformFullScreen" vs "QtFullScreen" or whatever...).

      However with a Qt 4.7.3 (and also with Qt 4.8 Beta I think) I had some issue
      with the "native" (or "unified") toolbar, especially when trying to toggle the
      visibility of the toolbar: sometimes the toolbar was not properly restored
      ("invisible"), even though the Qt API claimed it was "visible". And it somewhat
      flickers when going from "fullscreen" back to "normal" (well, it's more like
      some "animation" which makes it first invisible and then visible again).

      I tried to hack around this by setting the "visible" state explicitly. Also
      calling setUnifiedTitleAndToolBarOnMac() when changing state seemed to help a
      little.

      What I absolutely did not manage was something like "Show toolbar in normal
      view, but hide it when going fullscreen - show it again when going to normal
      view again". After toogling back and forth all of a sudden the toolbar would not
      show up, or only a few pixel height toolbar was visible etc.

      I think in general that "unified toolbar" code should be looked at again when
      testing "Lion fullscreen support"...

        Attachments

          Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            Activity

              People

              Assignee:
              sorvig Morten Sørvig
              Reporter:
              sorvig Morten Sørvig
              Votes:
              19 Vote for this issue
              Watchers:
              18 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes