src/video/quartz/SDL_QuartzVideo.m
changeset 657 714053f573e7
parent 656 864e2d2a9a55
child 668 f91ded895274
equal deleted inserted replaced
656:864e2d2a9a55 657:714053f573e7
   251         }
   251         }
   252     }
   252     }
   253     return client_mode_list;
   253     return client_mode_list;
   254 }
   254 }
   255 
   255 
       
   256 static SDL_bool QZ_WindowPosition(_THIS, int *x, int *y)
       
   257 {
       
   258     const char *window = getenv("SDL_VIDEO_WINDOW_POS");
       
   259     if ( window ) {
       
   260         if ( sscanf(window, "%d,%d", x, y) == 2 ) {
       
   261             return SDL_TRUE;
       
   262         }
       
   263     }
       
   264     return SDL_FALSE;
       
   265 }
       
   266 
   256 /* 
   267 /* 
   257     Gamma functions to try to hide the flash from a rez switch
   268     Gamma functions to try to hide the flash from a rez switch
   258     Fade the display from normal to black
   269     Fade the display from normal to black
   259     Save gamma tables for fade back to normal
   270     Save gamma tables for fade back to normal
   260 */
   271 */
   567 
   578 
   568 static SDL_Surface* QZ_SetVideoWindowed (_THIS, SDL_Surface *current, int width,
   579 static SDL_Surface* QZ_SetVideoWindowed (_THIS, SDL_Surface *current, int width,
   569                                          int height, int bpp, Uint32 flags) {
   580                                          int height, int bpp, Uint32 flags) {
   570     unsigned int style;
   581     unsigned int style;
   571     NSRect contentRect;
   582     NSRect contentRect;
       
   583     int center_window = 1;
       
   584     int origin_x, origin_y;
   572 
   585 
   573     current->flags = 0;
   586     current->flags = 0;
   574     current->w = width;
   587     current->w = width;
   575     current->h = height;
   588     current->h = height;
   576     
   589     
   604                 style |= NSResizableWindowMask;
   617                 style |= NSResizableWindowMask;
   605                 current->flags |= SDL_RESIZABLE;
   618                 current->flags |= SDL_RESIZABLE;
   606             }
   619             }
   607         }
   620         }
   608                 
   621                 
       
   622         if ( QZ_WindowPosition(this, &origin_x, &origin_y) ) {
       
   623             center_window = 0;
       
   624             contentRect.origin.x = (float)origin_x;
       
   625             contentRect.origin.y = (float)origin_y;            
       
   626         }
       
   627         
   609         /* Manually create a window, avoids having a nib file resource */
   628         /* Manually create a window, avoids having a nib file resource */
   610         qz_window = [ [ SDL_QuartzWindow alloc ] 
   629         qz_window = [ [ SDL_QuartzWindow alloc ] 
   611             initWithContentRect:contentRect
   630             initWithContentRect:contentRect
   612                 styleMask:style 
   631                 styleMask:style 
   613                     backing:NSBackingStoreBuffered
   632                     backing:NSBackingStoreBuffered
   620     
   639     
   621         //[ qz_window setReleasedWhenClosed:YES ];
   640         //[ qz_window setReleasedWhenClosed:YES ];
   622         QZ_SetCaption(this, this->wm_title, this->wm_icon);
   641         QZ_SetCaption(this, this->wm_title, this->wm_icon);
   623         [ qz_window setAcceptsMouseMovedEvents:YES ];
   642         [ qz_window setAcceptsMouseMovedEvents:YES ];
   624         [ qz_window setViewsNeedDisplay:NO ];
   643         [ qz_window setViewsNeedDisplay:NO ];
   625         [ qz_window center ];
   644         if ( center_window ) {
       
   645             [ qz_window center ];
       
   646         }
   626         [ qz_window setDelegate:
   647         [ qz_window setDelegate:
   627             [ [ [ SDL_QuartzWindowDelegate alloc ] init ] autorelease ] ];
   648             [ [ [ SDL_QuartzWindowDelegate alloc ] init ] autorelease ] ];
   628     }
   649     }
   629     /* We already have a window, just change its size */
   650     /* We already have a window, just change its size */
   630     else {
   651     else {