mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-24 02:01:18 +07:00
Skip rendering when backend is inactive
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user