Skip to content

Commit

Permalink
tests: fixup C test override checking
Browse files Browse the repository at this point in the history
  • Loading branch information
vaxerski committed Oct 1, 2024
1 parent 34efe23 commit 8060e64
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
7 changes: 5 additions & 2 deletions libhyprcursor/hyprcursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
13 changes: 12 additions & 1 deletion tests/c_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 8060e64

Please sign in to comment.