aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-10-20 20:15:06 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2024-10-20 20:18:56 +0300
commit55fb885256aac6aaf0c3fd645a9c9511f107d5fd (patch)
tree25c5060f95cff92f37d04e433a8335d243c51d2a /src/backend
parent73a531f8bc68b4c73b086c4215d0c3f331491c83 (diff)
downloadniri-55fb885256aac6aaf0c3fd645a9c9511f107d5fd.tar.gz
niri-55fb885256aac6aaf0c3fd645a9c9511f107d5fd.tar.bz2
niri-55fb885256aac6aaf0c3fd645a9c9511f107d5fd.zip
Use new Smithay method for turning off DPMS
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/tty.rs30
1 files changed, 11 insertions, 19 deletions
diff --git a/src/backend/tty.rs b/src/backend/tty.rs
index d836b6a6..439270a9 100644
--- a/src/backend/tty.rs
+++ b/src/backend/tty.rs
@@ -1019,6 +1019,14 @@ impl Tty {
}
}
+ // 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 {
+ if let Err(err) = compositor.clear() {
+ warn!("error clearing drm surface: {err:?}");
+ }
+ }
+
let vblank_frame_name =
tracy_client::FrameName::new_leak(format!("vblank on {connector_name}"));
let time_since_presentation_plot_name = tracy_client::PlotName::new_leak(format!(
@@ -1050,15 +1058,11 @@ impl Tty {
niri.add_output(output.clone(), Some(refresh_interval(mode)), vrr_enabled);
- // 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(())
@@ -1659,10 +1663,9 @@ impl Tty {
}
for device in self.devices.values_mut() {
- for (crtc, surface) in device.surfaces.iter_mut() {
- set_crtc_active(&device.drm, *crtc, false);
- if let Err(err) = surface.compositor.reset_state() {
- warn!("error resetting surface state: {err:?}");
+ for surface in device.surfaces.values_mut() {
+ if let Err(err) = surface.compositor.clear() {
+ warn!("error clearing drm surface: {err:?}");
}
}
}
@@ -2154,17 +2157,6 @@ fn get_drm_property(
.find_map(|(handle, value)| (handle == prop).then_some(value))
}
-fn set_crtc_active(drm: &DrmDevice, crtc: crtc::Handle, active: bool) {
- let Some((prop, _, _)) = find_drm_property(drm, crtc, "ACTIVE") else {
- return;
- };
-
- let value = property::Value::Boolean(active);
- if let Err(err) = drm.set_property(crtc, prop, value.into()) {
- warn!("error setting CRTC property: {err:?}");
- }
-}
-
fn refresh_interval(mode: DrmMode) -> Duration {
let clock = mode.clock() as u64;
let htotal = mode.hsync().2 as u64;