tty: Initialize primary node before others
Browse files at this commitcb47caba1101f6c0e718f02e1a1b9d8e579de70fParent: 6fcdb921 changed file +23 -1
- src/backend/tty.rs +23 -1
src/backend/tty.rsmodified+23 -1
| @@ -507,7 +507,29 @@ impl Tty { | ||
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | pub fn init(&mut self, niri: &mut Niri) { |
| 510 | - for (device_id, path) in self.udev_dispatcher.clone().as_source_ref().device_list() { | |
| 510 | + let udev = self.udev_dispatcher.clone(); | |
| 511 | + let udev = udev.as_source_ref(); | |
| 512 | + | |
| 513 | + // Initialize the primary node first as later nodes might depend on the primary render node | |
| 514 | + // being available. | |
| 515 | + if let Some((primary_device_id, primary_device_path)) = udev | |
| 516 | + .device_list() | |
| 517 | + .find(|&(device_id, _)| device_id == self.primary_node.dev_id()) | |
| 518 | + { | |
| 519 | + if let Err(err) = self.device_added(primary_device_id, primary_device_path, niri) { | |
| 520 | + warn!( | |
| 521 | + "error adding primary node device, display-only devices may not work: {err:?}" | |
| 522 | + ); | |
| 523 | + } | |
| 524 | + } else { | |
| 525 | + warn!("primary node is missing, display-only devices may not work"); | |
| 526 | + }; | |
| 527 | + | |
| 528 | + for (device_id, path) in udev.device_list() { | |
| 529 | + if device_id == self.primary_node.dev_id() { | |
| 530 | + continue; | |
| 531 | + } | |
| 532 | + | |
| 511 | 533 | if let Err(err) = self.device_added(device_id, path, niri) { |
| 512 | 534 | warn!("error adding device: {err:?}"); |
| 513 | 535 | } |