2024-03-09 17:52:59 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <hyprcursor/hyprcursor.hpp>
|
|
|
|
#include <memory>
|
|
|
|
#include "../includes.hpp"
|
2024-06-19 16:20:06 +02:00
|
|
|
#include "../helpers/math/Math.hpp"
|
2024-06-22 00:40:45 +02:00
|
|
|
#include "../helpers/memory/Memory.hpp"
|
2024-07-21 13:09:54 +02:00
|
|
|
#include "../macros.hpp"
|
2024-08-05 19:58:21 +02:00
|
|
|
#include "managers/eventLoop/EventLoopManager.hpp"
|
|
|
|
#include "managers/XCursorManager.hpp"
|
2024-07-21 13:09:54 +02:00
|
|
|
#include <aquamarine/buffer/Buffer.hpp>
|
2024-03-09 17:52:59 +01:00
|
|
|
|
2024-05-05 23:18:10 +02:00
|
|
|
class CWLSurface;
|
2024-03-09 17:52:59 +01:00
|
|
|
|
2024-07-21 13:09:54 +02:00
|
|
|
AQUAMARINE_FORWARD(IBuffer);
|
|
|
|
|
2024-08-07 13:23:00 +02:00
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
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
|
|
|
|
2024-07-21 13:09:54 +02:00
|
|
|
SP<Aquamarine::IBuffer> getCursorBuffer();
|
2024-03-09 17:52:59 +01:00
|
|
|
|
2024-07-21 13:09:54 +02:00
|
|
|
void setCursorFromName(const std::string& name);
|
|
|
|
void setCursorSurface(SP<CWLSurface> surf, const Vector2D& hotspot);
|
2024-08-07 13:23:00 +02:00
|
|
|
void setCursorBuffer(SP<CCursorBuffer> buf, const Vector2D& hotspot, const float& scale);
|
|
|
|
void setAnimationTimer(const int& frame, const int& delay);
|
2024-03-09 17:52:59 +01:00
|
|
|
|
2024-07-21 13:09:54 +02:00
|
|
|
bool changeTheme(const std::string& name, const int size);
|
|
|
|
void updateTheme();
|
|
|
|
SCursorImageData dataFor(const std::string& name); // for xwayland
|
|
|
|
void setXWaylandCursor();
|
2024-03-09 17:52:59 +01:00
|
|
|
|
2024-07-21 13:09:54 +02:00
|
|
|
void tickAnimatedCursor();
|
2024-03-09 17:52:59 +01:00
|
|
|
|
|
|
|
private:
|
2024-08-07 13:23:00 +02:00
|
|
|
bool m_bOurBufferConnected = false;
|
2024-07-21 13:09:54 +02:00
|
|
|
std::vector<SP<CCursorBuffer>> m_vCursorBuffers;
|
2024-03-09 17:52:59 +01:00
|
|
|
|
|
|
|
std::unique_ptr<Hyprcursor::CHyprcursorManager> m_pHyprcursor;
|
2024-08-05 19:58:21 +02:00
|
|
|
std::unique_ptr<CXCursorManager> m_pXcursor;
|
|
|
|
SP<SXCursors> m_currentXcursor;
|
2024-03-09 17:52:59 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2024-08-05 19:58:21 +02:00
|
|
|
SP<CEventLoopTimer> m_pAnimationTimer;
|
2024-03-09 17:52:59 +01:00
|
|
|
int m_iCurrentAnimationFrame = 0;
|
|
|
|
Hyprcursor::SCursorShapeData m_sCurrentCursorShapeData;
|
|
|
|
};
|
|
|
|
|
|
|
|
inline std::unique_ptr<CCursorManager> g_pCursorManager;
|