aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backend/tty.rs18
-rw-r--r--src/handlers/mod.rs8
2 files changed, 21 insertions, 5 deletions
diff --git a/src/backend/tty.rs b/src/backend/tty.rs
index 81f56102..07b5cd3f 100644
--- a/src/backend/tty.rs
+++ b/src/backend/tty.rs
@@ -402,10 +402,24 @@ impl Tty {
}
let mut device = self.output_device.take().unwrap();
- niri.dmabuf_state
- .destroy_global::<State>(&niri.display_handle, self.dmabuf_global.take().unwrap());
device.gles.unbind_wl_display();
+ let global = self.dmabuf_global.take().unwrap();
+ niri.dmabuf_state
+ .disable_global::<State>(&niri.display_handle, &global);
+ niri.event_loop
+ .insert_source(
+ Timer::from_duration(Duration::from_secs(10)),
+ move |_, _, state| {
+ state
+ .niri
+ .dmabuf_state
+ .destroy_global::<State>(&state.niri.display_handle, global);
+ TimeoutAction::Drop
+ },
+ )
+ .unwrap();
+
niri.event_loop.remove(device.token);
}
diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs
index 42f83a62..f7d94ed0 100644
--- a/src/handlers/mod.rs
+++ b/src/handlers/mod.rs
@@ -202,9 +202,11 @@ impl DmabufHandler for State {
dmabuf: Dmabuf,
notifier: ImportNotifier,
) {
- let renderer = self.backend.renderer().expect(
- "the dmabuf global must be created and destroyed together with the output device",
- );
+ let Some(renderer) = self.backend.renderer() else {
+ notifier.failed();
+ return;
+ };
+
match renderer.import_dmabuf(&dmabuf, None) {
Ok(_texture) => {
let _ = notifier.successful::<State>();