2023-02-03 12:58:55 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../defines.hpp"
|
2024-03-15 17:17:13 +01:00
|
|
|
#include "../helpers/Timer.hpp"
|
2024-04-30 17:32:05 +02:00
|
|
|
#include "../helpers/signal/Listener.hpp"
|
2024-03-15 17:17:13 +01:00
|
|
|
#include <cstdint>
|
|
|
|
#include <unordered_map>
|
2023-02-03 12:58:55 +01:00
|
|
|
|
2024-04-30 17:32:05 +02:00
|
|
|
class CSessionLockSurface;
|
|
|
|
class CSessionLock;
|
|
|
|
|
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;
|
|
|
|
wlr_surface* pWlrSurface = nullptr;
|
|
|
|
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;
|
2024-03-15 17:17:13 +01:00
|
|
|
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;
|
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;
|
|
|
|
|
2024-03-15 17:17:13 +01:00
|
|
|
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();
|
2023-02-03 12:58:55 +01:00
|
|
|
bool isSurfaceSessionLock(wlr_surface*);
|
|
|
|
|
|
|
|
void removeSessionLockSurface(SSessionLockSurface*);
|
|
|
|
|
|
|
|
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;
|