From 972c1c27e6b057e5e891b6ae9f5b2c83bac1e087 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Thu, 23 May 2024 12:58:54 +0200 Subject: [PATCH] restore: move to runtime dir and check his fixes #346 --- src/core/hyprlock.cpp | 12 +++++++++--- src/helpers/Webp.cpp | 24 +++++++++++------------- src/renderer/Renderer.cpp | 3 ++- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/core/hyprlock.cpp b/src/core/hyprlock.cpp index ba157c5..2325666 100644 --- a/src/core/hyprlock.cpp +++ b/src/core/hyprlock.cpp @@ -1083,10 +1083,16 @@ void CHyprlock::attemptRestoreOnDeath() { if (m_bTerminate) return; - // dirty hack - uint64_t timeNowMs = std::chrono::duration_cast(std::chrono::system_clock::now() - std::chrono::system_clock::from_time_t({0})).count(); + const auto XDG_RUNTIME_DIR = getenv("XDG_RUNTIME_DIR"); + const auto HIS = getenv("HYPRLAND_INSTANCE_SIGNATURE"); - constexpr const char* LASTRESTARTPATH = "/tmp/hypr/.hyprlockrestart"; + if (!XDG_RUNTIME_DIR || !HIS) + return; + + // dirty hack + uint64_t timeNowMs = std::chrono::duration_cast(std::chrono::system_clock::now() - std::chrono::system_clock::from_time_t({0})).count(); + + const auto LASTRESTARTPATH = std::string{XDG_RUNTIME_DIR} + "/.hyprlockrestart"; if (std::filesystem::exists(LASTRESTARTPATH)) { std::ifstream ifs(LASTRESTARTPATH); diff --git a/src/helpers/Webp.cpp b/src/helpers/Webp.cpp index 08d1ada..c42047f 100644 --- a/src/helpers/Webp.cpp +++ b/src/helpers/Webp.cpp @@ -15,11 +15,11 @@ cairo_surface_t* WEBP::createSurfaceFromWEBP(const std::filesystem::path& path) return nullptr; } - void* imageRawData; + void* imageRawData; struct stat fileInfo = {}; - const auto FD = open(path.c_str(), O_RDONLY); + const auto FD = open(path.c_str(), O_RDONLY); fstat(FD, &fileInfo); @@ -43,32 +43,31 @@ cairo_surface_t* WEBP::createSurfaceFromWEBP(const std::filesystem::path& path) } const auto HEIGHT = config.input.height; - const auto WIDTH = config.input.width; + const auto WIDTH = config.input.width; - auto cairoSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, WIDTH, HEIGHT); + auto cairoSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, WIDTH, HEIGHT); if (cairo_surface_status(cairoSurface) != CAIRO_STATUS_SUCCESS) { Debug::log(CRIT, "createSurfaceFromWEBP: Cairo Failed (?)"); cairo_surface_destroy(cairoSurface); return nullptr; } - #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ config.output.colorspace = MODE_bgrA; #else config.output.colorspace = MODE_Argb; #endif - const auto CAIRODATA = cairo_image_surface_get_data(cairoSurface); + const auto CAIRODATA = cairo_image_surface_get_data(cairoSurface); const auto CAIROSTRIDE = cairo_image_surface_get_stride(cairoSurface); config.options.no_fancy_upsampling = 1; - config.output.u.RGBA.rgba = CAIRODATA; - config.output.u.RGBA.stride = CAIROSTRIDE; - config.output.u.RGBA.size = CAIROSTRIDE * HEIGHT; - config.output.is_external_memory = 1; - config.output.width = WIDTH; - config.output.height = HEIGHT; + config.output.u.RGBA.rgba = CAIRODATA; + config.output.u.RGBA.stride = CAIROSTRIDE; + config.output.u.RGBA.size = CAIROSTRIDE * HEIGHT; + config.output.is_external_memory = 1; + config.output.width = WIDTH; + config.output.height = HEIGHT; if (WebPDecode((const unsigned char*)imageRawData, fileInfo.st_size, &config) != VP8_STATUS_OK) { Debug::log(CRIT, "createSurfaceFromWEBP: WebP Decode Failed (?)"); @@ -81,5 +80,4 @@ cairo_surface_t* WEBP::createSurfaceFromWEBP(const std::filesystem::path& path) WebPFreeDecBuffer(&config.output); return cairoSurface; - } diff --git a/src/renderer/Renderer.cpp b/src/renderer/Renderer.cpp index 463f353..08a15c9 100644 --- a/src/renderer/Renderer.cpp +++ b/src/renderer/Renderer.cpp @@ -204,7 +204,8 @@ CRenderer::SRenderFeedback CRenderer::renderLock(const CSessionLockSurface& surf bga = 1.0; if (g_pHyprlock->m_bFadeStarted && !**PNOFADEOUT) { - bga = std::clamp(std::chrono::duration_cast(g_pHyprlock->m_tFadeEnds - std::chrono::system_clock::now()).count() / 500000.0 - 0.02, 0.0, 1.0); + bga = + std::clamp(std::chrono::duration_cast(g_pHyprlock->m_tFadeEnds - std::chrono::system_clock::now()).count() / 500000.0 - 0.02, 0.0, 1.0); // - 0.02 so that the fade ends a little earlier than the final second } // render widgets