From bbf4f46b280efb24c34df23253f20b195c1f347c Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Sun, 19 May 2024 02:23:06 +0200 Subject: [PATCH] compositor_wayland: properly handle moving the cursor plane failing On test failure, the plane has to be disabled or future atomic tests fail BUG: 487037 --- src/compositor_wayland.cpp | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/src/compositor_wayland.cpp b/src/compositor_wayland.cpp index 9e06aeeaa2..de7d7ed5d3 100644 --- a/src/compositor_wayland.cpp +++ b/src/compositor_wayland.cpp @@ -450,18 +450,32 @@ void WaylandCompositor::addOutput(Output *output) const QRectF outputLocalRect = output->mapFromGlobal(cursor->geometry()); const auto outputLayer = m_backend->cursorLayer(output); bool hardwareCursor = false; - if (outputLayer) { - if (outputLayer->isEnabled()) { - const QRectF nativeCursorRect = output->transform() - .map(QRectF(outputLocalRect.topLeft() * output->scale(), outputLayer->targetRect().size()), output->pixelSize()); - outputLayer->setTargetRect(QRect(nativeCursorRect.topLeft().toPoint(), outputLayer->targetRect().size())); - hardwareCursor = output->updateCursorLayer(); - } else if (!cursorLayer->isVisible() && !forceSoftwareCursor) { - // this is for the case that the cursor wasn't visible because it was on a different output before - hardwareCursor = updateCursorLayer(); + const bool shouldBeVisible = cursor->isOnOutput(output); + if (outputLayer && !forceSoftwareCursor) { + if (shouldBeVisible) { + const bool enabledBefore = outputLayer->isEnabled(); + if (enabledBefore) { + // just move it + const QRectF nativeCursorRect = output->transform().map(QRectF(outputLocalRect.topLeft() * output->scale(), outputLayer->targetRect().size()), output->pixelSize()); + outputLayer->setTargetRect(QRect(nativeCursorRect.topLeft().toPoint(), outputLayer->targetRect().size())); + outputLayer->setEnabled(true); + hardwareCursor = output->updateCursorLayer(); + if (!hardwareCursor) { + outputLayer->setEnabled(false); + if (enabledBefore) { + output->updateCursorLayer(); + } + } + } else { + // do the full update + hardwareCursor = updateCursorLayer(); + } + } else if (outputLayer->isEnabled()) { + outputLayer->setEnabled(false); + output->updateCursorLayer(); } } - cursorLayer->setVisible(cursor->isOnOutput(output) && !hardwareCursor); + cursorLayer->setVisible(shouldBeVisible && !hardwareCursor); cursorLayer->setGeometry(outputLocalRect); cursorLayer->addRepaintFull(); };