mirror of
https://github.com/danbulant/appit
synced 2026-06-16 04:41:17 +00:00
Fixing multiwindow close behavior
This commit is contained in:
parent
d0af8bb4e0
commit
ea1c0975dc
4 changed files with 17 additions and 3 deletions
|
|
@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## Unreleased
|
||||
|
||||
### Fixed
|
||||
|
||||
- When multiple windows are open, windows now properly close fully without
|
||||
requiring that all windows are closed.
|
||||
|
||||
## v0.3.0 (2024-07-15)
|
||||
|
||||
### Added
|
||||
|
|
|
|||
|
|
@ -474,7 +474,9 @@ impl<Message> Windows<Message> {
|
|||
|
||||
fn close(&self, window: WindowId) -> bool {
|
||||
let mut data = self.data.lock().unwrap_or_else(PoisonError::into_inner);
|
||||
data.remove(&window);
|
||||
if let Some(closed) = data.remove(&window) {
|
||||
closed.winit.close();
|
||||
}
|
||||
data.is_empty()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,10 @@ impl OpenedWindow {
|
|||
.unwrap_or_else(PoisonError::into_inner)
|
||||
.clone()
|
||||
}
|
||||
|
||||
pub(crate) fn close(&self) {
|
||||
*self.0.lock().unwrap_or_else(PoisonError::into_inner) = None;
|
||||
}
|
||||
}
|
||||
|
||||
pub enum EventLoopMessage<AppMessage>
|
||||
|
|
|
|||
|
|
@ -221,7 +221,8 @@ where
|
|||
let (sender, receiver) = mpsc::sync_channel(65536);
|
||||
let sender = Arc::new(sender);
|
||||
let app = self.owner.as_application().app();
|
||||
let show_after_init = self.attributes.delay_visible && std::mem::replace(&mut self.attributes.visible, false);
|
||||
let show_after_init =
|
||||
self.attributes.delay_visible && std::mem::replace(&mut self.attributes.visible, false);
|
||||
let Some(winit) = self.owner.as_application_mut().open(
|
||||
self.attributes,
|
||||
sender.clone(),
|
||||
|
|
@ -464,7 +465,7 @@ where
|
|||
behavior.redraw(&mut self);
|
||||
self.window.set_visible(true);
|
||||
}
|
||||
|
||||
|
||||
while !self.close {
|
||||
match self.process_messages_until_redraw(&mut behavior) {
|
||||
Ok(guard) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue