Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Unreleased

- On macOS, fix application not to terminate on `run_return`.
- On Wayland, fix cursor icon updates on window borders when using CSD.

# # 0.20.0 Alpha 5 (2019-12-09)
Expand Down
24 changes: 21 additions & 3 deletions src/platform_impl/macos/app_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ use std::{
time::Instant,
};

use cocoa::{appkit::NSApp, base::nil};
use cocoa::{appkit::NSApp, base::nil, foundation::NSString};

use crate::{
event::{Event, StartCause, WindowEvent},
event_loop::{ControlFlow, EventLoopWindowTarget as RootWindowTarget},
platform_impl::platform::{observer::EventLoopWaker, util::Never},
window::WindowId,
};
use objc::runtime::Object;

lazy_static! {
static ref HANDLER: Handler = Default::default();
Expand Down Expand Up @@ -275,8 +276,25 @@ impl AppState {
HANDLER.set_in_callback(false);
}
if HANDLER.should_exit() {
let _: () = unsafe { msg_send![NSApp(), terminate: nil] };
return;
unsafe {
let _: () = msg_send![NSApp(), stop: nil];

let windows: *const Object = msg_send![NSApp(), windows];
let window: *const Object = msg_send![windows, objectAtIndex:0];
assert_ne!(window, nil);

let title: *const Object = msg_send![window, title];
assert_ne!(title, nil);
let postfix = NSString::alloc(nil).init_str("*");
let some_unique_title: *const Object =
msg_send![title, stringByAppendingString: postfix];
assert_ne!(some_unique_title, nil);

// To stop event loop immediately, we need to send some UI event here.
let _: () = msg_send![window, setTitle: some_unique_title];
// And restore it.
let _: () = msg_send![window, setTitle: title];
};
}
HANDLER.update_start_time();
match HANDLER.get_old_and_new_control_flow() {
Expand Down