surface: unify owners

This commit is contained in:
Vaxry
2024-02-29 15:07:11 +00:00
parent bcec082a1c
commit 6916d0a6a3
8 changed files with 124 additions and 28 deletions

View File

@@ -4,14 +4,21 @@
#include "../helpers/Region.hpp"
class CWindow;
struct SLayerSurface;
class CSubsurface;
class CPopup;
class CWLSurface {
public:
CWLSurface() = default;
CWLSurface(wlr_surface* pSurface);
~CWLSurface();
// anonymous surfaces are non-desktop components, e.g. a cursor surface or a DnD
void assign(wlr_surface* pSurface);
void assign(wlr_surface* pSurface, CWindow* pOwner);
void assign(wlr_surface* pSurface, SLayerSurface* pOwner);
void assign(wlr_surface* pSurface, CSubsurface* pOwner);
void assign(wlr_surface* pSurface, CPopup* pOwner);
void unassign();
CWLSurface(const CWLSurface&) = delete;
@@ -26,12 +33,18 @@ class CWLSurface {
Vector2D getViewporterCorrectedSize() const;
CRegion logicalDamage() const;
// getters for owners.
CWindow* getWindow();
SLayerSurface* getLayer();
CPopup* getPopup();
CSubsurface* getSubsurface();
// desktop components misc utils
std::optional<CBox> getSurfaceBoxGlobal();
// allow stretching. Useful for plugins.
bool m_bFillIgnoreSmall = false;
// if present, means this is a base surface of a window. Cleaned on unassign()
CWindow* m_pOwner = nullptr;
// track surface data and avoid dupes
float m_fLastScale = 0;
int m_iLastScale = 0;
@@ -63,10 +76,18 @@ class CWLSurface {
}
private:
wlr_surface* m_pWLRSurface = nullptr;
bool m_bInert = true;
void destroy();
void init();
wlr_surface* m_pWLRSurface = nullptr;
CWindow* m_pWindowOwner = nullptr;
SLayerSurface* m_pLayerOwner = nullptr;
CPopup* m_pPopupOwner = nullptr;
CSubsurface* m_pSubsurfaceOwner = nullptr;
void destroy();
void init();
bool desktopComponent();
DYNLISTENER(destroy);
};