mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-15 18:45:59 +01:00
3d82d199f0
* 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.
78 lines
No EOL
3.1 KiB
C++
78 lines
No EOL
3.1 KiB
C++
#pragma once
|
|
|
|
#include <string>
|
|
#include <hyprcursor/hyprcursor.hpp>
|
|
#include <memory>
|
|
#include "../includes.hpp"
|
|
#include "../helpers/math/Math.hpp"
|
|
#include "../helpers/memory/Memory.hpp"
|
|
#include "../macros.hpp"
|
|
#include "managers/eventLoop/EventLoopManager.hpp"
|
|
#include "managers/XCursorManager.hpp"
|
|
#include <aquamarine/buffer/Buffer.hpp>
|
|
|
|
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();
|
|
~CCursorManager();
|
|
|
|
SP<Aquamarine::IBuffer> getCursorBuffer();
|
|
|
|
void setCursorFromName(const std::string& name);
|
|
void setCursorSurface(SP<CWLSurface> surf, const Vector2D& hotspot);
|
|
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();
|
|
SCursorImageData dataFor(const std::string& name); // for xwayland
|
|
void setXWaylandCursor();
|
|
|
|
void tickAnimatedCursor();
|
|
|
|
private:
|
|
bool m_bOurBufferConnected = false;
|
|
std::vector<SP<CCursorBuffer>> m_vCursorBuffers;
|
|
|
|
std::unique_ptr<Hyprcursor::CHyprcursorManager> m_pHyprcursor;
|
|
std::unique_ptr<CXCursorManager> m_pXcursor;
|
|
SP<SXCursors> m_currentXcursor;
|
|
|
|
std::string m_szTheme = "";
|
|
int m_iSize = 0;
|
|
float m_fCursorScale = 1.0;
|
|
|
|
Hyprcursor::SCursorStyleInfo m_sCurrentStyleInfo;
|
|
|
|
SP<CEventLoopTimer> m_pAnimationTimer;
|
|
int m_iCurrentAnimationFrame = 0;
|
|
Hyprcursor::SCursorShapeData m_sCurrentCursorShapeData;
|
|
};
|
|
|
|
inline std::unique_ptr<CCursorManager> g_pCursorManager; |