session-lock: send locked after the lock screen is properly rendered (#6850)

The protocol says:
> The locked event "must not be sent until a new "locked" frame (either from a
> session lock surface or the compositor blanking the output) has been presented
> on all outputs and no security sensitive normal/unlocked content is possibly
> visible".

This helps users ensure the screen is properly locked before suspending
the machine. (e.g. with swaylock --ready-fd)
This commit is contained in:
Junxuan Liao
2024-07-13 18:32:08 +08:00
committed by GitHub
parent f85c6416c6
commit 7486576fa7
3 changed files with 23 additions and 3 deletions

View File

@@ -5,6 +5,7 @@
#include "../helpers/signal/Signal.hpp"
#include <cstdint>
#include <unordered_map>
#include <unordered_set>
class CSessionLockSurface;
class CSessionLock;
@@ -37,6 +38,9 @@ struct SSessionLock {
CHyprSignalListener unlock;
CHyprSignalListener destroy;
} listeners;
bool m_hasSentLocked = false;
std::unordered_set<uint64_t> m_lockedMonitors;
};
class CSessionLockManager {
@@ -54,6 +58,8 @@ class CSessionLockManager {
void removeSessionLockSurface(SSessionLockSurface*);
void onLockscreenRenderedOnMonitor(uint64_t id);
private:
UP<SSessionLock> m_pSessionLock;
@@ -64,4 +70,4 @@ class CSessionLockManager {
void onNewSessionLock(SP<CSessionLock> pWlrLock);
};
inline std::unique_ptr<CSessionLockManager> g_pSessionLockManager;
inline std::unique_ptr<CSessionLockManager> g_pSessionLockManager;