From 5018b3a2ef7009ed7add167104cdbbdab579e19c Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Fri, 5 Jun 2026 14:21:37 -0700 Subject: [PATCH] WIP Updates for future wayland-rs release --- Cargo.toml | 11 +++-------- src/backends/wayland/buffer.rs | 22 +++++++++++++++------- src/backends/wayland/mod.rs | 21 ++++++--------------- 3 files changed, 24 insertions(+), 30 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d9ffcb09..e8ce665d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,9 +16,7 @@ default = ["wayland", "wayland-dlopen", "x11", "x11-dlopen"] # Enable the Wayland backend. wayland = [ - "dep:wayland-backend", "dep:wayland-client", - "dep:wayland-sys", "dep:memmap2", "dep:rustix", "dep:fastrand", @@ -26,7 +24,7 @@ wayland = [ "winit/wayland", "winit/wayland-csd-adwaita", ] -wayland-dlopen = ["wayland-sys/dlopen", "winit/wayland-dlopen"] +wayland-dlopen = ["wayland-client/dlopen", "winit/wayland-dlopen"] # Enable the X11 backend. x11 = [ @@ -64,11 +62,8 @@ rustix = { version = "1.0.1", default-features = false, optional = true, feature ] } # Wayland memmap2 = { version = "0.9.0", optional = true } -wayland-backend = { version = "0.3.0", optional = true, features = [ - "client_system", -] } -wayland-client = { version = "0.31.14", optional = true } -wayland-sys = { version = "0.31.0", optional = true } +# wayland-client = { version = "0.31.14", optional = true, features = ["system"] } +wayland-client = { git = "https://github.com/smithay/wayland-rs", optional = true, features = ["system"] } # X11 as-raw-xcb-connection = { version = "1.0.0", optional = true } tiny-xlib = { version = "0.2.1", optional = true } diff --git a/src/backends/wayland/buffer.rs b/src/backends/wayland/buffer.rs index 37f973f8..883e9137 100644 --- a/src/backends/wayland/buffer.rs +++ b/src/backends/wayland/buffer.rs @@ -110,7 +110,9 @@ impl WaylandBuffer { util::byte_stride(width as u32) as i32, format, qh, - released.clone(), + WlBufferData { + released: released.clone(), + }, ); Self { @@ -151,7 +153,9 @@ impl WaylandBuffer { util::byte_stride(width as u32) as i32, format, &self.qh, - self.released.clone(), + WlBufferData { + released: self.released.clone(), + }, ); self.width = width; self.height = height; @@ -189,29 +193,33 @@ impl Drop for WaylandBuffer { } } -impl Dispatch for State { +impl Dispatch for () { fn event( + &self, _: &mut State, _: &wl_shm_pool::WlShmPool, _: wl_shm_pool::Event, - _: &(), _: &Connection, _: &QueueHandle, ) { } } -impl Dispatch> for State { +struct WlBufferData { + released: Arc, +} + +impl Dispatch for WlBufferData { fn event( + &self, _: &mut State, _: &wl_buffer::WlBuffer, event: wl_buffer::Event, - released: &Arc, _: &Connection, _: &QueueHandle, ) { if let wl_buffer::Event::Release = event { - released.store(true, Ordering::SeqCst); + self.released.store(true, Ordering::SeqCst); } } } diff --git a/src/backends/wayland/mod.rs b/src/backends/wayland/mod.rs index 1c85e0db..2057c827 100644 --- a/src/backends/wayland/mod.rs +++ b/src/backends/wayland/mod.rs @@ -10,8 +10,8 @@ use std::{ }; use wayland_client::{ backend::{Backend, ObjectId}, - globals::{registry_queue_init, GlobalListContents}, - protocol::{wl_registry, wl_shm, wl_surface}, + globals::{registry_queue_init, GlobalListHandler}, + protocol::{wl_shm, wl_surface}, Connection, Dispatch, EventQueue, Proxy, QueueHandle, }; @@ -310,25 +310,16 @@ impl BufferInterface for BufferImpl<'_> { } } -impl Dispatch for State { - fn event( - _: &mut State, - _: &wl_registry::WlRegistry, - _: wl_registry::Event, - _: &GlobalListContents, - _: &Connection, - _: &QueueHandle, - ) { - // Ignore globals added after initialization - } +impl GlobalListHandler for State { + // Ignore globals added after initialization } -impl Dispatch for State { +impl Dispatch for () { fn event( + &self, _: &mut State, _: &wl_shm::WlShm, _: wl_shm::Event, - _: &(), _: &Connection, _: &QueueHandle, ) {