Skip to content

Commit

Permalink
Address review
Browse files Browse the repository at this point in the history
  • Loading branch information
daxpedda committed Sep 4, 2023
1 parent f2659d6 commit cc6d8d8
Show file tree
Hide file tree
Showing 16 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ And please only add new entries to the top of this list, right below the `# Unre
- Mark `startup_notify` unsafe functions as safe.
- Fix a bug where Wayland would be chosen on Linux even if the user specified `with_x11`. (#3058)
- **Breaking:** Moved `ControlFlow` to `EventLoopWindowTarget::set_control_flow()` and `EventLoopWindowTarget::control_flow()`.
- **Breaking:** Moved `ControlFlow::Exit` to `EventLoopWindowTarget::set_exit()` and `EventLoopWindowTarget::is_exit()` and removed `ControlFlow::ExitWithCode(_)` entirely.
- **Breaking:** Moved `ControlFlow::Exit` to `EventLoopWindowTarget::set_exit()` and `EventLoopWindowTarget::exiting()` and removed `ControlFlow::ExitWithCode(_)` entirely.

# 0.29.1-beta

Expand Down
2 changes: 1 addition & 1 deletion src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//! ```rust,ignore
//! let mut start_cause = StartCause::Init;
//!
//! while !elwt.is_exit() {
//! while !elwt.exiting() {
//! event_handler(NewEvents(start_cause), elwt);
//!
//! for e in (window events, user events, device events) {
Expand Down
10 changes: 5 additions & 5 deletions src/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ pub enum ControlFlow {
}

impl ControlFlow {
/// Sets this to wait until a timeout has expired.
/// Creates a [`ControlFlow`] that waits until a timeout has expired.
///
/// In most cases, this is set to [`WaitUntil`]. However, if the timeout overflows, it is
/// instead set to [`Wait`].
Expand Down Expand Up @@ -320,18 +320,18 @@ impl<T> EventLoopWindowTarget<T> {
self.p.control_flow()
}

/// Send a [`LoopExiting`] event and stop the event loop.
/// This exits the event loop.
///
/// [`LoopExiting`]: Event::LoopExiting
/// See [`LoopExiting`](Event::LoopExiting).
pub fn exit(&self) {
self.p.exit()
}

/// Returns if the [`EventLoop`] is about to stop.
///
/// See [`exit()`](Self::exit).
pub fn is_exit(&self) -> bool {
self.p.is_exit()
pub fn exiting(&self) -> bool {
self.p.exiting()
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/platform_impl/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,10 +534,10 @@ impl<T: 'static> EventLoop<T> {

// Consider the possibility that the `StartCause::Init` iteration could
// request to Exit
if !self.is_exit() {
if !self.exiting() {
self.poll_events_with_timeout(timeout, &mut callback);
}
if self.is_exit() {
if self.exiting() {
self.loop_running = false;

callback(event::Event::LoopExiting, self.window_target());
Expand Down Expand Up @@ -645,8 +645,8 @@ impl<T: 'static> EventLoop<T> {
self.window_target.p.control_flow()
}

fn is_exit(&self) -> bool {
self.window_target.p.is_exit()
fn exiting(&self) -> bool {
self.window_target.p.exiting()
}
}

Expand Down Expand Up @@ -712,7 +712,7 @@ impl<T: 'static> EventLoopWindowTarget<T> {
self.exit.set(true)
}

pub(crate) fn is_exit(&self) -> bool {
pub(crate) fn exiting(&self) -> bool {
self.exit.get()
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/platform_impl/ios/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl<T: 'static> EventLoopWindowTarget<T> {
warn!("`ControlFlow::Exit` ignored on iOS");
}

pub(crate) fn is_exit(&self) -> bool {
pub(crate) fn exiting(&self) -> bool {
false
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/platform_impl/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -858,8 +858,8 @@ impl<T> EventLoopWindowTarget<T> {
x11_or_wayland!(match self; Self(evlp) => evlp.exit())
}

pub(crate) fn is_exit(&self) -> bool {
x11_or_wayland!(match self; Self(evlp) => evlp.is_exit())
pub(crate) fn exiting(&self) -> bool {
x11_or_wayland!(match self; Self(evlp) => evlp.exiting())
}

fn set_exit_code(&self, code: i32) {
Expand Down
6 changes: 3 additions & 3 deletions src/platform_impl/linux/wayland/event_loop/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ impl<T: 'static> EventLoop<T> {

// Consider the possibility that the `StartCause::Init` iteration could
// request to Exit.
if !self.is_exit() {
if !self.exiting() {
self.poll_events_with_timeout(timeout, &mut callback);
}
if let Some(code) = self.exit_code() {
Expand Down Expand Up @@ -619,8 +619,8 @@ impl<T: 'static> EventLoop<T> {
self.window_target.p.control_flow()
}

fn is_exit(&self) -> bool {
self.window_target.p.is_exit()
fn exiting(&self) -> bool {
self.window_target.p.exiting()
}

fn set_exit_code(&self, code: i32) {
Expand Down
2 changes: 1 addition & 1 deletion src/platform_impl/linux/wayland/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl<T> EventLoopWindowTarget<T> {
self.exit.set(Some(0))
}

pub(crate) fn is_exit(&self) -> bool {
pub(crate) fn exiting(&self) -> bool {
self.exit.get().is_some()
}

Expand Down
8 changes: 4 additions & 4 deletions src/platform_impl/linux/x11/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ impl<T: 'static> EventLoop<T> {

// Consider the possibility that the `StartCause::Init` iteration could
// request to Exit.
if !self.is_exit() {
if !self.exiting() {
self.poll_events_with_timeout(timeout, &mut callback);
}
if let Some(code) = self.exit_code() {
Expand Down Expand Up @@ -649,8 +649,8 @@ impl<T: 'static> EventLoop<T> {
self.target.p.control_flow()
}

fn is_exit(&self) -> bool {
self.target.p.is_exit()
fn exiting(&self) -> bool {
self.target.p.exiting()
}

fn set_exit_code(&self, code: i32) {
Expand Down Expand Up @@ -727,7 +727,7 @@ impl<T> EventLoopWindowTarget<T> {
self.exit.set(Some(0))
}

pub(crate) fn is_exit(&self) -> bool {
pub(crate) fn exiting(&self) -> bool {
self.exit.get().is_some()
}

Expand Down
8 changes: 4 additions & 4 deletions src/platform_impl/macos/app_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ impl Handler {
self.exit.store(true, Ordering::Relaxed)
}

pub fn is_exit(&self) -> bool {
pub fn exiting(&self) -> bool {
self.exit.load(Ordering::Relaxed)
}

Expand Down Expand Up @@ -429,8 +429,8 @@ impl AppState {
HANDLER.exit()
}

pub fn is_exit() -> bool {
HANDLER.is_exit()
pub fn exiting() -> bool {
HANDLER.exiting()
}

pub fn dispatch_init_events() {
Expand Down Expand Up @@ -640,7 +640,7 @@ impl AppState {
HANDLER.handle_nonuser_event(Event::AboutToWait);
HANDLER.set_in_callback(false);

if HANDLER.is_exit() {
if HANDLER.exiting() {
Self::stop();
}

Expand Down
6 changes: 3 additions & 3 deletions src/platform_impl/macos/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ impl<T: 'static> EventLoopWindowTarget<T> {
AppState::exit()
}

pub(crate) fn is_exit(&self) -> bool {
AppState::is_exit()
pub(crate) fn exiting(&self) -> bool {
AppState::exiting()
}
}

Expand Down Expand Up @@ -418,7 +418,7 @@ impl<T> EventLoop<T> {
resume_unwind(panic);
}

if AppState::is_exit() {
if AppState::exiting() {
AppState::internal_exit();
PumpStatus::Exit(0)
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/platform_impl/orbital/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ impl<T: 'static> EventLoop<T> {

event_handler(event::Event::AboutToWait, &self.window_target);

if self.window_target.p.is_exit() {
if self.window_target.p.exiting() {
break;
}

Expand Down Expand Up @@ -752,7 +752,7 @@ impl<T: 'static> EventLoopWindowTarget<T> {
self.exit.set(true);
}

pub(crate) fn is_exit(&self) -> bool {
pub(crate) fn exiting(&self) -> bool {
self.exit.get()
}
}
8 changes: 4 additions & 4 deletions src/platform_impl/web/event_loop/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ impl Shared {
RunnerEnum::Destroyed => return,
}

let is_closed = self.is_exit();
let is_closed = self.exiting();

// Don't take events out of the queue if the loop is closed or the runner doesn't exist
// If the runner doesn't exist and this method recurses, it will recurse infinitely
Expand All @@ -627,7 +627,7 @@ impl Shared {
// Apply the new ControlFlow that has been selected by the user
// Start any necessary timeouts etc
fn apply_control_flow(&self) {
let new_state = if self.is_exit() {
let new_state = if self.exiting() {
State::Exit
} else {
match self.control_flow() {
Expand Down Expand Up @@ -713,7 +713,7 @@ impl Shared {
// Check if the event loop is currently closed
fn is_closed(&self) -> bool {
match self.0.runner.try_borrow().as_ref().map(Deref::deref) {
Ok(RunnerEnum::Running(runner)) => runner.state.is_exit(),
Ok(RunnerEnum::Running(runner)) => runner.state.exiting(),
// The event loop is not closed since it is not initialized.
Ok(RunnerEnum::Pending) => false,
// The event loop is closed since it has been destroyed.
Expand Down Expand Up @@ -766,7 +766,7 @@ impl Shared {
self.0.exit.set(true)
}

pub(crate) fn is_exit(&self) -> bool {
pub(crate) fn exiting(&self) -> bool {
self.0.exit.get()
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/platform_impl/web/event_loop/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub enum State {
}

impl State {
pub fn is_exit(&self) -> bool {
pub fn exiting(&self) -> bool {
matches!(self, State::Exit)
}
}
4 changes: 2 additions & 2 deletions src/platform_impl/web/event_loop/window_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ impl<T> EventLoopWindowTarget<T> {
self.runner.exit()
}

pub(crate) fn is_exit(&self) -> bool {
self.runner.is_exit()
pub(crate) fn exiting(&self) -> bool {
self.runner.exiting()
}
}
2 changes: 1 addition & 1 deletion src/platform_impl/windows/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ impl<T> EventLoopWindowTarget<T> {
self.runner_shared.set_exit_code(0)
}

pub(crate) fn is_exit(&self) -> bool {
pub(crate) fn exiting(&self) -> bool {
self.runner_shared.exit_code().is_some()
}

Expand Down

0 comments on commit cc6d8d8

Please sign in to comment.