diff --git a/Cargo.lock b/Cargo.lock index 2cfd72d..0fca6ae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3355,7 +3355,7 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "smithay" version = "0.3.0" -source = "git+https://github.com/Smithay/smithay.git#234586dbea6bc084cb72a32f164997e47ea36b2b" +source = "git+https://github.com/Smithay/smithay.git?branch=fix/multiple_cursor_planes#9d36da3e692f9090c2ddbcf5a94b93bb185f32e1" dependencies = [ "appendlist", "bitflags 2.5.0", @@ -3429,7 +3429,7 @@ dependencies = [ [[package]] name = "smithay-drm-extras" version = "0.1.0" -source = "git+https://github.com/Smithay/smithay.git#234586dbea6bc084cb72a32f164997e47ea36b2b" +source = "git+https://github.com/Smithay/smithay.git#f208cd758416e4495e9eb8b27a96c523e92817a6" dependencies = [ "drm", "edid-rs", diff --git a/Cargo.toml b/Cargo.toml index f0b009d..93712f6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,6 +21,7 @@ tracy-client = { version = "0.17.0", default-features = false } [workspace.dependencies.smithay] git = "https://github.com/Smithay/smithay.git" +branch = "fix/multiple_cursor_planes" # path = "../smithay" default-features = false diff --git a/niri-config/src/lib.rs b/niri-config/src/lib.rs index 2946b8c..78cd6af 100644 --- a/niri-config/src/lib.rs +++ b/niri-config/src/lib.rs @@ -1242,8 +1242,6 @@ pub struct DebugConfig { #[knuffel(child)] pub wait_for_frame_completion_before_queueing: bool, #[knuffel(child)] - pub enable_color_transformations_capability: bool, - #[knuffel(child)] pub enable_overlay_planes: bool, #[knuffel(child)] pub disable_cursor_plane: bool, diff --git a/niri-visual-tests/src/smithay_view.rs b/niri-visual-tests/src/smithay_view.rs index 8d0a168..60eed79 100644 --- a/niri-visual-tests/src/smithay_view.rs +++ b/niri-visual-tests/src/smithay_view.rs @@ -15,7 +15,7 @@ mod imp { use niri::utils::get_monotonic_time; use smithay::backend::egl::ffi::egl; use smithay::backend::egl::EGLContext; - use smithay::backend::renderer::gles::{Capability, GlesRenderer}; + use smithay::backend::renderer::gles::GlesRenderer; use smithay::backend::renderer::{Frame, Renderer, Unbind}; use smithay::utils::{Physical, Rectangle, Scale, Transform}; @@ -186,13 +186,8 @@ mod imp { let egl_context = EGLContext::from_raw(egl_display, egl_config_id as *const _, egl_context) .context("error creating EGL context")?; - let capabilities = GlesRenderer::supported_capabilities(&egl_context) - .context("error getting supported renderer capabilities")? - .into_iter() - .filter(|c| *c != Capability::ColorTransformations); - let mut renderer = GlesRenderer::with_capabilities(egl_context, capabilities) - .context("error creating GlesRenderer")?; + let mut renderer = GlesRenderer::new(egl_context).context("error creating GlesRenderer")?; resources::init(&mut renderer); shaders::init(&mut renderer); diff --git a/src/backend/tty.rs b/src/backend/tty.rs index 0654f4f..dc0954d 100644 --- a/src/backend/tty.rs +++ b/src/backend/tty.rs @@ -24,9 +24,9 @@ use smithay::backend::drm::{ DrmDevice, DrmDeviceFd, DrmEvent, DrmEventMetadata, DrmEventTime, DrmNode, NodeType, }; use smithay::backend::egl::context::ContextPriority; -use smithay::backend::egl::{EGLContext, EGLDevice, EGLDisplay}; +use smithay::backend::egl::{EGLDevice, EGLDisplay}; use smithay::backend::libinput::{LibinputInputBackend, LibinputSessionInterface}; -use smithay::backend::renderer::gles::{Capability, GlesRenderer}; +use smithay::backend::renderer::gles::GlesRenderer; use smithay::backend::renderer::multigpu::gbm::GbmGlesBackend; use smithay::backend::renderer::multigpu::{GpuManager, MultiFrame, MultiRenderer}; use smithay::backend::renderer::{DebugFlags, ImportDma, ImportEgl, Renderer}; @@ -148,7 +148,16 @@ impl OutputDevice { builder.add_connector(connector); builder.add_crtc(*crtc); let planes = self.drm.planes(crtc).map_err(LeaseRejected::with_cause)?; - builder.add_plane(planes.primary.handle); + let (primary_plane, primary_plane_claim) = planes + .primary + .iter() + .find_map(|plane| { + self.drm + .claim_plane(plane.handle, *crtc) + .map(|claim| (plane, claim)) + }) + .ok_or_else(LeaseRejected::default)?; + builder.add_plane(primary_plane.handle, primary_plane_claim); } Ok(builder) } @@ -239,25 +248,7 @@ impl Tty { }) .unwrap(); - let config_ = config.clone(); - let create_renderer = move |display: &EGLDisplay| { - let color_transforms = config_ - .borrow() - .debug - .enable_color_transformations_capability; - - let egl_context = EGLContext::new_with_priority(display, ContextPriority::High)?; - let gles = if color_transforms { - unsafe { GlesRenderer::new(egl_context)? } - } else { - let capabilities = unsafe { GlesRenderer::supported_capabilities(&egl_context) }? - .into_iter() - .filter(|c| *c != Capability::ColorTransformations); - unsafe { GlesRenderer::with_capabilities(egl_context, capabilities)? } - }; - Ok(gles) - }; - let api = GbmGlesBackend::with_factory(Box::new(create_renderer)); + let api = GbmGlesBackend::with_context_priority(ContextPriority::High); let gpu_manager = GpuManager::new(api).context("error creating the GPU manager")?; let (primary_node, primary_render_node) = primary_node_from_config(&config.borrow()) @@ -1987,8 +1978,8 @@ fn surface_dmabuf_feedback( let surface = compositor.surface(); let planes = surface.planes(); - let plane_formats = planes - .primary + let plane_formats = surface + .plane_info() .formats .iter() .chain(planes.overlay.iter().flat_map(|p| p.formats.iter())) diff --git a/src/handlers/compositor.rs b/src/handlers/compositor.rs index 3403012..583e88b 100644 --- a/src/handlers/compositor.rs +++ b/src/handlers/compositor.rs @@ -50,7 +50,8 @@ impl CompositorHandler for State { let maybe_dmabuf = with_states(surface, |surface_data| { surface_data .cached_state - .pending::() + .get::() + .pending() .buffer .as_ref() .and_then(|assignment| match assignment { diff --git a/src/handlers/xdg_shell.rs b/src/handlers/xdg_shell.rs index f333778..f6cad9a 100644 --- a/src/handlers/xdg_shell.rs +++ b/src/handlers/xdg_shell.rs @@ -1000,8 +1000,10 @@ pub fn add_mapped_toplevel_pre_commit_hook(toplevel: &ToplevelSurface) -> HookId }; let (got_unmapped, commit_serial) = with_states(surface, |states| { - let attrs = states.cached_state.pending::(); - let got_unmapped = matches!(attrs.buffer, Some(BufferAssignment::Removed)); + let got_unmapped = { + let mut guard = states.cached_state.get::(); + matches!(guard.pending().buffer, Some(BufferAssignment::Removed)) + }; let role = states .data_map diff --git a/src/render_helpers/renderer.rs b/src/render_helpers/renderer.rs index 5c48318..f487273 100644 --- a/src/render_helpers/renderer.rs +++ b/src/render_helpers/renderer.rs @@ -17,7 +17,7 @@ pub trait NiriRenderer: + AsGlesRenderer { // Associated types to work around the instability of associated type bounds. - type NiriTextureId: Texture + Clone + 'static; + type NiriTextureId: Texture + Clone + Send + 'static; type NiriError: std::error::Error + Send + Sync @@ -28,7 +28,7 @@ pub trait NiriRenderer: impl NiriRenderer for R where R: ImportAll + ImportMem + ExportMem + Bind + Offscreen + AsGlesRenderer, - R::TextureId: Texture + Clone + 'static, + R::TextureId: Texture + Clone + Send + 'static, R::Error: std::error::Error + Send + Sync + From<::Error> + 'static, { type NiriTextureId = R::TextureId; diff --git a/src/render_helpers/surface.rs b/src/render_helpers/surface.rs index 9373867..9606592 100644 --- a/src/render_helpers/surface.rs +++ b/src/render_helpers/surface.rs @@ -25,7 +25,7 @@ pub fn render_snapshot_from_surface_tree( let data = states.data_map.get::(); if let Some(data) = data { - let data = &*data.borrow(); + let data = &*data.lock().unwrap(); if let Some(view) = data.view() { location += view.offset.to_f64(); @@ -42,19 +42,17 @@ pub fn render_snapshot_from_surface_tree( let data = states.data_map.get::(); if let Some(data) = data { - if let Some(view) = data.borrow().view() { - location += view.offset.to_f64(); - } else { + let Some(view) = data.lock().unwrap().view() else { return; - } + }; + location += view.offset.to_f64(); if let Err(err) = import_surface(renderer, states) { warn!("failed to import surface: {err:?}"); return; } - let data = data.borrow(); - let view = data.view().unwrap(); + let data = data.lock().unwrap(); let Some(texture) = data.texture::(renderer.id()) else { return; }; diff --git a/src/window/mapped.rs b/src/window/mapped.rs index 8b6b8e6..178b0a3 100644 --- a/src/window/mapped.rs +++ b/src/window/mapped.rs @@ -461,8 +461,8 @@ impl LayoutElement for Mapped { fn min_size(&self) -> Size { let mut size = with_states(self.toplevel().wl_surface(), |state| { - let curr = state.cached_state.current::(); - curr.min_size + let mut guard = state.cached_state.get::(); + guard.current().min_size }); if let Some(x) = self.rules.min_width { @@ -477,8 +477,8 @@ impl LayoutElement for Mapped { fn max_size(&self) -> Size { let mut size = with_states(self.toplevel().wl_surface(), |state| { - let curr = state.cached_state.current::(); - curr.max_size + let mut guard = state.cached_state.get::(); + guard.current().max_size }); if let Some(x) = self.rules.max_width {