Hyprland/src/helpers/SubsurfaceTree.hpp

61 lines
1.5 KiB
C++
Raw Normal View History

2022-03-27 17:25:20 +02:00
#pragma once
#include "../defines.hpp"
#include <list>
2023-03-20 16:00:58 +01:00
#include "WLSurface.hpp"
2022-03-27 17:25:20 +02:00
struct SSubsurface;
class CWindow;
2022-03-27 17:25:20 +02:00
typedef void (*applyGlobalOffsetFn)(void*, int*, int*);
2022-03-27 17:25:20 +02:00
struct SSurfaceTreeNode {
2023-03-20 16:00:58 +01:00
CWLSurface* pSurface = nullptr; // actual surface
CWLSurface pInternalSurface; // not present for head nodes to not dupe wlr_surface ownership
2022-03-27 17:25:20 +02:00
2022-03-28 22:31:39 +02:00
DYNLISTENER(newSubsurface);
DYNLISTENER(commit);
DYNLISTENER(destroy);
2022-03-27 17:25:20 +02:00
SSurfaceTreeNode* pParent = nullptr;
SSubsurface* pSubsurface = nullptr;
2022-03-27 17:25:20 +02:00
std::list<SSubsurface> childSubsurfaces;
applyGlobalOffsetFn offsetfn;
void* globalOffsetData;
CWindow* pWindowOwner = nullptr;
2022-03-27 17:25:20 +02:00
Vector2D lastSize;
2023-08-07 13:35:19 +02:00
//
bool operator==(const SSurfaceTreeNode& rhs) const {
2022-03-27 17:25:20 +02:00
return pSurface == rhs.pSurface;
}
};
struct SSubsurface {
wlr_subsurface* pSubsurface = nullptr;
2022-03-27 17:25:20 +02:00
SSurfaceTreeNode* pParent = nullptr;
SSurfaceTreeNode* pChild = nullptr;
2022-03-27 17:25:20 +02:00
2022-03-28 22:31:39 +02:00
DYNLISTENER(map);
DYNLISTENER(unmap);
DYNLISTENER(destroy);
2022-03-27 17:25:20 +02:00
CWindow* pWindowOwner = nullptr;
2023-08-07 13:35:19 +02:00
//
bool operator==(const SSubsurface& rhs) const {
2022-03-27 17:25:20 +02:00
return pSubsurface == rhs.pSubsurface;
}
};
namespace SubsurfaceTree {
SSurfaceTreeNode* createTreeRoot(wlr_surface*, applyGlobalOffsetFn, void*, CWindow* pWindow = nullptr);
void destroySurfaceTree(SSurfaceTreeNode*);
2022-03-27 17:25:20 +02:00
inline std::list<SSurfaceTreeNode> surfaceTreeNodes;
};