From 71060011797104aabb91363dd1eb143a29673ed3 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Tue, 5 Mar 2024 12:25:20 -0800 Subject: [PATCH] Address various warnings --- src/desktop_info.rs | 1 + src/main.rs | 24 +++++++++++------------- src/view/mod.rs | 4 ++-- src/wayland/buffer.rs | 12 +++--------- src/wayland/mod.rs | 9 +++++---- src/wayland/screencopy.rs | 2 +- src/widgets/toplevels.rs | 3 +-- 7 files changed, 24 insertions(+), 31 deletions(-) diff --git a/src/desktop_info.rs b/src/desktop_info.rs index f5971ba..02add6f 100644 --- a/src/desktop_info.rs +++ b/src/desktop_info.rs @@ -14,6 +14,7 @@ pub fn icon_for_app_id(app_id: String) -> Option { ) } +#[allow(dead_code)] #[derive(Debug, Clone, Default)] struct DesktopInfo { id: String, diff --git a/src/main.rs b/src/main.rs index d36d454..8ac872e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,7 +40,6 @@ use cosmic::{ iced_sctk::commands::layer_surface::{destroy_layer_surface, get_layer_surface}, }; use cosmic_comp_config::CosmicCompConfig; -use cosmic_config::ConfigSet; use cosmic_config::{cosmic_config_derive::CosmicConfigEntry, CosmicConfigEntry}; use i18n_embed::DesktopLanguageRequester; use once_cell::sync::Lazy; @@ -117,6 +116,7 @@ enum Msg { Close, Closed(SurfaceId), ActivateWorkspace(zcosmic_workspace_handle_v1::ZcosmicWorkspaceHandleV1), + #[allow(dead_code)] CloseWorkspace(zcosmic_workspace_handle_v1::ZcosmicWorkspaceHandleV1), ActivateToplevel(zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1), CloseToplevel(zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1), @@ -132,6 +132,7 @@ enum Msg { DndWorkspaceDrop, DndWorkspaceData(String, Vec), SourceFinished, + #[allow(dead_code)] NewWorkspace, CompConfig(CosmicCompConfig), Config(CosmicWorkspacesConfig), @@ -555,7 +556,7 @@ impl Application for App { ); } } - Msg::DndWorkspaceEnter(handle, output, action, mimes, (_x, _y)) => { + Msg::DndWorkspaceEnter(handle, output, _action, mimes, (_x, _y)) => { self.drop_target = Some((handle, output)); // XXX // if mimes.iter().any(|x| x == WORKSPACE_MIME) && action == DndAction::Move { @@ -581,17 +582,14 @@ impl Application for App { .ok() .and_then(|s| u32::from_str(s).ok()); if let Some((_, DragSurface::Toplevel { handle, .. }, _)) = &self.drag_surface { - if let Some(toplevel) = self.toplevels.iter().find(|t| &t.handle == handle) - { - if let Some(drop_target) = &self.drop_target { - if let Some(toplevel_manager) = self.toplevel_manager.as_ref() { - if toplevel_manager.version() >= 2 { - toplevel_manager.move_to_workspace( - handle, - &drop_target.0, - &drop_target.1, - ); - } + if let Some(drop_target) = &self.drop_target { + if let Some(toplevel_manager) = self.toplevel_manager.as_ref() { + if toplevel_manager.version() >= 2 { + toplevel_manager.move_to_workspace( + handle, + &drop_target.0, + &drop_target.1, + ); } } } diff --git a/src/view/mod.rs b/src/view/mod.rs index 919a7eb..59548e7 100644 --- a/src/view/mod.rs +++ b/src/view/mod.rs @@ -102,7 +102,7 @@ pub(crate) fn workspace_item<'a>( fn workspace_sidebar_entry<'a>( workspace: &'a Workspace, output: &'a wl_output::WlOutput, - is_drop_target: bool, + _is_drop_target: bool, ) -> cosmic::Element<'a, Msg> { /* XXX let mouse_interaction = if is_drop_target { @@ -154,6 +154,7 @@ fn workspaces_sidebar<'a>( }; let sidebar_entries_container = widget::container(crate::widgets::workspace_bar(sidebar_entries, axis)).padding(12.0); + /* let new_workspace_button = widget::button( widget::container(row![ widget::icon::from_name("list-add-symbolic").symbolic(true), @@ -164,7 +165,6 @@ fn workspaces_sidebar<'a>( ) .on_press(Msg::NewWorkspace) .width(iced::Length::Fill); - /* let bar: cosmic::Element<_> = if amount != WorkspaceAmount::Dynamic { match layout { WorkspaceLayout::Vertical => { diff --git a/src/wayland/buffer.rs b/src/wayland/buffer.rs index 3f05aac..842f6e7 100644 --- a/src/wayland/buffer.rs +++ b/src/wayland/buffer.rs @@ -7,9 +7,7 @@ use cctk::{ }, }; use cosmic::cctk; -use cosmic::iced::widget::image; -use cosmic::iced_sctk::subsurface_widget::{BufferSource, Dmabuf, Plane, Shmbuf, SubsurfaceBuffer}; -use memmap2::Mmap; +use cosmic::iced_sctk::subsurface_widget::{BufferSource, Dmabuf, Plane, Shmbuf}; use rustix::{io::Errno, shm::ShmOFlags}; use std::{ os::fd::{AsFd, OwnedFd}, @@ -58,6 +56,7 @@ fn create_memfile() -> rustix::io::Result { return Err(errno.into()); } }, + #[allow(unreachable_patterns)] Err(Errno::EXIST | Errno::EXIST) => { continue; } @@ -66,11 +65,6 @@ fn create_memfile() -> rustix::io::Result { } } -enum BufferBacking { - Shm { fd: OwnedFd }, - Dmabuf { fd: OwnedFd, stride: u32 }, -} - pub struct Buffer { pub backing: Arc, pub buffer: wl_buffer::WlBuffer, @@ -81,7 +75,7 @@ pub struct Buffer { impl AppData { fn create_shm_buffer(&self, buffer_info: &BufferInfo) -> Buffer { let fd = create_memfile().unwrap(); // XXX? - rustix::fs::ftruncate(&fd, buffer_info.stride as u64 * buffer_info.height as u64); + rustix::fs::ftruncate(&fd, buffer_info.stride as u64 * buffer_info.height as u64).unwrap(); let pool = self.shm_state.wl_shm().create_pool( fd.as_fd(), diff --git a/src/wayland/mod.rs b/src/wayland/mod.rs index f13db79..8888702 100644 --- a/src/wayland/mod.rs +++ b/src/wayland/mod.rs @@ -20,7 +20,7 @@ use cctk::{ toplevel_management::ToplevelManagerState, wayland_client::{ globals::registry_queue_init, - protocol::{wl_buffer, wl_output, wl_seat}, + protocol::{wl_output, wl_seat}, Connection, QueueHandle, }, workspace::WorkspaceState, @@ -99,7 +99,6 @@ pub enum Cmd { } pub struct AppData { - conn: Connection, qh: QueueHandle, dmabuf_state: DmabufState, registry_state: RegistryState, @@ -244,7 +243,6 @@ fn start(conn: Connection) -> mpsc::Receiver { let registry_state = RegistryState::new(&globals); let mut app_data = AppData { - conn: conn.clone(), qh: qh.clone(), dmabuf_state, workspace_state: WorkspaceState::new(®istry_state, &qh), // Create before toplevel info state @@ -286,7 +284,10 @@ fn start(conn: Connection) -> mpsc::Receiver { } }) .unwrap(); - event_loop.handle().insert_source(executor, |(), _, _| {}); + event_loop + .handle() + .insert_source(executor, |(), _, _| {}) + .unwrap(); loop { event_loop.dispatch(None, &mut app_data).unwrap(); diff --git a/src/wayland/screencopy.rs b/src/wayland/screencopy.rs index 4bc3ed6..e278742 100644 --- a/src/wayland/screencopy.rs +++ b/src/wayland/screencopy.rs @@ -62,7 +62,7 @@ impl ScreencopySession { } } - fn attach_buffer_and_commit(&mut self, capture: &Capture, conn: &Connection) { + fn attach_buffer_and_commit(&mut self, _capture: &Capture, conn: &Connection) { let Some(back) = self.buffers.as_ref().map(|x| &x[1]) else { return; }; diff --git a/src/widgets/toplevels.rs b/src/widgets/toplevels.rs index b4e6b10..87958e5 100644 --- a/src/widgets/toplevels.rs +++ b/src/widgets/toplevels.rs @@ -80,7 +80,7 @@ impl<'a, Msg> Widget for Toplevels<'a, Msg .zip(tree.children.iter_mut()) .map(|(child, tree)| { let child_limits = layout::Limits::new(Size::ZERO, limits.max()); - let mut layout = child.as_widget().layout(tree, renderer, &child_limits); + let layout = child.as_widget().layout(tree, renderer, &child_limits); self.axis.main(layout.size()) }) .collect::>(); @@ -122,7 +122,6 @@ impl<'a, Msg> Widget for Toplevels<'a, Msg let (total_width, total_height) = self.axis.pack(total_main, max_cross); let size = Size::new(total_width, total_height); - limits; layout::Node::with_children(size, nodes) }