diff --git a/src/main.rs b/src/main.rs index e38fa09..b63f9d9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,14 +1,16 @@ +#![allow(clippy::single_match)] + use cctk::{ cosmic_protocols::{ toplevel_info::v1::client::zcosmic_toplevel_handle_v1, toplevel_management::v1::client::zcosmic_toplevel_manager_v1, workspace::v1::client::{zcosmic_workspace_handle_v1, zcosmic_workspace_manager_v1}, }, - sctk::shell::layer::{Anchor, KeyboardInteractivity, Layer}, + sctk::shell::layer::{KeyboardInteractivity, Layer}, toplevel_info::ToplevelInfo, wayland_client::{ protocol::{wl_output, wl_seat}, - Connection, QueueHandle, WEnum, + Connection, WEnum, }, }; use cosmic::{ @@ -16,7 +18,7 @@ use cosmic::{ self, event::wayland::{Event as WaylandEvent, OutputEvent}, keyboard::KeyCode, - widget, Application, Command, Element, Subscription, + widget, Application, Command, Subscription, }, iced_native::{ command::platform_specific::wayland::layer_surface::{ @@ -30,7 +32,7 @@ use cosmic::{ settings::InitialSurface, }, }; -use std::{collections::HashMap, mem, process}; +use std::{collections::HashMap, mem}; mod toggle_dbus; mod wayland; @@ -132,7 +134,7 @@ impl App { ) -> Command { let id = self.next_surface_id(); self.layer_surfaces.insert( - id.clone(), + id, LayerSurface { output: output.clone(), output_name, @@ -242,8 +244,7 @@ impl Application for App { } OutputEvent::Created(None) => {} // XXX? OutputEvent::InfoUpdate(info) => { - if let Some(output) = self.outputs.iter_mut().find(|x| &x.handle == &output) - { + if let Some(output) = self.outputs.iter_mut().find(|x| x.handle == output) { if let Some((width, height)) = info.logical_size { output.width = width; output.height = height; @@ -253,7 +254,7 @@ impl Application for App { } } OutputEvent::Removed => { - if let Some(idx) = self.outputs.iter().position(|x| &x.handle == &output) { + if let Some(idx) = self.outputs.iter().position(|x| x.handle == output) { self.outputs.remove(idx); } if self.visible { @@ -288,7 +289,7 @@ impl Application for App { // XXX efficiency let img = old_workspaces .iter() - .find(|i| &i.handle == &workspace.handle) + .find(|i| i.handle == workspace.handle) .and_then(|i| i.img.clone()); self.workspaces.push(Workspace { @@ -301,7 +302,7 @@ impl Application for App { } } wayland::Event::NewToplevel(handle, info) => { - println!("New toplevel: {:?}", info); + println!("New toplevel: {info:?}"); self.toplevels.push(Toplevel { handle, info, @@ -315,13 +316,13 @@ impl Application for App { } wayland::Event::WorkspaceCapture(handle, image) => { if let Some(workspace) = self.workspace_for_handle_mut(&handle) { - workspace.img = Some(image.clone()); + workspace.img = Some(image); } } wayland::Event::ToplevelCapture(handle, image) => { if let Some(toplevel) = self.toplevel_for_handle_mut(&handle) { println!("Got toplevel image!"); - toplevel.img = Some(image.clone()); + toplevel.img = Some(image); } } wayland::Event::Seats(seats) => { @@ -337,20 +338,20 @@ impl Application for App { let workspace_manager = self.workspace_manager.as_ref().unwrap(); workspace_handle.activate(); workspace_manager.commit(); - self.conn.as_ref().unwrap().flush(); + let _ = self.conn.as_ref().unwrap().flush(); } Msg::ActivateToplevel(toplevel_handle) => { if let Some(toplevel_manager) = self.toplevel_manager.as_ref() { if !self.seats.is_empty() { for seat in &self.seats { - toplevel_manager.activate(&toplevel_handle, &seat); - self.conn.as_ref().unwrap().flush(); + toplevel_manager.activate(&toplevel_handle, seat); } + let _ = self.conn.as_ref().unwrap().flush(); return self.hide(); } } } - Msg::CloseWorkspace(workspace_handle) => {} + Msg::CloseWorkspace(_workspace_handle) => {} Msg::CloseToplevel(toplevel_handle) => { // TODO confirmation? if let Some(toplevel_manager) = self.toplevel_manager.as_ref() { @@ -407,7 +408,7 @@ fn layer_surface<'a>(app: &'a App, surface: &'a LayerSurface) -> cosmic::Element workspaces_sidebar( app.workspaces .iter() - .filter(|i| &i.output_name == &surface.output_name), + .filter(|i| i.output_name == surface.output_name), ), toplevel_previews(app.toplevels.iter().filter(|i| { if let Some(workspace) = &i.info.workspace { @@ -461,7 +462,7 @@ fn workspaces_sidebar<'a>( // New workspace } -fn toplevel_preview<'a>(toplevel: &'a Toplevel) -> cosmic::Element<'a, Msg> { +fn toplevel_preview(toplevel: &Toplevel) -> cosmic::Element { // capture of window // - selectable // name of window diff --git a/src/toggle_dbus.rs b/src/toggle_dbus.rs index 6b97bac..94a87cf 100644 --- a/src/toggle_dbus.rs +++ b/src/toggle_dbus.rs @@ -1,6 +1,6 @@ use cosmic::iced::{self, futures::StreamExt, subscription}; use futures_channel::mpsc; -use std::{fmt::Debug, hash::Hash}; +use std::fmt::Debug; use zbus::{dbus_interface, Connection, ConnectionBuilder}; pub fn subscription() -> iced::Subscription { @@ -36,7 +36,7 @@ async fn start_listening(state: State) -> (Option, State) { return (None, State::Waiting(conn, rx)); } } - return (None, State::Finished); + (None, State::Finished) } State::Waiting(conn, mut rx) => { if let Some(Event::Toggle) = rx.next().await { diff --git a/src/wayland/buffer.rs b/src/wayland/buffer.rs index df566e4..93bbe0e 100644 --- a/src/wayland/buffer.rs +++ b/src/wayland/buffer.rs @@ -41,6 +41,7 @@ impl Buffer { } // Buffer must be released by server for safety + #[allow(clippy::wrong_self_convention)] pub unsafe fn to_image(&mut self) -> image::Handle { // XXX is this at all a performance issue? image::Handle::from_pixels( diff --git a/src/wayland/mod.rs b/src/wayland/mod.rs index 6c19cf6..ea37771 100644 --- a/src/wayland/mod.rs +++ b/src/wayland/mod.rs @@ -93,6 +93,7 @@ enum CaptureSource { ), } +#[allow(clippy::derive_hash_xor_eq)] impl std::hash::Hash for CaptureSource { fn hash(&self, state: &mut H) where @@ -100,7 +101,7 @@ impl std::hash::Hash for CaptureSource { { match self { Self::Toplevel(handle) => handle.id(), - Self::Workspace(handle, output) => handle.id(), + Self::Workspace(handle, _output) => handle.id(), } .hash(state) } @@ -152,7 +153,7 @@ impl Capture { manager.capture_toplevel( toplevel, zcosmic_screencopy_manager_v1::CursorMode::Hidden, - &qh, + qh, udata, ); } @@ -161,7 +162,7 @@ impl Capture { workspace, output, zcosmic_screencopy_manager_v1::CursorMode::Hidden, - &qh, + qh, udata, ); } @@ -319,7 +320,7 @@ impl ToplevelInfoHandler for AppData { _qh: &QueueHandle, toplevel: &zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1, ) { - let info = self.toplevel_info_state.info(&toplevel).unwrap(); + let info = self.toplevel_info_state.info(toplevel).unwrap(); self.send_event(Event::NewToplevel(toplevel.clone(), info.clone())); self.add_capture_source(CaptureSource::Toplevel(toplevel.clone())); @@ -329,7 +330,7 @@ impl ToplevelInfoHandler for AppData { &mut self, _conn: &Connection, _qh: &QueueHandle, - toplevel: &zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1, + _toplevel: &zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1, ) { // TODO } @@ -423,8 +424,8 @@ impl ScreencopyHandler for AppData { fn ready( &mut self, - conn: &Connection, - qh: &QueueHandle, + _conn: &Connection, + _qh: &QueueHandle, session: &zcosmic_screencopy_session_v1::ZcosmicScreencopySessionV1, ) { let capture = &session.data::().unwrap().capture; @@ -451,10 +452,10 @@ impl ScreencopyHandler for AppData { fn failed( &mut self, - conn: &Connection, - qh: &QueueHandle, + _conn: &Connection, + _qh: &QueueHandle, session: &zcosmic_screencopy_session_v1::ZcosmicScreencopySessionV1, - reason: WEnum, + _reason: WEnum, ) { // TODO println!("Failed"); @@ -469,9 +470,9 @@ impl ToplevelManagerHandler for AppData { fn capabilities( &mut self, - conn: &Connection, - qh: &QueueHandle, - capabilities: Vec< + _conn: &Connection, + _qh: &QueueHandle, + _capabilities: Vec< WEnum, >, ) { @@ -481,7 +482,7 @@ impl ToplevelManagerHandler for AppData { impl Dispatch for AppData { fn event( _app_data: &mut Self, - buffer: &wl_buffer::WlBuffer, + _buffer: &wl_buffer::WlBuffer, event: wl_buffer::Event, _: &(), _: &Connection, @@ -499,7 +500,7 @@ fn start() -> mpsc::Receiver { // TODO share connection? Can't use same `WlOutput` with seperate connection let conn = Connection::connect_to_env().unwrap(); - let (globals, mut event_queue) = registry_queue_init(&conn).unwrap(); + let (globals, event_queue) = registry_queue_init(&conn).unwrap(); let qh = event_queue.handle(); let registry_state = RegistryState::new(&globals);