Skip rendering when backend is inactive
Browse files at this commit906ee36a934154221f1b8ef6d919f80e9ac950fbParent: ac167173 changed files +19 -0
- src/backend/mod.rs +7 -0
- src/backend/tty.rs +8 -0
- src/niri.rs +4 -0
src/backend/mod.rsmodified+7 -0
| @@ -100,6 +100,13 @@ impl Backend { | |||
| 100 | } | 100 | } |
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | + pub fn is_active(&self) -> bool { | ||
| 104 | + match self { | ||
| 105 | + Backend::Tty(tty) => tty.is_active(), | ||
| 106 | + Backend::Winit(_) => true, | ||
| 107 | + } | ||
| 108 | + } | ||
| 109 | + | ||
| 103 | pub fn tty(&mut self) -> &mut Tty { | 110 | pub fn tty(&mut self) -> &mut Tty { |
| 104 | if let Self::Tty(v) = self { | 111 | if let Self::Tty(v) = self { |
| 105 | v | 112 | v |
src/backend/tty.rsmodified+8 -0
| @@ -813,6 +813,14 @@ impl Tty { | |||
| 813 | pub fn gbm_device(&self) -> Option<GbmDevice<DrmDeviceFd>> { | 813 | pub fn gbm_device(&self) -> Option<GbmDevice<DrmDeviceFd>> { |
| 814 | self.output_device.as_ref().map(|d| d.gbm.clone()) | 814 | self.output_device.as_ref().map(|d| d.gbm.clone()) |
| 815 | } | 815 | } |
| 816 | + | ||
| 817 | + pub fn is_active(&self) -> bool { | ||
| 818 | + let Some(device) = &self.output_device else { | ||
| 819 | + return false; | ||
| 820 | + }; | ||
| 821 | + | ||
| 822 | + device.drm.is_active() | ||
| 823 | + } | ||
| 816 | } | 824 | } |
| 817 | 825 | ||
| 818 | fn refresh_interval(mode: DrmMode) -> Duration { | 826 | fn refresh_interval(mode: DrmMode) -> Duration { |
src/niri.rsmodified+4 -0
| @@ -945,6 +945,10 @@ impl Niri { | |||
| 945 | fn redraw(&mut self, backend: &mut Backend, output: &Output) { | 945 | fn redraw(&mut self, backend: &mut Backend, output: &Output) { |
| 946 | let _span = tracy_client::span!("Niri::redraw"); | 946 | let _span = tracy_client::span!("Niri::redraw"); |
| 947 | 947 | ||
| 948 | + if !backend.is_active() { | ||
| 949 | + return; | ||
| 950 | + } | ||
| 951 | + | ||
| 948 | let Some(renderer) = backend.renderer() else { | 952 | let Some(renderer) = backend.renderer() else { |
| 949 | return; | 953 | return; |
| 950 | }; | 954 | }; |