From 8060e645df769fb7d5757830271f268fa4dcd4a6 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Tue, 1 Oct 2024 23:25:32 +0100 Subject: [PATCH] tests: fixup C test override checking --- libhyprcursor/hyprcursor.cpp | 7 +++++-- tests/c_test.c | 13 ++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/libhyprcursor/hyprcursor.cpp b/libhyprcursor/hyprcursor.cpp index f7fb82c..544a506 100644 --- a/libhyprcursor/hyprcursor.cpp +++ b/libhyprcursor/hyprcursor.cpp @@ -399,11 +399,14 @@ SCursorRawShapeDataC* CHyprcursorManager::getRawShapeDataC(const char* shape_) { for (auto& shape : impl->theme.shapes) { // if it's overridden just return the override - if (const auto IT = std::find(shape->overrides.begin(), shape->overrides.end(), SHAPE); IT != shape->overrides.end()) { - data->overridenBy = strdup(IT->c_str()); + if (const auto IT = std::find_if(shape->overrides.begin(), shape->overrides.end(), [&](const auto& e) { return e == SHAPE && SHAPE != shape->directory; }); + IT != shape->overrides.end()) { + data->overridenBy = strdup(shape->directory.c_str()); return data; } + } + for (auto& shape : impl->theme.shapes) { if (shape->directory != SHAPE) continue; diff --git a/tests/c_test.c b/tests/c_test.c index 7561fd0..9b975b9 100644 --- a/tests/c_test.c +++ b/tests/c_test.c @@ -27,11 +27,22 @@ int main(int argc, char** argv) { } hyprcursor_cursor_raw_shape_data* shapeData = hyprcursor_get_raw_shape_data(mgr, "left_ptr"); - if (!shapeData || shapeData->len <= 0) { + if (!shapeData) { printf("failed querying left_ptr\n"); return 1; } + if (shapeData->overridenBy) { + hyprcursor_cursor_raw_shape_data* ov = hyprcursor_get_raw_shape_data(mgr, shapeData->overridenBy); + hyprcursor_raw_shape_data_free(shapeData); + shapeData = ov; + } + + if (!shapeData || shapeData->len <= 0) { + printf("left_ptr has no images\n"); + return 1; + } + printf("left_ptr images: %d\n", shapeData->len); for (size_t i = 0; i < shapeData->len; ++i) {