renderer: Add dimaround layer rule (#4643)

This commit is contained in:
TheOnlyMrCat 2024-04-11 21:41:18 +10:00 committed by GitHub
parent ac0f3411c1
commit 47e5b41fea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 18 additions and 2 deletions

View file

@ -1949,8 +1949,8 @@ bool windowRuleValid(const std::string& RULE) {
} }
bool layerRuleValid(const std::string& RULE) { bool layerRuleValid(const std::string& RULE) {
return RULE == "noanim" || RULE == "blur" || RULE == "blurpopups" || RULE.starts_with("ignorealpha") || RULE.starts_with("ignorezero") || RULE.starts_with("xray") || return RULE == "noanim" || RULE == "blur" || RULE == "blurpopups" || RULE.starts_with("ignorealpha") || RULE.starts_with("ignorezero") || RULE == "dimaround" ||
RULE.starts_with("animation"); RULE.starts_with("xray") || RULE.starts_with("animation");
} }
std::optional<std::string> CConfigManager::handleWindowRule(const std::string& command, const std::string& value) { std::optional<std::string> CConfigManager::handleWindowRule(const std::string& command, const std::string& value) {

View file

@ -10,6 +10,11 @@ SLayerSurface::SLayerSurface() {
realPosition.registerVar(); realPosition.registerVar();
realSize.registerVar(); realSize.registerVar();
alpha.setUpdateCallback([this](void*) {
if (dimAround)
g_pHyprRenderer->damageMonitor(g_pCompositor->getMonitorFromID(monitorID));
});
alpha.setValueAndWarp(0.f); alpha.setValueAndWarp(0.f);
} }
@ -26,6 +31,7 @@ void SLayerSurface::applyRules() {
forceBlur = false; forceBlur = false;
ignoreAlpha = false; ignoreAlpha = false;
ignoreAlphaValue = 0.f; ignoreAlphaValue = 0.f;
dimAround = false;
xray = -1; xray = -1;
animationStyle.reset(); animationStyle.reset();
@ -47,6 +53,8 @@ void SLayerSurface::applyRules() {
if (!alphaValue.empty()) if (!alphaValue.empty())
ignoreAlphaValue = std::stof(alphaValue); ignoreAlphaValue = std::stof(alphaValue);
} catch (...) { Debug::log(ERR, "Invalid value passed to ignoreAlpha"); } } catch (...) { Debug::log(ERR, "Invalid value passed to ignoreAlpha"); }
} else if (rule.rule == "dimaround") {
dimAround = true;
} else if (rule.rule.starts_with("xray")) { } else if (rule.rule.starts_with("xray")) {
CVarList vars{rule.rule, 0, ' '}; CVarList vars{rule.rule, 0, ' '};
try { try {

View file

@ -63,6 +63,7 @@ struct SLayerSurface {
int xray = -1; int xray = -1;
bool ignoreAlpha = false; bool ignoreAlpha = false;
float ignoreAlphaValue = 0.f; float ignoreAlphaValue = 0.f;
bool dimAround = false;
std::optional<std::string> animationStyle; std::optional<std::string> animationStyle;

View file

@ -660,6 +660,13 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec*
} }
void CHyprRenderer::renderLayer(SLayerSurface* pLayer, CMonitor* pMonitor, timespec* time, bool popups) { void CHyprRenderer::renderLayer(SLayerSurface* pLayer, CMonitor* pMonitor, timespec* time, bool popups) {
static auto PDIMAROUND = CConfigValue<Hyprlang::FLOAT>("decoration:dim_around");
if (*PDIMAROUND && pLayer->dimAround && !m_bRenderingSnapshot && !popups) {
CBox monbox = {0, 0, g_pHyprOpenGL->m_RenderData.pMonitor->vecTransformedSize.x, g_pHyprOpenGL->m_RenderData.pMonitor->vecTransformedSize.y};
g_pHyprOpenGL->renderRect(&monbox, CColor(0, 0, 0, *PDIMAROUND * pLayer->alpha.value()));
}
if (pLayer->fadingOut) { if (pLayer->fadingOut) {
if (!popups) if (!popups)
g_pHyprOpenGL->renderSnapshot(&pLayer); g_pHyprOpenGL->renderSnapshot(&pLayer);