Keep monitors powered off upon connecting a new one (#488)
Browse files at this commit1 changed file +11 -5
- src/backend/tty.rs +11 -5
src/backend/tty.rsmodified+11 -5
| @@ -965,16 +965,22 @@ impl Tty { | |||
| 965 | presentation_misprediction_plot_name, | 965 | presentation_misprediction_plot_name, |
| 966 | sequence_delta_plot_name, | 966 | sequence_delta_plot_name, |
| 967 | }; | 967 | }; |
| 968 | + | ||
| 968 | let res = device.surfaces.insert(crtc, surface); | 969 | let res = device.surfaces.insert(crtc, surface); |
| 969 | assert!(res.is_none(), "crtc must not have already existed"); | 970 | assert!(res.is_none(), "crtc must not have already existed"); |
| 970 | 971 | ||
| 971 | niri.add_output(output.clone(), Some(refresh_interval(mode)), vrr_enabled); | 972 | niri.add_output(output.clone(), Some(refresh_interval(mode)), vrr_enabled); |
| 972 | 973 | ||
| 973 | - // Power on all monitors if necessary and queue a redraw on the new one. | 974 | + // Some buggy monitors replug upon powering off, so powering on here would prevent such |
| 974 | - niri.event_loop.insert_idle(move |state| { | 975 | + // monitors from powering off. Therefore, we avoid unconditionally powering on. |
| 975 | - state.niri.activate_monitors(&mut state.backend); | 976 | + if niri.monitors_active { |
| 976 | - state.niri.queue_redraw(&output); | 977 | + // Redraw the new monitor. |
| 977 | - }); | 978 | + niri.event_loop.insert_idle(move |state| { |
| 979 | + state.niri.queue_redraw(&output); | ||
| 980 | + }); | ||
| 981 | + } else { | ||
| 982 | + set_crtc_active(&device.drm, crtc, false); | ||
| 983 | + } | ||
| 978 | 984 | ||
| 979 | Ok(()) | 985 | Ok(()) |
| 980 | } | 986 | } |