forge
Explore
Log in

Don't you dare go Hollow

Use new Smithay method for turning off DPMS

Browse files at this commit

55fb885256aac6aaf0c3fd645a9c9511f107d5fdIvan MolodetskikhParent: 73a531f
src/backend/tty.rsmodified+11 -19
@@ -1019,6 +1019,14 @@ impl Tty {
1019 }1019 }
1020 }1020 }
1021 1021
1022+ // Some buggy monitors replug upon powering off, so powering on here would prevent such
1023+ // monitors from powering off. Therefore, we avoid unconditionally powering on.
1024+ if !niri.monitors_active {
1025+ if let Err(err) = compositor.clear() {
1026+ warn!("error clearing drm surface: {err:?}");
1027+ }
1028+ }
1029+
1022 let vblank_frame_name =1030 let vblank_frame_name =
1023 tracy_client::FrameName::new_leak(format!("vblank on {connector_name}"));1031 tracy_client::FrameName::new_leak(format!("vblank on {connector_name}"));
1024 let time_since_presentation_plot_name = tracy_client::PlotName::new_leak(format!(1032 let time_since_presentation_plot_name = tracy_client::PlotName::new_leak(format!(
@@ -1050,15 +1058,11 @@ impl Tty {
1050 1058
1051 niri.add_output(output.clone(), Some(refresh_interval(mode)), vrr_enabled);1059 niri.add_output(output.clone(), Some(refresh_interval(mode)), vrr_enabled);
1052 1060
1053- // Some buggy monitors replug upon powering off, so powering on here would prevent such
1054- // monitors from powering off. Therefore, we avoid unconditionally powering on.
1055 if niri.monitors_active {1061 if niri.monitors_active {
1056 // Redraw the new monitor.1062 // Redraw the new monitor.
1057 niri.event_loop.insert_idle(move |state| {1063 niri.event_loop.insert_idle(move |state| {
1058 state.niri.queue_redraw(&output);1064 state.niri.queue_redraw(&output);
1059 });1065 });
1060- } else {
1061- set_crtc_active(&device.drm, crtc, false);
1062 }1066 }
1063 1067
1064 Ok(())1068 Ok(())
@@ -1659,10 +1663,9 @@ impl Tty {
1659 }1663 }
1660 1664
1661 for device in self.devices.values_mut() {1665 for device in self.devices.values_mut() {
1662- for (crtc, surface) in device.surfaces.iter_mut() {1666+ for surface in device.surfaces.values_mut() {
1663- set_crtc_active(&device.drm, *crtc, false);1667+ if let Err(err) = surface.compositor.clear() {
1664- if let Err(err) = surface.compositor.reset_state() {1668+ warn!("error clearing drm surface: {err:?}");
1665- warn!("error resetting surface state: {err:?}");
1666 }1669 }
1667 }1670 }
1668 }1671 }
@@ -2154,17 +2157,6 @@ fn get_drm_property(
2154 .find_map(|(handle, value)| (handle == prop).then_some(value))2157 .find_map(|(handle, value)| (handle == prop).then_some(value))
2155 }2158 }
2156 2159
2157-fn set_crtc_active(drm: &DrmDevice, crtc: crtc::Handle, active: bool) {
2158- let Some((prop, _, _)) = find_drm_property(drm, crtc, "ACTIVE") else {
2159- return;
2160- };
2161-
2162- let value = property::Value::Boolean(active);
2163- if let Err(err) = drm.set_property(crtc, prop, value.into()) {
2164- warn!("error setting CRTC property: {err:?}");
2165- }
2166-}
2167-
2168 fn refresh_interval(mode: DrmMode) -> Duration {2160 fn refresh_interval(mode: DrmMode) -> Duration {
2169 let clock = mode.clock() as u64;2161 let clock = mode.clock() as u64;
2170 let htotal = mode.hsync().2 as u64;2162 let htotal = mode.hsync().2 as u64;