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 Apr 1, 2024
1 parent 8cb38d4 commit 84fca7f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/config/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1910,8 +1910,8 @@ bool windowRuleValid(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") ||
RULE.starts_with("animation");
return RULE == "noanim" || RULE == "blur" || RULE == "blurpopups" || RULE.starts_with("ignorealpha") || RULE.starts_with("ignorezero") || RULE == "dimaround" ||
RULE.starts_with("xray") || RULE.starts_with("animation");
}

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

Expand All @@ -47,6 +48,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 Expand Up @@ -173,6 +176,9 @@ void SLayerSurface::startAnimation(bool in, bool instant) {
alpha = in ? 1.f : 0.f;
}

if (this->dimAround)
alpha.setUpdateCallback([&](void*) { g_pHyprRenderer->damageMonitor(g_pCompositor->getMonitorFromID(this->monitorID)); });

if (!in)
fadingOut = true;
}
Expand Down
1 change: 1 addition & 0 deletions src/helpers/WLClasses.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ struct SLayerSurface {
int xray = -1;
bool ignoreAlpha = false;
float ignoreAlphaValue = 0.f;
bool dimAround = false;

std::optional<std::string> animationStyle;

Expand Down
7 changes: 7 additions & 0 deletions src/render/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,13 @@ void CHyprRenderer::renderWindow(CWindow* pWindow, CMonitor* pMonitor, timespec*
}

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) {
g_pHyprOpenGL->renderSnapshot(&pLayer);
return;
Expand Down

0 comments on commit 84fca7f

Please sign in to comment.