aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/protocols/CursorShape.hpp
blob: 9fcca28de27b5d8c7c440c03f8b8a9478c845554 (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
#pragma once

#include <memory>
#include <unordered_map>
#include "WaylandProtocol.hpp"
#include "../helpers/signal/Signal.hpp"
#include "cursor-shape-v1.hpp"

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

    struct SSetShapeEvent {
        CWpCursorShapeDeviceV1*    pMgr = nullptr;
        wpCursorShapeDeviceV1Shape shape;
        std::string                shapeName;
    };

    struct {
        CSignal setShape;
    } events;

  private:
    void onManagerResourceDestroy(wl_resource* res);
    void onDeviceResourceDestroy(wl_resource* res);

    void onGetPointer(CWpCursorShapeManagerV1* pMgr, uint32_t id, wl_resource* pointer);
    void onGetTabletToolV2(CWpCursorShapeManagerV1* pMgr, uint32_t id, wl_resource* tablet);

    void onSetShape(CWpCursorShapeDeviceV1* pMgr, uint32_t serial, wpCursorShapeDeviceV1Shape shape);
    void createCursorShapeDevice(CWpCursorShapeManagerV1* pMgr, uint32_t id, wl_resource* resource);

    //
    std::vector<SP<CWpCursorShapeDeviceV1>>  m_vDevices;
    std::vector<UP<CWpCursorShapeManagerV1>> m_vManagers;
};

namespace PROTO {
    inline UP<CCursorShapeProtocol> cursorShape;
};