Fixed SDL_VIDEO_WINDOW_POS environment variable for Quartz target. SDL-1.2
authorRyan C. Gordon <icculus@icculus.org>
Tue, 29 Sep 2009 13:07:36 +0000
branchSDL-1.2
changeset 4265c7b1d5eaa77d
parent 4264 d6f4cc9a5bf6
child 4266 62849663f20a
Fixed SDL_VIDEO_WINDOW_POS environment variable for Quartz target.

Fixes Bugzilla #628.
src/video/quartz/SDL_QuartzVideo.m
     1.1 --- a/src/video/quartz/SDL_QuartzVideo.m	Tue Sep 29 11:28:43 2009 +0000
     1.2 +++ b/src/video/quartz/SDL_QuartzVideo.m	Tue Sep 29 13:07:36 2009 +0000
     1.3 @@ -670,7 +670,7 @@
     1.4      current->h = height;
     1.5      
     1.6      contentRect = NSMakeRect (0, 0, width, height);
     1.7 -    
     1.8 +
     1.9      /*
    1.10          Check if we should completely destroy the previous mode 
    1.11          - If it is fullscreen
    1.12 @@ -719,13 +719,7 @@
    1.13                  current->flags |= SDL_RESIZABLE;
    1.14              }
    1.15          }
    1.16 -                
    1.17 -        if ( QZ_WindowPosition(this, &origin_x, &origin_y) ) {
    1.18 -            center_window = 0;
    1.19 -            contentRect.origin.x = (float)origin_x;
    1.20 -            contentRect.origin.y = (float)origin_y;            
    1.21 -        }
    1.22 -        
    1.23 +
    1.24          /* Manually create a window, avoids having a nib file resource */
    1.25          qz_window = [ [ SDL_QuartzWindow alloc ] 
    1.26              initWithContentRect:contentRect
    1.27 @@ -741,14 +735,21 @@
    1.28              }
    1.29              return NULL;
    1.30          }
    1.31 -    
    1.32 +
    1.33          /*[ qz_window setReleasedWhenClosed:YES ];*/ /* no need to set this as it's the default for NSWindows */
    1.34          QZ_SetCaption(this, this->wm_title, this->wm_icon);
    1.35          [ qz_window setAcceptsMouseMovedEvents:YES ];
    1.36          [ qz_window setViewsNeedDisplay:NO ];
    1.37 -        if ( center_window ) {
    1.38 +
    1.39 +        if ( QZ_WindowPosition(this, &origin_x, &origin_y) ) {
    1.40 +            /* have to flip the Y value (NSPoint is lower left corner origin) */
    1.41 +            [ qz_window setFrameTopLeftPoint:NSMakePoint((float) origin_x, (float) (this->info.current_h - origin_y))];
    1.42 +            center_window = 0;
    1.43 +        }
    1.44 +        else if ( center_window ) {
    1.45              [ qz_window center ];
    1.46          }
    1.47 +
    1.48          [ qz_window setDelegate:
    1.49              [ [ SDL_QuartzWindowDelegate alloc ] init ] ];
    1.50          [ qz_window setContentView: [ [ [ SDL_QuartzView alloc ] init ] autorelease ] ];