| Summary: | Wayland: QMenu::popup(QCursor::pos()) creates windowed menu not at cursor position. | ||
|---|---|---|---|
| Product: | [Plasma] plasmashell | Reporter: | Lukas Spies <Lukas> |
| Component: | general | Assignee: | David Edmundson <kde> |
| Status: | RESOLVED NOT A BUG | ||
| Severity: | normal | CC: | plasma-bugs-null |
| Priority: | NOR | ||
| Version First Reported In: | 5.19.90 | ||
| Target Milestone: | 1.0 | ||
| Platform: | Other | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
| Attachments: | Simple Qt5 application illustrating observed behavior. | ||
>(Also, I wasn't sure which product this falls under.)
It unfortunately falls under: this is not expected to work. Wayland has some behavioural differences. You don't have access to global QCursor::pos() and you can't explicitly position a window.
Please use trayIcon->setContextMenu
Also note that on Plasma, any system tray icon will implicitly be using https://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/ Thanks for the comment. I might file a bug report against the Qt doc to get a note added there that this does not work on Wayland. |
Created attachment 131795 [details] Simple Qt5 application illustrating observed behavior. SUMMARY In Wayland, for a Qt 5 application, showing a menu at cursor position shows the menu windowed centered on application window instead of as menu at the position of the cursor. In particular, I observed this behavior with a menu set as context menu to a QSystemTrayIcon. (Also, I wasn't sure which product this falls under.) STEPS TO REPRODUCE 1. Run attached app. 2. Right and Left click on tray icon. OBSERVED RESULT A right click open the context menu properly/normally. A left click calling QMenu::popup(QCursor::pos()) opens the context menu as window centered on application window. EXPECTED RESULT A left click opens the context menu at cursor position. SOFTWARE/OS VERSIONS Linux: Arch Linux (available in About System) KDE Plasma Version: 5.19.90 KDE Frameworks Version: 5.74.0 Qt Version: 5.15.1 ADDITIONAL INFORMATION I observed this same behavior on 5.19.5 and 5.19.90.