2023-03-20 16:00:58 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../defines.hpp"
|
2024-06-19 16:20:06 +02:00
|
|
|
#include "../helpers/math/Math.hpp"
|
2024-04-27 00:55:41 +02:00
|
|
|
#include "../helpers/signal/Signal.hpp"
|
2023-10-20 21:15:41 +02:00
|
|
|
|
2024-02-29 16:07:11 +01:00
|
|
|
class CSubsurface;
|
|
|
|
class CPopup;
|
2024-04-27 00:55:41 +02:00
|
|
|
class CPointerConstraint;
|
2024-06-08 10:07:59 +02:00
|
|
|
class CWLSurfaceResource;
|
2023-10-20 21:15:41 +02:00
|
|
|
|
2023-03-20 16:00:58 +01:00
|
|
|
class CWLSurface {
|
|
|
|
public:
|
2024-06-08 10:07:59 +02:00
|
|
|
static SP<CWLSurface> create() {
|
|
|
|
auto p = SP<CWLSurface>(new CWLSurface);
|
|
|
|
p->self = p;
|
|
|
|
return p;
|
|
|
|
}
|
2023-03-20 16:00:58 +01:00
|
|
|
~CWLSurface();
|
|
|
|
|
2024-02-29 16:07:11 +01:00
|
|
|
// anonymous surfaces are non-desktop components, e.g. a cursor surface or a DnD
|
2024-06-08 10:07:59 +02:00
|
|
|
void assign(SP<CWLSurfaceResource> pSurface);
|
|
|
|
void assign(SP<CWLSurfaceResource> pSurface, PHLWINDOW pOwner);
|
|
|
|
void assign(SP<CWLSurfaceResource> pSurface, PHLLS pOwner);
|
|
|
|
void assign(SP<CWLSurfaceResource> pSurface, CSubsurface* pOwner);
|
|
|
|
void assign(SP<CWLSurfaceResource> pSurface, CPopup* pOwner);
|
2023-03-23 01:39:32 +01:00
|
|
|
void unassign();
|
2023-03-20 16:00:58 +01:00
|
|
|
|
2024-06-08 10:07:59 +02:00
|
|
|
CWLSurface(const CWLSurface&) = delete;
|
|
|
|
CWLSurface(CWLSurface&&) = delete;
|
|
|
|
CWLSurface& operator=(const CWLSurface&) = delete;
|
|
|
|
CWLSurface& operator=(CWLSurface&&) = delete;
|
2023-03-20 16:00:58 +01:00
|
|
|
|
2024-06-08 10:07:59 +02:00
|
|
|
SP<CWLSurfaceResource> resource() const;
|
|
|
|
bool exists() const;
|
2024-07-22 12:37:54 +02:00
|
|
|
bool small() const; // means surface is smaller than the requested size
|
|
|
|
Vector2D correctSmallVec() const; // returns a corrective vector for small() surfaces
|
|
|
|
Vector2D correctSmallVecBuf() const; // returns a corrective vector for small() surfaces, in BL coords
|
2024-06-08 10:07:59 +02:00
|
|
|
Vector2D getViewporterCorrectedSize() const;
|
2024-07-22 12:37:54 +02:00
|
|
|
CRegion computeDamage() const; // logical coordinates. May be wrong if the surface is unassigned
|
2024-06-08 10:07:59 +02:00
|
|
|
bool visible();
|
2024-07-27 15:03:52 +02:00
|
|
|
bool keyboardFocusable() const;
|
2023-10-20 21:15:41 +02:00
|
|
|
|
2024-02-29 16:07:11 +01:00
|
|
|
// getters for owners.
|
2024-07-22 12:37:54 +02:00
|
|
|
PHLWINDOW getWindow() const;
|
|
|
|
PHLLS getLayer() const;
|
|
|
|
CPopup* getPopup() const;
|
|
|
|
CSubsurface* getSubsurface() const;
|
2024-02-29 16:07:11 +01:00
|
|
|
|
|
|
|
// desktop components misc utils
|
2024-07-22 12:37:54 +02:00
|
|
|
std::optional<CBox> getSurfaceBoxGlobal() const;
|
2024-05-05 18:16:00 +02:00
|
|
|
void appendConstraint(WP<CPointerConstraint> constraint);
|
2024-07-22 12:37:54 +02:00
|
|
|
SP<CPointerConstraint> constraint() const;
|
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;
|
|
|
|
|
|
|
|
//
|
2024-06-08 10:07:59 +02:00
|
|
|
CWLSurface& operator=(SP<CWLSurfaceResource> pSurface) {
|
2023-10-20 21:15:41 +02:00
|
|
|
destroy();
|
2024-06-08 10:07:59 +02:00
|
|
|
m_pResource = pSurface;
|
2023-10-20 21:15:41 +02:00
|
|
|
init();
|
|
|
|
|
|
|
|
return *this;
|
2023-03-20 16:00:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const CWLSurface& other) const {
|
2024-06-08 10:07:59 +02:00
|
|
|
return other.resource() == resource();
|
2023-03-20 16:00:58 +01:00
|
|
|
}
|
|
|
|
|
2024-06-08 10:07:59 +02:00
|
|
|
bool operator==(const SP<CWLSurfaceResource> other) const {
|
|
|
|
return other == resource();
|
2023-03-20 16:00:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
explicit operator bool() const {
|
|
|
|
return exists();
|
|
|
|
}
|
|
|
|
|
2024-06-08 10:07:59 +02:00
|
|
|
static SP<CWLSurface> fromResource(SP<CWLSurfaceResource> pSurface);
|
2023-10-20 21:15:41 +02:00
|
|
|
|
2024-04-21 22:21:22 +02:00
|
|
|
// used by the alpha-modifier protocol
|
|
|
|
float m_pAlphaModifier = 1.F;
|
|
|
|
|
2024-04-27 00:55:41 +02:00
|
|
|
struct {
|
|
|
|
CSignal destroy;
|
|
|
|
} events;
|
|
|
|
|
2024-06-08 10:07:59 +02:00
|
|
|
WP<CWLSurface> self;
|
|
|
|
|
2023-03-20 16:00:58 +01:00
|
|
|
private:
|
2024-06-08 10:07:59 +02:00
|
|
|
CWLSurface() = default;
|
|
|
|
|
|
|
|
bool m_bInert = true;
|
2024-02-29 16:07:11 +01:00
|
|
|
|
2024-06-08 10:07:59 +02:00
|
|
|
WP<CWLSurfaceResource> m_pResource;
|
2024-02-29 16:07:11 +01:00
|
|
|
|
2024-06-08 10:07:59 +02:00
|
|
|
PHLWINDOWREF m_pWindowOwner;
|
|
|
|
PHLLSREF m_pLayerOwner;
|
|
|
|
CPopup* m_pPopupOwner = nullptr;
|
|
|
|
CSubsurface* m_pSubsurfaceOwner = nullptr;
|
2023-03-20 16:00:58 +01:00
|
|
|
|
2024-03-02 22:04:55 +01:00
|
|
|
//
|
2024-05-05 18:16:00 +02:00
|
|
|
WP<CPointerConstraint> m_pConstraint;
|
2024-03-02 22:04:55 +01:00
|
|
|
|
2024-05-05 18:16:00 +02:00
|
|
|
void destroy();
|
|
|
|
void init();
|
2024-07-22 12:37:54 +02:00
|
|
|
bool desktopComponent() const;
|
2023-03-20 16:00:58 +01:00
|
|
|
|
2024-06-08 10:07:59 +02:00
|
|
|
struct {
|
|
|
|
CHyprSignalListener destroy;
|
|
|
|
} listeners;
|
2024-03-02 22:04:55 +01:00
|
|
|
|
2024-04-27 00:55:41 +02:00
|
|
|
friend class CPointerConstraint;
|
2023-03-20 16:00:58 +01:00
|
|
|
};
|