From 0708b5a8484f49925b875d55ea249bdf105810eb Mon Sep 17 00:00:00 2001 From: Ashley Wulber Date: Wed, 16 Oct 2024 15:20:36 -0400 Subject: [PATCH] cleanup --- core/src/overlay.rs | 1 - runtime/src/dnd.rs | 4 +--- runtime/src/lib.rs | 4 ++-- runtime/src/platform_specific/mod.rs | 5 ++--- runtime/src/program/state.rs | 3 --- runtime/src/user_interface.rs | 1 - src/application.rs | 8 ++++---- src/daemon.rs | 12 ++++++------ src/error.rs | 8 ++------ src/lib.rs | 13 ------------- src/program.rs | 22 +++++++++++----------- 11 files changed, 28 insertions(+), 53 deletions(-) diff --git a/core/src/overlay.rs b/core/src/overlay.rs index 1cb98f8982..d0afe18ed6 100644 --- a/core/src/overlay.rs +++ b/core/src/overlay.rs @@ -9,7 +9,6 @@ use crate::event::{self, Event}; use crate::layout; use crate::mouse; use crate::renderer; -use crate::widget::Operation; use crate::widget::Tree; use crate::{Clipboard, Layout, Point, Rectangle, Shell, Size, Vector}; diff --git a/runtime/src/dnd.rs b/runtime/src/dnd.rs index 2fd3924499..0461becea8 100644 --- a/runtime/src/dnd.rs +++ b/runtime/src/dnd.rs @@ -2,10 +2,8 @@ use std::any::Any; -use bytes::buf::Take; use dnd::{DndDestinationRectangle, DndSurface}; -use iced_core::{clipboard::DndSource, Vector}; -use iced_futures::MaybeSend; +use iced_core::clipboard::DndSource; use window_clipboard::mime::{AllowedMimeTypes, AsMimeTypes}; use crate::{oneshot, task, Action, Task}; diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 8516561f90..fd6eb6d0b3 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -43,7 +43,6 @@ pub use user_interface::UserInterface; use crate::core::widget; use crate::futures::futures::channel::oneshot; -use dnd::DndAction; use std::borrow::Cow; use std::fmt; @@ -78,6 +77,7 @@ pub enum Action { /// This will normally close any application windows and /// terminate the runtime loop. Exit, + /// Run a Dnd action. Dnd(crate::dnd::DndAction), @@ -130,7 +130,7 @@ where Action::PlatformSpecific(action) => { write!(f, "Action::PlatformSpecific({:?})", action) } - Action::Dnd(action) => write!(f, "Action::Dnd"), + Action::Dnd(_) => write!(f, "Action::Dnd"), } } } diff --git a/runtime/src/platform_specific/mod.rs b/runtime/src/platform_specific/mod.rs index a8f761b75a..572288b3cb 100644 --- a/runtime/src/platform_specific/mod.rs +++ b/runtime/src/platform_specific/mod.rs @@ -1,8 +1,6 @@ //! Platform specific actions defined for wayland -use std::{fmt, marker::PhantomData}; - -use iced_futures::MaybeSend; +use std::fmt; #[cfg(feature = "wayland")] /// Platform specific actions defined for wayland @@ -20,6 +18,7 @@ impl fmt::Debug for Action { match self { #[cfg(feature = "wayland")] Action::Wayland(action) => action.fmt(_f), + #[cfg(not(feature = "wayland"))] _ => Ok(()), } } diff --git a/runtime/src/program/state.rs b/runtime/src/program/state.rs index c0befaa2b0..1eb2d770c7 100644 --- a/runtime/src/program/state.rs +++ b/runtime/src/program/state.rs @@ -1,5 +1,3 @@ -use iced_core::widget::operation::Outcome; - use crate::core::event::{self, Event}; use crate::core::mouse; use crate::core::renderer; @@ -211,7 +209,6 @@ where operation::Outcome::Chain(next) => { current_operation = Some(next); } - _ => {} }; } } diff --git a/runtime/src/user_interface.rs b/runtime/src/user_interface.rs index f6184d144c..15b12b3c74 100644 --- a/runtime/src/user_interface.rs +++ b/runtime/src/user_interface.rs @@ -2,7 +2,6 @@ use iced_core::clipboard::DndDestinationRectangles; use iced_core::widget::tree::NAMED; -use iced_core::widget::Operation; use crate::core::event::{self, Event}; use crate::core::layout; diff --git a/src/application.rs b/src/application.rs index acd38062b3..17070afb02 100644 --- a/src/application.rs +++ b/src/application.rs @@ -154,7 +154,7 @@ pub struct Application { } impl Application

{ - #[cfg(any(feature = "winit", feature = "wayland"))] + #[cfg(feature = "winit")] /// Runs the [`Application`]. /// /// The state of the [`Application`] must implement [`Default`]. @@ -162,7 +162,7 @@ impl Application

{ /// instead. /// /// [`run_with`]: Self::run_with - pub fn run(self) -> Result + pub fn run(self) -> crate::Result where Self: 'static, P::State: Default, @@ -170,9 +170,9 @@ impl Application

{ self.raw.run(self.settings, Some(self.window)) } - #[cfg(any(feature = "winit", feature = "wayland"))] + #[cfg(feature = "winit")] /// Runs the [`Application`] with a closure that creates the initial state. - pub fn run_with(self, initialize: I) -> Result + pub fn run_with(self, initialize: I) -> crate::Result where Self: 'static, I: FnOnce() -> (P::State, Task) + 'static, diff --git a/src/daemon.rs b/src/daemon.rs index 689b5222a4..b672ca13cb 100644 --- a/src/daemon.rs +++ b/src/daemon.rs @@ -1,12 +1,12 @@ //! Create and run daemons that run in the background. use crate::application; use crate::program::{self, Program}; -#[cfg(any(feature = "winit", feature = "wayland"))] +#[cfg(feature = "winit")] pub use crate::shell::program::{Appearance, DefaultStyle}; use crate::window; use crate::{Element, Executor, Font, Result, Settings, Subscription, Task}; -#[cfg(not(any(feature = "winit", feature = "wayland")))] +#[cfg(not(feature = "winit"))] use crate::runtime::{Appearance, DefaultStyle}; use std::borrow::Cow; @@ -103,7 +103,7 @@ pub struct Daemon { } impl Daemon

{ - #[cfg(any(feature = "winit", feature = "wayland"))] + #[cfg(feature = "winit")] /// Runs the [`Daemon`]. /// /// The state of the [`Daemon`] must implement [`Default`]. @@ -111,7 +111,7 @@ impl Daemon

{ /// instead. /// /// [`run_with`]: Self::run_with - pub fn run(self) -> Result + pub fn run(self) -> crate::Result where Self: 'static, P::State: Default, @@ -119,9 +119,9 @@ impl Daemon

{ self.raw.run(self.settings, None) } - #[cfg(any(feature = "winit", feature = "wayland"))] + #[cfg(feature = "winit")] /// Runs the [`Daemon`] with a closure that creates the initial state. - pub fn run_with(self, initialize: I) -> Result + pub fn run_with(self, initialize: I) -> crate::Result where Self: 'static, I: FnOnce() -> (P::State, Task) + 'static, diff --git a/src/error.rs b/src/error.rs index 3285592f85..5f78a8f5ac 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,6 +1,6 @@ use crate::futures; use crate::graphics; -#[cfg(any(feature = "winit", feature = "wayland"))] +#[cfg(feature = "winit")] use crate::shell; /// An error that occurred while running an application. @@ -19,7 +19,7 @@ pub enum Error { GraphicsCreationFailed(graphics::Error), } -#[cfg(any(feature = "winit", feature = "wayland"))] +#[cfg(feature = "winit")] impl From for Error { fn from(error: shell::Error) -> Error { match error { @@ -30,10 +30,6 @@ impl From for Error { shell::Error::WindowCreationFailed(error) => { Error::WindowCreationFailed(Box::new(error)) } - #[cfg(feature = "wayland")] - shell::Error::WindowCreationFailed(error) => { - Error::WindowCreationFailed(Box::new(error)) - } shell::Error::GraphicsCreationFailed(error) => { Error::GraphicsCreationFailed(error) } diff --git a/src/lib.rs b/src/lib.rs index bdd4154265..9642cf11b1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -512,19 +512,6 @@ pub use application::Application; #[cfg(feature = "winit")] pub use program::Program; -// wayland application -// #[cfg(feature = "wayland")] -// pub mod wayland; -// #[cfg(feature = "wayland")] -// pub use wayland::application; -// #[cfg(feature = "wayland")] -// pub use wayland::application::Application; -// #[cfg(feature = "wayland")] -// pub use wayland::program; -// #[doc(inline)] -// #[cfg(feature = "wayland")] -// pub use wayland::program::Program; - #[cfg(feature = "advanced")] pub mod advanced; diff --git a/src/program.rs b/src/program.rs index bac6ddfc39..f005771b86 100644 --- a/src/program.rs +++ b/src/program.rs @@ -1,13 +1,13 @@ use crate::core::text; use crate::graphics::compositor; -#[cfg(any(feature = "winit", feature = "wayland"))] +#[cfg(feature = "winit")] use crate::shell; -#[cfg(any(feature = "winit", feature = "wayland"))] +#[cfg(feature = "winit")] pub use crate::shell::program::{Appearance, DefaultStyle}; use crate::window; -use crate::{Element, Executor, Result, Settings, Subscription, Task}; +use crate::{Element, Executor, Subscription, Task}; -#[cfg(not(any(feature = "winit", feature = "wayland")))] +#[cfg(not(feature = "winit"))] pub use crate::runtime::{Appearance, DefaultStyle}; /// The internal definition of a [`Program`]. @@ -66,7 +66,7 @@ pub trait Program: Sized { 1.0 } - #[cfg(any(feature = "winit", feature = "wayland"))] + #[cfg(feature = "winit")] /// Runs the [`Program`]. /// /// The state of the [`Program`] must implement [`Default`]. @@ -76,9 +76,9 @@ pub trait Program: Sized { /// [`run_with`]: Self::run_with fn run( self, - settings: Settings, + settings: crate::Settings, window_settings: Option, - ) -> Result + ) -> crate::Result where Self: 'static, Self::State: Default, @@ -88,14 +88,14 @@ pub trait Program: Sized { }) } - #[cfg(any(feature = "winit", feature = "wayland"))] + #[cfg(feature = "winit")] /// Runs the [`Program`] with the given [`Settings`] and a closure that creates the initial state. fn run_with( self, - settings: Settings, + settings: crate::Settings, window_settings: Option, initialize: I, - ) -> Result + ) -> crate::Result where Self: 'static, I: FnOnce() -> (Self::State, Task) + 'static, @@ -184,7 +184,7 @@ pub trait Program: Sized { Instance, ::Compositor, >( - Settings { + crate::Settings { id: settings.id, fonts: settings.fonts, default_font: settings.default_font,