-
-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat(macOS): add Reopen event * fix: unable to compile on macos when arch isn't aarch64 * fix(examples::reopen_event): only create new window when no window exists
- Loading branch information
1 parent
cd38f23
commit f06843b
Showing
6 changed files
with
100 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"tao": minor | ||
--- | ||
|
||
Add `event::Reopen` for handle click on dock icon on macOS. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2014-2021 The winit contributors | ||
// Copyright 2021-2023 Tauri Programme within The Commons Conservancy | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use tao::{ | ||
event::{Event, WindowEvent}, | ||
event_loop::{ControlFlow, EventLoop}, | ||
window::Window, | ||
}; | ||
|
||
#[allow(clippy::single_match)] | ||
fn main() { | ||
let event_loop = EventLoop::new(); | ||
|
||
let mut window = Some(Window::new(&event_loop).unwrap()); | ||
|
||
event_loop.run(move |event, event_loop, control_flow| { | ||
*control_flow = ControlFlow::Wait; | ||
|
||
match event { | ||
Event::WindowEvent { | ||
event: WindowEvent::CloseRequested, | ||
.. | ||
} => { | ||
// drop the window | ||
window = None; | ||
} | ||
Event::Reopen { | ||
has_visible_windows, | ||
.. | ||
} => { | ||
println!("on reopen, has visible windows: {has_visible_windows}"); | ||
if !has_visible_windows { | ||
window = Some(Window::new(&event_loop).unwrap()) | ||
} | ||
} | ||
Event::MainEventsCleared => { | ||
if let Some(w) = &window { | ||
w.request_redraw(); | ||
} | ||
} | ||
_ => (), | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters