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

Maximized (and fullscreen) frameless QML view is a can of worms, when it comes to menu pop-ups (on Windows)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Incomplete
    • P2: Important
    • None
    • 5.3.2, 5.4.0
    • Quick: Other
    • None
    • Windows 7 Ultimate, AMD A6-3650 with recent video drivers, desktop OpenGL Qt: Digia / Commercial 5.4, Open-source / Community 5.3.2, MSVC 2013 x86

    Description

      A maximized QQuickView with a Qt::FramelessWindowHint flag set fails to pop up QML menus, with the menu being briefly visible, and then going back in the Windows z-stack (can be seen briefly again, if Alt-Tab is pressed). Showing full screen, or even aligning the view with the screen manually has the same effect (obviously, some logic is trying to optimize GL-backed window behavior when its geometry matches taht of the screen perfectly).

      Using MESA OpenGL_32.dll removes the issue, seemingly (did not check thoroughly with ANGLE, but the core issue seems hapenning there, too).

      Additionally, sometimes maximizing fails to re-render the window, and only displays what was its previous contents in the upper-left corner of the screen (adding some animated geometry helps here, see the QML code comments below); also, sometimes maximizng works only the first time, and sometimes the maximized window fails to get mouse input (see comments, again).

      Here's the .cpp and .qml (full project is attached) –

      main.cpp:

      #include <QQuickView>
      #include <QQmlContext>
      #include <QGuiApplication>
      
      int main(int argc, char *argv[])
      {
          QGuiApplication a(argc, argv);
      
          QQuickView view;
          view.setFlags( view.flags() | Qt::FramelessWindowHint );
      
          view.setResizeMode(QQuickView::SizeRootObjectToView);
          view.rootContext()->setContextProperty("view", &view);
          view.setSource(QUrl("qrc:/qml/main.qml"));
      
          view.resize(500, 300);
          view.show();
      
          return a.exec();
      }
      

      main.qml ([1...3] mark the seen issues in comments):

      import QtQuick 2.0
      import QtQuick.Window 2.2
      import QtQuick.Controls 1.1
      import QtQml 2.2
      
      Rectangle {
          border.width: 10
      
          Menu {
              id: menu
              Instantiator {
                  model: 20
                  MenuItem {
                      text: "Click me! #" + index
                      onTriggered: console.log("clicked: #" + index)
                  }
                  onObjectAdded: menu.insertItem(index, object)
                  onObjectRemoved: menu.removeItem(object)
              }
          }
      
          MouseArea {
              anchors.fill: parent
              onClicked: {
                  console.log("popping up menu")
                  menu.popup()
              }
          }
      
          Row { //[1] all three buttons may sometimes become unresponsive to mouse after maximizing / unmaximizing the window
                // (and this is *not* an issue with window contents not updated, as the rotating rectangle is still moving in the proper place)
              spacing: 50
              anchors.centerIn: parent
              Button {
                  text: "maximize"
      
                  //swap handlers below to make the issues in question go away (view.showFullScreen() would break as well)
                  onClicked: view.showMaximized() //[2] may not work the second time you try it (maximize->unmaximize->maximize, button clicked, nothing happens)
      //            onClicked: {
      //                view.x = 0
      //                view.width = Screen.width + 1 //not having "+ 1"s here has same breaking effect as showMaximized()
      //                view.y = 0
      //                view.height = Screen.height + 1 //see above
      //            }
              }
      
              Button {
                  text: "unmaximize"
                  onClicked: {
                      view.width = Screen.width / 2
                      view.height = Screen.height / 2
                  }
              }
              Button {
                  text: "close"
                  onClicked: view.close()
              }
          }
      
          //[3] with this commented out, the application fails to repaint in maximized state
          //  (shows its old window contents at (0,0) while still capturing mouse and keyboard... sometimes (see [1]))
      //    Rectangle {
      //        id: rect
      //        opacity: .5
      //        anchors.centerIn: parent
      //        width: 100
      //        height: width
      //        color: "red"
      //        RotationAnimation on rotation {
      //            from: 0
      //            to: 360
      //            duration: 1000
      //            onStopped: start()
      //        }
      //    }
      
          focus: true
          Keys.onSpacePressed: view.close() //when you're stuck :)
      }
      

      Attachments

        Issue Links

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

          Activity

            People

              andysh Andy Shaw
              vmoolle Vladimir Moolle
              Votes:
              5 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes