diff --git a/core/src/overlay.rs b/core/src/overlay.rs index e61ae83481..b8ce136f56 100644 --- a/core/src/overlay.rs +++ b/core/src/overlay.rs @@ -35,7 +35,7 @@ where cursor: mouse::Cursor, ); - /// Applies an [`Operation`] to the [`Overlay`]. + /// Applies an [`crate::widget::Operation`] to the [`Overlay`]. fn operate( &mut self, _layout: Layout<'_>, diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 2d6ff62385..615279dbb3 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -41,7 +41,7 @@ pub use program::Program; pub use task::Task; pub use user_interface::UserInterface; -use crate::core::{Color, widget}; +use crate::core::{widget, Color}; use crate::futures::futures::channel::oneshot; use std::borrow::Cow; @@ -146,14 +146,14 @@ pub fn exit() -> Task { /// The appearance of a program. #[derive(Debug, Clone, Copy, PartialEq)] pub struct Appearance { - /// The background [`Color`] of the application. - pub background_color: Color, + /// The background [`iced_core::Color`] of the application. + pub background_color: iced_core::Color, - /// The default text [`Color`] of the application. - pub text_color: Color, + /// The default text [`iced_core::Color`] of the application. + pub text_color: iced_core::Color, - /// The default icon [`Color`] of the application. - pub icon_color: Color, + /// The default icon [`iced_core::Color`] of the application. + pub icon_color: iced_core::Color, } /// The default style of a [`Program`]. diff --git a/src/program.rs b/src/program.rs index c59e9f2501..cb44eadb3f 100644 --- a/src/program.rs +++ b/src/program.rs @@ -89,7 +89,7 @@ pub trait Program: Sized { } #[cfg(feature = "winit")] - /// Runs the [`Program`] with the given [`Settings`](crate::Settings) and a closure that creates the initial state. + /// Runs the [`Program`] with the given settings, and a closure that creates the initial state. fn run_with( self, settings: crate::Settings, diff --git a/widget/src/checkbox.rs b/widget/src/checkbox.rs index b36bd3dd3d..d08976908f 100644 --- a/widget/src/checkbox.rs +++ b/widget/src/checkbox.rs @@ -263,14 +263,14 @@ where } #[cfg(feature = "a11y")] - /// Sets the name of the [`Button`]. + /// Sets the name of the [`Checkbox`]. pub fn name(mut self, name: impl Into>) -> Self { self.name = Some(name.into()); self } #[cfg(feature = "a11y")] - /// Sets the description of the [`Button`]. + /// Sets the description of the [`Checkbox`]. pub fn description_widget( mut self, description: &T, @@ -282,7 +282,7 @@ where } #[cfg(feature = "a11y")] - /// Sets the description of the [`Button`]. + /// Sets the description of the [`Checkbox`]. pub fn description(mut self, description: impl Into>) -> Self { self.description = Some(iced_accessibility::Description::Text(description.into())); diff --git a/widget/src/image.rs b/widget/src/image.rs index 2e80094078..20cb300c22 100644 --- a/widget/src/image.rs +++ b/widget/src/image.rs @@ -149,14 +149,14 @@ impl<'a, Handle> Image<'a, Handle> { } #[cfg(feature = "a11y")] - /// Sets the name of the [`Button`]. + /// Sets the name of the [`Image`]. pub fn name(mut self, name: impl Into>) -> Self { self.name = Some(name.into()); self } #[cfg(feature = "a11y")] - /// Sets the description of the [`Button`]. + /// Sets the description of the [`Image`]. pub fn description_widget( mut self, description: &T, @@ -168,7 +168,7 @@ impl<'a, Handle> Image<'a, Handle> { } #[cfg(feature = "a11y")] - /// Sets the description of the [`Button`]. + /// Sets the description of the [`Image`]. pub fn description(mut self, description: impl Into>) -> Self { self.description = Some(iced_accessibility::Description::Text(description.into())); @@ -176,7 +176,7 @@ impl<'a, Handle> Image<'a, Handle> { } #[cfg(feature = "a11y")] - /// Sets the label of the [`Button`]. + /// Sets the label of the [`Image`]. pub fn label(mut self, label: &dyn iced_accessibility::Labels) -> Self { self.label = Some(label.label().into_iter().map(|l| l.into()).collect()); diff --git a/widget/src/scrollable.rs b/widget/src/scrollable.rs index 120af2c601..d125c7f4c8 100644 --- a/widget/src/scrollable.rs +++ b/widget/src/scrollable.rs @@ -268,14 +268,14 @@ where } #[cfg(feature = "a11y")] - /// Sets the name of the [`Button`]. + /// Sets the name of the [`Scrollable`]. pub fn name(mut self, name: impl Into>) -> Self { self.name = Some(name.into()); self } #[cfg(feature = "a11y")] - /// Sets the description of the [`Button`]. + /// Sets the description of the [`Scrollable`]. pub fn description_widget( mut self, description: &impl iced_accessibility::Describes, @@ -287,7 +287,7 @@ where } #[cfg(feature = "a11y")] - /// Sets the description of the [`Button`]. + /// Sets the description of the [`Scrollable`]. pub fn description(mut self, description: impl Into>) -> Self { self.description = Some(iced_accessibility::Description::Text(description.into())); @@ -295,7 +295,7 @@ where } #[cfg(feature = "a11y")] - /// Sets the label of the [`Button`]. + /// Sets the label of the [`Scrollable`]. pub fn label(mut self, label: &dyn iced_accessibility::Labels) -> Self { self.label = Some(label.label().into_iter().map(|l| l.into()).collect()); diff --git a/widget/src/slider.rs b/widget/src/slider.rs index f770dfadd4..deb94b52b9 100644 --- a/widget/src/slider.rs +++ b/widget/src/slider.rs @@ -239,14 +239,14 @@ where } #[cfg(feature = "a11y")] - /// Sets the name of the [`Button`]. + /// Sets the name of the [`Slider`]. pub fn name(mut self, name: impl Into>) -> Self { self.name = Some(name.into()); self } #[cfg(feature = "a11y")] - /// Sets the description of the [`Button`]. + /// Sets the description of the [`Slider`]. pub fn description_widget( mut self, description: &impl iced_accessibility::Describes, @@ -258,7 +258,7 @@ where } #[cfg(feature = "a11y")] - /// Sets the description of the [`Button`]. + /// Sets the description of the [`Slider`]. pub fn description(mut self, description: impl Into>) -> Self { self.description = Some(iced_accessibility::Description::Text(description.into())); @@ -266,7 +266,7 @@ where } #[cfg(feature = "a11y")] - /// Sets the label of the [`Button`]. + /// Sets the label of the [`Slider`]. pub fn label(mut self, label: &dyn iced_accessibility::Labels) -> Self { self.label = Some(label.label().into_iter().map(|l| l.into()).collect()); diff --git a/widget/src/svg.rs b/widget/src/svg.rs index 7cb1afb9d3..72a45f291f 100644 --- a/widget/src/svg.rs +++ b/widget/src/svg.rs @@ -179,14 +179,14 @@ where } #[cfg(feature = "a11y")] - /// Sets the name of the [`Button`]. + /// Sets the name of the [`Svg`]. pub fn name(mut self, name: impl Into>) -> Self { self.name = Some(name.into()); self } #[cfg(feature = "a11y")] - /// Sets the description of the [`Button`]. + /// Sets the description of the [`Svg`]. pub fn description_widget( mut self, description: &T, @@ -198,7 +198,7 @@ where } #[cfg(feature = "a11y")] - /// Sets the description of the [`Button`]. + /// Sets the description of the [`Svg`]. pub fn description(mut self, description: impl Into>) -> Self { self.description = Some(iced_accessibility::Description::Text(description.into())); @@ -206,7 +206,7 @@ where } #[cfg(feature = "a11y")] - /// Sets the label of the [`Button`]. + /// Sets the label of the [`Svg`]. pub fn label(mut self, label: &dyn iced_accessibility::Labels) -> Self { self.label = Some(label.label().into_iter().map(|l| l.into()).collect()); diff --git a/widget/src/toggler.rs b/widget/src/toggler.rs index 08aa7fe8ca..8d000bc380 100644 --- a/widget/src/toggler.rs +++ b/widget/src/toggler.rs @@ -263,14 +263,14 @@ where } #[cfg(feature = "a11y")] - /// Sets the name of the [`Button`]. + /// Sets the name of the [`Toggler`]. pub fn name(mut self, name: impl Into>) -> Self { self.name = Some(name.into()); self } #[cfg(feature = "a11y")] - /// Sets the description of the [`Button`]. + /// Sets the description of the [`Toggler`]. pub fn description_widget( mut self, description: &T, @@ -282,7 +282,7 @@ where } #[cfg(feature = "a11y")] - /// Sets the description of the [`Button`]. + /// Sets the description of the [`Toggler`]. pub fn description(mut self, description: impl Into>) -> Self { self.description = Some(iced_accessibility::Description::Text(description.into())); @@ -290,7 +290,7 @@ where } #[cfg(feature = "a11y")] - /// Sets the label of the [`Button`] using another widget. + /// Sets the label of the [`Toggler`] using another widget. pub fn labeled_by_widget( mut self, label: &dyn iced_accessibility::Labels, diff --git a/winit/Cargo.toml b/winit/Cargo.toml index 436e7f75f4..4e9e20023b 100644 --- a/winit/Cargo.toml +++ b/winit/Cargo.toml @@ -14,7 +14,7 @@ keywords.workspace = true workspace = true [features] -default = ["x11", "wayland", "wayland-dlopen", "wayland-csd-adwaita"] +default = ["x11"] debug = ["iced_runtime/debug"] system = ["sysinfo"] program = [] @@ -30,6 +30,8 @@ wayland = [ "xkbcommon-dl", "xkeysym", "iced_runtime/wayland", + "wayland-dlopen", + "wayland-csd-adwaita", ] wayland-dlopen = ["winit/wayland-dlopen"] wayland-csd-adwaita = ["winit/wayland-csd-adwaita"] diff --git a/winit/src/platform_specific/mod.rs b/winit/src/platform_specific/mod.rs index 4ef88dd7d9..608ca389ec 100644 --- a/winit/src/platform_specific/mod.rs +++ b/winit/src/platform_specific/mod.rs @@ -1,16 +1,17 @@ //! Wayland specific shell //! +use std::collections::HashMap; + use iced_graphics::Compositor; -use iced_runtime::{core::window, platform_specific, Debug}; -use sctk::reexports::client::Connection; -use wayland::sctk_event::UserInterfaces; +use iced_runtime::{core::window, user_interface, Debug}; #[cfg(all(feature = "wayland", target_os = "linux"))] pub mod wayland; #[cfg(all(feature = "wayland", target_os = "linux"))] pub use wayland::*; +#[cfg(all(feature = "wayland", target_os = "linux"))] use wayland_backend::client::Backend; use crate::{program::WindowManager, Program}; @@ -52,7 +53,7 @@ impl PlatformSpecific { ) { match action { #[cfg(all(feature = "wayland", target_os = "linux"))] - platform_specific::Action::Wayland(a) => { + iced_runtime::platform_specific::Action::Wayland(a) => { self.send_wayland(wayland::Action::Action(a)); } } @@ -92,7 +93,7 @@ impl PlatformSpecific { wayland_display_handle.display.as_ptr().cast(), ) }; - Connection::from_backend(backend) + sctk::reexports::client::Connection::from_backend(backend) } _ => { return; @@ -136,6 +137,17 @@ impl PlatformSpecific { } } +pub type UserInterfaces<'a, P> = HashMap< + window::Id, + user_interface::UserInterface< + 'a, +

::Message, +

::Theme, +

::Renderer, + >, + rustc_hash::FxBuildHasher, +>; + pub(crate) fn handle_event<'a, P, C>( e: Event, events: &mut Vec<(Option, iced_runtime::core::Event)>, diff --git a/winit/src/platform_specific/wayland/mod.rs b/winit/src/platform_specific/wayland/mod.rs index 7fbd07b4d8..445b1b67be 100644 --- a/winit/src/platform_specific/wayland/mod.rs +++ b/winit/src/platform_specific/wayland/mod.rs @@ -18,7 +18,6 @@ use sctk::reexports::calloop; use sctk::reexports::client::protocol::wl_surface::WlSurface; use sctk::seat::keyboard::Modifiers; use sctk_event::SctkEvent; -use sctk_event::UserInterfaces; use std::{collections::HashMap, sync::Arc}; use subsurface_widget::{SubsurfaceInstance, SubsurfaceState}; use wayland_backend::client::ObjectId; @@ -128,7 +127,7 @@ impl WaylandSpecific { compositor: &mut C, window_manager: &mut WindowManager, debug: &mut Debug, - user_interfaces: &mut UserInterfaces<'a, P>, + user_interfaces: &mut super::UserInterfaces<'a, P>, clipboard: &mut crate::Clipboard, #[cfg(feature = "a11y")] adapters: &mut HashMap< window::Id, diff --git a/winit/src/platform_specific/wayland/sctk_event.rs b/winit/src/platform_specific/wayland/sctk_event.rs index 1f455a9e66..f4f51c3e8b 100755 --- a/winit/src/platform_specific/wayland/sctk_event.rs +++ b/winit/src/platform_specific/wayland/sctk_event.rs @@ -67,7 +67,6 @@ use std::{ collections::HashMap, num::NonZeroU32, sync::{Arc, Mutex}, - time::Instant, }; use wayland_protocols::wp::viewporter::client::wp_viewport::WpViewport; use winit::{ @@ -82,67 +81,6 @@ use super::{ winit_window::SctkWinitWindow, }; -pub enum IcedSctkEvent { - /// Emitted when new events arrive from the OS to be processed. - /// - /// This event type is useful as a place to put code that should be done before you start - /// processing events, such as updating frame timing information for benchmarking or checking - /// the [`StartCause`] to see if a timer set by - /// [`ControlFlow::WaitUntil`](crate::platform_specific::wayland::event_loop::control_flow::ControlFlow::WaitUntil) - /// has elapsed. - NewEvents(StartCause), - - /// An event produced by sctk - SctkEvent(SctkEvent), - - /// Emitted when all of the event loop's input events have been processed and redraw processing - /// is about to begin. - /// - /// This event is useful as a place to put your code that should be run after all - /// state-changing events have been handled and you want to do stuff (updating state, performing - /// calculations, etc) that happens as the "main body" of your event loop. If your program only draws - /// graphics when something changes, it's usually better to do it in response to - /// [`window::RedrawRequest`], which gets emitted - /// immediately after this event. Programs that draw graphics continuously, like most games, - /// can render here unconditionally for simplicity. - MainEventsCleared, - - /// Emitted after [`MainEventsCleared`] when a window should be redrawn. - /// - /// This gets triggered in two scenarios: - /// - The OS has performed an operation that's invalidated the window's contents (such as - /// resizing the window). - /// - The application has explicitly requested a redraw via [`iced_runtime::core::Shell::request_redraw`]. - /// - /// During each iteration of the event loop, Winit will aggregate duplicate redraw requests - /// into a single event, to help avoid duplicating rendering work. - /// - /// Mainly of interest to applications with mostly-static graphics that avoid redrawing unless - /// something changes, like most non-game GUIs. - /// - /// [`MainEventsCleared`]: Self::MainEventsCleared - RedrawRequested(ObjectId), - - /// Emitted after all [`RedrawRequested`] events have been processed and control flow is about to - /// be taken away from the program. If there are no `RedrawRequested` events, it is emitted - /// immediately after `MainEventsCleared`. - /// - /// This event is useful for doing any cleanup or bookkeeping work after all the rendering - /// tasks have been completed. - /// - /// [`RedrawRequested`]: Self::RedrawRequested - RedrawEventsCleared, - - /// Emitted when the event loop is being shut down. - /// - /// This is irreversible - if this event is emitted, it is guaranteed to be the last event that - /// gets emitted. You generally want to treat this as an "do on quit" event. - LoopDestroyed, - - /// Frame callback event - Frame(WlSurface, u32), -} - #[derive(Debug, Clone)] pub enum SctkEvent { // @@ -324,36 +262,6 @@ pub enum LayerSurfaceEventVariant { ScaleFactorChanged(f64, Option), } -/// Describes the reason the event loop is resuming. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum StartCause { - /// Sent if the time specified by [`ControlFlow::WaitUntil`] has been reached. Contains the - /// moment the timeout was requested and the requested resume time. The actual resume time is - /// guaranteed to be equal to or after the requested resume time. - /// - /// [`ControlFlow::WaitUntil`]: crate::platform_specific::wayland::event_loop::control_flow::ControlFlow::WaitUntil - ResumeTimeReached { - start: Instant, - requested_resume: Instant, - }, - - /// Sent if the OS has new events to send to the window, after a wait was requested. Contains - /// the moment the wait was requested and the resume time, if requested. - WaitCancelled { - start: Instant, - requested_resume: Option, - }, - - /// Sent if the event loop is being resumed after the loop's control flow was set to - /// [`ControlFlow::Poll`]. - /// - /// [`ControlFlow::Poll`]: crate::platform_specific::wayland::event_loop::control_flow::ControlFlow::Poll - Poll, - - /// Sent once, immediately after `run` is called. Indicates that the loop was just initialized. - Init, -} - /// Pending update to a window requested by the user. #[derive(Default, Debug, Clone, Copy)] pub struct SurfaceUserRequest { @@ -373,16 +281,6 @@ pub struct SurfaceCompositorUpdate { /// New scale factor. pub scale_factor: Option, } -pub type UserInterfaces<'a, P> = HashMap< - SurfaceId, - user_interface::UserInterface< - 'a, -

::Message, -

::Theme, -

::Renderer, - >, - rustc_hash::FxBuildHasher, ->; impl SctkEvent { pub(crate) fn process<'a, P, C>( @@ -397,7 +295,7 @@ impl SctkEvent { control_sender: &mpsc::UnboundedSender, proxy: &EventLoopProxy, debug: &mut Debug, - user_interfaces: &mut UserInterfaces<'a, P>, + user_interfaces: &mut crate::platform_specific::UserInterfaces<'a, P>, events: &mut Vec<(Option, iced_runtime::core::Event)>, clipboard: &mut Clipboard, subsurface_state: &mut Option,