mirror of
https://github.com/hyprwm/hyprlock.git
synced 2025-05-16 15:20:40 +01:00
widgets: use absolutePath to get last_write_time and ignore when no reloadTime (#615)
* image: use absolutePath to get last_write_time and ignore when no reloadTime * background: use absolutePath to get last_write_time and ignore when no reloadTime
This commit is contained in:
parent
90bc9764f1
commit
181294c4d8
2 changed files with 20 additions and 16 deletions
|
@ -1,7 +1,8 @@
|
||||||
#include "Background.hpp"
|
#include "Background.hpp"
|
||||||
#include "../Renderer.hpp"
|
#include "../Renderer.hpp"
|
||||||
#include "../../core/hyprlock.hpp"
|
#include "../../core/hyprlock.hpp"
|
||||||
#include "src/helpers/Log.hpp"
|
#include "../../helpers/Log.hpp"
|
||||||
|
#include "../../helpers/MiscFunctions.hpp"
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <hyprlang.hpp>
|
#include <hyprlang.hpp>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
@ -39,7 +40,7 @@ CBackground::CBackground(const Vector2D& viewport_, COutput* output_, const std:
|
||||||
path = std::any_cast<Hyprlang::STRING>(props.at("path"));
|
path = std::any_cast<Hyprlang::STRING>(props.at("path"));
|
||||||
reloadCommand = std::any_cast<Hyprlang::STRING>(props.at("reload_cmd"));
|
reloadCommand = std::any_cast<Hyprlang::STRING>(props.at("reload_cmd"));
|
||||||
reloadTime = std::any_cast<Hyprlang::INT>(props.at("reload_time"));
|
reloadTime = std::any_cast<Hyprlang::INT>(props.at("reload_time"));
|
||||||
crossFadeTime = std::any_cast<Hyprlang::FLOAT>(props.at("crossfade_time"));
|
crossFadeTime = std::any_cast<Hyprlang::FLOAT>(props.at("crossfade_time"));
|
||||||
|
|
||||||
} catch (const std::bad_any_cast& e) {
|
} catch (const std::bad_any_cast& e) {
|
||||||
RASSERT(false, "Failed to construct CBackground: {}", e.what()); //
|
RASSERT(false, "Failed to construct CBackground: {}", e.what()); //
|
||||||
|
@ -47,12 +48,13 @@ CBackground::CBackground(const Vector2D& viewport_, COutput* output_, const std:
|
||||||
RASSERT(false, "Missing propperty for CBackground: {}", e.what()); //
|
RASSERT(false, "Missing propperty for CBackground: {}", e.what()); //
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
if (!isScreenshot && reloadTime > -1) {
|
||||||
modificationTime = std::filesystem::last_write_time(path);
|
try {
|
||||||
} catch (std::exception& e) { Debug::log(ERR, "{}", e.what()); }
|
modificationTime = std::filesystem::last_write_time(absolutePath(path, ""));
|
||||||
|
} catch (std::exception& e) { Debug::log(ERR, "{}", e.what()); }
|
||||||
|
|
||||||
if (!isScreenshot)
|
|
||||||
plantReloadTimer(); // No reloads for screenshots.
|
plantReloadTimer(); // No reloads for screenshots.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBackground::renderRect(CColor color) {
|
void CBackground::renderRect(CColor color) {
|
||||||
|
@ -139,15 +141,14 @@ bool CBackground::draw(const SRenderData& data) {
|
||||||
|
|
||||||
if (fade)
|
if (fade)
|
||||||
g_pRenderer->renderTextureMix(texbox, asset->texture, pendingAsset->texture, 1.0,
|
g_pRenderer->renderTextureMix(texbox, asset->texture, pendingAsset->texture, 1.0,
|
||||||
std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - fade->start).count() / (1000 * crossFadeTime),
|
std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - fade->start).count() / (1000 * crossFadeTime), 0,
|
||||||
0, HYPRUTILS_TRANSFORM_NORMAL);
|
HYPRUTILS_TRANSFORM_NORMAL);
|
||||||
else
|
else
|
||||||
g_pRenderer->renderTexture(texbox, asset->texture, 1.0, 0,
|
g_pRenderer->renderTexture(texbox, asset->texture, 1.0, 0,
|
||||||
isScreenshot ?
|
isScreenshot ?
|
||||||
wlTransformToHyprutils(invertTransform(output->transform)) :
|
wlTransformToHyprutils(invertTransform(output->transform)) :
|
||||||
HYPRUTILS_TRANSFORM_NORMAL); // this could be omitted but whatever it's only once and makes code cleaner plus less blurring on large texs
|
HYPRUTILS_TRANSFORM_NORMAL); // this could be omitted but whatever it's only once and makes code cleaner plus less blurring on large texs
|
||||||
|
|
||||||
|
|
||||||
if (blurPasses > 0)
|
if (blurPasses > 0)
|
||||||
g_pRenderer->blurFB(blurredFB, CRenderer::SBlurParams{blurSize, blurPasses, noise, contrast, brightness, vibrancy, vibrancy_darkness});
|
g_pRenderer->blurFB(blurredFB, CRenderer::SBlurParams{blurSize, blurPasses, noise, contrast, brightness, vibrancy, vibrancy_darkness});
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||||
|
@ -222,7 +223,7 @@ void CBackground::onReloadTimerUpdate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const auto MTIME = std::filesystem::last_write_time(path);
|
const auto MTIME = std::filesystem::last_write_time(absolutePath(path, ""));
|
||||||
if (OLDPATH == path && MTIME == modificationTime)
|
if (OLDPATH == path && MTIME == modificationTime)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include "../Renderer.hpp"
|
#include "../Renderer.hpp"
|
||||||
#include "../../core/hyprlock.hpp"
|
#include "../../core/hyprlock.hpp"
|
||||||
#include "../../helpers/Log.hpp"
|
#include "../../helpers/Log.hpp"
|
||||||
|
#include "../../helpers/MiscFunctions.hpp"
|
||||||
#include "../../config/ConfigDataValues.hpp"
|
#include "../../config/ConfigDataValues.hpp"
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <hyprlang.hpp>
|
#include <hyprlang.hpp>
|
||||||
|
@ -46,7 +47,7 @@ void CImage::onTimerUpdate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const auto MTIME = std::filesystem::last_write_time(path);
|
const auto MTIME = std::filesystem::last_write_time(absolutePath(path, ""));
|
||||||
if (OLDPATH == path && MTIME == modificationTime)
|
if (OLDPATH == path && MTIME == modificationTime)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -101,13 +102,15 @@ CImage::CImage(const Vector2D& viewport_, COutput* output_, const std::string& r
|
||||||
RASSERT(false, "Missing propperty for CImage: {}", e.what()); //
|
RASSERT(false, "Missing propperty for CImage: {}", e.what()); //
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
modificationTime = std::filesystem::last_write_time(path);
|
|
||||||
} catch (std::exception& e) { Debug::log(ERR, "{}", e.what()); }
|
|
||||||
|
|
||||||
angle = angle * M_PI / 180.0;
|
angle = angle * M_PI / 180.0;
|
||||||
|
|
||||||
plantTimer();
|
if (reloadTime > -1) {
|
||||||
|
try {
|
||||||
|
modificationTime = std::filesystem::last_write_time(absolutePath(path, ""));
|
||||||
|
} catch (std::exception& e) { Debug::log(ERR, "{}", e.what()); }
|
||||||
|
|
||||||
|
plantTimer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CImage::draw(const SRenderData& data) {
|
bool CImage::draw(const SRenderData& data) {
|
||||||
|
|
Loading…
Reference in a new issue