From a21e0cfa61421cee30d78ef199656174748c3e92 Mon Sep 17 00:00:00 2001 From: Almamu Date: Sat, 10 May 2025 09:32:43 +0200 Subject: [PATCH] feat: add option to disable camera parallax --- README.md | 1 + .../Application/CApplicationContext.cpp | 6 ++++++ .../Application/CApplicationContext.h | 14 ++++++++------ src/WallpaperEngine/Render/Objects/CImage.cpp | 5 +++++ src/WallpaperEngine/Render/Wallpapers/CScene.cpp | 2 +- 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 957b7fc..d1faf32 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,7 @@ You can use either: | `--list-properties` | Show customizable properties of a wallpaper | | `--set-property name=value` | Override a specific property | | `--disable-mouse` | Disable mouse interaction | +| `--disable-parallax` | Disable parallax effect on backgrounds that support it | | `--no-fullscreen-pause` | Prevent pausing while fullscreen apps are running | --- diff --git a/src/WallpaperEngine/Application/CApplicationContext.cpp b/src/WallpaperEngine/Application/CApplicationContext.cpp index de9bef7..3084ac1 100644 --- a/src/WallpaperEngine/Application/CApplicationContext.cpp +++ b/src/WallpaperEngine/Application/CApplicationContext.cpp @@ -209,6 +209,12 @@ CApplicationContext::CApplicationContext (int argc, char* argv []) : .action ([this](const std::string& value) -> void { this->settings.mouse.enabled = false; }); + configurationGroup.add_argument ("--disable-parallax") + .help ("Disables parallax effect for the backgrounds") + .flag () + .action ([this](const std::string& value) -> void { + this->settings.mouse.disableparallax = true; + }); configurationGroup.add_argument ("-l", "--list-properties") .help ("List all the available properties and their configuration") diff --git a/src/WallpaperEngine/Application/CApplicationContext.h b/src/WallpaperEngine/Application/CApplicationContext.h index 630cd1a..95a3772 100644 --- a/src/WallpaperEngine/Application/CApplicationContext.h +++ b/src/WallpaperEngine/Application/CApplicationContext.h @@ -91,6 +91,8 @@ class CApplicationContext { struct { /** If the mouse movement is enabled */ bool enabled; + /** If the mouse parallax should be disabled */ + bool disableparallax; } mouse; /** @@ -119,12 +121,11 @@ class CApplicationContext { .mode = NORMAL_WINDOW, .maximumFPS = 30, .pauseOnFullscreen = true, - .window = - { - .geometry = {}, - .clamp = WallpaperEngine::Assets::ITexture::TextureFlags::ClampUVs, - .scalingMode = WallpaperEngine::Render::CWallpaperState::TextureUVsScaling::DefaultUVs, - }, + .window = { + .geometry = {}, + .clamp = WallpaperEngine::Assets::ITexture::TextureFlags::ClampUVs, + .scalingMode = WallpaperEngine::Render::CWallpaperState::TextureUVsScaling::DefaultUVs, + }, }, .audio = { .enabled = true, @@ -134,6 +135,7 @@ class CApplicationContext { }, .mouse = { .enabled = true, + .disableparallax = false, }, .screenshot = { .take = false, diff --git a/src/WallpaperEngine/Render/Objects/CImage.cpp b/src/WallpaperEngine/Render/Objects/CImage.cpp index d541b5f..4438009 100644 --- a/src/WallpaperEngine/Render/Objects/CImage.cpp +++ b/src/WallpaperEngine/Render/Objects/CImage.cpp @@ -420,6 +420,11 @@ void CImage::render () { } void CImage::updateScreenSpacePosition () { + // do not perform any changes to the image based on the parallax if it was explicitly disabled + if (this->getScene ()->getContext ().getApp ().getContext ().settings.mouse.disableparallax) { + return; + } + const double parallaxAmount = this->getScene ()->getScene ()->getCameraParallaxAmount (); const glm::vec2 depth = this->getImage ()->getParallaxDepth (); const glm::vec2* displacement = this->getScene ()->getParallaxDisplacement (); diff --git a/src/WallpaperEngine/Render/Wallpapers/CScene.cpp b/src/WallpaperEngine/Render/Wallpapers/CScene.cpp index e28c4fb..d268012 100644 --- a/src/WallpaperEngine/Render/Wallpapers/CScene.cpp +++ b/src/WallpaperEngine/Render/Wallpapers/CScene.cpp @@ -207,7 +207,7 @@ void CScene::renderFrame (glm::ivec4 viewport) { this->updateMouse (viewport); // update the parallax position if required - if (this->getScene ()->isCameraParallax ()) { + if (this->getScene ()->isCameraParallax () && !this->getContext ().getApp ().getContext ().settings.mouse.disableparallax) { const float influence = this->getScene ()->getCameraParallaxMouseInfluence (); const float amount = this->getScene ()->getCameraParallaxAmount (); const float delay =