hyprcursor/libhyprcursor/internalDefines.hpp

58 lines
1.6 KiB
C++
Raw Normal View History

2024-03-07 04:19:38 +01:00
#pragma once
#include "internalSharedTypes.hpp"
#include <optional>
#include <cairo/cairo.h>
#include <unordered_map>
#include <memory>
struct SLoadedCursorImage {
~SLoadedCursorImage() {
if (data)
delete[] (char*)data;
2024-03-07 15:50:48 +01:00
if (artificialData)
delete[] (char*)artificialData;
if (cairoSurface)
cairo_surface_destroy(cairoSurface);
2024-03-07 04:19:38 +01:00
}
// read stuff
size_t readNeedle = 0;
void* data = nullptr; // raw png / svg data, not image data
2024-03-07 04:19:38 +01:00
size_t dataLen = 0;
2024-03-11 22:01:14 +01:00
bool isSVG = false; // if true, data is just a string of chars
2024-03-07 04:19:38 +01:00
cairo_surface_t* cairoSurface = nullptr;
int side = 0;
2024-03-07 17:21:04 +01:00
int delay = 0;
2024-03-07 15:50:48 +01:00
// means this was created by resampling
void* artificialData = nullptr;
bool artificial = false;
2024-03-07 04:19:38 +01:00
};
struct SLoadedCursorShape {
std::vector<std::unique_ptr<SLoadedCursorImage>> images;
};
class CHyprcursorImplementation {
public:
2024-03-24 21:37:31 +01:00
CHyprcursorImplementation(Hyprcursor::CHyprcursorManager* mgr, PHYPRCURSORLOGFUNC fn) : owner(mgr), logFn(fn) {
;
}
Hyprcursor::CHyprcursorManager* owner = nullptr;
PHYPRCURSORLOGFUNC logFn = nullptr;
std::string themeName;
std::string themeFullDir;
2024-03-07 04:19:38 +01:00
2024-03-24 21:37:31 +01:00
SCursorTheme theme;
2024-03-07 04:19:38 +01:00
//
std::unordered_map<SCursorShape*, SLoadedCursorShape> loadedShapes;
//
2024-03-11 22:01:14 +01:00
std::optional<std::string> loadTheme();
std::vector<SLoadedCursorImage*> getFramesFor(SCursorShape* shape, int size);
2024-03-07 04:19:38 +01:00
};