Skip to content

Commit

Permalink
Merge pull request #105 from ianfixes/2019-03-28_fix_bad_merge_osx
Browse files Browse the repository at this point in the history
Fix bad merge of utils_macosx.mm to restore OSX builds
  • Loading branch information
ianfixes authored Mar 29, 2019
2 parents bb3b68a + 2aaf5cf commit 0dee083
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ matrix:
- sudo hdiutil attach SDL2-2.0.9.dmg
- sudo cp -r /Volumes/SDL2/SDL2.framework /Library/Frameworks/
- cd BasiliskII/src/MacOSX
- xcodebuild -scheme BasiliskII -configuration Release build | xcpretty -f `xcpretty-travis-formatter` | grep -v -e '^[[:space:]]*$' | grep -v '^ ' && test ${PIPESTATUS[0]} -eq 0
- xcodebuild -scheme BasiliskII -configuration Release build CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY="" | xcpretty -f `xcpretty-travis-formatter` | grep -v -e '^[[:space:]]*$' | grep -v '^ ' && test ${PIPESTATUS[0]} -eq 0
- os: linux
dist: trusty
sudo: required
Expand Down Expand Up @@ -65,5 +65,5 @@ matrix:
- cd SheepShaver
- make links
- cd src/MacOSX
- xcodebuild -scheme kpx_cpu -configuration Release build | xcpretty -f `xcpretty-travis-formatter` | grep -v -e '^[[:space:]]*$' | grep -v '^ ' && test ${PIPESTATUS[0]} -eq 0
- xcodebuild -scheme SheepShaver -configuration Release build | xcpretty -f `xcpretty-travis-formatter` && exit ${PIPESTATUS[0]}
- xcodebuild -scheme kpx_cpu -configuration Release build CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY="" | xcpretty -f `xcpretty-travis-formatter` | grep -v -e '^[[:space:]]*$' | grep -v '^ ' && test ${PIPESTATUS[0]} -eq 0
- xcodebuild -scheme SheepShaver -configuration Release build CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY="" | xcpretty -f `xcpretty-travis-formatter` && exit ${PIPESTATUS[0]}
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 0dee083

Please sign in to comment.