restore: move to runtime dir and check his

fixes #346
This commit is contained in:
Vaxry 2024-05-23 12:58:54 +02:00
parent ba4b08e5f5
commit 972c1c27e6
3 changed files with 22 additions and 17 deletions

View file

@ -1083,10 +1083,16 @@ void CHyprlock::attemptRestoreOnDeath() {
if (m_bTerminate)
return;
// dirty hack
uint64_t timeNowMs = std::chrono::duration_cast<std::chrono::milliseconds>(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::milliseconds>(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);

View file

@ -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;
}

View file

@ -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<std::chrono::microseconds>(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<std::chrono::microseconds>(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