mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-23 10:26:34 +11:00
X11: Fix deadlock on window state with certain window events (#1369)
This commit is contained in:
parent
6a330a2894
commit
6b0875728c
2 changed files with 21 additions and 9 deletions
|
@ -1,6 +1,7 @@
|
|||
# Unreleased
|
||||
|
||||
- On Windows, fix bug where `RedrawRequested` would only get emitted every other iteration of the event loop.
|
||||
- On X11, fix deadlock on window state when handling certain window events.
|
||||
|
||||
# 0.20.0 (2020-01-05)
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@ use std::{cell::RefCell, collections::HashMap, rc::Rc, slice, sync::Arc};
|
|||
|
||||
use libc::{c_char, c_int, c_long, c_uint, c_ulong};
|
||||
|
||||
use parking_lot::MutexGuard;
|
||||
|
||||
use super::{
|
||||
events, ffi, get_xtarget, mkdid, mkwid, monitor, util, Device, DeviceId, DeviceInfo, Dnd,
|
||||
DndState, GenericEventCookie, ImeReceiver, ScrollOrientation, UnownedWindow, WindowId,
|
||||
|
@ -384,9 +386,12 @@ impl<T: 'static> EventProcessor<T> {
|
|||
.inner_pos_to_outer(new_inner_position.0, new_inner_position.1);
|
||||
shared_state_lock.position = Some(outer);
|
||||
if moved {
|
||||
callback(Event::WindowEvent {
|
||||
window_id,
|
||||
event: WindowEvent::Moved(outer.into()),
|
||||
// Temporarily unlock shared state to prevent deadlock
|
||||
MutexGuard::unlocked(&mut shared_state_lock, || {
|
||||
callback(Event::WindowEvent {
|
||||
window_id,
|
||||
event: WindowEvent::Moved(outer.into()),
|
||||
});
|
||||
});
|
||||
}
|
||||
outer
|
||||
|
@ -426,12 +431,15 @@ impl<T: 'static> EventProcessor<T> {
|
|||
let old_inner_size = PhysicalSize::new(width, height);
|
||||
let mut new_inner_size = PhysicalSize::new(new_width, new_height);
|
||||
|
||||
callback(Event::WindowEvent {
|
||||
window_id,
|
||||
event: WindowEvent::ScaleFactorChanged {
|
||||
scale_factor: new_scale_factor,
|
||||
new_inner_size: &mut new_inner_size,
|
||||
},
|
||||
// Temporarily unlock shared state to prevent deadlock
|
||||
MutexGuard::unlocked(&mut shared_state_lock, || {
|
||||
callback(Event::WindowEvent {
|
||||
window_id,
|
||||
event: WindowEvent::ScaleFactorChanged {
|
||||
scale_factor: new_scale_factor,
|
||||
new_inner_size: &mut new_inner_size,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
if new_inner_size != old_inner_size {
|
||||
|
@ -461,6 +469,9 @@ impl<T: 'static> EventProcessor<T> {
|
|||
}
|
||||
|
||||
if resized {
|
||||
// Drop the shared state lock to prevent deadlock
|
||||
drop(shared_state_lock);
|
||||
|
||||
callback(Event::WindowEvent {
|
||||
window_id,
|
||||
event: WindowEvent::Resized(new_inner_size.into()),
|
||||
|
|
Loading…
Add table
Reference in a new issue