Hyprland/src/managers/SessionLockManager.hpp

67 lines
1.7 KiB
C++
Raw Normal View History

2023-02-03 12:58:55 +01:00
#pragma once
#include "../defines.hpp"
#include "../helpers/Timer.hpp"
2024-04-30 17:32:05 +02:00
#include "../helpers/signal/Listener.hpp"
#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;
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;
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>);
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;