From d8c42ec540ed8496340800ac1e9ad6c5bf00ef6b Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Fri, 25 Nov 2022 00:27:01 +0200 Subject: [PATCH] backends/wayland: Simplify pointer locking At the moment, once the first output gets pointer locked, other outputs release their locks. It's unnecessary, other outputs can keep their locks. --- src/backends/wayland/wayland_backend.h | 1 - src/backends/wayland/wayland_output.cpp | 20 +++----------------- 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/src/backends/wayland/wayland_backend.h b/src/backends/wayland/wayland_backend.h index 2f15db4b3c..9f24f18fab 100644 --- a/src/backends/wayland/wayland_backend.h +++ b/src/backends/wayland/wayland_backend.h @@ -288,7 +288,6 @@ public: } Q_SIGNALS: - void pointerLockSupportedChanged(); void pointerLockChanged(bool locked); private: diff --git a/src/backends/wayland/wayland_output.cpp b/src/backends/wayland/wayland_output.cpp index 7d841898e0..c4cb55bce9 100644 --- a/src/backends/wayland/wayland_output.cpp +++ b/src/backends/wayland/wayland_output.cpp @@ -62,23 +62,6 @@ WaylandOutput::WaylandOutput(const QString &name, WaylandBackend *backend) connect(m_xdgShellSurface.get(), &XdgShellSurface::closeRequested, qApp, &QCoreApplication::quit); connect(this, &WaylandOutput::enabledChanged, this, &WaylandOutput::updateWindowTitle); connect(this, &WaylandOutput::dpmsModeChanged, this, &WaylandOutput::updateWindowTitle); - - connect(backend, &WaylandBackend::pointerLockSupportedChanged, this, &WaylandOutput::updateWindowTitle); - connect(backend, &WaylandBackend::pointerLockChanged, this, [this](bool locked) { - if (locked) { - if (!m_hasPointerLock) { - // some other output has locked the pointer - // this surface can stop trying to lock the pointer - lockPointer(nullptr, false); - // set it true for the other surface - m_hasPointerLock = true; - } - } else { - // just try unlocking - lockPointer(nullptr, false); - } - updateWindowTitle(); - }); } WaylandOutput::~WaylandOutput() @@ -205,6 +188,7 @@ void WaylandOutput::lockPointer(Pointer *pointer, bool lock) m_pointerLock.reset(); m_hasPointerLock = false; if (surfaceWasLocked) { + updateWindowTitle(); Q_EMIT m_backend->pointerLockChanged(false); } return; @@ -218,11 +202,13 @@ void WaylandOutput::lockPointer(Pointer *pointer, bool lock) } connect(m_pointerLock.get(), &LockedPointer::locked, this, [this]() { m_hasPointerLock = true; + updateWindowTitle(); Q_EMIT m_backend->pointerLockChanged(true); }); connect(m_pointerLock.get(), &LockedPointer::unlocked, this, [this]() { m_pointerLock.reset(); m_hasPointerLock = false; + updateWindowTitle(); Q_EMIT m_backend->pointerLockChanged(false); }); }