tty: Move dmabuf_global up into Tty
Browse files at this commit84befb4e911245e7d28e939083004b512d34e8b2Parent: d39f7be1 changed file +6 -3
- src/backend/tty.rs +6 -3
src/backend/tty.rsmodified+6 -3
| @@ -52,6 +52,9 @@ pub struct Tty { | |||
| 52 | udev_dispatcher: Dispatcher<'static, UdevBackend, State>, | 52 | udev_dispatcher: Dispatcher<'static, UdevBackend, State>, |
| 53 | libinput: Libinput, | 53 | libinput: Libinput, |
| 54 | primary_gpu_path: PathBuf, | 54 | primary_gpu_path: PathBuf, |
| 55 | + // The dma-buf global corresponds to the output device (the primary GPU). It is only `Some()` | ||
| 56 | + // if we have a device corresponding to the primary GPU. | ||
| 57 | + dmabuf_global: Option<DmabufGlobal>, | ||
| 55 | output_device: Option<OutputDevice>, | 58 | output_device: Option<OutputDevice>, |
| 56 | connectors: Arc<Mutex<HashMap<String, Output>>>, | 59 | connectors: Arc<Mutex<HashMap<String, Output>>>, |
| 57 | } | 60 | } |
| @@ -70,7 +73,6 @@ struct OutputDevice { | |||
| 70 | formats: HashSet<DrmFormat>, | 73 | formats: HashSet<DrmFormat>, |
| 71 | drm_scanner: DrmScanner, | 74 | drm_scanner: DrmScanner, |
| 72 | surfaces: HashMap<crtc::Handle, Surface>, | 75 | surfaces: HashMap<crtc::Handle, Surface>, |
| 73 | - dmabuf_global: DmabufGlobal, | ||
| 74 | // SAFETY: drop after all the objects used with them are dropped. | 76 | // SAFETY: drop after all the objects used with them are dropped. |
| 75 | // See https://github.com/Smithay/smithay/issues/1102. | 77 | // See https://github.com/Smithay/smithay/issues/1102. |
| 76 | drm: DrmDevice, | 78 | drm: DrmDevice, |
| @@ -136,6 +138,7 @@ impl Tty { | |||
| 136 | udev_dispatcher, | 138 | udev_dispatcher, |
| 137 | libinput, | 139 | libinput, |
| 138 | primary_gpu_path, | 140 | primary_gpu_path, |
| 141 | + dmabuf_global: None, | ||
| 139 | output_device: None, | 142 | output_device: None, |
| 140 | connectors: Arc::new(Mutex::new(HashMap::new())), | 143 | connectors: Arc::new(Mutex::new(HashMap::new())), |
| 141 | } | 144 | } |
| @@ -344,8 +347,8 @@ impl Tty { | |||
| 344 | formats, | 347 | formats, |
| 345 | drm_scanner: DrmScanner::new(), | 348 | drm_scanner: DrmScanner::new(), |
| 346 | surfaces: HashMap::new(), | 349 | surfaces: HashMap::new(), |
| 347 | - dmabuf_global, | ||
| 348 | }); | 350 | }); |
| 351 | + self.dmabuf_global = Some(dmabuf_global); | ||
| 349 | 352 | ||
| 350 | self.device_changed(device_id, niri); | 353 | self.device_changed(device_id, niri); |
| 351 | 354 | ||
| @@ -400,7 +403,7 @@ impl Tty { | |||
| 400 | 403 | ||
| 401 | let mut device = self.output_device.take().unwrap(); | 404 | let mut device = self.output_device.take().unwrap(); |
| 402 | niri.dmabuf_state | 405 | niri.dmabuf_state |
| 403 | - .destroy_global::<State>(&niri.display_handle, device.dmabuf_global); | 406 | + .destroy_global::<State>(&niri.display_handle, self.dmabuf_global.take().unwrap()); |
| 404 | device.gles.unbind_wl_display(); | 407 | device.gles.unbind_wl_display(); |
| 405 | 408 | ||
| 406 | niri.event_loop.remove(device.token); | 409 | niri.event_loop.remove(device.token); |