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 {
644 lease_state.disable_global::<State>();644 lease_state.disable_global::<State>();
645 }645 }
646 646
647- if node == self.primary_node {647+ if node == self.primary_node || device.render_node == self.primary_render_node {
648 match self.gpu_manager.single_renderer(&device.render_node) {648 match self.gpu_manager.single_renderer(&device.render_node) {
649 Ok(mut renderer) => renderer.unbind_wl_display(),649 Ok(mut renderer) => renderer.unbind_wl_display(),
650 Err(err) => {650 Err(err) => {
@@ -653,27 +653,30 @@ impl Tty {
653 }653 }
654 654
655 // Disable and destroy the dmabuf global.655 // Disable and destroy the dmabuf global.
656- let global = self.dmabuf_global.take().unwrap();656+ if let Some(global) = self.dmabuf_global.take() {
657- niri.dmabuf_state657+ niri.dmabuf_state
658- .disable_global::<State>(&niri.display_handle, &global);658+ .disable_global::<State>(&niri.display_handle, &global);
659- niri.event_loop659+ niri.event_loop
660- .insert_source(660+ .insert_source(
661- Timer::from_duration(Duration::from_secs(10)),661+ Timer::from_duration(Duration::from_secs(10)),
662- move |_, _, state| {662+ move |_, _, state| {
663- state663+ state
664- .niri664+ .niri
665- .dmabuf_state665+ .dmabuf_state
666- .destroy_global::<State>(&state.niri.display_handle, global);666+ .destroy_global::<State>(&state.niri.display_handle, global);
667- TimeoutAction::Drop667+ TimeoutAction::Drop
668- },668+ },
669- )669+ )
670- .unwrap();670+ .unwrap();
671-671+
672- // Clear the dmabuf feedbacks for all surfaces.672+ // Clear the dmabuf feedbacks for all surfaces.
673- for device in self.devices.values_mut() {673+ for device in self.devices.values_mut() {
674- for surface in device.surfaces.values_mut() {674+ for surface in device.surfaces.values_mut() {
675- surface.dmabuf_feedback = None;675+ surface.dmabuf_feedback = None;
676+ }
676 }677 }
678+ } else {
679+ error!("dmabuf global was already missing");
677 }680 }
678 }681 }
679 682