summaryrefslogtreecommitdiff
path: root/src/managers/cursor/CursorShapeOverrideController.hpp
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2025-10-31 00:14:08 +0000
committerGitHub <noreply@github.com>2025-10-31 00:14:08 +0000
commit5e6cec962c780956177e56355ffc1d64cc5f83ca (patch)
tree9277452bb7202094e8a2a2cac3acea7aaa964772 /src/managers/cursor/CursorShapeOverrideController.hpp
parent6ade4d58cab67e18aa758ef664e36421cab4d8b2 (diff)
cursor: refactor override handling (#12166)
much cleaner and more reliable. Should fix https://github.com/hyprwm/Hyprland/issues/12088
Diffstat (limited to 'src/managers/cursor/CursorShapeOverrideController.hpp')
-rw-r--r--src/managers/cursor/CursorShapeOverrideController.hpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/managers/cursor/CursorShapeOverrideController.hpp b/src/managers/cursor/CursorShapeOverrideController.hpp
new file mode 100644
index 00000000..eca2ccf7
--- /dev/null
+++ b/src/managers/cursor/CursorShapeOverrideController.hpp
@@ -0,0 +1,49 @@
+#pragma once
+
+#include "../../helpers/memory/Memory.hpp"
+#include "../../helpers/signal/Signal.hpp"
+
+#include <array>
+#include <string>
+
+namespace Cursor {
+ enum eCursorShapeOverrideGroup : uint8_t {
+ // unknown group - lowest priority
+ CURSOR_OVERRIDE_UNKNOWN = 0,
+ // window edges for resizing from edge
+ CURSOR_OVERRIDE_WINDOW_EDGE,
+ // Drag and drop
+ CURSOR_OVERRIDE_DND,
+ // special action: Interactive::CDrag, kill, etc.
+ CURSOR_OVERRIDE_SPECIAL_ACTION,
+
+ //
+ CURSOR_OVERRIDE_END,
+ };
+
+ class CShapeOverrideController {
+ public:
+ CShapeOverrideController() = default;
+ ~CShapeOverrideController() = default;
+
+ CShapeOverrideController(const CShapeOverrideController&) = delete;
+ CShapeOverrideController(CShapeOverrideController&) = delete;
+ CShapeOverrideController(CShapeOverrideController&&) = delete;
+
+ void setOverride(const std::string& name, eCursorShapeOverrideGroup group);
+ void unsetOverride(eCursorShapeOverrideGroup group);
+
+ struct {
+ // if string is empty, override was cleared
+ CSignalT<const std::string&> overrideChanged;
+ } m_events;
+
+ private:
+ void recheckOverridesResendIfChanged();
+
+ std::array<std::string, CURSOR_OVERRIDE_END> m_overrides;
+ std::string m_overrideShape;
+ };
+
+ inline UP<CShapeOverrideController> overrideController = makeUnique<CShapeOverrideController>();
+}; \ No newline at end of file