changeset 1494:cf960e266444

Fixes for gravity obstacles on Mac.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 25 Dec 2011 03:55:24 +0000
parents ac43d9a9eee7
children 3b4dc98d753b
files mac/dw.m
diffstat 1 files changed, 25 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/mac/dw.m	Sun Dec 25 03:29:10 2011 +0000
+++ b/mac/dw.m	Sun Dec 25 03:55:24 2011 +0000
@@ -7599,7 +7599,7 @@
             /* If the position was not set... generate a default 
              * default one in a similar pattern to SHELLPOSITION. 
              */ 
-            if(rect.origin.x <= 1 || rect.origin.y <= 1)
+            if(rect.origin.x <= 1 && rect.origin.y <= 1)
             {
                 static int defaultx = 0, defaulty; 
                 int cx = dw_screen_width(), cy = dw_screen_height();
@@ -8474,9 +8474,9 @@
     DW_MUTEX_LOCK;
     NSObject *object = handle;
 
-    if([ object isKindOfClass:[ NSWindow class ] ])
-    {
-        NSWindow *window = handle;
+    if([ object isMemberOfClass:[ DWWindow class ] ])
+    {
+        DWWindow *window = handle;
         Box *thisbox;
         NSRect content, frame = NSMakeRect(0, 0, width, height);
        
@@ -8501,6 +8501,8 @@
        
         /* Finally set the size */
         [window setContentSize:content.size];
+        /* Size set manually... don't auto-position */
+        [window setShown:YES];
     }
     DW_MUTEX_UNLOCK;
 }
@@ -8536,8 +8538,6 @@
 {
     int horz = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_grav_horz"));
     int vert = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_grav_vert"));
-    NSRect visiblerect = [[NSScreen mainScreen] visibleFrame];
-    NSRect totalrect = [[NSScreen mainScreen] frame];
     
     /* Do any gravity calculations */
     if(horz || (vert & 0xf) != DW_GRAV_BOTTOM)
@@ -8561,19 +8561,25 @@
         *y = newy;
     }   
     /* Adjust the values to avoid Dock/Menubar if requested */
-    if(horz & DW_GRAV_OBSTACLES)
-    {
-        if((horz & 0xf) == DW_GRAV_LEFT)
-            *x += visiblerect.origin.x;
-        else if((horz & 0xf) == DW_GRAV_RIGHT)
-            *x -= (totalrect.origin.x + totalrect.size.width) - (visiblerect.origin.x + visiblerect.size.width);
-    }
-    if(vert & DW_GRAV_OBSTACLES)
-    {
-        if((vert & 0xf) == DW_GRAV_BOTTOM)
-            *y += visiblerect.origin.y;
-        else if((vert & 0xf) == DW_GRAV_RIGHT)
-            *y -= (totalrect.origin.y + totalrect.size.height) - (visiblerect.origin.y + visiblerect.size.height);
+    if((horz | vert) & DW_GRAV_OBSTACLES)
+    {
+        NSRect visiblerect = [[NSScreen mainScreen] visibleFrame];
+        NSRect totalrect = [[NSScreen mainScreen] frame];
+        
+        if(horz & DW_GRAV_OBSTACLES)
+        {
+            if((horz & 0xf) == DW_GRAV_LEFT)
+                *x += visiblerect.origin.x;
+            else if((horz & 0xf) == DW_GRAV_RIGHT)
+                *x -= (totalrect.origin.x + totalrect.size.width) - (visiblerect.origin.x + visiblerect.size.width);
+        }
+        if(vert & DW_GRAV_OBSTACLES)
+        {
+            if((vert & 0xf) == DW_GRAV_BOTTOM)
+                *y += visiblerect.origin.y;
+            else if((vert & 0xf) == DW_GRAV_TOP)
+                *y -= (totalrect.origin.y + totalrect.size.height) - (visiblerect.origin.y + visiblerect.size.height);
+        }
     }
 }