2024-03-09 17:52:59 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <hyprcursor/hyprcursor.hpp>
|
|
|
|
#include <memory>
|
|
|
|
#include "../includes.hpp"
|
|
|
|
#include "../helpers/Vector2D.hpp"
|
|
|
|
|
|
|
|
struct wlr_buffer;
|
|
|
|
struct wlr_xcursor_manager;
|
2024-05-05 23:18:10 +02:00
|
|
|
class CWLSurface;
|
2024-03-09 17:52:59 +01:00
|
|
|
|
|
|
|
class CCursorManager {
|
|
|
|
public:
|
|
|
|
CCursorManager();
|
2024-05-03 15:42:08 +02:00
|
|
|
~CCursorManager();
|
2024-03-09 17:52:59 +01:00
|
|
|
|
|
|
|
wlr_buffer* getCursorBuffer();
|
|
|
|
|
|
|
|
void setCursorFromName(const std::string& name);
|
2024-05-05 23:18:10 +02:00
|
|
|
void setCursorSurface(CWLSurface* surf, const Vector2D& hotspot);
|
|
|
|
void setXCursor(const std::string& name);
|
2024-03-09 17:52:59 +01:00
|
|
|
|
|
|
|
void changeTheme(const std::string& name, const int size);
|
|
|
|
void updateTheme();
|
|
|
|
SCursorImageData dataFor(const std::string& name); // for xwayland
|
2024-05-25 22:43:51 +02:00
|
|
|
void setXWaylandCursor();
|
2024-03-09 17:52:59 +01:00
|
|
|
|
|
|
|
void tickAnimatedCursor();
|
|
|
|
|
|
|
|
class CCursorBuffer {
|
|
|
|
public:
|
|
|
|
CCursorBuffer(cairo_surface_t* surf, const Vector2D& size, const Vector2D& hotspot);
|
2024-05-05 23:18:10 +02:00
|
|
|
CCursorBuffer(uint8_t* pixelData, const Vector2D& size, const Vector2D& hotspot);
|
2024-03-09 17:52:59 +01:00
|
|
|
~CCursorBuffer();
|
|
|
|
|
|
|
|
struct SCursorWlrBuffer {
|
|
|
|
wlr_buffer base;
|
2024-05-05 23:18:10 +02:00
|
|
|
cairo_surface_t* surface = nullptr;
|
|
|
|
bool dropped = false;
|
|
|
|
CCursorBuffer* parent = nullptr;
|
|
|
|
uint8_t* pixelData = nullptr;
|
|
|
|
size_t stride = 0;
|
2024-03-09 17:52:59 +01:00
|
|
|
} 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 = "";
|
2024-03-24 03:21:28 +01:00
|
|
|
int m_iSize = 0;
|
2024-03-09 17:52:59 +01:00
|
|
|
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;
|