<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hi Matt,<div><br></div><div>Thanks for proposing to test. However I remembered that I had a 10.3 laptop gathering dust in a corner so made some tests myself (and urghhh I hate azerty keyboards to write C++ code - you need a five minutes warm up for your fingers before typing a bracket if you don't want to get injured).</div><div>Anyway, I found that the easy solution indeed does not work, which I could easily have found before if I had read the reference documentation (NSMenu removeAllItems made its debut in OS X 10.6) And I found that our current code doesn't work well either (the app menu has no name!) :P</div><div><br></div><div>My alternative solution seems works with OS 10.3, 10.9 and 10.10 with SDL1.2 and SDL2 though, so I will commit that.</div><div><br></div><div>Also the documentation, once more (I really should read it more often) provided the answer regarding the call to NSApplication setAppleMenu:</div><div><span style="font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);">In Leopard and earlier, apps that tried to construct a menu bar without a nib would get an undesirable stubby application menu that could not be removed. To work around this problem on Leopard, you can call the undocumented setAppleMenu: method and pass it the application menu, like so:</span><br style="font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);"><pre style="margin-top: 0.455em; margin-bottom: 0.909em; font-size: 13px; font-family: Courier, Consolas, monospace; color: rgb(102, 102, 102); background-color: rgb(255, 255, 255);"><tt style="font-size: 14px; font-family: Courier, Consolas, monospace;">[NSApp setAppleMenu:[[[NSApp mainMenu] itemAtIndex:0] submenu]];</tt></pre><span style="font-family: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, Verdana, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);">In SnowLeopard, this workaround is unnecessary and should not be used. Under SnowLeopard, the first menu is always identified as the application menu.</span></div><div><br></div><div>It seems to work (despite the documentation saying it should not be called on 10.6+) so I left that call in there. But maybe we should conditionally do the call depending on the system on which ScummVM is executed.</div><div><br></div><div>Thierry</div><div><br><div><div>On 16 Dec 2015, at 00:57, Matthew Hoops <<a href="mailto:clone2727@gmail.com">clone2727@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><p dir="ltr">Hey Thierry,</p><p dir="ltr">If you have a branch (or branches), I'd be happy to test on 10.2 and 10.4.</p><p dir="ltr">-Matt</p>
<div class="gmail_quote">On Dec 15, 2015 7:49 PM, "Thierry Crozat" <<a href="mailto:criezy@scummvm.org">criezy@scummvm.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi all (or at least those who care about the OS X port),<div><br></div><div>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/<a href="http://appmenu_osx.mm/" target="_blank">appmenu_osx.mm</a></div><div><br></div><div>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.</div><div><div style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(0,132,0)">// Apple removed setAppleMenu from the header files in 10.4,</div><div style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(0,132,0)">// but as the method still exists we declare it ourselves here.</div><div style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(0,132,0)">// Yes, this works :)</div><div style="margin:0px;font-size:11px;font-family:Menlo"><span style="color:#bb2ca2">@interface</span> NSApplication(MissingFunction)</div><div style="margin:0px;font-size:11px;font-family:Menlo">- (<span style="color:#bb2ca2">void</span>)setAppleMenu:(NSMenu *)menu;</div><div style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(187,44,162)">@end</div></div><div><br></div><div>But that is secondary, and this call doesn't seem to do any harm anyway.</div><div><br></div><div>The issue is that in our code we do the following to remove the menus set by SDL:</div><div><div style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(0,132,0)"><span style="white-space:pre-wrap"> </span>// For some reason [[NSApp mainMenu] removeAllItems] doesn't work and crashes, so we need</div><div style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(0,132,0)"><span style=""><span style="white-space:pre-wrap"> </span></span>// to remove the SDL generated menus one by one</div></div><div><div style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap"> </span>[[NSApp mainMenu] removeItemAtIndex:<span style="color:#272ad8">0</span>];<span style="white-space:pre-wrap"> </span><span style="color:#008400">// Remove application menu</span></div><div style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap"> </span>[[NSApp mainMenu] removeItemAtIndex:<span style="color:#272ad8">0</span>];<span style="white-space:pre-wrap"> </span><span style="color:#008400">// Remove "Windows" menu</span></div></div><div><br></div><div>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.</div><div><br></div><div>The first things that works for me is to use:</div><div><div style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap"> </span>[[NSApp mainMenu] removeAllItems];</div></div><div><br></div><div>Indeed for me that works and that does not cause a crash. But the comment in our current code worries me.</div><div><br></div><div>The second things that works is:</div><div><div style="margin:0px;font-size:11px;font-family:Menlo"><span style="color:#bb2ca2"><span style="white-space:pre-wrap"> </span>while</span> ([NSApp mainMenu].numberOfItems > <span style="color:#272ad8">0</span>) {</div><div style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap"> </span>[[NSApp mainMenu] removeItemAtIndex:<span style="color:#272ad8">0</span>];</div><div style="margin:0px;font-size:11px;font-family:Menlo"><span style="white-space:pre-wrap"> </span>}</div></div><div><br></div><div>But I don't know if that works on old system (if removeAllItems crashes, I suppose that code could crash as well).</div><div><br></div><div>So does anybody have any though on that?</div><div><br></div><div>Thierry</div></div><br>------------------------------------------------------------------------------<br>
<br>_______________________________________________<br>
Scummvm-devel mailing list<br>
<a href="mailto:Scummvm-devel@lists.sourceforge.net">Scummvm-devel@lists.sourceforge.net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/scummvm-devel" rel="noreferrer" target="_blank">https://lists.sourceforge.net/lists/listinfo/scummvm-devel</a><br>
<br></blockquote></div>
</blockquote></div><br></div></body></html>