diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d055a8..42f45ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,11 +88,15 @@ pkg_check_modules( gbm hyprutils>=0.11.0 sdbus-c++>=2.0.0 - hyprgraphics>=0.1.6 - libavcodec - libavformat - libavutil - libswscale) + hyprgraphics>=0.1.6) + +option(VIDEO_BACKEND "Enable video background support via FFmpeg" ON) +if(VIDEO_BACKEND) + pkg_check_modules(ffmpeg REQUIRED IMPORTED_TARGET libavcodec libavformat libavutil libswscale) + message(STATUS "Video backend: enabled") +else() + message(STATUS "Video backend: disabled") +endif() find_library(PAM_FOUND NAMES pam libpam) if(PAM_FOUND) set(PAM_LIB ${PAM_FOUND}) @@ -108,10 +112,20 @@ endif() message(STATUS "Found pam at ${PAM_LIB}") file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp") + +if(NOT VIDEO_BACKEND) + list(FILTER SRCFILES EXCLUDE REGEX ".*/VideoBackend\\.cpp$") +endif() + add_executable(hyprlock ${SRCFILES}) target_link_libraries(hyprlock PRIVATE ${PAM_LIB} rt Threads::Threads PkgConfig::deps OpenGL::EGL OpenGL::GLES3) +if(VIDEO_BACKEND) + target_compile_definitions(hyprlock PRIVATE HYPRLOCK_HAS_VIDEO) + target_link_libraries(hyprlock PRIVATE PkgConfig::ffmpeg) +endif() + # protocols pkg_get_variable(WAYLAND_PROTOCOLS_DIR wayland-protocols pkgdatadir) message(STATUS "Found wayland-protocols at ${WAYLAND_PROTOCOLS_DIR}") diff --git a/src/renderer/widgets/Background.cpp b/src/renderer/widgets/Background.cpp index df1ffcd..e3015c1 100644 --- a/src/renderer/widgets/Background.cpp +++ b/src/renderer/widgets/Background.cpp @@ -87,6 +87,7 @@ void CBackground::configure(const std::unordered_map& pro resourceID = 0; } } else if (!path.empty()) { +#ifdef HYPRLOCK_HAS_VIDEO if (CVideoBackend::isVideoFile(path)) { m_videoBackend = makeUnique(); if (!m_videoBackend->open(path)) { @@ -96,12 +97,18 @@ void CBackground::configure(const std::unordered_map& pro } else { m_uploadBuffer.resize(4 * m_videoBackend->frameW() * m_videoBackend->frameH()); } - } else { + } else +#endif + { resourceID = g_asyncResourceManager->requestImage(path, m_imageRevision, nullptr); } } - if (!reloadCommand.empty() && reloadTime > -1 && !m_videoBackend) { + if (!reloadCommand.empty() && reloadTime > -1 +#ifdef HYPRLOCK_HAS_VIDEO + && !m_videoBackend +#endif + ) { try { if (!isScreenshot) modificationTime = std::filesystem::last_write_time(absolutePath(path, "")); @@ -112,11 +119,13 @@ void CBackground::configure(const std::unordered_map& pro } void CBackground::reset() { +#ifdef HYPRLOCK_HAS_VIDEO if (m_videoBackend) { m_videoBackend.reset(); m_videoTexture.destroyTexture(); m_uploadBuffer.clear(); } +#endif if (reloadTimer) { reloadTimer->cancel(); @@ -243,6 +252,7 @@ void CBackground::renderToFB(const CTexture& tex, CFramebuffer& fb, int passes, } bool CBackground::draw(const SRenderData& data) { +#ifdef HYPRLOCK_HAS_VIDEO // ── Video background fast path ──────────────────────────────────────── if (m_videoBackend) { if (m_videoBackend->swapFrame(m_uploadBuffer)) { @@ -286,6 +296,7 @@ bool CBackground::draw(const SRenderData& data) { return true; // always request the next compositor frame } // ── End video path ──────────────────────────────────────────────────── +#endif updatePrimaryAsset(); updatePendingAsset(); diff --git a/src/renderer/widgets/Background.hpp b/src/renderer/widgets/Background.hpp index 0d5a9c5..f757b3e 100644 --- a/src/renderer/widgets/Background.hpp +++ b/src/renderer/widgets/Background.hpp @@ -6,7 +6,9 @@ #include "../../helpers/Color.hpp" #include "../../core/Timer.hpp" #include "../Framebuffer.hpp" +#ifdef HYPRLOCK_HAS_VIDEO #include "../VideoBackend.hpp" +#endif #include #include #include @@ -86,7 +88,9 @@ class CBackground : public IWidget { size_t m_imageRevision = 0; // Video playback +#ifdef HYPRLOCK_HAS_VIDEO UP m_videoBackend; CTexture m_videoTexture; std::vector m_uploadBuffer; +#endif };