cargo fmt

This commit is contained in:
Shawn Wallace 2026-01-18 14:43:48 -05:00
parent 1979beaa39
commit 64c70be855
11 changed files with 110 additions and 75 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, 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};

View file

@ -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<WlRegistry, GlobalListContents> for MyWorld {
fn event(

View file

@ -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;

View file

@ -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<S: X11Selection> Dispatch<XwaylandSurfaceV1, Entity> for InnerServerState<S
if let Some(win_entity) = win_entity {
let bundle = state.world.take(win_entity).unwrap();
if !bundle.has::<x::Window>() {
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();

View file

@ -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,

View file

@ -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<S: X11Selection> ServerState<NoConnection<S>> {
.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<S: X11Selection> ServerState<NoConnection<S>> {
.bind::<WpViewporter, _, _>(&qh, 1..=1, ())
.expect("Could not bind wp_viewporter");
let fractional_scale = global_list.bind::<WpFractionalScaleManagerV1, _, _>(&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::<WpFractionalScaleManagerV1, _, _>(&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<C: XConnection> ServerState<C> {
}
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<C: XConnection> ServerState<C> {
}),
) {
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<S: X11Selection + 'static> InnerServerState<S> {
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:?}");

View file

@ -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};

View file

@ -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]

View file

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

View file

@ -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;