Index: macosx/tkMacOSXSubwindows.c
==================================================================
--- macosx/tkMacOSXSubwindows.c
+++ macosx/tkMacOSXSubwindows.c
@@ -151,12 +151,10 @@
 	    NSWindow *win = TkMacOSXDrawableWindow(window);
 	    [NSApp activateIgnoringOtherApps:YES];
 	    if ( [win canBecomeKeyWindow] ) {
 		[win makeKeyAndOrderFront:NSApp];
 	    }
-	    /* Why do we need this? (It is used by Carbon)*/
-	    [win windowRef];
 	    TkMacOSXApplyWindowAttributes(macWin->winPtr, win);
 	}
 	TkMacOSXInvalClipRgns((Tk_Window) macWin->winPtr);
 
 	/*
@@ -314,11 +312,10 @@
 {
     MacDrawable *macWin = (MacDrawable *) window;
     display->request++;
     if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) {
 	NSWindow *w = macWin->winPtr->wmInfoPtr->window;
-
 	if (w) {
 	    NSRect r = [w contentRectForFrameRect:[w frame]];
 	    r.origin.y += r.size.height - height;
 	    r.size.width = width;
 	    r.size.height = height;
@@ -358,14 +355,23 @@
 
     display->request++;
     if (Tk_IsTopLevel(macWin->winPtr) && !Tk_IsEmbedded(macWin->winPtr)) {
 	NSWindow *w = macWin->winPtr->wmInfoPtr->window;
 	if (w) {
-	    NSRect r = NSMakeRect(x + macWin->winPtr->wmInfoPtr->xInParent,
-		    tkMacOSXZeroScreenHeight - (y +
-		    macWin->winPtr->wmInfoPtr->yInParent + height),
-		    width, height);
+	    /* We explicitly convert everything to doubles so we don't get
+	     * surprised (again) by what happens when you do arithmetic with
+	     * unsigned ints.
+	     */
+	    CGFloat X = (CGFloat)x;
+	    CGFloat Y = (CGFloat)y;
+	    CGFloat Width = (CGFloat)width;
+	    CGFloat Height = (CGFloat)height;
+	    CGFloat XOff = (CGFloat)macWin->winPtr->wmInfoPtr->xInParent; 
+	    CGFloat YOff = (CGFloat)macWin->winPtr->wmInfoPtr->yInParent;
+	    NSRect r = NSMakeRect(X + XOff,
+	    			  tkMacOSXZeroScreenHeight - Y - YOff,
+	    			  Width, Height);
 	    [w setFrame:[w frameRectForContentRect:r] display:YES];
 	}
     } else {
 	MoveResizeWindow(macWin);
     }

