#pragma once #include "../defines.hpp" #include "../helpers/Region.hpp" #include "../helpers/signal/Signal.hpp" class CSubsurface; class CPopup; class CPointerConstraint; class CWLSurfaceResource; class CWLSurface { public: static SP create() { auto p = SP(new CWLSurface); p->self = p; return p; } ~CWLSurface(); // anonymous surfaces are non-desktop components, e.g. a cursor surface or a DnD void assign(SP pSurface); void assign(SP pSurface, PHLWINDOW pOwner); void assign(SP pSurface, PHLLS pOwner); void assign(SP pSurface, CSubsurface* pOwner); void assign(SP pSurface, CPopup* pOwner); void unassign(); CWLSurface(const CWLSurface&) = delete; CWLSurface(CWLSurface&&) = delete; CWLSurface& operator=(const CWLSurface&) = delete; CWLSurface& operator=(CWLSurface&&) = delete; SP resource() const; bool exists() const; bool small() const; // means surface is smaller than the requested size Vector2D correctSmallVec() const; // returns a corrective vector for small() surfaces Vector2D getViewporterCorrectedSize() const; CRegion logicalDamage() const; bool visible(); // getters for owners. PHLWINDOW getWindow(); PHLLS getLayer(); CPopup* getPopup(); CSubsurface* getSubsurface(); // desktop components misc utils std::optional getSurfaceBoxGlobal(); void appendConstraint(WP constraint); SP constraint(); // allow stretching. Useful for plugins. bool m_bFillIgnoreSmall = false; // track surface data and avoid dupes float m_fLastScale = 0; int m_iLastScale = 0; wl_output_transform m_eLastTransform = (wl_output_transform)-1; // CWLSurface& operator=(SP pSurface) { destroy(); m_pResource = pSurface; init(); return *this; } bool operator==(const CWLSurface& other) const { return other.resource() == resource(); } bool operator==(const SP other) const { return other == resource(); } explicit operator bool() const { return exists(); } static SP fromResource(SP pSurface); // used by the alpha-modifier protocol float m_pAlphaModifier = 1.F; struct { CSignal destroy; } events; WP self; private: CWLSurface() = default; bool m_bInert = true; WP m_pResource; PHLWINDOWREF m_pWindowOwner; PHLLSREF m_pLayerOwner; CPopup* m_pPopupOwner = nullptr; CSubsurface* m_pSubsurfaceOwner = nullptr; // WP m_pConstraint; void destroy(); void init(); bool desktopComponent(); struct { CHyprSignalListener destroy; } listeners; friend class CPointerConstraint; };