[Scummvm-devel] Issue with menus on OS X with SDL2

Matthew Hoops clone2727 at gmail.com
Wed Dec 16 01:57:56 CET 2015

Hey Thierry,

If you have a branch (or branches), I'd be happy to test on 10.2 and 10.4.

On Dec 15, 2015 7:49 PM, "Thierry Crozat" <criezy at scummvm.org> wrote:

> Hi all (or at least those who care about the OS X port),
> I noticed yesterday that when using SDL2 the menus in the menubar are
> incorrect. I get an app menu with a "Fullscreen" item, then a menu without
> a title that is our app menu and finally our Windows menu. The issue is in
> the file backends/platform/sdl/macosx/appmenu_osx.mm
> First I should note that we use NSApplication setAppleMenu: to set the app
> menu. But this call actually doesn't do anything for me. It seems that it
> just uses whatever is the menu at index 0 as app menu. This might be why
> setAppleMenu was removed from the header file in OS X 10.4 and maybe we
> could remove this call and the hack that goes with it.
> // Apple removed setAppleMenu from the header files in 10.4,
> // but as the method still exists we declare it ourselves here.
> // Yes, this works :)
> @interface NSApplication(MissingFunction)
> - (void)setAppleMenu:(NSMenu *)menu;
> @end
> But that is secondary, and this call doesn't seem to do any harm anyway.
> The issue is that in our code we do the following to remove the menus set
> by SDL:
> // For some reason [[NSApp mainMenu] removeAllItems] doesn't work and
> crashes, so we need
> // to remove the SDL generated menus one by one
> [[NSApp mainMenu] removeItemAtIndex:0]; // Remove application menu
> [[NSApp mainMenu] removeItemAtIndex:0]; // Remove "Windows" menu
> But when using SDL2 we actually have three menus, so what I see as app
> menu is actually the remaining SDL2 menu ("Views", but renamed as "ScummVM"
> when used as app menu, and which apparently only contains a "Fullscreen"
> menu item). I have two alternative code that work with both SDL1 and SDL2
> on OS X 10.9 and 10.10. But since I cannot test on old systems I would
> appreciate any feedback on if I should do a change, and which one.
> Currently I would tend to just add a comment for now and wait until after
> the next release (which I assume will be using SDL1.2) to make sure I do
> not break SCummVM on old systems.
> The first things that works for me is to use:
> [[NSApp mainMenu] removeAllItems];
> Indeed for me that works and that does not cause a crash. But the comment
> in our current code worries me.
> The second things that works is:
> while ([NSApp mainMenu].numberOfItems > 0) {
> [[NSApp mainMenu] removeItemAtIndex:0];
> }
> But I don't know if that works on old system (if removeAllItems crashes, I
> suppose that code could crash as well).
> So does anybody have any though on that?
> Thierry
> ------------------------------------------------------------------------------
> _______________________________________________
> Scummvm-devel mailing list
> Scummvm-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/scummvm-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scummvm.org/pipermail/scummvm-devel/attachments/20151215/489087d6/attachment.html>

More information about the Scummvm-devel mailing list