hyprcursor/libhyprcursor/hyprcursor_c.cpp

74 lines
2.4 KiB
C++
Raw Permalink Normal View History

2024-03-07 17:36:26 +01:00
#include "hyprcursor/hyprcursor.h"
#include "hyprcursor/hyprcursor.hpp"
2024-03-07 04:19:38 +01:00
using namespace Hyprcursor;
hyprcursor_manager_t* hyprcursor_manager_create(const char* theme_name) {
return (hyprcursor_manager_t*)new CHyprcursorManager(theme_name);
}
2024-03-24 21:37:31 +01:00
hyprcursor_manager_t* hyprcursor_manager_create_with_logger(const char* theme_name, PHYPRCURSORLOGFUNC fn) {
return (hyprcursor_manager_t*)new CHyprcursorManager(theme_name, fn);
}
2024-03-07 04:19:38 +01:00
void hyprcursor_manager_free(hyprcursor_manager_t* manager) {
delete (CHyprcursorManager*)manager;
}
2024-03-07 16:10:45 +01:00
int hyprcursor_manager_valid(hyprcursor_manager_t* manager) {
2024-03-07 04:19:38 +01:00
const auto MGR = (CHyprcursorManager*)manager;
return MGR->valid();
2024-03-07 16:10:45 +01:00
}
int hyprcursor_load_theme_style(hyprcursor_manager_t* manager, hyprcursor_cursor_style_info info_) {
const auto MGR = (CHyprcursorManager*)manager;
SCursorStyleInfo info;
info.size = info_.size;
return MGR->loadThemeStyle(info);
}
2024-03-07 17:01:45 +01:00
struct SCursorImageData** hyprcursor_get_cursor_image_data(struct hyprcursor_manager_t* manager, const char* shape, struct hyprcursor_cursor_style_info info_, int* out_size) {
2024-03-07 16:10:45 +01:00
const auto MGR = (CHyprcursorManager*)manager;
SCursorStyleInfo info;
2024-03-07 17:21:04 +01:00
info.size = info_.size;
int size = 0;
2024-03-07 17:01:45 +01:00
struct SCursorImageData** data = MGR->getShapesC(size, shape, info);
2024-03-07 17:21:04 +01:00
*out_size = size;
2024-03-07 17:01:45 +01:00
return data;
}
void hyprcursor_cursor_image_data_free(hyprcursor_cursor_image_data** data, int size) {
for (size_t i = 0; i < size; ++i) {
free(data[i]);
}
free(data);
2024-03-07 16:10:45 +01:00
}
void hyprcursor_style_done(hyprcursor_manager_t* manager, hyprcursor_cursor_style_info info_) {
const auto MGR = (CHyprcursorManager*)manager;
SCursorStyleInfo info;
info.size = info_.size;
return MGR->cursorSurfaceStyleDone(info);
2024-03-24 21:37:31 +01:00
}
void hyprcursor_register_logging_function(struct hyprcursor_manager_t* manager, PHYPRCURSORLOGFUNC fn) {
const auto MGR = (CHyprcursorManager*)manager;
MGR->registerLoggingFunction(fn);
}
CAPI hyprcursor_cursor_raw_shape_data* hyprcursor_get_raw_shape_data(struct hyprcursor_manager_t* manager, char* shape) {
const auto MGR = (CHyprcursorManager*)manager;
return MGR->getRawShapeDataC(shape);
}
CAPI void hyprcursor_raw_shape_data_free(hyprcursor_cursor_raw_shape_data* data) {
if (data->overridenBy) {
free(data->overridenBy);
delete data;
return;
}
delete[] data->images;
delete data;
}