From 28a882852daa1a22e5d694d5ce4a93255ce978ef Mon Sep 17 00:00:00 2001 From: Janis Date: Wed, 27 Nov 2024 01:26:03 +0100 Subject: [PATCH] cleanup warnings --- src/main.rs | 63 +++++++++++++++++++---------------------------------- 1 file changed, 22 insertions(+), 41 deletions(-) diff --git a/src/main.rs b/src/main.rs index 25b670b..df53762 100644 --- a/src/main.rs +++ b/src/main.rs @@ -36,13 +36,6 @@ struct BufferInfo { stride: u32, } -#[derive(Debug, PartialEq, Eq)] -enum FrameState { - Pre, - BufferDone, - Copied, -} - #[derive(Debug)] enum FrameData { Pre(Vec), @@ -53,25 +46,15 @@ enum FrameData { offset: usize, }, Copied { - buffer: WlBuffer, info: BufferInfo, offset: usize, }, Done, } -impl FrameData { - fn select_buffer(&mut self) { - if let Self::Pre(infos) = self { - *self = Self::Buffer(infos.pop().unwrap()); - } - } -} - #[derive(Debug)] struct Frame { frame: ZwlrScreencopyFrameV1, - buffer_infos: Vec, inverted_y: bool, data: FrameData, } @@ -79,6 +62,8 @@ struct Frame { #[derive(Debug)] struct Output { output: WlOutput, + // this isn't actually unused since we need to keep it around for the dispatcher + #[allow(unused)] xdg_output: ZxdgOutputV1, logical_size: Option<(i32, i32)>, physical_size: Option<(i32, i32)>, @@ -120,7 +105,6 @@ impl Output { frame: Frame { frame, inverted_y: false, - buffer_infos: Vec::new(), data: FrameData::Pre(vec![]), }, } @@ -151,7 +135,7 @@ impl Dispatch for App { impl Dispatch for App { fn event( state: &mut Self, - proxy: &ZwlrScreencopyFrameV1, + _proxy: &ZwlrScreencopyFrameV1, event: ::Event, data: &ObjectId, _conn: &Connection, @@ -189,11 +173,8 @@ impl Dispatch for App { offset, } = core::mem::replace(&mut output.frame.data, FrameData::Done) { - output.frame.data = FrameData::Copied { - buffer, - info, - offset, - }; + buffer.destroy(); + output.frame.data = FrameData::Copied { info, offset }; } } zwlr_screencopy_frame_v1::Event::Failed => { @@ -225,12 +206,12 @@ impl Dispatch for App { impl Dispatch for App { fn event( - state: &mut Self, - proxy: &ZxdgOutputManagerV1, - event: ::Event, - data: &(), - conn: &Connection, - qhandle: &wayland_client::QueueHandle, + _state: &mut Self, + _proxy: &ZxdgOutputManagerV1, + _event: ::Event, + _data: &(), + _conn: &Connection, + _qhandle: &wayland_client::QueueHandle, ) { } } @@ -238,11 +219,11 @@ impl Dispatch for App { impl Dispatch for App { fn event( state: &mut Self, - proxy: &ZxdgOutputV1, + _proxy: &ZxdgOutputV1, event: ::Event, data: &ObjectId, - conn: &Connection, - qhandle: &wayland_client::QueueHandle, + _conn: &Connection, + _qhandle: &wayland_client::QueueHandle, ) { let Some(output) = state.outputs.get_mut(data) else { return; @@ -298,12 +279,12 @@ impl Dispatch for App { impl Dispatch for App { fn event( - state: &mut Self, - proxy: &WlShm, - event: ::Event, - data: &(), - conn: &Connection, - qhandle: &wayland_client::QueueHandle, + _state: &mut Self, + _proxy: &WlShm, + _event: ::Event, + _data: &(), + _conn: &Connection, + _qhandle: &wayland_client::QueueHandle, ) { } } @@ -312,7 +293,7 @@ impl Dispatch for App { fn event( _state: &mut Self, _proxy: &WlShmPool, - event: ::Event, + _event: ::Event, _data: &(), _conn: &Connection, _qhandle: &wayland_client::QueueHandle, @@ -324,7 +305,7 @@ impl Dispatch for App { fn event( _state: &mut Self, _proxy: &WlBuffer, - event: ::Event, + _event: ::Event, _data: &(), _conn: &Connection, _qhandle: &wayland_client::QueueHandle,