aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/helpers/SubsurfaceTree.hpp
blob: d6f04a5822c5f08d6e118d5e186db2aa1fb94430 (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
#pragma once

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

struct SSubsurface;
class CWindow;

typedef void (*applyGlobalOffsetFn)(void*, int*, int*);

struct SSurfaceTreeNode {
    CWLSurface* pSurface = nullptr; // actual surface
    CWLSurface  pInternalSurface;   // not present for head nodes to not dupe wlr_surface ownership

    DYNLISTENER(newSubsurface);
    DYNLISTENER(commit);
    DYNLISTENER(destroy);

    SSurfaceTreeNode*      pParent     = nullptr;
    SSubsurface*           pSubsurface = nullptr;

    std::list<SSubsurface> childSubsurfaces;

    applyGlobalOffsetFn    offsetfn;
    void*                  globalOffsetData;
    CWindow*               pWindowOwner = nullptr;

    //
    bool operator==(const SSurfaceTreeNode& rhs) const {
        return pSurface == rhs.pSurface;
    }
};

struct SSubsurface {
    wlr_subsurface*   pSubsurface = nullptr;

    SSurfaceTreeNode* pParent = nullptr;
    SSurfaceTreeNode* pChild  = nullptr;

    DYNLISTENER(map);
    DYNLISTENER(unmap);
    DYNLISTENER(destroy);

    CWindow* pWindowOwner = nullptr;

    //
    bool operator==(const SSubsurface& rhs) const {
        return pSubsurface == rhs.pSubsurface;
    }
};

namespace SubsurfaceTree {
    SSurfaceTreeNode*                  createTreeRoot(wlr_surface*, applyGlobalOffsetFn, void*, CWindow* pWindow = nullptr);
    void                               destroySurfaceTree(SSurfaceTreeNode*);

    inline std::list<SSurfaceTreeNode> surfaceTreeNodes;
};