summaryrefslogtreecommitdiff
path: root/src/managers/CursorManager.hpp
diff options
context:
space:
mode:
authorTom Englund <tomenglund26@gmail.com>2024-08-07 13:23:00 +0200
committerGitHub <noreply@github.com>2024-08-07 13:23:00 +0200
commit3d82d199f0ec6d8bf6252ed0795b4d883ade84ff (patch)
tree8fe4cb387b106afc1aa3f8657fd171f2bca56a33 /src/managers/CursorManager.hpp
parenta05da63d853fc750bae29228d924b346243afaec (diff)
cursormgr: implement inheriting themes for xcursor (#7197)
* cursormgr: reduce duplicated code add a few functions such as setCursorBuffer and setAnimationTimer to reduce duplicated code and also avoid future mishaps of forgetting to clear buffer or disarm timer. and generally reduce spaghetti even tho pasta can be delicious. * xcursormgr: implent inherited themes implent index.theme parsing and inherited themes. * cursormgr: ensure a fallback xcursor exist ensure a xcursor fallback exist otherwise it wont load the proper theme if we at launch have hyprcursor enabled and then set it to false in config and reload. also use the env var when using hyprctl setcursor incase its empty.
Diffstat (limited to 'src/managers/CursorManager.hpp')
-rw-r--r--src/managers/CursorManager.hpp54
1 files changed, 25 insertions, 29 deletions
diff --git a/src/managers/CursorManager.hpp b/src/managers/CursorManager.hpp
index a114b6c2..ceb4816b 100644
--- a/src/managers/CursorManager.hpp
+++ b/src/managers/CursorManager.hpp
@@ -15,6 +15,28 @@ class CWLSurface;
AQUAMARINE_FORWARD(IBuffer);
+class CCursorBuffer : public Aquamarine::IBuffer {
+ public:
+ CCursorBuffer(cairo_surface_t* surf, const Vector2D& size, const Vector2D& hotspot);
+ CCursorBuffer(uint8_t* pixelData, const Vector2D& size, const Vector2D& hotspot);
+ ~CCursorBuffer() = default;
+
+ virtual Aquamarine::eBufferCapability caps();
+ virtual Aquamarine::eBufferType type();
+ virtual void update(const Hyprutils::Math::CRegion& damage);
+ virtual bool isSynchronous(); // whether the updates to this buffer are synchronous, aka happen over cpu
+ virtual bool good();
+ virtual Aquamarine::SSHMAttrs shm();
+ virtual std::tuple<uint8_t*, uint32_t, size_t> beginDataPtr(uint32_t flags);
+ virtual void endDataPtr();
+
+ private:
+ Vector2D hotspot;
+ cairo_surface_t* surface = nullptr;
+ uint8_t* pixelData = nullptr;
+ size_t stride = 0;
+};
+
class CCursorManager {
public:
CCursorManager();
@@ -24,7 +46,8 @@ class CCursorManager {
void setCursorFromName(const std::string& name);
void setCursorSurface(SP<CWLSurface> surf, const Vector2D& hotspot);
- void setXCursor(const std::string& name);
+ void setCursorBuffer(SP<CCursorBuffer> buf, const Vector2D& hotspot, const float& scale);
+ void setAnimationTimer(const int& frame, const int& delay);
bool changeTheme(const std::string& name, const int size);
void updateTheme();
@@ -33,35 +56,8 @@ class CCursorManager {
void tickAnimatedCursor();
- class CCursorBuffer : public Aquamarine::IBuffer {
- public:
- CCursorBuffer(cairo_surface_t* surf, const Vector2D& size, const Vector2D& hotspot);
- CCursorBuffer(uint8_t* pixelData, const Vector2D& size, const Vector2D& hotspot);
- ~CCursorBuffer();
-
- virtual Aquamarine::eBufferCapability caps();
- virtual Aquamarine::eBufferType type();
- virtual void update(const Hyprutils::Math::CRegion& damage);
- virtual bool isSynchronous(); // whether the updates to this buffer are synchronous, aka happen over cpu
- virtual bool good();
- virtual Aquamarine::SSHMAttrs shm();
- virtual std::tuple<uint8_t*, uint32_t, size_t> beginDataPtr(uint32_t flags);
- virtual void endDataPtr();
-
- private:
- Vector2D hotspot;
- cairo_surface_t* surface = nullptr;
- uint8_t* pixelData = nullptr;
- size_t stride = 0;
-
- friend class CCursorManager;
- };
-
- void dropBufferRef(CCursorBuffer* ref);
-
- bool m_bOurBufferConnected = false;
-
private:
+ bool m_bOurBufferConnected = false;
std::vector<SP<CCursorBuffer>> m_vCursorBuffers;
std::unique_ptr<Hyprcursor::CHyprcursorManager> m_pHyprcursor;