summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2022-12-11 17:15:02 +0000
committervaxerski <43317083+vaxerski@users.noreply.github.com>2022-12-11 17:15:02 +0000
commite8b99ae13a0525f9fbd6899fe39fe723879f86b9 (patch)
tree7a1f7863cc101a3076d970ab3f6e489a794e2041 /src
parentbb99f151da78fea9c16644ffcc3186427320aac1 (diff)
add override to opacity rules
Diffstat (limited to 'src')
-rw-r--r--src/Compositor.cpp18
-rw-r--r--src/Window.cpp25
-rw-r--r--src/Window.hpp2
-rw-r--r--src/config/ConfigManager.hpp2
-rw-r--r--src/render/Renderer.cpp6
5 files changed, 25 insertions, 28 deletions
diff --git a/src/Compositor.cpp b/src/Compositor.cpp
index c0fec3ad..942da2ee 100644
--- a/src/Compositor.cpp
+++ b/src/Compositor.cpp
@@ -1458,22 +1458,14 @@ void CCompositor::updateWindowAnimatedDecorationValues(CWindow* pWindow) {
// opacity
- if (pWindow->m_bIsFullscreen) {
- const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
-
- if (PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL)
- pWindow->m_fActiveInactiveAlpha = *PFULLSCREENALPHA;
- else {
- if (pWindow == m_pLastWindow)
- pWindow->m_fActiveInactiveAlpha = pWindow->m_sSpecialRenderData.alpha * *PACTIVEALPHA;
- else
- pWindow->m_fActiveInactiveAlpha = pWindow->m_sSpecialRenderData.alphaInactive != -1 ? pWindow->m_sSpecialRenderData.alphaInactive * *PINACTIVEALPHA : *PINACTIVEALPHA;
- }
+ const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
+ if (pWindow->m_bIsFullscreen && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL) {
+ pWindow->m_fActiveInactiveAlpha = *PFULLSCREENALPHA;
} else {
if (pWindow == m_pLastWindow)
- pWindow->m_fActiveInactiveAlpha = pWindow->m_sSpecialRenderData.alpha * *PACTIVEALPHA;
+ pWindow->m_fActiveInactiveAlpha = pWindow->m_sSpecialRenderData.alphaOverride ? pWindow->m_sSpecialRenderData.alpha : pWindow->m_sSpecialRenderData.alpha * *PACTIVEALPHA;
else
- pWindow->m_fActiveInactiveAlpha = pWindow->m_sSpecialRenderData.alphaInactive != -1 ? pWindow->m_sSpecialRenderData.alphaInactive * *PINACTIVEALPHA : *PINACTIVEALPHA;
+ pWindow->m_fActiveInactiveAlpha = pWindow->m_sSpecialRenderData.alphaInactive != -1 ? (pWindow->m_sSpecialRenderData.alphaInactiveOverride ? pWindow->m_sSpecialRenderData.alphaInactive : pWindow->m_sSpecialRenderData.alphaInactive * *PINACTIVEALPHA) : *PINACTIVEALPHA;
}
// dim
diff --git a/src/Window.cpp b/src/Window.cpp
index 274c3d57..61711415 100644
--- a/src/Window.cpp
+++ b/src/Window.cpp
@@ -328,14 +328,23 @@ void CWindow::applyDynamicRule(const SWindowRule& r) {
}
} else if (r.szRule.find("opacity") == 0) {
try {
- std::string alphaPart = removeBeginEndSpacesTabs(r.szRule.substr(r.szRule.find_first_of(' ') + 1));
-
- if (alphaPart.contains(' ')) {
- // we have a space, 2 values
- m_sSpecialRenderData.alpha = std::stof(alphaPart.substr(0, alphaPart.find_first_of(' ')));
- m_sSpecialRenderData.alphaInactive = std::stof(alphaPart.substr(alphaPart.find_first_of(' ') + 1));
- } else {
- m_sSpecialRenderData.alpha = std::stof(alphaPart);
+ CVarList vars(r.szRule, 0, ' ');
+
+ for (size_t i = 1 /* first item is "opacity" */; i < vars.size(); ++i) {
+ if (i == 1) {
+ // first arg, alpha
+ m_sSpecialRenderData.alpha = std::stof(vars[i]);
+ } else {
+ if (vars[i] == "override") {
+ if (i == 2) {
+ m_sSpecialRenderData.alphaOverride = true;
+ } else {
+ m_sSpecialRenderData.alphaInactiveOverride = true;
+ }
+ } else {
+ m_sSpecialRenderData.alphaInactive = std::stof(vars[i]);
+ }
+ }
}
} catch(std::exception& e) {
Debug::log(ERR, "Opacity rule \"%s\" failed with: %s", r.szRule.c_str(), e.what());
diff --git a/src/Window.hpp b/src/Window.hpp
index a7c6657c..2d76d12d 100644
--- a/src/Window.hpp
+++ b/src/Window.hpp
@@ -16,7 +16,9 @@ enum eIdleInhibitMode {
};
struct SWindowSpecialRenderData {
+ bool alphaOverride = false;
float alpha = 1.f;
+ bool alphaInactiveOverride = false;
float alphaInactive = -1.f; // -1 means unset
int64_t activeBorderColor = -1; // -1 means unset
diff --git a/src/config/ConfigManager.hpp b/src/config/ConfigManager.hpp
index 298745cc..432ea084 100644
--- a/src/config/ConfigManager.hpp
+++ b/src/config/ConfigManager.hpp
@@ -95,7 +95,7 @@ public:
~CVarList() = default;
- int size() const {
+ size_t size() const {
return m_vArgs.size();
}
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp
index 8307108c..9c8354ec 100644
--- a/src/render/Renderer.cpp
+++ b/src/render/Renderer.cpp
@@ -255,12 +255,6 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec*
renderdata.fadeAlpha = 255.f;
}
- // apply window special data
- 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;
-
// apply opaque
if (pWindow->m_sAdditionalConfigData.forceOpaque)
renderdata.alpha = 1.f;