Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-30139

QWindow::showFullScreen doesn't work well with window expand button on Mac OS 10.8

    XMLWordPrintable

Details

    • macOS
    • 7ee15bfbb815df87ae0526f105a13a591b192c76

    Description

      I first reported this at http://qt-project.org/forums/viewthread/25551/, but someone suggested I put it into bugtracker.

      I'm using Qt 5.0 on Mac OS 10.8.

      QWindow::showFullScreen() and ::showNormal() are the procedural way to enter and exit full screen mode.
      On Mac OS 10.8 (and 10.7) each window has an "expand" button that looks like two arrows pointing away from each other in the upper right of the window that gives a user interface to full screen mode.

      The bug is that with Qt 5.0 on Mac OS 10.8 if you use the expand button and then call showNormal(), it does not exit full screen mode. I conclude that the expand button is messing up some state information inside Qt. Below is a stripped down program and a script to reproduce the bug.

      Put cursor in window and type these keys — And you'll see this

      A
      up-arrow — enters full screen, as it should
      B
      down-arrow — exits full screen, as it should
      C
      expand-button — enters full screen, as it should
      D
      down-arrow — calls showNormal, but does not exit full screen! bug!
      E
      up-arrow — calls showFullScreen, so should do nothing, but it exits full screen! bug!
      F

      The keys A,B,C,D,E,F above simply act as markers in the history. The printout is:

      Resize from -1x-1 to 200x100
      Resize from 640x480 to 200x100
        KeyPress key=0x00000041=(A)  status: isFullScreen=0 windowState=0
        KeyPress key=0x01000013=()=UP
      showFullScreen - Resize from 200x100 to 1280x800
      status: isFullScreen=1 windowState=1
        KeyPress key=0x00000042=(B)  status: isFullScreen=1 windowState=1
        KeyPress key=0x01000015=()=DOWN
      showNormal - status: isFullScreen=0 windowState=0
      Resize from 1280x800 to 200x100
        KeyPress key=0x00000043=(C)  status: isFullScreen=0 windowState=0
      Resize from 200x100 to 1280x800
        KeyPress key=0x00000044=(D)  status: isFullScreen=1 windowState=1
        KeyPress key=0x01000015=()=DOWN
      showNormal - status: isFullScreen=0 windowState=0
        KeyPress key=0x00000045=(E)  status: isFullScreen=0 windowState=0
        KeyPress key=0x01000013=()=UP
      showFullScreen - status: isFullScreen=1 windowState=1
      Resize from 1280x800 to 200x100
        KeyPress key=0x00000046=(F)  status: isFullScreen=0 windowState=0
      

      Note that the first UP and DOWN keys and the expand button cause Resize events, as they should, but the DOWN that is done after D does not cause a Resize event, and the isFullScreen() values after that DOWN and at E are incorrect. So as far as I can tell, the numbers in the Resize are accurate, but isFullScreen() can't be trusted fully on 10.8, nor windowState(), nor showNormal(), nor showFullScreen().

      Is there a workaround for this until it's fully fixed?

      thanks

      fullscreen.pro:

      greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
      CONFIG += release
      HEADERS = fullscreen.h
      SOURCES = fullscreen.cpp
      

      fullscreen.h:

      #include <QMainWindow>
      class QEvent;
      
      class TopWindow : public QMainWindow {
          Q_OBJECT
        public:
          TopWindow();  // creates subwidgets and does show()
        private:
          bool event(QEvent *event);
      };
      

      fullscreen.cpp:

      // test Qt full screen functions:
      // can we enter and exit full screen mode well?
      
      #include <iostream>
      #include <QApplication>
      #include <QKeyEvent>
      #include <QLabel>
      
      #include "fullscreen.h"
      
      TopWindow::TopWindow() {
        QLabel *label = new QLabel(this);
        label->setText("xyz");
        show();
      }
      
      bool TopWindow::event(QEvent *event) {
        switch (event->type()) {
          case QEvent::KeyPress:
            {
              QKeyEvent *key_event = static_cast<QKeyEvent *>(event);
              int key = key_event->key();
              printf("  KeyPress key=0x%08x=(%c)", key, key);
              switch (key) {
                case Qt::Key_Up:
                  printf("=UP\nshowFullScreen - ");
                  showFullScreen();
                  printf("status: isFullScreen=%d windowState=%d\n", isFullScreen(),
                      windowState().testFlag(Qt::WindowFullScreen));
                  return true;  // we handled the event
                  break;
                case Qt::Key_Down:
                  printf("=DOWN\nshowNormal - ");
                  showNormal();
                  printf("status: isFullScreen=%d windowState=%d\n", isFullScreen(),
                      windowState().testFlag(Qt::WindowFullScreen));
                  return true;  // we handled the event
                  break;
                default:
                  printf("  status: isFullScreen=%d windowState=%d\n", isFullScreen(),
                      windowState().testFlag(Qt::WindowFullScreen));
                  break;
              }
              break;
            }
          case QEvent::Resize:
            {
              QResizeEvent *resize_event = static_cast<QResizeEvent *>(event);
              printf("Resize from %dx%d to %dx%d\n",
                  resize_event->oldSize().width(), resize_event->oldSize().height(),
                  resize_event->size().width(), resize_event->size().height());
              break;
            }
          default: break;
        }
        return false;  // we didn't handle the event
      }
      
      int main(int argc, char **argv) {
        QApplication app(argc, argv);
        TopWindow top;
        app.exec();
      }
      

      Attachments

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

        Activity

          People

            dedietri Gabriel de Dietrich (drgvond)
            paulheckbert Paul Heckbert
            Votes:
            3 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes