Skip to content

Commit

Permalink
* Removed fullscreen menu option from the "Window" menu
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Sam Lantinga committed Jun 11, 2001
1 parent ed1b367 commit 6f51643
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 86 deletions.
10 changes: 5 additions & 5 deletions BUGS
Expand Up @@ -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.
Expand Down
Binary file modified PBProjects.tar.gz
Binary file not shown.
1 change: 0 additions & 1 deletion src/main/macosx/SDLMain.h
Expand Up @@ -4,5 +4,4 @@
{
}
- (IBAction)quit:(id)sender;
- (IBAction)makeFullscreen:(id)sender;
@end
36 changes: 18 additions & 18 deletions src/main/macosx/SDLMain.m
Expand Up @@ -23,12 +23,6 @@ - (void) quit:(id)sender
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
{
Expand All @@ -53,16 +47,16 @@ - (void) setupWorkingDirectory
/* 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

Expand All @@ -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;
}
}
66 changes: 34 additions & 32 deletions src/video/SDL_video.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
}
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;
}
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/video/quartz/SDL_QuartzVideo.h
Expand Up @@ -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
Expand Down Expand Up @@ -89,7 +89,6 @@ typedef struct SDL_PrivateVideoData {
/* Window-only fields */
NSWindow *window;
NSQuickDrawView *view;
NSString *title;

} SDL_PrivateVideoData ;

Expand All @@ -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,
Expand Down
50 changes: 33 additions & 17 deletions src/video/quartz/SDL_QuartzVideo.m
Expand Up @@ -132,7 +132,6 @@ static int QZ_VideoInit (_THIS, SDL_PixelFormat *video_format) {
kCFNumberSInt32Type, &device_height);

video_format->BitsPerPixel = device_bpp;
windowTitle = @"";

return 0;
}
Expand Down Expand Up @@ -293,6 +292,7 @@ static void QZ_UnsetVideoMode (_THIS) {
current->pitch = CGDisplayBytesPerRow (display_id);
#endif

current->flags = 0;
current->w = width;
current->h = height;
current->flags |= SDL_FULLSCREEN;
Expand Down Expand Up @@ -350,27 +350,37 @@ static void QZ_UnsetVideoMode (_THIS) {

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 ];
Expand Down Expand Up @@ -400,11 +410,17 @@ static void QZ_UnsetVideoMode (_THIS) {
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;
}
Expand Down Expand Up @@ -444,15 +460,15 @@ static void QZ_UnsetVideoMode (_THIS) {
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;
Expand Down
19 changes: 13 additions & 6 deletions src/video/quartz/SDL_QuartzWM.m
Expand Up @@ -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) {
Expand Down
6 changes: 2 additions & 4 deletions src/video/quartz/SDL_QuartzWindow.m
Expand Up @@ -35,9 +35,7 @@ - (BOOL)windowShouldClose:(id)sender;
@implementation SDL_QuartzWindowDelegate
- (BOOL)windowShouldClose:(id)sender {

SDL_Event event;
event.type = SDL_QUIT;
SDL_PushEvent(&event);
SDL_PrivateQuit();
return NO;
}
@end
@end

0 comments on commit 6f51643

Please sign in to comment.