Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
wash2 committed Oct 17, 2024
1 parent 9687ea3 commit 0708b5a
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 53 deletions.
1 change: 0 additions & 1 deletion core/src/overlay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
4 changes: 1 addition & 3 deletions runtime/src/dnd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
4 changes: 2 additions & 2 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -78,6 +77,7 @@ pub enum Action<T> {
/// This will normally close any application windows and
/// terminate the runtime loop.
Exit,

/// Run a Dnd action.
Dnd(crate::dnd::DndAction),

Expand Down Expand Up @@ -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"),
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions runtime/src/platform_specific/mod.rs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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(()),
}
}
Expand Down
3 changes: 0 additions & 3 deletions runtime/src/program/state.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use iced_core::widget::operation::Outcome;

use crate::core::event::{self, Event};
use crate::core::mouse;
use crate::core::renderer;
Expand Down Expand Up @@ -211,7 +209,6 @@ where
operation::Outcome::Chain(next) => {
current_operation = Some(next);
}
_ => {}
};
}
}
Expand Down
1 change: 0 additions & 1 deletion runtime/src/user_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,25 +154,25 @@ pub struct Application<P: Program> {
}

impl<P: Program> Application<P> {
#[cfg(any(feature = "winit", feature = "wayland"))]
#[cfg(feature = "winit")]
/// Runs the [`Application`].
///
/// The state of the [`Application`] must implement [`Default`].
/// If your state does not implement [`Default`], use [`run_with`]
/// instead.
///
/// [`run_with`]: Self::run_with
pub fn run(self) -> Result
pub fn run(self) -> crate::Result
where
Self: 'static,
P::State: Default,
{
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<I>(self, initialize: I) -> Result
pub fn run_with<I>(self, initialize: I) -> crate::Result
where
Self: 'static,
I: FnOnce() -> (P::State, Task<P::Message>) + 'static,
Expand Down
12 changes: 6 additions & 6 deletions src/daemon.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -103,25 +103,25 @@ pub struct Daemon<P: Program> {
}

impl<P: Program> Daemon<P> {
#[cfg(any(feature = "winit", feature = "wayland"))]
#[cfg(feature = "winit")]
/// Runs the [`Daemon`].
///
/// The state of the [`Daemon`] must implement [`Default`].
/// If your state does not implement [`Default`], use [`run_with`]
/// instead.
///
/// [`run_with`]: Self::run_with
pub fn run(self) -> Result
pub fn run(self) -> crate::Result
where
Self: 'static,
P::State: Default,
{
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<I>(self, initialize: I) -> Result
pub fn run_with<I>(self, initialize: I) -> crate::Result
where
Self: 'static,
I: FnOnce() -> (P::State, Task<P::Message>) + 'static,
Expand Down
8 changes: 2 additions & 6 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -19,7 +19,7 @@ pub enum Error {
GraphicsCreationFailed(graphics::Error),
}

#[cfg(any(feature = "winit", feature = "wayland"))]
#[cfg(feature = "winit")]
impl From<shell::Error> for Error {
fn from(error: shell::Error) -> Error {
match error {
Expand All @@ -30,10 +30,6 @@ impl From<shell::Error> 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)
}
Expand Down
13 changes: 0 additions & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
22 changes: 11 additions & 11 deletions src/program.rs
Original file line number Diff line number Diff line change
@@ -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`].
Expand Down Expand Up @@ -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`].
Expand All @@ -76,9 +76,9 @@ pub trait Program: Sized {
/// [`run_with`]: Self::run_with
fn run(
self,
settings: Settings,
settings: crate::Settings,
window_settings: Option<window::Settings>,
) -> Result
) -> crate::Result
where
Self: 'static,
Self::State: Default,
Expand All @@ -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<I>(
self,
settings: Settings,
settings: crate::Settings,
window_settings: Option<window::Settings>,
initialize: I,
) -> Result
) -> crate::Result
where
Self: 'static,
I: FnOnce() -> (Self::State, Task<Self::Message>) + 'static,
Expand Down Expand Up @@ -184,7 +184,7 @@ pub trait Program: Sized {
Instance<Self, I>,
<Self::Renderer as compositor::Default>::Compositor,
>(
Settings {
crate::Settings {
id: settings.id,
fonts: settings.fonts,
default_font: settings.default_font,
Expand Down

0 comments on commit 0708b5a

Please sign in to comment.