mirror of
https://github.com/hyprwm/hyprlock.git
synced 2024-12-22 13:29:48 +01:00
parent
ba4b08e5f5
commit
972c1c27e6
3 changed files with 22 additions and 17 deletions
|
@ -1083,10 +1083,16 @@ void CHyprlock::attemptRestoreOnDeath() {
|
||||||
if (m_bTerminate)
|
if (m_bTerminate)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// dirty hack
|
const auto XDG_RUNTIME_DIR = getenv("XDG_RUNTIME_DIR");
|
||||||
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 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)) {
|
if (std::filesystem::exists(LASTRESTARTPATH)) {
|
||||||
std::ifstream ifs(LASTRESTARTPATH);
|
std::ifstream ifs(LASTRESTARTPATH);
|
||||||
|
|
|
@ -15,11 +15,11 @@ cairo_surface_t* WEBP::createSurfaceFromWEBP(const std::filesystem::path& path)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* imageRawData;
|
void* imageRawData;
|
||||||
|
|
||||||
struct stat fileInfo = {};
|
struct stat fileInfo = {};
|
||||||
|
|
||||||
const auto FD = open(path.c_str(), O_RDONLY);
|
const auto FD = open(path.c_str(), O_RDONLY);
|
||||||
|
|
||||||
fstat(FD, &fileInfo);
|
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 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) {
|
if (cairo_surface_status(cairoSurface) != CAIRO_STATUS_SUCCESS) {
|
||||||
Debug::log(CRIT, "createSurfaceFromWEBP: Cairo Failed (?)");
|
Debug::log(CRIT, "createSurfaceFromWEBP: Cairo Failed (?)");
|
||||||
cairo_surface_destroy(cairoSurface);
|
cairo_surface_destroy(cairoSurface);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||||
config.output.colorspace = MODE_bgrA;
|
config.output.colorspace = MODE_bgrA;
|
||||||
#else
|
#else
|
||||||
config.output.colorspace = MODE_Argb;
|
config.output.colorspace = MODE_Argb;
|
||||||
#endif
|
#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);
|
const auto CAIROSTRIDE = cairo_image_surface_get_stride(cairoSurface);
|
||||||
|
|
||||||
config.options.no_fancy_upsampling = 1;
|
config.options.no_fancy_upsampling = 1;
|
||||||
config.output.u.RGBA.rgba = CAIRODATA;
|
config.output.u.RGBA.rgba = CAIRODATA;
|
||||||
config.output.u.RGBA.stride = CAIROSTRIDE;
|
config.output.u.RGBA.stride = CAIROSTRIDE;
|
||||||
config.output.u.RGBA.size = CAIROSTRIDE * HEIGHT;
|
config.output.u.RGBA.size = CAIROSTRIDE * HEIGHT;
|
||||||
config.output.is_external_memory = 1;
|
config.output.is_external_memory = 1;
|
||||||
config.output.width = WIDTH;
|
config.output.width = WIDTH;
|
||||||
config.output.height = HEIGHT;
|
config.output.height = HEIGHT;
|
||||||
|
|
||||||
if (WebPDecode((const unsigned char*)imageRawData, fileInfo.st_size, &config) != VP8_STATUS_OK) {
|
if (WebPDecode((const unsigned char*)imageRawData, fileInfo.st_size, &config) != VP8_STATUS_OK) {
|
||||||
Debug::log(CRIT, "createSurfaceFromWEBP: WebP Decode Failed (?)");
|
Debug::log(CRIT, "createSurfaceFromWEBP: WebP Decode Failed (?)");
|
||||||
|
@ -81,5 +80,4 @@ cairo_surface_t* WEBP::createSurfaceFromWEBP(const std::filesystem::path& path)
|
||||||
WebPFreeDecBuffer(&config.output);
|
WebPFreeDecBuffer(&config.output);
|
||||||
|
|
||||||
return cairoSurface;
|
return cairoSurface;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -204,7 +204,8 @@ CRenderer::SRenderFeedback CRenderer::renderLock(const CSessionLockSurface& surf
|
||||||
bga = 1.0;
|
bga = 1.0;
|
||||||
|
|
||||||
if (g_pHyprlock->m_bFadeStarted && !**PNOFADEOUT) {
|
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
|
// - 0.02 so that the fade ends a little earlier than the final second
|
||||||
}
|
}
|
||||||
// render widgets
|
// render widgets
|
||||||
|
|
Loading…
Reference in a new issue