mirror of
https://github.com/rust-windowing/winit.git
synced 2026-09-02 14:50:04 -04:00
Fix some deadlocks that could occur when changing window state
This commit is contained in:
@@ -425,6 +425,7 @@ impl Window {
|
|||||||
if currently_grabbed == grab && grab == window_state_lock.cursor_grabbed {
|
if currently_grabbed == grab && grab == window_state_lock.cursor_grabbed {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
drop(window_state_lock);
|
||||||
let window = self.window.clone();
|
let window = self.window.clone();
|
||||||
let window_state = Arc::clone(&self.window_state);
|
let window_state = Arc::clone(&self.window_state);
|
||||||
let (tx, rx) = channel();
|
let (tx, rx) = channel();
|
||||||
@@ -435,7 +436,6 @@ impl Window {
|
|||||||
}
|
}
|
||||||
let _ = tx.send(result);
|
let _ = tx.send(result);
|
||||||
});
|
});
|
||||||
drop(window_state_lock);
|
|
||||||
rx.recv().unwrap()
|
rx.recv().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -500,6 +500,7 @@ impl Window {
|
|||||||
// We only maximize if we're not in fullscreen.
|
// We only maximize if we're not in fullscreen.
|
||||||
if window_state.fullscreen.is_none() {
|
if window_state.fullscreen.is_none() {
|
||||||
let window = self.window.clone();
|
let window = self.window.clone();
|
||||||
|
drop(window_state);
|
||||||
unsafe {
|
unsafe {
|
||||||
// `ShowWindow` resizes the window, so it must be called from the main thread.
|
// `ShowWindow` resizes the window, so it must be called from the main thread.
|
||||||
self.thread_executor.execute_in_thread(move || {
|
self.thread_executor.execute_in_thread(move || {
|
||||||
@@ -754,6 +755,7 @@ impl Window {
|
|||||||
let mut window_state = self.window_state.lock();
|
let mut window_state = self.window_state.lock();
|
||||||
if mem::replace(&mut window_state.always_on_top, always_on_top) != always_on_top {
|
if mem::replace(&mut window_state.always_on_top, always_on_top) != always_on_top {
|
||||||
let window = self.window.clone();
|
let window = self.window.clone();
|
||||||
|
drop(window_state);
|
||||||
self.thread_executor.execute_in_thread(move || {
|
self.thread_executor.execute_in_thread(move || {
|
||||||
let insert_after = if always_on_top {
|
let insert_after = if always_on_top {
|
||||||
winuser::HWND_TOPMOST
|
winuser::HWND_TOPMOST
|
||||||
|
|||||||
Reference in New Issue
Block a user