Skip to content

Commit

Permalink
internal: update to hyprlang 0.2.0
Browse files Browse the repository at this point in the history
fixes #87
  • Loading branch information
vaxerski committed Jan 1, 2024
1 parent 75270a9 commit 122aaa2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-unused-value -Wno-m
find_package(Threads REQUIRED)

find_package(PkgConfig REQUIRED)
pkg_check_modules(deps REQUIRED IMPORTED_TARGET wayland-client wayland-protocols cairo pango pangocairo libjpeg libwebp)
pkg_check_modules(deps REQUIRED IMPORTED_TARGET wayland-client wayland-protocols cairo pango pangocairo libjpeg libwebp hyprlang>=0.2.0)

file(GLOB_RECURSE SRCFILES "src/*.cpp")

Expand All @@ -65,7 +65,6 @@ target_link_libraries(hyprpaper
GLESv2
pthread
magic
hyprlang
${CMAKE_THREAD_LIBS_INIT}
${CMAKE_SOURCE_DIR}/wlr-layer-shell-unstable-v1-protocol.o
${CMAKE_SOURCE_DIR}/xdg-shell-protocol.o
Expand Down
14 changes: 6 additions & 8 deletions src/Hyprpaper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void CHyprpaper::init() {

preloadAllWallpapersFromConfig();

if (std::any_cast<int64_t>(g_pConfigManager->config->getConfigValue("ipc")))
if (std::any_cast<Hyprlang::INT>(g_pConfigManager->config->getConfigValue("ipc")))
g_pIPCSocket->initialize();

// run
Expand Down Expand Up @@ -451,10 +451,8 @@ SPoolBuffer* CHyprpaper::getPoolBuffer(SMonitor* pMonitor, CWallpaperTarget* pWa
}

void CHyprpaper::renderWallpaperForMonitor(SMonitor* pMonitor) {
static auto* const PRENDERSPLASH = g_pConfigManager->config->getConfigValuePtr("splash");
static auto* const PSPLASHOFFSET = g_pConfigManager->config->getConfigValuePtr("splash_offset");
const auto RENDERSPLASH = *reinterpret_cast<int64_t*>(PRENDERSPLASH->dataPtr());
const auto SPLASHOFFSET = *reinterpret_cast<float*>(PSPLASHOFFSET->dataPtr());
static auto* const PRENDERSPLASH = reinterpret_cast<Hyprlang::INT* const*>(g_pConfigManager->config->getConfigValuePtr("splash")->getDataStaticPtr());
static auto* const PSPLASHOFFSET = reinterpret_cast<Hyprlang::FLOAT* const*>(g_pConfigManager->config->getConfigValuePtr("splash_offset")->getDataStaticPtr());
const auto PWALLPAPERTARGET = m_mMonitorActiveWallpaperTargets[pMonitor];
const auto CONTAIN = m_mMonitorWallpaperRenderData[pMonitor->name].contain;

Expand Down Expand Up @@ -513,7 +511,7 @@ void CHyprpaper::renderWallpaperForMonitor(SMonitor* pMonitor) {

cairo_paint(PCAIRO);

if (RENDERSPLASH && getenv("HYPRLAND_INSTANCE_SIGNATURE")) {
if (**PRENDERSPLASH && getenv("HYPRLAND_INSTANCE_SIGNATURE")) {
auto SPLASH = execAndGet("hyprctl splash");
SPLASH.pop_back();

Expand All @@ -529,9 +527,9 @@ void CHyprpaper::renderWallpaperForMonitor(SMonitor* pMonitor) {
cairo_text_extents_t textExtents;
cairo_text_extents(PCAIRO, SPLASH.c_str(), &textExtents);

cairo_move_to(PCAIRO, ((DIMENSIONS.x - textExtents.width * scale) / 2.0) / scale, ((DIMENSIONS.y * (100 - SPLASHOFFSET)) / 100 - textExtents.height * scale) / scale);
cairo_move_to(PCAIRO, ((DIMENSIONS.x - textExtents.width * scale) / 2.0) / scale, ((DIMENSIONS.y * (100 - **PSPLASHOFFSET)) / 100 - textExtents.height * scale) / scale);

Debug::log(LOG, "Splash font size: %d, pos: %.2f, %.2f", FONTSIZE, (DIMENSIONS.x - textExtents.width) / 2.0 / scale, ((DIMENSIONS.y * (100 - SPLASHOFFSET)) / 100 - textExtents.height * scale) / scale);
Debug::log(LOG, "Splash font size: %d, pos: %.2f, %.2f", FONTSIZE, (DIMENSIONS.x - textExtents.width) / 2.0 / scale, ((DIMENSIONS.y * (100 - **PSPLASHOFFSET)) / 100 - textExtents.height * scale) / scale);

cairo_show_text(PCAIRO, SPLASH.c_str());

Expand Down
2 changes: 1 addition & 1 deletion src/config/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ CConfigManager::CConfigManager() {

std::string configPath = getMainConfigPath();

config = std::make_unique<Hyprlang::CConfig>(configPath.c_str(), Hyprlang::SConfigOptions{});
config = std::make_unique<Hyprlang::CConfig>(configPath.c_str(), Hyprlang::SConfigOptions{.allowMissingConfig = true});

config->addConfigValue("ipc", {1L});
config->addConfigValue("splash", {1L});
Expand Down

0 comments on commit 122aaa2

Please sign in to comment.