1
0
mirror of https://github.com/KDE/krfb synced 2026-07-01 07:41:17 -07:00

Fix incorrect cursor position under display scaling

Issue:
When running Krfb on a computer with display scaling, the remote cursor position shown in the VNC client is incorrect.

Change:
Multiply the remote cursor position by devicePixelRatio.

BUG: 466276

(cherry picked from commit 6379e0169d)
This commit is contained in:
Wendi Gan
2025-04-29 01:25:16 +08:00
committed by Alexey Minnekhanov
parent 25b55caac8
commit 6653960849

View File

@@ -8,6 +8,8 @@
#include <config-krfb.h>
#include <QCursor>
#include <QGuiApplication>
#include <QScreen>
FrameBuffer::FrameBuffer(QObject *parent)
@@ -72,5 +74,14 @@ void FrameBuffer::stopMonitor()
QPoint FrameBuffer::cursorPosition()
{
return QCursor::pos();
QPoint cursorPos = QCursor::pos();
QScreen *primaryScreen = QGuiApplication::primaryScreen();
if (primaryScreen) {
qreal scaleFactor = primaryScreen->devicePixelRatio();
cursorPos.setX(qRound(cursorPos.x() * scaleFactor));
cursorPos.setY(qRound(cursorPos.y() * scaleFactor));
} else {
qWarning() << "cursorPosition: ERROR: Failed to get application's primary screen info!";
}
return cursorPos;
}