From 84befb4e911245e7d28e939083004b512d34e8b2 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Mon, 1 Jan 2024 09:54:45 +0400 Subject: tty: Move dmabuf_global up into Tty --- src/backend/tty.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/backend/tty.rs') diff --git a/src/backend/tty.rs b/src/backend/tty.rs index 63c4c17b..81f56102 100644 --- a/src/backend/tty.rs +++ b/src/backend/tty.rs @@ -52,6 +52,9 @@ pub struct Tty { udev_dispatcher: Dispatcher<'static, UdevBackend, State>, libinput: Libinput, primary_gpu_path: PathBuf, + // The dma-buf global corresponds to the output device (the primary GPU). It is only `Some()` + // if we have a device corresponding to the primary GPU. + dmabuf_global: Option, output_device: Option, connectors: Arc>>, } @@ -70,7 +73,6 @@ struct OutputDevice { formats: HashSet, drm_scanner: DrmScanner, surfaces: HashMap, - dmabuf_global: DmabufGlobal, // SAFETY: drop after all the objects used with them are dropped. // See https://github.com/Smithay/smithay/issues/1102. drm: DrmDevice, @@ -136,6 +138,7 @@ impl Tty { udev_dispatcher, libinput, primary_gpu_path, + dmabuf_global: None, output_device: None, connectors: Arc::new(Mutex::new(HashMap::new())), } @@ -344,8 +347,8 @@ impl Tty { formats, drm_scanner: DrmScanner::new(), surfaces: HashMap::new(), - dmabuf_global, }); + self.dmabuf_global = Some(dmabuf_global); self.device_changed(device_id, niri); @@ -400,7 +403,7 @@ impl Tty { let mut device = self.output_device.take().unwrap(); niri.dmabuf_state - .destroy_global::(&niri.display_handle, device.dmabuf_global); + .destroy_global::(&niri.display_handle, self.dmabuf_global.take().unwrap()); device.gles.unbind_wl_display(); niri.event_loop.remove(device.token); -- cgit