Details
-
Bug
-
Resolution: Incomplete
-
P2: Important
-
None
-
5.15.0
-
None
Description
As we know the QCursor::pos is transformed by QPlatformCursor::pos() like this
QPoint QCursor::pos(const QScreen *screen)
{
if (screen) {
if (const QPlatformCursor *cursor = screen->handle()->cursor())Unknown macro: { const QPlatformScreen *ps = screen->handle(); QPoint nativePos = cursor->pos(); ps = ps->screenForPosition(nativePos); return QHighDpi}}
return QGuiApplicationPrivate::lastCursorPosition.toPoint();
}
In QtWayland the QWaylandCursor::pointerEvent effect QWaylandCursor::pos
void QWaylandCursor::pointerEvent(const QMouseEvent &event)
Unknown macro: { mLastPos = event.globalPos(); }
QPoint QWaylandCursor::pos() const
Unknown macro: { return mLastPos; }
The QWaylandCursor::pointerEvent is Used in QGuiApplicationPrivate::processMouseEvent
void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *e)
{
......
#ifndef QT_NO_CURSOR
if (!e->synthetic()) {
if (const QScreen *screen = window->screen())
if (QPlatformCursor *cursor = screen->handle()->cursor())Unknown macro: { const QPointF nativeLocalPoint = QHighDpi}}
#endif
......
}
Based on the following conditions :
1. multiple screen
2. The window is displayed between two screens
3. The window's scale ratio is 1.5(QT_SCALE_FACTOR=1.5 or QPlatformScreen::logicDpi = 144)
4. The mouse pointer is on window and in second screen
5. Suppose the physical size of the two screens is 1920*1080
Based on the above conditions to calculate QCursor::pos :
1. QGuiApplicationPrivate::processMouseEvent e->globalPos = (1500, 200)
2. const QPointF nativeGlobalPoint = QHighDpi::toNativePixels(globalPoint, screen) = (2250, 300)
3. cursor->pointerEvent(ev) -> QWaylandCursor::pos = (2250, 150)
4. QWaylandCursor::pos = (2250, 150) -> QCursor::pos = (2140, 150)
Calculation error in the second step, becase of toNativePixels's calculation methods.