summaryrefslogtreecommitdiff
path: root/src/protocols/Screencopy.cpp
diff options
context:
space:
mode:
authorKamikadze <40305144+Kam1k4dze@users.noreply.github.com>2025-05-27 20:10:22 +0500
committerGitHub <noreply@github.com>2025-05-27 16:10:22 +0100
commit24915a3a9b0bb8c4dc8b5a365cc0bc3a03ee36f0 (patch)
tree243e23671c81e48364ad76272f2e6b6d4793c363 /src/protocols/Screencopy.cpp
parent90d0b8ecae9540c21ce418ef781cf0fc2afc4dff (diff)
windowrules: Add noscreenshare (#10482)
Diffstat (limited to 'src/protocols/Screencopy.cpp')
-rw-r--r--src/protocols/Screencopy.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/protocols/Screencopy.cpp b/src/protocols/Screencopy.cpp
index 5fa7c84e..8002776a 100644
--- a/src/protocols/Screencopy.cpp
+++ b/src/protocols/Screencopy.cpp
@@ -13,6 +13,7 @@
#include "types/Buffer.hpp"
#include "../helpers/Format.hpp"
#include "../helpers/time/Time.hpp"
+#include "XDGShell.hpp"
#include <algorithm>
#include <functional>
@@ -200,6 +201,59 @@ void CScreencopyFrame::renderMon() {
g_pHyprOpenGL->renderTexture(TEXTURE, monbox, 1);
g_pHyprOpenGL->setRenderModifEnabled(true);
g_pHyprOpenGL->setMonitorTransformEnabled(false);
+
+ for (auto const& w : g_pCompositor->m_windows) {
+ if (!w->m_windowData.noScreenShare.valueOrDefault())
+ continue;
+
+ if (!g_pHyprRenderer->shouldRenderWindow(w))
+ continue;
+
+ const auto PWORKSPACE = w->m_workspace;
+
+ if UNLIKELY (!PWORKSPACE)
+ continue;
+
+ const auto REALPOS = w->m_realPosition->value() + (w->m_pinned ? Vector2D{} : PWORKSPACE->m_renderOffset->value());
+ const auto noScreenShareBox = CBox{REALPOS.x, REALPOS.y, std::max(w->m_realSize->value().x, 5.0), std::max(w->m_realSize->value().y, 5.0)}
+ .scale(m_monitor->m_scale)
+ .translate({-m_monitor->m_position.x, -m_monitor->m_position.y})
+ .translate({-m_box.x, -m_box.y});
+
+ const auto dontRound = w->isEffectiveInternalFSMode(FSMODE_FULLSCREEN) || w->m_windowData.noRounding.valueOrDefault();
+ const auto rounding = dontRound ? 0 : w->rounding() * m_monitor->m_scale;
+ const auto roundingPower = dontRound ? 2.0f : w->roundingPower();
+
+ g_pHyprOpenGL->renderRect(noScreenShareBox, {0, 0, 0, 255}, rounding, roundingPower);
+
+ if (w->m_isX11 || !w->m_popupHead)
+ continue;
+
+ const auto geom = w->m_xdgSurface->m_current.geometry;
+ const Vector2D popupBaseOffset = REALPOS - Vector2D{geom.pos().x, geom.pos().y};
+
+ w->m_popupHead->breadthfirst(
+ [&](WP<CPopup> popup, void*) {
+ if (!popup->m_wlSurface || !popup->m_wlSurface->resource() || !popup->m_mapped)
+ return;
+
+ const auto popRel = popup->coordsRelativeToParent();
+ popup->m_wlSurface->resource()->breadthfirst(
+ [&](SP<CWLSurfaceResource> surf, const Vector2D& localOff, void*) {
+ const auto size = surf->m_current.size;
+ const auto surfBox = CBox{popupBaseOffset.x + popRel.x + localOff.x, popupBaseOffset.y + popRel.y + localOff.y, size.x, size.y}
+ .scale(m_monitor->m_scale)
+ .translate({-m_monitor->m_position.x, -m_monitor->m_position.y})
+ .translate({-m_box.x, -m_box.y});
+
+ if LIKELY (surfBox.w > 0 && surfBox.h > 0)
+ g_pHyprOpenGL->renderRect(surfBox, {0, 0, 0, 255});
+ },
+ nullptr);
+ },
+ nullptr);
+ }
+
if (m_overlayCursor)
g_pPointerManager->renderSoftwareCursorsFor(m_monitor.lock(), Time::steadyNow(), fakeDamage,
g_pInputManager->getMouseCoordsInternal() - m_monitor->m_position - m_box.pos(), true);