changeset 4265:c7b1d5eaa77d SDL-1.2

Fixed SDL_VIDEO_WINDOW_POS environment variable for Quartz target. Fixes Bugzilla #628.
author Ryan C. Gordon <icculus@icculus.org>
date Tue, 29 Sep 2009 13:07:36 +0000
parents d6f4cc9a5bf6
children 62849663f20a
files src/video/quartz/SDL_QuartzVideo.m
diffstat 1 files changed, 11 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/video/quartz/SDL_QuartzVideo.m	Tue Sep 29 11:28:43 2009 +0000
+++ b/src/video/quartz/SDL_QuartzVideo.m	Tue Sep 29 13:07:36 2009 +0000
@@ -670,7 +670,7 @@
     current->h = height;
     
     contentRect = NSMakeRect (0, 0, width, height);
-    
+
     /*
         Check if we should completely destroy the previous mode 
         - If it is fullscreen
@@ -719,13 +719,7 @@
                 current->flags |= SDL_RESIZABLE;
             }
         }
-                
-        if ( QZ_WindowPosition(this, &origin_x, &origin_y) ) {
-            center_window = 0;
-            contentRect.origin.x = (float)origin_x;
-            contentRect.origin.y = (float)origin_y;            
-        }
-        
+
         /* Manually create a window, avoids having a nib file resource */
         qz_window = [ [ SDL_QuartzWindow alloc ] 
             initWithContentRect:contentRect
@@ -741,14 +735,21 @@
             }
             return NULL;
         }
-    
+
         /*[ qz_window setReleasedWhenClosed:YES ];*/ /* no need to set this as it's the default for NSWindows */
         QZ_SetCaption(this, this->wm_title, this->wm_icon);
         [ qz_window setAcceptsMouseMovedEvents:YES ];
         [ qz_window setViewsNeedDisplay:NO ];
-        if ( center_window ) {
+
+        if ( QZ_WindowPosition(this, &origin_x, &origin_y) ) {
+            /* have to flip the Y value (NSPoint is lower left corner origin) */
+            [ qz_window setFrameTopLeftPoint:NSMakePoint((float) origin_x, (float) (this->info.current_h - origin_y))];
+            center_window = 0;
+        }
+        else if ( center_window ) {
             [ qz_window center ];
         }
+
         [ qz_window setDelegate:
             [ [ SDL_QuartzWindowDelegate alloc ] init ] ];
         [ qz_window setContentView: [ [ [ SDL_QuartzView alloc ] init ] autorelease ] ];