GLFW on OS X : Apple Menu and handling "Quit"

Started by advanced_set, November 25, 2014, 17:27:28

Previous topic - Next topic



I am playing around with multiple windows (all created and rendered in the main thread). After the first window is created, GLFW takes control of the "Quit" in the apple menu:

QuoteOS X: The GLFW window has no icon, as it is not a document window, but the dock icon will be the same as the application bundle's icon. Also, the first time a window is opened the menu bar is populated with common commands like Hide, Quit and About. The (minimal) about dialog uses information from the application's bundle.

When you select "quit" it seems that GLFW sends "windowShouldClose" event to all windows and that is it (close all windows strategy). However, one may want different behaviours for closing a single window, closing all windows and exiting the application.

It seems that by design GLFW needs at least one window opened. This makes sense in Windows and Linux where usually the application exits when you close the main (or the last) window, but in a Mac having a menu with no windows is OK too.

Do you think it is possible to retake control of the Quit menu, i.e. replace GLFW handlers by my own handlers?

I know that GLFW's proposal is NOT to be a ui (i.e. not to provide menus and so on). But the fact that Mac OS imposes an application menu creates a design inconsistency between platforms, don't you think?


Have you tried using a hidden window?

For more customization, you'll probably have to wait for LWJGL 3 to support bindings to ObjC APIs. It's the next big feature that will be implemented, but I'm not able to give you an ETA right now.


A hidden window might be a good workaround. Good idea, I will try it out. Thanks!

I wanted to point this out because once you have multiple windows you open a plethora of possibilities, such as Game / Level Editors with multiple views, Simulators, and so on, which will behave more like a standard app.