aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/platform/sdl/macosx/appmenu_osx.mm25
1 files changed, 18 insertions, 7 deletions
diff --git a/backends/platform/sdl/macosx/appmenu_osx.mm b/backends/platform/sdl/macosx/appmenu_osx.mm
index d083fb8483..feea40bc06 100644
--- a/backends/platform/sdl/macosx/appmenu_osx.mm
+++ b/backends/platform/sdl/macosx/appmenu_osx.mm
@@ -28,12 +28,22 @@
#include <Cocoa/Cocoa.h>
-// Apple removed setAppleMenu from the header files in 10.4,
-// but as the method still exists we declare it ourselves here.
+// Apple added setAppleMenu in 10.5 and removed it in 10.6.
+// But as the method still exists we declare it ourselves here.
// Yes, this works :)
@interface NSApplication(MissingFunction)
- (void)setAppleMenu:(NSMenu *)menu;
@end
+// However maybe we should conditionally use it depending on the system on which we run ScummVM (and not
+// the one on which we compile) to only do it on OS X 10.5.
+// Here is the relevant bit from the release notes for 10.6:
+// 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:
+// [NSApp setAppleMenu:[[[NSApp mainMenu] itemAtIndex:0] submenu]];
+// In SnowLeopard, this workaround is unnecessary and should not be used. Under SnowLeopard, the first menu
+// is always identified as the application menu.
+
NSString *constructNSStringFromCString(const char *rawCString, CFStringEncoding stringEncoding) {
return (NSString *)CFStringCreateWithCString(NULL, rawCString, stringEncoding);
@@ -46,13 +56,14 @@ void replaceApplicationMenuItems() {
NSMenu *windowMenu;
NSMenuItem *menuItem;
- // 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
+ // We cannot use [[NSApp mainMenu] removeAllItems] as removeAllItems was added in OS X 10.6
+ // So remove the SDL generated menus one by one instead.
+ while ([[NSApp mainMenu] numberOfItems] > 0) {
+ [[NSApp mainMenu] removeItemAtIndex:0];
+ }
// Create new application menu
- appleMenu = [[NSMenu alloc] initWithTitle:@""];
+ appleMenu = [[NSMenu alloc] initWithTitle:@"ScummVM"];
NSString *nsString = NULL;