From 0e86808e5912823f1c6bea1b6d5fcae297fc9f57 Mon Sep 17 00:00:00 2001 From: Tom Englund Date: Mon, 5 Aug 2024 19:58:21 +0200 Subject: cursor: Better xcursor implementation (#7178) * xcursor: bootleg xcursors into its own manager implent XCursorManager and load themes based on librarypath and its dir, now we catch all supplied theme files. and also implent animated cursors. also refactor a bit of spaghetti regarding xcursors in CursorManager. * hyprcursor: fix buffer leak animated cursors are creating a new buffer for each image, ensure we drop the buffers so it continously doesnt build up in infinity. * cursormgr: use eventloopmgr for animation use EvenloopManager for timers instead of adding it directly to m_sWLEventLoop and using its related wl_* functions. --- src/managers/XCursorManager.hpp | 46 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/managers/XCursorManager.hpp (limited to 'src/managers/XCursorManager.hpp') diff --git a/src/managers/XCursorManager.hpp b/src/managers/XCursorManager.hpp new file mode 100644 index 00000000..9ced076f --- /dev/null +++ b/src/managers/XCursorManager.hpp @@ -0,0 +1,46 @@ +#pragma once +#include +#include +#include +#include +#include +#include "helpers/memory/Memory.hpp" + +extern "C" { +#include +} + +// gangsta bootleg XCursor impl. adidas balkanized +struct SXCursorImage { + Vector2D size; + Vector2D hotspot; + std::vector pixels; // XPixel is a u32 + uint32_t delay; // animation delay to next frame (ms) +}; + +struct SXCursors { + std::vector images; + std::string shape; +}; + +class CXCursorManager { + public: + CXCursorManager(); + ~CXCursorManager() = default; + + void loadTheme(const std::string& name, int size); + SP getShape(std::string const& shape, int size); + + private: + SP createCursor(std::string const& shape, XcursorImages* xImages); + std::vector themePaths(std::string const& theme); + std::string getLegacyShapeName(std::string const& shape); + std::vector> loadStandardCursors(std::string const& name, int size); + std::vector> loadAllFromDir(std::string const& path, int size); + + int lastLoadSize = 0; + std::string themeName = ""; + SP defaultCursor; + SP hyprCursor; + std::vector> cursors; +}; \ No newline at end of file -- cgit v1.2.3