Commit b53d195f authored by Vlad Zahorodnii's avatar Vlad Zahorodnii

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.
parent 170a0b63
......@@ -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) {
......
......@@ -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;
......
......@@ -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();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment