diff --git a/Cargo.lock b/Cargo.lock index 5c4836d..dd28bf0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1171,18 +1171,42 @@ checksum = "98888c4bbd601524c11a7ed63f814b8825f420514f78e96f752c437ae9cbb5d1" dependencies = [ "bitflags 2.6.0", "bytemuck", - "drm-ffi", + "drm-ffi 0.8.0", "drm-fourcc", "rustix", ] +[[package]] +name = "drm" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80bc8c5c6c2941f70a55c15f8d9f00f9710ebda3ffda98075f996a0e6c92756f" +dependencies = [ + "bitflags 2.6.0", + "bytemuck", + "drm-ffi 0.9.0", + "drm-fourcc", + "libc", + "rustix", +] + [[package]] name = "drm-ffi" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97c98727e48b7ccb4f4aea8cfe881e5b07f702d17b7875991881b41af7278d53" dependencies = [ - "drm-sys", + "drm-sys 0.7.0", + "rustix", +] + +[[package]] +name = "drm-ffi" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8e41459d99a9b529845f6d2c909eb9adf3b6d2f82635ae40be8de0601726e8b" +dependencies = [ + "drm-sys 0.8.0", "rustix", ] @@ -1203,10 +1227,14 @@ dependencies = [ ] [[package]] -name = "edid-rs" -version = "0.1.0" +name = "drm-sys" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ab5fa33485cd85ac354df485819a63360fefa312fe04cffe65e6f175be1522c" +checksum = "bafb66c8dbc944d69e15cfcc661df7e703beffbaec8bd63151368b06c5f9858c" +dependencies = [ + "libc", + "linux-raw-sys 0.6.5", +] [[package]] name = "either" @@ -1512,12 +1540,12 @@ dependencies = [ [[package]] name = "gbm" -version = "0.15.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45bf55ba6dd53ad0ac115046ff999c5324c283444ee6e0be82454c4e8eb2f36a" +checksum = "ce852e998d3ca5e4a97014fb31c940dc5ef344ec7d364984525fd11e8a547e6a" dependencies = [ "bitflags 2.6.0", - "drm", + "drm 0.14.1", "drm-fourcc", "gbm-sys", "libc", @@ -1527,9 +1555,9 @@ dependencies = [ [[package]] name = "gbm-sys" -version = "0.3.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9cc2f64de9fa707b5c6b2d2f10d7a7e49e845018a9f5685891eb40d3bab2538" +checksum = "c13a5f2acc785d8fb6bf6b7ab6bfb0ef5dad4f4d97e8e70bb8e470722312f76f" dependencies = [ "libc", ] @@ -2119,7 +2147,7 @@ dependencies = [ "bitflags 2.6.0", "input-sys", "libc", - "udev 0.9.1", + "udev", ] [[package]] @@ -2265,6 +2293,36 @@ version = "0.2.168" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5aaeb2981e0606ca11d79718f8bb01164f1d6ed75080182d3abf017e6d244b6d" +[[package]] +name = "libdisplay-info" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb6dd47a677df2378a8bb88d08a593f51e8dddf4b61d2db5f2ceb35e67f9389d" +dependencies = [ + "bitflags 2.6.0", + "libc", + "libdisplay-info-derive", + "libdisplay-info-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror 1.0.69", +] + +[[package]] +name = "libdisplay-info-derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea1cd31036b732a546d845f9485c56b1b606b5e476b0821c680dd66c8cd6fcee" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.90", +] + +[[package]] +name = "libdisplay-info-sys" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea8cec1fa7872b621f40c756bc1304b1a975461282e250b0e76737b037c0c236" + [[package]] name = "libdisplay-info-sys" version = "0.1.0" @@ -3136,10 +3194,10 @@ dependencies = [ "clap", "cliclack", "dircpy", - "drm-sys", + "drm-sys 0.8.0", "gag", "indexmap 2.7.0", - "libdisplay-info-sys", + "libdisplay-info-sys 0.1.0 (git+https://github.com/Smithay/libdisplay-info-rs?rev=a482d0d)", "pinnacle", "pinnacle-api", "pinnacle-api-defs", @@ -3642,12 +3700,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "scan_fmt" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b53b0a5db882a8e2fdaae0a43f7b39e7e9082389e978398bdf223a55b581248" - [[package]] name = "scoped-tls" version = "1.0.1" @@ -3819,7 +3871,7 @@ checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" [[package]] name = "smithay" version = "0.3.0" -source = "git+https://github.com/Smithay/smithay?rev=e7f0857#e7f08570bceab6107863267ae168d0afb018e8f5" +source = "git+https://github.com/Smithay/smithay?rev=0f32e8d#0f32e8d1f9e034c96f7c43a3373f1ce79a76553b" dependencies = [ "appendlist", "bitflags 2.6.0", @@ -3828,8 +3880,8 @@ dependencies = [ "cgmath", "cursor-icon", "downcast-rs", - "drm", - "drm-ffi", + "drm 0.14.1", + "drm-ffi 0.9.0", "drm-fourcc", "encoding_rs", "errno", @@ -3837,7 +3889,6 @@ dependencies = [ "gl_generator", "indexmap 2.7.0", "input", - "lazy_static", "libc", "libloading 0.8.6", "libseat", @@ -3846,13 +3897,12 @@ dependencies = [ "profiling", "rand", "rustix", - "scan_fmt", "scopeguard", "smallvec", "tempfile", "thiserror 1.0.69", "tracing", - "udev 0.8.0", + "udev", "wayland-backend", "wayland-client", "wayland-cursor", @@ -3934,10 +3984,10 @@ dependencies = [ [[package]] name = "smithay-drm-extras" version = "0.1.0" -source = "git+https://github.com/Smithay/smithay?rev=e7f0857#e7f08570bceab6107863267ae168d0afb018e8f5" +source = "git+https://github.com/Smithay/smithay?rev=0f32e8d#0f32e8d1f9e034c96f7c43a3373f1ce79a76553b" dependencies = [ - "drm", - "edid-rs", + "drm 0.14.1", + "libdisplay-info", ] [[package]] @@ -4022,7 +4072,7 @@ dependencies = [ "bytemuck", "cfg_aliases 0.2.1", "core-graphics 0.24.0", - "drm", + "drm 0.12.0", "fastrand", "foreign-types", "js-sys", @@ -4646,18 +4696,6 @@ version = "0.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2df906b07856748fa3f6e0ad0cbaa047052d4a7dd609e231c4f72cee8c36f31" -[[package]] -name = "udev" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50051c6e22be28ee6f217d50014f3bc29e81c20dc66ff7ca0d5c5226e1dcc5a1" -dependencies = [ - "io-lifetimes 1.0.11", - "libc", - "libudev-sys", - "pkg-config", -] - [[package]] name = "udev" version = "0.9.1" diff --git a/Cargo.toml b/Cargo.toml index 16a260e..e7813df 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -51,7 +51,7 @@ tower = { version = "0.5.2", features = ["util"] } [workspace.dependencies.smithay] git = "https://github.com/Smithay/smithay" -rev = "e7f0857" +rev = "0f32e8d" # path = "../../git/smithay" default-features = false features = [ @@ -92,7 +92,7 @@ version = "0.0.1" authors.workspace = true edition.workspace = true license = "GPL-3.0+" -description = "A WIP Smithay-based Wayland compositor, inspired by AwesomeWM" +description = "A WIP Smithay-based Wayland compositor" readme = "README.md" repository.workspace = true keywords = ["wayland", "compositor", "smithay", "lua"] @@ -100,7 +100,7 @@ keywords = ["wayland", "compositor", "smithay", "lua"] [dependencies] # Smithay smithay = { workspace = true } -smithay-drm-extras = { git = "https://github.com/Smithay/smithay", rev = "e7f0857" } +smithay-drm-extras = { git = "https://github.com/Smithay/smithay", rev = "0f32e8d" } # Tracing tracing = { workspace = true } tracing-subscriber = { workspace = true } @@ -135,7 +135,7 @@ chrono = "0.4.39" bytemuck = "1.20.0" pinnacle-api = { path = "./api/rust", default-features = false } gag = "1.0.0" -drm-sys = "0.7.0" # TODO: remove and use libdisplay-info +drm-sys = "0.8.0" # TODO: remove and use libdisplay-info libdisplay-info-sys = { git = "https://github.com/Smithay/libdisplay-info-rs", rev = "a482d0d" } indexmap = { workspace = true } snowcap = { path = "./snowcap", optional = true } diff --git a/src/backend/udev.rs b/src/backend/udev.rs index f70d213..caa426a 100644 --- a/src/backend/udev.rs +++ b/src/backend/udev.rs @@ -73,6 +73,7 @@ use smithay::{ utils::{DeviceFd, Point, Rectangle, Transform}, wayland::{ dmabuf::{self, DmabufFeedback, DmabufFeedbackBuilder, DmabufGlobal, DmabufState}, + presentation::Refresh, shm::shm_format_to_fourcc, }, }; @@ -1221,7 +1222,11 @@ impl Udev { feedback.presented::<_, smithay::utils::Monotonic>( time, - surface.frame_clock.refresh_interval().unwrap_or_default(), + surface + .frame_clock + .refresh_interval() + .map(Refresh::Fixed) + .unwrap_or(Refresh::Unknown), seq, flags, ); diff --git a/src/backend/udev/frame.rs b/src/backend/udev/frame.rs index e4c8f38..94a8c26 100644 --- a/src/backend/udev/frame.rs +++ b/src/backend/udev/frame.rs @@ -3,6 +3,8 @@ use std::{num::NonZeroU64, time::Duration}; use smithay::utils::{Clock, Monotonic}; use tracing::error; +// yo i gotta stop copying stuff from niri i don't remember what this is for + pub struct FrameClock { last_presentation_time: Option, refresh_interval_ns: Option, diff --git a/src/backend/winit.rs b/src/backend/winit.rs index 9ab458b..3392884 100644 --- a/src/backend/winit.rs +++ b/src/backend/winit.rs @@ -30,7 +30,10 @@ use smithay::{ }, }, utils::{Point, Rectangle, Transform}, - wayland::dmabuf::{self, DmabufFeedback, DmabufFeedbackBuilder, DmabufGlobal, DmabufState}, + wayland::{ + dmabuf::{self, DmabufFeedback, DmabufFeedbackBuilder, DmabufGlobal, DmabufState}, + presentation::Refresh, + }, }; use tracing::{debug, error, trace, warn}; @@ -401,8 +404,12 @@ impl Winit { now, self.output .current_mode() - .map(|mode| Duration::from_secs_f64(1000f64 / mode.refresh as f64)) - .unwrap_or_default(), + .map(|mode| { + Refresh::Fixed(Duration::from_secs_f64( + 1000f64 / mode.refresh as f64, + )) + }) + .unwrap_or(Refresh::Unknown), 0, wp_presentation_feedback::Kind::Vsync, ); diff --git a/src/handlers.rs b/src/handlers.rs index f19847d..48e3512 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -579,7 +579,7 @@ impl ClientDndGrabHandler for State { self.pinnacle.dnd_icon = icon; } - fn dropped(&mut self, _seat: Seat) { + fn dropped(&mut self, _target: Option, _validated: bool, _seat: Seat) { self.pinnacle.dnd_icon = None; } } @@ -907,6 +907,15 @@ impl PointerConstraintsHandler for State { self.pinnacle .maybe_activate_pointer_constraint(pointer.current_location()); } + + fn cursor_position_hint( + &mut self, + surface: &WlSurface, + pointer: &PointerHandle, + location: Point, + ) { + todo!() + } } delegate_pointer_constraints!(State); diff --git a/src/input.rs b/src/input.rs index f641843..ed8dbfa 100644 --- a/src/input.rs +++ b/src/input.rs @@ -513,7 +513,8 @@ impl State { .pinnacle .input_state .no_release_keys - .contains(&event.key_code()) + .contains(&event.key_code().into()) + // TODO: check keycode -> u32 { return FilterResult::Intercept(KeyAction::Suppress); } @@ -521,7 +522,9 @@ impl State { if press_state == KeyState::Pressed { let mod_mask = ModifierMask::from(modifiers); - let raw_sym = keysym.raw_syms().iter().next(); + // TODO: verify rawsyms are the right thing to do + let raw_syms = keysym.raw_syms(); + let raw_sym = raw_syms.first(); let mod_sym = keysym.modified_sym(); if let mut vt @ keysyms::KEY_XF86Switch_VT_1..=keysyms::KEY_XF86Switch_VT_12 = @@ -573,7 +576,7 @@ impl State { self.pinnacle .input_state .no_release_keys - .remove(&event.key_code()); + .remove(&event.key_code().into()); // TODO: check keycode -> u32 return; } @@ -581,7 +584,7 @@ impl State { self.pinnacle .input_state .no_release_keys - .insert(event.key_code()); + .insert(event.key_code().into()); // TODO: check keycode -> u32 match action { KeyAction::CallCallback(sender) => { let _ = sender.send(Ok(SetKeybindResponse {})); diff --git a/src/layout/transaction.rs b/src/layout/transaction.rs index 215a334..ecdf52e 100644 --- a/src/layout/transaction.rs +++ b/src/layout/transaction.rs @@ -20,8 +20,8 @@ use smithay::{ use crate::{ pinnacle_render_elements, render::{ - texture::CommonTextureRenderElement, util::snapshot::RenderSnapshot, AsGlesRenderer, - PRenderer, + util::{snapshot::RenderSnapshot, surface::WlSurfaceTextureRenderElement}, + AsGlesRenderer, PRenderer, }, state::{State, WithState}, window::WindowElement, @@ -31,7 +31,7 @@ use crate::{ const TIMEOUT: Duration = Duration::from_millis(150); /// Type for window snapshots. -pub type LayoutSnapshot = RenderSnapshot; +pub type LayoutSnapshot = RenderSnapshot; pinnacle_render_elements! { /// Render elements for an output snapshot @@ -40,7 +40,7 @@ pinnacle_render_elements! { /// Draw the window itself. Window = WaylandSurfaceRenderElement, /// Draw a snapshot of the window. - Snapshot = RescaleRenderElement, + Snapshot = RescaleRenderElement, } } diff --git a/src/render.rs b/src/render.rs index 9678763..9c48dd1 100644 --- a/src/render.rs +++ b/src/render.rs @@ -26,6 +26,7 @@ use smithay::{ utils::{Logical, Point, Scale}, wayland::shell::wlr_layer, }; +use util::surface::WlSurfaceTextureRenderElement; use crate::{ backend::{udev::UdevRenderer, Backend}, @@ -36,8 +37,7 @@ use crate::{ }; use self::{ - pointer::PointerRenderElement, texture::CommonTextureRenderElement, - util::surface::texture_render_elements_from_surface_tree, + pointer::PointerRenderElement, util::surface::texture_render_elements_from_surface_tree, }; pub const CLEAR_COLOR: [f32; 4] = [0.6, 0.6, 0.6, 1.0]; @@ -117,7 +117,7 @@ impl WindowElement { location: Point, scale: Scale, alpha: f32, - ) -> Vec { + ) -> Vec { let location = location - self.geometry().loc; let location = location.to_f64().to_physical_precise_round(scale); @@ -139,23 +139,15 @@ impl WindowElement { ) }); - render_elements.extend( - popup_render_elements - .into_iter() - .map(CommonTextureRenderElement::new), - ); + render_elements.extend(popup_render_elements); - render_elements.extend( - texture_render_elements_from_surface_tree( - renderer.as_gles_renderer(), - surface, - location, - scale, - alpha, - ) - .into_iter() - .map(CommonTextureRenderElement::new), - ); + render_elements.extend(texture_render_elements_from_surface_tree( + renderer.as_gles_renderer(), + surface, + location, + scale, + alpha, + )); render_elements } @@ -168,9 +160,6 @@ impl WindowElement { scale, alpha, ) - .into_iter() - .map(CommonTextureRenderElement::new) - .collect() } else { Vec::new() } diff --git a/src/render/util.rs b/src/render/util.rs index c9710b3..4ec2649 100644 --- a/src/render/util.rs +++ b/src/render/util.rs @@ -134,7 +134,7 @@ fn render_elements_to_bound_framebuffer( .context("failed to start render")?; frame - .clear([0.0, 0.0, 0.0, 0.0], &[dst_rect]) + .clear([0.0, 0.0, 0.0, 0.0].into(), &[dst_rect]) .context("failed to clear frame")?; for elem in elements { diff --git a/src/render/util/snapshot.rs b/src/render/util/snapshot.rs index 850267a..f952a2f 100644 --- a/src/render/util/snapshot.rs +++ b/src/render/util/snapshot.rs @@ -25,6 +25,7 @@ use crate::render::{AsGlesRenderer, PRenderer}; use crate::state::{Pinnacle, State, WithState}; use crate::window::WindowElement; +use super::surface::WlSurfaceTextureRenderElement; use super::{render_to_encompassing_texture, EncompassingTexture}; /// A snapshot of given elements that can be rendered at some point in the future. @@ -119,7 +120,11 @@ impl> RenderSnapshot { let scale = Scale::from((1.0 / scale.x, 1.0 / scale.y)); Some(SnapshotRenderElement::Snapshot( - RescaleRenderElement::from_element(common, loc, scale), + RescaleRenderElement::from_element( + WlSurfaceTextureRenderElement::Texture(common), + loc, + scale, + ), )) } } diff --git a/src/render/util/surface.rs b/src/render/util/surface.rs index bfe8ea6..6e506c7 100644 --- a/src/render/util/surface.rs +++ b/src/render/util/surface.rs @@ -4,10 +4,11 @@ use smithay::{ backend::renderer::{ element::{ self, - surface::WaylandSurfaceRenderElement, + solid::{SolidColorBuffer, SolidColorRenderElement}, + surface::{WaylandSurfaceRenderElement, WaylandSurfaceTexture}, texture::{TextureBuffer, TextureRenderElement}, }, - gles::{GlesRenderer, GlesTexture}, + gles::GlesRenderer, utils::RendererSurfaceStateUserData, }, reexports::wayland_server::protocol::wl_surface::WlSurface, @@ -16,7 +17,17 @@ use smithay::{ }; use tracing::warn; -/// Render a surface tree as [TextureRenderElement]s instead of wayland ones. +use crate::{pinnacle_render_elements, render::texture::CommonTextureRenderElement}; + +pinnacle_render_elements! { + #[derive(Debug)] + pub enum WlSurfaceTextureRenderElement { + Texture = CommonTextureRenderElement, + SolidColor = SolidColorRenderElement, + } +} + +/// Render a surface tree as [`WlSurfaceTextureRenderElement`]s instead of wayland ones. /// /// Needed to allow WaylandSurfaceRenderElements to be dropped to free shm buffers. pub fn texture_render_elements_from_surface_tree( @@ -25,10 +36,10 @@ pub fn texture_render_elements_from_surface_tree( location: impl Into>, scale: impl Into>, alpha: f32, -) -> Vec> { +) -> Vec { let location = location.into().to_f64(); let scale = scale.into(); - let mut surfaces: Vec> = Vec::new(); + let mut surfaces: Vec = Vec::new(); compositor::with_surface_tree_downward( surface, @@ -80,24 +91,41 @@ pub fn texture_render_elements_from_surface_tree( let data = data.lock().unwrap(); let view = data.view().unwrap(); - let texture_buffer = TextureBuffer::from_texture( - renderer, - surface.texture().clone(), - data.buffer_scale(), - data.buffer_transform(), - None, - ); + match surface.texture() { + WaylandSurfaceTexture::Texture(texture) => { + let texture_buffer = TextureBuffer::from_texture( + renderer, + texture.clone(), + data.buffer_scale(), + data.buffer_transform(), + None, + ); - let texture_elem = TextureRenderElement::from_texture_buffer( - location, - &texture_buffer, - Some(alpha), - Some(view.src), - Some(view.dst), - element::Kind::Unspecified, - ); + let texture_elem = TextureRenderElement::from_texture_buffer( + location, + &texture_buffer, + Some(alpha), + Some(view.src), + Some(view.dst), + element::Kind::Unspecified, + ); - surfaces.push(texture_elem); + surfaces + .push(CommonTextureRenderElement::new(texture_elem).into()); + } + WaylandSurfaceTexture::SolidColor(color) => { + let solid_color_buffer = + SolidColorBuffer::new(view.dst, *color); + let solid_color_elem = SolidColorRenderElement::from_buffer( + &solid_color_buffer, + location.to_i32_round(), // INFO: is this the correct rounding + scale, + alpha, + element::Kind::Unspecified, + ); + surfaces.push(solid_color_elem.into()); + } + } } Ok(None) => {} // surface is not mapped Err(err) => {