|
41 | 41 | #include "../protocols/types/ContentType.hpp" |
42 | 42 | #include "../helpers/MiscFunctions.hpp" |
43 | 43 | #include "render/OpenGL.hpp" |
| 44 | +#include "../protocols/Screencopy.hpp" |
| 45 | +#include "../config/ConfigDataValues.hpp" |
| 46 | +#include "../helpers/Color.hpp" |
| 47 | +#include "pass/BorderPassElement.hpp" |
44 | 48 |
|
45 | 49 | #include <hyprutils/utils/ScopeGuard.hpp> |
46 | 50 | using namespace Hyprutils::Utils; |
@@ -1457,6 +1461,46 @@ void CHyprRenderer::renderMonitor(PHLMONITOR pMonitor, bool commit) { |
1457 | 1461 | m_renderPass.add(makeUnique<CRectPassElement>(data)); |
1458 | 1462 | } |
1459 | 1463 |
|
| 1464 | + // Render border around monitor if it's being shared |
| 1465 | + static auto PENABLED = CConfigValue<Hyprlang::INT>("general:screencast_border.enabled"); |
| 1466 | + if (*PENABLED) { |
| 1467 | + // Check if monitor is being shared through screencopy |
| 1468 | + bool isMonitorShared = false; |
| 1469 | + if (PROTO::screencopy) { |
| 1470 | + for (const auto& frame : PROTO::screencopy->m_frames) { |
| 1471 | + if (frame && frame->m_monitor && frame->m_monitor.lock() == pMonitor) { |
| 1472 | + isMonitorShared = frame->m_client->m_sentScreencast; |
| 1473 | + break; |
| 1474 | + } |
| 1475 | + } |
| 1476 | + } |
| 1477 | + |
| 1478 | + if (isMonitorShared) { |
| 1479 | + static auto PBORDERSIZE = CConfigValue<Hyprlang::INT>("general:border_size"); |
| 1480 | + static auto PCOLOR = CConfigValue<Hyprlang::CUSTOMTYPE>("general:screencast_border.color"); |
| 1481 | + const int borderSize = *PBORDERSIZE > 0 ? *PBORDERSIZE : 1; |
| 1482 | + |
| 1483 | + const int scaledBorderSize = std::round(borderSize * pMonitor->m_scale); |
| 1484 | + CBox monitorBox = {scaledBorderSize, scaledBorderSize, std::max(1, sc<int>(pMonitor->m_transformedSize.x) - (2 * scaledBorderSize)), |
| 1485 | + std::max(1, sc<int>(pMonitor->m_transformedSize.y) - (2 * scaledBorderSize))}; |
| 1486 | + |
| 1487 | + const auto* const PGRAD = sc<CGradientValueData*>((PCOLOR.ptr())->getData()); |
| 1488 | + CGradientValueData borderGrad = PGRAD ? *PGRAD : CGradientValueData(Colors::RED); // fallback to red if config not loaded |
| 1489 | + |
| 1490 | + CBorderPassElement::SBorderData borderData; |
| 1491 | + borderData.box = monitorBox; |
| 1492 | + borderData.grad1 = borderGrad; |
| 1493 | + borderData.round = 0; |
| 1494 | + borderData.outerRound = -1; |
| 1495 | + borderData.roundingPower = 2.0f; |
| 1496 | + borderData.a = 1.0f; |
| 1497 | + borderData.borderSize = borderSize; |
| 1498 | + borderData.hasGrad2 = false; |
| 1499 | + |
| 1500 | + m_renderPass.add(makeUnique<CBorderPassElement>(borderData)); |
| 1501 | + } |
| 1502 | + } |
| 1503 | + |
1460 | 1504 | EMIT_HOOK_EVENT("render", RENDER_LAST_MOMENT); |
1461 | 1505 |
|
1462 | 1506 | endRender(); |
|
0 commit comments