aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backend/mod.rs7
-rw-r--r--src/backend/tty.rs8
-rw-r--r--src/niri.rs4
3 files changed, 19 insertions, 0 deletions
diff --git a/src/backend/mod.rs b/src/backend/mod.rs
index aaad7822..6475cab1 100644
--- a/src/backend/mod.rs
+++ b/src/backend/mod.rs
@@ -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
diff --git a/src/backend/tty.rs b/src/backend/tty.rs
index 5204c44a..9cfd46ee 100644
--- a/src/backend/tty.rs
+++ b/src/backend/tty.rs
@@ -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 {
diff --git a/src/niri.rs b/src/niri.rs
index 9aa0e027..777554fe 100644
--- a/src/niri.rs
+++ b/src/niri.rs
@@ -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;
};