Discard mouse down after Cocoa window resize (#466)

* Discard mouse down after Cocoa window resize

We are sending the mouse down event after the window resize has
completed, because Cocoa uses a modal event loop to implement window
resize. This leads to a mouse down without a matching mouse up.

* Also handle event discard in poll_events

Add some explanatory comments and a changelog entry.
This commit is contained in:
Tristam MacDonald 2018-04-15 10:16:44 -07:00 committed by Francesca Frangipane
parent 2477d8ce46
commit 19cd53193b
3 changed files with 30 additions and 2 deletions

View file

@ -87,6 +87,11 @@ impl WindowDelegate {
let state: *mut c_void = *this.get_ivar("winitState");
let state = &mut *(state as *mut DelegateState);
emit_resize_event(state);
// discard the pending mouse down event
if let Some(shared) = state.shared.upgrade() {
shared.discard_next_event();
}
}
}