diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 29d019c1..70a19cb5 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -2792,4 +2792,4 @@ void CCompositor::setPreferredScaleForSurface(wlr_surface* pSurface, double scal void CCompositor::setPreferredTransformForSurface(wlr_surface* pSurface, wl_output_transform transform) { wlr_surface_set_preferred_buffer_transform(pSurface, transform); -} \ No newline at end of file +} diff --git a/src/events/Monitors.cpp b/src/events/Monitors.cpp index 9155fe87..13f3f829 100644 --- a/src/events/Monitors.cpp +++ b/src/events/Monitors.cpp @@ -22,10 +22,13 @@ void Events::listener_change(wl_listener* listener, void* data) { if (!CONFIG) return; - for (auto& m : g_pCompositor->m_vMonitors) { + for (auto& m : g_pCompositor->m_vRealMonitors) { if (!m->output) continue; + if (g_pCompositor->m_pUnsafeOutput == m.get()) + continue; + const auto CONFIGHEAD = wlr_output_configuration_head_v1_create(CONFIG, m->output); CBox BOX; @@ -195,7 +198,7 @@ void Events::listener_monitorDestroy(void* owner, void* data) { Debug::log(LOG, "Destroy called for monitor {}", pMonitor->output->name); - pMonitor->onDisconnect(); + pMonitor->onDisconnect(true); pMonitor->output = nullptr; pMonitor->m_bRenderingInitPassed = false; diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index 9dbd2a3e..743c938e 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -188,7 +188,7 @@ void CMonitor::onConnect(bool noRule) { g_pCompositor->scheduleFrameForMonitor(this); } -void CMonitor::onDisconnect() { +void CMonitor::onDisconnect(bool destroy) { if (renderTimer) { wl_event_source_remove(renderTimer); @@ -276,7 +276,8 @@ void CMonitor::onDisconnect() { activeWorkspace = -1; - wlr_output_layout_remove(g_pCompositor->m_sWLROutputLayout, output); + if (!destroy) + wlr_output_layout_remove(g_pCompositor->m_sWLROutputLayout, output); wlr_output_enable(output, false); @@ -298,7 +299,6 @@ void CMonitor::onDisconnect() { g_pHyprRenderer->m_pMostHzMonitor = pMonitorMostHz; } - std::erase_if(g_pCompositor->m_vMonitors, [&](std::shared_ptr& el) { return el.get() == this; }); } @@ -642,4 +642,4 @@ void CMonitor::moveTo(const Vector2D& pos) { Vector2D CMonitor::middle() { return vecPosition + vecSize / 2.f; -} \ No newline at end of file +} diff --git a/src/helpers/Monitor.hpp b/src/helpers/Monitor.hpp index 10790b5e..2aa7e7eb 100644 --- a/src/helpers/Monitor.hpp +++ b/src/helpers/Monitor.hpp @@ -110,7 +110,7 @@ class CMonitor { // methods void onConnect(bool noRule); - void onDisconnect(); + void onDisconnect(bool destroy = false); void addDamage(const pixman_region32_t* rg); void addDamage(const CRegion* rg); void addDamage(const CBox* box); diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 98dcf7f5..65aa7138 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -2,6 +2,7 @@ #include "../Compositor.hpp" #include "linux-dmabuf-unstable-v1-protocol.h" #include "../helpers/Region.hpp" +#include CHyprRenderer::CHyprRenderer() { const auto ENV = getenv("WLR_DRM_NO_ATOMIC"); @@ -1287,13 +1288,22 @@ void CHyprRenderer::outputMgrApplyTest(wlr_output_configuration_v1* config, bool break; } - if (!test) + if (!test) { g_pConfigManager->m_bWantsMonitorReload = true; // for monitor keywords + // if everything is disabled, performMonitorReload won't be called from renderMonitor + bool allDisabled = std::all_of(g_pCompositor->m_vMonitors.begin(), g_pCompositor->m_vMonitors.end(), + [](const auto m) { return !m->m_bEnabled || g_pCompositor->m_pUnsafeOutput == m.get(); }); + if (allDisabled) { + Debug::log(LOG, "OutputMgr apply: All monitors disabled; performing monitor reload."); + g_pConfigManager->performMonitorReload(); + } + } if (ok) wlr_output_configuration_v1_send_succeeded(config); else wlr_output_configuration_v1_send_failed(config); + wlr_output_configuration_v1_destroy(config); Debug::log(LOG, "OutputMgr Applied/Tested."); @@ -1645,7 +1655,6 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR // if it's disabled, disable and ignore if (pMonitorRule->disabled) { - if (pMonitor->m_bEnabled) pMonitor->onDisconnect();