]> gitweb.factorcode.org Git - factor.git/commitdiff
Fix window positioning on OS X
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Mon, 13 Apr 2009 08:16:57 +0000 (03:16 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Mon, 13 Apr 2009 08:16:57 +0000 (03:16 -0500)
basis/ui/backend/cocoa/cocoa.factor

index 1bbf46c69e5e6b514a84084cc5e030072bb0eaf5..362305c8f70a4a32cdcf793babfaadd934bfe883 100755 (executable)
@@ -39,13 +39,16 @@ M: pasteboard set-clipboard-contents
     [ 0 0 ] dip dim>> first2 <CGRect> ;
 
 : auto-position ( window loc -- )
+    #! Note: if this is the initial window, the length of the windows
+    #! vector should be 1, since (open-window) calls auto-position
+    #! after register-window.
     dup { 0 0 } = [
         drop
-        windows get [ -> center ] [
-            peek second window-loc>>
+        windows get length 1 <= [ -> center ] [
+            windows get peek second window-loc>>
             dupd first2 <CGPoint> -> cascadeTopLeftFromPoint:
             -> setFrameTopLeftPoint:
-        ] if-empty
+        ] if
     ] [ first2 <CGPoint> -> setFrameTopLeftPoint: ] if ;
 
 M: cocoa-ui-backend set-title ( string world -- )