1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
|
diff --git a/gfx/drivers_context/cocoa_gl_ctx.m b/gfx/drivers_context/cocoa_gl_ctx.m
index e67725f..868d874 100644
--- a/gfx/drivers_context/cocoa_gl_ctx.m
+++ b/gfx/drivers_context/cocoa_gl_ctx.m
@@ -83,6 +83,7 @@ static NSOpenGLPixelFormat* g_format;
static unsigned g_minor = 0;
static unsigned g_major = 0;
+static bool g_is_inited = false;
/* forward declaration */
void *nsview_get_ptr(void);
@@ -152,6 +153,9 @@ static bool cocoagl_gfx_ctx_init(void *data)
{
(void)data;
+ if (g_is_inited)
+ return true;
+
#if defined(HAVE_COCOA)
CocoaView *g_view = (CocoaView*)nsview_get_ptr();
#if MAC_OS_X_VERSION_10_7
@@ -196,6 +200,11 @@ static bool cocoagl_gfx_ctx_init(void *data)
[g_context makeCurrentContext];
// Make sure the view was created
[CocoaView get];
+#if defined(HAVE_COCOA)
+ [NSApp setDelegate:g_view];
+#endif
+
+ g_is_inited = true;
return true;
}
@@ -221,6 +230,8 @@ static void cocoagl_gfx_ctx_destroy(void *data)
#endif
[GLContextClass clearCurrentContext];
g_context = nil;
+
+ g_is_inited = false;
}
static bool cocoagl_gfx_ctx_bind_api(void *data, enum gfx_ctx_api api, unsigned major, unsigned minor)
diff --git a/pkg/apple/OSX/Info.plist b/pkg/apple/OSX/Info.plist
index 8d59658..af95482 100644
--- a/pkg/apple/OSX/Info.plist
+++ b/pkg/apple/OSX/Info.plist
@@ -41,8 +41,6 @@
<true/>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2015 RetroArch. All rights reserved.</string>
- <key>NSMainNibFile</key>
- <string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>RApplication</string>
</dict>
diff --git a/pkg/apple/RetroArch.xcodeproj/project.pbxproj b/pkg/apple/RetroArch.xcodeproj/project.pbxproj
index a7c1b57..e48f0bf 100644
--- a/pkg/apple/RetroArch.xcodeproj/project.pbxproj
+++ b/pkg/apple/RetroArch.xcodeproj/project.pbxproj
@@ -7,9 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
- 1DDD58160DA1D0A300B32029 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1DDD58140DA1D0A300B32029 /* MainMenu.xib */; };
500845251B89300700CE6073 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
- 500845261B89300700CE6073 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1DDD58140DA1D0A300B32029 /* MainMenu.xib */; };
500845271B89300700CE6073 /* retroarch.icns in Resources */ = {isa = PBXBuildFile; fileRef = 84DD5EB71A89F1C7007336C1 /* retroarch.icns */; };
500845291B89300700CE6073 /* griffin_objc.m in Sources */ = {isa = PBXBuildFile; fileRef = 509F0C9C1AA23AFC00619ECC /* griffin_objc.m */; };
5008452A1B89300700CE6073 /* griffin.c in Sources */ = {isa = PBXBuildFile; fileRef = 840222FB1A889EE2009AB261 /* griffin.c */; };
@@ -75,7 +73,6 @@
/* Begin PBXFileReference section */
089C165DFE840E0CC02AAC07 /* InfoPlist.strings */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = InfoPlist.strings; path = OSX/en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
- 1DDD58150DA1D0A300B32029 /* MainMenu.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = MainMenu.xib; path = OSX/en.lproj/MainMenu.xib; sourceTree = "<group>"; };
29B97324FDCFA39411CA2CEA /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; };
5008453A1B89300700CE6073 /* RetroArch copy.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "RetroArch copy.app"; sourceTree = BUILT_PRODUCTS_DIR; };
5008453B1B89300700CE6073 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = "Info.plist"; path = "/../../pkg/apple/OSX/Info.plist"; sourceTree = SOURCE_ROOT; };
@@ -196,7 +193,6 @@
84DD5EB71A89F1C7007336C1 /* retroarch.icns */,
8D1107310486CEB800E47090 /* Info.plist */,
089C165CFE840E0CC02AAC07 /* InfoPlist.strings */,
- 1DDD58140DA1D0A300B32029 /* MainMenu.xib */,
);
name = Resources;
sourceTree = "<group>";
@@ -301,7 +297,6 @@
buildActionMask = 2147483647;
files = (
500845251B89300700CE6073 /* InfoPlist.strings in Resources */,
- 500845261B89300700CE6073 /* MainMenu.xib in Resources */,
500845271B89300700CE6073 /* retroarch.icns in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -311,7 +306,6 @@
buildActionMask = 2147483647;
files = (
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */,
- 1DDD58160DA1D0A300B32029 /* MainMenu.xib in Resources */,
84DD5EB81A89F1C7007336C1 /* retroarch.icns in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -348,14 +342,6 @@
name = InfoPlist.strings;
sourceTree = "<group>";
};
- 1DDD58140DA1D0A300B32029 /* MainMenu.xib */ = {
- isa = PBXVariantGroup;
- children = (
- 1DDD58150DA1D0A300B32029 /* MainMenu.xib */,
- );
- name = MainMenu.xib;
- sourceTree = "<group>";
- };
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
diff --git a/ui/drivers/ui_cocoa.m b/ui/drivers/ui_cocoa.m
index 5dde6f9..37cd066 100644
--- a/ui/drivers/ui_cocoa.m
+++ b/ui/drivers/ui_cocoa.m
@@ -421,10 +421,50 @@ extern void action_ok_push_quick_menu(void);
@end
+static void setup_appkit(void)
+{
+ [NSAutoreleasePool new];
+ [NSApplication sharedApplication];
+
+ /* Might be Snow Leopard (10.6) only and up */
+ [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
+
+ id menubar = [[NSMenu new] autorelease];
+ id appMenuItem = [[NSMenuItem new] autorelease];
+
+ [menubar addItem:appMenuItem];
+ [NSApp setMainMenu:menubar];
+
+ /* Add 'Quit' to menu */
+ id appMenu = [[NSMenu new] autorelease];
+ id appName = [[NSProcessInfo processInfo] processName];
+ id quitTitle = BOXSTRING("Quit");
+ id quitMenuItem = [[[NSMenuItem alloc] initWithTitle:quitTitle
+ action:@selector(terminate:) keyEquivalent:BOXSTRING("q")] autorelease];
+ [appMenu addItem:quitMenuItem];
+ [appMenuItem setSubmenu:appMenu];
+
+ /* Create a window and activate the application */
+ id window = [[[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 200, 200) styleMask:NSTitledWindowMask backing:NSBackingStoreBuffered defer:NO] autorelease];
+ [window cascadeTopLeftFromPoint:NSMakePoint(20,20)];
+ [window setTitle:appName];
+ [window makeKeyAndOrderFront:nil];
+
+ cocoagl_gfx_ctx_init(NULL);
+ [window setContentView:(CocoaView*)nsview_get_ptr()];
+
+ /* Start the application */
+ [NSApp activateIgnoringOtherApps:YES]; /* Brings application to front on startup */
+ [NSApp run];
+}
+
int main(int argc, char *argv[])
{
waiting_argc = argc;
waiting_argv = argv;
+
+ setup_appkit();
+
return NSApplicationMain(argc, (const char **) argv);
}
|