tty: Relax device checks on removal
Browse files at this commitb87fba2182a0b187c0d991f48d305387d0bea5e3Parent: 3d63f5e1 changed file +24 -21
- src/backend/tty.rs +24 -21
src/backend/tty.rsmodified+24 -21
| @@ -644,7 +644,7 @@ impl Tty { | ||
| 644 | 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 | 648 | match self.gpu_manager.single_renderer(&device.render_node) { |
| 649 | 649 | Ok(mut renderer) => renderer.unbind_wl_display(), |
| 650 | 650 | Err(err) => { |
| @@ -653,27 +653,30 @@ impl Tty { | ||
| 653 | 653 | } |
| 654 | 654 | |
| 655 | 655 | // 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 | + } | |
| 676 | 677 | } |
| 678 | + } else { | |
| 679 | + error!("dmabuf global was already missing"); | |
| 677 | 680 | } |
| 678 | 681 | } |
| 679 | 682 |