Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.9.0
-
None
-
Arch Linux with labwc compositor
Description
On Wayland, when an application's main window is positioned near the bottom of the screen, submenus are incorrectly positioned at-or-below the top of the main window, causing them to be misaligned relative to the parent menu.
This is due to positioning logic in QMenuPrivate::popup() which tries to position the menu at-or-below the global coordinate (0,0). On other window systems (e.g. X11) this is fine and good, because it keeps the menu on-screen. But on Wayland, the "global" coordinate system is actually not global, it's relative to the main window. Therefore there is nothing special about the coordinate (0,0), and the submenu should be allowed to pop up at negative coordinates.
A simple fix is to set the "adjustToDesktop" bool in QMenuPrivate::popup() to false when running on Wayland. This disables the logic which limits the submenu position to be at-or-below (0,0).
bool adjustToDesktop = !q->window()->testAttribute(Qt::WA_DontShowOnScreen) && !qApp->nativeInterface<QNativeInterface::QWaylandApplication>();
Patch: 0001-Fix-submenu-positioning-on-Wayland.patch
Test case:
- Start with the QMenu example: https://code.qt.io/cgit/qt/qtbase.git/tree/examples/widgets/mainwindows/menus
- Modify the example to add 10 more actions to the bottom of the Edit menu:
for (int i = 0; i < 10; i++) { editMenu->addAction(QString("action %1").arg(i)); }
- Build and run the example
- Move the window to the bottom of the screen
- Open the Edit -> Format submenu
- Note that the submenu is not aligned with the Format item in the Edit menu
Before screenshot:
After screenshot:
Attachments
Issue Links
- relates to
-
QTBUG-99618 Expose XdgPositioner to QtBase
-
- Reported
-