2023-03-20 16:00:58 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../defines.hpp"
|
2024-02-29 14:03:38 +01:00
|
|
|
#include "../helpers/Region.hpp"
|
2024-03-02 22:04:55 +01:00
|
|
|
#include "Constraint.hpp"
|
2023-10-20 21:15:41 +02:00
|
|
|
|
|
|
|
class CWindow;
|
2024-02-29 16:07:11 +01:00
|
|
|
struct SLayerSurface;
|
|
|
|
class CSubsurface;
|
|
|
|
class CPopup;
|
2023-10-20 21:15:41 +02:00
|
|
|
|
2023-03-20 16:00:58 +01:00
|
|
|
class CWLSurface {
|
|
|
|
public:
|
|
|
|
CWLSurface() = default;
|
|
|
|
~CWLSurface();
|
|
|
|
|
2024-02-29 16:07:11 +01:00
|
|
|
// anonymous surfaces are non-desktop components, e.g. a cursor surface or a DnD
|
2023-03-20 16:00:58 +01:00
|
|
|
void assign(wlr_surface* pSurface);
|
2024-02-29 16:07:11 +01:00
|
|
|
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);
|
2023-03-23 01:39:32 +01:00
|
|
|
void unassign();
|
2023-03-20 16:00:58 +01:00
|
|
|
|
2023-12-06 23:54:56 +01:00
|
|
|
CWLSurface(const CWLSurface&) = delete;
|
|
|
|
CWLSurface(CWLSurface&&) = delete;
|
2023-03-20 16:00:58 +01:00
|
|
|
CWLSurface& operator=(const CWLSurface&) = delete;
|
2023-12-06 23:54:56 +01:00
|
|
|
CWLSurface& operator=(CWLSurface&&) = delete;
|
2023-03-20 16:00:58 +01:00
|
|
|
|
|
|
|
wlr_surface* wlr() const;
|
|
|
|
bool exists() const;
|
2023-10-20 21:15:41 +02:00
|
|
|
bool small() const; // means surface is smaller than the requested size
|
|
|
|
Vector2D correctSmallVec() const; // returns a corrective vector for small() surfaces
|
2023-10-25 23:05:04 +02:00
|
|
|
Vector2D getViewporterCorrectedSize() const;
|
2024-02-19 12:24:54 +01:00
|
|
|
CRegion logicalDamage() const;
|
2024-03-02 22:04:55 +01:00
|
|
|
void onCommit();
|
2023-10-20 21:15:41 +02:00
|
|
|
|
2024-02-29 16:07:11 +01:00
|
|
|
// getters for owners.
|
|
|
|
CWindow* getWindow();
|
|
|
|
SLayerSurface* getLayer();
|
|
|
|
CPopup* getPopup();
|
|
|
|
CSubsurface* getSubsurface();
|
|
|
|
|
|
|
|
// desktop components misc utils
|
|
|
|
std::optional<CBox> getSurfaceBoxGlobal();
|
2024-03-02 22:04:55 +01:00
|
|
|
void appendConstraint(wlr_pointer_constraint_v1* constraint);
|
|
|
|
CConstraint* constraint();
|
2024-02-29 16:07:11 +01:00
|
|
|
|
2023-10-20 21:15:41 +02:00
|
|
|
// allow stretching. Useful for plugins.
|
|
|
|
bool m_bFillIgnoreSmall = false;
|
2023-03-20 16:00:58 +01:00
|
|
|
|
2024-01-11 13:15:20 +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;
|
|
|
|
|
|
|
|
//
|
2023-10-20 21:15:41 +02:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2023-10-20 21:15:41 +02:00
|
|
|
static CWLSurface* surfaceFromWlr(wlr_surface* pSurface) {
|
2024-03-02 22:04:55 +01:00
|
|
|
if (!pSurface)
|
|
|
|
return nullptr;
|
2023-10-20 21:15:41 +02:00
|
|
|
return (CWLSurface*)pSurface->data;
|
|
|
|
}
|
|
|
|
|
2024-04-21 22:21:22 +02:00
|
|
|
// used by the alpha-modifier protocol
|
|
|
|
float m_pAlphaModifier = 1.F;
|
|
|
|
|
2023-03-20 16:00:58 +01:00
|
|
|
private:
|
2024-02-29 16:07:11 +01:00
|
|
|
bool m_bInert = true;
|
|
|
|
|
|
|
|
wlr_surface* m_pWLRSurface = nullptr;
|
|
|
|
|
|
|
|
CWindow* m_pWindowOwner = nullptr;
|
|
|
|
SLayerSurface* m_pLayerOwner = nullptr;
|
|
|
|
CPopup* m_pPopupOwner = nullptr;
|
|
|
|
CSubsurface* m_pSubsurfaceOwner = nullptr;
|
2023-03-20 16:00:58 +01:00
|
|
|
|
2024-03-02 22:04:55 +01:00
|
|
|
//
|
|
|
|
std::unique_ptr<CConstraint> m_pConstraint;
|
|
|
|
|
|
|
|
void destroy();
|
|
|
|
void init();
|
|
|
|
bool desktopComponent();
|
2023-03-20 16:00:58 +01:00
|
|
|
|
|
|
|
DYNLISTENER(destroy);
|
2024-03-02 22:04:55 +01:00
|
|
|
DYNLISTENER(commit);
|
|
|
|
|
|
|
|
friend class CConstraint;
|
2023-03-20 16:00:58 +01:00
|
|
|
};
|