Skip to content

Commit

Permalink
fix: remove redundant enum variants
Browse files Browse the repository at this point in the history
  • Loading branch information
I-Info committed Feb 21, 2024
1 parent ad48395 commit e703d77
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
14 changes: 5 additions & 9 deletions examples/reopen.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![allow(clippy::single_match)]

// TODO: merge examples
// https://github.com/rust-windowing/winit/pull/3447
use std::collections::HashMap;

use simple_logger::SimpleLogger;
Expand Down Expand Up @@ -47,14 +47,10 @@ fn main() -> Result<(), impl std::error::Error> {
}
_ => (),
}
} else if let Event::Reopen {
has_visible_windows,
} = event
{
println!("Reopen event: has_visible_windows={}", has_visible_windows);
} else if let Event::Reopen = event {
// If there are no visible windows, open a new one.
if !has_visible_windows {
new_window(elwt, &mut windows);
if windows.is_empty() {
new_window(elwt, &mut windows)
}
}
})
Expand Down
8 changes: 2 additions & 6 deletions src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ pub enum Event<T: 'static> {
/// ### Others
///
/// - **Android / iOS / Web / Wayland / Windows / Orbital:** Unsupported.
Reopen { has_visible_windows: bool },
Reopen,
}

impl<T> Event<T> {
Expand All @@ -287,11 +287,7 @@ impl<T> Event<T> {
Suspended => Ok(Suspended),
Resumed => Ok(Resumed),
MemoryWarning => Ok(MemoryWarning),
Reopen {
has_visible_windows,
} => Ok(Reopen {
has_visible_windows,
}),
Reopen => Ok(Reopen),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/platform_impl/macos/app_delegate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ declare_class!(
}

#[method(applicationShouldHandleReopen:hasVisibleWindows:)]
fn should_handle_reopen(&self, _sender: &Option<&AnyObject>, has_visible_windows: bool) -> bool {
fn should_handle_reopen(&self, _sender: &Option<&AnyObject>, _has_visible_windows: bool) -> bool {
trace_scope!("applicationShouldHandleReopen:hasVisibleWindows:");

self.handle_event(Event::Reopen{ has_visible_windows });
self.handle_event(Event::Reopen);
// return true to preserve the default behavior, such as showing the minimized window.
true
}
Expand Down

0 comments on commit e703d77

Please sign in to comment.