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

Expose XdgPositioner to QtBase

XMLWordPrintable

    • All, Linux/Wayland

      I've written this as being against QtWayland, but ultimately all the work has to be in QWidgets.

      Right now Qt tries to keep new popups on screen, this is duplicated in a few places but doesn't work on wayland as we don't have enough information about where our window is, therefore it can't try and keep a window on screen. If anything Qt's attempts are detrimental.

      On wayland we need to supply the metadata to the compositor where it can make the right move. The API is quite good, so it's a good opportunity to de-duplicate the Qt code.

      // Step 1:

      Introduce QMenu::popup(QRect)
      copying the code from QMenubar

      then migrate QMenuBar to that, solving the QMenuBar problem

       Step 2:

       

       

      class QPopupPosition
      {
          QPopupPosition(QWindow *transientParent, QRect parentAnchorRect);    setTransientParent(QWindow *transientParent);
          setParentAnchorRect(const QRect &parentAnchorRect);    setParentAnchor(Qt::Edge anchorEdge);
          setClientAnchor(Qt::Edge anchorEdge); // this would be the inverse of gravity to be closer to Qt API   
      
          setConstaintHandling(Constraint); // flip, slide, resize    // offset?    
      
          // used by QMenu to either follow or ignore struts, write that this may have no effect on the platform blah blah
          setUseFullscreenForPopup(bool useFullScreen);
      };
      
      // add a method in QPlatformWindow (maybe surfaced in QWindow?)
      
      QPlatformWindow::position(const QPopupPosition &popupPosition)
      {
          setTransientParent(popupPosition.transientParent());    // position window (we can copy and paste all the kwin code's here)
          QPoint pos = ...
          move(pos);
      }
      
      QWaylandWindow::position(const QPopupPosition &popupPosition)
      {
          // on wayland we would cache the positioning
          m_popupPosition = position;
          // then somehow expose this to XdgShellPopup in the show method
      }
      
      

       

       

      port the following to use this

      QMenu
      QComboBox
      QDateTimeEdit
      QTooltip

       

        1. popup-anchors.png
          17 kB
          Liang Qi
        2. popup-flip.png
          21 kB
          Liang Qi
        3. popup-slide.png
          45 kB
          Liang Qi
        4. Screenshot_20240515_224352.png
          1.02 MB
          David Edmundson
        For Gerrit Dashboard: QTBUG-99618
        # Subject Branch Project Status CR V

            qt.team.graphics.and.multimedia Qt Graphics Team
            davidedmundson David Edmundson
            Votes:
            11 Vote for this issue
            Watchers:
            21 Start watching this issue

              Created:
              Updated:

                There are 2 open Gerrit changes