summaryrefslogtreecommitdiff
path: root/src/managers/CursorManager.hpp
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2024-03-09 16:52:59 +0000
committerGitHub <noreply@github.com>2024-03-09 16:52:59 +0000
commitc3882bb83240b602277f2d22f21d71690531f62e (patch)
treec5e9a1110cd5d22ef700fd8b7408a418cba7c4f0 /src/managers/CursorManager.hpp
parente7a5db4852d654596e554b9cdeaa2694b346ee03 (diff)
internal: Support libhyprcursor (#5009)
woo --------- Co-authored-by: Mihai Fufezan <fufexan@protonmail.com>
Diffstat (limited to 'src/managers/CursorManager.hpp')
-rw-r--r--src/managers/CursorManager.hpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/managers/CursorManager.hpp b/src/managers/CursorManager.hpp
new file mode 100644
index 00000000..b1c49b31
--- /dev/null
+++ b/src/managers/CursorManager.hpp
@@ -0,0 +1,69 @@
+#pragma once
+
+#include <string>
+#include <hyprcursor/hyprcursor.hpp>
+#include <memory>
+#include "../includes.hpp"
+#include "../helpers/Vector2D.hpp"
+
+struct wlr_buffer;
+struct wlr_xcursor_manager;
+
+class CCursorManager {
+ public:
+ CCursorManager();
+
+ wlr_buffer* getCursorBuffer();
+
+ void setCursorFromName(const std::string& name);
+ void setCursorSurface(wlr_surface* surf, const Vector2D& hotspot);
+
+ void changeTheme(const std::string& name, const int size);
+ void updateTheme();
+ SCursorImageData dataFor(const std::string& name); // for xwayland
+
+ void tickAnimatedCursor();
+
+ class CCursorBuffer {
+ public:
+ CCursorBuffer(cairo_surface_t* surf, const Vector2D& size, const Vector2D& hotspot);
+ ~CCursorBuffer();
+
+ struct SCursorWlrBuffer {
+ wlr_buffer base;
+ cairo_surface_t* surface = nullptr;
+ bool dropped = false;
+ CCursorBuffer* parent = nullptr;
+ } wlrBuffer;
+
+ private:
+ Vector2D size;
+ Vector2D hotspot;
+
+ friend class CCursorManager;
+ };
+
+ void dropBufferRef(CCursorBuffer* ref);
+
+ bool m_bOurBufferConnected = false;
+
+ private:
+ std::vector<std::unique_ptr<CCursorBuffer>> m_vCursorBuffers;
+
+ std::unique_ptr<Hyprcursor::CHyprcursorManager> m_pHyprcursor;
+
+ std::string m_szTheme = "";
+ int m_iSize = 24;
+ float m_fCursorScale = 1.0;
+
+ Hyprcursor::SCursorStyleInfo m_sCurrentStyleInfo;
+
+ wl_event_source* m_pAnimationTimer = nullptr;
+ int m_iCurrentAnimationFrame = 0;
+ Hyprcursor::SCursorShapeData m_sCurrentCursorShapeData;
+
+ // xcursor fallback
+ wlr_xcursor_manager* m_pWLRXCursorMgr = nullptr;
+};
+
+inline std::unique_ptr<CCursorManager> g_pCursorManager; \ No newline at end of file