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-06-11 17:17:45 +02:00
|
|
|
#include "../helpers/signal/Signal.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;
|
2024-06-08 10:07:59 +02:00
|
|
|
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;
|
2024-06-08 10:07:59 +02:00
|
|
|
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;
|
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();
|
2024-06-08 10:07:59 +02:00
|
|
|
bool isSurfaceSessionLock(SP<CWLSurfaceResource>);
|
2023-02-03 12:58:55 +01:00
|
|
|
|
|
|
|
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;
|