Skip rendering when backend is inactive

This commit is contained in:
Ivan Molodetskikh
2023-09-26 10:42:56 +04:00
parent ac16717f4e
commit 906ee36a93
3 changed files with 19 additions and 0 deletions
+7
View File
@@ -100,6 +100,13 @@ impl Backend {
}
}
pub fn is_active(&self) -> bool {
match self {
Backend::Tty(tty) => tty.is_active(),
Backend::Winit(_) => true,
}
}
pub fn tty(&mut self) -> &mut Tty {
if let Self::Tty(v) = self {
v
+8
View File
@@ -813,6 +813,14 @@ impl Tty {
pub fn gbm_device(&self) -> Option<GbmDevice<DrmDeviceFd>> {
self.output_device.as_ref().map(|d| d.gbm.clone())
}
pub fn is_active(&self) -> bool {
let Some(device) = &self.output_device else {
return false;
};
device.drm.is_active()
}
}
fn refresh_interval(mode: DrmMode) -> Duration {
+4
View File
@@ -945,6 +945,10 @@ impl Niri {
fn redraw(&mut self, backend: &mut Backend, output: &Output) {
let _span = tracy_client::span!("Niri::redraw");
if !backend.is_active() {
return;
}
let Some(renderer) = backend.renderer() else {
return;
};