summaryrefslogtreecommitdiff
path: root/src/protocols/LockNotify.hpp
blob: ec71034b01663a481e6f1954fa22f7bc0a5f8dc5 (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
47
48
49
50
#pragma once

#include <memory>
#include <vector>
#include <unordered_map>
#include "WaylandProtocol.hpp"
#include "hyprland-lock-notify-v1.hpp"

class CEventLoopTimer;

class CHyprlandLockNotification {
  public:
    CHyprlandLockNotification(SP<CHyprlandLockNotificationV1> resource_);
    ~CHyprlandLockNotification() = default;

    bool good();
    void onLocked();
    void onUnlocked();

  private:
    SP<CHyprlandLockNotificationV1> m_resource;
    bool                            m_locked = false;
};

class CLockNotifyProtocol : public IWaylandProtocol {
  public:
    CLockNotifyProtocol(const wl_interface* iface, const int& ver, const std::string& name);

    virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id);

    void         onLocked();
    void         onUnlocked();

  private:
    void onManagerResourceDestroy(wl_resource* res);
    void destroyNotification(CHyprlandLockNotification* notif);
    void onGetNotification(CHyprlandLockNotifierV1* pMgr, uint32_t id);

    bool m_isLocked = false;

    //
    std::vector<UP<CHyprlandLockNotifierV1>>   m_managers;
    std::vector<SP<CHyprlandLockNotification>> m_notifications;

    friend class CHyprlandLockNotification;
};

namespace PROTO {
    inline UP<CLockNotifyProtocol> lockNotify;
};