summaryrefslogtreecommitdiff
path: root/platform/osx/godot_osx.mm
diff options
context:
space:
mode:
Diffstat (limited to 'platform/osx/godot_osx.mm')
-rw-r--r--platform/osx/godot_osx.mm48
1 files changed, 23 insertions, 25 deletions
diff --git a/platform/osx/godot_osx.mm b/platform/osx/godot_osx.mm
index c35cd78334..626406ad1d 100644
--- a/platform/osx/godot_osx.mm
+++ b/platform/osx/godot_osx.mm
@@ -27,14 +27,15 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#include "godot_osx.h"
+
#include <sys/param.h> /* for MAXPATHLEN */
#include <unistd.h>
-#include "godot_osx.h"
/* For some reaon, Apple removed setAppleMenu from the headers in 10.4,
but the method still is there and works. To avoid warnings, we declare
it ourselves here. */
-@interface NSApplication()
+@interface NSApplication ()
- (void)setAppleMenu:(NSMenu *)menu;
@end
@@ -49,7 +50,7 @@ static NSString *getApplicationName(void) {
/* Determine the application name */
dict = (const NSDictionary *)CFBundleGetInfoDictionary(CFBundleGetMainBundle());
if (dict)
- appName = [dict objectForKey: @"CFBundleName"];
+ appName = [dict objectForKey:@"CFBundleName"];
if (![appName length])
appName = [[NSProcessInfo processInfo] processName];
@@ -80,7 +81,7 @@ static void setApplicationMenu(void) {
[appleMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"];
menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
- [menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)];
+ [menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask | NSCommandKeyMask)];
[appleMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""];
@@ -89,7 +90,6 @@ static void setApplicationMenu(void) {
title = [@"Quit " stringByAppendingString:appName];
[appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];
-
/* Put menu into the menubar */
menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
[menuItem setSubmenu:appleMenu];
@@ -105,9 +105,9 @@ static void setApplicationMenu(void) {
/* Create a window menu */
static void setupWindowMenu(void) {
- NSMenu *windowMenu;
- NSMenuItem *windowMenuItem;
- NSMenuItem *menuItem;
+ NSMenu *windowMenu;
+ NSMenuItem *windowMenuItem;
+ NSMenuItem *menuItem;
windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
@@ -130,9 +130,9 @@ static void setupWindowMenu(void) {
}
/* Replacement for NSApplicationMain */
-static void CustomApplicationMain (int argc, char **argv) {
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- GodotMain *main;
+static void CustomApplicationMain(int argc, char **argv) {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ GodotMain *main;
/* Ensure the application object is initialised */
[NSApplication sharedApplication];
@@ -152,10 +152,10 @@ static void CustomApplicationMain (int argc, char **argv) {
[pool release];
}
-extern int godot_main(int argc, char** argv);
+extern int godot_main(int argc, char **argv);
/* Called when the internal event loop has just started running */
-- (void) applicationDidFinishLaunching: (NSNotification *) note {
+- (void)applicationDidFinishLaunching:(NSNotification *)note {
int status;
/* Hand off to main application code */
@@ -168,15 +168,14 @@ extern int godot_main(int argc, char** argv);
@end
#ifdef main
-# undef main
+#undef main
#endif
-
-int main (int argc, char **argv) {
+int main(int argc, char **argv) {
/* Copy the arguments into a global variable */
/* This is passed if we are launched by double-clicking */
- if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) {
- global_argv = (char **) malloc(sizeof (char *) * 2);
+ if (argc >= 2 && strncmp(argv[1], "-psn", 4) == 0) {
+ global_argv = (char **)malloc(sizeof(char *) * 2);
global_argv[0] = argv[0];
global_argv[1] = NULL;
global_argc = 1;
@@ -184,14 +183,14 @@ int main (int argc, char **argv) {
// chdir to binary's dir when launched from finder
int len = strlen(global_argv[0]);
- while (len--){
+ while (len--) {
if (global_argv[0][len] == '/') break;
}
- if (len>=0) {
- char *path = (char *)malloc(len+1);
+ if (len >= 0) {
+ char *path = (char *)malloc(len + 1);
memcpy(path, global_argv[0], len);
- path[len]=0;
+ path[len] = 0;
printf("Path: %s\n", path);
chdir(path);
}
@@ -199,12 +198,11 @@ int main (int argc, char **argv) {
} else {
int i;
global_argc = argc;
- global_argv = (char **) malloc(sizeof (char *) * (argc+1));
+ global_argv = (char **)malloc(sizeof(char *) * (argc + 1));
for (i = 0; i <= argc; i++)
global_argv[i] = argv[i];
}
- CustomApplicationMain (argc, argv);
+ CustomApplicationMain(argc, argv);
return 0;
}
-