From 64c70be855344335fda19d0a373ef3a197ac0d50 Mon Sep 17 00:00:00 2001 From: Shawn Wallace Date: Sun, 18 Jan 2026 14:43:48 -0500 Subject: [PATCH] cargo fmt --- src/lib.rs | 2 +- src/server/clientside.rs | 35 ++++++++++++++--------- src/server/decoration.rs | 2 +- src/server/dispatch.rs | 6 ++-- src/server/event.rs | 2 +- src/server/mod.rs | 36 ++++++++++++++++------- src/server/selection.rs | 6 ++-- src/server/tests.rs | 62 +++++++++++++++++++++++----------------- src/xstate/mod.rs | 22 +++++++------- src/xstate/selection.rs | 4 +-- tests/integration.rs | 8 +++--- 11 files changed, 110 insertions(+), 75 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 8e2147a..9f11ef4 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, Timespec}; +use rustix::event::{PollFd, PollFlags, Timespec, poll}; use server::selection::{Clipboard, Primary}; use smithay_client_toolkit::data_device_manager::WritePipe; use std::io::{BufRead, BufReader, Read, Write}; diff --git a/src/server/clientside.rs b/src/server/clientside.rs index a3d7eb3..05c8cbe 100644 --- a/src/server/clientside.rs +++ b/src/server/clientside.rs @@ -16,7 +16,7 @@ use smithay_client_toolkit::{ selection::PrimarySelectionSourceHandler, }, }; -use std::sync::{mpsc, Mutex, OnceLock}; +use std::sync::{Mutex, OnceLock, mpsc}; use wayland_client::protocol::{ wl_buffer::WlBuffer, wl_callback::WlCallback, wl_compositor::WlCompositor, wl_keyboard::WlKeyboard, wl_output::WlOutput, wl_pointer::WlPointer, wl_region::WlRegion, @@ -25,15 +25,10 @@ use wayland_client::protocol::{ wl_touch::WlTouch, }; use wayland_client::{ - delegate_noop, event_created_child, + Connection, Dispatch, Proxy, QueueHandle, delegate_noop, event_created_child, globals::{Global, GlobalList, GlobalListContents}, - Connection, Dispatch, Proxy, QueueHandle, }; use wayland_protocols::{ - wp::relative_pointer::zv1::client::{ - zwp_relative_pointer_manager_v1::ZwpRelativePointerManagerV1, - zwp_relative_pointer_v1::ZwpRelativePointerV1, - }, wp::{ fractional_scale::v1::client::{ wp_fractional_scale_manager_v1::WpFractionalScaleManagerV1, @@ -44,6 +39,11 @@ use wayland_protocols::{ zwp_linux_dmabuf_feedback_v1::ZwpLinuxDmabufFeedbackV1 as DmabufFeedback, zwp_linux_dmabuf_v1::ZwpLinuxDmabufV1, }, + linux_drm_syncobj::v1::client::{ + wp_linux_drm_syncobj_manager_v1::WpLinuxDrmSyncobjManagerV1, + wp_linux_drm_syncobj_surface_v1::WpLinuxDrmSyncobjSurfaceV1, + wp_linux_drm_syncobj_timeline_v1::WpLinuxDrmSyncobjTimelineV1, + }, pointer_constraints::zv1::client::{ zwp_confined_pointer_v1::ZwpConfinedPointerV1, zwp_locked_pointer_v1::ZwpLockedPointerV1, @@ -54,25 +54,31 @@ use wayland_protocols::{ zwp_primary_selection_device_v1::ZwpPrimarySelectionDeviceV1, zwp_primary_selection_source_v1::ZwpPrimarySelectionSourceV1, }, + relative_pointer::zv1::client::{ + zwp_relative_pointer_manager_v1::ZwpRelativePointerManagerV1, + zwp_relative_pointer_v1::ZwpRelativePointerV1, + }, tablet::zv2::client::{ zwp_tablet_manager_v2::ZwpTabletManagerV2, - zwp_tablet_pad_group_v2::{ZwpTabletPadGroupV2, EVT_RING_OPCODE, EVT_STRIP_OPCODE}, + zwp_tablet_pad_group_v2::{EVT_RING_OPCODE, EVT_STRIP_OPCODE, ZwpTabletPadGroupV2}, zwp_tablet_pad_ring_v2::ZwpTabletPadRingV2, zwp_tablet_pad_strip_v2::ZwpTabletPadStripV2, - zwp_tablet_pad_v2::{ZwpTabletPadV2, EVT_GROUP_OPCODE}, + zwp_tablet_pad_v2::{EVT_GROUP_OPCODE, ZwpTabletPadV2}, zwp_tablet_seat_v2::{ - ZwpTabletSeatV2, EVT_PAD_ADDED_OPCODE, EVT_TABLET_ADDED_OPCODE, - EVT_TOOL_ADDED_OPCODE, + EVT_PAD_ADDED_OPCODE, EVT_TABLET_ADDED_OPCODE, EVT_TOOL_ADDED_OPCODE, + ZwpTabletSeatV2, }, zwp_tablet_tool_v2::ZwpTabletToolV2, zwp_tablet_v2::ZwpTabletV2, }, viewporter::client::{wp_viewport::WpViewport, wp_viewporter::WpViewporter}, }, - xdg::decoration::zv1::client::zxdg_decoration_manager_v1::ZxdgDecorationManagerV1, - xdg::decoration::zv1::client::zxdg_toplevel_decoration_v1::ZxdgToplevelDecorationV1, xdg::{ activation::v1::client::xdg_activation_v1::XdgActivationV1, + decoration::zv1::client::{ + zxdg_decoration_manager_v1::ZxdgDecorationManagerV1, + zxdg_toplevel_decoration_v1::ZxdgToplevelDecorationV1, + }, shell::client::{ xdg_popup::XdgPopup, xdg_positioner::XdgPositioner, xdg_surface::XdgSurface, xdg_toplevel::XdgToplevel, xdg_wm_base::XdgWmBase, @@ -185,6 +191,9 @@ delegate_noop!(MyWorld: ZxdgDecorationManagerV1); delegate_noop!(MyWorld: WpFractionalScaleManagerV1); delegate_noop!(MyWorld: ZwpPrimarySelectionDeviceManagerV1); delegate_noop!(MyWorld: WlSubsurface); +delegate_noop!(MyWorld: WpLinuxDrmSyncobjManagerV1); +delegate_noop!(MyWorld: WpLinuxDrmSyncobjSurfaceV1); +delegate_noop!(MyWorld: WpLinuxDrmSyncobjTimelineV1); impl Dispatch for MyWorld { fn event( diff --git a/src/server/decoration.rs b/src/server/decoration.rs index 4068ec7..db37dc2 100644 --- a/src/server/decoration.rs +++ b/src/server/decoration.rs @@ -10,11 +10,11 @@ use std::borrow::Cow; use std::sync::LazyLock; use tiny_skia::{Color, Paint, PathBuilder, Pixmap, Stroke, Transform}; use tiny_skia::{ColorU8, Rect}; +use wayland_client::Proxy; use wayland_client::protocol::wl_seat::WlSeat; use wayland_client::protocol::wl_shm; use wayland_client::protocol::wl_subsurface::WlSubsurface; use wayland_client::protocol::wl_surface::WlSurface; -use wayland_client::Proxy; use wayland_protocols::wp::viewporter::client::wp_viewport::WpViewport; use wayland_protocols::xdg::decoration::zv1::client::zxdg_toplevel_decoration_v1::ZxdgToplevelDecorationV1; use wayland_protocols::xdg::shell::client::xdg_toplevel::XdgToplevel; diff --git a/src/server/dispatch.rs b/src/server/dispatch.rs index 969b50a..5bad71b 100644 --- a/src/server/dispatch.rs +++ b/src/server/dispatch.rs @@ -47,6 +47,7 @@ use wayland_protocols::{ }, }; use wayland_server::{ + Dispatch, DisplayHandle, GlobalDispatch, Resource, protocol::{ wl_buffer::WlBuffer, wl_callback::WlCallback, @@ -61,7 +62,6 @@ use wayland_server::{ wl_surface::WlSurface, wl_touch::WlTouch, }, - Dispatch, DisplayHandle, GlobalDispatch, Resource, }; // noop @@ -1458,7 +1458,9 @@ impl Dispatch for InnerServerState() { - warn!("Window with same serial ({serial:?}) as {surface_id} has been destroyed?"); + warn!( + "Window with same serial ({serial:?}) as {surface_id} has been destroyed?" + ); return; } let mut builder = hecs::EntityBuilder::new(); diff --git a/src/server/event.rs b/src/server/event.rs index e4114f4..e856c0e 100644 --- a/src/server/event.rs +++ b/src/server/event.rs @@ -5,7 +5,7 @@ use hecs::{CommandBuffer, World}; use log::{debug, error, trace, warn}; use macros::simple_event_shunt; use std::os::fd::AsFd; -use wayland_client::{protocol as client, Proxy}; +use wayland_client::{Proxy, protocol as client}; use wayland_protocols::{ wp::{ fractional_scale::v1::client::wp_fractional_scale_v1, diff --git a/src/server/mod.rs b/src/server/mod.rs index a9d6a8b..96bfcb1 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -8,12 +8,12 @@ mod tests; use self::event::*; use crate::xstate::{Decorations, MoveResizeDirection, WindowDims, WmHints, WmName, WmNormalHints}; -use crate::{timespec_from_millis, X11Selection, XConnection}; +use crate::{X11Selection, XConnection, timespec_from_millis}; use clientside::MyWorld; use decoration::{DecorationsData, DecorationsDataSatellite}; use hecs::Entity; use log::{debug, error, warn}; -use rustix::event::{poll, PollFd, PollFlags}; +use rustix::event::{PollFd, PollFlags, poll}; use rustix::fs::Timespec; use smithay_client_toolkit::activation::ActivationState; use std::collections::{HashMap, HashSet}; @@ -23,8 +23,9 @@ use std::os::unix::net::UnixStream; use std::time::Duration; use wayland_client::protocol::wl_subcompositor::WlSubcompositor; use wayland_client::{ - globals::{registry_queue_init, Global}, - protocol as client, Connection, EventQueue, Proxy, QueueHandle, + Connection, EventQueue, Proxy, QueueHandle, + globals::{Global, registry_queue_init}, + protocol as client, }; use wayland_protocols::xdg::decoration::zv1::client::zxdg_decoration_manager_v1::ZxdgDecorationManagerV1; use wayland_protocols::xdg::decoration::zv1::client::zxdg_toplevel_decoration_v1::{self}; @@ -62,11 +63,11 @@ use wayland_protocols::{ }; use wayland_server::protocol::wl_seat::WlSeat; use wayland_server::{ + Client, DisplayHandle, Resource, WEnum, protocol::{ wl_callback::WlCallback, wl_compositor::WlCompositor, wl_output::WlOutput, wl_shm::WlShm, wl_surface::WlSurface, }, - Client, DisplayHandle, Resource, WEnum, }; use wl_drm::{client::wl_drm::WlDrm as WlDrmClient, server::wl_drm::WlDrm as WlDrmServer}; use xcb::x; @@ -485,7 +486,9 @@ impl ServerState> { .expect("Could not bind xdg_wm_base"); if xdg_wm_base.version() < 3 { - warn!("xdg_wm_base version 2 detected. Popup repositioning will not work, and some popups may not work correctly."); + warn!( + "xdg_wm_base version 2 detected. Popup repositioning will not work, and some popups may not work correctly." + ); } let compositor = global_list @@ -504,8 +507,13 @@ impl ServerState> { .bind::(&qh, 1..=1, ()) .expect("Could not bind wp_viewporter"); - let fractional_scale = global_list.bind::(&qh, 1..=1, ()) - .inspect_err(|e| warn!("Couldn't bind fractional scale manager: {e}. Fractional scaling will not work.")) + let fractional_scale = global_list + .bind::(&qh, 1..=1, ()) + .inspect_err(|e| { + warn!( + "Couldn't bind fractional scale manager: {e}. Fractional scaling will not work." + ) + }) .ok(); let activation_state = ActivationState::bind(&global_list, &qh) @@ -692,7 +700,9 @@ impl ServerState { } if mixed_scale { - warn!("Mixed output scales detected, choosing to give apps the smallest detected scale ({scale}x)"); + warn!( + "Mixed output scales detected, choosing to give apps the smallest detected scale ({scale}x)" + ); } debug!("Using new scale {scale}"); @@ -730,7 +740,9 @@ impl ServerState { }), ) { Ok(0) => { - error!("Failed to flush clientside events (timeout)! Will try again later."); + error!( + "Failed to flush clientside events (timeout)! Will try again later." + ); } Ok(_) => { self.queue.flush().unwrap(); @@ -825,7 +837,9 @@ impl InnerServerState { let new_title = match &mut win.attrs.title { Some(w) => { if matches!(w, WmName::NetWmName(_)) && matches!(name, WmName::WmName(_)) { - debug!("skipping setting window name to {name:?} because a _NET_WM_NAME title is already set"); + debug!( + "skipping setting window name to {name:?} because a _NET_WM_NAME title is already set" + ); None } else { debug!("setting {window:?} title to {name:?}"); diff --git a/src/server/selection.rs b/src/server/selection.rs index 901b472..bd32aaa 100644 --- a/src/server/selection.rs +++ b/src/server/selection.rs @@ -8,13 +8,13 @@ use wayland_client::protocol::wl_seat::WlSeat; use wayland_client::{Proxy, QueueHandle}; use smithay_client_toolkit::data_device_manager::{ - data_device::DataDevice, data_offer::SelectionOffer as WlSelectionOffer, - data_source::CopyPasteSource, DataDeviceManagerState, + DataDeviceManagerState, data_device::DataDevice, + data_offer::SelectionOffer as WlSelectionOffer, data_source::CopyPasteSource, }; +use smithay_client_toolkit::primary_selection::PrimarySelectionManagerState; use smithay_client_toolkit::primary_selection::device::PrimarySelectionDevice; use smithay_client_toolkit::primary_selection::offer::PrimarySelectionOffer; use smithay_client_toolkit::primary_selection::selection::PrimarySelectionSource; -use smithay_client_toolkit::primary_selection::PrimarySelectionManagerState; use std::io::Read; use std::rc::{Rc, Weak}; diff --git a/src/server/tests.rs b/src/server/tests.rs index 3b0fe96..da176cb 100644 --- a/src/server/tests.rs +++ b/src/server/tests.rs @@ -1,8 +1,8 @@ -use super::{selection::Clipboard, InnerServerState, NoConnection, ServerState, WindowDims}; +use super::{InnerServerState, NoConnection, ServerState, WindowDims, selection::Clipboard}; use crate::server::selection::{Primary, SelectionType}; use crate::xstate::{SetState, WinSize, WmName}; -use crate::{timespec_from_millis, XConnection}; -use rustix::event::{poll, PollFd, PollFlags}; +use crate::{XConnection, timespec_from_millis}; +use rustix::event::{PollFd, PollFlags, poll}; use std::collections::HashMap; use std::io::Write; use std::os::fd::{AsRawFd, BorrowedFd}; @@ -10,7 +10,8 @@ use std::os::unix::net::UnixStream; use std::sync::{Arc, Mutex}; use testwl::{SendDataForMimeFn, SurfaceRole}; use wayland_client::{ - backend::{protocol::Message, Backend, ObjectData, ObjectId, WaylandError}, + Connection, Proxy, WEnum, + backend::{Backend, ObjectData, ObjectId, WaylandError, protocol::Message}, protocol::{ wl_buffer::WlBuffer, wl_compositor::WlCompositor, @@ -25,8 +26,8 @@ use wayland_client::{ wl_surface::WlSurface, wl_touch::{self, WlTouch}, }, - Connection, Proxy, WEnum, }; +use wayland_protocols::wp::linux_drm_syncobj::v1::client::wp_linux_drm_syncobj_manager_v1::WpLinuxDrmSyncobjManagerV1; use wayland_protocols::xdg::decoration::zv1::server::zxdg_toplevel_decoration_v1; use wayland_protocols::{ wp::{ @@ -39,14 +40,14 @@ use wayland_protocols::{ tablet::zv2::client::{ zwp_tablet_manager_v2::{self, ZwpTabletManagerV2}, zwp_tablet_pad_group_v2::{ - self, ZwpTabletPadGroupV2, EVT_RING_OPCODE, EVT_STRIP_OPCODE, + self, EVT_RING_OPCODE, EVT_STRIP_OPCODE, ZwpTabletPadGroupV2, }, zwp_tablet_pad_ring_v2::ZwpTabletPadRingV2, zwp_tablet_pad_strip_v2::ZwpTabletPadStripV2, - zwp_tablet_pad_v2::{self, ZwpTabletPadV2, EVT_GROUP_OPCODE}, + zwp_tablet_pad_v2::{self, EVT_GROUP_OPCODE, ZwpTabletPadV2}, zwp_tablet_seat_v2::{ - self, ZwpTabletSeatV2, EVT_PAD_ADDED_OPCODE, EVT_TABLET_ADDED_OPCODE, - EVT_TOOL_ADDED_OPCODE, + self, EVT_PAD_ADDED_OPCODE, EVT_TABLET_ADDED_OPCODE, EVT_TOOL_ADDED_OPCODE, + ZwpTabletSeatV2, }, zwp_tablet_tool_v2::{self, ZwpTabletToolV2}, zwp_tablet_v2::{self, ZwpTabletV2}, @@ -63,7 +64,7 @@ use wayland_protocols::{ xwayland_shell_v1::XwaylandShellV1, xwayland_surface_v1::XwaylandSurfaceV1, }, }; -use wayland_server::{protocol as s_proto, Display, Resource}; +use wayland_server::{Display, Resource, protocol as s_proto}; use wl_drm::client::wl_drm::WlDrm; use xcb::x::{self, Window}; @@ -1097,7 +1098,8 @@ fn pass_through_globals() { WlDrm, ZwpPointerConstraintsV1, XwaylandShellV1, - ZwpTabletManagerV2 + ZwpTabletManagerV2, + WpLinuxDrmSyncobjManagerV1 } let mut globals = SupportedGlobals::default(); @@ -1222,40 +1224,46 @@ fn fullscreen() { f.run(); let data = f.testwl.get_surface_data(id).unwrap(); - assert!(data - .toplevel() - .states - .contains(&xdg_toplevel::State::Fullscreen)); + assert!( + data.toplevel() + .states + .contains(&xdg_toplevel::State::Fullscreen) + ); f.satellite.set_fullscreen(win, SetState::Remove); f.run(); f.run(); let data = f.testwl.get_surface_data(id).unwrap(); - assert!(!data - .toplevel() - .states - .contains(&xdg_toplevel::State::Fullscreen)); + assert!( + !data + .toplevel() + .states + .contains(&xdg_toplevel::State::Fullscreen) + ); f.satellite.set_fullscreen(win, SetState::Toggle); f.run(); f.run(); let data = f.testwl.get_surface_data(id).unwrap(); - assert!(data - .toplevel() - .states - .contains(&xdg_toplevel::State::Fullscreen)); + assert!( + data.toplevel() + .states + .contains(&xdg_toplevel::State::Fullscreen) + ); f.satellite.set_fullscreen(win, SetState::Toggle); f.run(); f.run(); let data = f.testwl.get_surface_data(id).unwrap(); - assert!(!data - .toplevel() - .states - .contains(&xdg_toplevel::State::Fullscreen)); + assert!( + !data + .toplevel() + .states + .contains(&xdg_toplevel::State::Fullscreen) + ); } #[test] diff --git a/src/xstate/mod.rs b/src/xstate/mod.rs index e08bcd7..5079f24 100644 --- a/src/xstate/mod.rs +++ b/src/xstate/mod.rs @@ -11,7 +11,7 @@ use std::collections::HashMap; use std::ffi::CString; use std::os::fd::BorrowedFd; use std::rc::Rc; -use xcb::{x, Xid, XidNew}; +use xcb::{Xid, XidNew, x}; use xcb_util_cursor::{Cursor, CursorContext}; // Sometimes we'll get events on windows that have already been destroyed @@ -369,9 +369,9 @@ impl XState { let attrs = self .connection .send_request(&x::GetWindowAttributes { window: e.window() }); - let geometry = unwrap_or_skip_bad_window_cont!(self - .connection - .wait_for_reply(geometry)); + let geometry = unwrap_or_skip_bad_window_cont!( + self.connection.wait_for_reply(geometry) + ); let attrs = unwrap_or_skip_bad_window_cont!(self.connection.wait_for_reply(attrs)); @@ -400,9 +400,10 @@ impl XState { value_list: &[x::ConfigWindow::StackMode(x::StackMode::Below)] } )); - unwrap_or_skip_bad_window_cont!(self - .connection - .send_and_check_request(&x::MapWindow { window: e.window() })); + unwrap_or_skip_bad_window_cont!( + self.connection + .send_and_check_request(&x::MapWindow { window: e.window() }) + ); } xcb::Event::X(x::Event::MapNotify(e)) => { unwrap_or_skip_bad_window_cont!(self.connection.send_and_check_request( @@ -1472,9 +1473,10 @@ impl XConnection for RealConnection { } fn unmap_window(&mut self, window: x::Window) { - unwrap_or_skip_bad_window_ret!(self - .connection - .send_and_check_request(&x::UnmapWindow { window })); + unwrap_or_skip_bad_window_ret!( + self.connection + .send_and_check_request(&x::UnmapWindow { window }) + ); } fn raise_to_top(&mut self, window: x::Window) { diff --git a/src/xstate/selection.rs b/src/xstate/selection.rs index aecb782..8500a79 100644 --- a/src/xstate/selection.rs +++ b/src/xstate/selection.rs @@ -1,8 +1,8 @@ -use super::{get_atom_name, XState}; +use super::{XState, get_atom_name}; use crate::server::selection::{Clipboard, ForeignSelection, Primary, SelectionType}; use crate::{RealServerState, X11Selection}; use log::{debug, error, warn}; -use rustix::event::{poll, PollFd, PollFlags}; +use rustix::event::{PollFd, PollFlags, poll}; use smithay_client_toolkit::data_device_manager::WritePipe; use std::cell::RefCell; use std::collections::VecDeque; diff --git a/tests/integration.rs b/tests/integration.rs index 5edfa31..361e9d3 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -1,4 +1,4 @@ -use rustix::event::{poll, PollFd, PollFlags}; +use rustix::event::{PollFd, PollFlags, poll}; use rustix::process::{Pid, Signal, WaitOptions}; use std::collections::HashMap; use std::io::Write; @@ -6,17 +6,17 @@ use std::mem::ManuallyDrop; use std::os::fd::{AsRawFd, BorrowedFd, OwnedFd}; use std::os::unix::net::UnixStream; use std::sync::{ - atomic::{AtomicBool, Ordering}, Arc, Mutex, Once, + atomic::{AtomicBool, Ordering}, }; use std::thread::JoinHandle; use std::time::{Duration, Instant}; use wayland_protocols::xdg::{ decoration::zv1::server::zxdg_toplevel_decoration_v1, shell::server::xdg_toplevel, }; -use wayland_server::protocol::{wl_output, wl_pointer}; use wayland_server::Resource; -use xcb::{x, Xid}; +use wayland_server::protocol::{wl_output, wl_pointer}; +use xcb::{Xid, x}; use xwayland_satellite as xwls; use xwayland_satellite::xstate::{MoveResizeDirection, WmSizeHintsFlags, WmState}; use xwls::timespec_from_millis;