On Wayland, fix WindowEvent::Destroyed delivery

This commit is contained in:
Kirill Chibisov
2023-12-22 19:56:52 +04:00
parent 2d1607b3f7
commit 5ca810ba8f
2 changed files with 29 additions and 28 deletions

View File

@@ -12,6 +12,7 @@ Unreleased` header.
# Unreleased # Unreleased
- On Web, fix context menu not being disabled by `with_prevent_default(true)`. - On Web, fix context menu not being disabled by `with_prevent_default(true)`.
- On Wayland, fix `WindowEvent::Destroyed` not being delivered after destroying window.
# 0.29.5 # 0.29.5

View File

@@ -467,13 +467,14 @@ impl<T: 'static> EventLoop<T> {
}); });
for window_id in window_ids.drain(..) { for window_id in window_ids.drain(..) {
let request_redraw = self.with_state(|state| { let event = self.with_state(|state| {
let window_requests = state.window_requests.get_mut(); let window_requests = state.window_requests.get_mut();
if window_requests.get(&window_id).unwrap().take_closed() { if window_requests.get(&window_id).unwrap().take_closed() {
mem::drop(window_requests.remove(&window_id)); mem::drop(window_requests.remove(&window_id));
mem::drop(state.windows.get_mut().remove(&window_id)); mem::drop(state.windows.get_mut().remove(&window_id));
false return Some(WindowEvent::Destroyed);
} else { }
let mut window = state let mut window = state
.windows .windows
.get_mut() .get_mut()
@@ -483,8 +484,9 @@ impl<T: 'static> EventLoop<T> {
.unwrap(); .unwrap();
if window.frame_callback_state() == FrameCallbackState::Requested { if window.frame_callback_state() == FrameCallbackState::Requested {
false return None;
} else { }
// Reset the frame callbacks state. // Reset the frame callbacks state.
window.frame_callback_reset(); window.frame_callback_reset();
let mut redraw_requested = window_requests let mut redraw_requested = window_requests
@@ -495,16 +497,14 @@ impl<T: 'static> EventLoop<T> {
// Redraw the frame while at it. // Redraw the frame while at it.
redraw_requested |= window.refresh_frame(); redraw_requested |= window.refresh_frame();
redraw_requested redraw_requested.then_some(WindowEvent::RedrawRequested)
}
}
}); });
if request_redraw { if let Some(event) = event {
callback( callback(
Event::WindowEvent { Event::WindowEvent {
window_id: crate::window::WindowId(window_id), window_id: crate::window::WindowId(window_id),
event: WindowEvent::RedrawRequested, event,
}, },
&self.window_target, &self.window_target,
); );