Hyprland/src/desktop/WLSurface.hpp

72 lines
1.9 KiB
C++
Raw Normal View History

2023-03-20 16:00:58 +01:00
#pragma once
#include "../defines.hpp"
#include "../helpers/Region.hpp"
class CWindow;
2023-03-20 16:00:58 +01:00
class CWLSurface {
public:
CWLSurface() = default;
CWLSurface(wlr_surface* pSurface);
~CWLSurface();
void assign(wlr_surface* pSurface);
2023-03-23 01:39:32 +01:00
void unassign();
2023-03-20 16:00:58 +01:00
CWLSurface(const CWLSurface&) = delete;
CWLSurface(CWLSurface&&) = delete;
2023-03-20 16:00:58 +01:00
CWLSurface& operator=(const CWLSurface&) = delete;
CWLSurface& operator=(CWLSurface&&) = delete;
2023-03-20 16:00:58 +01:00
wlr_surface* wlr() 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;
// allow stretching. Useful for plugins.
bool m_bFillIgnoreSmall = false;
2023-03-20 16:00:58 +01:00
// if present, means this is a base surface of a window. Cleaned on unassign()
CWindow* m_pOwner = nullptr;
2023-03-20 16:00:58 +01:00
// 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=(wlr_surface* pSurface) {
destroy();
m_pWLRSurface = pSurface;
init();
return *this;
2023-03-20 16:00:58 +01:00
}
bool operator==(const CWLSurface& other) const {
return other.wlr() == wlr();
}
bool operator==(const wlr_surface* other) const {
return other == wlr();
}
explicit operator bool() const {
return exists();
}
static CWLSurface* surfaceFromWlr(wlr_surface* pSurface) {
return (CWLSurface*)pSurface->data;
}
2023-03-20 16:00:58 +01:00
private:
wlr_surface* m_pWLRSurface = nullptr;
void destroy();
void init();
DYNLISTENER(destroy);
};