summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp')
-rw-r--r--src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp48
1 files changed, 34 insertions, 14 deletions
diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp
index 4d0cf0c47e..dc98cdce4b 100644
--- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp
+++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmcursor.cpp
@@ -69,7 +69,7 @@ QEglFSKmsGbmCursor::QEglFSKmsGbmCursor(QEglFSKmsGbmScreen *screen)
: m_screen(screen)
, m_cursorSize(64, 64) // 64x64 is the old standard size, we now try to query the real size below
, m_bo(nullptr)
- , m_cursorImage(0, 0, 0, 0, 0, 0)
+ , m_cursorImage(nullptr, nullptr, 0, 0, 0, 0)
, m_state(CursorPendingVisible)
, m_deviceListener(nullptr)
{
@@ -102,7 +102,7 @@ QEglFSKmsGbmCursor::QEglFSKmsGbmCursor(QEglFSKmsGbmScreen *screen)
#ifndef QT_NO_CURSOR
QCursor cursor(Qt::ArrowCursor);
- changeCursor(&cursor, 0);
+ changeCursor(&cursor, nullptr);
#endif
setPos(QPoint(0, 0));
}
@@ -214,7 +214,8 @@ void QEglFSKmsGbmCursor::changeCursor(QCursor *windowCursor, QWindow *window)
Q_FOREACH (QPlatformScreen *screen, m_screen->virtualSiblings()) {
QEglFSKmsScreen *kmsScreen = static_cast<QEglFSKmsScreen *>(screen);
-
+ if (kmsScreen->isCursorOutOfRange())
+ continue;
int status = drmModeSetCursor(kmsScreen->device()->fd(), kmsScreen->output().crtc_id, handle,
m_cursorSize.width(), m_cursorSize.height());
if (status != 0)
@@ -232,17 +233,36 @@ void QEglFSKmsGbmCursor::setPos(const QPoint &pos)
{
Q_FOREACH (QPlatformScreen *screen, m_screen->virtualSiblings()) {
QEglFSKmsScreen *kmsScreen = static_cast<QEglFSKmsScreen *>(screen);
- QPoint origin = kmsScreen->geometry().topLeft();
- QPoint localPos = pos - origin;
- QPoint adjustedPos = localPos - m_cursorImage.hotspot();
-
- int ret = drmModeMoveCursor(kmsScreen->device()->fd(), kmsScreen->output().crtc_id, adjustedPos.x(), adjustedPos.y());
- if (ret == 0)
- m_pos = pos;
- else
- qWarning("Failed to move cursor on screen %s: %d", kmsScreen->name().toLatin1().constData(), ret);
-
- kmsScreen->handleCursorMove(pos);
+ const QRect screenGeom = kmsScreen->geometry();
+ const QPoint origin = screenGeom.topLeft();
+ const QPoint localPos = pos - origin;
+ const QPoint adjustedLocalPos = localPos - m_cursorImage.hotspot();
+
+ if (localPos.x() < 0 || localPos.y() < 0
+ || localPos.x() >= screenGeom.width() || localPos.y() >= screenGeom.height())
+ {
+ if (!kmsScreen->isCursorOutOfRange()) {
+ kmsScreen->setCursorOutOfRange(true);
+ drmModeSetCursor(kmsScreen->device()->fd(), kmsScreen->output().crtc_id, 0, 0, 0);
+ }
+ } else {
+ int ret;
+ if (kmsScreen->isCursorOutOfRange()) {
+ kmsScreen->setCursorOutOfRange(false);
+ uint32_t handle = gbm_bo_get_handle(m_bo).u32;
+ ret = drmModeSetCursor(kmsScreen->device()->fd(), kmsScreen->output().crtc_id,
+ handle, m_cursorSize.width(), m_cursorSize.height());
+ } else {
+ ret = drmModeMoveCursor(kmsScreen->device()->fd(), kmsScreen->output().crtc_id,
+ adjustedLocalPos.x(), adjustedLocalPos.y());
+ }
+ if (ret == 0)
+ m_pos = pos;
+ else
+ qWarning("Failed to move cursor on screen %s: %d", kmsScreen->name().toLatin1().constData(), ret);
+
+ kmsScreen->handleCursorMove(pos);
+ }
}
}