summaryrefslogtreecommitdiffstats
path: root/winit/src/application
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--winit/src/application.rs37
-rw-r--r--winit/src/application/state.rs19
2 files changed, 21 insertions, 35 deletions
diff --git a/winit/src/application.rs b/winit/src/application.rs
index 3a5c3dac..23364209 100644
--- a/winit/src/application.rs
+++ b/winit/src/application.rs
@@ -9,7 +9,7 @@ use crate::mouse;
use crate::renderer;
use crate::widget::operation;
use crate::{
- Command, Debug, Error, Executor, Mode, Proxy, Runtime, Settings, Size,
+ Command, Debug, Error, Executor, Proxy, Runtime, Settings, Size,
Subscription,
};
@@ -81,16 +81,6 @@ where
Subscription::none()
}
- /// Returns the current [`Application`] mode.
- ///
- /// The runtime will automatically transition your application if a new mode
- /// is returned.
- ///
- /// By default, an application will run in windowed mode.
- fn mode(&self) -> Mode {
- Mode::Windowed
- }
-
/// Returns the scale factor of the [`Application`].
///
/// It can be used to dynamically control the size of the UI at runtime
@@ -147,12 +137,15 @@ where
runtime.enter(|| A::new(flags))
};
- let builder = settings.window.into_builder(
- &application.title(),
- application.mode(),
- event_loop.primary_monitor(),
- settings.id,
- );
+ let should_be_visible = settings.window.visible;
+ let builder = settings
+ .window
+ .into_builder(
+ &application.title(),
+ event_loop.primary_monitor(),
+ settings.id,
+ )
+ .with_visible(false);
log::info!("Window builder: {:#?}", builder);
@@ -189,6 +182,7 @@ where
receiver,
init_command,
window,
+ should_be_visible,
settings.exit_on_close_request,
));
@@ -239,6 +233,7 @@ async fn run_instance<A, E, C>(
mut receiver: mpsc::UnboundedReceiver<winit::event::Event<'_, A::Message>>,
init_command: Command<A::Message>,
window: winit::window::Window,
+ should_be_visible: bool,
exit_on_close_request: bool,
) where
A: Application + 'static,
@@ -252,6 +247,7 @@ async fn run_instance<A, E, C>(
let mut clipboard = Clipboard::connect(&window);
let mut cache = user_interface::Cache::default();
let mut surface = compositor.create_surface(&window);
+ let mut visible = false;
let mut state = State::new(&application, &window);
let mut viewport_version = state.viewport_version();
@@ -383,6 +379,7 @@ async fn run_instance<A, E, C>(
event::MacOS::ReceivedUrl(url),
)) => {
use iced_native::event;
+
events.push(iced_native::Event::PlatformSpecific(
event::PlatformSpecific::MacOS(event::MacOS::ReceivedUrl(
url,
@@ -450,6 +447,12 @@ async fn run_instance<A, E, C>(
Ok(()) => {
debug.render_finished();
+ if !visible && should_be_visible {
+ window.set_visible(true);
+
+ visible = true;
+ }
+
// TODO: Handle animations!
// Maybe we can use `ControlFlow::WaitUntil` for this.
}
diff --git a/winit/src/application/state.rs b/winit/src/application/state.rs
index 6b843919..5e953cb5 100644
--- a/winit/src/application/state.rs
+++ b/winit/src/application/state.rs
@@ -1,6 +1,6 @@
use crate::application::{self, StyleSheet as _};
use crate::conversion;
-use crate::{Application, Color, Debug, Mode, Point, Size, Viewport};
+use crate::{Application, Color, Debug, Point, Size, Viewport};
use std::marker::PhantomData;
use winit::event::{Touch, WindowEvent};
@@ -13,7 +13,6 @@ where
<A::Renderer as crate::Renderer>::Theme: application::StyleSheet,
{
title: String,
- mode: Mode,
scale_factor: f64,
viewport: Viewport,
viewport_version: usize,
@@ -31,7 +30,6 @@ where
/// Creates a new [`State`] for the provided [`Application`] and window.
pub fn new(application: &A, window: &Window) -> Self {
let title = application.title();
- let mode = application.mode();
let scale_factor = application.scale_factor();
let theme = application.theme();
let appearance = theme.appearance(application.style());
@@ -47,7 +45,6 @@ where
Self {
title,
- mode,
scale_factor,
viewport,
viewport_version: 0,
@@ -193,20 +190,6 @@ where
self.title = new_title;
}
- // Update window mode
- let new_mode = application.mode();
-
- if self.mode != new_mode {
- window.set_fullscreen(conversion::fullscreen(
- window.current_monitor(),
- new_mode,
- ));
-
- window.set_visible(conversion::visible(new_mode));
-
- self.mode = new_mode;
- }
-
// Update scale factor
let new_scale_factor = application.scale_factor();