# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1324785324 0 # Node ID cf960e266444bd0c704b62138e01a0bf0b35abd3 # Parent ac43d9a9eee76a9ea1903151c0951697ad279038 Fixes for gravity obstacles on Mac. diff -r ac43d9a9eee7 -r cf960e266444 mac/dw.m --- 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); + } } }