monitor: clear output state after usage

fixes massive lag
This commit is contained in:
Vaxry 2024-01-27 19:11:03 +00:00
parent 8b1069b330
commit bc7e488a4c
4 changed files with 21 additions and 0 deletions

View file

@ -2321,6 +2321,8 @@ void CConfigManager::ensureVRR(CMonitor* pMonitor) {
if (!wlr_output_commit_state(m->output, &m->outputState)) if (!wlr_output_commit_state(m->output, &m->outputState))
Debug::log(ERR, "Couldn't commit output {} in ensureVRR -> false", m->output->name); Debug::log(ERR, "Couldn't commit output {} in ensureVRR -> false", m->output->name);
pMonitor->clearState();
} }
m->vrrActive = false; m->vrrActive = false;
return; return;
@ -2335,6 +2337,8 @@ void CConfigManager::ensureVRR(CMonitor* pMonitor) {
if (!wlr_output_commit_state(m->output, &m->outputState)) if (!wlr_output_commit_state(m->output, &m->outputState))
Debug::log(ERR, "Couldn't commit output {} in ensureVRR -> true", m->output->name); Debug::log(ERR, "Couldn't commit output {} in ensureVRR -> true", m->output->name);
pMonitor->clearState();
} }
m->vrrActive = true; m->vrrActive = true;
return; return;
@ -2360,11 +2364,15 @@ void CConfigManager::ensureVRR(CMonitor* pMonitor) {
if (!wlr_output_commit_state(m->output, &m->outputState)) if (!wlr_output_commit_state(m->output, &m->outputState))
Debug::log(ERR, "Couldn't commit output {} in ensureVRR -> true", m->output->name); Debug::log(ERR, "Couldn't commit output {} in ensureVRR -> true", m->output->name);
pMonitor->clearState();
} else if (!WORKSPACEFULL && m->output->adaptive_sync_status == WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED) { } else if (!WORKSPACEFULL && m->output->adaptive_sync_status == WLR_OUTPUT_ADAPTIVE_SYNC_ENABLED) {
wlr_output_state_set_adaptive_sync_enabled(&m->outputState, 0); wlr_output_state_set_adaptive_sync_enabled(&m->outputState, 0);
if (!wlr_output_commit_state(m->output, &m->outputState)) if (!wlr_output_commit_state(m->output, &m->outputState))
Debug::log(ERR, "Couldn't commit output {} in ensureVRR -> false", m->output->name); Debug::log(ERR, "Couldn't commit output {} in ensureVRR -> false", m->output->name);
pMonitor->clearState();
} }
} }
}; };

View file

@ -682,3 +682,9 @@ void CMonitor::updateMatrix() {
wlr_matrix_translate(projMatrix.data(), -vecTransformedSize.x / 2.0, -vecTransformedSize.y / 2.0); wlr_matrix_translate(projMatrix.data(), -vecTransformedSize.x / 2.0, -vecTransformedSize.y / 2.0);
} }
} }
void CMonitor::clearState() {
wlr_output_state_finish(&outputState);
outputState = {0};
wlr_output_state_init(&outputState);
}

View file

@ -128,6 +128,7 @@ class CMonitor {
void moveTo(const Vector2D& pos); void moveTo(const Vector2D& pos);
Vector2D middle(); Vector2D middle();
void updateMatrix(); void updateMatrix();
void clearState();
bool m_bEnabled = false; bool m_bEnabled = false;
bool m_bRenderingInitPassed = false; bool m_bRenderingInitPassed = false;

View file

@ -1244,9 +1244,13 @@ void CHyprRenderer::renderMonitor(CMonitor* pMonitor) {
if (UNLOCK_SC) if (UNLOCK_SC)
wlr_output_lock_software_cursors(pMonitor->output, false); wlr_output_lock_software_cursors(pMonitor->output, false);
pMonitor->clearState();
return; return;
} }
pMonitor->clearState();
if (shouldTear) if (shouldTear)
pMonitor->tearingState.busy = true; pMonitor->tearingState.busy = true;
@ -2080,6 +2084,8 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
Debug::log(ERR, "Couldn't commit output named {}", pMonitor->output->name); Debug::log(ERR, "Couldn't commit output named {}", pMonitor->output->name);
} }
pMonitor->clearState();
int x, y; int x, y;
wlr_output_transformed_resolution(pMonitor->output, &x, &y); wlr_output_transformed_resolution(pMonitor->output, &x, &y);
pMonitor->vecSize = (Vector2D(x, y) / pMonitor->scale).floor(); pMonitor->vecSize = (Vector2D(x, y) / pMonitor->scale).floor();