Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

salcodes1
Copy link

Describe your PR, what does it fix/add?

Aims to enable functionality described in #10147 .

From commit message:

  • suppressvrr is a type of windowrule
  • whenever a matching window is visible on-screen in the current workspace of a monitor, that particular monitor will necessarily prevent VRR from being enabled.
  • this rule works in conjunction with misc:vrr and per-monitor VRR settings and gets applied last in the vrr logic
  • example usage: windowrule = suppressvrr, class:nemo will prevent VRR on any monitors that currently display a nemo window
  • as a small optimization, a workspace that has a fullscreen window will either necessarily suppress VRR or not depending on whether that particular window was matched for suppressvrr. Whether other windows in that workspace match for suppressvrr or not is irrelevant to this logic.

Is there anything you want to mention? (unchecked code, possible bugs, found problems, breaking compatibility, etc.)

As this is my first contribution to the project, I am not sure whether I put the additional calls to ensureVRR in the correct, canonical places. For now, I added the calls inside the listeners for mapping/unmapping.

Is it ready for merging, or does it need work?

Should be good to go afaik, aside from the question raised above.

- `suppressvrr` is a type of `windowrule`
- whenever a matching window is visible on-screen in the current workspace of a monitor, that particular monitor will necessarily prevent VRR from being enabled.
- this rule works in conjunction with misc:vrr and per-monitor vrr settings and gets applied last in the vrr logic
- example usage: `windowrule = suppressvrr, class:nemo` will prevent VRR on any monitors that currently display a nemo window
- as a small optimization, a workspace that has a fullscreen window will either necessarily suppress VRR or not depending on whether that particular window was matched for `suppressvrr`. Whether other windows in that workspace match for `suppressvrr` is irrelevant to this logic.
@salcodes1 salcodes1 changed the title renderer: added windowrule type suppressvrr renderer: add windowrule type suppressvrr May 6, 2025
@@ -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());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redundant

@@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redundant

const auto PWORKSPACE = m->m_activeWorkspace;
if (PWORKSPACE) {
auto vrrSuppressingWindows = 0;
std::optional<bool> fullscreenWindowSuppressing = std::nullopt;
Copy link
Member

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

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()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prefer guards

}
for (auto const& w : g_pCompositor->m_windows) {
if (w->m_isMapped && w->workspaceID() == PWORKSPACE->m_id && !w->isHidden()) {
if (w->m_suppressVrr)
Copy link
Member

Choose a reason for hiding this comment

The 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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can break afterwards

// 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)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no {}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants