diff src/video/quartz/SDL_QuartzWindow.m @ 1662:782fd950bd46 SDL-1.3

Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API. WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid. The code is now run through a consistent indent format: indent -i4 -nut -nsc -br -ce The headers are being converted to automatically generate doxygen documentation.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 28 May 2006 13:04:16 +0000
parents e49147870aac
children
line wrap: on
line diff
--- a/src/video/quartz/SDL_QuartzWindow.m	Sun May 21 17:27:13 2006 +0000
+++ b/src/video/quartz/SDL_QuartzWindow.m	Sun May 28 13:04:16 2006 +0000
@@ -29,190 +29,185 @@
     The genie effect uses the alpha component. Otherwise,
     it doesn't seem to matter what value it has.
 */
-static void QZ_SetPortAlphaOpaque () {
-    
+static void
+QZ_SetPortAlphaOpaque ()
+{
+
     SDL_Surface *surface = current_video->screen;
     int bpp;
-    
+
     bpp = surface->format->BitsPerPixel;
-    
+
     if (bpp == 32) {
-    
-        Uint32    *pixels = (Uint32*) surface->pixels;
-        Uint32    rowPixels = surface->pitch / 4;
-        Uint32    i, j;
-        
+
+        Uint32 *pixels = (Uint32 *) surface->pixels;
+        Uint32 rowPixels = surface->pitch / 4;
+        Uint32 i, j;
+
         for (i = 0; i < surface->h; i++)
             for (j = 0; j < surface->w; j++) {
-        
-                pixels[ (i * rowPixels) + j ] |= 0xFF000000;
+
+                pixels[(i * rowPixels) + j] |= 0xFF000000;
             }
     }
 }
 
 @implementation SDL_QuartzWindow
+/* we override these methods to fix the miniaturize animation/dock icon bug */
+- (void) miniaturize:(id) sender {
+    if (SDL_VideoSurface->flags & SDL_INTERNALOPENGL) {
 
-/* we override these methods to fix the miniaturize animation/dock icon bug */
-- (void)miniaturize:(id)sender
-{
-    if (SDL_VideoSurface->flags & SDL_INTERNALOPENGL) {
-    
         /* 
-            Future: Grab framebuffer and put into NSImage
-            [ qz_window setMiniwindowImage:image ];
-        */
-    }
-    else {
-        
+           Future: Grab framebuffer and put into NSImage
+           [ qz_window setMiniwindowImage:image ];
+         */
+    } else {
+
         /* make the alpha channel opaque so anim won't have holes in it */
         QZ_SetPortAlphaOpaque ();
     }
-    
+
     /* window is hidden now */
     SDL_PrivateAppActive (0, SDL_APPACTIVE);
-    
-    [ super miniaturize:sender ];
+
+  [super miniaturize:sender];
 }
 
-- (void)display
-{    
+-(void) display {
     /* 
-        This method fires just before the window deminaturizes from the Dock.
-        
-        We'll save the current visible surface, let the window manager redraw any
-        UI elements, and restore the SDL surface. This way, no expose event 
-        is required, and the deminiaturize works perfectly.
-    */
-     SDL_VideoDevice *this = (SDL_VideoDevice*)current_video;
-    
+       This method fires just before the window deminaturizes from the Dock.
+
+       We'll save the current visible surface, let the window manager redraw any
+       UI elements, and restore the SDL surface. This way, no expose event 
+       is required, and the deminiaturize works perfectly.
+     */
+    SDL_VideoDevice *this = (SDL_VideoDevice *) current_video;
+
     /* make sure pixels are fully opaque */
-    if (! ( SDL_VideoSurface->flags & SDL_INTERNALOPENGL ) )
+    if (!(SDL_VideoSurface->flags & SDL_INTERNALOPENGL))
         QZ_SetPortAlphaOpaque ();
-    
+
     /* save current visible SDL surface */
-    [ self cacheImageInRect:[ window_view frame ] ];
-    
+  [self cacheImageInRect:[window_view frame]];
+
     /* let the window manager redraw controls, border, etc */
-    [ super display ];
-    
+    [super display];
+
     /* restore visible SDL surface */
-    [ self restoreCachedImage ];
-    
+    [self restoreCachedImage];
+
     /* window is visible again */
     SDL_PrivateAppActive (1, SDL_APPACTIVE);
 }
 
-- (void)setFrame:(NSRect)frameRect display:(BOOL)flag
+-(void) setFrame:(NSRect)
+     frameRect display:(BOOL) flag
 {
 
     /*
-        If the video surface is NULL, this originated from QZ_SetVideoMode,
-        so don't send the resize event. 
-    */
-    SDL_VideoDevice *this = (SDL_VideoDevice*)current_video;
-    
+       If the video surface is NULL, this originated from QZ_SetVideoMode,
+       so don't send the resize event. 
+     */
+    SDL_VideoDevice *this = (SDL_VideoDevice *) current_video;
+
     if (this && SDL_VideoSurface == NULL) {
 
-        [ super setFrame:frameRect display:flag ];
-    }
-    else if (this && qz_window) {
+      [super setFrame: frameRect display:flag];
+    } else if (this && qz_window) {
 
         NSRect newViewFrame;
-        
-        [ super setFrame:frameRect display:flag ];
-        
-        newViewFrame = [ window_view frame ];
-        
+
+      [super setFrame: frameRect display:flag];
+
+        newViewFrame =[window_view frame];
+
         SDL_PrivateResize (newViewFrame.size.width, newViewFrame.size.height);
 
         /* If not OpenGL, we have to update the pixels and pitch */
-        if ( ! ( SDL_VideoSurface->flags & SDL_INTERNALOPENGL ) ) {
-            
-            CGrafPtr thePort = [ window_view qdPort ];
-            LockPortBits ( thePort );
-            
-            SDL_VideoSurface->pixels = GetPixBaseAddr ( GetPortPixMap ( thePort ) );
-            SDL_VideoSurface->pitch  = GetPixRowBytes ( GetPortPixMap ( thePort ) );
-                        
+        if (!(SDL_VideoSurface->flags & SDL_INTERNALOPENGL)) {
+
+            CGrafPtr thePort =[window_view qdPort];
+            LockPortBits (thePort);
+
+            SDL_VideoSurface->pixels =
+                GetPixBaseAddr (GetPortPixMap (thePort));
+            SDL_VideoSurface->pitch =
+                GetPixRowBytes (GetPortPixMap (thePort));
+
             /* 
-                SDL_VideoSurface->pixels now points to the window's pixels
-                We want it to point to the *view's* pixels 
-            */
-            { 
-                int vOffset = [ qz_window frame ].size.height - 
+               SDL_VideoSurface->pixels now points to the window's pixels
+               We want it to point to the *view's* pixels 
+             */
+            {
+                int vOffset =[qz_window frame].size.height -
                     newViewFrame.size.height - newViewFrame.origin.y;
-                
+
                 int hOffset = newViewFrame.origin.x;
-                        
-                SDL_VideoSurface->pixels = (Uint8 *)SDL_VideoSurface->pixels + (vOffset * SDL_VideoSurface->pitch) + hOffset * (device_bpp/8);
+
+                SDL_VideoSurface->pixels =
+                    (Uint8 *) SDL_VideoSurface->pixels +
+                    (vOffset * SDL_VideoSurface->pitch) +
+                    hOffset * (device_bpp / 8);
             }
-            
-            UnlockPortBits ( thePort );
+
+            UnlockPortBits (thePort);
         }
     }
 }
 
-- (void)appDidHide:(NSNotification*)note
-{
+-(void) appDidHide:(NSNotification *) note {
     SDL_PrivateAppActive (0, SDL_APPACTIVE);
 }
 
-- (void)appWillUnhide:(NSNotification*)note
-{
-    SDL_VideoDevice *this = (SDL_VideoDevice*)current_video;
-    
-    if ( this ) {
-    
+-(void) appWillUnhide:(NSNotification *) note {
+    SDL_VideoDevice *this = (SDL_VideoDevice *) current_video;
+
+    if (this) {
+
         /* make sure pixels are fully opaque */
-        if (! ( SDL_VideoSurface->flags & SDL_INTERNALOPENGL ) )
+        if (!(SDL_VideoSurface->flags & SDL_INTERNALOPENGL))
             QZ_SetPortAlphaOpaque ();
-          
+
         /* save current visible SDL surface */
-        [ self cacheImageInRect:[ window_view frame ] ];
+      [self cacheImageInRect:[window_view frame]];
     }
 }
 
-- (void)appDidUnhide:(NSNotification*)note
-{
+-(void) appDidUnhide:(NSNotification *) note {
     /* restore cached image, since it may not be current, post expose event too */
-    [ self restoreCachedImage ];
-    
-    /*SDL_PrivateExpose ();*/
-    
+    [self restoreCachedImage];
+
+    /*SDL_PrivateExpose (); */
+
     SDL_PrivateAppActive (1, SDL_APPACTIVE);
 }
 
-- (id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)styleMask backing:(NSBackingStoreType)backingType defer:(BOOL)flag
+-(id) initWithContentRect:(NSRect)
+     contentRect styleMask:(unsigned int)
+     styleMask backing:(NSBackingStoreType)
+     backingType defer:(BOOL) flag
 {
     /* Make our window subclass receive these application notifications */
-    [ [ NSNotificationCenter defaultCenter ] addObserver:self
-        selector:@selector(appDidHide:) name:NSApplicationDidHideNotification object:NSApp ];
-    
-    [ [ NSNotificationCenter defaultCenter ] addObserver:self
-        selector:@selector(appDidUnhide:) name:NSApplicationDidUnhideNotification object:NSApp ];
-   
-    [ [ NSNotificationCenter defaultCenter ] addObserver:self
-        selector:@selector(appWillUnhide:) name:NSApplicationWillUnhideNotification object:NSApp ];
-        
-    return [ super initWithContentRect:contentRect styleMask:styleMask backing:backingType defer:flag ];
+  [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector (appDidHide: )name: NSApplicationDidHideNotification object:NSApp];
+
+  [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector (appDidUnhide: )name: NSApplicationDidUnhideNotification object:NSApp];
+
+  [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector (appWillUnhide: )name: NSApplicationWillUnhideNotification object:NSApp];
+
+  return[super initWithContentRect: contentRect styleMask: styleMask backing: backingType defer:flag];
 }
 
-@end
-
-@implementation SDL_QuartzWindowDelegate
-- (BOOL)windowShouldClose:(id)sender
+@end @ implementation SDL_QuartzWindowDelegate - (BOOL) windowShouldClose:(id) sender
 {
-    SDL_PrivateQuit();
+    SDL_PrivateQuit ();
     return NO;
 }
 
-- (void)windowDidBecomeKey:(NSNotification *)aNotification
-{
+-(void) windowDidBecomeKey:(NSNotification *) aNotification {
     QZ_DoActivate (current_video);
 }
 
-- (void)windowDidResignKey:(NSNotification *)aNotification
-{
+-(void) windowDidResignKey:(NSNotification *) aNotification {
     QZ_DoDeactivate (current_video);
 }