From b53d195f34b22ac9d7ecbad3c30a0cb30ddf3852 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Tue, 27 Oct 2020 11:40:38 +0200 Subject: [PATCH] platforms/drm: Hide sw cursor if there is no pointer Currently, if there is no pointer, only the hardware cursor will be hidden. If the software cursor is forced, you are going to see a dead immovable cursor. --- plugins/platforms/drm/drm_backend.cpp | 36 +++++++++++---------------- plugins/platforms/drm/drm_backend.h | 5 ---- plugins/platforms/drm/drm_output.cpp | 4 +-- 3 files changed, 17 insertions(+), 28 deletions(-) diff --git a/plugins/platforms/drm/drm_backend.cpp b/plugins/platforms/drm/drm_backend.cpp index fc32b9bc32..efb214961f 100644 --- a/plugins/platforms/drm/drm_backend.cpp +++ b/plugins/platforms/drm/drm_backend.cpp @@ -511,22 +511,18 @@ void DrmBackend::initCursor() setSoftWareCursor(needsSoftwareCursor); #endif - m_cursorEnabled = waylandServer()->seat()->hasPointer(); + if (waylandServer()->seat()->hasPointer()) { + // The cursor is visible by default, do nothing. + } else { + hideCursor(); + } + connect(waylandServer()->seat(), &KWaylandServer::SeatInterface::hasPointerChanged, this, [this] { - m_cursorEnabled = waylandServer()->seat()->hasPointer(); - if (usesSoftwareCursor()) { - return; - } - for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { - if (m_cursorEnabled) { - if (!(*it)->showCursor()) { - setSoftWareCursor(true); - break; - } - } else { - (*it)->hideCursor(); - } + if (waylandServer()->seat()->hasPointer()) { + showCursor(); + } else { + hideCursor(); } } ); @@ -537,11 +533,9 @@ void DrmBackend::initCursor() void DrmBackend::setCursor() { - if (m_cursorEnabled) { - for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { - if (!(*it)->showCursor()) { - setSoftWareCursor(true); - } + for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { + if (!(*it)->showCursor()) { + setSoftWareCursor(true); } } } @@ -577,7 +571,7 @@ void DrmBackend::doShowCursor() void DrmBackend::doHideCursor() { - if (!m_cursorEnabled || usesSoftwareCursor()) { + if (usesSoftwareCursor()) { return; } for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { @@ -587,7 +581,7 @@ void DrmBackend::doHideCursor() void DrmBackend::moveCursor(Cursor *cursor, const QPoint &pos) { - if (!m_cursorEnabled || isCursorHidden() || usesSoftwareCursor()) { + if (isCursorHidden() || usesSoftwareCursor()) { return; } for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { diff --git a/plugins/platforms/drm/drm_backend.h b/plugins/platforms/drm/drm_backend.h index 2c5368833e..a659b872b8 100644 --- a/plugins/platforms/drm/drm_backend.h +++ b/plugins/platforms/drm/drm_backend.h @@ -82,10 +82,6 @@ public: QString supportInformation() const override; - bool isCursorEnabled() const { - return m_cursorEnabled; - }; - public Q_SLOTS: void turnOutputsOn(); @@ -119,7 +115,6 @@ private: // active and enabled pipelines (above + wl_output) QVector m_enabledOutputs; - bool m_cursorEnabled = false; int m_pageFlipsPending = 0; bool m_active = false; QVector m_gpus; diff --git a/plugins/platforms/drm/drm_output.cpp b/plugins/platforms/drm/drm_output.cpp index 9d2e50d5d7..4d5ee4fe8b 100644 --- a/plugins/platforms/drm/drm_output.cpp +++ b/plugins/platforms/drm/drm_output.cpp @@ -649,7 +649,7 @@ void DrmOutput::updateTransform(Transform transform) m_modesetRequested = true; // show cursor only if is enabled, i.e if pointer device is presentP - if (m_backend->isCursorEnabled() && !m_backend->usesSoftwareCursor()) { + if (!m_backend->isCursorHidden() && !m_backend->usesSoftwareCursor()) { // the cursor might need to get rotated updateCursor(); showCursor(); @@ -809,7 +809,7 @@ bool DrmOutput::presentAtomically(DrmBuffer *buffer) m_primaryPlane->setTransformation(m_lastWorkingState.planeTransformations); } m_modesetRequested = true; - if (m_backend->isCursorEnabled()) { + if (!m_backend->isCursorHidden()) { // the cursor might need to get rotated updateCursor(); showCursor();