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.
This commit is contained in:
En-En 2025-10-08 12:27:28 +00:00 committed by Supreeeme
parent e827c42d2d
commit bf745144ac
6 changed files with 41 additions and 59 deletions

View file

@ -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" {

View file

@ -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<C: XConnection> ServerState<C> {
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();
}
}

View file

@ -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<T: SelectionTest>() {
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<T: SelectionTest>() {
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();
}
});