Commit 23d3cf98 authored by Sam Lantinga's avatar Sam Lantinga

Added Max's patches for building MacOS X apps on command line

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40169
parent 9e856712
...@@ -61,7 +61,7 @@ exports: ...@@ -61,7 +61,7 @@ exports:
PBProjects.tar.gz: PBProjects.tar.gz:
rm -f `find . -name .DS_Store` rm -f `find . -name .DS_Store`
if [ -d PBProjects ]; then \ if [ -d PBProjects ]; then \
tar zcvf $@ PBProjects src/main/macosx/SDLMain.nib; \ tar zcvf $@ PBProjects; \
fi fi
# Rule to force automake to rebuild the library # Rule to force automake to rebuild the library
......
No preview for this file type
...@@ -2191,6 +2191,7 @@ docs/man3/Makefile ...@@ -2191,6 +2191,7 @@ docs/man3/Makefile
include/Makefile include/Makefile
src/Makefile src/Makefile
src/main/Makefile src/main/Makefile
src/main/macosx/Makefile
src/audio/Makefile src/audio/Makefile
src/audio/alsa/Makefile src/audio/alsa/Makefile
src/audio/arts/Makefile src/audio/arts/Makefile
......
...@@ -56,6 +56,12 @@ while test $# -gt 0; do ...@@ -56,6 +56,12 @@ while test $# -gt 0; do
@ENABLE_STATIC_TRUE@ libdirs="-L@libdir@ @SDL_RLD_FLAGS@" @ENABLE_STATIC_TRUE@ libdirs="-L@libdir@ @SDL_RLD_FLAGS@"
@ENABLE_STATIC_TRUE@ echo $libdirs @SDL_LIBS@ @SYSTEM_LIBS@ @ENABLE_STATIC_TRUE@ echo $libdirs @SDL_LIBS@ @SYSTEM_LIBS@
@ENABLE_STATIC_TRUE@ ;; @ENABLE_STATIC_TRUE@ ;;
@TARGET_MACOSX_TRUE@ --nib)
@TARGET_MACOSX_TRUE@ echo @datadir@/sdl/SDLMain.nib
@TARGET_MACOSX_TRUE@ ;;
@TARGET_MACOSX_TRUE@ --plist)
@TARGET_MACOSX_TRUE@ echo @datadir@/sdl/Info.plist
@TARGET_MACOSX_TRUE@ ;;
*) *)
echo "${usage}" 1>&2 echo "${usage}" 1>&2
exit 1 exit 1
......
...@@ -58,6 +58,17 @@ dnl Now check if the installed SDL is sufficiently new. (Also sanity ...@@ -58,6 +58,17 @@ dnl Now check if the installed SDL is sufficiently new. (Also sanity
dnl checks the results of sdl-config to some extent dnl checks the results of sdl-config to some extent
dnl dnl
rm -f conf.sdltest rm -f conf.sdltest
case "$target" in
*-*-darwin*)
cp -r `$SDL_CONFIG --nib` .
dnl create an Info.plist file, unless one exists
if test -f Info.plist ; then
:
else
cp `$SDL_CONFIG --plist` .
fi
;;
esac
AC_TRY_RUN([ AC_TRY_RUN([
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -169,5 +180,11 @@ int main(int argc, char *argv[]) ...@@ -169,5 +180,11 @@ int main(int argc, char *argv[])
fi fi
AC_SUBST(SDL_CFLAGS) AC_SUBST(SDL_CFLAGS)
AC_SUBST(SDL_LIBS) AC_SUBST(SDL_LIBS)
case "$target" in
*-*-darwin*)
SDL_APPLE_CREATOR="????"
AC_SUBST(SDL_APPLE_CREATOR)
;;
esac
rm -f conf.sdltest rm -f conf.sdltest
]) ])
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
# This is necessary because some platforms have special program # This is necessary because some platforms have special program
# entry points, which require special application initialization. # entry points, which require special application initialization.
SUBDIRS = macosx
ARCH_SUBDIRS = $(srcdir)/beos $(srcdir)/linux \ ARCH_SUBDIRS = $(srcdir)/beos $(srcdir)/linux \
$(srcdir)/macos $(srcdir)/macosx $(srcdir)/win32 $(srcdir)/macos $(srcdir)/macosx $(srcdir)/win32
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>dummy</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>dummy</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>NSMainNibFile</key>
<string>SDLMain.nib</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>
# On OS X, install the SDLMain.nib.
# We use an ugly hack to force the creation of the
# destination dir, maybe somebody with more automake
# experience knows how to do this properly?
if TARGET_MACOSX
masternibdatadir = $(datadir)/sdl/SDLMain.nib
masternibdata_DATA = \
SDLMain.nib
nibdatadir = $(datadir)/sdl
nibdata_DATA = \
SDLMain.nib/classes.nib \
SDLMain.nib/info.nib \
SDLMain.nib/objects.nib \
Info.plist
endif
...@@ -10,5 +10,6 @@ ...@@ -10,5 +10,6 @@
{ {
} }
- (IBAction)quit:(id)sender; - (IBAction)quit:(id)sender;
- (IBAction)makeFullscreen:(id)sender;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification; - (void)applicationDidFinishLaunching:(NSNotification *)aNotification;
@end @end
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
static int gArgc; static int gArgc;
static char **gArgv; static char **gArgv;
static NSString *gAppName = 0; static NSString *gAppName = 0;
static BOOL gFinderLaunch;
@interface NSString (ReplaceSubString) @interface NSString (ReplaceSubString)
- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString; - (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString;
...@@ -29,8 +30,14 @@ static NSString *gAppName = 0; ...@@ -29,8 +30,14 @@ static NSString *gAppName = 0;
SDL_PushEvent(&event); SDL_PushEvent(&event);
} }
/* Invoked from the Make Full-Screen menu item */
- (void) makeFullscreen:(id)sender
{
/* TODO */
}
/* Set the working directory to the .app's parent directory */ /* Set the working directory to the .app's parent directory */
- (void) setupWorkingDirectory - (void) setupWorkingDirectory:(BOOL)shouldChdir
{ {
char parentdir[MAXPATHLEN]; char parentdir[MAXPATHLEN];
char *c; char *c;
...@@ -46,10 +53,12 @@ static NSString *gAppName = 0; ...@@ -46,10 +53,12 @@ static NSString *gAppName = 0;
*c++ = '\0'; /* cut off last part (binary name) */ *c++ = '\0'; /* cut off last part (binary name) */
if (shouldChdir)
{
assert ( chdir (parentdir) == 0 ); /* chdir to the binary app's parent */ assert ( chdir (parentdir) == 0 ); /* chdir to the binary app's parent */
assert ( chdir ("../../../") == 0 ); /* chdir to the .app's parent */ assert ( chdir ("../../../") == 0 ); /* chdir to the .app's parent */
}
gAppName = [ NSString stringWithCString: c ]; /* gAppName = [ NSString stringWithCString: c ]; */
} }
/* Fix menu to contain the real app name instead of "SDL App" */ /* Fix menu to contain the real app name instead of "SDL App" */
...@@ -81,9 +90,10 @@ static NSString *gAppName = 0; ...@@ -81,9 +90,10 @@ static NSString *gAppName = 0;
int status; int status;
/* Set the working directory to the .app's parent directory */ /* Set the working directory to the .app's parent directory */
[ self setupWorkingDirectory ]; [ self setupWorkingDirectory: gFinderLaunch ];
/* Set the main menu to contain the real app name instead of "SDL App" */ /* Set the main menu to contain the real app name instead of "SDL App" */
gAppName = [ [ NSBundle mainBundle ] bundleIdentifier ];
[ self fixMenu: [ NSApp mainMenu ] ]; [ self fixMenu: [ NSApp mainMenu ] ];
/* Hand off to main application code */ /* Hand off to main application code */
...@@ -148,8 +158,10 @@ int main (int argc, char **argv) { ...@@ -148,8 +158,10 @@ int main (int argc, char **argv) {
/* This is passed if we are launched by double-clicking */ /* This is passed if we are launched by double-clicking */
if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) { if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) {
gArgc = 1; gArgc = 1;
gFinderLaunch = YES;
} else { } else {
gArgc = argc; gArgc = argc;
gFinderLaunch = NO;
} }
gArgv = (char**) malloc (sizeof(*gArgv) * (gArgc+1)); gArgv = (char**) malloc (sizeof(*gArgv) * (gArgc+1));
assert (gArgv != NULL); assert (gArgv != NULL);
......
{
IBClasses = (
{CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{
ACTIONS = {makeFullscreen = id; quit = id; };
CLASS = SDLMain;
LANGUAGE = ObjC;
SUPERCLASS = NSObject;
}
);
IBVersion = 1;
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
<dict>
<key>IBDocumentLocation</key>
<string>49 97 356 240 0 0 987 746 </string>
<key>IBMainMenuLocation</key>
<string>20 515 195 44 0 46 800 532 </string>
<key>IBUserGuides</key>
<dict/>
</dict>
</plist>
...@@ -72,7 +72,7 @@ static int Mac_HandleActivate(int activate) ...@@ -72,7 +72,7 @@ static int Mac_HandleActivate(int activate)
SDL_SetCursor(NULL); SDL_SetCursor(NULL);
/* put our mask back case it changed during context switch */ /* put our mask back case it changed during context switch */
SetEventMask(everyEvent - autoKeyMask); SetEventMask(everyEvent & ~autoKeyMask);
} else { } else {
#if TARGET_API_MAC_CARBON #if TARGET_API_MAC_CARBON
{ Cursor cursor; { Cursor cursor;
...@@ -617,7 +617,7 @@ void Mac_InitEvents(_THIS) ...@@ -617,7 +617,7 @@ void Mac_InitEvents(_THIS)
FlushEvents(everyEvent, 0); FlushEvents(everyEvent, 0);
/* Allow every event but keyrepeat */ /* Allow every event but keyrepeat */
SetEventMask(everyEvent - autoKeyMask); SetEventMask(everyEvent & ~autoKeyMask);
} }
void Mac_QuitEvents(_THIS) void Mac_QuitEvents(_THIS)
......
...@@ -68,17 +68,21 @@ WMcursor *Mac_CreateWMCursor(_THIS, ...@@ -68,17 +68,21 @@ WMcursor *Mac_CreateWMCursor(_THIS,
} }
memset(cursor, 0, sizeof(*cursor)); memset(cursor, 0, sizeof(*cursor));
bytes = (w/8); if (w > 16)
if ( bytes > 2 ) { w = 16;
bytes = 2;
} if (h > 16)
for ( row=0; row<h && (row < 16); ++row ) { h = 16;
bytes = (w+7)/8;
for ( row=0; row<h; ++row ) {
memcpy(&cursor->curs.data[row], data, bytes); memcpy(&cursor->curs.data[row], data, bytes);
data += w/8; data += bytes;
} }
for ( row=0; row<h && (row < 16); ++row ) { for ( row=0; row<h; ++row ) {
memcpy(&cursor->curs.mask[row], mask, bytes); memcpy(&cursor->curs.mask[row], mask, bytes);
mask += w/8; mask += bytes;
} }
cursor->curs.hotSpot.h = hot_x; cursor->curs.hotSpot.h = hot_x;
cursor->curs.hotSpot.v = hot_y; cursor->curs.hotSpot.v = hot_y;
......
...@@ -11,7 +11,7 @@ QUARTZ_SRCS = \ ...@@ -11,7 +11,7 @@ QUARTZ_SRCS = \
SDL_QuartzVideo.m SDL_QuartzVideo.m
# These files are included by SDL_QuartzVideo.m (is that right??) # These files are included by SDL_QuartzVideo.m (is that right??)
EXTRA_DIST = \ noinst_HEADERS = \
SDL_QuartzEvents.m \ SDL_QuartzEvents.m \
SDL_QuartzWM.m \ SDL_QuartzWM.m \
SDL_QuartzWindow.m SDL_QuartzWindow.m
...@@ -207,6 +207,12 @@ static void QZ_DoActivate (_THIS) ...@@ -207,6 +207,12 @@ static void QZ_DoActivate (_THIS)
CGAssociateMouseAndMouseCursorPosition (0); CGAssociateMouseAndMouseCursorPosition (0);
} }
/* Hide the mouse cursor if inside the app window */
// FIXME
if (!QZ_cursor_visible) {
HideCursor ();
}
SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS); SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS);
} }
...@@ -219,6 +225,12 @@ static void QZ_DoDeactivate (_THIS) { ...@@ -219,6 +225,12 @@ static void QZ_DoDeactivate (_THIS) {
CGAssociateMouseAndMouseCursorPosition (1); CGAssociateMouseAndMouseCursorPosition (1);
} }
/* Show the mouse cursor */
// FIXME
if (!QZ_cursor_visible) {
ShowCursor ();
}
SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS); SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS);
} }
...@@ -309,6 +321,8 @@ static void QZ_PumpEvents (_THIS) ...@@ -309,6 +321,8 @@ static void QZ_PumpEvents (_THIS)
case NSRightMouseDragged: case NSRightMouseDragged:
case 27: case 27:
case NSMouseMoved: case NSMouseMoved:
if ( (SDL_VideoSurface->flags & SDL_FULLSCREEN)
|| NSPointInRect([event locationInWindow], winRect) )
{ {
static int moves = 0; static int moves = 0;
NSPoint p; NSPoint p;
......
...@@ -35,6 +35,8 @@ static WMcursor* QZ_CreateWMCursor (_THIS, Uint8 *data, Uint8 *mask, ...@@ -35,6 +35,8 @@ static WMcursor* QZ_CreateWMCursor (_THIS, Uint8 *data, Uint8 *mask,
int w, int h, int hot_x, int hot_y) { int w, int h, int hot_x, int hot_y) {
WMcursor *cursor; WMcursor *cursor;
int row, bytes; int row, bytes;
/* Allocate the cursor memory */
cursor = (WMcursor *)malloc(sizeof(WMcursor)); cursor = (WMcursor *)malloc(sizeof(WMcursor));
if ( cursor == NULL ) { if ( cursor == NULL ) {
SDL_OutOfMemory(); SDL_OutOfMemory();
...@@ -42,17 +44,21 @@ static WMcursor* QZ_CreateWMCursor (_THIS, Uint8 *data, Uint8 *mask, ...@@ -42,17 +44,21 @@ static WMcursor* QZ_CreateWMCursor (_THIS, Uint8 *data, Uint8 *mask,
} }
memset(cursor, 0, sizeof(*cursor)); memset(cursor, 0, sizeof(*cursor));
bytes = (w/8); if (w > 16)
if ( bytes > 2 ) { w = 16;
bytes = 2;
} if (h > 16)
for ( row=0; row<h && (row < 16); ++row ) { h = 16;
bytes = (w+7)/8;
for ( row=0; row<h; ++row ) {
memcpy(&cursor->curs.data[row], data, bytes); memcpy(&cursor->curs.data[row], data, bytes);
data += w/8; data += bytes;
} }
for ( row=0; row<h && (row < 16); ++row ) { for ( row=0; row<h; ++row ) {
memcpy(&cursor->curs.mask[row], mask, bytes); memcpy(&cursor->curs.mask[row], mask, bytes);
mask += w/8; mask += bytes;
} }
cursor->curs.hotSpot.h = hot_x; cursor->curs.hotSpot.h = hot_x;
cursor->curs.hotSpot.v = hot_y; cursor->curs.hotSpot.v = hot_y;
...@@ -60,21 +66,21 @@ static WMcursor* QZ_CreateWMCursor (_THIS, Uint8 *data, Uint8 *mask, ...@@ -60,21 +66,21 @@ static WMcursor* QZ_CreateWMCursor (_THIS, Uint8 *data, Uint8 *mask,
return(cursor); return(cursor);
} }
static int QZ_ShowWMCursor (_THIS, WMcursor *cursor) { static int QZ_cursor_visible = 1;
static int visible = 1; static int QZ_ShowWMCursor (_THIS, WMcursor *cursor) {
if ( cursor == NULL) { if ( cursor == NULL) {
if ( visible ) { if ( QZ_cursor_visible ) {
HideCursor (); HideCursor ();
visible = 0; QZ_cursor_visible = 0;
} }
} }
else { else {
SetCursor(&cursor->curs); SetCursor(&cursor->curs);
if ( ! visible ) { if ( ! QZ_cursor_visible ) {
ShowCursor (); ShowCursor ();
visible = 1; QZ_cursor_visible = 1;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment