aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2023-08-09 14:20:59 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2023-08-10 14:50:51 +0400
commit7527cad20035c87255826ee276658b0b89d58f7f (patch)
treeba8cdf5877ea5ff7bab12dec0c97bf7d2c00a1b3 /src
parentc50e22d415f09dd15e164cff06c76e95102f3cf6 (diff)
downloadniri-7527cad20035c87255826ee276658b0b89d58f7f.tar.gz
niri-7527cad20035c87255826ee276658b0b89d58f7f.tar.bz2
niri-7527cad20035c87255826ee276658b0b89d58f7f.zip
tty: Improve reselience to rendering errors
Diffstat (limited to 'src')
-rw-r--r--src/tty.rs53
1 files changed, 33 insertions, 20 deletions
diff --git a/src/tty.rs b/src/tty.rs
index 0c74ee66..bc5fe907 100644
--- a/src/tty.rs
+++ b/src/tty.rs
@@ -33,6 +33,7 @@ use smithay_drm_extras::edid::EdidInfo;
use crate::backend::Backend;
use crate::{LoopData, Niri};
+const BACKGROUND_COLOR: [f32; 4] = [0.1, 0.1, 0.1, 1.];
const SUPPORTED_COLOR_FORMATS: &[Fourcc] = &[Fourcc::Argb8888, Fourcc::Abgr8888];
pub struct Tty {
@@ -68,28 +69,40 @@ impl Backend for Tty {
elements: &[SpaceRenderElements<GlesRenderer, WaylandSurfaceRenderElement<GlesRenderer>>],
) {
let output_device = self.output_device.as_mut().unwrap();
- let res = output_device
- .drm_compositor
- .render_frame::<_, _, GlesRenderbuffer>(
- &mut output_device.gles,
- elements,
- [0.1, 0.1, 0.1, 1.],
+ let drm_compositor = &mut output_device.drm_compositor;
+
+ match drm_compositor.render_frame::<_, _, GlesRenderbuffer>(
+ &mut output_device.gles,
+ elements,
+ BACKGROUND_COLOR,
+ ) {
+ Ok(res) => {
+ assert!(!res.needs_sync());
+ if res.damage.is_some() {
+ match output_device.drm_compositor.queue_frame(()) {
+ Ok(()) => return,
+ Err(err) => {
+ error!("error queueing frame: {err}");
+ }
+ }
+ }
+ }
+ Err(err) => {
+ // Can fail if we switched to a different TTY.
+ error!("error rendering frame: {err}");
+ }
+ }
+
+ // FIXME: render on demand instead of busy looping.
+ niri.event_loop
+ .insert_source(
+ Timer::from_duration(Duration::from_millis(6)),
+ |_, _, data| {
+ data.niri.redraw(data.tty.as_mut().unwrap());
+ TimeoutAction::Drop
+ },
)
.unwrap();
- assert!(!res.needs_sync());
- if res.damage.is_some() {
- output_device.drm_compositor.queue_frame(()).unwrap();
- } else {
- niri.event_loop
- .insert_source(
- Timer::from_duration(Duration::from_millis(6)),
- |_, _, data| {
- data.niri.redraw(data.tty.as_mut().unwrap());
- TimeoutAction::Drop
- },
- )
- .unwrap();
- }
}
}