Skip to content

Commit

Permalink
On macOS, fix resize event emits before fullscreen actually exit (#662)
Browse files Browse the repository at this point in the history
  • Loading branch information
wusyong committed Jan 9, 2023
1 parent 67cab01 commit 3867e7b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changes/mac-fullscreen-resize.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"tao": patch
---

Fix resize event emits before fullscreen actually exit.

19 changes: 17 additions & 2 deletions src/platform_impl/macos/window_delegate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,18 @@ extern "C" fn window_will_close(this: &Object, _: Sel, _: id) {
extern "C" fn window_did_resize(this: &Object, _: Sel, _: id) {
trace!("Triggered `windowDidResize:`");
with_state(this, |state| {
if !state.is_checking_zoomed_in {
// If window is entering/exiting, resize and move event will be emitted in
// window_did_enter_fullscreen & window_did_exit_fullscreen.
let in_fullscreen_transition = state
.with_window(|window| {
trace!("Locked shared state in `window_did_resize`");
let shared_state = window.shared_state.lock().unwrap();
trace!("Unlocked shared state in `window_did_resize`");
shared_state.in_fullscreen_transition
})
.unwrap_or(false);

if !state.is_checking_zoomed_in && !in_fullscreen_transition {
state.emit_resize_event();
state.emit_move_event();
}
Expand Down Expand Up @@ -572,6 +583,8 @@ extern "C" fn window_did_enter_fullscreen(this: &Object, _: Sel, _: id) {
window.set_fullscreen(target_fullscreen);
}
});
state.emit_resize_event();
state.emit_move_event();
});
trace!("Completed `windowDidEnterFullscreen:`");
}
Expand All @@ -591,7 +604,9 @@ extern "C" fn window_did_exit_fullscreen(this: &Object, _: Sel, _: id) {
if let Some(target_fullscreen) = target_fullscreen {
window.set_fullscreen(target_fullscreen);
}
})
});
state.emit_resize_event();
state.emit_move_event();
});
trace!("Completed `windowDidExitFullscreen:`");
}
Expand Down

0 comments on commit 3867e7b

Please sign in to comment.