Skip to content

Commit

Permalink
Call SetActivationPolicy at the proper time
Browse files Browse the repository at this point in the history
If this method is called too early, the menu bar won't be
clickable on startup until the window loses focus. Calling
it once the application finishes launching seems to fix
the issue.

See glfw/glfw#1648
  • Loading branch information
maxbrunsfeld committed Apr 8, 2021
1 parent 334de06 commit f656b38
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions gpui/src/platform/mac/runner.rs
Expand Up @@ -205,7 +205,6 @@ impl crate::platform::Runner for Runner {
let app: id = msg_send![APP_CLASS, sharedApplication];
let app_delegate: id = msg_send![APP_DELEGATE_CLASS, new];

app.setActivationPolicy_(NSApplicationActivationPolicyRegular);
(*app).set_ivar(RUNNER_IVAR, self_ptr as *mut c_void);
(*app_delegate).set_ivar(RUNNER_IVAR, self_ptr as *mut c_void);
app.setDelegate_(app_delegate);
Expand Down Expand Up @@ -241,9 +240,14 @@ extern "C" fn send_event(this: &mut Object, _sel: Sel, native_event: id) {
}

extern "C" fn did_finish_launching(this: &mut Object, _: Sel, _: id) {
let runner = unsafe { get_runner(this) };
if let Some(callback) = runner.finish_launching_callback.take() {
callback();
unsafe {
let app: id = msg_send![APP_CLASS, sharedApplication];
app.setActivationPolicy_(NSApplicationActivationPolicyRegular);

let runner = get_runner(this);
if let Some(callback) = runner.finish_launching_callback.take() {
callback();
}
}
}

Expand Down

0 comments on commit f656b38

Please sign in to comment.