From 04ccad1dbcca13cad951dc966d84bd221d61308e Mon Sep 17 00:00:00 2001 From: mitchmindtree Date: Tue, 20 Jun 2017 21:25:53 +1000 Subject: [PATCH] Rename ControlFlow variant from Complete to Break --- examples/cursor.rs | 2 +- examples/fullscreen.rs | 4 ++-- examples/grabbing.rs | 2 +- examples/min_max_size.rs | 2 +- examples/multiwindow.rs | 2 +- examples/proxy.rs | 2 +- examples/transparent.rs | 2 +- examples/window.rs | 2 +- src/api_transition.rs | 6 +++--- src/lib.rs | 10 +++++----- src/platform/linux/wayland/event_loop.rs | 6 +++--- src/platform/linux/x11/mod.rs | 8 ++++---- src/platform/macos/events_loop.rs | 8 ++++---- 13 files changed, 28 insertions(+), 28 deletions(-) diff --git a/examples/cursor.rs b/examples/cursor.rs index cd979b99..bc7deea6 100644 --- a/examples/cursor.rs +++ b/examples/cursor.rs @@ -23,7 +23,7 @@ fn main() { } }, Event::WindowEvent { event: WindowEvent::Closed, .. } => { - return ControlFlow::Complete; + return ControlFlow::Break; }, _ => () } diff --git a/examples/fullscreen.rs b/examples/fullscreen.rs index 921caa61..6f2f118a 100644 --- a/examples/fullscreen.rs +++ b/examples/fullscreen.rs @@ -37,10 +37,10 @@ fn main() { match event { Event::WindowEvent { event, .. } => { match event { - WindowEvent::Closed => return ControlFlow::Complete, + WindowEvent::Closed => return ControlFlow::Break, WindowEvent::KeyboardInput { input: winit::KeyboardInput { virtual_keycode: Some(winit::VirtualKeyCode::Escape), .. }, .. - } => return ControlFlow::Complete, + } => return ControlFlow::Break, _ => () } }, diff --git a/examples/grabbing.rs b/examples/grabbing.rs index fc6b7d7c..f7e7c9b3 100644 --- a/examples/grabbing.rs +++ b/examples/grabbing.rs @@ -28,7 +28,7 @@ fn main() { } }, - WindowEvent::Closed => return ControlFlow::Complete, + WindowEvent::Closed => return ControlFlow::Break, a @ WindowEvent::MouseMoved { .. } => { println!("{:?}", a); diff --git a/examples/min_max_size.rs b/examples/min_max_size.rs index 54f03da7..7500e893 100644 --- a/examples/min_max_size.rs +++ b/examples/min_max_size.rs @@ -13,7 +13,7 @@ fn main() { println!("{:?}", 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, } }); diff --git a/examples/multiwindow.rs b/examples/multiwindow.rs index 28f9955f..9c5b93b8 100644 --- a/examples/multiwindow.rs +++ b/examples/multiwindow.rs @@ -24,7 +24,7 @@ fn main() { num_windows -= 1; if num_windows == 0 { - return winit::ControlFlow::Complete; + return winit::ControlFlow::Break; } }, _ => (), diff --git a/examples/proxy.rs b/examples/proxy.rs index 8741d775..338c4675 100644 --- a/examples/proxy.rs +++ b/examples/proxy.rs @@ -22,7 +22,7 @@ fn main() { println!("{:?}", event); match event { winit::Event::WindowEvent { event: winit::WindowEvent::Closed, .. } => - winit::ControlFlow::Complete, + winit::ControlFlow::Break, _ => winit::ControlFlow::Continue, } }); diff --git a/examples/transparent.rs b/examples/transparent.rs index da9a80e7..de633175 100644 --- a/examples/transparent.rs +++ b/examples/transparent.rs @@ -13,7 +13,7 @@ fn main() { println!("{:?}", 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, } }); diff --git a/examples/window.rs b/examples/window.rs index fd5ef6e9..65f0ade2 100644 --- a/examples/window.rs +++ b/examples/window.rs @@ -13,7 +13,7 @@ fn main() { match event { winit::Event::WindowEvent { event: winit::WindowEvent::Closed, .. } => { - winit::ControlFlow::Complete + winit::ControlFlow::Break }, _ => winit::ControlFlow::Continue, } diff --git a/src/api_transition.rs b/src/api_transition.rs index 34448801..158c6d44 100644 --- a/src/api_transition.rs +++ b/src/api_transition.rs @@ -52,11 +52,11 @@ macro_rules! gen_api_transition { loop { let mut control_flow = ::ControlFlow::Continue; self.poll_events(|e| { - if let ::ControlFlow::Complete = callback(e) { - control_flow = ::ControlFlow::Complete; + if let ::ControlFlow::Break = callback(e) { + control_flow = ::ControlFlow::Break; } }); - if let ::ControlFlow::Complete = control_flow { + if let ::ControlFlow::Break = control_flow { break; } ::std::thread::sleep(::std::time::Duration::from_millis(5)); diff --git a/src/lib.rs b/src/lib.rs index 74d3c5a8..d4b91c40 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -51,7 +51,7 @@ //! ``` //! //! 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 //! use winit::{ControlFlow, Event, WindowEvent}; @@ -62,7 +62,7 @@ //! match event { //! Event::WindowEvent { event: WindowEvent::Closed, .. } => { //! println!("The window was closed ; stopping"); -//! ControlFlow::Complete +//! ControlFlow::Break //! }, //! _ => ControlFlow::Continue, //! } @@ -143,7 +143,7 @@ pub mod os; /// events_loop.run_forever(|event| { /// match event { /// Event::WindowEvent { event: WindowEvent::Closed, .. } => { -/// ControlFlow::Complete +/// ControlFlow::Break /// }, /// _ => ControlFlow::Continue, /// } @@ -192,8 +192,8 @@ pub struct EventsLoop { pub enum ControlFlow { /// Continue looping and waiting for events. Continue, - /// Exit from the event loop. - Complete, + /// Break from the event loop. + Break, } impl EventsLoop { diff --git a/src/platform/linux/wayland/event_loop.rs b/src/platform/linux/wayland/event_loop.rs index f2b1325e..703562b6 100644 --- a/src/platform/linux/wayland/event_loop.rs +++ b/src/platform/linux/wayland/event_loop.rs @@ -226,8 +226,8 @@ impl EventsLoop { // Check for control flow by wrapping the callback. let control_flow = ::std::cell::Cell::new(ControlFlow::Continue); - let callback = |event| if let ControlFlow::Complete = callback(event) { - control_flow.set(ControlFlow::Complete); + let callback = |event| if let ControlFlow::Break = callback(event) { + control_flow.set(ControlFlow::Break); }; // set the callback into the sink @@ -251,7 +251,7 @@ impl EventsLoop { self.prune_dead_windows() } - if let ControlFlow::Complete = control_flow.get() { + if let ControlFlow::Break = control_flow.get() { break; } } diff --git a/src/platform/linux/x11/mod.rs b/src/platform/linux/x11/mod.rs index 151c9e0c..7b8f6bd7 100644 --- a/src/platform/linux/x11/mod.rs +++ b/src/platform/linux/x11/mod.rs @@ -163,18 +163,18 @@ impl EventsLoop { 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| { - if let ControlFlow::Complete = callback(event) { - control_flow = ControlFlow::Complete; + if let ControlFlow::Break = callback(event) { + control_flow = ControlFlow::Break; } }; self.process_event(&mut xev, &mut cb); } - if let ControlFlow::Complete = control_flow { + if let ControlFlow::Break = control_flow { break; } } diff --git a/src/platform/macos/events_loop.rs b/src/platform/macos/events_loop.rs index c11321cd..52130bbe 100644 --- a/src/platform/macos/events_loop.rs +++ b/src/platform/macos/events_loop.rs @@ -222,8 +222,8 @@ impl EventsLoop { let control_flow = std::cell::Cell::new(ControlFlow::Continue); let mut callback = |event| { - if let ControlFlow::Complete = callback(event) { - control_flow.set(ControlFlow::Complete); + if let ControlFlow::Break = callback(event) { + control_flow.set(ControlFlow::Break); } }; @@ -233,7 +233,7 @@ impl EventsLoop { unsafe { // First, yield all 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; } @@ -254,7 +254,7 @@ impl EventsLoop { if let Some(event) = maybe_event { self.shared.user_callback.call_with_event(event); - if let ControlFlow::Complete = control_flow.get() { + if let ControlFlow::Break = control_flow.get() { break; } }