Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
This bumps all dependencies to their latest versions, including Smithay.
  • Loading branch information
chrisduerr committed Sep 2, 2024
1 parent 2cc5383 commit 1c2dca4
Show file tree
Hide file tree
Showing 9 changed files with 297 additions and 237 deletions.
400 changes: 233 additions & 167 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ features = [
]

[dependencies]
calloop = { version = "0.13.0", features = ["signals"] }
calloop = { version = "0.14.0", features = ["signals"] }
catacomb_ipc = { version = "0.1.0", path = "./catacomb_ipc", features = ["clap", "smithay"] }
clap = { version = "4.2.3", features = ["derive", "wrap_help"] }
dirs = "5.0.0"
Expand All @@ -41,3 +41,4 @@ serde = { version = "1.0.144", features = ["derive"] }
tracing = "0.1.37"
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
udev = "0.8.0"
indexmap = "2.5.0"
2 changes: 1 addition & 1 deletion catacomb_ipc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ optional = true
clap = { version = "4.2.3", features = ["derive"], optional = true }
serde = { version = "1.0.144", features = ["derive"] }
serde_json = "1.0.85"
xkbcommon = "0.7.0"
xkbcommon = "0.8.0"
dirs = "5.0.0"
regex = "1.8.1"

Expand Down
1 change: 0 additions & 1 deletion src/catacomb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,6 @@ impl DmabufHandler for Catacomb {
}
}
}

delegate_dmabuf!(Catacomb);

impl XdgShellHandler for Catacomb {
Expand Down
27 changes: 20 additions & 7 deletions src/drawing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use smithay::backend::renderer::element::utils::{
use smithay::backend::renderer::element::{Element, Id, RenderElement, UnderlyingStorage};
use smithay::backend::renderer::gles::{ffi, GlesFrame, GlesRenderer, GlesTexture};
use smithay::backend::renderer::utils::{
Buffer, CommitCounter, DamageBag, DamageSet, DamageSnapshot,
Buffer, CommitCounter, DamageBag, DamageSet, DamageSnapshot, OpaqueRegions,
};
use smithay::backend::renderer::{self, Renderer, Texture as _};
use smithay::reexports::wayland_server::protocol::wl_buffer::WlBuffer;
Expand Down Expand Up @@ -218,7 +218,7 @@ impl Element for RenderTexture {
DamageSet::from_iter(damage.into_iter().map(|rect| rect.to_physical_precise_round(scale)))
}

fn opaque_regions(&self, scale: Scale<f64>) -> Vec<Rectangle<i32, Physical>> {
fn opaque_regions(&self, scale: Scale<f64>) -> OpaqueRegions<i32, Physical> {
let scale = self.window_scale.map_or(scale.x, |window_scale| window_scale.scale(scale.x));
self.opaque_regions.iter().map(|rect| rect.to_physical_precise_round(scale)).collect()
}
Expand All @@ -231,12 +231,23 @@ impl RenderElement<GlesRenderer> for RenderTexture {
src: Rectangle<f64, BufferSpace>,
dst: Rectangle<i32, Physical>,
damage: &[Rectangle<i32, Physical>],
opaque_regions: &[Rectangle<i32, Physical>],
) -> Result<(), <GlesRenderer as Renderer>::Error> {
frame.render_texture_from_to(&self.texture, src, dst, damage, self.transform, 1., None, &[])
frame.render_texture_from_to(
&self.texture,
src,
dst,
damage,
opaque_regions,
self.transform,
1.,
None,
&[],
)
}

fn underlying_storage(&self, _renderer: &mut GlesRenderer) -> Option<UnderlyingStorage> {
self.buffer.clone().map(UnderlyingStorage::Wayland)
self.buffer.as_ref().map(UnderlyingStorage::Wayland)
}
}

Expand Down Expand Up @@ -296,7 +307,7 @@ impl Element for CatacombElement {
self.0.damage_since(scale, commit)
}

fn opaque_regions(&self, scale: Scale<f64>) -> Vec<Rectangle<i32, Physical>> {
fn opaque_regions(&self, scale: Scale<f64>) -> OpaqueRegions<i32, Physical> {
self.0.opaque_regions(scale)
}
}
Expand All @@ -308,8 +319,9 @@ impl RenderElement<GlesRenderer> for CatacombElement {
src: Rectangle<f64, BufferSpace>,
dst: Rectangle<i32, Physical>,
damage: &[Rectangle<i32, Physical>],
opaque_regions: &[Rectangle<i32, Physical>],
) -> Result<(), <GlesRenderer as Renderer>::Error> {
self.0.draw(frame, src, dst, damage)
self.0.draw(frame, src, dst, damage, opaque_regions)
}

fn underlying_storage(&self, renderer: &mut GlesRenderer) -> Option<UnderlyingStorage> {
Expand Down Expand Up @@ -459,7 +471,8 @@ impl CatacombSurfaceData {
let viewport_valid =
viewporter::ensure_viewport_valid(surface_data, self.buffer_size);
let (viewport_src, viewport_dst) = if viewport_valid {
let viewport = surface_data.cached_state.current::<ViewportCachedState>();
let mut viewport = surface_data.cached_state.get::<ViewportCachedState>();
let viewport = viewport.current();
(viewport.src, viewport.size())
} else {
(None, None)
Expand Down
4 changes: 2 additions & 2 deletions src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -548,8 +548,8 @@ impl Catacomb {
// Convert positions to pre-window scaling.
let scale = self.windows.canvas().scale();
let window_scale_position = position.upscale(scale / input_surface.surface_scale);
let surface_position_x = input_surface.surface_offset.x.round() as i32;
let surface_position_y = input_surface.surface_offset.y.round() as i32;
let surface_position_x = input_surface.surface_offset.x;
let surface_position_y = input_surface.surface_offset.y;
let surface_position = Point::from((surface_position_x, surface_position_y));

// Send touch event to the client.
Expand Down
62 changes: 21 additions & 41 deletions src/udev.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
//! Udev backend.
use std::collections::{HashMap, HashSet};
use std::collections::HashMap;
use std::error::Error;
use std::path::{Path, PathBuf};
use std::time::Duration;
use std::{env, io, mem, process, ptr};

use _linux_dmabuf::zv1::server::zwp_linux_dmabuf_feedback_v1::TrancheFlags;
use indexmap::IndexSet;
use libc::dev_t as DeviceId;
#[cfg(feature = "profiling")]
use profiling::puffin::GlobalProfiler;
use smithay::backend::allocator::dmabuf::Dmabuf;
use smithay::backend::allocator::gbm::{GbmAllocator, GbmBuffer, GbmBufferFlags, GbmDevice};
use smithay::backend::allocator::{Format, Fourcc};
use smithay::backend::allocator::Fourcc;
use smithay::backend::drm::compositor::{DrmCompositor as SmithayDrmCompositor, RenderFrameResult};
use smithay::backend::drm::gbm::GbmFramebuffer;
use smithay::backend::drm::{DrmDevice, DrmDeviceFd, DrmEvent, DrmNode, DrmSurface};
use smithay::backend::egl::context::EGLContext;
use smithay::backend::egl::display::EGLDisplay;
use smithay::backend::libinput::{LibinputInputBackend, LibinputSessionInterface};
use smithay::backend::renderer::element::RenderElementStates;
use smithay::backend::renderer::gles::{ffi, Capability, GlesRenderbuffer, GlesRenderer};
use smithay::backend::renderer::gles::{ffi, GlesRenderbuffer, GlesRenderer};
use smithay::backend::renderer::sync::SyncPoint;
use smithay::backend::renderer::{
self, utils, Bind, BufferType, Frame, ImportDma, ImportEgl, Offscreen, Renderer,
Expand Down Expand Up @@ -346,14 +347,7 @@ impl Udev {
let display = unsafe { EGLDisplay::new(gbm.clone())? };
let context = EGLContext::new(&display)?;

let mut gles = unsafe {
// Filter driver capabilities that reduce performance.
let mut capabilities =
GlesRenderer::supported_capabilities(&context).expect("gl capabilities");
capabilities.retain(|capability| capability != &Capability::ColorTransformations);

GlesRenderer::with_capabilities(context, capabilities).expect("create renderer")
};
let mut gles = unsafe { GlesRenderer::new(context).expect("create renderer") };

// Initialize GPU for EGL rendering.
trace_error!(gles.bind_wl_display(display_handle));
Expand Down Expand Up @@ -668,12 +662,12 @@ impl OutputDevice {
fn copy_framebuffer_dma(
gles: &mut GlesRenderer,
scale: f64,
frame_result: &RenderFrameResult<GbmBuffer<()>, GbmFramebuffer, CatacombElement>,
frame_result: &RenderFrameResult<GbmBuffer, GbmFramebuffer, CatacombElement>,
region: Rectangle<i32, Physical>,
buffer: Dmabuf,
buffer: &Dmabuf,
) -> Result<SyncPoint, Box<dyn Error>> {
// Bind the screencopy buffer as render target.
gles.bind(buffer)?;
gles.bind(buffer.clone())?;

// Blit the framebuffer into the target buffer.
let damage = [Rectangle::from_loc_and_size((0, 0), region.size)];
Expand Down Expand Up @@ -716,7 +710,7 @@ impl OutputDevice {

// Initialize the buffer to our clear color.
let mut frame = self.gles.render(output_size, transform)?;
frame.clear(CLEAR_COLOR, &[damage])?;
frame.clear(CLEAR_COLOR.into(), &[damage])?;

// Render everything to the offscreen buffer.
utils::draw_render_elements(&mut frame, scale, textures, &[damage])?;
Expand Down Expand Up @@ -770,20 +764,22 @@ impl OutputDevice {
let surface = self.drm_compositor.surface();
let planes = surface.planes();

// Get primary plane formats supported by renderer.
let dmabuf_formats = self.gles.dmabuf_formats().collect::<HashSet<_>>();
let mut primary_formats = planes.primary.formats.clone();
Self::format_intersection(&mut primary_formats, [&dmabuf_formats]);
// Get formats supported by ANY primary plane and the renderer.
let dmabuf_formats = self.gles.dmabuf_formats();
let dmabuf_formats = dmabuf_formats.indexset();
let primary_formats: IndexSet<_> =
planes.primary.iter().flat_map(|plane| plane.formats.iter()).copied().collect();
let primary_formats = primary_formats.intersection(dmabuf_formats).copied();

// Get formats supported by ANY overlay plane and the renderer.
let mut any_overlay_formats: HashSet<_> =
planes.overlay.iter().flat_map(|plane| &plane.formats).copied().collect();
Self::format_intersection(&mut any_overlay_formats, [&dmabuf_formats]);
let any_overlay_formats: IndexSet<_> =
planes.overlay.iter().flat_map(|plane| plane.formats.iter()).copied().collect();
let any_overlay_formats = any_overlay_formats.intersection(dmabuf_formats).copied();

// Get formats supported by ALL overlay planes and the renderer.
let mut all_overlay_formats = dmabuf_formats.clone();
let overlay_formats = planes.overlay.iter().map(|plane| &plane.formats);
Self::format_intersection(&mut all_overlay_formats, overlay_formats);
all_overlay_formats
.retain(|format| planes.overlay.iter().all(|plane| plane.formats.contains(format)));

// The dmabuf feedback DRM device is expected to have a render node, so if this
// device doesn't have one, we fall back to the first one that does.
Expand All @@ -805,7 +801,7 @@ impl OutputDevice {
}

// Setup feedback builder.
let feedback_builder = DmabufFeedbackBuilder::new(gbm_id, dmabuf_formats);
let feedback_builder = DmabufFeedbackBuilder::new(gbm_id, dmabuf_formats.iter().copied());

// Create default feedback preference.
let surface_id = surface.device_fd().dev_id()?;
Expand All @@ -821,22 +817,6 @@ impl OutputDevice {

Ok(feedback)
}

/// Calculate the intersection of DRM formats between planes.
fn format_intersection<'a, D>(drm_formats: &mut HashSet<Format>, filter: D)
where
D: IntoIterator<Item = &'a HashSet<Format>>,
{
// Filter formats which aren't supported by all other planes.
for formats in filter {
drm_formats.retain(|format| formats.contains(format));

// Abort early if no format intersects.
if drm_formats.is_empty() {
break;
}
}
}
}

/// DRM compositor type alias.
Expand Down
2 changes: 1 addition & 1 deletion src/windows/surface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub trait Surface {
/// Geometry of the window's visible bounds.
fn geometry(&self) -> Option<Rectangle<i32, Logical>> {
compositor::with_states(self.surface(), |states| {
states.cached_state.current::<SurfaceCachedState>().geometry
states.cached_state.get::<SurfaceCachedState>().current().geometry
})
}
}
Expand Down
33 changes: 17 additions & 16 deletions src/windows/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ impl<S: Surface + 'static> Window<S> {
/// Send a frame request to the window.
pub fn request_frame(&self, runtime: u32) {
self.with_surfaces(|_, surface_data| {
let mut attributes = surface_data.cached_state.current::<SurfaceAttributes>();
for callback in attributes.frame_callbacks.drain(..) {
let mut attributes = surface_data.cached_state.get::<SurfaceAttributes>();
for callback in attributes.current().frame_callbacks.drain(..) {
callback.done(runtime);
}
});
Expand Down Expand Up @@ -267,8 +267,8 @@ impl<S: Surface + 'static> Window<S> {
// Use the subsurface's location as the origin for its children.
let mut location = *location;
if surface_data.role == Some("subsurface") {
let subsurface = surface_data.cached_state.current::<SubsurfaceCachedState>();
location += subsurface.location;
let mut subsurface = surface_data.cached_state.get::<SubsurfaceCachedState>();
location += subsurface.current().location;
}

// Update surface data location so we don't need to recompute for processing.
Expand Down Expand Up @@ -299,8 +299,8 @@ impl<S: Surface + 'static> Window<S> {

// Stage presentation callbacks for submission.
let mut feedback_state =
surface_data.cached_state.current::<PresentationFeedbackCachedState>();
for callback in feedback_state.callbacks.drain(..) {
surface_data.cached_state.get::<PresentationFeedbackCachedState>();
for callback in feedback_state.current().callbacks.drain(..) {
let callback = PresentationCallback::new(surface.clone(), callback);
self.presentation_callbacks.push(callback);
}
Expand Down Expand Up @@ -485,7 +485,8 @@ impl<S: Surface + 'static> Window<S> {
.borrow_mut();

// Check if new buffer has been attached.
let mut attributes = data.cached_state.current::<SurfaceAttributes>();
let mut attributes = data.cached_state.get::<SurfaceAttributes>();
let attributes = attributes.current();
let buffer_assignment = match attributes.buffer.take() {
Some(buffer_assignment) => buffer_assignment,
None => return TraversalAction::DoChildren(()),
Expand All @@ -499,7 +500,7 @@ impl<S: Surface + 'static> Window<S> {
.unwrap_or_default();

// Store pending buffer updates.
surface_data.update_buffer(data, &mut attributes, buffer_assignment);
surface_data.update_buffer(data, attributes, buffer_assignment);

TraversalAction::DoChildren(())
},
Expand Down Expand Up @@ -662,8 +663,8 @@ impl<S: Surface + 'static> Window<S> {
// Calculate subsurface offset for child processing.
let mut location = *location;
if surface_data.role == Some("subsurface") {
let current = surface_data.cached_state.current::<SubsurfaceCachedState>();
location += current.location.to_f64();
let mut cached_state = surface_data.cached_state.get::<SubsurfaceCachedState>();
location += cached_state.current().location.to_f64();
}

TraversalAction::DoChildren(location)
Expand All @@ -677,8 +678,8 @@ impl<S: Surface + 'static> Window<S> {
// Recalculate subsurface offset for surface processing.
let mut location = *location;
if surface_data.role == Some("subsurface") {
let current = surface_data.cached_state.current::<SubsurfaceCachedState>();
location += current.location.to_f64();
let mut cached_state = surface_data.cached_state.get::<SubsurfaceCachedState>();
location += cached_state.current().location.to_f64();
}

// Calculate surface's bounding box.
Expand All @@ -692,8 +693,8 @@ impl<S: Surface + 'static> Window<S> {
let surface_rect = Rectangle::from_loc_and_size(surface_loc, size.to_f64());

// Get input region and its relative touch position.
let attributes = surface_data.cached_state.current::<SurfaceAttributes>();
let input_region = attributes.input_region.as_ref();
let mut attributes = surface_data.cached_state.get::<SurfaceAttributes>();
let input_region = attributes.current().input_region.as_ref();
let input_position = (position - surface_rect.loc).to_i32_round();

// Check if the position is within the surface bounds.
Expand Down Expand Up @@ -877,7 +878,7 @@ impl Window<CatacombLayerSurface> {
/// Recompute the window's size and location.
pub fn update_dimensions(&mut self, output: &mut Output, fullscreen_active: bool) {
let state = compositor::with_states(self.surface.surface(), |states| {
*states.cached_state.current::<LayerSurfaceCachedState>()
*states.cached_state.get::<LayerSurfaceCachedState>().current()
});

// Exclude gesture handle from Top/Overlay window size.
Expand Down Expand Up @@ -933,7 +934,7 @@ impl Window<CatacombLayerSurface> {
/// Update layer-specific shell properties.
fn update_layer_state(&mut self, output: &mut Output) {
let state = compositor::with_states(self.surface.surface(), |states| {
*states.cached_state.current::<LayerSurfaceCachedState>()
*states.cached_state.get::<LayerSurfaceCachedState>().current()
});

// Update keyboard interactivity.
Expand Down

0 comments on commit 1c2dca4

Please sign in to comment.