<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="color:#000000"><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>