tty: Disable dmabuf global before destroying

This commit is contained in:
Ivan Molodetskikh
2024-01-01 09:57:51 +04:00
parent 84befb4e91
commit ac6ff7ff41
2 changed files with 21 additions and 5 deletions
+16 -2
View File
@@ -402,10 +402,24 @@ impl Tty {
} }
let mut device = self.output_device.take().unwrap(); 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(); 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); niri.event_loop.remove(device.token);
} }
+5 -3
View File
@@ -202,9 +202,11 @@ impl DmabufHandler for State {
dmabuf: Dmabuf, dmabuf: Dmabuf,
notifier: ImportNotifier, notifier: ImportNotifier,
) { ) {
let renderer = self.backend.renderer().expect( let Some(renderer) = self.backend.renderer() else {
"the dmabuf global must be created and destroyed together with the output device", notifier.failed();
); return;
};
match renderer.import_dmabuf(&dmabuf, None) { match renderer.import_dmabuf(&dmabuf, None) {
Ok(_texture) => { Ok(_texture) => {
let _ = notifier.successful::<State>(); let _ = notifier.successful::<State>();