diff --git a/CHANGELOG.md b/CHANGELOG.md index 250ef38a..d15294b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Unreleased - 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) - Added Clone implementation for 'static events. diff --git a/src/platform_impl/linux/wayland/event_loop.rs b/src/platform_impl/linux/wayland/event_loop.rs index 5a3614c8..3262fe1e 100644 --- a/src/platform_impl/linux/wayland/event_loop.rs +++ b/src/platform_impl/linux/wayland/event_loop.rs @@ -667,6 +667,8 @@ impl EventLoop { window_target.store.lock().unwrap().for_each_redraw_trigger( |refresh, frame_refresh, wid, frame| { if let Some(frame) = frame { + let mut frame = frame.lock().unwrap(); + if frame_refresh { frame.refresh(); if !refresh { @@ -751,6 +753,7 @@ impl EventLoop { if window.new_size.is_some() || window.new_scale_factor.is_some() { if let Some(frame) = window.frame { + let mut frame = frame.lock().unwrap(); // Update decorations state match window.decorations_action { Some(DecorationsAction::Hide) => frame.set_decorate(false), diff --git a/src/platform_impl/linux/wayland/window.rs b/src/platform_impl/linux/wayland/window.rs index 12ae9ba1..5b680999 100644 --- a/src/platform_impl/linux/wayland/window.rs +++ b/src/platform_impl/linux/wayland/window.rs @@ -461,7 +461,7 @@ pub struct WindowStoreForEach<'a> { pub grab_cursor: Option, pub surface: &'a wl_surface::WlSurface, pub wid: WindowId, - pub frame: Option<&'a mut SWindow>, + pub frame: Option>>>, pub decorations_action: Option, } @@ -522,8 +522,7 @@ impl WindowStore { if let Some(scale_factor) = window.new_scale_factor { window.current_scale_factor = scale_factor; } - let opt_arc = window.frame.upgrade(); - let mut opt_mutex_lock = opt_arc.as_ref().map(|m| m.lock().unwrap()); + let frame = window.frame.upgrade(); let decorations_action = { window.pending_decorations_action.lock().unwrap().take() }; f(WindowStoreForEach { new_size: window.new_size.take(), @@ -534,7 +533,7 @@ impl WindowStore { grab_cursor: window.cursor_grab_changed.lock().unwrap().take(), surface: &window.surface, wid: make_wid(&window.surface), - frame: opt_mutex_lock.as_mut().map(|m| &mut **m), + frame, decorations_action, }); // avoid re-spamming the event @@ -544,16 +543,15 @@ impl WindowStore { pub fn for_each_redraw_trigger(&mut self, mut f: F) where - F: FnMut(bool, bool, WindowId, Option<&mut SWindow>), + F: FnMut(bool, bool, WindowId, Option>>>), { for window in &mut self.windows { - let opt_arc = window.frame.upgrade(); - let mut opt_mutex_lock = opt_arc.as_ref().map(|m| m.lock().unwrap()); + let frame = window.frame.upgrade(); f( replace(&mut *window.need_refresh.lock().unwrap(), false), replace(&mut *window.need_frame_refresh.lock().unwrap(), false), make_wid(&window.surface), - opt_mutex_lock.as_mut().map(|m| &mut **m), + frame, ); } }