From bf745144acda1343934e9a094cf9458a54d57889 Mon Sep 17 00:00:00 2001 From: En-En <39373446+En-En-Code@users.noreply.github.com> Date: Wed, 8 Oct 2025 12:27:28 +0000 Subject: [PATCH] fix: bump xcb-util-cursor to 0.3.5 xcb-util-cursor made another patch release to revert back to Rust 2021 edition, so we bump to that. Also create a function, `timespec_from_millis` to make creating `Timespec` for using in `poll` calls a lot more ergonomic. --- Cargo.lock | 9 ++++----- Cargo.toml | 8 +++----- src/lib.rs | 10 +++++++++- src/server/mod.rs | 11 ++++------- src/server/tests.rs | 29 ++++++++++------------------- tests/integration.rs | 33 +++++++++++---------------------- 6 files changed, 41 insertions(+), 59 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a3a9aa8..9893e62 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1100,9 +1100,9 @@ dependencies = [ [[package]] name = "xcb-util-cursor" -version = "0.3.4" +version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f361f49c89d5aa2e9e44bd5c38ac6865b9338d48b58a980015881df5c4484eff" +checksum = "bf6417c51a1f5eda49156061175021bd3ccf0a759bc7c402bbea6a6a1ae14239" dependencies = [ "xcb", "xcb-util-cursor-sys", @@ -1110,9 +1110,9 @@ dependencies = [ [[package]] name = "xcb-util-cursor-sys" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7df0ea411b072fa53e1f4f5a6543649712cb9640c0de7686cca8edaf6971b117" +checksum = "4c78acb131647687ee62f9e64c988457f23ecb8f3a078a37a312f989b320cb47" dependencies = [ "bindgen", "pkg-config", @@ -1148,7 +1148,6 @@ dependencies = [ "testwl", "vergen-gitcl", "wayland-client", - "wayland-cursor", "wayland-protocols", "wayland-server", "wl_drm", diff --git a/Cargo.toml b/Cargo.toml index 41e4e62..b9f5ba6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,9 +3,6 @@ members = ["macros", "testwl", "wl_drm"] [workspace.dependencies] wayland-client = "0.31.11" -# We don't directly use wayland-cursor, but we need to set its version so -# smithay-client-toolkit does not depend on an older version with rustix < 1 -wayland-cursor = "0.31.11" wayland-protocols = "0.32.9" wayland-scanner = "0.31.7" wayland-server = "0.31.10" @@ -33,14 +30,15 @@ crate-type = ["lib"] bitflags = "2.5.0" rustix = { workspace = true, features = ["event"] } wayland-client.workspace = true -wayland-cursor.workspace = true wayland-protocols = { workspace = true, features = ["client", "server", "staging", "unstable"] } wayland-server.workspace = true xcb = { version = "1.6.0", features = ["composite", "randr", "res"] } wl_drm = { path = "wl_drm" } log = "0.4.21" pretty_env_logger = "0.5.0" -xcb-util-cursor = "0.3.4" +# xcb-util-cursor 0.4 uses Rust 2024, which would bump MSRV from 1.83 to 1.85, however it also has +# no meaningful code changes, so we stick to the older version +xcb-util-cursor = "0.3.5" smithay-client-toolkit = { version = "0.20.0", default-features = false } sd-notify = { version = "0.4.2", optional = true } diff --git a/src/lib.rs b/src/lib.rs index 6ae2084..c1c0fa1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,7 +4,7 @@ pub mod xstate; use crate::server::{NoConnection, PendingSurfaceState, ServerState}; use crate::xstate::{RealConnection, XState}; use log::{error, info}; -use rustix::event::{poll, PollFd, PollFlags}; +use rustix::event::{poll, PollFd, PollFlags, Timespec}; use server::selection::{Clipboard, Primary}; use smithay_client_toolkit::data_device_manager::WritePipe; use std::io::{BufRead, BufReader, Read, Write}; @@ -47,6 +47,14 @@ pub trait RunData { fn xwayland_ready(&self, _display: String, _pid: u32) {} } +pub const fn timespec_from_millis(millis: u64) -> Timespec { + let d = std::time::Duration::from_millis(millis); + Timespec { + tv_sec: d.as_secs() as i64, + tv_nsec: d.subsec_nanos() as i64, + } +} + pub fn main(mut data: impl RunData) -> Option<()> { let mut version = env!("VERGEN_GIT_DESCRIBE"); if version == "VERGEN_IDEMPOTENT_OUTPUT" { diff --git a/src/server/mod.rs b/src/server/mod.rs index fd12bdb..bb33217 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -7,11 +7,11 @@ mod tests; use self::event::*; use crate::xstate::{Decorations, MoveResizeDirection, WindowDims, WmHints, WmName, WmNormalHints}; -use crate::{X11Selection, XConnection}; +use crate::{timespec_from_millis, X11Selection, XConnection}; use clientside::MyWorld; use hecs::{Entity, World}; use log::{debug, warn}; -use rustix::event::{poll, PollFd, PollFlags, Timespec}; +use rustix::event::{poll, PollFd, PollFlags}; use smithay_client_toolkit::activation::ActivationState; use std::collections::{HashMap, HashSet}; use std::ops::{Deref, DerefMut}; @@ -569,11 +569,8 @@ impl ServerState { if let Some(r) = self.queue.prepare_read() { let fd = r.connection_fd(); let pollfd = PollFd::new(&fd, PollFlags::IN); - let timeout = Some(&Timespec { - tv_sec: 0, - tv_nsec: 0, - }); - if poll(&mut [pollfd], timeout).unwrap() > 0 { + let timeout = timespec_from_millis(0); + if poll(&mut [pollfd], Some(&timeout)).unwrap() > 0 { let _ = r.read(); } } diff --git a/src/server/tests.rs b/src/server/tests.rs index a436561..24da976 100644 --- a/src/server/tests.rs +++ b/src/server/tests.rs @@ -1,8 +1,8 @@ use super::{selection::Clipboard, InnerServerState, NoConnection, ServerState, WindowDims}; use crate::server::selection::{Primary, SelectionType}; use crate::xstate::{SetState, WinSize, WmName}; -use crate::XConnection; -use rustix::event::{poll, PollFd, PollFlags, Timespec}; +use crate::{timespec_from_millis, XConnection}; +use rustix::event::{poll, PollFd, PollFlags}; use std::collections::HashMap; use std::io::Write; use std::os::fd::{AsRawFd, BorrowedFd}; @@ -361,11 +361,8 @@ impl EarlyTestFixture { // Handle initial globals roundtrip setup requirement let thread = std::thread::spawn(move || { let mut pollfd = [PollFd::from_borrowed_fd(testwl.poll_fd(), PollFlags::IN)]; - let timeout = Some(&Timespec { - tv_sec: 1, - tv_nsec: 0, - }); - if poll(&mut pollfd, timeout).unwrap() == 0 { + let timeout = timespec_from_millis(1000); + if poll(&mut pollfd, Some(&timeout)).unwrap() == 0 { panic!("Did not get events for testwl!"); } testwl.dispatch(); @@ -1396,15 +1393,12 @@ fn copy_from_wayland() { s.spawn(|| { let pollfd = unsafe { BorrowedFd::borrow_raw(f.testwl.poll_fd().as_raw_fd()) }; let mut pollfd = [PollFd::from_borrowed_fd(pollfd, PollFlags::IN)]; - let timeout = Some(&Timespec { - tv_sec: 0, - tv_nsec: 100_000_000, - }); - if poll(&mut pollfd, timeout).unwrap() == 0 { + let timeout = timespec_from_millis(100); + if poll(&mut pollfd, Some(&timeout)).unwrap() == 0 { panic!("Did not get events for testwl!"); } f.testwl.dispatch(); - while poll(&mut pollfd, timeout).unwrap() > 0 { + while poll(&mut pollfd, Some(&timeout)).unwrap() > 0 { f.testwl.dispatch(); } }); @@ -1460,15 +1454,12 @@ fn selection_x11_then_wayland() { s.spawn(|| { let pollfd = unsafe { BorrowedFd::borrow_raw(f.testwl.poll_fd().as_raw_fd()) }; let mut pollfd = [PollFd::from_borrowed_fd(pollfd, PollFlags::IN)]; - let timeout = Some(&Timespec { - tv_sec: 0, - tv_nsec: 100_000_000, - }); - if poll(&mut pollfd, timeout).unwrap() == 0 { + let timeout = timespec_from_millis(100); + if poll(&mut pollfd, Some(&timeout)).unwrap() == 0 { panic!("Did not get events for testwl!"); } f.testwl.dispatch(); - while poll(&mut pollfd, timeout).unwrap() > 0 { + while poll(&mut pollfd, Some(&timeout)).unwrap() > 0 { f.testwl.dispatch(); } }); diff --git a/tests/integration.rs b/tests/integration.rs index 147f15a..3bd58e2 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -1,4 +1,4 @@ -use rustix::event::{poll, PollFd, PollFlags, Timespec}; +use rustix::event::{poll, PollFd, PollFlags}; use rustix::process::{Pid, Signal, WaitOptions}; use std::collections::HashMap; use std::io::Write; @@ -19,6 +19,7 @@ use wayland_server::Resource; use xcb::{x, Xid}; use xwayland_satellite as xwls; use xwayland_satellite::xstate::{MoveResizeDirection, WmSizeHintsFlags, WmState}; +use xwls::timespec_from_millis; #[derive(Default)] struct TestDataInner { @@ -131,11 +132,8 @@ impl Fixture { // wait for connection let fd = unsafe { BorrowedFd::borrow_raw(testwl.poll_fd().as_raw_fd()) }; let pollfd = PollFd::from_borrowed_fd(fd, PollFlags::IN); - let timeout = Some(&Timespec { - tv_sec: 1, - tv_nsec: 0, - }); - assert!(poll(&mut [pollfd.clone()], timeout).unwrap() > 0); + let timeout = timespec_from_millis(1000); + assert!(poll(&mut [pollfd.clone()], Some(&timeout)).unwrap() > 0); testwl.dispatch(); let try_bool_timeout = |b: &AtomicBool| { @@ -163,11 +161,8 @@ impl Fixture { let mut ready = our_data.display.lock().unwrap().is_some(); while !ready && start.elapsed() < Duration::from_millis(2000) { - let timeout = Some(&Timespec { - tv_sec: 0, - tv_nsec: 100_000_000, - }); - let n = poll(&mut f, timeout).unwrap(); + let timeout = timespec_from_millis(100); + let n = poll(&mut f, Some(&timeout)).unwrap(); if n > 0 { testwl.dispatch(); } @@ -195,18 +190,15 @@ impl Fixture { fn wait_and_dispatch(&mut self) { let mut pollfd = [self.pollfd.clone()]; self.testwl.dispatch(); - let timeout = Some(&Timespec { - tv_sec: 0, - tv_nsec: 50_000_000, - }); + let timeout = timespec_from_millis(50); assert!( - poll(&mut pollfd, timeout).unwrap() > 0, + poll(&mut pollfd, Some(&timeout)).unwrap() > 0, "Did not receive any events" ); self.pollfd.clear_revents(); self.testwl.dispatch(); - while poll(&mut pollfd, timeout).unwrap() > 0 { + while poll(&mut pollfd, Some(&timeout)).unwrap() > 0 { self.testwl.dispatch(); self.pollfd.clear_revents(); } @@ -479,12 +471,9 @@ impl Connection { if let Some(event) = self.poll_for_event().expect("Failed to poll for event") { return event; } - let timeout = Some(&Timespec { - tv_sec: 0, - tv_nsec: 100_000_000, - }); + let timeout = timespec_from_millis(100); assert!( - poll(&mut [self.pollfd.clone()], timeout).expect("poll failed") > 0, + poll(&mut [self.pollfd.clone()], Some(&timeout)).expect("poll failed") > 0, "Did not get any X11 events" ); self.pollfd.clear_revents();