mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-26 20:28:49 -05:00
Fixed menu bar for non-bundled OS X applications.
The menu bar for non-bundled applications did not become visible until it had lost and regained focus. This is fixed (somehow) by letting the NSApplication run loop start and stop. Technique by scoopr.
This commit is contained in:
parent
a611144d0c
commit
9aa15aa710
|
@ -228,9 +228,12 @@ void _glfwPlatformTerminate(void)
|
|||
_glfw.ns.eventSource = NULL;
|
||||
}
|
||||
|
||||
[NSApp setDelegate:nil];
|
||||
[_glfw.ns.delegate release];
|
||||
_glfw.ns.delegate = nil;
|
||||
id delegate = [NSApp delegate];
|
||||
if (delegate)
|
||||
{
|
||||
[delegate release];
|
||||
[NSApp setDelegate:nil];
|
||||
}
|
||||
|
||||
[_glfw.ns.autoreleasePool release];
|
||||
_glfw.ns.autoreleasePool = nil;
|
||||
|
|
|
@ -72,7 +72,6 @@ typedef struct _GLFWwindowNS
|
|||
typedef struct _GLFWlibraryNS
|
||||
{
|
||||
CGEventSourceRef eventSource;
|
||||
id delegate;
|
||||
id autoreleasePool;
|
||||
id cursor;
|
||||
|
||||
|
|
|
@ -262,6 +262,13 @@ static NSRect convertRectToBacking(_GLFWwindow* window, NSRect contentRect)
|
|||
_glfwInputMonitorChange();
|
||||
}
|
||||
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)notification
|
||||
{
|
||||
[NSApp stop:nil];
|
||||
|
||||
_glfwPlatformPostEmptyEvent();
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
// Translates OS X key modifiers into GLFW ones
|
||||
|
@ -802,7 +809,18 @@ static GLboolean initializeAppKit(void)
|
|||
createMenuBar();
|
||||
#endif
|
||||
|
||||
[NSApp finishLaunching];
|
||||
// There can only be one application delegate, but we allocate it the
|
||||
// first time a window is created to keep all window code in this file
|
||||
id delegate = [[GLFWApplicationDelegate alloc] init];
|
||||
if (delegate == nil)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Cocoa: Failed to create application delegate");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
[NSApp setDelegate:delegate];
|
||||
[NSApp run];
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
@ -905,21 +923,6 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|||
if (!initializeAppKit())
|
||||
return GL_FALSE;
|
||||
|
||||
// There can only be one application delegate, but we allocate it the
|
||||
// first time a window is created to keep all window code in this file
|
||||
if (_glfw.ns.delegate == nil)
|
||||
{
|
||||
_glfw.ns.delegate = [[GLFWApplicationDelegate alloc] init];
|
||||
if (_glfw.ns.delegate == nil)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"Cocoa: Failed to create application delegate");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
[NSApp setDelegate:_glfw.ns.delegate];
|
||||
}
|
||||
|
||||
if (!createWindow(window, wndconfig))
|
||||
return GL_FALSE;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user