* Removed fullscreen menu option from the "Window" menu

* Updated the BUGS file
* Fixed command line parameters when launched from Finder
* Implemented setting the icon window caption
* Implemented frameless style windows
* Added note about SDL_RESIZABLE implementation to SDL_QuartzVideo.m
* Window close requests now go through the event filtering system

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%4059
This commit is contained in:
Sam Lantinga 2001-06-11 06:44:43 +00:00
parent 982c4718af
commit 254c4d997c
9 changed files with 106 additions and 86 deletions

10
BUGS
View File

@ -72,12 +72,12 @@ MacOS:
MacOS X:
Joystick and CD-ROM functions are not implemented yet.
Closing window from window's close widget not implemented yet.
Minimizing the window erases the framebuffer to the pinstripe pattern.
Window management buttons don't draw correctly.
Window may not close when unsetting video mode and resetting.
Resizeable windows aren't implemented yet.
Depth switching for windowed mode isn't implemented yet.
Palette handling isn't implemented in windowed mode yet.

Binary file not shown.

View File

@ -4,5 +4,4 @@
{
}
- (IBAction)quit:(id)sender;
- (IBAction)makeFullscreen:(id)sender;
@end

View File

@ -23,12 +23,6 @@ static char **gArgv;
SDL_PushEvent(&event);
}
/* Invoked from the "Make fulllscreen" menu item */
- (void) makeFullscreen:(id)sender
{
}
/* Set the working directory to the .app's parent directory */
- (void) setupWorkingDirectory
{
@ -53,16 +47,16 @@ static char **gArgv;
/* Called when the internal event loop has just started running */
- (void) applicationDidFinishLaunching: (NSNotification *) note
{
int status;
/* Set the working directory to the .app's parent directory */
[ self setupWorkingDirectory ];
/* This is passed if we are launched by double-clicking */
if ( gArgc >= 2 && strncmp (gArgv[1], "-psn", 4) == 0 )
gArgc = 1;
/* Hand off to main application code */
SDL_main (gArgc, gArgv);
exit(0);
status = SDL_main (gArgc, gArgv);
/* We're done, thank you for playing */
exit(status);
}
@end
@ -76,13 +70,19 @@ int main (int argc, char **argv) {
/* Copy the arguments into a global variable */
int i;
gArgc = argc;
gArgv = (char**) malloc (sizeof(*gArgv) * gArgc);
/* This is passed if we are launched by double-clicking */
if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) {
gArgc = 1;
} else {
gArgc = argc;
}
gArgv = (char**) malloc (sizeof(*gArgv) * (gArgc+1));
assert (gArgv != NULL);
for (i = 0; i < gArgc; i++) {
gArgv[i] = strdup (argv[i]);
gArgv[i] = argv[i];
}
gArgv[i] = NULL;
NSApplicationMain (argc, argv);
return 0;
}
}

View File

@ -100,10 +100,6 @@ static VideoBootStrap *bootstrap[] = {
};
SDL_VideoDevice *current_video = NULL;
/* Places to store title and icon text for the app */
static char *wm_title = NULL;
static char *wm_icon = NULL;
/* Various local functions */
int SDL_VideoInit(const char *driver_name, Uint32 flags);
void SDL_VideoQuit(void);
@ -1254,13 +1250,13 @@ void SDL_VideoQuit (void)
free(video->gamma);
video->gamma = NULL;
}
if ( wm_title != NULL ) {
free(wm_title);
wm_title = NULL;
if ( video->wm_title != NULL ) {
free(video->wm_title);
video->wm_title = NULL;
}
if ( wm_icon != NULL ) {
free(wm_icon);
wm_icon = NULL;
if ( video->wm_icon != NULL ) {
free(video->wm_icon);
video->wm_icon = NULL;
}
/* Finish cleaning up video subsystem */
@ -1539,35 +1535,41 @@ void SDL_WM_SetCaption (const char *title, const char *icon)
SDL_VideoDevice *video = current_video;
SDL_VideoDevice *this = current_video;
if ( title ) {
if ( wm_title ) {
free(wm_title);
if ( video ) {
if ( title ) {
if ( video->wm_title ) {
free(video->wm_title);
}
video->wm_title = (char *)malloc(strlen(title)+1);
if ( video->wm_title != NULL ) {
strcpy(video->wm_title, title);
}
}
wm_title = (char *)malloc(strlen(title)+1);
if ( wm_title != NULL ) {
strcpy(wm_title, title);
if ( icon ) {
if ( video->wm_icon ) {
free(video->wm_icon);
}
video->wm_icon = (char *)malloc(strlen(icon)+1);
if ( video->wm_icon != NULL ) {
strcpy(video->wm_icon, icon);
}
}
}
if ( icon ) {
if ( wm_icon ) {
free(wm_icon);
if ( (title || icon) && (video->SetCaption != NULL) ) {
video->SetCaption(this, video->wm_title,video->wm_icon);
}
wm_icon = (char *)malloc(strlen(icon)+1);
if ( wm_icon != NULL ) {
strcpy(wm_icon, icon);
}
}
if ( (title || icon) && video && (video->SetCaption != NULL) ) {
video->SetCaption(this, wm_title, wm_icon);
}
}
void SDL_WM_GetCaption (char **title, char **icon)
{
if ( title ) {
*title = wm_title;
}
if ( icon ) {
*icon = wm_icon;
SDL_VideoDevice *video = current_video;
if ( video ) {
if ( title ) {
*title = video->wm_title;
}
if ( icon ) {
*icon = video->wm_icon;
}
}
}

View File

@ -40,7 +40,7 @@
- SetColors sets palette correctly but clears framebuffer
- Crash in CG after several mode switches
- Retained windows don't draw their title bar quite right (OS Bug)
- Should I do depth switching for windowed modes?
- Should I do depth switching for windowed modes? - No, not usually.
- Launch times are slow, maybe prebinding will help
- Direct framebuffer access has some artifacts, maybe a driver issue
- Cursor in 8 bit modes is screwy
@ -89,7 +89,6 @@ typedef struct SDL_PrivateVideoData {
/* Window-only fields */
NSWindow *window;
NSQuickDrawView *view;
NSString *title;
} SDL_PrivateVideoData ;
@ -108,7 +107,6 @@ typedef struct SDL_PrivateVideoData {
#define mode_flags (this->hidden->flags)
#define window (this->hidden->window)
#define windowView (this->hidden->view)
#define windowTitle (this->hidden->title)
/* Interface for hardware fill not (yet) in the public API */
int CGSDisplayHWFill (CGDirectDisplayID id, unsigned int x, unsigned int y,

View File

@ -132,7 +132,6 @@ static int QZ_VideoInit (_THIS, SDL_PixelFormat *video_format) {
kCFNumberSInt32Type, &device_height);
video_format->BitsPerPixel = device_bpp;
windowTitle = @"";
return 0;
}
@ -293,6 +292,7 @@ static SDL_Surface* QZ_SetVideoFullScreen (_THIS, SDL_Surface *current, int widt
current->pitch = CGDisplayBytesPerRow (display_id);
#endif
current->flags = 0;
current->w = width;
current->h = height;
current->flags |= SDL_FULLSCREEN;
@ -350,27 +350,37 @@ static SDL_Surface* QZ_SetVideoFullScreen (_THIS, SDL_Surface *current, int widt
static SDL_Surface* QZ_SetVideoWindowed (_THIS, SDL_Surface *current, int width,
int height, int bpp, Uint32 flags) {
unsigned int style;
NSRect rect;
rect = NSMakeRect (0, 0, width, height);
#if 1 // FIXME - the resize button doesn't show? Also need resize events...
flags &= ~SDL_RESIZABLE;
#endif
/* Set the window style based on input flags */
if ( flags & SDL_NOFRAME ) {
style = NSBorderlessWindowMask;
} else {
style = NSTitledWindowMask;
style |= (NSMiniaturizableWindowMask | NSClosableWindowMask);
if ( flags & SDL_RESIZABLE )
style |= NSResizableWindowMask;
}
/* Manually create a window, avoids having a nib file resource */
window = [ [ SDL_QuartzWindow alloc ] initWithContentRect:rect
styleMask:(NSTitledWindowMask | NSMiniaturizableWindowMask |
NSClosableWindowMask)
backing: //NSBackingStoreBuffered
NSBackingStoreRetained
defer:NO ];
styleMask:style backing:NSBackingStoreRetained defer:NO ];
if (window == nil) {
SDL_SetError ("Could not create the Cocoa window");
return NULL;
}
current->w = width;
current->flags = 0;
current->w = width;
current->h = height;
[ window setReleasedWhenClosed:YES ];
[ window setTitle:windowTitle ];
QZ_SetCaption(this, this->wm_title, this->wm_icon);
[ window setAcceptsMouseMovedEvents:YES ];
[ window setViewsNeedDisplay:NO ];
[ window center ];
@ -400,11 +410,17 @@ static SDL_Surface* QZ_SetVideoWindowed (_THIS, SDL_Surface *current, int width,
current->pixels = GetPixBaseAddr ( GetPortPixMap ( [ windowView qdPort ] ) );
current->pitch = GetPixRowBytes ( GetPortPixMap ( [ windowView qdPort ] ) );
/* Offset 22 pixels down to fill the full content region */
current->pixels += 22 * current->pitch;
current->flags |= SDL_SWSURFACE;
current->flags |= SDL_PREALLOC;
if ( flags & SDL_NOFRAME )
current->flags |= SDL_NOFRAME;
if ( flags & SDL_RESIZABLE )
current->flags |= SDL_RESIZABLE;
/* Offset 22 pixels down to fill the full content region */
if ( ! (current->flags & SDL_NOFRAME) ) {
current->pixels += 22 * current->pitch;
}
this->UpdateRects = QZ_UpdateRects;
}
@ -444,15 +460,15 @@ static SDL_Surface* QZ_SetVideoMode (_THIS, SDL_Surface *current, int width,
switch (bpp) {
case 16: /* (1)-5-5-5 RGB */
amask = 0;
rmask = 0x7c00;
gmask = 0x3e0;
bmask = 0x1f;
rmask = 0x7C00;
gmask = 0x03E0;
bmask = 0x001F;
break;
case 24:
SDL_SetError ("24bpp is not available");
return NULL;
case 32: /* (8)-8-8-8 ARGB */
amask = 0x00000000; /* per-pixel alpha needs to be fixed */
amask = 0x00000000; /* These are the correct semantics */
rmask = 0x00FF0000;
gmask = 0x0000FF00;
bmask = 0x000000FF;

View File

@ -122,12 +122,19 @@ static void QZ_CheckMouseMode (_THIS) { }
static void QZ_SetCaption (_THIS, const char *title, const char *icon) {
NSString *str = [ [ NSString alloc ] initWithCString:title ];
if (window != nil)
[ window setTitle:str ];
[ windowTitle release ];
windowTitle = str;
if ( window != nil ) {
NSString *string;
if ( title != NULL ) {
string = [ [ NSString alloc ] initWithCString:title ];
[ window setTitle:string ];
[ string release ];
}
if ( icon != NULL ) {
string = [ [ NSString alloc ] initWithCString:icon ];
[ window setMiniwindowTitle:string ];
[ string release ];
}
}
}
static void QZ_SetIcon (_THIS, SDL_Surface *icon, Uint8 *mask) {

View File

@ -35,9 +35,7 @@
@implementation SDL_QuartzWindowDelegate
- (BOOL)windowShouldClose:(id)sender {
SDL_Event event;
event.type = SDL_QUIT;
SDL_PushEvent(&event);
SDL_PrivateQuit();
return NO;
}
@end
@end