diff --git a/src/MacVim/MMVimController.m b/src/MacVim/MMVimController.m index c5bbd98dfa..99bad6a756 100644 --- a/src/MacVim/MMVimController.m +++ b/src/MacVim/MMVimController.m @@ -851,6 +851,10 @@ static BOOL isUnsafeMessage(int msgid); int x = *((int*)bytes); bytes += sizeof(int); int y = *((int*)bytes); bytes += sizeof(int); + // NOTE: Vim measures Y-coordinates from top of screen. + NSRect frame = [[[windowController window] screen] frame]; + y = NSMaxY(frame) - y; + [windowController setTopLeft:NSMakePoint(x,y)]; } else if (SetTooltipMsgID == msgid) { id textView = [[windowController vimView] textView]; diff --git a/src/MacVim/MMWindowController.m b/src/MacVim/MMWindowController.m index 0fea63f511..6f4a7dc0b2 100644 --- a/src/MacVim/MMWindowController.m +++ b/src/MacVim/MMWindowController.m @@ -874,7 +874,10 @@ // NOTE: This method is called when the user drags the window, but not when // the top left point changes programmatically. - int pos[2] = { (int)topLeft.x, (int)topLeft.y }; + // NOTE 2: Vim counts Y-coordinates from the top of the screen. + int pos[2] = { + (int)topLeft.x, + (int)(NSMaxY([[decoratedWindow screen] frame]) - topLeft.y) }; NSData *data = [NSData dataWithBytes:pos length:2*sizeof(int)]; [vimController sendMessage:SetWindowPositionMsgID data:data]; } @@ -1062,7 +1065,10 @@ // NOTE: The window top left position may change due to the window // being moved e.g. when the tabline is shown so we must tell Vim what // the new window position is here. - int pos[2] = { (int)newTopLeft.x, (int)newTopLeft.y }; + // NOTE 2: Vim measures Y-coordinates from top of screen. + int pos[2] = { + (int)newTopLeft.x, + (int)(NSMaxY([[decoratedWindow screen] frame]) - newTopLeft.y) }; NSData *data = [NSData dataWithBytes:pos length:2*sizeof(int)]; [vimController sendMessage:SetWindowPositionMsgID data:data]; }