mirror of
https://github.com/KDE/krfb
synced 2026-07-01 07:31:16 -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
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user