add override to opacity rules

This commit is contained in:
vaxerski 2022-12-11 17:15:02 +00:00
parent bb99f151da
commit e8b99ae13a
5 changed files with 24 additions and 27 deletions

View file

@ -1458,22 +1458,14 @@ void CCompositor::updateWindowAnimatedDecorationValues(CWindow* pWindow) {
// opacity // opacity
if (pWindow->m_bIsFullscreen) { const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID);
const auto PWORKSPACE = g_pCompositor->getWorkspaceByID(pWindow->m_iWorkspaceID); if (pWindow->m_bIsFullscreen && PWORKSPACE->m_efFullscreenMode == FULLSCREEN_FULL) {
pWindow->m_fActiveInactiveAlpha = *PFULLSCREENALPHA;
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;
}
} else { } else {
if (pWindow == m_pLastWindow) 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 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 // dim

View file

@ -328,14 +328,23 @@ void CWindow::applyDynamicRule(const SWindowRule& r) {
} }
} else if (r.szRule.find("opacity") == 0) { } else if (r.szRule.find("opacity") == 0) {
try { try {
std::string alphaPart = removeBeginEndSpacesTabs(r.szRule.substr(r.szRule.find_first_of(' ') + 1)); CVarList vars(r.szRule, 0, ' ');
if (alphaPart.contains(' ')) { for (size_t i = 1 /* first item is "opacity" */; i < vars.size(); ++i) {
// we have a space, 2 values if (i == 1) {
m_sSpecialRenderData.alpha = std::stof(alphaPart.substr(0, alphaPart.find_first_of(' '))); // first arg, alpha
m_sSpecialRenderData.alphaInactive = std::stof(alphaPart.substr(alphaPart.find_first_of(' ') + 1)); m_sSpecialRenderData.alpha = std::stof(vars[i]);
} else { } else {
m_sSpecialRenderData.alpha = std::stof(alphaPart); 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) { } catch(std::exception& e) {
Debug::log(ERR, "Opacity rule \"%s\" failed with: %s", r.szRule.c_str(), e.what()); Debug::log(ERR, "Opacity rule \"%s\" failed with: %s", r.szRule.c_str(), e.what());

View file

@ -16,7 +16,9 @@ enum eIdleInhibitMode {
}; };
struct SWindowSpecialRenderData { struct SWindowSpecialRenderData {
bool alphaOverride = false;
float alpha = 1.f; float alpha = 1.f;
bool alphaInactiveOverride = false;
float alphaInactive = -1.f; // -1 means unset float alphaInactive = -1.f; // -1 means unset
int64_t activeBorderColor = -1; // -1 means unset int64_t activeBorderColor = -1; // -1 means unset

View file

@ -95,7 +95,7 @@ public:
~CVarList() = default; ~CVarList() = default;
int size() const { size_t size() const {
return m_vArgs.size(); return m_vArgs.size();
} }

View file

@ -255,12 +255,6 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec*
renderdata.fadeAlpha = 255.f; 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 // apply opaque
if (pWindow->m_sAdditionalConfigData.forceOpaque) if (pWindow->m_sAdditionalConfigData.forceOpaque)
renderdata.alpha = 1.f; renderdata.alpha = 1.f;