mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-26 03:36:32 +11:00
On Wayland, fix deadlock when calling set_inner_size from event loop
Fixes #1571.
This commit is contained in:
parent
6cfddfea21
commit
ff66bdda7c
3 changed files with 11 additions and 8 deletions
|
@ -1,6 +1,8 @@
|
||||||
# Unreleased
|
# Unreleased
|
||||||
- On Web, prevent the webpage from scrolling when the user is focused on a winit canvas
|
- On Web, prevent the webpage from scrolling when the user is focused on a winit canvas
|
||||||
|
|
||||||
|
- On Wayland, fix deadlock when calling to `set_inner_size` from a callback.
|
||||||
|
|
||||||
# 0.22.2 (2020-05-16)
|
# 0.22.2 (2020-05-16)
|
||||||
|
|
||||||
- Added Clone implementation for 'static events.
|
- Added Clone implementation for 'static events.
|
||||||
|
|
|
@ -667,6 +667,8 @@ impl<T> EventLoop<T> {
|
||||||
window_target.store.lock().unwrap().for_each_redraw_trigger(
|
window_target.store.lock().unwrap().for_each_redraw_trigger(
|
||||||
|refresh, frame_refresh, wid, frame| {
|
|refresh, frame_refresh, wid, frame| {
|
||||||
if let Some(frame) = frame {
|
if let Some(frame) = frame {
|
||||||
|
let mut frame = frame.lock().unwrap();
|
||||||
|
|
||||||
if frame_refresh {
|
if frame_refresh {
|
||||||
frame.refresh();
|
frame.refresh();
|
||||||
if !refresh {
|
if !refresh {
|
||||||
|
@ -751,6 +753,7 @@ impl<T> EventLoop<T> {
|
||||||
|
|
||||||
if window.new_size.is_some() || window.new_scale_factor.is_some() {
|
if window.new_size.is_some() || window.new_scale_factor.is_some() {
|
||||||
if let Some(frame) = window.frame {
|
if let Some(frame) = window.frame {
|
||||||
|
let mut frame = frame.lock().unwrap();
|
||||||
// Update decorations state
|
// Update decorations state
|
||||||
match window.decorations_action {
|
match window.decorations_action {
|
||||||
Some(DecorationsAction::Hide) => frame.set_decorate(false),
|
Some(DecorationsAction::Hide) => frame.set_decorate(false),
|
||||||
|
|
|
@ -461,7 +461,7 @@ pub struct WindowStoreForEach<'a> {
|
||||||
pub grab_cursor: Option<bool>,
|
pub grab_cursor: Option<bool>,
|
||||||
pub surface: &'a wl_surface::WlSurface,
|
pub surface: &'a wl_surface::WlSurface,
|
||||||
pub wid: WindowId,
|
pub wid: WindowId,
|
||||||
pub frame: Option<&'a mut SWindow<ConceptFrame>>,
|
pub frame: Option<Arc<Mutex<SWindow<ConceptFrame>>>>,
|
||||||
pub decorations_action: Option<DecorationsAction>,
|
pub decorations_action: Option<DecorationsAction>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -522,8 +522,7 @@ impl WindowStore {
|
||||||
if let Some(scale_factor) = window.new_scale_factor {
|
if let Some(scale_factor) = window.new_scale_factor {
|
||||||
window.current_scale_factor = scale_factor;
|
window.current_scale_factor = scale_factor;
|
||||||
}
|
}
|
||||||
let opt_arc = window.frame.upgrade();
|
let frame = window.frame.upgrade();
|
||||||
let mut opt_mutex_lock = opt_arc.as_ref().map(|m| m.lock().unwrap());
|
|
||||||
let decorations_action = { window.pending_decorations_action.lock().unwrap().take() };
|
let decorations_action = { window.pending_decorations_action.lock().unwrap().take() };
|
||||||
f(WindowStoreForEach {
|
f(WindowStoreForEach {
|
||||||
new_size: window.new_size.take(),
|
new_size: window.new_size.take(),
|
||||||
|
@ -534,7 +533,7 @@ impl WindowStore {
|
||||||
grab_cursor: window.cursor_grab_changed.lock().unwrap().take(),
|
grab_cursor: window.cursor_grab_changed.lock().unwrap().take(),
|
||||||
surface: &window.surface,
|
surface: &window.surface,
|
||||||
wid: make_wid(&window.surface),
|
wid: make_wid(&window.surface),
|
||||||
frame: opt_mutex_lock.as_mut().map(|m| &mut **m),
|
frame,
|
||||||
decorations_action,
|
decorations_action,
|
||||||
});
|
});
|
||||||
// avoid re-spamming the event
|
// avoid re-spamming the event
|
||||||
|
@ -544,16 +543,15 @@ impl WindowStore {
|
||||||
|
|
||||||
pub fn for_each_redraw_trigger<F>(&mut self, mut f: F)
|
pub fn for_each_redraw_trigger<F>(&mut self, mut f: F)
|
||||||
where
|
where
|
||||||
F: FnMut(bool, bool, WindowId, Option<&mut SWindow<ConceptFrame>>),
|
F: FnMut(bool, bool, WindowId, Option<Arc<Mutex<SWindow<ConceptFrame>>>>),
|
||||||
{
|
{
|
||||||
for window in &mut self.windows {
|
for window in &mut self.windows {
|
||||||
let opt_arc = window.frame.upgrade();
|
let frame = window.frame.upgrade();
|
||||||
let mut opt_mutex_lock = opt_arc.as_ref().map(|m| m.lock().unwrap());
|
|
||||||
f(
|
f(
|
||||||
replace(&mut *window.need_refresh.lock().unwrap(), false),
|
replace(&mut *window.need_refresh.lock().unwrap(), false),
|
||||||
replace(&mut *window.need_frame_refresh.lock().unwrap(), false),
|
replace(&mut *window.need_frame_refresh.lock().unwrap(), false),
|
||||||
make_wid(&window.surface),
|
make_wid(&window.surface),
|
||||||
opt_mutex_lock.as_mut().map(|m| &mut **m),
|
frame,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue