mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-23 22:01:31 +11:00
This fixes the run_return loop never returning on macos when using multiple windows
This commit is contained in:
parent
224872ce03
commit
4c39b3188c
|
@ -8,6 +8,7 @@ And please only add new entries to the top of this list, right below the `# Unre
|
|||
|
||||
# Unreleased
|
||||
|
||||
- On macOS, fixed an issue where having multiple windows would prevent run_return from ever returning.
|
||||
- On Wayland, fix bug where the cursor wouldn't hide in GNOME.
|
||||
- On macOS, Windows, and Wayland, add `set_cursor_hittest` to let the window ignore mouse events.
|
||||
- On Windows, added `WindowExtWindows::set_skip_taskbar` and `WindowBuilderExtWindows::with_skip_taskbar`.
|
||||
|
|
|
@ -127,7 +127,6 @@ impl<T> EventHandler for EventLoopHandler<T> {
|
|||
struct Handler {
|
||||
ready: AtomicBool,
|
||||
in_callback: AtomicBool,
|
||||
dialog_is_closing: AtomicBool,
|
||||
control_flow: Mutex<ControlFlow>,
|
||||
control_flow_prev: Mutex<ControlFlow>,
|
||||
start_time: Mutex<Option<Instant>>,
|
||||
|
@ -262,8 +261,6 @@ impl Handler {
|
|||
}
|
||||
}
|
||||
|
||||
pub static INTERRUPT_EVENT_LOOP_EXIT: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
pub enum AppState {}
|
||||
|
||||
impl AppState {
|
||||
|
@ -403,40 +400,12 @@ impl AppState {
|
|||
if HANDLER.should_exit() {
|
||||
unsafe {
|
||||
let app: id = NSApp();
|
||||
let windows: id = msg_send![app, windows];
|
||||
let window_count: usize = msg_send![windows, count];
|
||||
|
||||
let dialog_open = if window_count > 1 {
|
||||
let dialog: id = msg_send![windows, lastObject];
|
||||
let is_main_window: BOOL = msg_send![dialog, isMainWindow];
|
||||
let is_visible: BOOL = msg_send![dialog, isVisible];
|
||||
is_visible != NO && is_main_window == NO
|
||||
} else {
|
||||
false
|
||||
};
|
||||
|
||||
let dialog_is_closing = HANDLER.dialog_is_closing.load(Ordering::SeqCst);
|
||||
autoreleasepool(|| {
|
||||
if !INTERRUPT_EVENT_LOOP_EXIT.load(Ordering::SeqCst)
|
||||
&& !dialog_open
|
||||
&& !dialog_is_closing
|
||||
{
|
||||
let () = msg_send![app, stop: nil];
|
||||
// To stop event loop immediately, we need to post some event here.
|
||||
post_dummy_event(app);
|
||||
}
|
||||
let () = msg_send![app, stop: nil];
|
||||
// To stop event loop immediately, we need to post some event here.
|
||||
post_dummy_event(app);
|
||||
});
|
||||
|
||||
if window_count > 0 {
|
||||
let window: id = msg_send![windows, firstObject];
|
||||
let window_has_focus: BOOL = msg_send![window, isKeyWindow];
|
||||
if !dialog_open && window_has_focus != NO && dialog_is_closing {
|
||||
HANDLER.dialog_is_closing.store(false, Ordering::SeqCst);
|
||||
}
|
||||
if dialog_open {
|
||||
HANDLER.dialog_is_closing.store(true, Ordering::SeqCst);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
HANDLER.update_start_time();
|
||||
|
|
|
@ -20,7 +20,6 @@ use crate::{
|
|||
platform::macos::WindowExtMacOS,
|
||||
platform_impl::platform::{
|
||||
app_state::AppState,
|
||||
app_state::INTERRUPT_EVENT_LOOP_EXIT,
|
||||
ffi,
|
||||
monitor::{self, MonitorHandle, VideoMode},
|
||||
util::{self, IdRef},
|
||||
|
@ -907,8 +906,6 @@ impl UnownedWindow {
|
|||
let mut shared_state_lock = self.lock_shared_state("set_fullscreen");
|
||||
shared_state_lock.fullscreen = fullscreen.clone();
|
||||
|
||||
INTERRUPT_EVENT_LOOP_EXIT.store(true, Ordering::SeqCst);
|
||||
|
||||
match (&old_fullscreen, &fullscreen) {
|
||||
(&None, &Some(_)) => unsafe {
|
||||
util::toggle_full_screen_async(
|
||||
|
@ -978,7 +975,7 @@ impl UnownedWindow {
|
|||
setLevel: ffi::NSWindowLevel::NSNormalWindowLevel
|
||||
];
|
||||
},
|
||||
_ => INTERRUPT_EVENT_LOOP_EXIT.store(false, Ordering::SeqCst),
|
||||
_ => {}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::{
|
||||
f64,
|
||||
os::raw::c_void,
|
||||
sync::{atomic::Ordering, Arc, Weak},
|
||||
sync::{Arc, Weak},
|
||||
};
|
||||
|
||||
use cocoa::{
|
||||
|
@ -20,7 +20,6 @@ use crate::{
|
|||
event::{Event, ModifiersState, WindowEvent},
|
||||
platform_impl::platform::{
|
||||
app_state::AppState,
|
||||
app_state::INTERRUPT_EVENT_LOOP_EXIT,
|
||||
event::{EventProxy, EventWrapper},
|
||||
util::{self, IdRef},
|
||||
view::ViewState,
|
||||
|
@ -414,8 +413,6 @@ extern "C" fn dragging_exited(this: &Object, _: Sel, _: id) {
|
|||
extern "C" fn window_will_enter_fullscreen(this: &Object, _: Sel, _: id) {
|
||||
trace_scope!("windowWillEnterFullscreen:");
|
||||
|
||||
INTERRUPT_EVENT_LOOP_EXIT.store(true, Ordering::SeqCst);
|
||||
|
||||
with_state(this, |state| {
|
||||
state.with_window(|window| {
|
||||
let mut shared_state = window.lock_shared_state("window_will_enter_fullscreen");
|
||||
|
@ -445,8 +442,6 @@ extern "C" fn window_will_enter_fullscreen(this: &Object, _: Sel, _: id) {
|
|||
extern "C" fn window_will_exit_fullscreen(this: &Object, _: Sel, _: id) {
|
||||
trace_scope!("windowWillExitFullScreen:");
|
||||
|
||||
INTERRUPT_EVENT_LOOP_EXIT.store(true, Ordering::SeqCst);
|
||||
|
||||
with_state(this, |state| {
|
||||
state.with_window(|window| {
|
||||
let mut shared_state = window.lock_shared_state("window_will_exit_fullscreen");
|
||||
|
@ -490,8 +485,6 @@ extern "C" fn window_will_use_fullscreen_presentation_options(
|
|||
/// Invoked when entered fullscreen
|
||||
extern "C" fn window_did_enter_fullscreen(this: &Object, _: Sel, _: id) {
|
||||
trace_scope!("windowDidEnterFullscreen:");
|
||||
INTERRUPT_EVENT_LOOP_EXIT.store(false, Ordering::SeqCst);
|
||||
|
||||
with_state(this, |state| {
|
||||
state.initial_fullscreen = false;
|
||||
state.with_window(|window| {
|
||||
|
@ -509,7 +502,6 @@ extern "C" fn window_did_enter_fullscreen(this: &Object, _: Sel, _: id) {
|
|||
/// Invoked when exited fullscreen
|
||||
extern "C" fn window_did_exit_fullscreen(this: &Object, _: Sel, _: id) {
|
||||
trace_scope!("windowDidExitFullscreen:");
|
||||
INTERRUPT_EVENT_LOOP_EXIT.store(false, Ordering::SeqCst);
|
||||
|
||||
with_state(this, |state| {
|
||||
state.with_window(|window| {
|
||||
|
|
Loading…
Reference in a new issue