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

Expose XdgPositioner to QtBase

    XMLWordPrintable

Details

    • All, Linux/Wayland

    Description

      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

       

      Attachments

        1. popup-anchors.png
          popup-anchors.png
          17 kB
        2. popup-flip.png
          popup-flip.png
          21 kB
        3. popup-slide.png
          popup-slide.png
          45 kB

        Issue Links

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

          Activity

            People

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

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes