tty: Try harder to find a GBM device
Browse files at this commit3d63f5e644604a6d749c8c3405fac481b7a34cddParent: 1096f0c1 changed file +9 -1
- src/backend/tty.rs +9 -1
src/backend/tty.rsmodified+9 -1
| @@ -1537,7 +1537,15 @@ impl Tty { | |||
| 1537 | 1537 | ||
| 1538 | #[cfg(feature = "xdp-gnome-screencast")] | 1538 | #[cfg(feature = "xdp-gnome-screencast")] |
| 1539 | pub fn primary_gbm_device(&self) -> Option<GbmDevice<DrmDeviceFd>> { | 1539 | pub fn primary_gbm_device(&self) -> Option<GbmDevice<DrmDeviceFd>> { |
| 1540 | - self.devices.get(&self.primary_node).map(|d| d.gbm.clone()) | 1540 | + // Try to find a device corresponding to the primary render node. |
| 1541 | + let device = self | ||
| 1542 | + .devices | ||
| 1543 | + .values() | ||
| 1544 | + .find(|d| d.render_node == self.primary_render_node); | ||
| 1545 | + // Otherwise, try to get the device corresponding to the primary node. | ||
| 1546 | + let device = device.or_else(|| self.devices.get(&self.primary_node)); | ||
| 1547 | + | ||
| 1548 | + Some(device?.gbm.clone()) | ||
| 1541 | } | 1549 | } |
| 1542 | 1550 | ||
| 1543 | pub fn set_monitors_active(&mut self, active: bool) { | 1551 | pub fn set_monitors_active(&mut self, active: bool) { |