aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/mod.rs2
-rw-r--r--src/backend/tty.rs24
-rw-r--r--src/input.rs4
-rw-r--r--src/niri.rs4
4 files changed, 23 insertions, 11 deletions
diff --git a/src/backend/mod.rs b/src/backend/mod.rs
index 595b8513..588a6d33 100644
--- a/src/backend/mod.rs
+++ b/src/backend/mod.rs
@@ -138,7 +138,7 @@ impl Backend {
}
}
- pub fn set_monitors_active(&self, active: bool) {
+ pub fn set_monitors_active(&mut self, active: bool) {
match self {
Backend::Tty(tty) => tty.set_monitors_active(active),
Backend::Winit(_) => (),
diff --git a/src/backend/tty.rs b/src/backend/tty.rs
index 85e3c998..c1fba4e1 100644
--- a/src/backend/tty.rs
+++ b/src/backend/tty.rs
@@ -728,7 +728,7 @@ impl Tty {
// Power on all monitors if necessary and queue a redraw on the new one.
niri.event_loop.insert_idle(move |state| {
- state.niri.activate_monitors(&state.backend);
+ state.niri.activate_monitors(&mut state.backend);
state.niri.queue_redraw(output);
});
@@ -1031,7 +1031,7 @@ impl Tty {
niri.send_dmabuf_feedbacks(output, dmabuf_feedback, &res.states);
}
- if res.damage.is_some() {
+ if !res.is_empty {
let presentation_feedbacks =
niri.take_presentation_feedbacks(output, &res.states);
let data = (presentation_feedbacks, target_presentation_time);
@@ -1196,10 +1196,22 @@ impl Tty {
self.devices.get(&self.primary_node).map(|d| d.gbm.clone())
}
- pub fn set_monitors_active(&self, active: bool) {
- for device in self.devices.values() {
- for crtc in device.surfaces.keys() {
- set_crtc_active(&device.drm, *crtc, active);
+ pub fn set_monitors_active(&mut self, active: bool) {
+ // We only disable the CRTC here, this will also reset the
+ // surface state so that the next call to `render_frame` will
+ // always produce a new frame and `queue_frame` will change
+ // the CRTC to active. This makes sure we always enable a CRTC
+ // within an atomic operation.
+ if active {
+ return;
+ }
+
+ for device in self.devices.values_mut() {
+ for (crtc, surface) in device.surfaces.iter_mut() {
+ set_crtc_active(&device.drm, *crtc, false);
+ if let Err(err) = surface.compositor.reset_state() {
+ warn!("error resetting surface state: {err:?}");
+ }
}
}
}
diff --git a/src/input.rs b/src/input.rs
index b9b91545..0b671b4d 100644
--- a/src/input.rs
+++ b/src/input.rs
@@ -51,7 +51,7 @@ impl State {
// Power on monitors if they were off.
if should_activate_monitors(&event) {
- self.niri.activate_monitors(&self.backend);
+ self.niri.activate_monitors(&mut self.backend);
}
let hide_hotkey_overlay =
@@ -284,7 +284,7 @@ impl State {
self.niri.suppressed_keys.clear();
}
Action::PowerOffMonitors => {
- self.niri.deactivate_monitors(&self.backend);
+ self.niri.deactivate_monitors(&mut self.backend);
}
Action::ToggleDebugTint => {
self.backend.toggle_debug_tint();
diff --git a/src/niri.rs b/src/niri.rs
index 1bb8a6d0..e0f5a498 100644
--- a/src/niri.rs
+++ b/src/niri.rs
@@ -1310,7 +1310,7 @@ impl Niri {
self.queue_redraw(output);
}
- pub fn deactivate_monitors(&mut self, backend: &Backend) {
+ pub fn deactivate_monitors(&mut self, backend: &mut Backend) {
if !self.monitors_active {
return;
}
@@ -1319,7 +1319,7 @@ impl Niri {
backend.set_monitors_active(false);
}
- pub fn activate_monitors(&mut self, backend: &Backend) {
+ pub fn activate_monitors(&mut self, backend: &mut Backend) {
if self.monitors_active {
return;
}