Bug 426761 - Wayland: QMenu::popup(QCursor::pos()) creates windowed menu not at cursor position.
Summary: Wayland: QMenu::popup(QCursor::pos()) creates windowed menu not at cursor pos...
Status: RESOLVED NOT A BUG
Alias: None
Product: plasmashell
Classification: Plasma
Component: general (show other bugs)
Version: 5.19.90
Platform: Other Linux
: NOR normal
Target Milestone: 1.0
Assignee: David Edmundson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-09-20 05:31 UTC by Lukas Spies
Modified: 2020-09-20 16:53 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Simple Qt5 application illustrating observed behavior. (3.80 KB, application/gzip)
2020-09-20 05:31 UTC, Lukas Spies
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Lukas Spies 2020-09-20 05:31:51 UTC
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.
Comment 1 David Edmundson 2020-09-20 11:51:10 UTC
>(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
Comment 2 David Edmundson 2020-09-20 12:01:41 UTC
Also note that on Plasma, any system tray icon will implicitly be using 

https://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/
Comment 3 Lukas Spies 2020-09-20 16:37:01 UTC
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.
Comment 4 Lukas Spies 2020-09-20 16:53:23 UTC
https://bugreports.qt.io/browse/QTBUG-86780