summaryrefslogtreecommitdiff
path: root/src/desktop/Subsurface.hpp
blob: ca02a6d53056d2306bd277539951a570dd4bdb51 (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
#pragma once

#include "../defines.hpp"
#include <vector>
#include "WLSurface.hpp"

class CWindow;
class CPopup;

class CSubsurface {
  public:
    // root dummy nodes
    CSubsurface(CWindow* pOwner);
    CSubsurface(CPopup* pOwner);

    // real nodes
    CSubsurface(wlr_subsurface* pSubsurface, CWindow* pOwner);
    CSubsurface(wlr_subsurface* pSubsurface, CPopup* pOwner);

    ~CSubsurface();

    Vector2D coordsRelativeToParent();
    Vector2D coordsGlobal();

    Vector2D size();

    void     onCommit();
    void     onDestroy();
    void     onNewSubsurface(wlr_subsurface* pSubsurface);
    void     onMap();
    void     onUnmap();

    void     recheckDamageForSubsurfaces();

  private:
    DYNLISTENER(destroySubsurface);
    DYNLISTENER(commitSubsurface);
    DYNLISTENER(newSubsurface);
    DYNLISTENER(mapSubsurface);
    DYNLISTENER(unmapSubsurface);

    wlr_subsurface* m_pSubsurface = nullptr;
    CWLSurface      m_sWLSurface;
    Vector2D        m_vLastSize = {};

    // if nullptr, means it's a dummy node
    CSubsurface*                              m_pParent = nullptr;

    CWindow*                                  m_pWindowParent = nullptr;
    CPopup*                                   m_pPopupParent  = nullptr;

    std::vector<std::unique_ptr<CSubsurface>> m_vChildren;

    bool                                      m_bInert = false;

    void                                      initSignals();
    void                                      initExistingSubsurfaces();
    void                                      checkSiblingDamage();
};