Call SetActivationPolicy at the proper time
Max Brunsfeld
created 4 years ago
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 https://github.com/glfw/glfw/issues/1648
Change summary
gpui/src/platform/mac/runner.rs | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
Detailed changes
@@ -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);
@@ -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();
+ }
}
}