mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-23 22:01:31 +11:00
Rename ControlFlow variant from Complete to Break
This commit is contained in:
parent
df1276d72a
commit
04ccad1dbc
|
@ -23,7 +23,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Event::WindowEvent { event: WindowEvent::Closed, .. } => {
|
Event::WindowEvent { event: WindowEvent::Closed, .. } => {
|
||||||
return ControlFlow::Complete;
|
return ControlFlow::Break;
|
||||||
},
|
},
|
||||||
_ => ()
|
_ => ()
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,10 +37,10 @@ fn main() {
|
||||||
match event {
|
match event {
|
||||||
Event::WindowEvent { event, .. } => {
|
Event::WindowEvent { event, .. } => {
|
||||||
match event {
|
match event {
|
||||||
WindowEvent::Closed => return ControlFlow::Complete,
|
WindowEvent::Closed => return ControlFlow::Break,
|
||||||
WindowEvent::KeyboardInput {
|
WindowEvent::KeyboardInput {
|
||||||
input: winit::KeyboardInput { virtual_keycode: Some(winit::VirtualKeyCode::Escape), .. }, ..
|
input: winit::KeyboardInput { virtual_keycode: Some(winit::VirtualKeyCode::Escape), .. }, ..
|
||||||
} => return ControlFlow::Complete,
|
} => return ControlFlow::Break,
|
||||||
_ => ()
|
_ => ()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -28,7 +28,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
WindowEvent::Closed => return ControlFlow::Complete,
|
WindowEvent::Closed => return ControlFlow::Break,
|
||||||
|
|
||||||
a @ WindowEvent::MouseMoved { .. } => {
|
a @ WindowEvent::MouseMoved { .. } => {
|
||||||
println!("{:?}", a);
|
println!("{:?}", a);
|
||||||
|
|
|
@ -13,7 +13,7 @@ fn main() {
|
||||||
println!("{:?}", event);
|
println!("{:?}", event);
|
||||||
|
|
||||||
match event {
|
match event {
|
||||||
winit::Event::WindowEvent { event: winit::WindowEvent::Closed, .. } => winit::ControlFlow::Complete,
|
winit::Event::WindowEvent { event: winit::WindowEvent::Closed, .. } => winit::ControlFlow::Break,
|
||||||
_ => winit::ControlFlow::Continue,
|
_ => winit::ControlFlow::Continue,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -24,7 +24,7 @@ fn main() {
|
||||||
|
|
||||||
num_windows -= 1;
|
num_windows -= 1;
|
||||||
if num_windows == 0 {
|
if num_windows == 0 {
|
||||||
return winit::ControlFlow::Complete;
|
return winit::ControlFlow::Break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => (),
|
_ => (),
|
||||||
|
|
|
@ -22,7 +22,7 @@ fn main() {
|
||||||
println!("{:?}", event);
|
println!("{:?}", event);
|
||||||
match event {
|
match event {
|
||||||
winit::Event::WindowEvent { event: winit::WindowEvent::Closed, .. } =>
|
winit::Event::WindowEvent { event: winit::WindowEvent::Closed, .. } =>
|
||||||
winit::ControlFlow::Complete,
|
winit::ControlFlow::Break,
|
||||||
_ => winit::ControlFlow::Continue,
|
_ => winit::ControlFlow::Continue,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,7 +13,7 @@ fn main() {
|
||||||
println!("{:?}", event);
|
println!("{:?}", event);
|
||||||
|
|
||||||
match event {
|
match event {
|
||||||
winit::Event::WindowEvent { event: winit::WindowEvent::Closed, .. } => winit::ControlFlow::Complete,
|
winit::Event::WindowEvent { event: winit::WindowEvent::Closed, .. } => winit::ControlFlow::Break,
|
||||||
_ => winit::ControlFlow::Continue,
|
_ => winit::ControlFlow::Continue,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,7 +13,7 @@ fn main() {
|
||||||
|
|
||||||
match event {
|
match event {
|
||||||
winit::Event::WindowEvent { event: winit::WindowEvent::Closed, .. } => {
|
winit::Event::WindowEvent { event: winit::WindowEvent::Closed, .. } => {
|
||||||
winit::ControlFlow::Complete
|
winit::ControlFlow::Break
|
||||||
},
|
},
|
||||||
_ => winit::ControlFlow::Continue,
|
_ => winit::ControlFlow::Continue,
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,11 +52,11 @@ macro_rules! gen_api_transition {
|
||||||
loop {
|
loop {
|
||||||
let mut control_flow = ::ControlFlow::Continue;
|
let mut control_flow = ::ControlFlow::Continue;
|
||||||
self.poll_events(|e| {
|
self.poll_events(|e| {
|
||||||
if let ::ControlFlow::Complete = callback(e) {
|
if let ::ControlFlow::Break = callback(e) {
|
||||||
control_flow = ::ControlFlow::Complete;
|
control_flow = ::ControlFlow::Break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if let ::ControlFlow::Complete = control_flow {
|
if let ::ControlFlow::Break = control_flow {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
::std::thread::sleep(::std::time::Duration::from_millis(5));
|
::std::thread::sleep(::std::time::Duration::from_millis(5));
|
||||||
|
|
10
src/lib.rs
10
src/lib.rs
|
@ -51,7 +51,7 @@
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! The second way is to call `events_loop.run_forever(...)`. As its name tells, it will run
|
//! The second way is to call `events_loop.run_forever(...)`. As its name tells, it will run
|
||||||
//! forever unless it is stopped by returning `ControlFlow::Complete`.
|
//! forever unless it is stopped by returning `ControlFlow::Break`.
|
||||||
//!
|
//!
|
||||||
//! ```no_run
|
//! ```no_run
|
||||||
//! use winit::{ControlFlow, Event, WindowEvent};
|
//! use winit::{ControlFlow, Event, WindowEvent};
|
||||||
|
@ -62,7 +62,7 @@
|
||||||
//! match event {
|
//! match event {
|
||||||
//! Event::WindowEvent { event: WindowEvent::Closed, .. } => {
|
//! Event::WindowEvent { event: WindowEvent::Closed, .. } => {
|
||||||
//! println!("The window was closed ; stopping");
|
//! println!("The window was closed ; stopping");
|
||||||
//! ControlFlow::Complete
|
//! ControlFlow::Break
|
||||||
//! },
|
//! },
|
||||||
//! _ => ControlFlow::Continue,
|
//! _ => ControlFlow::Continue,
|
||||||
//! }
|
//! }
|
||||||
|
@ -143,7 +143,7 @@ pub mod os;
|
||||||
/// events_loop.run_forever(|event| {
|
/// events_loop.run_forever(|event| {
|
||||||
/// match event {
|
/// match event {
|
||||||
/// Event::WindowEvent { event: WindowEvent::Closed, .. } => {
|
/// Event::WindowEvent { event: WindowEvent::Closed, .. } => {
|
||||||
/// ControlFlow::Complete
|
/// ControlFlow::Break
|
||||||
/// },
|
/// },
|
||||||
/// _ => ControlFlow::Continue,
|
/// _ => ControlFlow::Continue,
|
||||||
/// }
|
/// }
|
||||||
|
@ -192,8 +192,8 @@ pub struct EventsLoop {
|
||||||
pub enum ControlFlow {
|
pub enum ControlFlow {
|
||||||
/// Continue looping and waiting for events.
|
/// Continue looping and waiting for events.
|
||||||
Continue,
|
Continue,
|
||||||
/// Exit from the event loop.
|
/// Break from the event loop.
|
||||||
Complete,
|
Break,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EventsLoop {
|
impl EventsLoop {
|
||||||
|
|
|
@ -226,8 +226,8 @@ impl EventsLoop {
|
||||||
|
|
||||||
// Check for control flow by wrapping the callback.
|
// Check for control flow by wrapping the callback.
|
||||||
let control_flow = ::std::cell::Cell::new(ControlFlow::Continue);
|
let control_flow = ::std::cell::Cell::new(ControlFlow::Continue);
|
||||||
let callback = |event| if let ControlFlow::Complete = callback(event) {
|
let callback = |event| if let ControlFlow::Break = callback(event) {
|
||||||
control_flow.set(ControlFlow::Complete);
|
control_flow.set(ControlFlow::Break);
|
||||||
};
|
};
|
||||||
|
|
||||||
// set the callback into the sink
|
// set the callback into the sink
|
||||||
|
@ -251,7 +251,7 @@ impl EventsLoop {
|
||||||
self.prune_dead_windows()
|
self.prune_dead_windows()
|
||||||
}
|
}
|
||||||
|
|
||||||
if let ControlFlow::Complete = control_flow.get() {
|
if let ControlFlow::Break = control_flow.get() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,18 +163,18 @@ impl EventsLoop {
|
||||||
|
|
||||||
let mut control_flow = ControlFlow::Continue;
|
let mut control_flow = ControlFlow::Continue;
|
||||||
|
|
||||||
// Track whether or not `Complete` was returned when processing the event.
|
// Track whether or not `Break` was returned when processing the event.
|
||||||
{
|
{
|
||||||
let mut cb = |event| {
|
let mut cb = |event| {
|
||||||
if let ControlFlow::Complete = callback(event) {
|
if let ControlFlow::Break = callback(event) {
|
||||||
control_flow = ControlFlow::Complete;
|
control_flow = ControlFlow::Break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
self.process_event(&mut xev, &mut cb);
|
self.process_event(&mut xev, &mut cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let ControlFlow::Complete = control_flow {
|
if let ControlFlow::Break = control_flow {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,8 +222,8 @@ impl EventsLoop {
|
||||||
let control_flow = std::cell::Cell::new(ControlFlow::Continue);
|
let control_flow = std::cell::Cell::new(ControlFlow::Continue);
|
||||||
|
|
||||||
let mut callback = |event| {
|
let mut callback = |event| {
|
||||||
if let ControlFlow::Complete = callback(event) {
|
if let ControlFlow::Break = callback(event) {
|
||||||
control_flow.set(ControlFlow::Complete);
|
control_flow.set(ControlFlow::Break);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@ impl EventsLoop {
|
||||||
unsafe {
|
unsafe {
|
||||||
// First, yield all pending events.
|
// First, yield all pending events.
|
||||||
self.shared.call_user_callback_with_pending_events();
|
self.shared.call_user_callback_with_pending_events();
|
||||||
if let ControlFlow::Complete = control_flow.get() {
|
if let ControlFlow::Break = control_flow.get() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,7 +254,7 @@ impl EventsLoop {
|
||||||
|
|
||||||
if let Some(event) = maybe_event {
|
if let Some(event) = maybe_event {
|
||||||
self.shared.user_callback.call_with_event(event);
|
self.shared.user_callback.call_with_event(event);
|
||||||
if let ControlFlow::Complete = control_flow.get() {
|
if let ControlFlow::Break = control_flow.get() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue