cursormgr: implement inheriting themes for xcursor (#7197)

* 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.
This commit is contained in:
Tom Englund
2024-08-07 13:23:00 +02:00
committed by GitHub
parent a05da63d85
commit 3d82d199f0
4 changed files with 285 additions and 223 deletions

View File

@@ -1,6 +1,7 @@
#pragma once
#include <string>
#include <vector>
#include <unordered_set>
#include <array>
#include <cstdint>
#include <hyprutils/math/Vector2D.hpp>
@@ -32,15 +33,15 @@ class CXCursorManager {
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);
SP<SXCursors> createCursor(std::string const& shape, XcursorImages* xImages);
std::unordered_set<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;
int lastLoadSize = 0;
std::string themeName = "";
SP<SXCursors> defaultCursor;
SP<SXCursors> hyprCursor;
std::vector<SP<SXCursors>> cursors;
};