Added Max's patches for building MacOS X apps on command line
authorSam Lantinga <slouken@libsdl.org>
Tue, 04 Sep 2001 23:18:45 +0000
changeset 168e92aa316c517
parent 167 cb384ef627f6
child 169 8039a5b760b9
Added Max's patches for building MacOS X apps on command line
Makefile.am
PBProjects.tar.gz
configure.in
sdl-config.in
sdl.m4
src/main/Makefile.am
src/main/macosx/Info.plist
src/main/macosx/Makefile.am
src/main/macosx/SDLMain.h
src/main/macosx/SDLMain.m
src/main/macosx/SDLMain.nib/classes.nib
src/main/macosx/SDLMain.nib/info.nib
src/main/macosx/SDLMain.nib/objects.nib
src/video/maccommon/SDL_macevents.c
src/video/maccommon/SDL_macmouse.c
src/video/quartz/Makefile.am
src/video/quartz/SDL_QuartzEvents.m
src/video/quartz/SDL_QuartzWM.m
     1.1 --- a/Makefile.am	Tue Sep 04 22:53:46 2001 +0000
     1.2 +++ b/Makefile.am	Tue Sep 04 23:18:45 2001 +0000
     1.3 @@ -61,7 +61,7 @@
     1.4  PBProjects.tar.gz:
     1.5  	rm -f `find . -name .DS_Store`
     1.6  	if [ -d PBProjects ]; then \
     1.7 -	    tar zcvf $@ PBProjects src/main/macosx/SDLMain.nib; \
     1.8 +	    tar zcvf $@ PBProjects; \
     1.9  	fi
    1.10  
    1.11  # Rule to force automake to rebuild the library
     2.1 Binary file PBProjects.tar.gz has changed
     3.1 --- a/configure.in	Tue Sep 04 22:53:46 2001 +0000
     3.2 +++ b/configure.in	Tue Sep 04 23:18:45 2001 +0000
     3.3 @@ -2191,6 +2191,7 @@
     3.4  include/Makefile
     3.5  src/Makefile
     3.6  src/main/Makefile
     3.7 +src/main/macosx/Makefile
     3.8  src/audio/Makefile
     3.9  src/audio/alsa/Makefile
    3.10  src/audio/arts/Makefile
     4.1 --- a/sdl-config.in	Tue Sep 04 22:53:46 2001 +0000
     4.2 +++ b/sdl-config.in	Tue Sep 04 23:18:45 2001 +0000
     4.3 @@ -56,6 +56,12 @@
     4.4  @ENABLE_STATIC_TRUE@      libdirs="-L@libdir@ @SDL_RLD_FLAGS@"
     4.5  @ENABLE_STATIC_TRUE@      echo $libdirs @SDL_LIBS@ @SYSTEM_LIBS@
     4.6  @ENABLE_STATIC_TRUE@      ;;
     4.7 +@TARGET_MACOSX_TRUE@    --nib)
     4.8 +@TARGET_MACOSX_TRUE@      echo @datadir@/sdl/SDLMain.nib
     4.9 +@TARGET_MACOSX_TRUE@      ;;
    4.10 +@TARGET_MACOSX_TRUE@    --plist)
    4.11 +@TARGET_MACOSX_TRUE@      echo @datadir@/sdl/Info.plist
    4.12 +@TARGET_MACOSX_TRUE@      ;;
    4.13      *)
    4.14        echo "${usage}" 1>&2
    4.15        exit 1
     5.1 --- a/sdl.m4	Tue Sep 04 22:53:46 2001 +0000
     5.2 +++ b/sdl.m4	Tue Sep 04 23:18:45 2001 +0000
     5.3 @@ -58,6 +58,17 @@
     5.4  dnl checks the results of sdl-config to some extent
     5.5  dnl
     5.6        rm -f conf.sdltest
     5.7 +      case "$target" in
     5.8 +          *-*-darwin*)
     5.9 +            cp -r `$SDL_CONFIG --nib` .
    5.10 +            dnl create an Info.plist file, unless one exists
    5.11 +            if test -f Info.plist ; then
    5.12 +             :
    5.13 +            else
    5.14 +             cp `$SDL_CONFIG --plist` .
    5.15 +            fi
    5.16 +              ;;
    5.17 +      esac
    5.18        AC_TRY_RUN([
    5.19  #include <stdio.h>
    5.20  #include <stdlib.h>
    5.21 @@ -169,5 +180,11 @@
    5.22    fi
    5.23    AC_SUBST(SDL_CFLAGS)
    5.24    AC_SUBST(SDL_LIBS)
    5.25 +      case "$target" in
    5.26 +          *-*-darwin*)
    5.27 +              SDL_APPLE_CREATOR="????"
    5.28 +              AC_SUBST(SDL_APPLE_CREATOR)
    5.29 +              ;;
    5.30 +      esac
    5.31    rm -f conf.sdltest
    5.32  ])
     6.1 --- a/src/main/Makefile.am	Tue Sep 04 22:53:46 2001 +0000
     6.2 +++ b/src/main/Makefile.am	Tue Sep 04 23:18:45 2001 +0000
     6.3 @@ -4,6 +4,8 @@
     6.4  # This is necessary because some platforms have special program
     6.5  # entry points, which require special application initialization.
     6.6  
     6.7 +SUBDIRS = macosx
     6.8 +
     6.9  ARCH_SUBDIRS = $(srcdir)/beos $(srcdir)/linux \
    6.10                 $(srcdir)/macos $(srcdir)/macosx $(srcdir)/win32
    6.11  
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/src/main/macosx/Info.plist	Tue Sep 04 23:18:45 2001 +0000
     7.3 @@ -0,0 +1,22 @@
     7.4 +<?xml version="1.0" encoding="UTF-8"?>
     7.5 +<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
     7.6 +<plist version="0.9">
     7.7 +<dict>
     7.8 +	<key>CFBundleDevelopmentRegion</key>
     7.9 +	<string>English</string>
    7.10 +	<key>CFBundleExecutable</key>
    7.11 +	<string>dummy</string>
    7.12 +	<key>CFBundleInfoDictionaryVersion</key>
    7.13 +	<string>6.0</string>
    7.14 +	<key>CFBundleName</key>
    7.15 +	<string>dummy</string>
    7.16 +	<key>CFBundlePackageType</key>
    7.17 +	<string>APPL</string>
    7.18 +	<key>CFBundleSignature</key>
    7.19 +	<string>????</string>
    7.20 +	<key>NSMainNibFile</key>
    7.21 +	<string>SDLMain.nib</string>
    7.22 +	<key>NSPrincipalClass</key>
    7.23 +	<string>NSApplication</string>
    7.24 +</dict>
    7.25 +</plist>
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/src/main/macosx/Makefile.am	Tue Sep 04 23:18:45 2001 +0000
     8.3 @@ -0,0 +1,17 @@
     8.4 +# On OS X, install the SDLMain.nib.
     8.5 +# We use an ugly hack to force the creation of the
     8.6 +# destination dir, maybe somebody with more automake
     8.7 +# experience knows how to do this properly?
     8.8 +
     8.9 +if TARGET_MACOSX
    8.10 +masternibdatadir = $(datadir)/sdl/SDLMain.nib
    8.11 +masternibdata_DATA =		\
    8.12 +	SDLMain.nib
    8.13 +
    8.14 +nibdatadir = $(datadir)/sdl
    8.15 +nibdata_DATA =			\
    8.16 +	SDLMain.nib/classes.nib	\
    8.17 +	SDLMain.nib/info.nib	\
    8.18 +	SDLMain.nib/objects.nib	\
    8.19 +	Info.plist
    8.20 +endif
     9.1 --- a/src/main/macosx/SDLMain.h	Tue Sep 04 22:53:46 2001 +0000
     9.2 +++ b/src/main/macosx/SDLMain.h	Tue Sep 04 23:18:45 2001 +0000
     9.3 @@ -10,5 +10,6 @@
     9.4  {
     9.5  }
     9.6  - (IBAction)quit:(id)sender;
     9.7 +- (IBAction)makeFullscreen:(id)sender;
     9.8  - (void)applicationDidFinishLaunching:(NSNotification *)aNotification;
     9.9  @end
    10.1 --- a/src/main/macosx/SDLMain.m	Tue Sep 04 22:53:46 2001 +0000
    10.2 +++ b/src/main/macosx/SDLMain.m	Tue Sep 04 23:18:45 2001 +0000
    10.3 @@ -12,6 +12,7 @@
    10.4  static int    gArgc;
    10.5  static char  **gArgv;
    10.6  static NSString *gAppName = 0;
    10.7 +static BOOL   gFinderLaunch;
    10.8  
    10.9  @interface NSString (ReplaceSubString)
   10.10  - (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString;
   10.11 @@ -29,15 +30,21 @@
   10.12      SDL_PushEvent(&event);
   10.13  }
   10.14  
   10.15 +/* Invoked from the Make Full-Screen menu item */
   10.16 +- (void) makeFullscreen:(id)sender
   10.17 +{
   10.18 +    /* TODO */
   10.19 +}
   10.20 +
   10.21  /* Set the working directory to the .app's parent directory */
   10.22 -- (void) setupWorkingDirectory
   10.23 +- (void) setupWorkingDirectory:(BOOL)shouldChdir
   10.24  {
   10.25      char parentdir[MAXPATHLEN];
   10.26      char *c;
   10.27      
   10.28      strncpy ( parentdir, gArgv[0], sizeof(parentdir) );
   10.29      c = (char*) parentdir;
   10.30 -    
   10.31 +
   10.32      while (*c != '\0')     /* go to end */
   10.33          c++;
   10.34      
   10.35 @@ -45,11 +52,13 @@
   10.36          c--;
   10.37      
   10.38      *c++ = '\0';             /* cut off last part (binary name) */
   10.39 -    
   10.40 -    assert ( chdir (parentdir) == 0 );   /* chdir to the binary app's parent */
   10.41 -    assert ( chdir ("../../../") == 0 ); /* chdir to the .app's parent */
   10.42 -    
   10.43 -    gAppName = [ NSString stringWithCString: c ];
   10.44 +  
   10.45 +    if (shouldChdir)
   10.46 +    {
   10.47 +      assert ( chdir (parentdir) == 0 );   /* chdir to the binary app's parent */
   10.48 +      assert ( chdir ("../../../") == 0 ); /* chdir to the .app's parent */
   10.49 +    }
   10.50 +    /* gAppName = [ NSString stringWithCString: c ]; */
   10.51  }
   10.52  
   10.53  /* Fix menu to contain the real app name instead of "SDL App" */
   10.54 @@ -81,9 +90,10 @@
   10.55      int status;
   10.56  
   10.57      /* Set the working directory to the .app's parent directory */
   10.58 -    [ self setupWorkingDirectory ];
   10.59 +    [ self setupWorkingDirectory: gFinderLaunch ];
   10.60  
   10.61      /* Set the main menu to contain the real app name instead of "SDL App" */
   10.62 +    gAppName = [ [ NSBundle mainBundle ] bundleIdentifier ];
   10.63      [ self fixMenu: [ NSApp mainMenu ] ];
   10.64  
   10.65      /* Hand off to main application code */
   10.66 @@ -148,8 +158,10 @@
   10.67      /* This is passed if we are launched by double-clicking */
   10.68      if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) {
   10.69          gArgc = 1;
   10.70 +	gFinderLaunch = YES;
   10.71      } else {
   10.72          gArgc = argc;
   10.73 +	gFinderLaunch = NO;
   10.74      }
   10.75      gArgv = (char**) malloc (sizeof(*gArgv) * (gArgc+1));
   10.76      assert (gArgv != NULL);
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/src/main/macosx/SDLMain.nib/classes.nib	Tue Sep 04 23:18:45 2001 +0000
    11.3 @@ -0,0 +1,12 @@
    11.4 +{
    11.5 +    IBClasses = (
    11.6 +        {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, 
    11.7 +        {
    11.8 +            ACTIONS = {makeFullscreen = id; quit = id; }; 
    11.9 +            CLASS = SDLMain; 
   11.10 +            LANGUAGE = ObjC; 
   11.11 +            SUPERCLASS = NSObject; 
   11.12 +        }
   11.13 +    ); 
   11.14 +    IBVersion = 1; 
   11.15 +}
   11.16 \ No newline at end of file
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/src/main/macosx/SDLMain.nib/info.nib	Tue Sep 04 23:18:45 2001 +0000
    12.3 @@ -0,0 +1,12 @@
    12.4 +<?xml version="1.0" encoding="UTF-8"?>
    12.5 +<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
    12.6 +<plist version="0.9">
    12.7 +<dict>
    12.8 +	<key>IBDocumentLocation</key>
    12.9 +	<string>49 97 356 240 0 0 987 746 </string>
   12.10 +	<key>IBMainMenuLocation</key>
   12.11 +	<string>20 515 195 44 0 46 800 532 </string>
   12.12 +	<key>IBUserGuides</key>
   12.13 +	<dict/>
   12.14 +</dict>
   12.15 +</plist>
    13.1 Binary file src/main/macosx/SDLMain.nib/objects.nib has changed
    14.1 --- a/src/video/maccommon/SDL_macevents.c	Tue Sep 04 22:53:46 2001 +0000
    14.2 +++ b/src/video/maccommon/SDL_macevents.c	Tue Sep 04 23:18:45 2001 +0000
    14.3 @@ -72,7 +72,7 @@
    14.4  		SDL_SetCursor(NULL);
    14.5  
    14.6  		/* put our mask back case it changed during context switch */
    14.7 -		SetEventMask(everyEvent - autoKeyMask);
    14.8 +		SetEventMask(everyEvent & ~autoKeyMask);
    14.9  	} else {
   14.10  #if TARGET_API_MAC_CARBON
   14.11  		{ Cursor cursor;
   14.12 @@ -617,7 +617,7 @@
   14.13  	FlushEvents(everyEvent, 0);
   14.14  	
   14.15  	/* Allow every event but keyrepeat */
   14.16 -	SetEventMask(everyEvent - autoKeyMask);
   14.17 +	SetEventMask(everyEvent & ~autoKeyMask);
   14.18  }
   14.19  
   14.20  void Mac_QuitEvents(_THIS)
    15.1 --- a/src/video/maccommon/SDL_macmouse.c	Tue Sep 04 22:53:46 2001 +0000
    15.2 +++ b/src/video/maccommon/SDL_macmouse.c	Tue Sep 04 23:18:45 2001 +0000
    15.3 @@ -67,18 +67,22 @@
    15.4  		return(NULL);
    15.5  	}
    15.6  	memset(cursor, 0, sizeof(*cursor));
    15.7 -		
    15.8 -	bytes = (w/8);
    15.9 -	if ( bytes > 2 ) {
   15.10 -		bytes = 2;
   15.11 +    
   15.12 +    if (w > 16)
   15.13 +        w = 16;
   15.14 +    
   15.15 +    if (h > 16)
   15.16 +        h = 16;
   15.17 +    
   15.18 +	bytes = (w+7)/8;
   15.19 +
   15.20 +	for ( row=0; row<h; ++row ) {
   15.21 +		memcpy(&cursor->curs.data[row], data, bytes);
   15.22 +		data += bytes;
   15.23  	}
   15.24 -	for ( row=0; row<h && (row < 16); ++row ) {
   15.25 -		memcpy(&cursor->curs.data[row], data, bytes);
   15.26 -		data += w/8;
   15.27 -	}
   15.28 -	for ( row=0; row<h && (row < 16); ++row ) {
   15.29 +	for ( row=0; row<h; ++row ) {
   15.30  		memcpy(&cursor->curs.mask[row], mask, bytes);
   15.31 -		mask += w/8;
   15.32 +		mask += bytes;
   15.33  	}
   15.34  	cursor->curs.hotSpot.h = hot_x;
   15.35  	cursor->curs.hotSpot.v = hot_y;
    16.1 --- a/src/video/quartz/Makefile.am	Tue Sep 04 22:53:46 2001 +0000
    16.2 +++ b/src/video/quartz/Makefile.am	Tue Sep 04 23:18:45 2001 +0000
    16.3 @@ -11,7 +11,7 @@
    16.4  	SDL_QuartzVideo.m
    16.5  
    16.6  # These files are included by SDL_QuartzVideo.m (is that right??)
    16.7 -EXTRA_DIST = 			\
    16.8 +noinst_HEADERS =		\
    16.9  	SDL_QuartzEvents.m	\
   16.10  	SDL_QuartzWM.m		\
   16.11  	SDL_QuartzWindow.m
    17.1 --- a/src/video/quartz/SDL_QuartzEvents.m	Tue Sep 04 22:53:46 2001 +0000
    17.2 +++ b/src/video/quartz/SDL_QuartzEvents.m	Tue Sep 04 23:18:45 2001 +0000
    17.3 @@ -206,6 +206,12 @@
    17.4          QZ_WarpWMCursor (this, SDL_VideoSurface->w / 2, SDL_VideoSurface->h / 2);
    17.5          CGAssociateMouseAndMouseCursorPosition (0);
    17.6      }
    17.7 +
    17.8 +    /* Hide the mouse cursor if inside the app window */
    17.9 +    // FIXME
   17.10 +    if (!QZ_cursor_visible) {
   17.11 +            HideCursor ();
   17.12 +    }
   17.13      
   17.14      SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS);
   17.15  }
   17.16 @@ -218,6 +224,12 @@
   17.17      if (currentGrabMode == SDL_GRAB_ON) {
   17.18          CGAssociateMouseAndMouseCursorPosition (1);
   17.19      }
   17.20 +
   17.21 +    /* Show the mouse cursor */
   17.22 +    // FIXME
   17.23 +    if (!QZ_cursor_visible) {
   17.24 +            ShowCursor ();
   17.25 +    }
   17.26      
   17.27      SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS);
   17.28  }
   17.29 @@ -309,6 +321,8 @@
   17.30              case NSRightMouseDragged:
   17.31              case 27:
   17.32              case NSMouseMoved:
   17.33 +                if ( (SDL_VideoSurface->flags & SDL_FULLSCREEN)
   17.34 +                	|| NSPointInRect([event locationInWindow], winRect) )
   17.35                  {
   17.36                     static int moves = 0;
   17.37                     NSPoint p;
    18.1 --- a/src/video/quartz/SDL_QuartzWM.m	Tue Sep 04 22:53:46 2001 +0000
    18.2 +++ b/src/video/quartz/SDL_QuartzWM.m	Tue Sep 04 23:18:45 2001 +0000
    18.3 @@ -35,46 +35,52 @@
    18.4                                            int w, int h, int hot_x, int hot_y) { 
    18.5  	WMcursor *cursor;
    18.6  	int row, bytes;
    18.7 +		
    18.8 +	/* Allocate the cursor memory */
    18.9  	cursor = (WMcursor *)malloc(sizeof(WMcursor));
   18.10  	if ( cursor == NULL ) {
   18.11  		SDL_OutOfMemory();
   18.12  		return(NULL);
   18.13  	}
   18.14  	memset(cursor, 0, sizeof(*cursor));
   18.15 -		
   18.16 -	bytes = (w/8);
   18.17 -	if ( bytes > 2 ) {
   18.18 -		bytes = 2;
   18.19 +    
   18.20 +    if (w > 16)
   18.21 +        w = 16;
   18.22 +    
   18.23 +    if (h > 16)
   18.24 +        h = 16;
   18.25 +    
   18.26 +	bytes = (w+7)/8;
   18.27 +
   18.28 +	for ( row=0; row<h; ++row ) {
   18.29 +		memcpy(&cursor->curs.data[row], data, bytes);
   18.30 +		data += bytes;
   18.31  	}
   18.32 -	for ( row=0; row<h && (row < 16); ++row ) {
   18.33 -		memcpy(&cursor->curs.data[row], data, bytes);
   18.34 -		data += w/8;
   18.35 -	}
   18.36 -	for ( row=0; row<h && (row < 16); ++row ) {
   18.37 +	for ( row=0; row<h; ++row ) {
   18.38  		memcpy(&cursor->curs.mask[row], mask, bytes);
   18.39 -		mask += w/8;
   18.40 +		mask += bytes;
   18.41  	}
   18.42  	cursor->curs.hotSpot.h = hot_x;
   18.43  	cursor->curs.hotSpot.v = hot_y;
   18.44  	
   18.45 -        return(cursor);
   18.46 +    return(cursor);
   18.47  }
   18.48  
   18.49 +static int QZ_cursor_visible = 1;
   18.50 +    
   18.51  static int QZ_ShowWMCursor (_THIS, WMcursor *cursor) { 
   18.52  
   18.53 -    static int visible = 1;
   18.54 -    
   18.55      if ( cursor == NULL) {
   18.56 -        if ( visible ) {
   18.57 +        if ( QZ_cursor_visible ) {
   18.58              HideCursor ();
   18.59 -            visible = 0;
   18.60 +            QZ_cursor_visible = 0;
   18.61          }
   18.62      }
   18.63      else {
   18.64          SetCursor(&cursor->curs);
   18.65 -        if ( ! visible ) {
   18.66 +        if ( ! QZ_cursor_visible ) {
   18.67              ShowCursor ();
   18.68 -            visible = 1;
   18.69 +            QZ_cursor_visible = 1;
   18.70          }
   18.71      }
   18.72