aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/protocols/ShortcutsInhibit.hpp
blob: ba1c134cd33d485f47fc088e137f21b4743c513b (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 <memory>
#include <vector>
#include <cstdint>
#include "WaylandProtocol.hpp"
#include "keyboard-shortcuts-inhibit-unstable-v1.hpp"

class CWLSurfaceResource;

class CKeyboardShortcutsInhibitor {
  public:
    CKeyboardShortcutsInhibitor(SP<CZwpKeyboardShortcutsInhibitorV1> resource_, SP<CWLSurfaceResource> surf);

    // read-only pointer, may be invalid
    SP<CWLSurfaceResource> surface();
    bool                   good();

  private:
    SP<CZwpKeyboardShortcutsInhibitorV1> resource;
    WP<CWLSurfaceResource>               pSurface;
};

class CKeyboardShortcutsInhibitProtocol : public IWaylandProtocol {
  public:
    CKeyboardShortcutsInhibitProtocol(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);

    bool         isInhibited();

  private:
    void onManagerResourceDestroy(wl_resource* res);
    void destroyInhibitor(CKeyboardShortcutsInhibitor* pointer);
    void onInhibit(CZwpKeyboardShortcutsInhibitManagerV1* pMgr, uint32_t id, wl_resource* surface, wl_resource* seat);

    //
    std::vector<UP<CZwpKeyboardShortcutsInhibitManagerV1>> m_vManagers;
    std::vector<UP<CKeyboardShortcutsInhibitor>>           m_vInhibitors;

    friend class CKeyboardShortcutsInhibitor;
};

namespace PROTO {
    inline UP<CKeyboardShortcutsInhibitProtocol> shortcutsInhibit;
};