Date: Tue, 21 Aug 2001 03:50:01 +0200
From: Max Horn <max@quendi.de> Subject: New patch for OS X Attached a .patch file for SDL/OSX with some nice bug fixes / enhancments. * fixes the activation issues, which also caused the window to be always drawn like an inactive. The close/minimize widgets now are animated properly, too. * the menu items are automatically adjusted to use the app name instead of just "SDL App". I did this so that we really can use one central SDLMain.nib file, w/o requiring developers to make a copy of it and adjust it. * libSDLMain now contains the proper cocoa code, not as before the carbon code. This means apps no longer have to carry a copy of SDLMain.m/SDLMain.h * revamped configure.in to properly build a Cocoa/Quartz SDL lib, not a Carbon based SDL lib --HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40159
This commit is contained in:
parent
6dbdba950a
commit
75ab0e7ade
8 changed files with 170 additions and 62 deletions
48
configure.in
48
configure.in
|
@ -63,10 +63,6 @@ case "$target" in
|
||||||
*-*-linux*)
|
*-*-linux*)
|
||||||
AC_PROG_CXX
|
AC_PROG_CXX
|
||||||
;;
|
;;
|
||||||
*-*-darwin*)
|
|
||||||
OBJC="???"
|
|
||||||
AC_SUBST(OBJC)
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
AC_PROG_INSTALL
|
AC_PROG_INSTALL
|
||||||
AC_FUNC_ALLOCA
|
AC_FUNC_ALLOCA
|
||||||
|
@ -1192,6 +1188,21 @@ CheckCARBON()
|
||||||
VIDEO_DRIVERS="$VIDEO_DRIVERS macrom/libvideo_macrom.la"
|
VIDEO_DRIVERS="$VIDEO_DRIVERS macrom/libvideo_macrom.la"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dnl Set up the Mac toolbox video driver for Mac OS X
|
||||||
|
CheckQUARTZ()
|
||||||
|
{
|
||||||
|
# "MACOSX" is not an official definition, but it's commonly
|
||||||
|
# accepted as a way to differentiate between what runs on X
|
||||||
|
# and what runs on older Macs - while in theory "Carbon" defns
|
||||||
|
# are consistent between the two, in practice Carbon is still
|
||||||
|
# changing. -sts Aug 2000
|
||||||
|
CFLAGS="$CFLAGS -I/System/Library/Frameworks/Carbon.framework/Headers \
|
||||||
|
-I/System/Library/Frameworks/Cocoa.framework/Headers -fpascal-strings \
|
||||||
|
-DENABLE_QUARTZ -DMACOSX -DTARGET_API_MAC_CARBON=1 -I\$(top_srcdir)/src/video/quartz"
|
||||||
|
VIDEO_SUBDIRS="$VIDEO_SUBDIRS quartz"
|
||||||
|
VIDEO_DRIVERS="$VIDEO_DRIVERS quartz/libvideo_quartz.la"
|
||||||
|
}
|
||||||
|
|
||||||
dnl Set up the kernel statistics library for Solaris
|
dnl Set up the kernel statistics library for Solaris
|
||||||
CheckKSTAT()
|
CheckKSTAT()
|
||||||
{
|
{
|
||||||
|
@ -1994,17 +2005,17 @@ case "$target" in
|
||||||
;;
|
;;
|
||||||
*-*-darwin* )
|
*-*-darwin* )
|
||||||
# Strictly speaking, we want "Mac OS X", not "Darwin", which is
|
# Strictly speaking, we want "Mac OS X", not "Darwin", which is
|
||||||
# just the OS X kernel sans upper layers like Carbon. But
|
# just the OS X kernel sans upper layers like Carbon and Cocoa.
|
||||||
# config.guess comes back with "darwin", so go with the flow.
|
# But config.guess comes back with "darwin", so go with the flow.
|
||||||
ARCH=macos
|
ARCH=macosx
|
||||||
CheckDummyVideo
|
CheckDummyVideo
|
||||||
CheckDiskAudio
|
CheckDiskAudio
|
||||||
CheckCARBON
|
CheckQUARTZ
|
||||||
CheckMacGL
|
CheckMacGL
|
||||||
CheckPTHREAD
|
CheckPTHREAD
|
||||||
# Set up files for the main() stub
|
# Set up files for the main() stub
|
||||||
# COPY_ARCH_SRC(src/main, macos, SDL_main.c)
|
COPY_ARCH_SRC(src/main, macosx, SDLmain.m)
|
||||||
COPY_ARCH_SRC(src/main, linux, SDL_main.c)
|
COPY_ARCH_SRC(src/main, macosx, SDLmain.h)
|
||||||
# Set up files for the audio library
|
# Set up files for the audio library
|
||||||
if test x$enable_audio = xyes; then
|
if test x$enable_audio = xyes; then
|
||||||
AUDIO_SUBDIRS="$AUDIO_SUBDIRS macrom"
|
AUDIO_SUBDIRS="$AUDIO_SUBDIRS macrom"
|
||||||
|
@ -2040,8 +2051,8 @@ case "$target" in
|
||||||
COPY_ARCH_SRC(src/timer, linux, SDL_systimer.c)
|
COPY_ARCH_SRC(src/timer, linux, SDL_systimer.c)
|
||||||
fi
|
fi
|
||||||
# The MacOS X platform requires special setup
|
# The MacOS X platform requires special setup
|
||||||
SDL_CFLAGS="$SDL_CFLAGS -F/System/Library/Frameworks/Carbon.framework"
|
SDL_CFLAGS="$SDL_CFLAGS -F/System/Library/Frameworks/Carbon.framework -F/System/Library/Frameworks/Cocoa.framework"
|
||||||
SDL_LIBS="-lSDLmain $SDL_LIBS -framework Carbon"
|
SDL_LIBS="-lSDLmain $SDL_LIBS -framework Carbon -framework Cocoa"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
AC_MSG_ERROR(Unsupported target: Please add to configure.in)
|
AC_MSG_ERROR(Unsupported target: Please add to configure.in)
|
||||||
|
@ -2061,6 +2072,7 @@ AM_CONDITIONAL(TARGET_AIX, test $ARCH = aix)
|
||||||
AM_CONDITIONAL(TARGET_WIN32, test $ARCH = win32)
|
AM_CONDITIONAL(TARGET_WIN32, test $ARCH = win32)
|
||||||
AM_CONDITIONAL(TARGET_BEOS, test $ARCH = beos)
|
AM_CONDITIONAL(TARGET_BEOS, test $ARCH = beos)
|
||||||
AM_CONDITIONAL(TARGET_MACOS, test $ARCH = macos)
|
AM_CONDITIONAL(TARGET_MACOS, test $ARCH = macos)
|
||||||
|
AM_CONDITIONAL(TARGET_MACOSX, test $ARCH = macosx)
|
||||||
|
|
||||||
# Set conditional variables for shared and static library selection.
|
# Set conditional variables for shared and static library selection.
|
||||||
# These are not used in any Makefile.am but in sdl-config.in.
|
# These are not used in any Makefile.am but in sdl-config.in.
|
||||||
|
@ -2122,6 +2134,18 @@ CFLAGS="$CFLAGS -I\$(top_srcdir)/src/endian"
|
||||||
CFLAGS="$CFLAGS -I\$(top_srcdir)/src/file"
|
CFLAGS="$CFLAGS -I\$(top_srcdir)/src/file"
|
||||||
CXXFLAGS="$CFLAGS"
|
CXXFLAGS="$CFLAGS"
|
||||||
|
|
||||||
|
|
||||||
|
# Check for darwin at the very end and set up the Objective C compiler
|
||||||
|
# We do this here so that we get the full CFLAGS into OBJCFLAGS
|
||||||
|
case "$target" in
|
||||||
|
*-*-darwin*)
|
||||||
|
OBJC="cc"
|
||||||
|
OBJCFLAGS="$CFLAGS"
|
||||||
|
AC_SUBST(OBJC)
|
||||||
|
AC_SUBST(OBJCFLAGS)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# Finally create all the generated files
|
# Finally create all the generated files
|
||||||
dnl Important: Any directory that you want to be in the distcheck should
|
dnl Important: Any directory that you want to be in the distcheck should
|
||||||
dnl have a file listed here, so that configure generates the
|
dnl have a file listed here, so that configure generates the
|
||||||
|
|
|
@ -10,7 +10,11 @@ ARCH_SUBDIRS = $(srcdir)/beos $(srcdir)/linux \
|
||||||
# Build a separate library containing the main() entry point.
|
# Build a separate library containing the main() entry point.
|
||||||
lib_LIBRARIES = libSDLmain.a
|
lib_LIBRARIES = libSDLmain.a
|
||||||
|
|
||||||
|
if TARGET_MACOSX
|
||||||
|
MAINLIB_ARCH_SRCS = SDLmain.m SDLmain.h
|
||||||
|
else
|
||||||
MAINLIB_ARCH_SRCS = SDL_main.c
|
MAINLIB_ARCH_SRCS = SDL_main.c
|
||||||
|
endif
|
||||||
|
|
||||||
libSDLmain_a_SOURCES = $(MAINLIB_ARCH_SRCS)
|
libSDLmain_a_SOURCES = $(MAINLIB_ARCH_SRCS)
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,14 @@
|
||||||
|
/* SDLMain.h - main entry point for our Cocoa-ized SDL app
|
||||||
|
Darrell Walisser - dwaliss1@purdue.edu
|
||||||
|
|
||||||
|
Feel free to customize this file to suit your needs
|
||||||
|
*/
|
||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
@interface SDLMain : NSObject
|
@interface SDLMain : NSObject
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
- (IBAction)quit:(id)sender;
|
- (IBAction)quit:(id)sender;
|
||||||
|
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification;
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -11,6 +11,12 @@
|
||||||
|
|
||||||
static int gArgc;
|
static int gArgc;
|
||||||
static char **gArgv;
|
static char **gArgv;
|
||||||
|
static NSString *gAppName = 0;
|
||||||
|
|
||||||
|
@interface NSString (ReplaceSubString)
|
||||||
|
- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString;
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
/* The main class of the application, the application's delegate */
|
/* The main class of the application, the application's delegate */
|
||||||
@implementation SDLMain
|
@implementation SDLMain
|
||||||
|
@ -18,9 +24,9 @@ static char **gArgv;
|
||||||
/* Invoked from the Quit menu item */
|
/* Invoked from the Quit menu item */
|
||||||
- (void) quit:(id)sender
|
- (void) quit:(id)sender
|
||||||
{
|
{
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
event.type = SDL_QUIT;
|
event.type = SDL_QUIT;
|
||||||
SDL_PushEvent(&event);
|
SDL_PushEvent(&event);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the working directory to the .app's parent directory */
|
/* Set the working directory to the .app's parent directory */
|
||||||
|
@ -29,7 +35,7 @@ static char **gArgv;
|
||||||
char parentdir[MAXPATHLEN];
|
char parentdir[MAXPATHLEN];
|
||||||
char *c;
|
char *c;
|
||||||
|
|
||||||
strncpy ( parentdir, gArgv[0], MAXPATHLEN );
|
strncpy ( parentdir, gArgv[0], sizeof(parentdir) );
|
||||||
c = (char*) parentdir;
|
c = (char*) parentdir;
|
||||||
|
|
||||||
while (*c != '\0') /* go to end */
|
while (*c != '\0') /* go to end */
|
||||||
|
@ -38,10 +44,35 @@ static char **gArgv;
|
||||||
while (*c != '/') /* back up to parent */
|
while (*c != '/') /* back up to parent */
|
||||||
c--;
|
c--;
|
||||||
|
|
||||||
*c = '\0'; /* cut off last part (binary name) */
|
*c++ = '\0'; /* cut off last part (binary name) */
|
||||||
|
|
||||||
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 ];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fix menu to contain the real app name instead of "SDL App" */
|
||||||
|
- (void) fixMenu:(NSMenu *)aMenu
|
||||||
|
{
|
||||||
|
NSRange aRange;
|
||||||
|
NSEnumerator *enumerator;
|
||||||
|
NSMenuItem *menuItem;
|
||||||
|
|
||||||
|
aRange = [[aMenu title] rangeOfString:@"SDL App"];
|
||||||
|
if (aRange.length != 0)
|
||||||
|
[aMenu setTitle: [[aMenu title] stringByReplacingRange:aRange with:gAppName]];
|
||||||
|
|
||||||
|
enumerator = [[aMenu itemArray] objectEnumerator];
|
||||||
|
while ((menuItem = [enumerator nextObject]))
|
||||||
|
{
|
||||||
|
aRange = [[menuItem title] rangeOfString:@"SDL App"];
|
||||||
|
if (aRange.length != 0)
|
||||||
|
[menuItem setTitle: [[menuItem title] stringByReplacingRange:aRange with:gAppName]];
|
||||||
|
if ([menuItem hasSubmenu])
|
||||||
|
[self fixMenu: [menuItem submenu]];
|
||||||
|
}
|
||||||
|
[ aMenu sizeToFit ];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called when the internal event loop has just started running */
|
/* Called when the internal event loop has just started running */
|
||||||
|
@ -52,6 +83,9 @@ static char **gArgv;
|
||||||
/* Set the working directory to the .app's parent directory */
|
/* Set the working directory to the .app's parent directory */
|
||||||
[ self setupWorkingDirectory ];
|
[ self setupWorkingDirectory ];
|
||||||
|
|
||||||
|
/* Set the main menu to contain the real app name instead of "SDL App" */
|
||||||
|
[ self fixMenu: [ NSApp mainMenu ] ];
|
||||||
|
|
||||||
/* Hand off to main application code */
|
/* Hand off to main application code */
|
||||||
status = SDL_main (gArgc, gArgv);
|
status = SDL_main (gArgc, gArgv);
|
||||||
|
|
||||||
|
@ -60,6 +94,47 @@ static char **gArgv;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
@implementation NSString (ReplaceSubString)
|
||||||
|
|
||||||
|
- (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString
|
||||||
|
{
|
||||||
|
unsigned int bufferSize;
|
||||||
|
unsigned int selfLen = [self length];
|
||||||
|
unsigned int aStringLen = [aString length];
|
||||||
|
unichar *buffer;
|
||||||
|
NSRange localRange;
|
||||||
|
NSString *result;
|
||||||
|
|
||||||
|
bufferSize = selfLen + aStringLen - aRange.length;
|
||||||
|
buffer = NSAllocateMemoryPages(bufferSize*sizeof(unichar));
|
||||||
|
|
||||||
|
// Get first part into buffer
|
||||||
|
localRange.location = 0;
|
||||||
|
localRange.length = aRange.location;
|
||||||
|
[self getCharacters:buffer range:localRange];
|
||||||
|
|
||||||
|
// Get middle part into buffer
|
||||||
|
localRange.location = 0;
|
||||||
|
localRange.length = aStringLen;
|
||||||
|
[aString getCharacters:(buffer+aRange.location) range:localRange];
|
||||||
|
|
||||||
|
// Get last part into buffer
|
||||||
|
localRange.location = aRange.location + aRange.length;
|
||||||
|
localRange.length = selfLen - localRange.location;
|
||||||
|
[self getCharacters:(buffer+aRange.location+aStringLen) range:localRange];
|
||||||
|
|
||||||
|
// Build output string
|
||||||
|
result = [NSString stringWithCharacters:buffer length:bufferSize];
|
||||||
|
|
||||||
|
NSDeallocateMemoryPages(buffer, bufferSize);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
#ifdef main
|
#ifdef main
|
||||||
# undef main
|
# undef main
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -223,7 +223,7 @@ static void QZ_DoDeactivate (_THIS) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void QZ_PumpEvents (_THIS)
|
static void QZ_PumpEvents (_THIS)
|
||||||
{
|
{
|
||||||
NSDate *distantPast;
|
NSDate *distantPast;
|
||||||
NSEvent *event;
|
NSEvent *event;
|
||||||
NSRect winRect;
|
NSRect winRect;
|
||||||
|
@ -247,27 +247,29 @@ static void QZ_PumpEvents (_THIS)
|
||||||
|
|
||||||
if (event != nil) {
|
if (event != nil) {
|
||||||
unsigned int type;
|
unsigned int type;
|
||||||
|
BOOL isForGameWin;
|
||||||
|
|
||||||
#define DO_MOUSE_DOWN(button, sendToWindow) \
|
#define DO_MOUSE_DOWN(button, sendToWindow) do { \
|
||||||
if ( inForeground ) { \
|
if ( inForeground ) { \
|
||||||
if ( (SDL_VideoSurface->flags & SDL_FULLSCREEN) || \
|
if ( (SDL_VideoSurface->flags & SDL_FULLSCREEN) || \
|
||||||
NSPointInRect([event locationInWindow], winRect) ) \
|
NSPointInRect([event locationInWindow], winRect) ) \
|
||||||
SDL_PrivateMouseButton (SDL_PRESSED, button, 0, 0); \
|
SDL_PrivateMouseButton (SDL_PRESSED, button, 0, 0); \
|
||||||
else if (sendToWindow) \
|
|
||||||
[ window sendEvent:event ]; \
|
|
||||||
} \
|
} \
|
||||||
else { \
|
else { \
|
||||||
QZ_DoActivate (this); \
|
QZ_DoActivate (this); \
|
||||||
}
|
} \
|
||||||
|
[ NSApp sendEvent:event ]; \
|
||||||
#define DO_MOUSE_UP(button, sendToWindow) \
|
} while(0)
|
||||||
|
|
||||||
|
#define DO_MOUSE_UP(button, sendToWindow) do { \
|
||||||
if ( (SDL_VideoSurface->flags & SDL_FULLSCREEN) || \
|
if ( (SDL_VideoSurface->flags & SDL_FULLSCREEN) || \
|
||||||
!NSPointInRect([event locationInWindow], titleBarRect) )\
|
!NSPointInRect([event locationInWindow], titleBarRect) )\
|
||||||
SDL_PrivateMouseButton (SDL_RELEASED, button, 0, 0); \
|
SDL_PrivateMouseButton (SDL_RELEASED, button, 0, 0); \
|
||||||
if (sendToWindow) \
|
[ NSApp sendEvent:event ]; \
|
||||||
[ window sendEvent:event ]
|
} while(0)
|
||||||
|
|
||||||
type = [ event type ];
|
type = [ event type ];
|
||||||
|
isForGameWin = (qz_window == [ event window ]);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
|
||||||
case NSLeftMouseDown:
|
case NSLeftMouseDown:
|
||||||
|
@ -351,8 +353,8 @@ static void QZ_PumpEvents (_THIS)
|
||||||
case NSFlagsChanged:
|
case NSFlagsChanged:
|
||||||
QZ_DoModifiers( [ event modifierFlags ] );
|
QZ_DoModifiers( [ event modifierFlags ] );
|
||||||
break;
|
break;
|
||||||
case NSMouseEntered: break;
|
// case NSMouseEntered: break;
|
||||||
case NSMouseExited: break;
|
// case NSMouseExited: break;
|
||||||
case NSAppKitDefined:
|
case NSAppKitDefined:
|
||||||
switch ( [ event subtype ] ) {
|
switch ( [ event subtype ] ) {
|
||||||
case NSApplicationActivatedEventType:
|
case NSApplicationActivatedEventType:
|
||||||
|
@ -361,14 +363,14 @@ static void QZ_PumpEvents (_THIS)
|
||||||
case NSApplicationDeactivatedEventType:
|
case NSApplicationDeactivatedEventType:
|
||||||
QZ_DoDeactivate (this);
|
QZ_DoDeactivate (this);
|
||||||
break;
|
break;
|
||||||
case NSWindowMovedEventType:
|
|
||||||
[ window sendEvent:event ];
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
[ NSApp sendEvent:event ];
|
||||||
break;
|
break;
|
||||||
case NSApplicationDefined: break;
|
// case NSApplicationDefined: break;
|
||||||
case NSPeriodic: break;
|
// case NSPeriodic: break;
|
||||||
case NSCursorUpdate: break;
|
// case NSCursorUpdate: break;
|
||||||
|
default:
|
||||||
|
[ NSApp sendEvent:event ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (event != nil);
|
} while (event != nil);
|
||||||
|
|
|
@ -44,10 +44,6 @@
|
||||||
- Launch times are slow, maybe prebinding will help
|
- Launch times are slow, maybe prebinding will help
|
||||||
- Direct framebuffer access has some artifacts, maybe a driver issue
|
- Direct framebuffer access has some artifacts, maybe a driver issue
|
||||||
- Cursor in 8 bit modes is screwy
|
- Cursor in 8 bit modes is screwy
|
||||||
- Modifier + mouse-down maps alternate mouse button, but if modifier is released
|
|
||||||
before mouse button, corresponding mouse-up event is not generated.
|
|
||||||
- Clicking in content activates app, but doesn't generate the activate event,
|
|
||||||
and subsequent switches generate no activate/deactivate events! (OS Bug I hope)
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ApplicationServices/ApplicationServices.h>
|
#include <ApplicationServices/ApplicationServices.h>
|
||||||
|
@ -107,7 +103,7 @@ typedef struct SDL_PrivateVideoData {
|
||||||
#define device_bpp (this->hidden->bpp)
|
#define device_bpp (this->hidden->bpp)
|
||||||
#define mode_flags (this->hidden->flags)
|
#define mode_flags (this->hidden->flags)
|
||||||
#define video_set (this->hidden->video_is_set)
|
#define video_set (this->hidden->video_is_set)
|
||||||
#define window (this->hidden->window)
|
#define qz_window (this->hidden->window)
|
||||||
#define windowView (this->hidden->view)
|
#define windowView (this->hidden->view)
|
||||||
|
|
||||||
/* Interface for hardware fill not (yet) in the public API */
|
/* Interface for hardware fill not (yet) in the public API */
|
||||||
|
|
|
@ -267,9 +267,9 @@ static void QZ_UnsetVideoMode (_THIS) {
|
||||||
UnlockPortBits ( [ windowView qdPort ] );
|
UnlockPortBits ( [ windowView qdPort ] );
|
||||||
[ windowView release ];
|
[ windowView release ];
|
||||||
}
|
}
|
||||||
[ window setContentView:nil ];
|
[ qz_window setContentView:nil ];
|
||||||
[ window setDelegate:nil ];
|
[ qz_window setDelegate:nil ];
|
||||||
[ window close ];
|
[ qz_window close ];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set pixels to null (so other code doesn't try to free it) */
|
/* Set pixels to null (so other code doesn't try to free it) */
|
||||||
|
@ -408,9 +408,9 @@ static SDL_Surface* QZ_SetVideoWindowed (_THIS, SDL_Surface *current, int width,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Manually create a window, avoids having a nib file resource */
|
/* Manually create a window, avoids having a nib file resource */
|
||||||
window = [ [ SDL_QuartzWindow alloc ] initWithContentRect:rect
|
qz_window = [ [ SDL_QuartzWindow alloc ] initWithContentRect:rect
|
||||||
styleMask:style backing:NSBackingStoreBuffered defer:NO ];
|
styleMask:style backing:NSBackingStoreBuffered defer:NO ];
|
||||||
if (window == nil) {
|
if (qz_window == nil) {
|
||||||
SDL_SetError ("Could not create the Cocoa window");
|
SDL_SetError ("Could not create the Cocoa window");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -419,12 +419,12 @@ static SDL_Surface* QZ_SetVideoWindowed (_THIS, SDL_Surface *current, int width,
|
||||||
current->w = width;
|
current->w = width;
|
||||||
current->h = height;
|
current->h = height;
|
||||||
|
|
||||||
[ window setReleasedWhenClosed:YES ];
|
[ qz_window setReleasedWhenClosed:YES ];
|
||||||
QZ_SetCaption(this, this->wm_title, this->wm_icon);
|
QZ_SetCaption(this, this->wm_title, this->wm_icon);
|
||||||
[ window setAcceptsMouseMovedEvents:YES ];
|
[ qz_window setAcceptsMouseMovedEvents:YES ];
|
||||||
[ window setViewsNeedDisplay:NO ];
|
[ qz_window setViewsNeedDisplay:NO ];
|
||||||
[ window center ];
|
[ qz_window center ];
|
||||||
[ window setDelegate:
|
[ qz_window setDelegate:
|
||||||
[ [ [ SDL_QuartzWindowDelegate alloc ] init ] autorelease ] ];
|
[ [ [ SDL_QuartzWindowDelegate alloc ] init ] autorelease ] ];
|
||||||
|
|
||||||
/* For OpenGL, we set the content view to a NSOpenGLView */
|
/* For OpenGL, we set the content view to a NSOpenGLView */
|
||||||
|
@ -434,17 +434,17 @@ static SDL_Surface* QZ_SetVideoWindowed (_THIS, SDL_Surface *current, int width,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
[ gl_context setView: [ window contentView ] ];
|
[ gl_context setView: [ qz_window contentView ] ];
|
||||||
[ gl_context makeCurrentContext];
|
[ gl_context makeCurrentContext];
|
||||||
[ window orderFront:nil ];
|
[ qz_window makeKeyAndOrderFront:nil ];
|
||||||
current->flags |= SDL_OPENGL;
|
current->flags |= SDL_OPENGL;
|
||||||
}
|
}
|
||||||
/* For 2D, we set the content view to a NSQuickDrawView */
|
/* For 2D, we set the content view to a NSQuickDrawView */
|
||||||
else {
|
else {
|
||||||
|
|
||||||
windowView = [ [ NSQuickDrawView alloc ] init ];
|
windowView = [ [ NSQuickDrawView alloc ] init ];
|
||||||
[ window setContentView:windowView ];
|
[ qz_window setContentView:windowView ];
|
||||||
[ window orderFront:nil ];
|
[ qz_window makeKeyAndOrderFront:nil ];
|
||||||
|
|
||||||
LockPortBits ( [ windowView qdPort ] );
|
LockPortBits ( [ windowView qdPort ] );
|
||||||
current->pixels = GetPixBaseAddr ( GetPortPixMap ( [ windowView qdPort ] ) );
|
current->pixels = GetPixBaseAddr ( GetPortPixMap ( [ windowView qdPort ] ) );
|
||||||
|
|
|
@ -96,7 +96,7 @@ static void QZ_PrivateWarpCursor (_THIS, int fullscreen, int h, int x, int y) {
|
||||||
/* Convert to absolute screen coordinates */
|
/* Convert to absolute screen coordinates */
|
||||||
NSPoint base, screen;
|
NSPoint base, screen;
|
||||||
base = NSMakePoint (p.x, p.y);
|
base = NSMakePoint (p.x, p.y);
|
||||||
screen = [ window convertBaseToScreen:base ];
|
screen = [ qz_window convertBaseToScreen:base ];
|
||||||
p.x = screen.x;
|
p.x = screen.x;
|
||||||
p.y = device_height - screen.y;
|
p.y = device_height - screen.y;
|
||||||
CGDisplayMoveCursorToPoint (display_id, p);
|
CGDisplayMoveCursorToPoint (display_id, p);
|
||||||
|
@ -122,16 +122,16 @@ static void QZ_CheckMouseMode (_THIS) { }
|
||||||
|
|
||||||
static void QZ_SetCaption (_THIS, const char *title, const char *icon) {
|
static void QZ_SetCaption (_THIS, const char *title, const char *icon) {
|
||||||
|
|
||||||
if ( window != nil ) {
|
if ( qz_window != nil ) {
|
||||||
NSString *string;
|
NSString *string;
|
||||||
if ( title != NULL ) {
|
if ( title != NULL ) {
|
||||||
string = [ [ NSString alloc ] initWithCString:title ];
|
string = [ [ NSString alloc ] initWithCString:title ];
|
||||||
[ window setTitle:string ];
|
[ qz_window setTitle:string ];
|
||||||
[ string release ];
|
[ string release ];
|
||||||
}
|
}
|
||||||
if ( icon != NULL ) {
|
if ( icon != NULL ) {
|
||||||
string = [ [ NSString alloc ] initWithCString:icon ];
|
string = [ [ NSString alloc ] initWithCString:icon ];
|
||||||
[ window setMiniwindowTitle:string ];
|
[ qz_window setMiniwindowTitle:string ];
|
||||||
[ string release ];
|
[ string release ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,19 +144,19 @@ static void QZ_SetIcon (_THIS, SDL_Surface *icon, Uint8 *mask) {
|
||||||
static int QZ_IconifyWindow (_THIS) {
|
static int QZ_IconifyWindow (_THIS) {
|
||||||
|
|
||||||
/* Bug! minimize erases the framebuffer */
|
/* Bug! minimize erases the framebuffer */
|
||||||
if ( ! [ window isMiniaturized ] ) {
|
if ( ! [ qz_window isMiniaturized ] ) {
|
||||||
[ window miniaturize:nil ];
|
[ qz_window miniaturize:nil ];
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SDL_SetError ("window already iconified");
|
SDL_SetError ("qz_window already iconified");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
static int QZ_GetWMInfo (_THIS, SDL_SysWMinfo *info) {
|
static int QZ_GetWMInfo (_THIS, SDL_SysWMinfo *info) {
|
||||||
info->nsWindowPtr = window;
|
info->nsWindowPtr = qz_window;
|
||||||
return 0;
|
return 0;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue