2024-04-27 00:55:41 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <vector>
|
|
|
|
#include <cstdint>
|
|
|
|
#include "WaylandProtocol.hpp"
|
|
|
|
#include "pointer-constraints-unstable-v1.hpp"
|
2024-06-19 16:20:06 +02:00
|
|
|
#include "../helpers/math/Math.hpp"
|
|
|
|
#include "../helpers/math/Math.hpp"
|
2024-06-11 17:17:45 +02:00
|
|
|
#include "../helpers/signal/Signal.hpp"
|
2024-04-27 00:55:41 +02:00
|
|
|
|
|
|
|
class CWLSurface;
|
2024-06-08 10:07:59 +02:00
|
|
|
class CWLSurfaceResource;
|
2024-04-27 00:55:41 +02:00
|
|
|
|
|
|
|
class CPointerConstraint {
|
|
|
|
public:
|
2024-06-08 10:07:59 +02:00
|
|
|
CPointerConstraint(SP<CZwpLockedPointerV1> resource_, SP<CWLSurfaceResource> surf, wl_resource* region, zwpPointerConstraintsV1Lifetime lifetime);
|
|
|
|
CPointerConstraint(SP<CZwpConfinedPointerV1> resource_, SP<CWLSurfaceResource> surf, wl_resource* region, zwpPointerConstraintsV1Lifetime lifetime);
|
2024-04-27 00:55:41 +02:00
|
|
|
~CPointerConstraint();
|
|
|
|
|
2024-06-08 10:07:59 +02:00
|
|
|
bool good();
|
2024-04-27 00:55:41 +02:00
|
|
|
|
2024-06-08 10:07:59 +02:00
|
|
|
void deactivate();
|
|
|
|
void activate();
|
|
|
|
bool isActive();
|
2024-04-27 00:55:41 +02:00
|
|
|
|
2024-06-08 10:07:59 +02:00
|
|
|
SP<CWLSurface> owner();
|
2024-04-27 00:55:41 +02:00
|
|
|
|
2024-06-08 10:07:59 +02:00
|
|
|
CRegion logicConstraintRegion();
|
|
|
|
bool isLocked();
|
|
|
|
Vector2D logicPositionHint();
|
2024-04-27 00:55:41 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
SP<CZwpLockedPointerV1> resourceL;
|
|
|
|
SP<CZwpConfinedPointerV1> resourceC;
|
|
|
|
wl_client* pClient = nullptr;
|
|
|
|
|
2024-06-08 10:07:59 +02:00
|
|
|
WP<CWLSurface> pHLSurface;
|
2024-04-27 00:55:41 +02:00
|
|
|
|
|
|
|
CRegion region;
|
|
|
|
bool hintSet = false;
|
|
|
|
Vector2D positionHint = {-1, -1};
|
|
|
|
Vector2D cursorPosOnActivate = {-1, -1};
|
|
|
|
bool active = false;
|
|
|
|
bool locked = false;
|
|
|
|
bool dead = false;
|
|
|
|
zwpPointerConstraintsV1Lifetime lifetime = ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_ONESHOT;
|
|
|
|
|
|
|
|
void sharedConstructions();
|
|
|
|
void onSetRegion(wl_resource* region);
|
|
|
|
|
|
|
|
struct {
|
|
|
|
CHyprSignalListener destroySurface;
|
|
|
|
} listeners;
|
|
|
|
};
|
|
|
|
|
|
|
|
class CPointerConstraintsProtocol : public IWaylandProtocol {
|
|
|
|
public:
|
|
|
|
CPointerConstraintsProtocol(const wl_interface* iface, const int& ver, const std::string& name);
|
|
|
|
|
|
|
|
virtual void bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void onManagerResourceDestroy(wl_resource* res);
|
|
|
|
void destroyPointerConstraint(CPointerConstraint* constraint);
|
|
|
|
void onLockPointer(CZwpPointerConstraintsV1* pMgr, uint32_t id, wl_resource* surface, wl_resource* pointer, wl_resource* region, zwpPointerConstraintsV1Lifetime lifetime);
|
|
|
|
void onConfinePointer(CZwpPointerConstraintsV1* pMgr, uint32_t id, wl_resource* surface, wl_resource* pointer, wl_resource* region, zwpPointerConstraintsV1Lifetime lifetime);
|
|
|
|
void onNewConstraint(SP<CPointerConstraint> constraint, CZwpPointerConstraintsV1* pMgr);
|
|
|
|
|
|
|
|
//
|
|
|
|
std::vector<UP<CZwpPointerConstraintsV1>> m_vManagers;
|
|
|
|
std::vector<SP<CPointerConstraint>> m_vConstraints;
|
|
|
|
|
|
|
|
friend class CPointerConstraint;
|
|
|
|
};
|
|
|
|
|
|
|
|
namespace PROTO {
|
|
|
|
inline UP<CPointerConstraintsProtocol> constraints;
|
|
|
|
};
|