diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index 0a59ca6f..bb9ae17f 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -126,7 +126,7 @@ void CMonitor::onConnect(bool noRule) { g_pHyprRenderer->applyMonitorRule(this, &monitorRule, true); if (!state.commit()) - Debug::log(WARN, "wlr_output_commit_state failed in CMonitor::onCommit"); + Debug::log(WARN, "state.commit() failed in CMonitor::onCommit"); damage.setSize(vecTransformedSize); @@ -775,10 +775,24 @@ CMonitorState::~CMonitorState() { } bool CMonitorState::commit() { + if (!updateSwapchain()) + return false; bool ret = m_pOwner->output->commit(); return ret; } bool CMonitorState::test() { + if (!updateSwapchain()) + return false; return m_pOwner->output->test(); } + +bool CMonitorState::updateSwapchain() { + auto options = m_pOwner->output->swapchain->currentOptions(); + const auto& STATE = m_pOwner->output->state->state(); + options.format = STATE.drmFormat; + options.scanout = true; + options.length = 2; + options.size = STATE.mode ? STATE.mode->pixelSize : STATE.customMode->pixelSize; + return m_pOwner->output->swapchain->reconfigure(options); +} diff --git a/src/helpers/Monitor.hpp b/src/helpers/Monitor.hpp index 87c73a14..a221e1e9 100644 --- a/src/helpers/Monitor.hpp +++ b/src/helpers/Monitor.hpp @@ -49,6 +49,7 @@ class CMonitorState { bool commit(); bool test(); + bool updateSwapchain(); private: CMonitor* m_pOwner; diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index a0591416..e9edf2b9 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -2607,18 +2607,6 @@ bool CHyprRenderer::beginRender(CMonitor* pMonitor, CRegion& damage, eRenderMode static constexpr const int HL_BUFFER_AGE = 2; if (!buffer) { - const auto& MODE = pMonitor->output->state->state().mode ? pMonitor->output->state->state().mode : pMonitor->output->state->state().customMode; - if (!MODE) // no mode?? - return false; - Aquamarine::SSwapchainOptions opts = pMonitor->output->swapchain->currentOptions(); - opts.length = 2; - opts.size = MODE->pixelSize; - opts.format = pMonitor->output->state->state().drmFormat; - if (!pMonitor->output->swapchain->reconfigure(opts)) { - Debug::log(ERR, "Failed to reconfigure swapchain for {}", pMonitor->szName); - return false; - } - m_pCurrentBuffer = pMonitor->output->swapchain->next(nullptr); if (!m_pCurrentBuffer) { Debug::log(ERR, "Failed to acquire swapchain buffer for {}", pMonitor->szName);