diff --git a/Cargo.lock b/Cargo.lock index 86e121e6..9cc5794c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4732,7 +4732,7 @@ checksum = "8917285742e9f3e1683f0a9c4e6b57960b7314d0b08d30d1ecd426713ee2eee9" [[package]] name = "smithay" version = "0.7.0" -source = "git+https://github.com/smithay/smithay.git?rev=aaa1966#aaa19668d31cbc9d73561dc0ea8423fc41574d6c" +source = "git+https://github.com/smithay/smithay.git?rev=c03c373#c03c373e351243168a24dea695ba3e603c04392b" dependencies = [ "aliasable", "appendlist", diff --git a/Cargo.toml b/Cargo.toml index 0b2cbe60..899ff319 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -124,4 +124,4 @@ cosmic-protocols = { git = "https://github.com/pop-os//cosmic-protocols", branch cosmic-client-toolkit = { git = "https://github.com/pop-os//cosmic-protocols", branch = "main" } [patch.crates-io] -smithay = { git = "https://github.com/smithay/smithay.git", rev = "aaa1966" } +smithay = { git = "https://github.com/smithay/smithay.git", rev = "c03c373" } diff --git a/src/backend/kms/device.rs b/src/backend/kms/device.rs index 7bc8c8ea..afe2662b 100644 --- a/src/backend/kms/device.rs +++ b/src/backend/kms/device.rs @@ -264,7 +264,7 @@ impl State { gbm.clone(), GbmBufferFlags::RENDERING | GbmBufferFlags::SCANOUT, ), - GbmFramebufferExporter::new(gbm.clone(), Some(drm_node)), + GbmFramebufferExporter::new(gbm.clone(), drm_node.into()), Some(gbm.clone()), [ Fourcc::Abgr2101010, @@ -692,38 +692,31 @@ impl Device { .map(|(crtc, surface)| (*crtc, surface.output.clone())) .collect::>(); - self.drm.with_compositors::>(|map| { - for (crtc, compositor) in map.iter() { - let elements = match output_map.get(crtc) { - Some(output) => output_elements( - Some(&self.render_node), - renderer, - shell, - now, - &output, - CursorMode::All, - None, - ) - .with_context(|| "Failed to render outputs")?, - None => Vec::new(), - }; - - let mut compositor = compositor.lock().unwrap(); - compositor.render_frame( + let mut drm = self.drm.lock(); + let map = drm.compositors(); + for (crtc, compositor) in map.iter() { + let elements = match output_map.get(crtc) { + Some(output) => output_elements( + Some(&self.render_node), renderer, - &elements, - CLEAR_COLOR, - FrameFlags::empty(), - )?; - if let Err(err) = compositor.commit_frame() { - if !matches!(err, FrameError::EmptyFrame) { - return Err(err.into()); - } + shell, + now, + &output, + CursorMode::All, + None, + ) + .with_context(|| "Failed to render outputs")?, + None => Vec::new(), + }; + + let mut compositor = compositor.lock().unwrap(); + compositor.render_frame(renderer, &elements, CLEAR_COLOR, FrameFlags::empty())?; + if let Err(err) = compositor.commit_frame() { + if !matches!(err, FrameError::EmptyFrame) { + return Err(err.into()); } } - - Ok(()) - })?; + } } Ok(()) @@ -760,27 +753,27 @@ impl Device { shell, )?; - self.drm.with_compositors(|comps| { - for (crtc, comp) in comps { - let Some(surface) = self.surfaces.get_mut(crtc) else { - continue; - }; - let comp = comp.lock().unwrap(); - surface.primary_plane_formats = if flag { - comp.surface().plane_info().formats.clone() - } else { - // This certainly isn't perfect and might still miss the happy path, - // but it is surprisingly difficult to hack an api into smithay, - // to get the actual framebuffer format - let code = comp.format(); - FormatSet::from_iter(comp.modifiers().iter().map(|mo| Format { - code, - modifier: *mo, - })) - }; - surface.feedback.clear(); - } - }); + let mut drm = self.drm.lock(); + let maps = drm.compositors(); + for (crtc, comp) in maps { + let Some(surface) = self.surfaces.get_mut(crtc) else { + continue; + }; + let comp = comp.lock().unwrap(); + surface.primary_plane_formats = if flag { + comp.surface().plane_info().formats.clone() + } else { + // This certainly isn't perfect and might still miss the happy path, + // but it is surprisingly difficult to hack an api into smithay, + // to get the actual framebuffer format + let code = comp.format(); + FormatSet::from_iter(comp.modifiers().iter().map(|mo| Format { + code, + modifier: *mo, + })) + }; + surface.feedback.clear(); + } Ok(()) } diff --git a/src/backend/kms/mod.rs b/src/backend/kms/mod.rs index 532d6590..5c607442 100644 --- a/src/backend/kms/mod.rs +++ b/src/backend/kms/mod.rs @@ -310,7 +310,7 @@ impl State { } // active drm, resume leases for device in backend.drm_devices.values_mut() { - if let Err(err) = device.drm.activate(true) { + if let Err(err) = device.drm.lock().activate(true) { error!(?err, "Failed to resume drm device"); } if let Some(lease_state) = device.leasing_global.as_mut() { @@ -771,7 +771,7 @@ impl KmsState { for (crtc, surface) in device.surfaces.iter_mut() { let output_config = surface.output.config(); - let drm = &mut device.drm; + let drm = &mut device.drm.lock(); let conn = surface.connector; let conn_info = drm.device().get_connector(conn, false)?; let mode = conn_info @@ -956,6 +956,7 @@ impl KmsState { if let Err(err) = device .drm + .lock() .try_to_restore_modifiers(&mut renderer, &elements) { warn!(?err, "Failed to restore modifiers"); diff --git a/src/wayland/handlers/data_control.rs b/src/wayland/handlers/data_control.rs index 546b039a..f6132856 100644 --- a/src/wayland/handlers/data_control.rs +++ b/src/wayland/handlers/data_control.rs @@ -7,8 +7,8 @@ use smithay::{ }; impl DataControlHandler for State { - fn data_control_state(&self) -> &DataControlState { - self.common.data_control_state.as_ref().unwrap() + fn data_control_state(&mut self) -> &mut DataControlState { + self.common.data_control_state.as_mut().unwrap() } } diff --git a/src/wayland/handlers/data_device.rs b/src/wayland/handlers/data_device.rs index 9007e889..a15321ba 100644 --- a/src/wayland/handlers/data_device.rs +++ b/src/wayland/handlers/data_device.rs @@ -103,8 +103,8 @@ impl ClientDndGrabHandler for State { } impl ServerDndGrabHandler for State {} impl DataDeviceHandler for State { - fn data_device_state(&self) -> &DataDeviceState { - &self.common.data_device_state + fn data_device_state(&mut self) -> &mut DataDeviceState { + &mut self.common.data_device_state } } diff --git a/src/wayland/handlers/primary_selection.rs b/src/wayland/handlers/primary_selection.rs index 255cff1b..8a594305 100644 --- a/src/wayland/handlers/primary_selection.rs +++ b/src/wayland/handlers/primary_selection.rs @@ -7,8 +7,8 @@ use smithay::{ }; impl PrimarySelectionHandler for State { - fn primary_selection_state(&self) -> &PrimarySelectionState { - &self.common.primary_selection_state + fn primary_selection_state(&mut self) -> &mut PrimarySelectionState { + &mut self.common.primary_selection_state } }