Removed glutin MW support and reverted glutin changes back to Iced master since it's being axed as we speak.

This commit is contained in:
bungoboingo 2023-02-28 13:44:36 -08:00
parent 51296572c0
commit e36daa6f93
15 changed files with 130 additions and 1376 deletions

View file

@ -46,8 +46,8 @@ chrome-trace = [
"iced_wgpu?/tracing", "iced_wgpu?/tracing",
"iced_glow?/tracing", "iced_glow?/tracing",
] ]
# Enables experimental multi-window support # Enables experimental multi-window support for iced_winit
multi_window = ["iced_winit/multi_window", "iced_glutin?/multi_window"] multi_window = ["iced_winit/multi_window"]
[badges] [badges]
maintenance = { status = "actively-developed" } maintenance = { status = "actively-developed" }

View file

@ -13,7 +13,6 @@ use iced_glow::{Backend, Renderer, Settings, Viewport};
use iced_glutin::conversion; use iced_glutin::conversion;
use iced_glutin::glutin; use iced_glutin::glutin;
use iced_glutin::renderer; use iced_glutin::renderer;
use iced_glutin::window;
use iced_glutin::{program, Clipboard, Color, Debug, Size}; use iced_glutin::{program, Clipboard, Color, Debug, Size};
pub fn main() { pub fn main() {
@ -31,8 +30,7 @@ pub fn main() {
.unwrap(); .unwrap();
unsafe { unsafe {
let windowed_context = let windowed_context = windowed_context.make_current().unwrap();
windowed_context.make_current(todo!("derezzedex")).unwrap();
let gl = glow::Context::from_loader_function(|s| { let gl = glow::Context::from_loader_function(|s| {
windowed_context.get_proc_address(s) as *const _ windowed_context.get_proc_address(s) as *const _
@ -109,7 +107,7 @@ pub fn main() {
// Map window event to iced event // Map window event to iced event
if let Some(event) = iced_winit::conversion::window_event( if let Some(event) = iced_winit::conversion::window_event(
window::Id::MAIN, iced_winit::window::Id::MAIN,
&event, &event,
windowed_context.window().scale_factor(), windowed_context.window().scale_factor(),
modifiers, modifiers,
@ -182,7 +180,7 @@ pub fn main() {
), ),
); );
windowed_context.swap_buffers(todo!("derezzedex")).unwrap(); windowed_context.swap_buffers().unwrap();
} }
_ => (), _ => (),
} }

View file

@ -11,19 +11,17 @@ keywords = ["gui", "ui", "graphics", "interface", "widgets"]
categories = ["gui"] categories = ["gui"]
[features] [features]
trace = ["iced_winit/trace", "tracing"] trace = ["iced_winit/trace"]
debug = ["iced_winit/debug"] debug = ["iced_winit/debug"]
system = ["iced_winit/system"] system = ["iced_winit/system"]
multi_window = ["iced_winit/multi_window"]
[dependencies.raw-window-handle]
version = "0.5.0"
[dependencies] [dependencies]
log = "0.4" log = "0.4"
[dependencies.glutin] [dependencies.glutin]
version = "0.30" version = "0.29"
git = "https://github.com/iced-rs/glutin"
rev = "da8d291486b4c9bec12487a46c119c4b1d386abf"
[dependencies.iced_native] [dependencies.iced_native]
version = "0.9" version = "0.9"

View file

@ -13,33 +13,14 @@ use iced_winit::futures::channel::mpsc;
use iced_winit::renderer; use iced_winit::renderer;
use iced_winit::time::Instant; use iced_winit::time::Instant;
use iced_winit::user_interface; use iced_winit::user_interface;
use iced_winit::winit;
use iced_winit::{Clipboard, Command, Debug, Event, Proxy, Settings}; use iced_winit::{Clipboard, Command, Debug, Event, Proxy, Settings};
use glutin::config::{ use glutin::window::Window;
Config, ConfigSurfaceTypes, ConfigTemplateBuilder, GlConfig,
};
use glutin::context::{
ContextApi, ContextAttributesBuilder, NotCurrentContext,
NotCurrentGlContextSurfaceAccessor,
PossiblyCurrentContextGlSurfaceAccessor, PossiblyCurrentGlContext,
};
use glutin::display::{Display, DisplayApiPreference, GlDisplay};
use glutin::surface::{
GlSurface, Surface, SurfaceAttributesBuilder, WindowSurface,
};
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle};
use std::ffi::CString;
use std::mem::ManuallyDrop; use std::mem::ManuallyDrop;
use std::num::NonZeroU32;
#[cfg(feature = "trace")] #[cfg(feature = "tracing")]
use tracing::{info_span, instrument::Instrument}; use tracing::{info_span, instrument::Instrument};
#[allow(unsafe_code)]
const ONE: NonZeroU32 = unsafe { NonZeroU32::new_unchecked(1) };
/// Runs an [`Application`] with an executor, compositor, and the provided /// Runs an [`Application`] with an executor, compositor, and the provided
/// settings. /// settings.
pub fn run<A, E, C>( pub fn run<A, E, C>(
@ -54,8 +35,9 @@ where
{ {
use futures::task; use futures::task;
use futures::Future; use futures::Future;
use winit::event_loop::EventLoopBuilder; use glutin::event_loop::EventLoopBuilder;
use winit::platform::run_return::EventLoopExtRunReturn; use glutin::platform::run_return::EventLoopExtRunReturn;
use glutin::ContextBuilder;
#[cfg(feature = "trace")] #[cfg(feature = "trace")]
let _guard = iced_winit::Profiler::init(); let _guard = iced_winit::Profiler::init();
@ -63,7 +45,7 @@ where
let mut debug = Debug::new(); let mut debug = Debug::new();
debug.startup_started(); debug.startup_started();
#[cfg(feature = "trace")] #[cfg(feature = "tracing")]
let _ = info_span!("Application::Glutin", "RUN").entered(); let _ = info_span!("Application::Glutin", "RUN").entered();
let mut event_loop = EventLoopBuilder::with_user_event().build(); let mut event_loop = EventLoopBuilder::with_user_event().build();
@ -82,205 +64,74 @@ where
runtime.enter(|| A::new(flags)) runtime.enter(|| A::new(flags))
}; };
let builder = settings.window.into_builder( let context = {
&application.title(), let builder = settings.window.into_builder(
event_loop.primary_monitor(), &application.title(),
settings.id, event_loop.primary_monitor(),
); settings.id,
);
log::debug!("Window builder: {:#?}", builder); log::debug!("Window builder: {:#?}", builder);
#[allow(unsafe_code)] let opengl_builder = ContextBuilder::new()
let (display, window, surface, context) = unsafe { .with_vsync(true)
struct Configuration(Config); .with_multisampling(C::sample_count(&compositor_settings) as u16);
use std::fmt;
impl fmt::Debug for Configuration {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let config = &self.0;
f.debug_struct("Configuration") let opengles_builder = opengl_builder.clone().with_gl(
.field("raw", &config) glutin::GlRequest::Specific(glutin::Api::OpenGlEs, (2, 0)),
.field("samples", &config.num_samples()) );
.field("buffer_type", &config.color_buffer_type())
.field("surface_type", &config.config_surface_types())
.field("depth", &config.depth_size())
.field("alpha", &config.alpha_size())
.field("stencil", &config.stencil_size())
.field("float_pixels", &config.float_pixels())
.field("srgb", &config.srgb_capable())
.field("api", &config.api())
.finish()
}
}
impl AsRef<Config> for Configuration { let (first_builder, second_builder) = if settings.try_opengles_first {
fn as_ref(&self) -> &Config { (opengles_builder, opengl_builder)
&self.0 } else {
} (opengl_builder, opengles_builder)
}
let display_handle = event_loop.raw_display_handle();
#[cfg(all(
any(windows, target_os = "macos"),
not(target_arch = "wasm32")
))]
let (window, window_handle) = {
let window = builder
.build(&event_loop)
.map_err(Error::WindowCreationFailed)?;
let handle = window.raw_window_handle();
(window, handle)
}; };
#[cfg(target_arch = "wasm32")] log::info!("Trying first builder: {:#?}", first_builder);
let preference = Err(Error::GraphicsCreationFailed(
iced_graphics::Error::BackendError(format!(
"target not supported by backend"
)),
))?;
#[cfg(all(windows, not(target_arch = "wasm32")))] let context = first_builder
let preference = DisplayApiPreference::WglThenEgl(Some(window_handle)); .build_windowed(builder.clone(), &event_loop)
#[cfg(all(target_os = "macos", not(target_arch = "wasm32")))]
let preference = DisplayApiPreference::Cgl;
#[cfg(all(
unix,
not(target_os = "macos"),
not(target_arch = "wasm32")
))]
let preference = DisplayApiPreference::GlxThenEgl(Box::new(
winit::platform::unix::register_xlib_error_hook,
));
let display =
Display::new(display_handle, preference).map_err(|error| {
Error::GraphicsCreationFailed(
iced_graphics::Error::BackendError(format!(
"failed to create display: {error}"
)),
)
})?;
log::debug!("Display: {}", display.version_string());
let samples = C::sample_count(&compositor_settings) as u8;
let mut template = ConfigTemplateBuilder::new()
.with_surface_type(ConfigSurfaceTypes::WINDOW);
if samples != 0 {
template = template.with_multisampling(samples);
}
#[cfg(all(windows, not(target_arch = "wasm32")))]
let template = template.compatible_with_native_window(window_handle);
log::debug!("Searching for display configurations");
let configuration = display
.find_configs(template.build())
.map_err(|_| {
Error::GraphicsCreationFailed(
iced_graphics::Error::NoAvailablePixelFormat,
)
})?
.map(Configuration)
.inspect(|config| {
log::trace!("{config:#?}");
})
.min_by_key(|config| {
config.as_ref().num_samples().saturating_sub(samples)
})
.ok_or(Error::GraphicsCreationFailed(
iced_graphics::Error::NoAvailablePixelFormat,
))?;
log::debug!("Selected: {configuration:#?}");
#[cfg(all(
unix,
not(target_os = "macos"),
not(target_arch = "wasm32")
))]
let (window, window_handle) = {
use glutin::platform::x11::X11GlConfigExt;
let builder =
if let Some(visual) = configuration.as_ref().x11_visual() {
use winit::platform::unix::WindowBuilderExtUnix;
builder.with_x11_visual(visual.into_raw())
} else {
builder
};
let window = builder
.build(&event_loop)
.map_err(Error::WindowCreationFailed)?;
let handle = window.raw_window_handle();
(window, handle)
};
let attributes =
ContextAttributesBuilder::new().build(Some(window_handle));
let fallback_attributes = ContextAttributesBuilder::new()
.with_context_api(ContextApi::Gles(None))
.build(Some(window_handle));
let context = display
.create_context(configuration.as_ref(), &attributes)
.or_else(|_| { .or_else(|_| {
display.create_context( log::info!("Trying second builder: {:#?}", second_builder);
configuration.as_ref(), second_builder.build_windowed(builder, &event_loop)
&fallback_attributes,
)
}) })
.map_err(|error| { .map_err(|error| {
Error::GraphicsCreationFailed( use glutin::CreationError;
iced_graphics::Error::BackendError(format!( use iced_graphics::Error as ContextError;
"failed to create context: {error}"
)), match error {
) CreationError::Window(error) => {
Error::WindowCreationFailed(error)
}
CreationError::OpenGlVersionNotSupported => {
Error::GraphicsCreationFailed(
ContextError::VersionNotSupported,
)
}
CreationError::NoAvailablePixelFormat => {
Error::GraphicsCreationFailed(
ContextError::NoAvailablePixelFormat,
)
}
error => Error::GraphicsCreationFailed(
ContextError::BackendError(error.to_string()),
),
}
})?; })?;
let surface = gl_surface(&display, configuration.as_ref(), &window) #[allow(unsafe_code)]
.map_err(|error| { unsafe {
Error::GraphicsCreationFailed( context.make_current().expect("Make OpenGL context current")
iced_graphics::Error::BackendError(format!(
"failed to create surface: {error}"
)),
)
})?;
let context = {
context
.make_current(&surface)
.expect("make context current")
};
if let Err(error) = surface.set_swap_interval(
&context,
glutin::surface::SwapInterval::Wait(ONE),
) {
log::error!("set swap interval failed: {}", error);
} }
(display, window, surface, context)
}; };
#[allow(unsafe_code)] #[allow(unsafe_code)]
let (compositor, renderer) = unsafe { let (compositor, renderer) = unsafe {
C::new(compositor_settings, |address| { C::new(compositor_settings, |address| {
let address = CString::new(address).expect("address error"); context.get_proc_address(address)
display.get_proc_address(address.as_c_str())
})? })?
}; };
let context = { context.make_not_current().expect("make context current") };
let (mut event_sender, event_receiver) = mpsc::unbounded(); let (mut event_sender, event_receiver) = mpsc::unbounded();
let (control_sender, mut control_receiver) = mpsc::unbounded(); let (control_sender, mut control_receiver) = mpsc::unbounded();
@ -294,14 +145,12 @@ where
debug, debug,
event_receiver, event_receiver,
control_sender, control_sender,
window,
surface,
context, context,
init_command, init_command,
settings.exit_on_close_request, settings.exit_on_close_request,
); );
#[cfg(feature = "trace")] #[cfg(feature = "tracing")]
let run_instance = let run_instance =
run_instance.instrument(info_span!("Application", "LOOP")); run_instance.instrument(info_span!("Application", "LOOP"));
@ -311,22 +160,22 @@ where
let mut context = task::Context::from_waker(task::noop_waker_ref()); let mut context = task::Context::from_waker(task::noop_waker_ref());
let _ = event_loop.run_return(move |event, _, control_flow| { let _ = event_loop.run_return(move |event, _, control_flow| {
use winit::event_loop::ControlFlow; use glutin::event_loop::ControlFlow;
if let ControlFlow::ExitWithCode(_) = control_flow { if let ControlFlow::ExitWithCode(_) = control_flow {
return; return;
} }
let event = match event { let event = match event {
winit::event::Event::WindowEvent { glutin::event::Event::WindowEvent {
event: event:
winit::event::WindowEvent::ScaleFactorChanged { glutin::event::WindowEvent::ScaleFactorChanged {
new_inner_size, new_inner_size,
.. ..
}, },
window_id, window_id,
} => Some(winit::event::Event::WindowEvent { } => Some(glutin::event::Event::WindowEvent {
event: winit::event::WindowEvent::Resized(*new_inner_size), event: glutin::event::WindowEvent::Resized(*new_inner_size),
window_id, window_id,
}), }),
_ => event.to_static(), _ => event.to_static(),
@ -358,13 +207,13 @@ async fn run_instance<A, E, C>(
mut compositor: C, mut compositor: C,
mut renderer: A::Renderer, mut renderer: A::Renderer,
mut runtime: Runtime<E, Proxy<A::Message>, A::Message>, mut runtime: Runtime<E, Proxy<A::Message>, A::Message>,
mut proxy: winit::event_loop::EventLoopProxy<A::Message>, mut proxy: glutin::event_loop::EventLoopProxy<A::Message>,
mut debug: Debug, mut debug: Debug,
mut event_receiver: mpsc::UnboundedReceiver<winit::event::Event<'_, A::Message>, >, mut event_receiver: mpsc::UnboundedReceiver<
mut control_sender: mpsc::UnboundedSender<winit::event_loop::ControlFlow>, glutin::event::Event<'_, A::Message>,
window: winit::window::Window, >,
surface: Surface<WindowSurface>, mut control_sender: mpsc::UnboundedSender<glutin::event_loop::ControlFlow>,
context: NotCurrentContext, mut context: glutin::ContextWrapper<glutin::PossiblyCurrent, Window>,
init_command: Command<A::Message>, init_command: Command<A::Message>,
exit_on_close_request: bool, exit_on_close_request: bool,
) where ) where
@ -373,19 +222,13 @@ async fn run_instance<A, E, C>(
C: window::GLCompositor<Renderer = A::Renderer> + 'static, C: window::GLCompositor<Renderer = A::Renderer> + 'static,
<A::Renderer as iced_native::Renderer>::Theme: StyleSheet, <A::Renderer as iced_native::Renderer>::Theme: StyleSheet,
{ {
use glutin::event;
use glutin::event_loop::ControlFlow;
use iced_winit::futures::stream::StreamExt; use iced_winit::futures::stream::StreamExt;
use winit::event_loop::ControlFlow;
use winit::event;
let context = { let mut clipboard = Clipboard::connect(context.window());
context
.make_current(&surface)
.expect("make context current")
};
let mut clipboard = Clipboard::connect(&window);
let mut cache = user_interface::Cache::default(); let mut cache = user_interface::Cache::default();
let mut state = application::State::new(&application, &window); let mut state = application::State::new(&application, context.window());
let mut viewport_version = state.viewport_version(); let mut viewport_version = state.viewport_version();
let mut should_exit = false; let mut should_exit = false;
@ -400,7 +243,7 @@ async fn run_instance<A, E, C>(
&mut should_exit, &mut should_exit,
&mut proxy, &mut proxy,
&mut debug, &mut debug,
&window, context.window(),
|| compositor.fetch_information(), || compositor.fetch_information(),
); );
runtime.track(application.subscription()); runtime.track(application.subscription());
@ -473,12 +316,12 @@ async fn run_instance<A, E, C>(
&mut proxy, &mut proxy,
&mut debug, &mut debug,
&mut messages, &mut messages,
&window, context.window(),
|| compositor.fetch_information(), || compositor.fetch_information(),
); );
// Update window // Update window
state.synchronize(&application, &window); state.synchronize(&application, context.window());
user_interface = user_interface =
ManuallyDrop::new(application::build_user_interface( ManuallyDrop::new(application::build_user_interface(
@ -524,15 +367,16 @@ async fn run_instance<A, E, C>(
debug.draw_finished(); debug.draw_finished();
if new_mouse_interaction != mouse_interaction { if new_mouse_interaction != mouse_interaction {
window.set_cursor_icon(conversion::mouse_interaction( context.window().set_cursor_icon(
new_mouse_interaction, conversion::mouse_interaction(new_mouse_interaction),
)); );
mouse_interaction = new_mouse_interaction; mouse_interaction = new_mouse_interaction;
} }
window.request_redraw(); context.window().request_redraw();
runtime.broadcast((redraw_event, crate::event::Status::Ignored)); runtime
.broadcast((redraw_event, crate::event::Status::Ignored));
let _ = control_sender.start_send(match interface_state { let _ = control_sender.start_send(match interface_state {
user_interface::State::Updated { user_interface::State::Updated {
@ -564,15 +408,18 @@ async fn run_instance<A, E, C>(
messages.push(message); messages.push(message);
} }
event::Event::RedrawRequested(_) => { event::Event::RedrawRequested(_) => {
#[cfg(feature = "trace")] #[cfg(feature = "tracing")]
let _ = info_span!("Application", "FRAME").entered(); let _ = info_span!("Application", "FRAME").entered();
debug.render_started(); debug.render_started();
if !context.is_current() { #[allow(unsafe_code)]
context unsafe {
.make_current(&surface) if !context.is_current() {
.expect("Make OpenGL context current"); context = context
.make_current()
.expect("Make OpenGL context current");
}
} }
let current_viewport_version = state.viewport_version(); let current_viewport_version = state.viewport_version();
@ -600,18 +447,19 @@ async fn run_instance<A, E, C>(
debug.draw_finished(); debug.draw_finished();
if new_mouse_interaction != mouse_interaction { if new_mouse_interaction != mouse_interaction {
window.set_cursor_icon(conversion::mouse_interaction( context.window().set_cursor_icon(
new_mouse_interaction, conversion::mouse_interaction(
)); new_mouse_interaction,
),
);
mouse_interaction = new_mouse_interaction; mouse_interaction = new_mouse_interaction;
} }
surface.resize( context.resize(glutin::dpi::PhysicalSize::new(
&context, physical_size.width,
NonZeroU32::new(physical_size.width).unwrap_or(ONE), physical_size.height,
NonZeroU32::new(physical_size.height).unwrap_or(ONE), ));
);
compositor.resize_viewport(physical_size); compositor.resize_viewport(physical_size);
@ -625,7 +473,7 @@ async fn run_instance<A, E, C>(
&debug.overlay(), &debug.overlay(),
); );
surface.swap_buffers(&context).expect("Swap buffers"); context.swap_buffers().expect("Swap buffers");
debug.render_finished(); debug.render_finished();
@ -642,7 +490,7 @@ async fn run_instance<A, E, C>(
break; break;
} }
state.update(&window, &window_event, &mut debug); state.update(context.window(), &window_event, &mut debug);
if let Some(event) = conversion::window_event( if let Some(event) = conversion::window_event(
crate::window::Id::MAIN, crate::window::Id::MAIN,
@ -660,23 +508,3 @@ async fn run_instance<A, E, C>(
// Manually drop the user interface // Manually drop the user interface
drop(ManuallyDrop::into_inner(user_interface)); drop(ManuallyDrop::into_inner(user_interface));
} }
#[allow(unsafe_code)]
/// Creates a new [`glutin::Surface<WindowSurface>`].
pub fn gl_surface(
display: &Display,
gl_config: &Config,
window: &winit::window::Window,
) -> Result<Surface<WindowSurface>, glutin::error::Error> {
let (width, height) = window.inner_size().into();
let surface_attributes = SurfaceAttributesBuilder::<WindowSurface>::new()
.with_srgb(Some(true))
.build(
window.raw_window_handle(),
NonZeroU32::new(width).unwrap_or(ONE),
NonZeroU32::new(height).unwrap_or(ONE),
);
unsafe { display.create_window_surface(gl_config, &surface_attributes) }
}

View file

@ -29,8 +29,5 @@ pub use iced_winit::*;
pub mod application; pub mod application;
#[cfg(feature = "multi_window")]
pub mod multi_window;
#[doc(no_inline)] #[doc(no_inline)]
pub use application::Application; pub use application::Application;

File diff suppressed because it is too large Load diff

View file

@ -30,7 +30,7 @@ pub trait GLCompositor: Sized {
/// The settings of the [`GLCompositor`]. /// The settings of the [`GLCompositor`].
/// ///
/// It's up to you to decide the configuration supported by your renderer! /// It's up to you to decide the configuration supported by your renderer!
type Settings: Default + Clone; type Settings: Default;
/// Creates a new [`GLCompositor`] and [`Renderer`] with the given /// Creates a new [`GLCompositor`] and [`Renderer`] with the given
/// [`Settings`] and an OpenGL address loader function. /// [`Settings`] and an OpenGL address loader function.

View file

@ -4,12 +4,10 @@ use std::hash::{Hash, Hasher};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
/// The ID of the window. /// The ID of the window.
///
/// This is not necessarily the same as the window ID fetched from `winit::window::Window`.
pub struct Id(u64); pub struct Id(u64);
impl Id { impl Id {
/// TODO(derezzedex): maybe change `u64` to an enum `Type::{Single, Multi(u64)}` /// The reserved window ID for the primary window in an Iced application.
pub const MAIN: Self = Id(0); pub const MAIN: Self = Id(0);
/// Creates a new unique window ID. /// Creates a new unique window ID.

View file

@ -182,7 +182,7 @@ pub mod touch;
pub mod widget; pub mod widget;
pub mod window; pub mod window;
#[cfg(feature = "multi_window")] #[cfg(all(not(feature = "glow"), feature = "multi_window"))]
pub mod multi_window; pub mod multi_window;
#[cfg(all(not(feature = "glow"), feature = "wgpu"))] #[cfg(all(not(feature = "glow"), feature = "wgpu"))]

View file

@ -734,7 +734,7 @@ pub fn run_command<A, E>(
clipboard.write(contents); clipboard.write(contents);
} }
}, },
command::Action::Window(_id, action) => match action { command::Action::Window(_, action) => match action {
window::Action::Close => { window::Action::Close => {
*should_exit = true; *should_exit = true;
} }

View file

@ -1,4 +1,4 @@
//! Create interactive, native cross-platform applications. //! Create interactive, native cross-platform applications for WGPU.
mod state; mod state;
pub use state::State; pub use state::State;
@ -31,17 +31,14 @@ pub use crate::Profiler;
#[cfg(feature = "trace")] #[cfg(feature = "trace")]
use tracing::{info_span, instrument::Instrument}; use tracing::{info_span, instrument::Instrument};
/// TODO(derezzedex) /// This is a wrapper around the `Application::Message` associate type
// This is the an wrapper around the `Application::Message` associate type /// to allows the `shell` to create internal messages, while still having
// to allows the `shell` to create internal messages, while still having /// the current user specified custom messages.
// the current user specified custom messages.
#[derive(Debug)] #[derive(Debug)]
pub enum Event<Message> { pub enum Event<Message> {
/// An [`Application`] generated message /// An [`Application`] generated message
Application(Message), Application(Message),
/// TODO(derezzedex) /// A message which spawns a new window.
// Create a wrapper variant of `window::Event` type instead
// (maybe we should also allow users to listen/react to those internal messages?)
NewWindow { NewWindow {
/// The [window::Id] of the newly spawned [`Window`]. /// The [window::Id] of the newly spawned [`Window`].
id: window::Id, id: window::Id,
@ -50,9 +47,9 @@ pub enum Event<Message> {
/// The title of the newly spawned [`Window`]. /// The title of the newly spawned [`Window`].
title: String, title: String,
}, },
/// TODO(derezzedex) /// Close a window.
CloseWindow(window::Id), CloseWindow(window::Id),
/// TODO(derezzedex) /// A message for when the window has finished being created.
WindowCreated(window::Id, winit::window::Window), WindowCreated(window::Id, winit::window::Window),
} }
@ -90,7 +87,7 @@ where
/// background by shells. /// background by shells.
fn update(&mut self, message: Self::Message) -> Command<Self::Message>; fn update(&mut self, message: Self::Message) -> Command<Self::Message>;
/// Returns the widgets to display in the [`Program`]. /// Returns the widgets to display for the `window` in the [`Program`].
/// ///
/// These widgets can produce __messages__ based on user interaction. /// These widgets can produce __messages__ based on user interaction.
fn view( fn view(
@ -108,7 +105,7 @@ where
/// load state from a file, perform an initial HTTP request, etc. /// load state from a file, perform an initial HTTP request, etc.
fn new(flags: Self::Flags) -> (Self, Command<Self::Message>); fn new(flags: Self::Flags) -> (Self, Command<Self::Message>);
/// Returns the current title of the current [`Application`] window. /// Returns the current title of each [`Application`] window.
/// ///
/// This title can be dynamic! The runtime will automatically update the /// This title can be dynamic! The runtime will automatically update the
/// title of your application when necessary. /// title of your application when necessary.
@ -137,7 +134,7 @@ where
Subscription::none() Subscription::none()
} }
/// Returns the scale factor of the [`Application`]. /// Returns the scale factor of the window of the [`Application`].
/// ///
/// It can be used to dynamically control the size of the UI at runtime /// It can be used to dynamically control the size of the UI at runtime
/// (i.e. zooming). /// (i.e. zooming).
@ -1142,7 +1139,7 @@ pub fn run_command<A, E>(
} }
} }
/// TODO(derezzedex) /// Build the user interfaces for every window.
pub fn build_user_interfaces<'a, A>( pub fn build_user_interfaces<'a, A>(
application: &'a A, application: &'a A,
renderer: &mut A::Renderer, renderer: &mut A::Renderer,

View file

@ -8,7 +8,7 @@ use std::marker::PhantomData;
use winit::event::{Touch, WindowEvent}; use winit::event::{Touch, WindowEvent};
use winit::window::Window; use winit::window::Window;
/// The state of a windowed [`Application`]. /// The state of a multi-windowed [`Application`].
#[allow(missing_debug_implementations)] #[allow(missing_debug_implementations)]
pub struct State<A: Application> pub struct State<A: Application>
where where
@ -29,7 +29,7 @@ impl<A: Application> State<A>
where where
<A::Renderer as crate::Renderer>::Theme: application::StyleSheet, <A::Renderer as crate::Renderer>::Theme: application::StyleSheet,
{ {
/// Creates a new [`State`] for the provided [`Application`]'s window. /// Creates a new [`State`] for the provided [`Application`]'s `window`.
pub fn new( pub fn new(
application: &A, application: &A,
window_id: window::Id, window_id: window::Id,
@ -116,8 +116,7 @@ where
self.appearance.text_color self.appearance.text_color
} }
/// Processes the provided window event and updates the [`State`] /// Processes the provided window event and updates the [`State`] accordingly.
/// accordingly.
pub fn update( pub fn update(
&mut self, &mut self,
window: &Window, window: &Window,

View file

@ -21,7 +21,6 @@ pub struct Profiler {
impl Profiler { impl Profiler {
/// Initializes the [`Profiler`]. /// Initializes the [`Profiler`].
pub fn init() -> Self { pub fn init() -> Self {
log::info!("Capturing trace..");
// Registry stores the spans & generates unique span IDs // Registry stores the spans & generates unique span IDs
let subscriber = Registry::default(); let subscriber = Registry::default();

View file

@ -179,9 +179,9 @@ impl Window {
{ {
use winit::platform::windows::WindowBuilderExtWindows; use winit::platform::windows::WindowBuilderExtWindows;
// if let Some(parent) = self.platform_specific.parent { if let Some(parent) = self.platform_specific.parent {
// window_builder = window_builder.with_parent_window(parent); window_builder = window_builder.with_parent_window(parent);
// } }
window_builder = window_builder window_builder = window_builder
.with_drag_and_drop(self.platform_specific.drag_and_drop); .with_drag_and_drop(self.platform_specific.drag_and_drop);
@ -227,7 +227,7 @@ impl From<iced_native::window::Settings> for Window {
fn from(settings: iced_native::window::Settings) -> Self { fn from(settings: iced_native::window::Settings) -> Self {
Self { Self {
size: settings.size, size: settings.size,
position: Position::from(settings.position), position: settings.position,
min_size: settings.min_size, min_size: settings.min_size,
max_size: settings.max_size, max_size: settings.max_size,
visible: settings.visible, visible: settings.visible,

View file

@ -4,7 +4,7 @@
#[derive(Debug, Clone, Copy, PartialEq, Eq)] #[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct PlatformSpecific { pub struct PlatformSpecific {
/// Parent window /// Parent window
// pub parent: Option<winit::platform::windows::HWND>, pub parent: Option<winit::platform::windows::HWND>,
/// Drag and drop support /// Drag and drop support
pub drag_and_drop: bool, pub drag_and_drop: bool,
@ -13,7 +13,7 @@ pub struct PlatformSpecific {
impl Default for PlatformSpecific { impl Default for PlatformSpecific {
fn default() -> Self { fn default() -> Self {
Self { Self {
// parent: None, parent: None,
drag_and_drop: true, drag_and_drop: true,
} }
} }