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.
This commit is contained in:
Vlad Zahorodnii 2020-10-27 11:40:38 +02:00
parent 170a0b6395
commit b53d195f34
3 changed files with 17 additions and 28 deletions

View file

@ -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;
}
if (waylandServer()->seat()->hasPointer()) {
showCursor();
} else {
(*it)->hideCursor();
}
hideCursor();
}
}
);
@ -537,13 +533,11 @@ 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);
}
}
}
}
void DrmBackend::updateCursor()
@ -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) {

View file

@ -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<DrmOutput*> m_enabledOutputs;
bool m_cursorEnabled = false;
int m_pageFlipsPending = 0;
bool m_active = false;
QVector<DrmGpu*> m_gpus;

View file

@ -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();