Hyprland/src/managers/SessionLockManager.hpp

75 lines
2 KiB
C++
Raw Permalink Normal View History

2023-02-03 12:58:55 +01:00
#pragma once
#include "../defines.hpp"
#include "../helpers/Timer.hpp"
#include "../helpers/signal/Signal.hpp"
#include <cstdint>
#include <unordered_map>
#include <unordered_set>
2023-02-03 12:58:55 +01:00
2024-04-30 17:32:05 +02:00
class CSessionLockSurface;
class CSessionLock;
class CWLSurfaceResource;
2024-04-30 17:32:05 +02:00
2023-02-03 12:58:55 +01:00
struct SSessionLockSurface {
2024-04-30 17:32:05 +02:00
SSessionLockSurface(SP<CSessionLockSurface> surface_);
WP<CSessionLockSurface> surface;
WP<CWLSurfaceResource> pWlrSurface;
uint64_t iMonitorID = -1;
2023-02-03 12:58:55 +01:00
2024-04-30 17:32:05 +02:00
bool mapped = false;
2023-02-03 12:58:55 +01:00
2024-04-30 17:32:05 +02:00
struct {
CHyprSignalListener map;
CHyprSignalListener destroy;
CHyprSignalListener commit;
} listeners;
2023-02-03 12:58:55 +01:00
};
struct SSessionLock {
2024-04-30 17:32:05 +02:00
WP<CSessionLock> lock;
2023-02-03 12:58:55 +01:00
std::vector<std::unique_ptr<SSessionLockSurface>> vSessionLockSurfaces;
std::unordered_map<uint64_t, CTimer> mMonitorsWithoutMappedSurfaceTimers;
2023-02-03 12:58:55 +01:00
2024-04-30 17:32:05 +02:00
struct {
CHyprSignalListener newSurface;
CHyprSignalListener unlock;
CHyprSignalListener destroy;
} listeners;
bool m_hasSentLocked = false;
std::unordered_set<uint64_t> m_lockedMonitors;
2023-02-03 12:58:55 +01:00
};
class CSessionLockManager {
public:
2024-04-30 17:32:05 +02:00
CSessionLockManager();
2023-02-03 12:58:55 +01:00
~CSessionLockManager() = default;
SSessionLockSurface* getSessionLockSurfaceForMonitor(uint64_t);
float getRedScreenAlphaForMonitor(uint64_t);
2023-02-03 12:58:55 +01:00
bool isSessionLocked();
2024-04-30 17:32:05 +02:00
bool isSessionLockPresent();
bool isSurfaceSessionLock(SP<CWLSurfaceResource>);
bool anySessionLockSurfacesPresent();
2023-02-03 12:58:55 +01:00
void removeSessionLockSurface(SSessionLockSurface*);
void onLockscreenRenderedOnMonitor(uint64_t id);
2023-02-03 12:58:55 +01:00
private:
2024-04-30 17:32:05 +02:00
UP<SSessionLock> m_pSessionLock;
struct {
CHyprSignalListener newLock;
} listeners;
void onNewSessionLock(SP<CSessionLock> pWlrLock);
2023-02-03 12:58:55 +01:00
};
inline std::unique_ptr<CSessionLockManager> g_pSessionLockManager;