aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/protocols/XWaylandShell.hpp
blob: c8c0c04af2b2617049f59a87ecc0b44383fb494c (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#pragma once

#include <memory>
#include <vector>
#include <cstdint>
#include "WaylandProtocol.hpp"
#include "xwayland-shell-v1.hpp"
#include "../helpers/signal/Signal.hpp"

class CWLSurfaceResource;

class CXWaylandSurfaceResource {
  public:
    CXWaylandSurfaceResource(SP<CXwaylandSurfaceV1> resource_, SP<CWLSurfaceResource> surface_);
    ~CXWaylandSurfaceResource();

    bool       good();
    wl_client* client();

    struct {
        CSignal destroy;
    } events;

    uint64_t                     serial = 0;
    WP<CWLSurfaceResource>       surface;

    WP<CXWaylandSurfaceResource> self;

  private:
    SP<CXwaylandSurfaceV1> resource;
    wl_client*             pClient = nullptr;
};

class CXWaylandShellResource {
  public:
    CXWaylandShellResource(SP<CXwaylandShellV1> resource_);

    bool good();

  private:
    SP<CXwaylandShellV1> resource;
};

class CXWaylandShellProtocol : public IWaylandProtocol {
  public:
    CXWaylandShellProtocol(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 {
        CSignal newSurface; // SP<CXWaylandSurfaceResource>. Fired when it sets a serial, otherwise it's useless
    } events;

  private:
    void destroyResource(CXWaylandSurfaceResource* resource);
    void destroyResource(CXWaylandShellResource* resource);

    //
    std::vector<SP<CXWaylandShellResource>>   m_vManagers;
    std::vector<SP<CXWaylandSurfaceResource>> m_vSurfaces;

    friend class CXWaylandSurfaceResource;
    friend class CXWaylandShellResource;
};

namespace PROTO {
    inline UP<CXWaylandShellProtocol> xwaylandShell;
};