New upstream version 0.1.5

This commit is contained in:
alan (NyxTrail) 2024-03-25 19:18:26 +00:00
parent dbdc288df3
commit e1ad3198ee
5 changed files with 50 additions and 22 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.19) 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}") add_compile_definitions(HYPRCURSOR_VERSION="${HYPRCURSOR_VERSION}")
project(hyprcursor project(hyprcursor
@ -20,7 +20,7 @@ configure_file(hyprcursor.pc.in hyprcursor.pc @ONLY)
set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD 23)
find_package(PkgConfig REQUIRED) 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) if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
message(STATUS "Configuring hyprcursor in Debug") message(STATUS "Configuring hyprcursor in Debug")
@ -48,7 +48,9 @@ target_link_libraries(hyprcursor PkgConfig::deps)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# for std::expected. # for std::expected.
# probably evil. Arch's clang is very outdated tho... # 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
$<$<COMPILE_LANGUAGE:CXX>:-std=gnu++2b -D__cpp_concepts=202002L>
-Wno-builtin-macro-redefined)
endif() endif()
# hyprcursor-util # 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) add_dependencies(tests hyprcursor_test_c)
# Installation # Installation
install(DIRECTORY "include/hyprcursor" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} DIRECTORY_PERMISSIONS install(DIRECTORY "include/hyprcursor" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
OWNER_WRITE OWNER_READ OWNER_EXECUTE
GROUP_WRITE GROUP_READ GROUP_EXECUTE
WORLD_WRITE WORLD_READ WORLD_EXECUTE)
install(FILES ${CMAKE_BINARY_DIR}/hyprcursor.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) install(FILES ${CMAKE_BINARY_DIR}/hyprcursor.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)

View File

@ -342,7 +342,7 @@ static std::optional<std::string> extractXTheme(const std::string& xpath_, const
std::cout << "Found xcursor " << xcursor.path().stem().string() << "\n"; std::cout << "Found xcursor " << xcursor.path().stem().string() << "\n";
// decompile xcursor // 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())); std::filesystem::canonical(xcursor.path()).string()));
// read the config // read the config

View File

@ -99,13 +99,31 @@ static std::string getFullPathForThemeName(const std::string& name) {
if (!themeDir.is_directory()) if (!themeDir.is_directory())
continue; continue;
if (!name.empty() && themeDir.path().stem().string() != name)
continue;
const auto MANIFESTPATH = themeDir.path().string() + "/manifest.hl"; const auto MANIFESTPATH = themeDir.path().string() + "/manifest.hl";
if (std::filesystem::exists(MANIFESTPATH)) if (name.empty()) {
return std::filesystem::canonical(themeDir.path()).string(); if (std::filesystem::exists(MANIFESTPATH))
return std::filesystem::canonical(themeDir.path()).string();
continue;
}
if (!std::filesystem::exists(MANIFESTPATH))
continue;
std::unique_ptr<Hyprlang::CConfig> manifest;
try {
manifest = std::make_unique<Hyprlang::CConfig>(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<Hyprlang::STRING>(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; image.filename = RHS;
try { if (!image.filename.ends_with(".svg")) {
image.size = std::stoull(LHS); try {
} catch (std::exception& e) { image.size = std::stoull(LHS);
result.setError(e.what()); } catch (std::exception& e) {
return result; result.setError(e.what());
} return result;
}
} else
image.size = 0;
currentTheme->shapes.back()->images.push_back(image); 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; 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; DATA->readNeedle += toRead;
if (DATA->readNeedle >= DATA->dataLen) { if (DATA->readNeedle >= DATA->dataLen) {
@ -615,7 +636,7 @@ std::optional<std::string> CHyprcursorImplementation::loadTheme() {
// load image // load image
Debug::log(TRACE, "Loading {} for shape {}", i.filename, cursor.path().stem().string()); Debug::log(TRACE, "Loading {} for shape {}", i.filename, cursor.path().stem().string());
auto* IMAGE = LOADEDSHAPE.images.emplace_back(std::make_unique<SLoadedCursorImage>()).get(); auto* IMAGE = LOADEDSHAPE.images.emplace_back(std::make_unique<SLoadedCursorImage>()).get();
IMAGE->side = i.size; IMAGE->side = SHAPE->shapeType == SHAPE_SVG ? 0 : i.size;
IMAGE->delay = i.delay; IMAGE->delay = i.delay;
IMAGE->isSVG = SHAPE->shapeType == SHAPE_SVG; IMAGE->isSVG = SHAPE->shapeType == SHAPE_SVG;

View File

@ -9,6 +9,10 @@ int main(int argc, char** argv) {
printf("mgr null\n"); printf("mgr null\n");
return 1; return 1;
} }
if (!hyprcursor_manager_valid(mgr)) {
printf("mgr is invalid\n");
return 1;
}
struct hyprcursor_cursor_style_info info = {.size = 48}; struct hyprcursor_cursor_style_info info = {.size = 48};
if (!hyprcursor_load_theme_style(mgr, info)) { if (!hyprcursor_load_theme_style(mgr, info)) {

View File

@ -4,8 +4,12 @@
int main(int argc, char** argv) { int main(int argc, char** argv) {
Hyprcursor::CHyprcursorManager mgr(nullptr); 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 // preload size 48 for testing
if (!mgr.loadThemeStyle(style)) { if (!mgr.loadThemeStyle(style)) {
std::cout << "failed loading style\n"; std::cout << "failed loading style\n";