summaryrefslogtreecommitdiff
path: root/src/managers/SessionLockManager.hpp
blob: 512328678b220bae34b3e22ebc979ee8e5539c27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#pragma once

#include "../defines.hpp"

struct SSessionLockSurface {
    wlr_session_lock_surface_v1* pWlrLockSurface = nullptr;
    int                          iMonitorID      = -1;

    bool                         mapped = false;

    DYNLISTENER(map);
    DYNLISTENER(destroy);
    DYNLISTENER(commit);
};

struct SSessionLock {
    bool                                              active   = false;
    wlr_session_lock_v1*                              pWlrLock = nullptr;

    std::vector<std::unique_ptr<SSessionLockSurface>> vSessionLockSurfaces;

    DYNLISTENER(newSurface);
    DYNLISTENER(unlock);
    DYNLISTENER(destroy);
};

class CSessionLockManager {
  public:
    CSessionLockManager()  = default;
    ~CSessionLockManager() = default;

    void                 onNewSessionLock(wlr_session_lock_v1*);
    SSessionLockSurface* getSessionLockSurfaceForMonitor(const int&);

    bool                 isSessionLocked();
    bool                 isSurfaceSessionLock(wlr_surface*);

    void                 removeSessionLockSurface(SSessionLockSurface*);

    void                 activateLock();

  private:
    SSessionLock m_sSessionLock;
};

inline std::unique_ptr<CSessionLockManager> g_pSessionLockManager;