From 105938df0bffefaf09beb576e7b9b22f159ce5eb Mon Sep 17 00:00:00 2001 From: it-a-me <92066678+it-a-me@users.noreply.github.com> Date: Tue, 2 Jul 2024 01:21:07 -0700 Subject: Keep monitors powered off upon connecting a new one (#488) * Keep monitors powered off upon connecting a new one Update src/backend/tty.rs Co-authored-by: Ivan Molodetskikh Update src/backend/tty.rs Co-authored-by: Ivan Molodetskikh fix tests * Update --------- Co-authored-by: Ivan Molodetskikh --- src/backend/tty.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/backend/tty.rs b/src/backend/tty.rs index ff806723..54fc97c1 100644 --- a/src/backend/tty.rs +++ b/src/backend/tty.rs @@ -965,16 +965,22 @@ impl Tty { presentation_misprediction_plot_name, sequence_delta_plot_name, }; + let res = device.surfaces.insert(crtc, surface); assert!(res.is_none(), "crtc must not have already existed"); niri.add_output(output.clone(), Some(refresh_interval(mode)), vrr_enabled); - // Power on all monitors if necessary and queue a redraw on the new one. - niri.event_loop.insert_idle(move |state| { - state.niri.activate_monitors(&mut state.backend); - state.niri.queue_redraw(&output); - }); + // Some buggy monitors replug upon powering off, so powering on here would prevent such + // monitors from powering off. Therefore, we avoid unconditionally powering on. + if niri.monitors_active { + // Redraw the new monitor. + niri.event_loop.insert_idle(move |state| { + state.niri.queue_redraw(&output); + }); + } else { + set_crtc_active(&device.drm, crtc, false); + } Ok(()) } -- cgit