Skip to content

Commit

Permalink
Fix bad merge of utils_macosx.mm to restore OSX builds
Browse files Browse the repository at this point in the history
  • Loading branch information
ikatz-drizly committed Mar 29, 2019
1 parent bb3b68a commit 7c73849
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions BasiliskII/src/MacOSX/utils_macosx.mm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,13 @@
*/

#include <Cocoa/Cocoa.h>
#include "sysdeps.h"
#include "utils_macosx.h"
#include <SDL.h>

#if SDL_VERSION_ATLEAST(2,0,0)
#include <SDL_syswm.h>
#endif

// This is used from video_sdl.cpp.
void NSAutoReleasePool_wrap(void (*fn)(void))
Expand All @@ -28,3 +34,50 @@ void NSAutoReleasePool_wrap(void (*fn)(void))
fn();
[pool release];
}

#if SDL_VERSION_ATLEAST(2,0,0)

void disable_SDL2_macosx_menu_bar_keyboard_shortcuts() {
for (NSMenuItem * menu_item in [NSApp mainMenu].itemArray) {
if (menu_item.hasSubmenu) {
for (NSMenuItem * sub_item in menu_item.submenu.itemArray) {
sub_item.keyEquivalent = @"";
sub_item.keyEquivalentModifierMask = 0;
}
}
if ([menu_item.title isEqualToString:@"View"]) {
[[NSApp mainMenu] removeItem:menu_item];
break;
}
}
}

bool is_fullscreen_osx(SDL_Window * window)
{
if (!window) {
return false;
}

SDL_SysWMinfo wmInfo;
SDL_VERSION(&wmInfo.version);
if (!SDL_GetWindowWMInfo(window, &wmInfo)) {
return false;
}

const NSWindowStyleMask styleMask = [wmInfo.info.cocoa.window styleMask];
return (styleMask & NSWindowStyleMaskFullScreen) != 0;
}
#endif

void set_menu_bar_visible_osx(bool visible)
{
[NSMenu setMenuBarVisible:(visible ? YES : NO)];
}

void set_current_directory()
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
chdir([[[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] UTF8String]);
[pool release];
}

0 comments on commit 7c73849

Please sign in to comment.