Client: Fix enter event cursor position with xdg-popup and QHighDpiScaling

QWindowSystemInterface::handleEnterEvent accepts device-dependent
position while QCursor::pos provides device-independent position.

Use QWaylandCursor::pos instead.

Pick-to: 6.6 6.5 6.2 5.15
Change-Id: I70d2997610f7a34c6763bd4f10f20a65c3debdbe
Reviewed-by: David Edmundson <davidedmundson@kde.org>
This commit is contained in:
Ilya Fedin 2023-12-03 19:12:03 +04:00
parent d3fd429f82
commit d4220cf486

View File

@ -11,6 +11,7 @@
#include <QtWaylandClient/private/qwaylandwindow_p.h>
#include <QtWaylandClient/private/qwaylandinputdevice_p.h>
#include <QtWaylandClient/private/qwaylandscreen_p.h>
#include <QtWaylandClient/private/qwaylandcursor_p.h>
#include <QtWaylandClient/private/qwaylandabstractdecoration_p.h>
#include <QtGui/QGuiApplication>
@ -235,8 +236,10 @@ QWaylandXdgSurface::Popup::~Popup()
leave = m_xdgSurface->window()->window();
QWindowSystemInterface::handleLeaveEvent(leave);
if (QWindow *enter = QGuiApplication::topLevelAt(QCursor::pos()))
QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
if (QWindow *enter = QGuiApplication::topLevelAt(QCursor::pos())) {
const auto pos = m_xdgSurface->window()->display()->waylandCursor()->pos();
QWindowSystemInterface::handleEnterEvent(enter, enter->handle()->mapFromGlobal(pos), pos);
}
}
}
@ -590,8 +593,10 @@ void QWaylandXdgSurface::setGrabPopup(QWaylandWindow *parent, QWaylandInputDevic
if (m_popup && m_popup->m_xdgSurface && m_popup->m_xdgSurface->window())
enter = m_popup->m_xdgSurface->window()->window();
if (enter)
QWindowSystemInterface::handleEnterEvent(enter, enter->mapFromGlobal(QCursor::pos()), QCursor::pos());
if (enter) {
const auto pos = m_popup->m_xdgSurface->window()->display()->waylandCursor()->pos();
QWindowSystemInterface::handleEnterEvent(enter, enter->handle()->mapFromGlobal(pos), pos);
}
}
void QWaylandXdgSurface::xdg_surface_configure(uint32_t serial)