Skip to content

Commit

Permalink
On Wayland, fix WindowEvent::Destroyed delivery
Browse files Browse the repository at this point in the history
  • Loading branch information
kchibisov committed Dec 24, 2023
1 parent 2d1607b commit 5ca810b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 26 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Unreleased` header.
# Unreleased

- 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

Expand Down
52 changes: 26 additions & 26 deletions src/platform_impl/linux/wayland/event_loop/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,44 +467,44 @@ impl<T: 'static> EventLoop<T> {
});

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();
if window_requests.get(&window_id).unwrap().take_closed() {
mem::drop(window_requests.remove(&window_id));
mem::drop(state.windows.get_mut().remove(&window_id));
false
} else {
let mut window = state
.windows
.get_mut()
.get_mut(&window_id)
.unwrap()
.lock()
.unwrap();

if window.frame_callback_state() == FrameCallbackState::Requested {
false
} else {
// Reset the frame callbacks state.
window.frame_callback_reset();
let mut redraw_requested = window_requests
.get(&window_id)
.unwrap()
.take_redraw_requested();
return Some(WindowEvent::Destroyed);
}

// Redraw the frame while at it.
redraw_requested |= window.refresh_frame();
let mut window = state
.windows
.get_mut()
.get_mut(&window_id)
.unwrap()
.lock()
.unwrap();

redraw_requested
}
if window.frame_callback_state() == FrameCallbackState::Requested {
return None;
}

// Reset the frame callbacks state.
window.frame_callback_reset();
let mut redraw_requested = window_requests
.get(&window_id)
.unwrap()
.take_redraw_requested();

// Redraw the frame while at it.
redraw_requested |= window.refresh_frame();

redraw_requested.then_some(WindowEvent::RedrawRequested)
});

if request_redraw {
if let Some(event) = event {
callback(
Event::WindowEvent {
window_id: crate::window::WindowId(window_id),
event: WindowEvent::RedrawRequested,
event,
},
&self.window_target,
);
Expand Down

0 comments on commit 5ca810b

Please sign in to comment.