Skip to content

Commit

Permalink
renderer: Add dimaround layer rule
Browse files Browse the repository at this point in the history
  • Loading branch information
TheOnlyMrCat committed Feb 8, 2024
1 parent a6ccd36 commit d90cc45
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/config/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ bool windowRuleValid(const std::string& RULE) {
}

bool layerRuleValid(const std::string& RULE) {
return RULE == "noanim" || RULE == "blur" || RULE.starts_with("ignorealpha") || RULE.starts_with("ignorezero") || RULE.starts_with("xray");
return RULE == "noanim" || RULE == "blur" || RULE.starts_with("ignorealpha") || RULE.starts_with("ignorezero") || RULE == "dimaround" || RULE.starts_with("xray");
}

void CConfigManager::handleWindowRule(const std::string& command, const std::string& value) {
Expand Down
3 changes: 3 additions & 0 deletions src/helpers/WLClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ void SLayerSurface::applyRules() {
forceBlur = false;
ignoreAlpha = false;
ignoreAlphaValue = 0.f;
dimAround = false;
xray = -1;

for (auto& rule : g_pConfigManager->getMatchingRules(this)) {
Expand All @@ -39,6 +40,8 @@ void SLayerSurface::applyRules() {
if (!alphaValue.empty())
ignoreAlphaValue = std::stof(alphaValue);
} catch (...) { Debug::log(ERR, "Invalid value passed to ignoreAlpha"); }
} else if (rule.rule == "dimaround") {
dimAround = true;
} else if (rule.rule.starts_with("xray")) {
CVarList vars{rule.rule, 0, ' '};
try {
Expand Down
1 change: 1 addition & 0 deletions src/helpers/WLClasses.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ struct SLayerSurface {
int xray = -1;
bool ignoreAlpha = false;
float ignoreAlphaValue = 0.f;
bool dimAround = false;

// For the list lookup
bool operator==(const SLayerSurface& rhs) const {
Expand Down
11 changes: 11 additions & 0 deletions src/render/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,17 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec*
}

void CHyprRenderer::renderLayer(SLayerSurface* pLayer, CMonitor* pMonitor, timespec* time) {
static auto* const PDIMAROUND = &g_pConfigManager->getConfigValuePtr("decoration:dim_around")->floatValue;

if (*PDIMAROUND && pLayer->dimAround && !m_bRenderingSnapshot) {
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.fl()));

if (pLayer->fadingOut) {
g_pHyprRenderer->damageMonitor(g_pCompositor->getMonitorFromID(pLayer->monitorID));
}
}

if (pLayer->fadingOut) {
g_pHyprOpenGL->renderSnapshot(&pLayer);
return;
Expand Down

0 comments on commit d90cc45

Please sign in to comment.