Cargo autofixes

This commit is contained in:
stickynotememo
2025-11-20 08:56:59 +11:00
parent 3867e9a571
commit fffc40e86e
+42 -46
View File
@@ -1,32 +1,28 @@
#![feature(more_qualified_paths)] #![feature(more_qualified_paths)]
use std::fs::File; use std::fs::File;
use std::time::Duration; use std::ffi::CString;
use std::{ffi::CString, thread::sleep};
use std::os::fd::BorrowedFd; use std::os::fd::BorrowedFd;
use memmap2::{MmapMut, MmapOptions}; use memmap2::{MmapMut, MmapOptions};
use wayland_client::{ use wayland_client::{
Connection, Dispatch, EventQueue, Proxy, backend::ObjectId, delegate_noop, protocol::{ Connection, Dispatch, EventQueue, Proxy, delegate_noop, protocol::{
wl_buffer::{self, WlBuffer}, wl_buffer::WlBuffer,
wl_compositor::{self, WlCompositor}, wl_compositor::{self, WlCompositor},
wl_registry, wl_shell, wl_registry,
wl_shm::{self, Format, WlShm}, wl_shm::{self, Format, WlShm},
wl_shm_pool::{self, WlShmPool}, wl_shm_pool::{self, WlShmPool},
wl_surface::{self, Event, WlSurface}, wl_surface::WlSurface,
} }
}; };
use libc::{O_CREAT, O_RDWR, PROT_READ, PROT_WRITE, S_IROTH, S_IRWXU, ftruncate, mmap, shm_open}; use libc::{O_CREAT, O_RDWR, S_IROTH, S_IRWXU, ftruncate, shm_open};
use wayland_protocols::xdg::{ use wayland_protocols::xdg::shell::client::{
self, xdg_surface::XdgSurface,
shell::client::{
xdg_surface::{self, XdgSurface},
xdg_toplevel::XdgToplevel, xdg_toplevel::XdgToplevel,
xdg_wm_base::{self, XdgWmBase}, xdg_wm_base::{self, XdgWmBase},
}, };
};
const WIDTH: i32 = 960; const WIDTH: i32 = 960;
const HEIGHT: i32 = 540; const HEIGHT: i32 = 540;
@@ -53,7 +49,7 @@ impl Dispatch<wl_registry::WlRegistry, ()> for State {
proxy: &wl_registry::WlRegistry, proxy: &wl_registry::WlRegistry,
event: <wl_registry::WlRegistry as wayland_client::Proxy>::Event, event: <wl_registry::WlRegistry as wayland_client::Proxy>::Event,
data: &(), data: &(),
conn: &Connection, _conn: &Connection,
qhandle: &wayland_client::QueueHandle<Self>, qhandle: &wayland_client::QueueHandle<Self>,
) { ) {
// Iterate over the globals given by the registry. // Iterate over the globals given by the registry.
@@ -96,7 +92,7 @@ impl Dispatch<WlShm, ()> for State {
proxy: &WlShm, proxy: &WlShm,
event: <WlShm as wayland_client::Proxy>::Event, event: <WlShm as wayland_client::Proxy>::Event,
data: &(), data: &(),
conn: &Connection, _conn: &Connection,
qhandle: &wayland_client::QueueHandle<Self>, qhandle: &wayland_client::QueueHandle<Self>,
) { ) {
if let <WlShm as Proxy>::Event::Format { format } = event { if let <WlShm as Proxy>::Event::Format { format } = event {
@@ -135,10 +131,10 @@ impl Dispatch<WlShm, ()> for State {
BorrowedFd::borrow_raw(fildes) BorrowedFd::borrow_raw(fildes)
}; };
let mut shm_file = File::from(shm_fd.try_clone_to_owned().unwrap()); // Converts borrowed let shm_file = File::from(shm_fd.try_clone_to_owned().unwrap()); // Converts borrowed
// to owned. Are there problems with this? // to owned. Are there problems with this?
let mut mmap = unsafe { let mmap = unsafe {
// SAFETY: This effectively creates a memory map from a raw // SAFETY: This effectively creates a memory map from a raw
// pointer. As above, as long as the compositor does not // pointer. As above, as long as the compositor does not
// mutate the underlying shared memory pool, mutations // mutate the underlying shared memory pool, mutations
@@ -163,12 +159,12 @@ impl Dispatch<WlShm, ()> for State {
impl Dispatch<WlBuffer, ()> for State { impl Dispatch<WlBuffer, ()> for State {
fn event( fn event(
state: &mut Self, _state: &mut Self,
proxy: &WlBuffer, _proxy: &WlBuffer,
event: <WlBuffer as Proxy>::Event, _event: <WlBuffer as Proxy>::Event,
data: &(), _data: &(),
conn: &Connection, _conn: &Connection,
qhandle: &wayland_client::QueueHandle<Self>, _qhandle: &wayland_client::QueueHandle<Self>,
) { ) {
} }
} }
@@ -176,11 +172,11 @@ impl Dispatch<WlBuffer, ()> for State {
impl Dispatch<XdgWmBase, ()> for State { impl Dispatch<XdgWmBase, ()> for State {
fn event( fn event(
state: &mut Self, state: &mut Self,
proxy: &XdgWmBase, _proxy: &XdgWmBase,
event: <XdgWmBase as Proxy>::Event, event: <XdgWmBase as Proxy>::Event,
data: &(), _data: &(),
conn: &Connection, _conn: &Connection,
qhandle: &wayland_client::QueueHandle<Self>, _qhandle: &wayland_client::QueueHandle<Self>,
) { ) {
if let xdg_wm_base::Event::Ping { serial } = event { if let xdg_wm_base::Event::Ping { serial } = event {
state.wm_base.as_ref().unwrap().pong(serial); // Ok to unwrap as a ping won't be recieved until state.wm_base.as_ref().unwrap().pong(serial); // Ok to unwrap as a ping won't be recieved until
@@ -194,12 +190,12 @@ impl Dispatch<XdgWmBase, ()> for State {
impl Dispatch<XdgSurface, ()> for State { impl Dispatch<XdgSurface, ()> for State {
fn event( fn event(
state: &mut Self, _state: &mut Self,
proxy: &XdgSurface, proxy: &XdgSurface,
event: <XdgSurface as Proxy>::Event, event: <XdgSurface as Proxy>::Event,
data: &(), _data: &(),
conn: &Connection, _conn: &Connection,
qhandle: &wayland_client::QueueHandle<Self>, _qhandle: &wayland_client::QueueHandle<Self>,
) { ) {
if let <XdgSurface as Proxy>::Event::Configure { serial } = event { if let <XdgSurface as Proxy>::Event::Configure { serial } = event {
proxy.ack_configure(serial); proxy.ack_configure(serial);
@@ -209,17 +205,17 @@ impl Dispatch<XdgSurface, ()> for State {
impl Dispatch<XdgToplevel, ()> for State { impl Dispatch<XdgToplevel, ()> for State {
fn event( fn event(
state: &mut Self, _state: &mut Self,
proxy: &XdgToplevel, _proxy: &XdgToplevel,
event: <XdgToplevel as Proxy>::Event, event: <XdgToplevel as Proxy>::Event,
data: &(), _data: &(),
conn: &Connection, _conn: &Connection,
qhandle: &wayland_client::QueueHandle<Self>, _qhandle: &wayland_client::QueueHandle<Self>,
) { ) {
if let <XdgToplevel as Proxy>::Event::Configure { if let <XdgToplevel as Proxy>::Event::Configure {
width, width: _,
height, height: _,
states, states: _,
} = event } = event
{ {
// state.xdg_surface.unwrap().ack_configure(serial); // state.xdg_surface.unwrap().ack_configure(serial);
@@ -231,12 +227,12 @@ impl Dispatch<XdgToplevel, ()> for State {
impl Dispatch<WlSurface, ()> for State { impl Dispatch<WlSurface, ()> for State {
fn event( fn event(
state: &mut Self, _state: &mut Self,
proxy: &WlSurface, _proxy: &WlSurface,
event: <WlSurface as Proxy>::Event, _event: <WlSurface as Proxy>::Event,
data: &(), _data: &(),
conn: &Connection, _conn: &Connection,
qhandle: &wayland_client::QueueHandle<Self>, _qhandle: &wayland_client::QueueHandle<Self>,
) { ) {
} }
} }
@@ -305,7 +301,7 @@ fn main() {
// FIX: 3 channels won't work, even with Xrgb8888 for some reason // FIX: 3 channels won't work, even with Xrgb8888 for some reason
// TODO: Update for more channels // TODO: Update for more channels
let size: i32 = (WIDTH * HEIGHT * channel_count * 2).try_into().unwrap(); let _size: i32 = (WIDTH * HEIGHT * channel_count * 2).try_into().unwrap();
let buffer = shm_pool.create_buffer( let buffer = shm_pool.create_buffer(
0, 0,