Skip to content

Commit

Permalink
On Windows, fix deadlock during Cursor{Enter,Leave}
Browse files Browse the repository at this point in the history
The lock was not released when calling back to the user.

Fixes #3171.
  • Loading branch information
kchibisov committed Oct 22, 2023
1 parent 772b21c commit d37d1a0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Unreleased` header.

# Unreleased

- On Windows, fix deadlock when accessing the state during `Cursor{Enter,Leave}`.

# 0.29.2

- **Breaking:** Bump MSRV from `1.60` to `1.65`.
Expand Down
3 changes: 3 additions & 0 deletions src/platform_impl/windows/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1465,6 +1465,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
.set_cursor_flags(window, |f| f.set(CursorFlags::IN_WINDOW, true))
.ok();

drop(w);
userdata.send_event(Event::WindowEvent {
window_id: RootWindowId(WindowId(window)),
event: CursorEntered {
Expand All @@ -1487,6 +1488,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
.set_cursor_flags(window, |f| f.set(CursorFlags::IN_WINDOW, false))
.ok();

drop(w);
userdata.send_event(Event::WindowEvent {
window_id: RootWindowId(WindowId(window)),
event: CursorLeft {
Expand All @@ -1500,6 +1502,7 @@ unsafe fn public_window_callback_inner<T: 'static>(
// handle spurious WM_MOUSEMOVE messages
// see https://devblogs.microsoft.com/oldnewthing/20031001-00/?p=42343
// and http://debugandconquer.blogspot.com/2015/08/the-cause-of-spurious-mouse-move.html
let mut w = userdata.window_state_lock();
cursor_moved = w.mouse.last_position != Some(position);
w.mouse.last_position = Some(position);
}
Expand Down

0 comments on commit d37d1a0

Please sign in to comment.