diff --git a/plugins/platforms/drm/drm_backend.h b/plugins/platforms/drm/drm_backend.h --- a/plugins/platforms/drm/drm_backend.h +++ b/plugins/platforms/drm/drm_backend.h @@ -122,6 +122,7 @@ int m_drmId = 0; QVector m_outputs; DrmBuffer *m_cursor[2]; + bool m_cursorEnabled = false; int m_cursorIndex = 0; int m_pageFlipsPending = 0; bool m_active = false; diff --git a/plugins/platforms/drm/drm_backend.cpp b/plugins/platforms/drm/drm_backend.cpp --- a/plugins/platforms/drm/drm_backend.cpp +++ b/plugins/platforms/drm/drm_backend.cpp @@ -32,6 +32,7 @@ #include "egl_gbm_backend.h" #endif // KWayland +#include #include // KF5 #include @@ -467,6 +468,19 @@ void DrmBackend::initCursor() { + m_cursorEnabled = waylandServer()->seat()->hasPointer(); + connect(waylandServer()->seat(), &KWayland::Server::SeatInterface::hasPointerChanged, this, + [this] { + m_cursorEnabled = waylandServer()->seat()->hasPointer(); + for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { + if (m_cursorEnabled) { + (*it)->showCursor(m_cursor[m_cursorIndex]); + } else { + (*it)->hideCursor(); + } + } + } + ); uint64_t capability = 0; QSize cursorSize; if (drmGetCap(m_fd, DRM_CAP_CURSOR_WIDTH, &capability) == 0) { @@ -494,8 +508,10 @@ { DrmBuffer *c = m_cursor[m_cursorIndex]; m_cursorIndex = (m_cursorIndex + 1) % 2; - for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { - (*it)->showCursor(c); + if (m_cursorEnabled) { + for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { + (*it)->showCursor(c); + } } markCursorAsRendered(); } @@ -520,14 +536,20 @@ void DrmBackend::hideCursor() { + if (!m_cursorEnabled) { + return; + } for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { (*it)->hideCursor(); } } void DrmBackend::moveCursor() { const QPoint p = Cursor::pos() - softwareCursorHotspot(); + if (!m_cursorEnabled) { + return; + } for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { (*it)->moveCursor(p); }