aboutsummaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
authorChristian Meissl <meissl.christian@gmail.com>2024-01-28 16:18:52 +0100
committerIvan Molodetskikh <yalterz@gmail.com>2024-01-30 08:03:21 +0400
commitb813f99abd2d6e09eb72e8c0083e92b486b4b210 (patch)
tree6c2a87e3b5ffe806a532bdb52de5655babaae785 /src/backend
parentd9b9cec8b850d5ff404f79d2183a02c619423a4a (diff)
downloadniri-b813f99abd2d6e09eb72e8c0083e92b486b4b210.tar.gz
niri-b813f99abd2d6e09eb72e8c0083e92b486b4b210.tar.bz2
niri-b813f99abd2d6e09eb72e8c0083e92b486b4b210.zip
tty: reset surface state after changing monitor state
changing the "ACTIVE" property of a surface requires to re-evaluate the surface state.
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/mod.rs2
-rw-r--r--src/backend/tty.rs24
2 files changed, 19 insertions, 7 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:?}");
+ }
}
}
}