Make ControlFlow::Wait the default (#3106)
This commit is contained in:
parent
e2e01e1fc6
commit
878d832d24
34 changed files with 154 additions and 228 deletions
|
|
@ -151,16 +151,17 @@ impl<T> fmt::Debug for EventLoopWindowTarget<T> {
|
|||
///
|
||||
/// Indicates the desired behavior of the event loop after [`Event::AboutToWait`] is emitted.
|
||||
///
|
||||
/// Defaults to [`Poll`].
|
||||
/// Defaults to [`Wait`].
|
||||
///
|
||||
/// [`Poll`]: Self::Poll
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
/// [`Wait`]: Self::Wait
|
||||
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
|
||||
pub enum ControlFlow {
|
||||
/// When the current loop iteration finishes, immediately begin a new iteration regardless of
|
||||
/// whether or not new events are available to process.
|
||||
Poll,
|
||||
|
||||
/// When the current loop iteration finishes, suspend the thread until another event arrives.
|
||||
#[default]
|
||||
Wait,
|
||||
|
||||
/// When the current loop iteration finishes, suspend the thread until either another event
|
||||
|
|
@ -190,13 +191,6 @@ impl ControlFlow {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for ControlFlow {
|
||||
#[inline(always)]
|
||||
fn default() -> Self {
|
||||
Self::Poll
|
||||
}
|
||||
}
|
||||
|
||||
impl EventLoop<()> {
|
||||
/// Alias for [`EventLoopBuilder::new().build()`].
|
||||
///
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ pub use raw_window_handle;
|
|||
/// ```no_run
|
||||
/// use winit::{
|
||||
/// event::{Event, WindowEvent},
|
||||
/// event_loop::{ControlFlow, EventLoop},
|
||||
/// event_loop::EventLoop,
|
||||
/// window::Window,
|
||||
/// };
|
||||
///
|
||||
|
|
@ -48,8 +48,6 @@ pub use raw_window_handle;
|
|||
/// let window = Window::new(&event_loop).unwrap();
|
||||
///
|
||||
/// event_loop.run(move |event, elwt| {
|
||||
/// elwt.set_control_flow(ControlFlow::Wait);
|
||||
///
|
||||
/// match event {
|
||||
/// Event::WindowEvent {
|
||||
/// event: WindowEvent::CloseRequested,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue