Position grabbing popups correctly when started from hover events

If there is no known lastInputDevice, child popups will be randomly
positioned. This can happen when a popup is triggered by a hover event.
The obvious fix is to call setLastInputDevice from pointer_enter().
However, Weston (and probably other compositors) do not accept enter
events as valid grab serials. Calling setLastInputDevice from every pointer_enter would therefore completely disable menu popup on mouse-over for those compositors.
The solution is to only call setLastInputDevice when we have not seen one before. This means that the user may have to click once to get hover popups to work. This should be an acceptable price to pay to avoid menus appearing at random positions.

Fixes: QTBUG-128937
Change-Id: I446abb2f4bed65cb4c46ec89d08025cd6cd8e5f3
Reviewed-by: David Edmundson <davidedmundson@kde.org>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
Paul Olav Tvete 2024-10-29 16:58:46 +01:00
parent e7539d2ee8
commit 77aeb195a4

View File

@ -681,6 +681,10 @@ void QWaylandInputDevice::Pointer::pointer_enter(uint32_t serial, struct wl_surf
mParent->mSerial = serial;
mEnterSerial = serial;
if (!mParent->mQDisplay->lastInputDevice()) {
mParent->mQDisplay->setLastInputDevice(mParent, serial, window);
}
#if QT_CONFIG(cursor)
// Depends on mEnterSerial being updated
updateCursor();