Date: Thu, 24 Jul 2003 01:40:17 +0200
authorSam Lantinga <slouken@libsdl.org>
Wed, 23 Jul 2003 04:39:44 +0000
changeset 657714053f573e7
parent 656 864e2d2a9a55
child 658 e71b7108d2d7
Date: Thu, 24 Jul 2003 01:40:17 +0200
From: Andrew Straw
Subject: Patch: Mac OS X window position environment variable
src/video/quartz/SDL_QuartzVideo.m
     1.1 --- a/src/video/quartz/SDL_QuartzVideo.m	Tue Jul 22 15:33:28 2003 +0000
     1.2 +++ b/src/video/quartz/SDL_QuartzVideo.m	Wed Jul 23 04:39:44 2003 +0000
     1.3 @@ -253,6 +253,17 @@
     1.4      return client_mode_list;
     1.5  }
     1.6  
     1.7 +static SDL_bool QZ_WindowPosition(_THIS, int *x, int *y)
     1.8 +{
     1.9 +    const char *window = getenv("SDL_VIDEO_WINDOW_POS");
    1.10 +    if ( window ) {
    1.11 +        if ( sscanf(window, "%d,%d", x, y) == 2 ) {
    1.12 +            return SDL_TRUE;
    1.13 +        }
    1.14 +    }
    1.15 +    return SDL_FALSE;
    1.16 +}
    1.17 +
    1.18  /* 
    1.19      Gamma functions to try to hide the flash from a rez switch
    1.20      Fade the display from normal to black
    1.21 @@ -569,6 +580,8 @@
    1.22                                           int height, int bpp, Uint32 flags) {
    1.23      unsigned int style;
    1.24      NSRect contentRect;
    1.25 +    int center_window = 1;
    1.26 +    int origin_x, origin_y;
    1.27  
    1.28      current->flags = 0;
    1.29      current->w = width;
    1.30 @@ -606,6 +619,12 @@
    1.31              }
    1.32          }
    1.33                  
    1.34 +        if ( QZ_WindowPosition(this, &origin_x, &origin_y) ) {
    1.35 +            center_window = 0;
    1.36 +            contentRect.origin.x = (float)origin_x;
    1.37 +            contentRect.origin.y = (float)origin_y;            
    1.38 +        }
    1.39 +        
    1.40          /* Manually create a window, avoids having a nib file resource */
    1.41          qz_window = [ [ SDL_QuartzWindow alloc ] 
    1.42              initWithContentRect:contentRect
    1.43 @@ -622,7 +641,9 @@
    1.44          QZ_SetCaption(this, this->wm_title, this->wm_icon);
    1.45          [ qz_window setAcceptsMouseMovedEvents:YES ];
    1.46          [ qz_window setViewsNeedDisplay:NO ];
    1.47 -        [ qz_window center ];
    1.48 +        if ( center_window ) {
    1.49 +            [ qz_window center ];
    1.50 +        }
    1.51          [ qz_window setDelegate:
    1.52              [ [ [ SDL_QuartzWindowDelegate alloc ] init ] autorelease ] ];
    1.53      }