Mercurial > sdl-ios-xcode
changeset 58:bd6b0a910a65
* 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
author | Sam Lantinga <slouken@lokigames.com> |
---|---|
date | Mon, 11 Jun 2001 06:44:43 +0000 |
parents | ec550054db3b |
children | b685c94f8db7 |
files | BUGS PBProjects.tar.gz src/main/macosx/SDLMain.h src/main/macosx/SDLMain.m src/video/SDL_video.c src/video/quartz/SDL_QuartzVideo.h src/video/quartz/SDL_QuartzVideo.m src/video/quartz/SDL_QuartzWM.m src/video/quartz/SDL_QuartzWindow.m |
diffstat | 9 files changed, 106 insertions(+), 86 deletions(-) [+] |
line wrap: on
line diff
--- a/BUGS Mon Jun 11 00:08:35 2001 +0000 +++ b/BUGS Mon Jun 11 06:44:43 2001 +0000 @@ -72,12 +72,12 @@ 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.
--- a/src/main/macosx/SDLMain.h Mon Jun 11 00:08:35 2001 +0000 +++ b/src/main/macosx/SDLMain.h Mon Jun 11 06:44:43 2001 +0000 @@ -4,5 +4,4 @@ { } - (IBAction)quit:(id)sender; -- (IBAction)makeFullscreen:(id)sender; @end
--- a/src/main/macosx/SDLMain.m Mon Jun 11 00:08:35 2001 +0000 +++ b/src/main/macosx/SDLMain.m Mon Jun 11 06:44:43 2001 +0000 @@ -23,12 +23,6 @@ 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 @@ /* 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 @@ /* 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; -} \ No newline at end of file +}
--- a/src/video/SDL_video.c Mon Jun 11 00:08:35 2001 +0000 +++ b/src/video/SDL_video.c Mon Jun 11 06:44:43 2001 +0000 @@ -100,10 +100,6 @@ }; 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 @@ 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 @@ SDL_VideoDevice *video = current_video; SDL_VideoDevice *this = current_video; - if ( title ) { - if ( wm_title ) { - free(wm_title); - } - wm_title = (char *)malloc(strlen(title)+1); - if ( wm_title != NULL ) { - strcpy(wm_title, 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); + } } - } - if ( icon ) { - if ( wm_icon ) { - free(wm_icon); + 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); + } } - wm_icon = (char *)malloc(strlen(icon)+1); - if ( wm_icon != NULL ) { - strcpy(wm_icon, icon); + if ( (title || icon) && (video->SetCaption != NULL) ) { + video->SetCaption(this, video->wm_title,video->wm_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; + } } }
--- a/src/video/quartz/SDL_QuartzVideo.h Mon Jun 11 00:08:35 2001 +0000 +++ b/src/video/quartz/SDL_QuartzVideo.h Mon Jun 11 06:44:43 2001 +0000 @@ -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 @@ /* Window-only fields */ NSWindow *window; NSQuickDrawView *view; - NSString *title; } SDL_PrivateVideoData ; @@ -108,7 +107,6 @@ #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,
--- a/src/video/quartz/SDL_QuartzVideo.m Mon Jun 11 00:08:35 2001 +0000 +++ b/src/video/quartz/SDL_QuartzVideo.m Mon Jun 11 06:44:43 2001 +0000 @@ -132,7 +132,6 @@ kCFNumberSInt32Type, &device_height); video_format->BitsPerPixel = device_bpp; - windowTitle = @""; return 0; } @@ -293,6 +292,7 @@ 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_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 @@ 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 @@ 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;
--- a/src/video/quartz/SDL_QuartzWM.m Mon Jun 11 00:08:35 2001 +0000 +++ b/src/video/quartz/SDL_QuartzWM.m Mon Jun 11 06:44:43 2001 +0000 @@ -122,12 +122,19 @@ 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) {
--- a/src/video/quartz/SDL_QuartzWindow.m Mon Jun 11 00:08:35 2001 +0000 +++ b/src/video/quartz/SDL_QuartzWindow.m Mon Jun 11 06:44:43 2001 +0000 @@ -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 \ No newline at end of file +@end