src/video/quartz/SDL_QuartzVideo.m
branchSDL-1.2
changeset 4267 27f972dd5aff
parent 4265 c7b1d5eaa77d
child 4317 719faf118c38
equal deleted inserted replaced
4266:62849663f20a 4267:27f972dd5aff
   459                                            int height, int bpp, Uint32 flags) {
   459                                            int height, int bpp, Uint32 flags) {
   460     boolean_t exact_match = 0;
   460     boolean_t exact_match = 0;
   461     NSRect screen_rect;
   461     NSRect screen_rect;
   462     CGError error;
   462     CGError error;
   463     NSRect contentRect;
   463     NSRect contentRect;
   464     BOOL isCustom = NO;
       
   465     CGDisplayFadeReservationToken fade_token = kCGDisplayFadeReservationInvalidToken;
   464     CGDisplayFadeReservationToken fade_token = kCGDisplayFadeReservationInvalidToken;
   466 
   465 
   467     /* Fade to black to hide resolution-switching flicker (and garbage
   466     /* Fade to black to hide resolution-switching flicker (and garbage
   468        that is displayed by a destroyed OpenGL context, if applicable) */
   467        that is displayed by a destroyed OpenGL context, if applicable) */
   469     if ( CGAcquireDisplayFadeReservation (5, &fade_token) == kCGErrorSuccess ) {
   468     if ( CGAcquireDisplayFadeReservation (5, &fade_token) == kCGErrorSuccess ) {
   575             [ qz_window setViewsNeedDisplay:NO ];
   574             [ qz_window setViewsNeedDisplay:NO ];
   576         }
   575         }
   577     }
   576     }
   578     /* We already have a window, just change its size */
   577     /* We already have a window, just change its size */
   579     else {
   578     else {
   580         if (!isCustom) {
   579         [ qz_window setContentSize:contentRect.size ];
   581             [ qz_window setContentSize:contentRect.size ];
   580         current->flags |= (SDL_NOFRAME|SDL_RESIZABLE) & mode_flags;
   582             current->flags |= (SDL_NOFRAME|SDL_RESIZABLE) & mode_flags;
   581         [ window_view setFrameSize:contentRect.size ];
   583             [ window_view setFrameSize:contentRect.size ];
       
   584         }
       
   585     }
   582     }
   586 
   583 
   587     /* Setup OpenGL for a fullscreen context */
   584     /* Setup OpenGL for a fullscreen context */
   588     if (flags & SDL_OPENGL) {
   585     if (flags & SDL_OPENGL) {
   589 
   586 
   658 
   655 
   659 static SDL_Surface* QZ_SetVideoWindowed (_THIS, SDL_Surface *current, int width,
   656 static SDL_Surface* QZ_SetVideoWindowed (_THIS, SDL_Surface *current, int width,
   660                                          int height, int *bpp, Uint32 flags) {
   657                                          int height, int *bpp, Uint32 flags) {
   661     unsigned int style;
   658     unsigned int style;
   662     NSRect contentRect;
   659     NSRect contentRect;
   663     BOOL isCustom = NO;
       
   664     int center_window = 1;
   660     int center_window = 1;
   665     int origin_x, origin_y;
   661     int origin_x, origin_y;
   666     CGDisplayFadeReservationToken fade_token = kCGDisplayFadeReservationInvalidToken;
   662     CGDisplayFadeReservationToken fade_token = kCGDisplayFadeReservationInvalidToken;
   667 
   663 
   668     current->flags = 0;
   664     current->flags = 0;
   743 
   739 
   744         if ( QZ_WindowPosition(this, &origin_x, &origin_y) ) {
   740         if ( QZ_WindowPosition(this, &origin_x, &origin_y) ) {
   745             /* have to flip the Y value (NSPoint is lower left corner origin) */
   741             /* have to flip the Y value (NSPoint is lower left corner origin) */
   746             [ qz_window setFrameTopLeftPoint:NSMakePoint((float) origin_x, (float) (this->info.current_h - origin_y))];
   742             [ qz_window setFrameTopLeftPoint:NSMakePoint((float) origin_x, (float) (this->info.current_h - origin_y))];
   747             center_window = 0;
   743             center_window = 0;
   748         }
   744         } else if ( center_window ) {
   749         else if ( center_window ) {
       
   750             [ qz_window center ];
   745             [ qz_window center ];
   751         }
   746         }
   752 
   747 
   753         [ qz_window setDelegate:
   748         [ qz_window setDelegate:
   754             [ [ SDL_QuartzWindowDelegate alloc ] init ] ];
   749             [ [ SDL_QuartzWindowDelegate alloc ] init ] ];
   755         [ qz_window setContentView: [ [ [ SDL_QuartzView alloc ] init ] autorelease ] ];
   750         [ qz_window setContentView: [ [ [ SDL_QuartzView alloc ] init ] autorelease ] ];
   756     }
   751     }
   757     /* We already have a window, just change its size */
   752     /* We already have a window, just change its size */
   758     else {
   753     else {
   759     
   754         [ qz_window setContentSize:contentRect.size ];
   760         if (!isCustom) {
   755         current->flags |= (SDL_NOFRAME|SDL_RESIZABLE) & mode_flags;
   761             [ qz_window setContentSize:contentRect.size ];
   756         [ window_view setFrameSize:contentRect.size ];
   762             current->flags |= (SDL_NOFRAME|SDL_RESIZABLE) & mode_flags;
       
   763             [ window_view setFrameSize:contentRect.size ];
       
   764         }
       
   765     }
   757     }
   766 
   758 
   767     /* For OpenGL, we bind the context to a subview */
   759     /* For OpenGL, we bind the context to a subview */
   768     if ( flags & SDL_OPENGL ) {
   760     if ( flags & SDL_OPENGL ) {
   769 
   761