-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
renderer: add windowrule type suppressvrr #10300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1683,33 +1683,15 @@ void CConfigManager::ensureVRR(PHLMONITOR pMonitor) { | |
if (!m->m_output || m->m_createdByUser) | ||
return; | ||
|
||
const auto OLDVRRSTATUS = m->m_vrrActive; | ||
auto NEWVRRSTATUS = m->m_vrrActive; | ||
|
||
const auto USEVRR = m->m_activeMonitorRule.vrr.has_value() ? m->m_activeMonitorRule.vrr.value() : **PVRR; | ||
|
||
if (USEVRR == 0) { | ||
if (m->m_vrrActive) { | ||
m->m_output->state->resetExplicitFences(); | ||
m->m_output->state->setAdaptiveSync(false); | ||
|
||
if (!m->m_state.commit()) | ||
Debug::log(ERR, "Couldn't commit output {} in ensureVRR -> false", m->m_output->name); | ||
} | ||
m->m_vrrActive = false; | ||
return; | ||
NEWVRRSTATUS = false; | ||
} else if (USEVRR == 1) { | ||
if (!m->m_vrrActive) { | ||
m->m_output->state->resetExplicitFences(); | ||
m->m_output->state->setAdaptiveSync(true); | ||
|
||
if (!m->m_state.test()) { | ||
Debug::log(LOG, "Pending output {} does not accept VRR.", m->m_output->name); | ||
m->m_output->state->setAdaptiveSync(false); | ||
} | ||
|
||
if (!m->m_state.commit()) | ||
Debug::log(ERR, "Couldn't commit output {} in ensureVRR -> true", m->m_output->name); | ||
} | ||
m->m_vrrActive = true; | ||
return; | ||
NEWVRRSTATUS = true; | ||
} else if (USEVRR == 2 || USEVRR == 3) { | ||
const auto PWORKSPACE = m->m_activeWorkspace; | ||
|
||
|
@@ -1722,23 +1704,61 @@ void CConfigManager::ensureVRR(PHLMONITOR pMonitor) { | |
wantVRR = contentType == CONTENT_TYPE_GAME || contentType == CONTENT_TYPE_VIDEO; | ||
} | ||
|
||
if (wantVRR) { | ||
/* fullscreen */ | ||
m->m_vrrActive = true; | ||
NEWVRRSTATUS = wantVRR; | ||
} | ||
|
||
if (!m->m_output->state->state().adaptiveSync) { | ||
m->m_output->state->setAdaptiveSync(true); | ||
// search for windows within workspace that should suppress VRR | ||
const auto PWORKSPACE = m->m_activeWorkspace; | ||
if (PWORKSPACE) { | ||
auto vrrSuppressingWindows = 0; | ||
std::optional<bool> fullscreenWindowSuppressing = std::nullopt; | ||
|
||
if (!m->m_state.test()) { | ||
Debug::log(LOG, "Pending output {} does not accept VRR.", m->m_output->name); | ||
m->m_output->state->setAdaptiveSync(false); | ||
} | ||
for (auto const& w : g_pCompositor->m_windows) { | ||
if (w->m_isMapped && w->workspaceID() == PWORKSPACE->m_id && !w->isHidden()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. prefer guards |
||
if (w->m_suppressVrr) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. other windows dont matter, only the fs one |
||
vrrSuppressingWindows++; | ||
|
||
if (w->isFullscreen()) | ||
fullscreenWindowSuppressing = w->m_suppressVrr; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can break afterwards |
||
} | ||
} else { | ||
m->m_vrrActive = false; | ||
} | ||
|
||
auto FSWINDOW = PWORKSPACE->getFullscreenWindow(); | ||
|
||
// * if there exists a fullscreen window in the workspace, disable VRR solely based on | ||
// whether that window is `suppressvrr` or not; | ||
// * if there doesn't exist one, then disable VRR for at least one visible window that is `suppressvrr` | ||
|
||
if (fullscreenWindowSuppressing == true || (fullscreenWindowSuppressing == std::nullopt && vrrSuppressingWindows > 0)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no {} |
||
NEWVRRSTATUS = false; | ||
} | ||
} | ||
|
||
if (OLDVRRSTATUS && !NEWVRRSTATUS) { // VRR ON ~> OFF transition | ||
Debug::log(LOG, "VRR ON ~> OFF on output {}", m->m_output->name); | ||
m->m_output->state->resetExplicitFences(); | ||
m->m_output->state->setAdaptiveSync(false); | ||
|
||
if (!m->m_state.commit()) | ||
Debug::log(ERR, "Couldn't commit output {} in ensureVRR -> false", m->m_output->name); | ||
|
||
m->m_vrrActive = NEWVRRSTATUS; | ||
return; | ||
} else if (!OLDVRRSTATUS && NEWVRRSTATUS) { // VRR OFF ~> ON transition | ||
Debug::log(LOG, "VRR OFF ~> ON on output {}", m->m_output->name); | ||
m->m_output->state->resetExplicitFences(); | ||
m->m_output->state->setAdaptiveSync(true); | ||
|
||
if (!m->m_state.test()) { | ||
Debug::log(LOG, "Pending output {} does not accept VRR.", m->m_output->name); | ||
m->m_output->state->setAdaptiveSync(false); | ||
} | ||
|
||
if (!m->m_state.commit()) | ||
Debug::log(ERR, "Couldn't commit output {} in ensureVRR -> true", m->m_output->name); | ||
|
||
m->m_vrrActive = NEWVRRSTATUS; | ||
return; | ||
} | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -321,6 +321,11 @@ void Events::listener_mapWindow(void* owner, void* data) { | |
try { | ||
PWINDOW->m_closeableSince = Time::steadyNow() + std::chrono::milliseconds(std::stoull(VARS[1])); | ||
} catch (std::exception& e) { Debug::log(ERR, "Rule \"{}\" failed with: {}", r->m_rule, e.what()); } | ||
break; | ||
} | ||
case CWindowRule::RULE_SUPPRESSVRR: { | ||
PWINDOW->m_suppressVrr = true; | ||
break; | ||
} | ||
default: break; | ||
} | ||
|
@@ -710,6 +715,9 @@ void Events::listener_mapWindow(void* owner, void* data) { | |
|
||
if (PMONITOR && PWINDOW->isX11OverrideRedirect()) | ||
PWINDOW->m_X11SurfaceScaledBy = PMONITOR->m_scale; | ||
|
||
// VRR should update | ||
g_pConfigManager->ensureVRR(PWINDOW->m_monitor.lock()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. redundant |
||
} | ||
|
||
void Events::listener_unmapWindow(void* owner, void* data) { | ||
|
@@ -847,6 +855,9 @@ void Events::listener_unmapWindow(void* owner, void* data) { | |
|
||
// update lastwindow after focus | ||
PWINDOW->onUnmap(); | ||
|
||
// VRR should update | ||
g_pConfigManager->ensureVRR(PMONITOR); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. redundant |
||
} | ||
|
||
void Events::listener_commitWindow(void* owner, void* data) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can just be a bool = false and set to true in the loop if a matching window is found