forge
Explore
Log in

Don't you dare go Hollow

tty: Disable dmabuf global before destroying

Browse files at this commit

ac6ff7ff410a5874680dbfd1cf1023dabc623c43Ivan MolodetskikhParent: 84befb4
src/backend/tty.rsmodified+16 -2
@@ -402,10 +402,24 @@ impl Tty {
402 }402 }
403 403
404 let mut device = self.output_device.take().unwrap();404 let mut device = self.output_device.take().unwrap();
405- niri.dmabuf_state
406- .destroy_global::<State>(&niri.display_handle, self.dmabuf_global.take().unwrap());
407 device.gles.unbind_wl_display();405 device.gles.unbind_wl_display();
408 406
407+ let global = self.dmabuf_global.take().unwrap();
408+ niri.dmabuf_state
409+ .disable_global::<State>(&niri.display_handle, &global);
410+ niri.event_loop
411+ .insert_source(
412+ Timer::from_duration(Duration::from_secs(10)),
413+ move |_, _, state| {
414+ state
415+ .niri
416+ .dmabuf_state
417+ .destroy_global::<State>(&state.niri.display_handle, global);
418+ TimeoutAction::Drop
419+ },
420+ )
421+ .unwrap();
422+
409 niri.event_loop.remove(device.token);423 niri.event_loop.remove(device.token);
410 }424 }
411 425
src/handlers/mod.rsmodified+5 -3
@@ -202,9 +202,11 @@ impl DmabufHandler for State {
202 dmabuf: Dmabuf,202 dmabuf: Dmabuf,
203 notifier: ImportNotifier,203 notifier: ImportNotifier,
204 ) {204 ) {
205- let renderer = self.backend.renderer().expect(205+ let Some(renderer) = self.backend.renderer() else {
206- "the dmabuf global must be created and destroyed together with the output device",206+ notifier.failed();
207- );207+ return;
208+ };
209+
208 match renderer.import_dmabuf(&dmabuf, None) {210 match renderer.import_dmabuf(&dmabuf, None) {
209 Ok(_texture) => {211 Ok(_texture) => {
210 let _ = notifier.successful::<State>();212 let _ = notifier.successful::<State>();