mirror of
https://github.com/Ryujinx/SDL.git
synced 2024-12-23 04:55:34 +00:00
Fixed bug 4415 - SDL menu bar is nonstandard on Mac
foo.null I'm on macOS 10.14 and I think I'm using or around SDL 2.0.9. This is about the menu bar that SDL sets up which looks like: <App Name> <Window> <View> 1. View menu never proceeds after the Window menu in any Mac application (it is always before). 2. For SDL, the only purpose of the View menu is for a single fullscreen menu item, which is not justifiable enough to reserve space for a menu. The View menu should thus be removed, and the full screen menu item should be added at the end inside of Window's menu. See built in apps like Dictionary, Chess, App Store (on 10.14) that do this. 3. SDL should add a "Close" menu item to the Window's submenu, and it should be the first item. Its key equivalent should map to command w. Without this, you cannot close the game window via this shortcut, and you cannot close the app's About window via this shortcut. 4. Apps typically use "Enter Full Screen" or "Exit Full Screen" depending on context, not "Toggle Full Screen" which is less user friendly -- I personally care about this point the least.
This commit is contained in:
parent
70ce0f2e06
commit
1c9595b16f
|
@ -275,7 +275,6 @@ CreateApplicationMenus(void)
|
||||||
NSMenu *appleMenu;
|
NSMenu *appleMenu;
|
||||||
NSMenu *serviceMenu;
|
NSMenu *serviceMenu;
|
||||||
NSMenu *windowMenu;
|
NSMenu *windowMenu;
|
||||||
NSMenu *viewMenu;
|
|
||||||
NSMenuItem *menuItem;
|
NSMenuItem *menuItem;
|
||||||
NSMenu *mainMenu;
|
NSMenu *mainMenu;
|
||||||
|
|
||||||
|
@ -342,9 +341,22 @@ CreateApplicationMenus(void)
|
||||||
windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
|
windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
|
||||||
|
|
||||||
/* Add menu items */
|
/* Add menu items */
|
||||||
|
[windowMenu addItemWithTitle:@"Close" action:@selector(performClose:) keyEquivalent:@"w"];
|
||||||
|
|
||||||
[windowMenu addItemWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"];
|
[windowMenu addItemWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"];
|
||||||
|
|
||||||
[windowMenu addItemWithTitle:@"Zoom" action:@selector(performZoom:) keyEquivalent:@""];
|
[windowMenu addItemWithTitle:@"Zoom" action:@selector(performZoom:) keyEquivalent:@""];
|
||||||
|
|
||||||
|
/* Add the fullscreen toggle menu option, if supported */
|
||||||
|
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) {
|
||||||
|
/* Cocoa should update the title to Enter or Exit Full Screen automatically.
|
||||||
|
* But if not, then just fallback to Toggle Full Screen.
|
||||||
|
*/
|
||||||
|
menuItem = [[NSMenuItem alloc] initWithTitle:@"Toggle Full Screen" action:@selector(toggleFullScreen:) keyEquivalent:@"f"];
|
||||||
|
[menuItem setKeyEquivalentModifierMask:NSEventModifierFlagControl | NSEventModifierFlagCommand];
|
||||||
|
[windowMenu addItem:menuItem];
|
||||||
|
[menuItem release];
|
||||||
|
}
|
||||||
|
|
||||||
/* Put menu into the menubar */
|
/* Put menu into the menubar */
|
||||||
menuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
|
menuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""];
|
||||||
|
@ -355,25 +367,6 @@ CreateApplicationMenus(void)
|
||||||
/* Tell the application object that this is now the window menu */
|
/* Tell the application object that this is now the window menu */
|
||||||
[NSApp setWindowsMenu:windowMenu];
|
[NSApp setWindowsMenu:windowMenu];
|
||||||
[windowMenu release];
|
[windowMenu release];
|
||||||
|
|
||||||
|
|
||||||
/* Add the fullscreen view toggle menu option, if supported */
|
|
||||||
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6) {
|
|
||||||
/* Create the view menu */
|
|
||||||
viewMenu = [[NSMenu alloc] initWithTitle:@"View"];
|
|
||||||
|
|
||||||
/* Add menu items */
|
|
||||||
menuItem = [viewMenu addItemWithTitle:@"Toggle Full Screen" action:@selector(toggleFullScreen:) keyEquivalent:@"f"];
|
|
||||||
[menuItem setKeyEquivalentModifierMask:NSEventModifierFlagControl | NSEventModifierFlagCommand];
|
|
||||||
|
|
||||||
/* Put menu into the menubar */
|
|
||||||
menuItem = [[NSMenuItem alloc] initWithTitle:@"View" action:nil keyEquivalent:@""];
|
|
||||||
[menuItem setSubmenu:viewMenu];
|
|
||||||
[[NSApp mainMenu] addItem:menuItem];
|
|
||||||
[menuItem release];
|
|
||||||
|
|
||||||
[viewMenu release];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -1356,6 +1356,11 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window)
|
||||||
return SDL_SetError("%s", [[e reason] UTF8String]);
|
return SDL_SetError("%s", [[e reason] UTF8String]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* By default, don't allow users to make our window tabbed in 10.12 or later */
|
||||||
|
if ([nswindow respondsToSelector:@selector(setTabbingMode:)]) {
|
||||||
|
[nswindow setTabbingMode:NSWindowTabbingModeDisallowed];
|
||||||
|
}
|
||||||
|
|
||||||
if (videodata->allow_spaces) {
|
if (videodata->allow_spaces) {
|
||||||
SDL_assert(floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6);
|
SDL_assert(floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6);
|
||||||
SDL_assert([nswindow respondsToSelector:@selector(toggleFullScreen:)]);
|
SDL_assert([nswindow respondsToSelector:@selector(toggleFullScreen:)]);
|
||||||
|
|
Loading…
Reference in a new issue