aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/protocols/GlobalShortcuts.hpp
blob: 14f6ee0b9ba1e5e8d3c2e2076e3b8f23263c2bce (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
#pragma once
#include "../defines.hpp"
#include "hyprland-global-shortcuts-v1.hpp"
#include "../protocols/WaylandProtocol.hpp"
#include <vector>

struct SShortcut {
    SP<CHyprlandGlobalShortcutV1> resource;
    std::string                   id, description, appid;
    uint32_t                      shortcut = 0;
};

class CShortcutClient {
  public:
    CShortcutClient(SP<CHyprlandGlobalShortcutsManagerV1> resource);

    bool good();

  private:
    SP<CHyprlandGlobalShortcutsManagerV1> resource;
    std::vector<SP<SShortcut>>            shortcuts;

    friend class CGlobalShortcutsProtocol;
};

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

    void                   bindManager(wl_client* client, void* data, uint32_t version, uint32_t id);
    void                   destroyResource(CShortcutClient* client);

    void                   sendGlobalShortcutEvent(std::string appid, std::string trigger, bool pressed);
    bool                   isTaken(std::string id, std::string app_id);
    std::vector<SShortcut> getAllShortcuts();

  private:
    std::vector<SP<CShortcutClient>> m_vClients;
};

namespace PROTO {
    inline UP<CGlobalShortcutsProtocol> globalShortcuts;
};