mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-08-16 20:43:48 -07:00
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.
This commit is contained in:
46
src/managers/XCursorManager.hpp
Normal file
46
src/managers/XCursorManager.hpp
Normal file
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <hyprutils/math/Vector2D.hpp>
|
||||
#include "helpers/memory/Memory.hpp"
|
||||
|
||||
extern "C" {
|
||||
#include <X11/Xcursor/Xcursor.h>
|
||||
}
|
||||
|
||||
// gangsta bootleg XCursor impl. adidas balkanized
|
||||
struct SXCursorImage {
|
||||
Vector2D size;
|
||||
Vector2D hotspot;
|
||||
std::vector<uint32_t> pixels; // XPixel is a u32
|
||||
uint32_t delay; // animation delay to next frame (ms)
|
||||
};
|
||||
|
||||
struct SXCursors {
|
||||
std::vector<SXCursorImage> images;
|
||||
std::string shape;
|
||||
};
|
||||
|
||||
class CXCursorManager {
|
||||
public:
|
||||
CXCursorManager();
|
||||
~CXCursorManager() = default;
|
||||
|
||||
void loadTheme(const std::string& name, int size);
|
||||
SP<SXCursors> getShape(std::string const& shape, int size);
|
||||
|
||||
private:
|
||||
SP<SXCursors> createCursor(std::string const& shape, XcursorImages* xImages);
|
||||
std::vector<std::string> themePaths(std::string const& theme);
|
||||
std::string getLegacyShapeName(std::string const& shape);
|
||||
std::vector<SP<SXCursors>> loadStandardCursors(std::string const& name, int size);
|
||||
std::vector<SP<SXCursors>> loadAllFromDir(std::string const& path, int size);
|
||||
|
||||
int lastLoadSize = 0;
|
||||
std::string themeName = "";
|
||||
SP<SXCursors> defaultCursor;
|
||||
SP<SXCursors> hyprCursor;
|
||||
std::vector<SP<SXCursors>> cursors;
|
||||
};
|
Reference in New Issue
Block a user