* Removed fullscreen menu option from the "Window" menu
authorSam Lantinga <slouken@lokigames.com>
Mon, 11 Jun 2001 06:44:43 +0000
changeset 58bd6b0a910a65
parent 57 ec550054db3b
child 59 b685c94f8db7
* 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
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
     1.1 --- a/BUGS	Mon Jun 11 00:08:35 2001 +0000
     1.2 +++ b/BUGS	Mon Jun 11 06:44:43 2001 +0000
     1.3 @@ -72,12 +72,12 @@
     1.4  MacOS X:
     1.5  	Joystick and CD-ROM functions are not implemented yet.
     1.6  
     1.7 -	Closing window from window's close widget not implemented yet.
     1.8 -	
     1.9 -	Minimizing the window erases the framebuffer to the pinstripe pattern.
    1.10 -	
    1.11 +	Window management buttons don't draw correctly.
    1.12 +
    1.13  	Window may not close when unsetting video mode and resetting.
    1.14 -	
    1.15 +
    1.16 +	Resizeable windows aren't implemented yet.
    1.17 +
    1.18  	Depth switching for windowed mode isn't implemented yet.
    1.19  	
    1.20  	Palette handling isn't implemented in windowed mode yet.
     2.1 Binary file PBProjects.tar.gz has changed
     3.1 --- a/src/main/macosx/SDLMain.h	Mon Jun 11 00:08:35 2001 +0000
     3.2 +++ b/src/main/macosx/SDLMain.h	Mon Jun 11 06:44:43 2001 +0000
     3.3 @@ -4,5 +4,4 @@
     3.4  {
     3.5  }
     3.6  - (IBAction)quit:(id)sender;
     3.7 -- (IBAction)makeFullscreen:(id)sender;
     3.8  @end
     4.1 --- a/src/main/macosx/SDLMain.m	Mon Jun 11 00:08:35 2001 +0000
     4.2 +++ b/src/main/macosx/SDLMain.m	Mon Jun 11 06:44:43 2001 +0000
     4.3 @@ -23,12 +23,6 @@
     4.4  	SDL_PushEvent(&event);
     4.5  }
     4.6  
     4.7 -/* Invoked from the "Make fulllscreen" menu item */
     4.8 -- (void) makeFullscreen:(id)sender
     4.9 -{
    4.10 -    
    4.11 -}
    4.12 -
    4.13  /* Set the working directory to the .app's parent directory */
    4.14  - (void) setupWorkingDirectory
    4.15  {
    4.16 @@ -53,16 +47,16 @@
    4.17  /* Called when the internal event loop has just started running */
    4.18  - (void) applicationDidFinishLaunching: (NSNotification *) note
    4.19  {
    4.20 +    int status;
    4.21 +
    4.22      /* Set the working directory to the .app's parent directory */
    4.23      [ self setupWorkingDirectory ];
    4.24 -    
    4.25 -    /* This is passed if we are launched by double-clicking */
    4.26 -    if ( gArgc >= 2 && strncmp (gArgv[1], "-psn", 4) == 0 )
    4.27 -        gArgc = 1;
    4.28 -    
    4.29 +
    4.30      /* Hand off to main application code */
    4.31 -    SDL_main (gArgc, gArgv);
    4.32 -    exit(0);
    4.33 +    status = SDL_main (gArgc, gArgv);
    4.34 +
    4.35 +    /* We're done, thank you for playing */
    4.36 +    exit(status);
    4.37  }
    4.38  @end
    4.39  
    4.40 @@ -76,13 +70,19 @@
    4.41      /* Copy the arguments into a global variable */
    4.42      int i;
    4.43      
    4.44 -    gArgc = argc;
    4.45 -    gArgv = (char**) malloc (sizeof(*gArgv) * gArgc);
    4.46 +    /* This is passed if we are launched by double-clicking */
    4.47 +    if ( argc >= 2 && strncmp (argv[1], "-psn", 4) == 0 ) {
    4.48 +        gArgc = 1;
    4.49 +    } else {
    4.50 +        gArgc = argc;
    4.51 +    }
    4.52 +    gArgv = (char**) malloc (sizeof(*gArgv) * (gArgc+1));
    4.53      assert (gArgv != NULL);
    4.54      for (i = 0; i < gArgc; i++) {
    4.55 -        gArgv[i] = strdup (argv[i]);
    4.56 +        gArgv[i] = argv[i];
    4.57      }
    4.58 -    
    4.59 +    gArgv[i] = NULL;
    4.60 +
    4.61      NSApplicationMain (argc, argv);
    4.62      return 0;
    4.63 -}
    4.64 \ No newline at end of file
    4.65 +}
     5.1 --- a/src/video/SDL_video.c	Mon Jun 11 00:08:35 2001 +0000
     5.2 +++ b/src/video/SDL_video.c	Mon Jun 11 06:44:43 2001 +0000
     5.3 @@ -100,10 +100,6 @@
     5.4  };
     5.5  SDL_VideoDevice *current_video = NULL;
     5.6  
     5.7 -/* Places to store title and icon text for the app */
     5.8 -static char *wm_title = NULL;
     5.9 -static char *wm_icon  = NULL;
    5.10 -
    5.11  /* Various local functions */
    5.12  int SDL_VideoInit(const char *driver_name, Uint32 flags);
    5.13  void SDL_VideoQuit(void);
    5.14 @@ -1254,13 +1250,13 @@
    5.15  			free(video->gamma);
    5.16  			video->gamma = NULL;
    5.17  		}
    5.18 -		if ( wm_title != NULL ) {
    5.19 -			free(wm_title);
    5.20 -			wm_title = NULL;
    5.21 +		if ( video->wm_title != NULL ) {
    5.22 +			free(video->wm_title);
    5.23 +			video->wm_title = NULL;
    5.24  		}
    5.25 -		if ( wm_icon != NULL ) {
    5.26 -			free(wm_icon);
    5.27 -			wm_icon = NULL;
    5.28 +		if ( video->wm_icon != NULL ) {
    5.29 +			free(video->wm_icon);
    5.30 +			video->wm_icon = NULL;
    5.31  		}
    5.32  
    5.33  		/* Finish cleaning up video subsystem */
    5.34 @@ -1539,35 +1535,41 @@
    5.35  	SDL_VideoDevice *video = current_video;
    5.36  	SDL_VideoDevice *this  = current_video;
    5.37  
    5.38 -	if ( title ) {
    5.39 -		if ( wm_title ) {
    5.40 -			free(wm_title);
    5.41 +	if ( video ) {
    5.42 +		if ( title ) {
    5.43 +			if ( video->wm_title ) {
    5.44 +				free(video->wm_title);
    5.45 +			}
    5.46 +			video->wm_title = (char *)malloc(strlen(title)+1);
    5.47 +			if ( video->wm_title != NULL ) {
    5.48 +				strcpy(video->wm_title, title);
    5.49 +			}
    5.50  		}
    5.51 -		wm_title = (char *)malloc(strlen(title)+1);
    5.52 -		if ( wm_title != NULL ) {
    5.53 -			strcpy(wm_title, title);
    5.54 +		if ( icon ) {
    5.55 +			if ( video->wm_icon ) {
    5.56 +				free(video->wm_icon);
    5.57 +			}
    5.58 +			video->wm_icon = (char *)malloc(strlen(icon)+1);
    5.59 +			if ( video->wm_icon != NULL ) {
    5.60 +				strcpy(video->wm_icon, icon);
    5.61 +			}
    5.62  		}
    5.63 -	}
    5.64 -	if ( icon ) {
    5.65 -		if ( wm_icon ) {
    5.66 -			free(wm_icon);
    5.67 +		if ( (title || icon) && (video->SetCaption != NULL) ) {
    5.68 +			video->SetCaption(this, video->wm_title,video->wm_icon);
    5.69  		}
    5.70 -		wm_icon = (char *)malloc(strlen(icon)+1);
    5.71 -		if ( wm_icon != NULL ) {
    5.72 -			strcpy(wm_icon, icon);
    5.73 -		}
    5.74 -	}
    5.75 -	if ( (title || icon) && video && (video->SetCaption != NULL) ) {
    5.76 -		video->SetCaption(this, wm_title, wm_icon);
    5.77  	}
    5.78  }
    5.79  void SDL_WM_GetCaption (char **title, char **icon)
    5.80  {
    5.81 -	if ( title ) {
    5.82 -		*title = wm_title;
    5.83 -	}
    5.84 -	if ( icon ) {
    5.85 -		*icon = wm_icon;
    5.86 +	SDL_VideoDevice *video = current_video;
    5.87 +
    5.88 +	if ( video ) {
    5.89 +		if ( title ) {
    5.90 +			*title = video->wm_title;
    5.91 +		}
    5.92 +		if ( icon ) {
    5.93 +			*icon = video->wm_icon;
    5.94 +		}
    5.95  	}
    5.96  }
    5.97  
     6.1 --- a/src/video/quartz/SDL_QuartzVideo.h	Mon Jun 11 00:08:35 2001 +0000
     6.2 +++ b/src/video/quartz/SDL_QuartzVideo.h	Mon Jun 11 06:44:43 2001 +0000
     6.3 @@ -40,7 +40,7 @@
     6.4          - SetColors sets palette correctly but clears framebuffer
     6.5          - Crash in CG after several mode switches
     6.6          - Retained windows don't draw their title bar quite right (OS Bug)
     6.7 -        - Should I do depth switching for windowed modes?
     6.8 +        - Should I do depth switching for windowed modes? - No, not usually.
     6.9          - Launch times are slow, maybe prebinding will help
    6.10          - Direct framebuffer access has some artifacts, maybe a driver issue
    6.11          - Cursor in 8 bit modes is screwy
    6.12 @@ -89,7 +89,6 @@
    6.13      /* Window-only fields */
    6.14      NSWindow        *window;
    6.15      NSQuickDrawView *view;
    6.16 -    NSString        *title;
    6.17      
    6.18  } SDL_PrivateVideoData ;
    6.19  
    6.20 @@ -108,7 +107,6 @@
    6.21  #define mode_flags (this->hidden->flags)
    6.22  #define window (this->hidden->window)
    6.23  #define windowView (this->hidden->view)
    6.24 -#define windowTitle (this->hidden->title)
    6.25  
    6.26  /* Interface for hardware fill not (yet) in the public API */
    6.27  int CGSDisplayHWFill (CGDirectDisplayID id, unsigned int x, unsigned int y, 
     7.1 --- a/src/video/quartz/SDL_QuartzVideo.m	Mon Jun 11 00:08:35 2001 +0000
     7.2 +++ b/src/video/quartz/SDL_QuartzVideo.m	Mon Jun 11 06:44:43 2001 +0000
     7.3 @@ -132,7 +132,6 @@
     7.4                      kCFNumberSInt32Type, &device_height);
     7.5  
     7.6    video_format->BitsPerPixel = device_bpp;
     7.7 -  windowTitle = @"";
     7.8    
     7.9    return 0;
    7.10  }
    7.11 @@ -293,6 +292,7 @@
    7.12      current->pitch  = CGDisplayBytesPerRow (display_id);
    7.13  #endif
    7.14  
    7.15 +    current->flags = 0;
    7.16      current->w = width;
    7.17      current->h = height;
    7.18      current->flags |= SDL_FULLSCREEN;  
    7.19 @@ -350,27 +350,37 @@
    7.20  
    7.21  static SDL_Surface* QZ_SetVideoWindowed (_THIS, SDL_Surface *current, int width,
    7.22                                             int height, int bpp, Uint32 flags) {    
    7.23 +    unsigned int style;
    7.24      NSRect rect;    
    7.25      rect = NSMakeRect (0, 0, width, height);
    7.26 -    
    7.27 +
    7.28 +#if 1 // FIXME - the resize button doesn't show?  Also need resize events...
    7.29 +    flags &= ~SDL_RESIZABLE;
    7.30 +#endif
    7.31 +    /* Set the window style based on input flags */
    7.32 +    if ( flags & SDL_NOFRAME ) {
    7.33 +        style = NSBorderlessWindowMask;
    7.34 +    } else {
    7.35 +        style = NSTitledWindowMask;
    7.36 +        style |= (NSMiniaturizableWindowMask | NSClosableWindowMask);
    7.37 +        if ( flags & SDL_RESIZABLE )
    7.38 +            style |= NSResizableWindowMask;
    7.39 +    }
    7.40 +
    7.41      /* Manually create a window, avoids having a nib file resource */
    7.42      window = [ [ SDL_QuartzWindow alloc ] initWithContentRect:rect 
    7.43 -        styleMask:(NSTitledWindowMask | NSMiniaturizableWindowMask |
    7.44 -                    NSClosableWindowMask)
    7.45 -        backing: //NSBackingStoreBuffered
    7.46 -            NSBackingStoreRetained
    7.47 -          defer:NO ];
    7.48 -    
    7.49 +        styleMask:style backing:NSBackingStoreRetained defer:NO ];
    7.50      if (window == nil) {
    7.51          SDL_SetError ("Could not create the Cocoa window");
    7.52          return NULL;
    7.53      }
    7.54      
    7.55 -    current->w  = width;
    7.56 +    current->flags = 0;
    7.57 +    current->w = width;
    7.58      current->h = height;
    7.59      
    7.60      [ window setReleasedWhenClosed:YES ];
    7.61 -    [ window setTitle:windowTitle ];
    7.62 +    QZ_SetCaption(this, this->wm_title, this->wm_icon);
    7.63      [ window setAcceptsMouseMovedEvents:YES ];
    7.64      [ window setViewsNeedDisplay:NO ];
    7.65      [ window center ];
    7.66 @@ -400,11 +410,17 @@
    7.67          current->pixels = GetPixBaseAddr ( GetPortPixMap ( [ windowView qdPort ] ) );
    7.68          current->pitch  = GetPixRowBytes ( GetPortPixMap ( [ windowView qdPort ] ) );
    7.69              
    7.70 -        /* Offset 22 pixels down to fill the full content region */
    7.71 -        current->pixels += 22 * current->pitch;
    7.72 -        
    7.73          current->flags |= SDL_SWSURFACE;
    7.74          current->flags |= SDL_PREALLOC;
    7.75 +	if ( flags & SDL_NOFRAME )
    7.76 +        	current->flags |= SDL_NOFRAME;
    7.77 +	if ( flags & SDL_RESIZABLE )
    7.78 +        	current->flags |= SDL_RESIZABLE;
    7.79 +
    7.80 +        /* Offset 22 pixels down to fill the full content region */
    7.81 +	if ( ! (current->flags & SDL_NOFRAME) ) {
    7.82 +        	current->pixels += 22 * current->pitch;
    7.83 +	}
    7.84  
    7.85          this->UpdateRects = QZ_UpdateRects;
    7.86      }
    7.87 @@ -444,15 +460,15 @@
    7.88          switch (bpp) {
    7.89              case 16:   /* (1)-5-5-5 RGB */
    7.90                  amask = 0; 
    7.91 -                rmask = 0x7c00;
    7.92 -                gmask = 0x3e0;
    7.93 -                bmask = 0x1f;
    7.94 +                rmask = 0x7C00;
    7.95 +                gmask = 0x03E0;
    7.96 +                bmask = 0x001F;
    7.97                  break;
    7.98              case 24:
    7.99                  SDL_SetError ("24bpp is not available");
   7.100                  return NULL;
   7.101              case 32:   /* (8)-8-8-8 ARGB */
   7.102 -                amask = 0x00000000; /* per-pixel alpha needs to be fixed */
   7.103 +                amask = 0x00000000; /* These are the correct semantics */
   7.104                  rmask = 0x00FF0000;
   7.105                  gmask = 0x0000FF00;
   7.106                  bmask = 0x000000FF;
     8.1 --- a/src/video/quartz/SDL_QuartzWM.m	Mon Jun 11 00:08:35 2001 +0000
     8.2 +++ b/src/video/quartz/SDL_QuartzWM.m	Mon Jun 11 06:44:43 2001 +0000
     8.3 @@ -122,12 +122,19 @@
     8.4  
     8.5  static void QZ_SetCaption    (_THIS, const char *title, const char *icon) {
     8.6  
     8.7 -    NSString *str = [ [ NSString alloc ] initWithCString:title ];
     8.8 -    if (window != nil)
     8.9 -        [ window setTitle:str ];
    8.10 -
    8.11 -    [ windowTitle release ];
    8.12 -    windowTitle = str;
    8.13 +    if ( window != nil ) {
    8.14 +        NSString *string;
    8.15 +        if ( title != NULL ) {
    8.16 +            string = [ [ NSString alloc ] initWithCString:title ];
    8.17 +            [ window setTitle:string ];
    8.18 +            [ string release ];
    8.19 +        }
    8.20 +        if ( icon != NULL ) {
    8.21 +            string = [ [ NSString alloc ] initWithCString:icon ];
    8.22 +            [ window setMiniwindowTitle:string ];
    8.23 +            [ string release ];
    8.24 +        }
    8.25 +    }
    8.26  }
    8.27  
    8.28  static void QZ_SetIcon       (_THIS, SDL_Surface *icon, Uint8 *mask) {
     9.1 --- a/src/video/quartz/SDL_QuartzWindow.m	Mon Jun 11 00:08:35 2001 +0000
     9.2 +++ b/src/video/quartz/SDL_QuartzWindow.m	Mon Jun 11 06:44:43 2001 +0000
     9.3 @@ -35,9 +35,7 @@
     9.4  @implementation SDL_QuartzWindowDelegate
     9.5  - (BOOL)windowShouldClose:(id)sender {
     9.6  
     9.7 -    SDL_Event event;
     9.8 -    event.type = SDL_QUIT;
     9.9 -    SDL_PushEvent(&event);
    9.10 +    SDL_PrivateQuit();
    9.11      return NO;
    9.12  }
    9.13 -@end
    9.14 \ No newline at end of file
    9.15 +@end