diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d1872e..a5362c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.19) -set(HYPRCURSOR_VERSION "0.1.4") +set(HYPRCURSOR_VERSION "0.1.5") add_compile_definitions(HYPRCURSOR_VERSION="${HYPRCURSOR_VERSION}") project(hyprcursor @@ -20,7 +20,7 @@ configure_file(hyprcursor.pc.in hyprcursor.pc @ONLY) set(CMAKE_CXX_STANDARD 23) find_package(PkgConfig REQUIRED) -pkg_check_modules(deps REQUIRED IMPORTED_TARGET hyprlang>=0.4.0 libzip cairo librsvg-2.0) +pkg_check_modules(deps REQUIRED IMPORTED_TARGET hyprlang>=0.4.2 libzip cairo librsvg-2.0) if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG) message(STATUS "Configuring hyprcursor in Debug") @@ -48,7 +48,9 @@ target_link_libraries(hyprcursor PkgConfig::deps) if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") # for std::expected. # probably evil. Arch's clang is very outdated tho... - target_compile_options(hyprcursor PUBLIC -std=gnu++2b -D__cpp_concepts=202002L -Wno-macro-redefined) + target_compile_options(hyprcursor PUBLIC + $<$:-std=gnu++2b -D__cpp_concepts=202002L> + -Wno-builtin-macro-redefined) endif() # hyprcursor-util @@ -70,8 +72,5 @@ add_test(NAME "Test libhyprcursor in C" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/te add_dependencies(tests hyprcursor_test_c) # Installation -install(DIRECTORY "include/hyprcursor" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} DIRECTORY_PERMISSIONS - OWNER_WRITE OWNER_READ OWNER_EXECUTE - GROUP_WRITE GROUP_READ GROUP_EXECUTE - WORLD_WRITE WORLD_READ WORLD_EXECUTE) +install(DIRECTORY "include/hyprcursor" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) install(FILES ${CMAKE_BINARY_DIR}/hyprcursor.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) diff --git a/hyprcursor-util/src/main.cpp b/hyprcursor-util/src/main.cpp index 6a622b4..f219380 100644 --- a/hyprcursor-util/src/main.cpp +++ b/hyprcursor-util/src/main.cpp @@ -342,7 +342,7 @@ static std::optional extractXTheme(const std::string& xpath_, const std::cout << "Found xcursor " << xcursor.path().stem().string() << "\n"; // decompile xcursor - const auto OUT = spawnSync(std::format("rm -f /tmp/hyprcursor-util/* && cd /tmp/hyprcursor-util && xcur2png {} -d /tmp/hyprcursor-util 2>&1", + const auto OUT = spawnSync(std::format("rm -f /tmp/hyprcursor-util/* && cd /tmp/hyprcursor-util && xcur2png '{}' -d /tmp/hyprcursor-util 2>&1", std::filesystem::canonical(xcursor.path()).string())); // read the config diff --git a/libhyprcursor/hyprcursor.cpp b/libhyprcursor/hyprcursor.cpp index 6e5bb0c..d0f8a22 100644 --- a/libhyprcursor/hyprcursor.cpp +++ b/libhyprcursor/hyprcursor.cpp @@ -99,13 +99,31 @@ static std::string getFullPathForThemeName(const std::string& name) { if (!themeDir.is_directory()) continue; - if (!name.empty() && themeDir.path().stem().string() != name) - continue; - const auto MANIFESTPATH = themeDir.path().string() + "/manifest.hl"; - if (std::filesystem::exists(MANIFESTPATH)) - return std::filesystem::canonical(themeDir.path()).string(); + if (name.empty()) { + if (std::filesystem::exists(MANIFESTPATH)) + return std::filesystem::canonical(themeDir.path()).string(); + continue; + } + + if (!std::filesystem::exists(MANIFESTPATH)) + continue; + + std::unique_ptr manifest; + try { + manifest = std::make_unique(MANIFESTPATH.c_str(), Hyprlang::SConfigOptions{}); + manifest->addConfigValue("name", Hyprlang::STRING{""}); + manifest->commence(); + manifest->parse(); + } catch (const char* e) { continue; } + + const std::string NAME = std::any_cast(manifest->getConfigValue("name")); + + if (NAME != name) + continue; + + return std::filesystem::canonical(themeDir.path()).string(); } } @@ -473,12 +491,15 @@ static Hyprlang::CParseResult parseDefineSize(const char* C, const char* V) { image.filename = RHS; - try { - image.size = std::stoull(LHS); - } catch (std::exception& e) { - result.setError(e.what()); - return result; - } + if (!image.filename.ends_with(".svg")) { + try { + image.size = std::stoull(LHS); + } catch (std::exception& e) { + result.setError(e.what()); + return result; + } + } else + image.size = 0; currentTheme->shapes.back()->images.push_back(image); @@ -508,7 +529,7 @@ static cairo_status_t readPNG(void* data, unsigned char* output, unsigned int le size_t toRead = len > DATA->dataLen - DATA->readNeedle ? DATA->dataLen - DATA->readNeedle : len; - std::memcpy(output, DATA->data + DATA->readNeedle, toRead); + std::memcpy(output, (uint8_t*)DATA->data + DATA->readNeedle, toRead); DATA->readNeedle += toRead; if (DATA->readNeedle >= DATA->dataLen) { @@ -615,7 +636,7 @@ std::optional CHyprcursorImplementation::loadTheme() { // load image Debug::log(TRACE, "Loading {} for shape {}", i.filename, cursor.path().stem().string()); auto* IMAGE = LOADEDSHAPE.images.emplace_back(std::make_unique()).get(); - IMAGE->side = i.size; + IMAGE->side = SHAPE->shapeType == SHAPE_SVG ? 0 : i.size; IMAGE->delay = i.delay; IMAGE->isSVG = SHAPE->shapeType == SHAPE_SVG; diff --git a/tests/test.c b/tests/test.c index 749fbd3..d5fa80a 100644 --- a/tests/test.c +++ b/tests/test.c @@ -9,6 +9,10 @@ int main(int argc, char** argv) { printf("mgr null\n"); return 1; } + if (!hyprcursor_manager_valid(mgr)) { + printf("mgr is invalid\n"); + return 1; + } struct hyprcursor_cursor_style_info info = {.size = 48}; if (!hyprcursor_load_theme_style(mgr, info)) { diff --git a/tests/test.cpp b/tests/test.cpp index 155f120..95377d7 100644 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -4,8 +4,12 @@ int main(int argc, char** argv) { Hyprcursor::CHyprcursorManager mgr(nullptr); - Hyprcursor::SCursorStyleInfo style{.size = 48}; + if (!mgr.valid()) { + std::cout << "mgr is invalid\n"; + return 1; + } + Hyprcursor::SCursorStyleInfo style{.size = 48}; // preload size 48 for testing if (!mgr.loadThemeStyle(style)) { std::cout << "failed loading style\n";