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

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

class CPopup;
class CWLSubsurfaceResource;

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

    // real nodes
    CSubsurface(SP<CWLSubsurfaceResource> pSubsurface, PHLWINDOW pOwner);
    CSubsurface(SP<CWLSubsurfaceResource> pSubsurface, CPopup* pOwner);

    ~CSubsurface();

    Vector2D coordsRelativeToParent();
    Vector2D coordsGlobal();

    Vector2D size();

    void     onCommit();
    void     onDestroy();
    void     onNewSubsurface(SP<CWLSubsurfaceResource> pSubsurface);
    void     onMap();
    void     onUnmap();

    bool     visible();

    void     recheckDamageForSubsurfaces();

  private:
    struct {
        CHyprSignalListener destroySubsurface;
        CHyprSignalListener commitSubsurface;
        CHyprSignalListener mapSubsurface;
        CHyprSignalListener unmapSubsurface;
        CHyprSignalListener newSubsurface;
    } listeners;

    WP<CWLSubsurfaceResource> m_pSubsurface;
    SP<CWLSurface>            m_pWLSurface;
    Vector2D                  m_vLastSize = {};

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

    PHLWINDOWREF                 m_pWindowParent;
    CPopup*                      m_pPopupParent = nullptr;

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

    bool                         m_bInert = false;

    void                         initSignals();
    void                         initExistingSubsurfaces(SP<CWLSurfaceResource> pSurface);
    void                         checkSiblingDamage();
};