Handle errors with drmModeSetCursor instead of silently failing

Summary:
Make sure we switch to a software cursor when drmModeSetCursor
fails.

Reviewers: #kwin, graesslin

Subscribers: davidedmundson, bshah, graesslin, kwin, #kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D12447
This commit is contained in:
Rohan Garg 2018-04-22 15:17:53 +02:00
parent 01ed1d84b9
commit 757ed91a5d
3 changed files with 21 additions and 11 deletions

View file

@ -624,7 +624,9 @@ void DrmBackend::initCursor()
}
for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) {
if (m_cursorEnabled) {
(*it)->showCursor();
if (!(*it)->showCursor()) {
setSoftWareCursor(true);
}
} else {
(*it)->hideCursor();
}
@ -653,7 +655,9 @@ void DrmBackend::setCursor()
{
if (m_cursorEnabled) {
for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) {
(*it)->showCursor();
if (!(*it)->showCursor()) {
setSoftWareCursor(true);
}
}
}
markCursorAsRendered();

View file

@ -96,24 +96,30 @@ void DrmOutput::releaseGbm()
}
}
void DrmOutput::hideCursor()
bool DrmOutput::hideCursor()
{
drmModeSetCursor(m_backend->fd(), m_crtc->id(), 0, 0, 0);
return drmModeSetCursor(m_backend->fd(), m_crtc->id(), 0, 0, 0) == 0;
}
void DrmOutput::showCursor(DrmDumbBuffer *c)
bool DrmOutput::showCursor(DrmDumbBuffer *c)
{
const QSize &s = c->size();
drmModeSetCursor(m_backend->fd(), m_crtc->id(), c->handle(), s.width(), s.height());
return drmModeSetCursor(m_backend->fd(), m_crtc->id(), c->handle(), s.width(), s.height()) == 0;
}
void DrmOutput::showCursor()
bool DrmOutput::showCursor()
{
showCursor(m_cursor[m_cursorIndex]);
const bool ret = showCursor(m_cursor[m_cursorIndex]);
if (!ret) {
return ret;
}
if (m_hasNewCursor) {
m_cursorIndex = (m_cursorIndex + 1) % 2;
m_hasNewCursor = false;
}
return ret;
}
void DrmOutput::updateCursor()

View file

@ -66,9 +66,9 @@ public:
};
virtual ~DrmOutput();
void releaseGbm();
void showCursor(DrmDumbBuffer *buffer);
void showCursor();
void hideCursor();
bool showCursor(DrmDumbBuffer *buffer);
bool showCursor();
bool hideCursor();
void updateCursor();
void moveCursor(const QPoint &globalPos);
bool init(drmModeConnector *connector);