From d9c79e36274c3347087c846704c3add03e435c87 Mon Sep 17 00:00:00 2001 From: Erik Kurzinger Date: Tue, 19 Mar 2019 12:46:16 -0700 Subject: [PATCH] [platforms/drm] Fix software cursors with drm backend Summary: If hardware cursor support is not available when using the drm backend for Wayland compositing, the software cursor texture will not be updated when the cursor image changes, and it will still be drawn when no cursor image is set (such as when running a full-screen game). Furthermore, the drmModeSetCursor and drmModeMoveCursor functions will still be unnecessarily called when the cursor is moved or hidden. To correct this, SceneOpenGL should connect Platform::cursorChanged as opposed to Cursor::cursorChanged to its texture update function, as only the former will be emitted when the cursor is updated and the compositor should check if the cursor is hidden and the software cursor image is not null before rendering it. DrmBackend::moveCursor and DrmBackend::hideCursor should also return immediately if using a software cursor. Reviewers: #kwin, davidedmundson Reviewed By: #kwin, davidedmundson Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D18376 --- plugins/platforms/drm/drm_backend.cpp | 4 ++-- plugins/scenes/opengl/scene_opengl.cpp | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/plugins/platforms/drm/drm_backend.cpp b/plugins/platforms/drm/drm_backend.cpp index 34c7c386ac..32b2384294 100644 --- a/plugins/platforms/drm/drm_backend.cpp +++ b/plugins/platforms/drm/drm_backend.cpp @@ -702,7 +702,7 @@ void DrmBackend::doShowCursor() void DrmBackend::doHideCursor() { - if (!m_cursorEnabled) { + if (!m_cursorEnabled || usesSoftwareCursor()) { return; } for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { @@ -712,7 +712,7 @@ void DrmBackend::doHideCursor() void DrmBackend::moveCursor() { - if (!m_cursorEnabled || isCursorHidden()) { + if (!m_cursorEnabled || isCursorHidden() || usesSoftwareCursor()) { return; } for (auto it = m_outputs.constBegin(); it != m_outputs.constEnd(); ++it) { diff --git a/plugins/scenes/opengl/scene_opengl.cpp b/plugins/scenes/opengl/scene_opengl.cpp index ca9e5f06f6..235903d485 100644 --- a/plugins/scenes/opengl/scene_opengl.cpp +++ b/plugins/scenes/opengl/scene_opengl.cpp @@ -596,8 +596,10 @@ void SceneOpenGL::insertWait() **/ void SceneOpenGL2::paintCursor() { - // don't paint if we use hardware cursor - if (!kwinApp()->platform()->usesSoftwareCursor()) { + // don't paint if we use hardware cursor or the cursor is hidden + if (!kwinApp()->platform()->usesSoftwareCursor() || + kwinApp()->platform()->isCursorHidden() || + kwinApp()->platform()->softwareCursor().isNull()) { return; } @@ -616,7 +618,7 @@ void SceneOpenGL2::paintCursor() updateCursorTexture(); // handle shape update on case cursor image changed - connect(Cursor::self(), &Cursor::cursorChanged, this, updateCursorTexture); + connect(kwinApp()->platform(), &Platform::cursorChanged, this, updateCursorTexture); } // get cursor position in projection coordinates