From 0b529c668230ff36269c3a4c6b62c57a725af497 Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Wed, 28 Feb 2024 21:41:30 -0800 Subject: [PATCH] fix(slock): make SessionLock.secure accurate --- src/wayland/session_lock.cpp | 7 +++++-- src/wayland/session_lock/manager.cpp | 3 +++ src/wayland/session_lock/manager.hpp | 1 + src/wayland/session_lock/session_lock.cpp | 1 + src/wayland/session_lock/session_lock.hpp | 1 + 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/wayland/session_lock.cpp b/src/wayland/session_lock.cpp index be8136f9..a466e4d6 100644 --- a/src/wayland/session_lock.cpp +++ b/src/wayland/session_lock.cpp @@ -89,7 +89,10 @@ void SessionLock::updateSurfaces(SessionLock* old) { instance->onReload(oldInstance); this->surfaces[screen] = instance; - instance->show(); + } + + for (auto* surface: this->surfaces.values()) { + surface->show(); } } } @@ -117,7 +120,7 @@ bool SessionLock::isLocked() const { } bool SessionLock::isSecure() const { - return this->manager != nullptr && SessionLockManager::sessionLocked(); + return this->manager != nullptr && SessionLockManager::isSecure(); } void SessionLock::setLocked(bool locked) { diff --git a/src/wayland/session_lock/manager.cpp b/src/wayland/session_lock/manager.cpp index db6852bc..dc186601 100644 --- a/src/wayland/session_lock/manager.cpp +++ b/src/wayland/session_lock/manager.cpp @@ -18,3 +18,6 @@ QSWaylandSessionLock* QSWaylandSessionLockManager::acquireLock() { } bool QSWaylandSessionLockManager::isLocked() const { return this->active != nullptr; } +bool QSWaylandSessionLockManager::isSecure() const { + return this->isLocked() && this->active->hasCompositorLock(); +} diff --git a/src/wayland/session_lock/manager.hpp b/src/wayland/session_lock/manager.hpp index 8c36aa5e..6a21a3ce 100644 --- a/src/wayland/session_lock/manager.hpp +++ b/src/wayland/session_lock/manager.hpp @@ -17,6 +17,7 @@ public: // Create a new session lock if there is no currently active lock, otherwise null. QSWaylandSessionLock* acquireLock(); [[nodiscard]] bool isLocked() const; + [[nodiscard]] bool isSecure() const; static bool sessionLocked(); diff --git a/src/wayland/session_lock/session_lock.cpp b/src/wayland/session_lock/session_lock.cpp index 65ceef68..dc08d7d1 100644 --- a/src/wayland/session_lock/session_lock.cpp +++ b/src/wayland/session_lock/session_lock.cpp @@ -44,6 +44,7 @@ bool SessionLockManager::unlock() { bool SessionLockManager::isLocked() const { return this->mLock != nullptr; } bool SessionLockManager::sessionLocked() { return manager()->isLocked(); } +bool SessionLockManager::isSecure() { return manager()->isSecure(); } LockWindowExtension::~LockWindowExtension() { if (this->surface != nullptr) { diff --git a/src/wayland/session_lock/session_lock.hpp b/src/wayland/session_lock/session_lock.hpp index 45e86d6d..7e3968bd 100644 --- a/src/wayland/session_lock/session_lock.hpp +++ b/src/wayland/session_lock/session_lock.hpp @@ -26,6 +26,7 @@ public: [[nodiscard]] bool isLocked() const; static bool sessionLocked(); + static bool isSecure(); signals: // This signal is sent once the compositor considers the session to be fully locked.