diff options
| author | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2023-02-28 19:18:13 +0000 |
|---|---|---|
| committer | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2023-02-28 19:18:13 +0000 |
| commit | 7beb9fd606106e82554c7050aebbc5ca23dafa79 (patch) | |
| tree | f61bc10e0e1c90b468b58b4127717a700d740dfe /src/hyprerror/HyprError.cpp | |
| parent | 4d3f2ca96b006fe9fd27de7f1bd4d317ad732762 (diff) | |
Draw HyprError on the last monitor
Diffstat (limited to 'src/hyprerror/HyprError.cpp')
| -rw-r--r-- | src/hyprerror/HyprError.cpp | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/src/hyprerror/HyprError.cpp b/src/hyprerror/HyprError.cpp index 40f01aa3..ca0776ea 100644 --- a/src/hyprerror/HyprError.cpp +++ b/src/hyprerror/HyprError.cpp @@ -4,6 +4,22 @@ CHyprError::CHyprError() { m_fFadeOpacity.create(AVARTYPE_FLOAT, g_pConfigManager->getAnimationPropertyConfig("fadeIn"), nullptr, AVARDAMAGE_NONE); m_fFadeOpacity.registerVar(); + + g_pHookSystem->hookDynamic("focusedMon", [&](void* self, std::any param) { + if (!m_bIsCreated) + return; + + g_pHyprRenderer->damageMonitor(g_pCompositor->m_pLastMonitor); + m_bMonitorChanged = true; + }); + + g_pHookSystem->hookDynamic("preRender", [&](void* self, std::any param) { + if (!m_bIsCreated) + return; + + if (m_fFadeOpacity.isBeingAnimated() || m_bMonitorChanged) + g_pHyprRenderer->damageBox(&m_bDamageBox); + }); } CHyprError::~CHyprError() { @@ -54,7 +70,7 @@ void CHyprError::createQueued() { const double HEIGHT = (FONTSIZE + 2 * (FONTSIZE / 10.0)) * LINECOUNT + 3; const double RADIUS = PAD > HEIGHT / 2 ? HEIGHT / 2 - 1 : PAD; - m_bDamageBox = {(int)PMONITOR->vecPosition.x, (int)PMONITOR->vecPosition.y, (int)PMONITOR->vecPixelSize.x, (int)HEIGHT + (int)PAD * 2}; + m_bDamageBox = {0, 0, (int)PMONITOR->vecPixelSize.x, (int)HEIGHT + (int)PAD * 2}; cairo_new_sub_path(CAIRO); cairo_arc(CAIRO, X + WIDTH - RADIUS, Y + RADIUS, RADIUS, -90 * DEGREES, 0 * DEGREES); @@ -137,16 +153,18 @@ void CHyprError::draw() { } } - const auto PMONITOR = g_pCompositor->m_vMonitors.front().get(); + const auto PMONITOR = g_pHyprOpenGL->m_RenderData.pMonitor; - if (g_pHyprOpenGL->m_RenderData.pMonitor != PMONITOR) - return; // wrong mon + wlr_box monbox = {0, 0, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y}; - wlr_box monbox = {0, 0, PMONITOR->vecPixelSize.x, PMONITOR->vecPixelSize.y}; + m_bDamageBox.x = (int)PMONITOR->vecPosition.x; + m_bDamageBox.y = (int)PMONITOR->vecPosition.y; - if (m_fFadeOpacity.isBeingAnimated()) + if (m_fFadeOpacity.isBeingAnimated() || m_bMonitorChanged) g_pHyprRenderer->damageBox(&m_bDamageBox); + m_bMonitorChanged = false; + g_pHyprOpenGL->renderTexture(m_tTexture, &monbox, m_fFadeOpacity.fl(), 0); } |
