mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-14 20:25:58 +01:00
7486576fa7
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)
73 lines
1.9 KiB
C++
73 lines
1.9 KiB
C++
#pragma once
|
|
|
|
#include "../defines.hpp"
|
|
#include "../helpers/Timer.hpp"
|
|
#include "../helpers/signal/Signal.hpp"
|
|
#include <cstdint>
|
|
#include <unordered_map>
|
|
#include <unordered_set>
|
|
|
|
class CSessionLockSurface;
|
|
class CSessionLock;
|
|
class CWLSurfaceResource;
|
|
|
|
struct SSessionLockSurface {
|
|
SSessionLockSurface(SP<CSessionLockSurface> surface_);
|
|
|
|
WP<CSessionLockSurface> surface;
|
|
WP<CWLSurfaceResource> pWlrSurface;
|
|
uint64_t iMonitorID = -1;
|
|
|
|
bool mapped = false;
|
|
|
|
struct {
|
|
CHyprSignalListener map;
|
|
CHyprSignalListener destroy;
|
|
CHyprSignalListener commit;
|
|
} listeners;
|
|
};
|
|
|
|
struct SSessionLock {
|
|
WP<CSessionLock> lock;
|
|
|
|
std::vector<std::unique_ptr<SSessionLockSurface>> vSessionLockSurfaces;
|
|
std::unordered_map<uint64_t, CTimer> mMonitorsWithoutMappedSurfaceTimers;
|
|
|
|
struct {
|
|
CHyprSignalListener newSurface;
|
|
CHyprSignalListener unlock;
|
|
CHyprSignalListener destroy;
|
|
} listeners;
|
|
|
|
bool m_hasSentLocked = false;
|
|
std::unordered_set<uint64_t> m_lockedMonitors;
|
|
};
|
|
|
|
class CSessionLockManager {
|
|
public:
|
|
CSessionLockManager();
|
|
~CSessionLockManager() = default;
|
|
|
|
SSessionLockSurface* getSessionLockSurfaceForMonitor(uint64_t);
|
|
|
|
float getRedScreenAlphaForMonitor(uint64_t);
|
|
|
|
bool isSessionLocked();
|
|
bool isSessionLockPresent();
|
|
bool isSurfaceSessionLock(SP<CWLSurfaceResource>);
|
|
|
|
void removeSessionLockSurface(SSessionLockSurface*);
|
|
|
|
void onLockscreenRenderedOnMonitor(uint64_t id);
|
|
|
|
private:
|
|
UP<SSessionLock> m_pSessionLock;
|
|
|
|
struct {
|
|
CHyprSignalListener newLock;
|
|
} listeners;
|
|
|
|
void onNewSessionLock(SP<CSessionLock> pWlrLock);
|
|
};
|
|
|
|
inline std::unique_ptr<CSessionLockManager> g_pSessionLockManager;
|