diff --git a/src/desktop/LayerRule.cpp b/src/desktop/LayerRule.cpp index dfcd289a..d6bfcadf 100644 --- a/src/desktop/LayerRule.cpp +++ b/src/desktop/LayerRule.cpp @@ -4,7 +4,7 @@ #include #include "../debug/Log.hpp" -static const auto RULES = std::unordered_set{"noanim", "blur", "blurpopups", "dimaround"}; +static const auto RULES = std::unordered_set{"noanim", "blur", "blurpopups", "dimaround", "noscreenshare"}; static const auto RULES_PREFIX = std::unordered_set{"ignorealpha", "ignorezero", "xray", "animation", "order", "abovelock"}; CLayerRule::CLayerRule(const std::string& rule_, const std::string& ns_) : m_targetNamespace(ns_), m_rule(rule_) { @@ -21,6 +21,8 @@ CLayerRule::CLayerRule(const std::string& rule_, const std::string& ns_) : m_tar m_ruleType = RULE_BLURPOPUPS; else if (m_rule == "dimaround") m_ruleType = RULE_DIMAROUND; + else if (m_rule == "noscreenshare") + m_ruleType = RULE_NOSCREENSHARE; else if (m_rule.starts_with("ignorealpha")) m_ruleType = RULE_IGNOREALPHA; else if (m_rule.starts_with("ignorezero")) diff --git a/src/desktop/LayerRule.hpp b/src/desktop/LayerRule.hpp index 0463196e..7b6c8a6d 100644 --- a/src/desktop/LayerRule.hpp +++ b/src/desktop/LayerRule.hpp @@ -21,6 +21,7 @@ class CLayerRule { RULE_ANIMATION, RULE_ORDER, RULE_ZUMBA, + RULE_NOSCREENSHARE }; eRuleType m_ruleType = RULE_INVALID; diff --git a/src/desktop/LayerSurface.cpp b/src/desktop/LayerSurface.cpp index a89f9dba..5d2ab9a8 100644 --- a/src/desktop/LayerSurface.cpp +++ b/src/desktop/LayerSurface.cpp @@ -388,8 +388,9 @@ void CLayerSurface::applyRules() { m_noAnimations = false; m_forceBlur = false; m_ignoreAlpha = false; - m_ignoreAlphaValue = 0.f; m_dimAround = false; + m_noScreenShare = false; + m_ignoreAlphaValue = 0.f; m_xray = -1; m_animationStyle.reset(); @@ -425,6 +426,10 @@ void CLayerSurface::applyRules() { m_dimAround = true; break; } + case CLayerRule::RULE_NOSCREENSHARE: { + m_noScreenShare = true; + break; + } case CLayerRule::RULE_XRAY: { CVarList vars{rule->m_rule, 0, ' '}; m_xray = configStringToInt(vars[1]).value_or(false); diff --git a/src/desktop/LayerSurface.hpp b/src/desktop/LayerSurface.hpp index be32a778..b70739cd 100644 --- a/src/desktop/LayerSurface.hpp +++ b/src/desktop/LayerSurface.hpp @@ -48,6 +48,7 @@ class CLayerSurface { bool m_ignoreAlpha = false; float m_ignoreAlphaValue = 0.f; bool m_dimAround = false; + bool m_noScreenShare = false; int64_t m_order = 0; bool m_aboveLockscreen = false; bool m_aboveLockscreenInteractable = false; diff --git a/src/protocols/Screencopy.cpp b/src/protocols/Screencopy.cpp index 3a2e4b4a..80538623 100644 --- a/src/protocols/Screencopy.cpp +++ b/src/protocols/Screencopy.cpp @@ -211,6 +211,22 @@ void CScreencopyFrame::renderMon() { g_pHyprOpenGL->setRenderModifEnabled(true); g_pHyprOpenGL->popMonitorTransformEnabled(); + for (auto const& l : g_pCompositor->m_layers) { + if (!l->m_noScreenShare) + continue; + + if UNLIKELY ((!l->m_mapped && !l->m_fadingOut) || l->m_alpha->value() == 0.f) + continue; + + const auto REALPOS = l->m_realPosition->value(); + const auto REALSIZE = l->m_realSize->value(); + + const auto noScreenShareBox = + CBox{REALPOS.x, REALPOS.y, std::max(REALSIZE.x, 5.0), std::max(REALSIZE.y, 5.0)}.translate(-m_monitor->m_position).scale(m_monitor->m_scale).translate(-m_box.pos()); + + g_pHyprOpenGL->renderRect(noScreenShareBox, Colors::BLACK, {}); + } + for (auto const& w : g_pCompositor->m_windows) { if (!w->m_windowData.noScreenShare.valueOrDefault()) continue;