aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/protocols/XDGOutput.hpp
blob: 6a5be2844d1b898f4da0aba710cf704b6bc809a3 (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
#pragma once

#include "xdg-output-unstable-v1.hpp"
#include "WaylandProtocol.hpp"
#include <optional>

class CMonitor;
class CXDGOutputProtocol;
class CWLOutputProtocol;

class CXDGOutput {
  public:
    CXDGOutput(SP<CZxdgOutputV1> resource, PHLMONITOR monitor_);

    void sendDetails();

  private:
    PHLMONITORREF           monitor;
    SP<CZxdgOutputV1>       resource;
    WP<CWLOutputProtocol>   outputProto;

    std::optional<Vector2D> overridePosition;

    wl_client*              client     = nullptr;
    bool                    isXWayland = false;

    friend class CXDGOutputProtocol;
};

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

  private:
    void onManagerResourceDestroy(wl_resource* res);
    void onOutputResourceDestroy(wl_resource* res);
    void onManagerGetXDGOutput(CZxdgOutputManagerV1* mgr, uint32_t id, wl_resource* outputResource);

    //
    std::vector<UP<CZxdgOutputManagerV1>> m_vManagerResources;
    std::vector<UP<CXDGOutput>>           m_vXDGOutputs;

    friend class CXDGOutput;
};

namespace PROTO {
    inline UP<CXDGOutputProtocol> xdgOutput;
};