summaryrefslogtreecommitdiff
path: root/src/protocols/PointerConstraints.hpp
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2024-04-26 23:55:41 +0100
committerVaxry <vaxry@vaxry.net>2024-04-27 03:17:04 +0100
commit25aec3ac8ce65ed224f025f8f6dfef73780577a4 (patch)
tree9fa63de1670bd2f535f3bc237800fc6b7a81f646 /src/protocols/PointerConstraints.hpp
parentf94264928a8ab4da8759d4ded25a46af44451d38 (diff)
pointer-constraints: move to new impl
Diffstat (limited to 'src/protocols/PointerConstraints.hpp')
-rw-r--r--src/protocols/PointerConstraints.hpp80
1 files changed, 80 insertions, 0 deletions
diff --git a/src/protocols/PointerConstraints.hpp b/src/protocols/PointerConstraints.hpp
new file mode 100644
index 00000000..93e57c46
--- /dev/null
+++ b/src/protocols/PointerConstraints.hpp
@@ -0,0 +1,80 @@
+#pragma once
+
+#pragma once
+
+#include <memory>
+#include <vector>
+#include <cstdint>
+#include "WaylandProtocol.hpp"
+#include "pointer-constraints-unstable-v1.hpp"
+#include "../helpers/Vector2D.hpp"
+#include "../helpers/Region.hpp"
+#include "../helpers/signal/Listener.hpp"
+
+class CWLSurface;
+
+class CPointerConstraint {
+ public:
+ CPointerConstraint(SP<CZwpLockedPointerV1> resource_, wlr_surface* surf, wl_resource* region, zwpPointerConstraintsV1Lifetime lifetime);
+ CPointerConstraint(SP<CZwpConfinedPointerV1> resource_, wlr_surface* surf, wl_resource* region, zwpPointerConstraintsV1Lifetime lifetime);
+ ~CPointerConstraint();
+
+ bool good();
+
+ void deactivate();
+ void activate();
+ bool isActive();
+
+ CWLSurface* owner();
+
+ CRegion logicConstraintRegion();
+ bool isLocked();
+ Vector2D logicPositionHint();
+
+ private:
+ SP<CZwpLockedPointerV1> resourceL;
+ SP<CZwpConfinedPointerV1> resourceC;
+ wl_client* pClient = nullptr;
+
+ CWLSurface* pHLSurface = nullptr;
+
+ 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;
+}; \ No newline at end of file