Input: Convert QScreen geometry to native pixels
Low-level input handling uses the native coordinate system and the (device independent) coordinates from QScreen needs to be converted. Change-Id: I501dc77f5e51be01a42e533cd0609e069b8d228b Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com> Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
This commit is contained in:
parent
3510c7324d
commit
6f8a19846b
@ -43,6 +43,7 @@
|
||||
|
||||
#include <qplatformdefs.h>
|
||||
#include <private/qcore_unix_p.h> // overrides QT_OPEN
|
||||
#include <private/qhighdpiscaling_p.h>
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
@ -141,7 +142,8 @@ bool QEvdevMouseHandler::getHardwareMaximum()
|
||||
|
||||
m_hardwareHeight = absInfo.maximum - absInfo.minimum;
|
||||
|
||||
QRect g = QGuiApplication::primaryScreen()->virtualGeometry();
|
||||
QScreen *primaryScreen = QGuiApplication::primaryScreen();
|
||||
QRect g = QHighDpi::toNativePixels(primaryScreen->virtualGeometry(), primaryScreen);
|
||||
m_hardwareScalerX = static_cast<qreal>(m_hardwareWidth) / (g.right() - g.left());
|
||||
m_hardwareScalerY = static_cast<qreal>(m_hardwareHeight) / (g.bottom() - g.top());
|
||||
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include <QtPlatformSupport/private/qdevicediscovery_p.h>
|
||||
#include <private/qguiapplication_p.h>
|
||||
#include <private/qinputdevicemanager_p_p.h>
|
||||
#include <private/qhighdpiscaling_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
@ -106,7 +107,8 @@ QEvdevMouseManager::~QEvdevMouseManager()
|
||||
void QEvdevMouseManager::clampPosition()
|
||||
{
|
||||
// clamp to screen geometry
|
||||
QRect g = QGuiApplication::primaryScreen()->virtualGeometry();
|
||||
QScreen *primaryScreen = QGuiApplication::primaryScreen();
|
||||
QRect g = QHighDpi::toNativePixels(primaryScreen->virtualGeometry(), primaryScreen);
|
||||
if (m_x + m_xoffset < g.left())
|
||||
m_x = g.left() - m_xoffset;
|
||||
else if (m_x + m_xoffset > g.right())
|
||||
|
@ -36,6 +36,7 @@
|
||||
#include <QtGui/QGuiApplication>
|
||||
#include <QtGui/QScreen>
|
||||
#include <qpa/qwindowsysteminterface.h>
|
||||
#include <private/qhighdpiscaling_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
@ -81,7 +82,8 @@ void QLibInputPointer::processMotion(libinput_event_pointer *e)
|
||||
{
|
||||
const double dx = libinput_event_pointer_get_dx(e);
|
||||
const double dy = libinput_event_pointer_get_dy(e);
|
||||
const QRect g = QGuiApplication::primaryScreen()->virtualGeometry();
|
||||
QScreen * const primaryScreen = QGuiApplication::primaryScreen();
|
||||
const QRect g = QHighDpi::toNativePixels(primaryScreen->virtualGeometry(), primaryScreen);
|
||||
|
||||
m_pos.setX(qBound(g.left(), qRound(m_pos.x() + dx), g.right()));
|
||||
m_pos.setY(qBound(g.top(), qRound(m_pos.y() + dy), g.bottom()));
|
||||
@ -110,7 +112,9 @@ void QLibInputPointer::processAxis(libinput_event_pointer *e)
|
||||
|
||||
void QLibInputPointer::setPos(const QPoint &pos)
|
||||
{
|
||||
const QRect g = QGuiApplication::primaryScreen()->virtualGeometry();
|
||||
QScreen * const primaryScreen = QGuiApplication::primaryScreen();
|
||||
const QRect g = QHighDpi::toNativePixels(primaryScreen->virtualGeometry(), primaryScreen);
|
||||
|
||||
m_pos.setX(qBound(g.left(), pos.x(), g.right()));
|
||||
m_pos.setY(qBound(g.top(), pos.y(), g.bottom()));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user