From 77aeb195a4adcdc76e1543cf93c3569c7485468b Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Tue, 29 Oct 2024 16:58:46 +0100 Subject: [PATCH] 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 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/plugins/platforms/wayland/qwaylandinputdevice.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp index 0c4da6fef4a..ff2b22a613b 100644 --- a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp +++ b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp @@ -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();