summaryrefslogtreecommitdiff
path: root/src/managers/XCursorManager.hpp
blob: 2535d8a0320542c136e1f9efcd2b0249f99cd24e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#pragma once
#include <string>
#include <vector>
#include <set>
#include <array>
#include <cstdint>
#include <hyprutils/math/Vector2D.hpp>
#include "helpers/memory/Memory.hpp"

// gangsta bootleg XCursor impl. adidas balkanized
struct SXCursorImage {
    Hyprutils::Math::Vector2D size;
    Hyprutils::Math::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, float scale);
    SP<SXCursors> getShape(std::string const& shape, int size, float scale);
    void          syncGsettings();

  private:
    SP<SXCursors>              createCursor(std::string const& shape, void* /* XcursorImages* */ xImages);
    std::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                        m_lastLoadSize  = 0;
    float                      m_lastLoadScale = 0;
    std::string                m_themeName     = "";
    SP<SXCursors>              m_defaultCursor;
    SP<SXCursors>              m_hyprCursor;
    std::vector<SP<SXCursors>> m_cursors;
};