Deprecate window creation with stale event loop
Creating window when event loop is not running generally doesn't work, since a bunch of events and sync OS requests can't be processed. This is also an issue on e.g. Android, since window can't be created outside event loop easily. Thus deprecate the window creation when event loop is not running, as well as other resource creation to running event loop. Given that all the examples use the bad pattern of creating the window when event loop is not running and also most example existence is questionable, since they show single thing and the majority of their code is window/event loop initialization, they wore merged into a single example 'window.rs' example that showcases very simple application using winit. Fixes #3399.
This commit is contained in:
parent
19190a95a0
commit
3fb93b4f83
90 changed files with 1594 additions and 3495 deletions
|
|
@ -24,8 +24,8 @@
|
|||
use std::env;
|
||||
|
||||
use crate::error::NotSupportedError;
|
||||
use crate::event_loop::{AsyncRequestSerial, EventLoopWindowTarget};
|
||||
use crate::window::{ActivationToken, Window, WindowBuilder};
|
||||
use crate::event_loop::{ActiveEventLoop, AsyncRequestSerial};
|
||||
use crate::window::{ActivationToken, Window, WindowAttributes};
|
||||
|
||||
/// The variable which is used mostly on X11.
|
||||
const X11_VAR: &str = "DESKTOP_STARTUP_ID";
|
||||
|
|
@ -47,7 +47,7 @@ pub trait WindowExtStartupNotify {
|
|||
fn request_activation_token(&self) -> Result<AsyncRequestSerial, NotSupportedError>;
|
||||
}
|
||||
|
||||
pub trait WindowBuilderExtStartupNotify {
|
||||
pub trait WindowAttributesExtStartupNotify {
|
||||
/// Use this [`ActivationToken`] during window creation.
|
||||
///
|
||||
/// Not using such a token upon a window could make your window not gaining
|
||||
|
|
@ -55,13 +55,13 @@ pub trait WindowBuilderExtStartupNotify {
|
|||
fn with_activation_token(self, token: ActivationToken) -> Self;
|
||||
}
|
||||
|
||||
impl EventLoopExtStartupNotify for EventLoopWindowTarget {
|
||||
impl EventLoopExtStartupNotify for ActiveEventLoop {
|
||||
fn read_token_from_env(&self) -> Option<ActivationToken> {
|
||||
match self.p {
|
||||
#[cfg(wayland_platform)]
|
||||
crate::platform_impl::EventLoopWindowTarget::Wayland(_) => env::var(WAYLAND_VAR),
|
||||
crate::platform_impl::ActiveEventLoop::Wayland(_) => env::var(WAYLAND_VAR),
|
||||
#[cfg(x11_platform)]
|
||||
crate::platform_impl::EventLoopWindowTarget::X(_) => env::var(X11_VAR),
|
||||
crate::platform_impl::ActiveEventLoop::X(_) => env::var(X11_VAR),
|
||||
}
|
||||
.ok()
|
||||
.map(ActivationToken::_new)
|
||||
|
|
@ -74,9 +74,9 @@ impl WindowExtStartupNotify for Window {
|
|||
}
|
||||
}
|
||||
|
||||
impl WindowBuilderExtStartupNotify for WindowBuilder {
|
||||
impl WindowAttributesExtStartupNotify for WindowAttributes {
|
||||
fn with_activation_token(mut self, token: ActivationToken) -> Self {
|
||||
self.window.platform_specific.activation_token = Some(token);
|
||||
self.platform_specific.activation_token = Some(token);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue