Clippy fixes

This commit is contained in:
Ian Douglas Scott 2023-02-09 14:29:34 -08:00
parent 8c690e9648
commit a5b78a4300
4 changed files with 38 additions and 35 deletions

View file

@ -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<Msg> {
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<Msg> {
// capture of window
// - selectable
// name of window

View file

@ -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<Event> {
@ -36,7 +36,7 @@ async fn start_listening(state: State) -> (Option<Event>, 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 {

View file

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

View file

@ -93,6 +93,7 @@ enum CaptureSource {
),
}
#[allow(clippy::derive_hash_xor_eq)]
impl std::hash::Hash for CaptureSource {
fn hash<H>(&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<Self>,
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<Self>,
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<Self>,
_conn: &Connection,
_qh: &QueueHandle<Self>,
session: &zcosmic_screencopy_session_v1::ZcosmicScreencopySessionV1,
) {
let capture = &session.data::<SessionData>().unwrap().capture;
@ -451,10 +452,10 @@ impl ScreencopyHandler for AppData {
fn failed(
&mut self,
conn: &Connection,
qh: &QueueHandle<Self>,
_conn: &Connection,
_qh: &QueueHandle<Self>,
session: &zcosmic_screencopy_session_v1::ZcosmicScreencopySessionV1,
reason: WEnum<zcosmic_screencopy_session_v1::FailureReason>,
_reason: WEnum<zcosmic_screencopy_session_v1::FailureReason>,
) {
// TODO
println!("Failed");
@ -469,9 +470,9 @@ impl ToplevelManagerHandler for AppData {
fn capabilities(
&mut self,
conn: &Connection,
qh: &QueueHandle<Self>,
capabilities: Vec<
_conn: &Connection,
_qh: &QueueHandle<Self>,
_capabilities: Vec<
WEnum<zcosmic_toplevel_manager_v1::ZcosmicToplelevelManagementCapabilitiesV1>,
>,
) {
@ -481,7 +482,7 @@ impl ToplevelManagerHandler for AppData {
impl Dispatch<wl_buffer::WlBuffer, ()> 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<Event> {
// 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);