Make ControlFlow::Wait the default (#3106)
This commit is contained in:
parent
e2e01e1fc6
commit
878d832d24
34 changed files with 154 additions and 228 deletions
|
|
@ -25,6 +25,7 @@ And please only add new entries to the top of this list, right below the `# Unre
|
||||||
- On Web, add `EventLoopWindowTargetExtWebSys` and `PollStrategy`, which allows to set different strategies for `ControlFlow::Poll`. By default the Prioritized Task Scheduling API is used, but an option to use `Window.requestIdleCallback` is available as well. Both use `setTimeout()`, with a trick to circumvent throttling to 4ms, as a fallback.
|
- On Web, add `EventLoopWindowTargetExtWebSys` and `PollStrategy`, which allows to set different strategies for `ControlFlow::Poll`. By default the Prioritized Task Scheduling API is used, but an option to use `Window.requestIdleCallback` is available as well. Both use `setTimeout()`, with a trick to circumvent throttling to 4ms, as a fallback.
|
||||||
- Implement `PartialOrd` and `Ord` for `MouseButton`.
|
- Implement `PartialOrd` and `Ord` for `MouseButton`.
|
||||||
- On X11, fix event loop not waking up on `ControlFlow::Poll` and `ControlFlow::WaitUntil`.
|
- On X11, fix event loop not waking up on `ControlFlow::Poll` and `ControlFlow::WaitUntil`.
|
||||||
|
- **Breaking:** Change default `ControlFlow` from `Poll` to `Wait`.
|
||||||
|
|
||||||
# 0.29.1-beta
|
# 0.29.1-beta
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ another library.
|
||||||
```rust
|
```rust
|
||||||
use winit::{
|
use winit::{
|
||||||
event::{Event, WindowEvent},
|
event::{Event, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::EventLoop,
|
||||||
window::WindowBuilder,
|
window::WindowBuilder,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -44,8 +44,6 @@ fn main() {
|
||||||
let window = WindowBuilder::new().build(&event_loop).unwrap();
|
let window = WindowBuilder::new().build(&event_loop).unwrap();
|
||||||
|
|
||||||
event_loop.run(move |event, elwt| {
|
event_loop.run(move |event, elwt| {
|
||||||
elwt.set_control_flow(ControlFlow::Wait);
|
|
||||||
|
|
||||||
match event {
|
match event {
|
||||||
Event::WindowEvent {
|
Event::WindowEvent {
|
||||||
event: WindowEvent::CloseRequested,
|
event: WindowEvent::CloseRequested,
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ fn main() -> Result<(), impl std::error::Error> {
|
||||||
use winit::{
|
use winit::{
|
||||||
dpi::{LogicalPosition, LogicalSize, Position},
|
dpi::{LogicalPosition, LogicalSize, Position},
|
||||||
event::{ElementState, Event, KeyEvent, WindowEvent},
|
event::{ElementState, Event, KeyEvent, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop, EventLoopWindowTarget},
|
event_loop::{EventLoop, EventLoopWindowTarget},
|
||||||
window::raw_window_handle::HasRawWindowHandle,
|
window::raw_window_handle::HasRawWindowHandle,
|
||||||
window::{Window, WindowBuilder, WindowId},
|
window::{Window, WindowBuilder, WindowId},
|
||||||
};
|
};
|
||||||
|
|
@ -47,8 +47,6 @@ fn main() -> Result<(), impl std::error::Error> {
|
||||||
println!("parent window: {parent_window:?})");
|
println!("parent window: {parent_window:?})");
|
||||||
|
|
||||||
event_loop.run(move |event: Event<()>, elwt| {
|
event_loop.run(move |event: Event<()>, elwt| {
|
||||||
elwt.set_control_flow(ControlFlow::Wait);
|
|
||||||
|
|
||||||
if let Event::WindowEvent { event, window_id } = event {
|
if let Event::WindowEvent { event, window_id } = event {
|
||||||
match event {
|
match event {
|
||||||
WindowEvent::CloseRequested => {
|
WindowEvent::CloseRequested => {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
use simple_logger::SimpleLogger;
|
use simple_logger::SimpleLogger;
|
||||||
use winit::{
|
use winit::{
|
||||||
event::{ElementState, Event, KeyEvent, WindowEvent},
|
event::{ElementState, Event, KeyEvent, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::EventLoop,
|
||||||
window::{CursorIcon, WindowBuilder},
|
window::{CursorIcon, WindowBuilder},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -20,8 +20,6 @@ fn main() -> Result<(), impl std::error::Error> {
|
||||||
let mut cursor_idx = 0;
|
let mut cursor_idx = 0;
|
||||||
|
|
||||||
event_loop.run(move |event, elwt| {
|
event_loop.run(move |event, elwt| {
|
||||||
elwt.set_control_flow(ControlFlow::Wait);
|
|
||||||
|
|
||||||
if let Event::WindowEvent { event, .. } = event {
|
if let Event::WindowEvent { event, .. } = event {
|
||||||
match event {
|
match event {
|
||||||
WindowEvent::KeyboardInput {
|
WindowEvent::KeyboardInput {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
use simple_logger::SimpleLogger;
|
use simple_logger::SimpleLogger;
|
||||||
use winit::{
|
use winit::{
|
||||||
event::{DeviceEvent, ElementState, Event, KeyEvent, WindowEvent},
|
event::{DeviceEvent, ElementState, Event, KeyEvent, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::EventLoop,
|
||||||
keyboard::{Key, ModifiersState},
|
keyboard::{Key, ModifiersState},
|
||||||
window::{CursorGrabMode, WindowBuilder},
|
window::{CursorGrabMode, WindowBuilder},
|
||||||
};
|
};
|
||||||
|
|
@ -22,10 +22,7 @@ fn main() -> Result<(), impl std::error::Error> {
|
||||||
|
|
||||||
let mut modifiers = ModifiersState::default();
|
let mut modifiers = ModifiersState::default();
|
||||||
|
|
||||||
event_loop.run(move |event, elwt| {
|
event_loop.run(move |event, elwt| match event {
|
||||||
elwt.set_control_flow(ControlFlow::Wait);
|
|
||||||
|
|
||||||
match event {
|
|
||||||
Event::WindowEvent { event, .. } => match event {
|
Event::WindowEvent { event, .. } => match event {
|
||||||
WindowEvent::CloseRequested => elwt.exit(),
|
WindowEvent::CloseRequested => elwt.exit(),
|
||||||
WindowEvent::KeyboardInput {
|
WindowEvent::KeyboardInput {
|
||||||
|
|
@ -72,6 +69,5 @@ fn main() -> Result<(), impl std::error::Error> {
|
||||||
_ => (),
|
_ => (),
|
||||||
},
|
},
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ fn main() -> Result<(), impl std::error::Error> {
|
||||||
use simple_logger::SimpleLogger;
|
use simple_logger::SimpleLogger;
|
||||||
use winit::{
|
use winit::{
|
||||||
event::{Event, WindowEvent},
|
event::{Event, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoopBuilder},
|
event_loop::EventLoopBuilder,
|
||||||
window::WindowBuilder,
|
window::WindowBuilder,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -40,10 +40,7 @@ fn main() -> Result<(), impl std::error::Error> {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
event_loop.run(move |event, elwt| {
|
event_loop.run(move |event, elwt| match event {
|
||||||
elwt.set_control_flow(ControlFlow::Wait);
|
|
||||||
|
|
||||||
match event {
|
|
||||||
Event::UserEvent(event) => println!("user event: {event:?}"),
|
Event::UserEvent(event) => println!("user event: {event:?}"),
|
||||||
Event::WindowEvent {
|
Event::WindowEvent {
|
||||||
event: WindowEvent::CloseRequested,
|
event: WindowEvent::CloseRequested,
|
||||||
|
|
@ -56,7 +53,6 @@ fn main() -> Result<(), impl std::error::Error> {
|
||||||
fill::fill_window(&window);
|
fill::fill_window(&window);
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
use simple_logger::SimpleLogger;
|
use simple_logger::SimpleLogger;
|
||||||
use winit::dpi::PhysicalSize;
|
use winit::dpi::PhysicalSize;
|
||||||
use winit::event::{ElementState, Event, KeyEvent, WindowEvent};
|
use winit::event::{ElementState, Event, KeyEvent, WindowEvent};
|
||||||
use winit::event_loop::{ControlFlow, EventLoop};
|
use winit::event_loop::EventLoop;
|
||||||
use winit::keyboard::Key;
|
use winit::keyboard::Key;
|
||||||
use winit::window::{Fullscreen, WindowBuilder};
|
use winit::window::{Fullscreen, WindowBuilder};
|
||||||
|
|
||||||
|
|
@ -53,8 +53,6 @@ fn main() -> Result<(), impl std::error::Error> {
|
||||||
println!("- A\tToggle mAx size limit");
|
println!("- A\tToggle mAx size limit");
|
||||||
|
|
||||||
event_loop.run(move |event, elwt| {
|
event_loop.run(move |event, elwt| {
|
||||||
elwt.set_control_flow(ControlFlow::Wait);
|
|
||||||
|
|
||||||
if let Event::WindowEvent { event, .. } = event {
|
if let Event::WindowEvent { event, .. } = event {
|
||||||
match event {
|
match event {
|
||||||
WindowEvent::CloseRequested => elwt.exit(),
|
WindowEvent::CloseRequested => elwt.exit(),
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
use simple_logger::SimpleLogger;
|
use simple_logger::SimpleLogger;
|
||||||
use winit::{
|
use winit::{
|
||||||
event::{ElementState, Event, KeyEvent, WindowEvent},
|
event::{ElementState, Event, KeyEvent, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::EventLoop,
|
||||||
keyboard::Key,
|
keyboard::Key,
|
||||||
window::WindowBuilder,
|
window::WindowBuilder,
|
||||||
};
|
};
|
||||||
|
|
@ -23,8 +23,6 @@ fn main() -> Result<(), impl std::error::Error> {
|
||||||
let mut close_requested = false;
|
let mut close_requested = false;
|
||||||
|
|
||||||
event_loop.run(move |event, elwt| {
|
event_loop.run(move |event, elwt| {
|
||||||
elwt.set_control_flow(ControlFlow::Wait);
|
|
||||||
|
|
||||||
if let Event::WindowEvent { event, .. } = event {
|
if let Event::WindowEvent { event, .. } = event {
|
||||||
match event {
|
match event {
|
||||||
WindowEvent::CloseRequested => {
|
WindowEvent::CloseRequested => {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use simple_logger::SimpleLogger;
|
||||||
use winit::{
|
use winit::{
|
||||||
dpi::{PhysicalPosition, PhysicalSize},
|
dpi::{PhysicalPosition, PhysicalSize},
|
||||||
event::{ElementState, Event, Ime, WindowEvent},
|
event::{ElementState, Event, Ime, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::EventLoop,
|
||||||
keyboard::{Key, KeyCode},
|
keyboard::{Key, KeyCode},
|
||||||
window::{ImePurpose, WindowBuilder},
|
window::{ImePurpose, WindowBuilder},
|
||||||
};
|
};
|
||||||
|
|
@ -40,7 +40,6 @@ fn main() -> Result<(), impl std::error::Error> {
|
||||||
let mut ime_pos = PhysicalPosition::new(0.0, 0.0);
|
let mut ime_pos = PhysicalPosition::new(0.0, 0.0);
|
||||||
|
|
||||||
event_loop.run(move |event, elwt| {
|
event_loop.run(move |event, elwt| {
|
||||||
elwt.set_control_flow(ControlFlow::Wait);
|
|
||||||
if let Event::WindowEvent { event, .. } = event {
|
if let Event::WindowEvent { event, .. } = event {
|
||||||
match event {
|
match event {
|
||||||
WindowEvent::CloseRequested => elwt.exit(),
|
WindowEvent::CloseRequested => elwt.exit(),
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
use winit::{
|
use winit::{
|
||||||
dpi::LogicalSize,
|
dpi::LogicalSize,
|
||||||
event::{ElementState, Event, WindowEvent},
|
event::{ElementState, Event, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::EventLoop,
|
||||||
keyboard::{Key, ModifiersState},
|
keyboard::{Key, ModifiersState},
|
||||||
// WARNING: This is not available on all platforms (for example on the web).
|
// WARNING: This is not available on all platforms (for example on the web).
|
||||||
platform::modifier_supplement::KeyEventExtModifierSupplement,
|
platform::modifier_supplement::KeyEventExtModifierSupplement,
|
||||||
|
|
@ -32,8 +32,6 @@ fn main() -> Result<(), impl std::error::Error> {
|
||||||
let mut modifiers = ModifiersState::default();
|
let mut modifiers = ModifiersState::default();
|
||||||
|
|
||||||
event_loop.run(move |event, elwt| {
|
event_loop.run(move |event, elwt| {
|
||||||
elwt.set_control_flow(ControlFlow::Wait);
|
|
||||||
|
|
||||||
if let Event::WindowEvent { event, .. } = event {
|
if let Event::WindowEvent { event, .. } = event {
|
||||||
match event {
|
match event {
|
||||||
WindowEvent::CloseRequested => elwt.exit(),
|
WindowEvent::CloseRequested => elwt.exit(),
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
use simple_logger::SimpleLogger;
|
use simple_logger::SimpleLogger;
|
||||||
use winit::{
|
use winit::{
|
||||||
event::{Event, WindowEvent},
|
event::{Event, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::EventLoop,
|
||||||
window::WindowBuilder,
|
window::WindowBuilder,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -35,8 +35,6 @@ In other words, the deltas indicate the direction in which to move the content (
|
||||||
);
|
);
|
||||||
|
|
||||||
event_loop.run(move |event, elwt| {
|
event_loop.run(move |event, elwt| {
|
||||||
elwt.set_control_flow(ControlFlow::Wait);
|
|
||||||
|
|
||||||
if let Event::WindowEvent { event, .. } = event {
|
if let Event::WindowEvent { event, .. } = event {
|
||||||
match event {
|
match event {
|
||||||
WindowEvent::CloseRequested => elwt.exit(),
|
WindowEvent::CloseRequested => elwt.exit(),
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ fn main() -> Result<(), impl std::error::Error> {
|
||||||
use winit::{
|
use winit::{
|
||||||
dpi::{PhysicalPosition, PhysicalSize, Position, Size},
|
dpi::{PhysicalPosition, PhysicalSize, Position, Size},
|
||||||
event::{ElementState, Event, KeyEvent, WindowEvent},
|
event::{ElementState, Event, KeyEvent, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::EventLoop,
|
||||||
keyboard::{Key, ModifiersState},
|
keyboard::{Key, ModifiersState},
|
||||||
window::{CursorGrabMode, CursorIcon, Fullscreen, WindowBuilder, WindowLevel},
|
window::{CursorGrabMode, CursorIcon, Fullscreen, WindowBuilder, WindowLevel},
|
||||||
};
|
};
|
||||||
|
|
@ -174,10 +174,9 @@ fn main() -> Result<(), impl std::error::Error> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
event_loop.run(move |event, elwt| {
|
event_loop.run(move |event, elwt| {
|
||||||
match !window_senders.is_empty() {
|
if window_senders.is_empty() {
|
||||||
true => elwt.set_control_flow(ControlFlow::Wait),
|
elwt.exit()
|
||||||
false => elwt.exit(),
|
}
|
||||||
};
|
|
||||||
match event {
|
match event {
|
||||||
Event::WindowEvent { event, window_id } => match event {
|
Event::WindowEvent { event, window_id } => match event {
|
||||||
WindowEvent::CloseRequested
|
WindowEvent::CloseRequested
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use std::collections::HashMap;
|
||||||
use simple_logger::SimpleLogger;
|
use simple_logger::SimpleLogger;
|
||||||
use winit::{
|
use winit::{
|
||||||
event::{ElementState, Event, KeyEvent, WindowEvent},
|
event::{ElementState, Event, KeyEvent, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::EventLoop,
|
||||||
keyboard::Key,
|
keyboard::Key,
|
||||||
window::Window,
|
window::Window,
|
||||||
};
|
};
|
||||||
|
|
@ -27,8 +27,6 @@ fn main() -> Result<(), impl std::error::Error> {
|
||||||
println!("Press N to open a new window.");
|
println!("Press N to open a new window.");
|
||||||
|
|
||||||
event_loop.run(move |event, elwt| {
|
event_loop.run(move |event, elwt| {
|
||||||
elwt.set_control_flow(ControlFlow::Wait);
|
|
||||||
|
|
||||||
if let Event::WindowEvent { event, window_id } = event {
|
if let Event::WindowEvent { event, window_id } = event {
|
||||||
match event {
|
match event {
|
||||||
WindowEvent::CloseRequested => {
|
WindowEvent::CloseRequested => {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
use simple_logger::SimpleLogger;
|
use simple_logger::SimpleLogger;
|
||||||
use winit::{
|
use winit::{
|
||||||
event::{ElementState, Event, WindowEvent},
|
event::{ElementState, Event, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::EventLoop,
|
||||||
window::WindowBuilder,
|
window::WindowBuilder,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -22,8 +22,6 @@ fn main() -> Result<(), impl std::error::Error> {
|
||||||
event_loop.run(move |event, elwt| {
|
event_loop.run(move |event, elwt| {
|
||||||
println!("{event:?}");
|
println!("{event:?}");
|
||||||
|
|
||||||
elwt.set_control_flow(ControlFlow::Wait);
|
|
||||||
|
|
||||||
if let Event::WindowEvent { event, .. } = event {
|
if let Event::WindowEvent { event, .. } = event {
|
||||||
match event {
|
match event {
|
||||||
WindowEvent::CloseRequested => elwt.exit(),
|
WindowEvent::CloseRequested => elwt.exit(),
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ fn main() -> Result<(), impl std::error::Error> {
|
||||||
use simple_logger::SimpleLogger;
|
use simple_logger::SimpleLogger;
|
||||||
use winit::{
|
use winit::{
|
||||||
event::{Event, WindowEvent},
|
event::{Event, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::EventLoop,
|
||||||
window::WindowBuilder,
|
window::WindowBuilder,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -36,8 +36,6 @@ fn main() -> Result<(), impl std::error::Error> {
|
||||||
event_loop.run(move |event, elwt| {
|
event_loop.run(move |event, elwt| {
|
||||||
println!("{event:?}");
|
println!("{event:?}");
|
||||||
|
|
||||||
elwt.set_control_flow(ControlFlow::Wait);
|
|
||||||
|
|
||||||
match event {
|
match event {
|
||||||
Event::WindowEvent {
|
Event::WindowEvent {
|
||||||
event: WindowEvent::CloseRequested,
|
event: WindowEvent::CloseRequested,
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use simple_logger::SimpleLogger;
|
||||||
use winit::{
|
use winit::{
|
||||||
dpi::LogicalSize,
|
dpi::LogicalSize,
|
||||||
event::{ElementState, Event, KeyEvent, WindowEvent},
|
event::{ElementState, Event, KeyEvent, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::EventLoop,
|
||||||
keyboard::KeyCode,
|
keyboard::KeyCode,
|
||||||
window::WindowBuilder,
|
window::WindowBuilder,
|
||||||
};
|
};
|
||||||
|
|
@ -28,8 +28,6 @@ fn main() -> Result<(), impl std::error::Error> {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
event_loop.run(move |event, elwt| {
|
event_loop.run(move |event, elwt| {
|
||||||
elwt.set_control_flow(ControlFlow::Wait);
|
|
||||||
|
|
||||||
if let Event::WindowEvent { event, .. } = event {
|
if let Event::WindowEvent { event, .. } = event {
|
||||||
match event {
|
match event {
|
||||||
WindowEvent::CloseRequested => elwt.exit(),
|
WindowEvent::CloseRequested => elwt.exit(),
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ mod example {
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
use winit::event::{ElementState, Event, KeyEvent, WindowEvent};
|
use winit::event::{ElementState, Event, KeyEvent, WindowEvent};
|
||||||
use winit::event_loop::{ControlFlow, EventLoop};
|
use winit::event_loop::EventLoop;
|
||||||
use winit::keyboard::Key;
|
use winit::keyboard::Key;
|
||||||
use winit::platform::startup_notify::{
|
use winit::platform::startup_notify::{
|
||||||
EventLoopExtStartupNotify, WindowBuilderExtStartupNotify, WindowExtStartupNotify,
|
EventLoopExtStartupNotify, WindowBuilderExtStartupNotify, WindowExtStartupNotify,
|
||||||
|
|
@ -102,8 +102,6 @@ mod example {
|
||||||
counter += 1;
|
counter += 1;
|
||||||
create_first_window = false;
|
create_first_window = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
elwt.set_control_flow(ControlFlow::Wait);
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
use simple_logger::SimpleLogger;
|
use simple_logger::SimpleLogger;
|
||||||
use winit::{
|
use winit::{
|
||||||
event::{ElementState, Event, KeyEvent, WindowEvent},
|
event::{ElementState, Event, KeyEvent, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::EventLoop,
|
||||||
keyboard::Key,
|
keyboard::Key,
|
||||||
window::{Theme, WindowBuilder},
|
window::{Theme, WindowBuilder},
|
||||||
};
|
};
|
||||||
|
|
@ -28,8 +28,6 @@ fn main() -> Result<(), impl std::error::Error> {
|
||||||
println!(" (D) Dark theme");
|
println!(" (D) Dark theme");
|
||||||
|
|
||||||
event_loop.run(move |event, elwt| {
|
event_loop.run(move |event, elwt| {
|
||||||
elwt.set_control_flow(ControlFlow::Wait);
|
|
||||||
|
|
||||||
if let Event::WindowEvent { window_id, event } = event {
|
if let Event::WindowEvent { window_id, event } = event {
|
||||||
match event {
|
match event {
|
||||||
WindowEvent::CloseRequested => elwt.exit(),
|
WindowEvent::CloseRequested => elwt.exit(),
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use simple_logger::SimpleLogger;
|
use simple_logger::SimpleLogger;
|
||||||
use winit::{
|
use winit::{
|
||||||
event::{Event, WindowEvent},
|
event::{Event, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::EventLoop,
|
||||||
window::WindowBuilder,
|
window::WindowBuilder,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -20,8 +20,6 @@ fn main() -> Result<(), impl std::error::Error> {
|
||||||
println!("Only supported on macOS at the moment.");
|
println!("Only supported on macOS at the moment.");
|
||||||
|
|
||||||
event_loop.run(move |event, elwt| {
|
event_loop.run(move |event, elwt| {
|
||||||
elwt.set_control_flow(ControlFlow::Wait);
|
|
||||||
|
|
||||||
if let Event::WindowEvent { event, .. } = event {
|
if let Event::WindowEvent { event, .. } = event {
|
||||||
match event {
|
match event {
|
||||||
WindowEvent::CloseRequested => elwt.exit(),
|
WindowEvent::CloseRequested => elwt.exit(),
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
use simple_logger::SimpleLogger;
|
use simple_logger::SimpleLogger;
|
||||||
use winit::{
|
use winit::{
|
||||||
event::{Event, WindowEvent},
|
event::{Event, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::EventLoop,
|
||||||
window::WindowBuilder,
|
window::WindowBuilder,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -23,7 +23,6 @@ fn main() -> Result<(), impl std::error::Error> {
|
||||||
window.set_title("A fantastic window!");
|
window.set_title("A fantastic window!");
|
||||||
|
|
||||||
event_loop.run(move |event, elwt| {
|
event_loop.run(move |event, elwt| {
|
||||||
elwt.set_control_flow(ControlFlow::Wait);
|
|
||||||
println!("{event:?}");
|
println!("{event:?}");
|
||||||
|
|
||||||
if let Event::WindowEvent { event, .. } = event {
|
if let Event::WindowEvent { event, .. } = event {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use winit::{
|
use winit::{
|
||||||
event::{ElementState, Event, KeyEvent, WindowEvent},
|
event::{ElementState, Event, KeyEvent, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::EventLoop,
|
||||||
keyboard::KeyCode,
|
keyboard::KeyCode,
|
||||||
window::{Fullscreen, WindowBuilder},
|
window::{Fullscreen, WindowBuilder},
|
||||||
};
|
};
|
||||||
|
|
@ -22,8 +22,6 @@ pub fn main() -> Result<(), impl std::error::Error> {
|
||||||
let log_list = wasm::insert_canvas_and_create_log_list(&window);
|
let log_list = wasm::insert_canvas_and_create_log_list(&window);
|
||||||
|
|
||||||
event_loop.run(move |event, elwt| {
|
event_loop.run(move |event, elwt| {
|
||||||
elwt.set_control_flow(ControlFlow::Wait);
|
|
||||||
|
|
||||||
#[cfg(wasm_platform)]
|
#[cfg(wasm_platform)]
|
||||||
wasm::log_event(&log_list, &event);
|
wasm::log_event(&log_list, &event);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ mod wasm {
|
||||||
use winit::{
|
use winit::{
|
||||||
dpi::PhysicalSize,
|
dpi::PhysicalSize,
|
||||||
event::{Event, WindowEvent},
|
event::{Event, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::EventLoop,
|
||||||
platform::web::WindowBuilderExtWebSys,
|
platform::web::WindowBuilderExtWebSys,
|
||||||
window::{Window, WindowBuilder},
|
window::{Window, WindowBuilder},
|
||||||
};
|
};
|
||||||
|
|
@ -47,10 +47,7 @@ This example demonstrates the desired future functionality which will possibly b
|
||||||
// Render once with the size info we currently have
|
// Render once with the size info we currently have
|
||||||
render_circle(&canvas, window.inner_size());
|
render_circle(&canvas, window.inner_size());
|
||||||
|
|
||||||
let _ = event_loop.run(move |event, elwt| {
|
let _ = event_loop.run(move |event, _| match event {
|
||||||
elwt.set_control_flow(ControlFlow::Wait);
|
|
||||||
|
|
||||||
match event {
|
|
||||||
Event::WindowEvent {
|
Event::WindowEvent {
|
||||||
event: WindowEvent::Resized(resize),
|
event: WindowEvent::Resized(resize),
|
||||||
window_id,
|
window_id,
|
||||||
|
|
@ -58,7 +55,6 @@ This example demonstrates the desired future functionality which will possibly b
|
||||||
render_circle(&canvas, resize);
|
render_circle(&canvas, resize);
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
use simple_logger::SimpleLogger;
|
use simple_logger::SimpleLogger;
|
||||||
use winit::{
|
use winit::{
|
||||||
event::{Event, WindowEvent},
|
event::{Event, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::EventLoop,
|
||||||
window::WindowBuilder,
|
window::WindowBuilder,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -21,7 +21,6 @@ fn main() -> Result<(), impl std::error::Error> {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
event_loop.run(move |event, elwt| {
|
event_loop.run(move |event, elwt| {
|
||||||
elwt.set_control_flow(ControlFlow::Wait);
|
|
||||||
println!("{event:?}");
|
println!("{event:?}");
|
||||||
|
|
||||||
match event {
|
match event {
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use simple_logger::SimpleLogger;
|
||||||
use winit::{
|
use winit::{
|
||||||
dpi::LogicalSize,
|
dpi::LogicalSize,
|
||||||
event::{ElementState, Event, KeyEvent, WindowEvent},
|
event::{ElementState, Event, KeyEvent, WindowEvent},
|
||||||
event_loop::{ControlFlow, DeviceEvents, EventLoop},
|
event_loop::{DeviceEvents, EventLoop},
|
||||||
keyboard::Key,
|
keyboard::Key,
|
||||||
window::{WindowBuilder, WindowButtons},
|
window::{WindowBuilder, WindowButtons},
|
||||||
};
|
};
|
||||||
|
|
@ -32,8 +32,6 @@ fn main() -> Result<(), impl std::error::Error> {
|
||||||
event_loop.listen_device_events(DeviceEvents::Always);
|
event_loop.listen_device_events(DeviceEvents::Always);
|
||||||
|
|
||||||
event_loop.run(move |event, elwt| {
|
event_loop.run(move |event, elwt| {
|
||||||
elwt.set_control_flow(ControlFlow::Wait);
|
|
||||||
|
|
||||||
if let Event::WindowEvent { window_id, event } = event {
|
if let Event::WindowEvent { window_id, event } = event {
|
||||||
match event {
|
match event {
|
||||||
WindowEvent::KeyboardInput {
|
WindowEvent::KeyboardInput {
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use simple_logger::SimpleLogger;
|
||||||
use winit::{
|
use winit::{
|
||||||
dpi::{LogicalSize, PhysicalSize},
|
dpi::{LogicalSize, PhysicalSize},
|
||||||
event::{DeviceEvent, ElementState, Event, KeyEvent, RawKeyEvent, WindowEvent},
|
event::{DeviceEvent, ElementState, Event, KeyEvent, RawKeyEvent, WindowEvent},
|
||||||
event_loop::{ControlFlow, DeviceEvents, EventLoop},
|
event_loop::{DeviceEvents, EventLoop},
|
||||||
keyboard::{Key, KeyCode},
|
keyboard::{Key, KeyCode},
|
||||||
window::{Fullscreen, WindowBuilder},
|
window::{Fullscreen, WindowBuilder},
|
||||||
};
|
};
|
||||||
|
|
@ -39,8 +39,6 @@ fn main() -> Result<(), impl std::error::Error> {
|
||||||
event_loop.listen_device_events(DeviceEvents::Always);
|
event_loop.listen_device_events(DeviceEvents::Always);
|
||||||
|
|
||||||
event_loop.run(move |event, elwt| {
|
event_loop.run(move |event, elwt| {
|
||||||
elwt.set_control_flow(ControlFlow::Wait);
|
|
||||||
|
|
||||||
match event {
|
match event {
|
||||||
// This used to use the virtual key, but the new API
|
// This used to use the virtual key, but the new API
|
||||||
// only provides the `physical_key` (`Code`).
|
// only provides the `physical_key` (`Code`).
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use std::path::Path;
|
||||||
use simple_logger::SimpleLogger;
|
use simple_logger::SimpleLogger;
|
||||||
use winit::{
|
use winit::{
|
||||||
event::{Event, WindowEvent},
|
event::{Event, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::EventLoop,
|
||||||
window::{Icon, WindowBuilder},
|
window::{Icon, WindowBuilder},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -34,8 +34,6 @@ fn main() -> Result<(), impl std::error::Error> {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
event_loop.run(move |event, elwt| {
|
event_loop.run(move |event, elwt| {
|
||||||
elwt.set_control_flow(ControlFlow::Wait);
|
|
||||||
|
|
||||||
if let Event::WindowEvent { event, .. } = event {
|
if let Event::WindowEvent { event, .. } = event {
|
||||||
match event {
|
match event {
|
||||||
WindowEvent::CloseRequested => elwt.exit(),
|
WindowEvent::CloseRequested => elwt.exit(),
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ fn main() -> Result<(), impl std::error::Error> {
|
||||||
use winit::{
|
use winit::{
|
||||||
error::EventLoopError,
|
error::EventLoopError,
|
||||||
event::{Event, WindowEvent},
|
event::{Event, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::EventLoop,
|
||||||
platform::run_ondemand::EventLoopExtRunOnDemand,
|
platform::run_ondemand::EventLoopExtRunOnDemand,
|
||||||
window::{Window, WindowBuilder, WindowId},
|
window::{Window, WindowBuilder, WindowId},
|
||||||
};
|
};
|
||||||
|
|
@ -31,7 +31,6 @@ fn main() -> Result<(), impl std::error::Error> {
|
||||||
let mut app = App::default();
|
let mut app = App::default();
|
||||||
|
|
||||||
event_loop.run_ondemand(move |event, elwt| {
|
event_loop.run_ondemand(move |event, elwt| {
|
||||||
elwt.set_control_flow(ControlFlow::Wait);
|
|
||||||
println!("Run {idx}: {:?}", event);
|
println!("Run {idx}: {:?}", event);
|
||||||
|
|
||||||
if let Some(window) = &app.window {
|
if let Some(window) = &app.window {
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use winit::platform::macos::{OptionAsAlt, WindowExtMacOS};
|
||||||
use winit::{
|
use winit::{
|
||||||
event::ElementState,
|
event::ElementState,
|
||||||
event::{Event, MouseButton, WindowEvent},
|
event::{Event, MouseButton, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::EventLoop,
|
||||||
window::WindowBuilder,
|
window::WindowBuilder,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -31,10 +31,7 @@ fn main() -> Result<(), impl std::error::Error> {
|
||||||
|
|
||||||
let mut option_as_alt = window.option_as_alt();
|
let mut option_as_alt = window.option_as_alt();
|
||||||
|
|
||||||
event_loop.run(move |event, elwt| {
|
event_loop.run(move |event, elwt| match event {
|
||||||
elwt.set_control_flow(ControlFlow::Wait);
|
|
||||||
|
|
||||||
match event {
|
|
||||||
Event::WindowEvent {
|
Event::WindowEvent {
|
||||||
event: WindowEvent::CloseRequested,
|
event: WindowEvent::CloseRequested,
|
||||||
window_id,
|
window_id,
|
||||||
|
|
@ -66,7 +63,6 @@ fn main() -> Result<(), impl std::error::Error> {
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ fn main() -> std::process::ExitCode {
|
||||||
use simple_logger::SimpleLogger;
|
use simple_logger::SimpleLogger;
|
||||||
use winit::{
|
use winit::{
|
||||||
event::{Event, WindowEvent},
|
event::{Event, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::EventLoop,
|
||||||
platform::pump_events::{EventLoopExtPumpEvents, PumpStatus},
|
platform::pump_events::{EventLoopExtPumpEvents, PumpStatus},
|
||||||
window::WindowBuilder,
|
window::WindowBuilder,
|
||||||
};
|
};
|
||||||
|
|
@ -33,8 +33,6 @@ fn main() -> std::process::ExitCode {
|
||||||
'main: loop {
|
'main: loop {
|
||||||
let timeout = Some(Duration::ZERO);
|
let timeout = Some(Duration::ZERO);
|
||||||
let status = event_loop.pump_events(timeout, |event, elwt| {
|
let status = event_loop.pump_events(timeout, |event, elwt| {
|
||||||
elwt.set_control_flow(ControlFlow::Wait);
|
|
||||||
|
|
||||||
if let Event::WindowEvent { event, .. } = &event {
|
if let Event::WindowEvent { event, .. } = &event {
|
||||||
// Print only Window events to reduce noise
|
// Print only Window events to reduce noise
|
||||||
println!("{event:?}");
|
println!("{event:?}");
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ use simple_logger::SimpleLogger;
|
||||||
use winit::{
|
use winit::{
|
||||||
dpi::LogicalSize,
|
dpi::LogicalSize,
|
||||||
event::{ElementState, Event, KeyEvent, WindowEvent},
|
event::{ElementState, Event, KeyEvent, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::EventLoop,
|
||||||
keyboard::Key,
|
keyboard::Key,
|
||||||
window::WindowBuilder,
|
window::WindowBuilder,
|
||||||
};
|
};
|
||||||
|
|
@ -24,10 +24,7 @@ fn main() -> Result<(), impl std::error::Error> {
|
||||||
|
|
||||||
let mut has_increments = true;
|
let mut has_increments = true;
|
||||||
|
|
||||||
event_loop.run(move |event, elwt| {
|
event_loop.run(move |event, elwt| match event {
|
||||||
elwt.set_control_flow(ControlFlow::Wait);
|
|
||||||
|
|
||||||
match event {
|
|
||||||
Event::WindowEvent { event, window_id } if window_id == window.id() => match event {
|
Event::WindowEvent { event, window_id } if window_id == window.id() => match event {
|
||||||
WindowEvent::CloseRequested => elwt.exit(),
|
WindowEvent::CloseRequested => elwt.exit(),
|
||||||
WindowEvent::KeyboardInput {
|
WindowEvent::KeyboardInput {
|
||||||
|
|
@ -56,6 +53,5 @@ fn main() -> Result<(), impl std::error::Error> {
|
||||||
Event::AboutToWait => window.request_redraw(),
|
Event::AboutToWait => window.request_redraw(),
|
||||||
|
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ use simple_logger::SimpleLogger;
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
use winit::{
|
use winit::{
|
||||||
event::{ElementState, Event, KeyEvent, WindowEvent},
|
event::{ElementState, Event, KeyEvent, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::EventLoop,
|
||||||
keyboard::Key,
|
keyboard::Key,
|
||||||
platform::macos::{WindowBuilderExtMacOS, WindowExtMacOS},
|
platform::macos::{WindowBuilderExtMacOS, WindowExtMacOS},
|
||||||
window::{Window, WindowBuilder},
|
window::{Window, WindowBuilder},
|
||||||
|
|
@ -31,8 +31,6 @@ fn main() -> Result<(), impl std::error::Error> {
|
||||||
println!("Press N to open a new window.");
|
println!("Press N to open a new window.");
|
||||||
|
|
||||||
event_loop.run(move |event, elwt| {
|
event_loop.run(move |event, elwt| {
|
||||||
elwt.set_control_flow(ControlFlow::Wait);
|
|
||||||
|
|
||||||
if let Event::WindowEvent { event, window_id } = event {
|
if let Event::WindowEvent { event, window_id } = event {
|
||||||
match event {
|
match event {
|
||||||
WindowEvent::CloseRequested => {
|
WindowEvent::CloseRequested => {
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ mod imple {
|
||||||
use simple_logger::SimpleLogger;
|
use simple_logger::SimpleLogger;
|
||||||
use winit::{
|
use winit::{
|
||||||
event::{Event, WindowEvent},
|
event::{Event, WindowEvent},
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::EventLoop,
|
||||||
platform::x11::WindowBuilderExtX11,
|
platform::x11::WindowBuilderExtX11,
|
||||||
window::WindowBuilder,
|
window::WindowBuilder,
|
||||||
};
|
};
|
||||||
|
|
@ -33,8 +33,6 @@ mod imple {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
event_loop.run(move |event, elwt| {
|
event_loop.run(move |event, elwt| {
|
||||||
elwt.set_control_flow(ControlFlow::Wait);
|
|
||||||
|
|
||||||
match event {
|
match event {
|
||||||
Event::WindowEvent {
|
Event::WindowEvent {
|
||||||
event: WindowEvent::CloseRequested,
|
event: WindowEvent::CloseRequested,
|
||||||
|
|
|
||||||
|
|
@ -151,16 +151,17 @@ impl<T> fmt::Debug for EventLoopWindowTarget<T> {
|
||||||
///
|
///
|
||||||
/// Indicates the desired behavior of the event loop after [`Event::AboutToWait`] is emitted.
|
/// Indicates the desired behavior of the event loop after [`Event::AboutToWait`] is emitted.
|
||||||
///
|
///
|
||||||
/// Defaults to [`Poll`].
|
/// Defaults to [`Wait`].
|
||||||
///
|
///
|
||||||
/// [`Poll`]: Self::Poll
|
/// [`Wait`]: Self::Wait
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
|
||||||
pub enum ControlFlow {
|
pub enum ControlFlow {
|
||||||
/// When the current loop iteration finishes, immediately begin a new iteration regardless of
|
/// When the current loop iteration finishes, immediately begin a new iteration regardless of
|
||||||
/// whether or not new events are available to process.
|
/// whether or not new events are available to process.
|
||||||
Poll,
|
Poll,
|
||||||
|
|
||||||
/// When the current loop iteration finishes, suspend the thread until another event arrives.
|
/// When the current loop iteration finishes, suspend the thread until another event arrives.
|
||||||
|
#[default]
|
||||||
Wait,
|
Wait,
|
||||||
|
|
||||||
/// When the current loop iteration finishes, suspend the thread until either another event
|
/// 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<()> {
|
impl EventLoop<()> {
|
||||||
/// Alias for [`EventLoopBuilder::new().build()`].
|
/// Alias for [`EventLoopBuilder::new().build()`].
|
||||||
///
|
///
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ pub use raw_window_handle;
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// use winit::{
|
/// use winit::{
|
||||||
/// event::{Event, WindowEvent},
|
/// event::{Event, WindowEvent},
|
||||||
/// event_loop::{ControlFlow, EventLoop},
|
/// event_loop::EventLoop,
|
||||||
/// window::Window,
|
/// window::Window,
|
||||||
/// };
|
/// };
|
||||||
///
|
///
|
||||||
|
|
@ -48,8 +48,6 @@ pub use raw_window_handle;
|
||||||
/// let window = Window::new(&event_loop).unwrap();
|
/// let window = Window::new(&event_loop).unwrap();
|
||||||
///
|
///
|
||||||
/// event_loop.run(move |event, elwt| {
|
/// event_loop.run(move |event, elwt| {
|
||||||
/// elwt.set_control_flow(ControlFlow::Wait);
|
|
||||||
///
|
|
||||||
/// match event {
|
/// match event {
|
||||||
/// Event::WindowEvent {
|
/// Event::WindowEvent {
|
||||||
/// event: WindowEvent::CloseRequested,
|
/// event: WindowEvent::CloseRequested,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue