Skip to content

Commit

Permalink
Cocoa: Fix menubar for unbundled apps on 10.15
Browse files Browse the repository at this point in the history
NSApp setActivationPolicy: was being called too soon when the app was
not bundled and launched from the command line.

This fix is based on #1802 by @richardwilkes.

Fixes #1648.
Closes #1802.
  • Loading branch information
elmindreda committed Dec 8, 2020
1 parent 7e8da57 commit cdc3b71
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Expand Up @@ -178,6 +178,8 @@ information on what to include when reporting a bug.
- [Cocoa] Bugfix: Failing to retrieve the refresh rate of built-in displays
could leak memory
- [Cocoa] Bugfix: Objective-C files were compiled as C with CMake 3.19 (#1787)
- [Cocoa] Bugfix: Menubar was not clickable on macOS 10.15+ until it lost and
regained focus (#1648,#1802)
- [X11] Bugfix: The CMake files did not check for the XInput headers (#1480)
- [X11] Bugfix: Key names were not updated when the keyboard layout changed
(#1462,#1528)
Expand Down Expand Up @@ -439,6 +441,7 @@ skills.
- Frank Wille
- Andy Williams
- Joel Winarske
- Richard A. Wilkes
- Tatsuya Yatagawa
- Ryogo Yoshimura
- Lukas Zanner
Expand Down
6 changes: 3 additions & 3 deletions src/cocoa_init.m
Expand Up @@ -428,9 +428,6 @@ - (void)applicationWillFinishLaunching:(NSNotification *)notification
{
if (_glfw.hints.init.ns.menubar)
{
// In case we are unbundled, make us a proper UI application
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];

// Menu bar setup must go between sharedApplication and finishLaunching
// in order to properly emulate the behavior of NSApplicationMain

Expand Down Expand Up @@ -557,6 +554,9 @@ int _glfwPlatformInit(void)
if (![[NSRunningApplication currentApplication] isFinishedLaunching])
[NSApp run];

// In case we are unbundled, make us a proper UI application
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];

return GLFW_TRUE;

} // autoreleasepool
Expand Down

0 comments on commit cdc3b71

Please sign in to comment.