monitor: ensure swapchain is updated before mode test (#14065)

* monitor: ensure swapchain is updated before mode test

* monitor: ensure swapchain update via helper for all mode set paths

* monitor: fix formatting

* monitor: move swapchain helper to CMonitorState

* monitor: move swapchain helper to CMonitorState
This commit is contained in:
Visal Vijay 2026-04-14 22:54:44 +05:30 committed by GitHub
parent e539d21174
commit 88f3e7e9d5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 4 deletions

View file

@ -827,7 +827,7 @@ bool CMonitor::applyMonitorRule(Config::CMonitorRule&& pMonitorRule, bool force)
std::string modeStr = std::format("{:X0}@{:.2f}Hz", mode->pixelSize, mode->refreshRate / 1000.f);
if (mode->modeInfo.has_value() && mode->modeInfo->type == DRM_MODE_TYPE_USERDEF) {
m_output->state->setCustomMode(mode);
m_state.applyCustomModeWithSwapchain(mode);
if (!m_state.test()) {
Log::logger->log(Log::ERR, "Monitor {}: REJECTED custom mode {}!", m_name, modeStr);
@ -836,7 +836,7 @@ bool CMonitor::applyMonitorRule(Config::CMonitorRule&& pMonitorRule, bool force)
m_customDrmMode = mode->modeInfo.value();
} else {
m_output->state->setMode(mode);
m_state.applyModeWithSwapchain(mode);
if (!m_state.test()) {
Log::logger->log(Log::ERR, "Monitor {}: REJECTED available mode {}!", m_name, modeStr);
@ -870,7 +870,7 @@ bool CMonitor::applyMonitorRule(Config::CMonitorRule&& pMonitorRule, bool force)
auto mode = makeShared<Aquamarine::SOutputMode>(Aquamarine::SOutputMode{.pixelSize = RULE->m_resolution, .refreshRate = refreshRate});
std::string modeStr = std::format("{:X0}@{:.2f}Hz", mode->pixelSize, mode->refreshRate / 1000.f);
m_output->state->setCustomMode(mode);
m_state.applyCustomModeWithSwapchain(mode);
if (m_state.test()) {
Log::logger->log(Log::DEBUG, "Monitor {}: requested {}, using custom mode {}", m_name, requestedStr, modeStr);
@ -888,7 +888,7 @@ bool CMonitor::applyMonitorRule(Config::CMonitorRule&& pMonitorRule, bool force)
// try any of the modes if none of the above work
if (!success) {
for (auto const& mode : m_output->modes) {
m_output->state->setMode(mode);
m_state.applyModeWithSwapchain(mode);
if (!m_state.test())
continue;
@ -2478,6 +2478,15 @@ bool CMonitorState::updateSwapchain() {
options.size = MODE->pixelSize;
return m_owner->m_output->swapchain->reconfigure(options);
}
void CMonitorState::applyModeWithSwapchain(const SP<Aquamarine::SOutputMode>& mode) {
m_owner->m_output->state->setMode(mode);
updateSwapchain();
}
void CMonitorState::applyCustomModeWithSwapchain(const SP<Aquamarine::SOutputMode>& mode) {
m_owner->m_output->state->setCustomMode(mode);
updateSwapchain();
}
bool CMonitor::needsACopyFB() {
return !m_mirrors.empty() || Screenshare::mgr()->isOutputBeingSSd(m_self.lock());

View file

@ -92,6 +92,8 @@ class CMonitorState {
bool commit();
bool test();
bool updateSwapchain();
void applyModeWithSwapchain(const SP<Aquamarine::SOutputMode>& mode);
void applyCustomModeWithSwapchain(const SP<Aquamarine::SOutputMode>& mode);
private:
void ensureBufferPresent();