aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorvaxerski <[email protected]>2022-05-31 17:35:50 +0200
committervaxerski <[email protected]>2022-05-31 17:35:50 +0200
commit8de7cc5a8da13973b347d5da96de89efc3dbdbaf (patch)
tree2f3120a1e870ed155d23746be0b20557bcd154aa
parente73df80782593f0cab39a5f3e7a5a005203c9b0c (diff)
downloadHyprland-8de7cc5a8da13973b347d5da96de89efc3dbdbaf.tar.gz
Hyprland-8de7cc5a8da13973b347d5da96de89efc3dbdbaf.zip
opacity windowrule support 2 values
-rw-r--r--src/Window.hpp1
-rw-r--r--src/events/Windows.cpp10
-rw-r--r--src/render/Renderer.cpp5
3 files changed, 14 insertions, 2 deletions
diff --git a/src/Window.hpp b/src/Window.hpp
index 7fd909ba..7d357292 100644
--- a/src/Window.hpp
+++ b/src/Window.hpp
@@ -9,6 +9,7 @@
struct SWindowSpecialRenderData {
float alpha = 1.f;
+ float alphaInactive = -1.f; // -1 means unset
};
struct SWindowAdditionalConfigData {
diff --git a/src/events/Windows.cpp b/src/events/Windows.cpp
index 0fbb7227..47cb5b24 100644
--- a/src/events/Windows.cpp
+++ b/src/events/Windows.cpp
@@ -114,7 +114,15 @@ void Events::listener_mapWindow(void* owner, void* data) {
}
} else if (r.szRule.find("opacity") == 0) {
try {
- PWINDOW->m_sSpecialRenderData.alpha = std::stof(r.szRule.substr(r.szRule.find_first_of(' ') + 1));
+ std::string alphaPart = r.szRule.substr(r.szRule.find_first_of(' ') + 1);
+
+ if (alphaPart.find_first_of(' ') != std::string::npos) {
+ // we have a comma, 2 values
+ PWINDOW->m_sSpecialRenderData.alpha = std::stof(alphaPart.substr(0, alphaPart.find_first_of(' ')));
+ PWINDOW->m_sSpecialRenderData.alphaInactive = std::stof(alphaPart.substr(alphaPart.find_first_of(' ') + 1));
+ } else {
+ PWINDOW->m_sSpecialRenderData.alpha = std::stof(alphaPart);
+ }
} catch(std::exception& e) {
Debug::log(ERR, "Opacity rule \"%s\" failed with: %s", r.szRule.c_str(), e.what());
}
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp
index 096102e0..86528f53 100644
--- a/src/render/Renderer.cpp
+++ b/src/render/Renderer.cpp
@@ -130,7 +130,10 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, SMonitor* pMonitor, timespec*
renderdata.rounding = pWindow->m_sAdditionalConfigData.rounding;
// apply window special data
- renderdata.alpha *= pWindow->m_sSpecialRenderData.alpha;
+ if (pWindow->m_sSpecialRenderData.alphaInactive == -1)
+ renderdata.alpha *= pWindow->m_sSpecialRenderData.alpha;
+ else
+ renderdata.alpha *= pWindow == g_pCompositor->m_pLastWindow ? pWindow->m_sSpecialRenderData.alpha : pWindow->m_sSpecialRenderData.alphaInactive;
g_pHyprOpenGL->m_pCurrentWindow = pWindow;