Skip to content

Commit

Permalink
Fix macOS main menu not working before refocus. (#994)
Browse files Browse the repository at this point in the history
  • Loading branch information
xStrom authored May 31, 2020
1 parent 2b6dd11 commit 05311d1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ This means that druid no longer requires cairo on macOS and uses Core Graphics i
- Wheel events now properly update hot state. ([#951] by [@xStrom])
- X11: Support mouse scrolling. ([#961] by [@jneem])
- `Painter` now properly repaints on data change in `Container`. ([#991] by [@cmyr])
- macOS: The application menu is now immediately interactable after launch. ([#994] by [@xStrom])

### Visual

Expand Down Expand Up @@ -248,6 +249,7 @@ This means that druid no longer requires cairo on macOS and uses Core Graphics i
[#990]: https://github.com/xi-editor/druid/pull/990
[#991]: https://github.com/xi-editor/druid/pull/991
[#993]: https://github.com/xi-editor/druid/pull/993
[#994]: https://github.com/xi-editor/druid/pull/994
[#996]: https://github.com/xi-editor/druid/pull/996
[#1001]: https://github.com/xi-editor/druid/pull/1001

Expand Down
9 changes: 5 additions & 4 deletions druid-shell/src/platform/mac/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@ impl Application {
util::assert_main_thread();
unsafe {
let _pool = NSAutoreleasePool::new(nil);

let ns_app = NSApp();
ns_app.setActivationPolicy_(NSApplicationActivationPolicyRegular);

let state = Rc::new(RefCell::new(State { quitting: false }));

Ok(Application { ns_app, state })
Expand Down Expand Up @@ -174,7 +171,11 @@ lazy_static! {

extern "C" fn application_did_finish_launching(_this: &mut Object, _: Sel, _notification: id) {
unsafe {
let () = msg_send![NSApp(), activateIgnoringOtherApps: YES];
let ns_app = NSApp();
// We need to delay setting the activation policy and activating the app
// until we have the main menu all set up. Otherwise the menu won't be interactable.
ns_app.setActivationPolicy_(NSApplicationActivationPolicyRegular);
let () = msg_send![ns_app, activateIgnoringOtherApps: YES];
}
}

Expand Down

0 comments on commit 05311d1

Please sign in to comment.