core: formatting and small fixes

This commit is contained in:
Vaxry 2024-03-07 17:51:14 +00:00
parent ceecc4e7da
commit d1dcce9a00
3 changed files with 20 additions and 11 deletions

View file

@ -21,7 +21,6 @@ namespace Hyprcursor {
unsigned int size = 0;
};
/*!
struct for cursor shape data
*/
@ -78,6 +77,8 @@ namespace Hyprcursor {
image.delay = images[i]->delay;
image.size = images[i]->size;
image.surface = images[i]->surface;
image.hotspotX = images[i]->hotspotX;
image.hotspotY = images[i]->hotspotY;
data.images.push_back(image);
free(images[i]);

View file

@ -10,6 +10,8 @@ struct SCursorImageData {
cairo_surface_t* surface;
int size;
int delay;
int hotspotX;
int hotspotY;
};
typedef struct SCursorImageData hyprcursor_cursor_image_data;

View file

@ -166,11 +166,15 @@ SCursorImageData** CHyprcursorManager::getShapesC(int& outSize, const char* shap
std::string REQUESTEDSHAPE = shape_;
std::vector<SLoadedCursorImage*> resultingImages;
float hotX = 0, hotY = 0;
for (auto& shape : impl->theme.shapes) {
if (REQUESTEDSHAPE != shape->directory && std::find(shape->overrides.begin(), shape->overrides.end(), REQUESTEDSHAPE) == shape->overrides.end())
continue;
hotX = shape->hotspotX;
hotY = shape->hotspotY;
// matched :)
bool foundAny = false;
for (auto& image : impl->loadedShapes[shape.get()].images) {
@ -229,6 +233,8 @@ SCursorImageData** CHyprcursorManager::getShapesC(int& outSize, const char* shap
data[i]->delay = resultingImages[i]->delay;
data[i]->size = resultingImages[i]->side;
data[i]->surface = resultingImages[i]->cairoSurface;
data[i]->hotspotX = hotX * data[i]->size;
data[i]->hotspotY = hotY * data[i]->size;
}
outSize = resultingImages.size();