[platforms/drm] Only show cursor if a pointer device is available
Summary: When the pointer device gets plugged off the cursor is hidden, when a pointer device gets plugged in the cursor is shown again. This allows to easily turn a tablet into a proper system by showing the cursor only when it makes sense. Test Plan: Tested on exopc with external mouse Reviewers: #plasma Subscribers: plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D1682
This commit is contained in:
parent
6f733c3bd0
commit
b5b2adc5a2
2 changed files with 25 additions and 2 deletions
|
@ -32,6 +32,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "egl_gbm_backend.h"
|
||||
#endif
|
||||
// KWayland
|
||||
#include <KWayland/Server/seat_interface.h>
|
||||
#include <KWayland/Server/outputconfiguration_interface.h>
|
||||
// KF5
|
||||
#include <KConfigGroup>
|
||||
|
@ -467,6 +468,19 @@ void DrmBackend::present(DrmBuffer *buffer, DrmOutput *output)
|
|||
|
||||
void DrmBackend::initCursor()
|
||||
{
|
||||
m_cursorEnabled = waylandServer()->seat()->hasPointer();
|
||||
connect(waylandServer()->seat(), &KWayland::Server::SeatInterface::hasPointerChanged, this,
|
||||
[this] {
|
||||
m_cursorEnabled = waylandServer()->seat()->hasPointer();
|
||||
for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) {
|
||||
if (m_cursorEnabled) {
|
||||
(*it)->showCursor(m_cursor[m_cursorIndex]);
|
||||
} else {
|
||||
(*it)->hideCursor();
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
uint64_t capability = 0;
|
||||
QSize cursorSize;
|
||||
if (drmGetCap(m_fd, DRM_CAP_CURSOR_WIDTH, &capability) == 0) {
|
||||
|
@ -494,8 +508,10 @@ void DrmBackend::setCursor()
|
|||
{
|
||||
DrmBuffer *c = m_cursor[m_cursorIndex];
|
||||
m_cursorIndex = (m_cursorIndex + 1) % 2;
|
||||
for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) {
|
||||
(*it)->showCursor(c);
|
||||
if (m_cursorEnabled) {
|
||||
for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) {
|
||||
(*it)->showCursor(c);
|
||||
}
|
||||
}
|
||||
markCursorAsRendered();
|
||||
}
|
||||
|
@ -520,6 +536,9 @@ void DrmBackend::updateCursor()
|
|||
|
||||
void DrmBackend::hideCursor()
|
||||
{
|
||||
if (!m_cursorEnabled) {
|
||||
return;
|
||||
}
|
||||
for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) {
|
||||
(*it)->hideCursor();
|
||||
}
|
||||
|
@ -528,6 +547,9 @@ void DrmBackend::hideCursor()
|
|||
void DrmBackend::moveCursor()
|
||||
{
|
||||
const QPoint p = Cursor::pos() - softwareCursorHotspot();
|
||||
if (!m_cursorEnabled) {
|
||||
return;
|
||||
}
|
||||
for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) {
|
||||
(*it)->moveCursor(p);
|
||||
}
|
||||
|
|
|
@ -122,6 +122,7 @@ private:
|
|||
int m_drmId = 0;
|
||||
QVector<DrmOutput*> m_outputs;
|
||||
DrmBuffer *m_cursor[2];
|
||||
bool m_cursorEnabled = false;
|
||||
int m_cursorIndex = 0;
|
||||
int m_pageFlipsPending = 0;
|
||||
bool m_active = false;
|
||||
|
|
Loading…
Reference in a new issue