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

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

class CPopup;
class CWLSubsurfaceResource;

class CSubsurface {
  public:
    // root dummy nodes
    static UP<CSubsurface> create(PHLWINDOW pOwner);
    static UP<CSubsurface> create(WP<CPopup> pOwner);

    // real nodes
    static UP<CSubsurface> create(SP<CWLSubsurfaceResource> pSubsurface, PHLWINDOW pOwner);
    static UP<CSubsurface> create(SP<CWLSubsurfaceResource> pSubsurface, WP<CPopup> pOwner);

    ~CSubsurface() = default;

    Vector2D        coordsRelativeToParent();
    Vector2D        coordsGlobal();

    Vector2D        size();

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

    bool            visible();

    void            recheckDamageForSubsurfaces();

    WP<CSubsurface> m_self;

  private:
    CSubsurface() = default;

    struct {
        CHyprSignalListener destroySubsurface;
        CHyprSignalListener commitSubsurface;
        CHyprSignalListener mapSubsurface;
        CHyprSignalListener unmapSubsurface;
        CHyprSignalListener newSubsurface;
    } m_listeners;

    WP<CWLSubsurfaceResource> m_subsurface;
    SP<CWLSurface>            m_wlSurface;
    Vector2D                  m_lastSize     = {};
    Vector2D                  m_lastPosition = {};

    // if nullptr, means it's a dummy node
    WP<CSubsurface>              m_parent;

    PHLWINDOWREF                 m_windowParent;
    WP<CPopup>                   m_popupParent;

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

    bool                         m_inert = false;

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