forge
Explore
Log in

Don't you dare go Hollow

tty: Relax device checks on removal

Browse files at this commit

b87fba2182a0b187c0d991f48d305387d0bea5e3Ivan MolodetskikhParent: 3d63f5e
src/backend/tty.rsmodified+24 -21
@@ -644,7 +644,7 @@ impl Tty {
644644 lease_state.disable_global::<State>();
645645 }
646646
647- if node == self.primary_node {
647+ if node == self.primary_node || device.render_node == self.primary_render_node {
648648 match self.gpu_manager.single_renderer(&device.render_node) {
649649 Ok(mut renderer) => renderer.unbind_wl_display(),
650650 Err(err) => {
@@ -653,27 +653,30 @@ impl Tty {
653653 }
654654
655655 // Disable and destroy the dmabuf global.
656- let global = self.dmabuf_global.take().unwrap();
657- niri.dmabuf_state
658- .disable_global::<State>(&niri.display_handle, &global);
659- niri.event_loop
660- .insert_source(
661- Timer::from_duration(Duration::from_secs(10)),
662- move |_, _, state| {
663- state
664- .niri
665- .dmabuf_state
666- .destroy_global::<State>(&state.niri.display_handle, global);
667- TimeoutAction::Drop
668- },
669- )
670- .unwrap();
671-
672- // Clear the dmabuf feedbacks for all surfaces.
673- for device in self.devices.values_mut() {
674- for surface in device.surfaces.values_mut() {
675- surface.dmabuf_feedback = None;
656+ if let Some(global) = self.dmabuf_global.take() {
657+ niri.dmabuf_state
658+ .disable_global::<State>(&niri.display_handle, &global);
659+ niri.event_loop
660+ .insert_source(
661+ Timer::from_duration(Duration::from_secs(10)),
662+ move |_, _, state| {
663+ state
664+ .niri
665+ .dmabuf_state
666+ .destroy_global::<State>(&state.niri.display_handle, global);
667+ TimeoutAction::Drop
668+ },
669+ )
670+ .unwrap();
671+
672+ // Clear the dmabuf feedbacks for all surfaces.
673+ for device in self.devices.values_mut() {
674+ for surface in device.surfaces.values_mut() {
675+ surface.dmabuf_feedback = None;
676+ }
676677 }
678+ } else {
679+ error!("dmabuf global was already missing");
677680 }
678681 }
679682