- fixed mouse cursor positioning in menu for Cocoa backend

With video resolution scaling enabled engine coordinates of mouse cursor were wrong

(cherry picked from commit f8f1148c59)
This commit is contained in:
alexey.lysiuk 2018-06-03 17:45:02 +03:00 committed by drfrag666
parent d645da3ccf
commit 53f66a6c4c

View file

@ -484,11 +484,14 @@ void NSEventToGameMousePosition(NSEvent* inEvent, event_t* outEvent)
const NSPoint viewPos = [view convertPointToBacking:windowRect.origin];
const CGFloat frameHeight = I_GetContentViewSize(window).height;
const CGFloat posX = ( viewPos.x - rbOpts.shiftX) / rbOpts.pixelScale;
const CGFloat posY = (frameHeight - viewPos.y - rbOpts.shiftY) / rbOpts.pixelScale;
outEvent->data1 = static_cast<int16_t>( viewPos.x);
outEvent->data2 = static_cast<int16_t>(frameHeight - viewPos.y);
outEvent->data1 = static_cast<int>(posX);
outEvent->data2 = static_cast<int>(posY);
// Compensate letterbox adjustment done by cross-platform code
// More elegant solution is a bit problematic due to HiDPI/Retina support
outEvent->data2 += (screen->GetTrueHeight() - screen->VideoHeight) / 2;
screen->ScaleCoordsFromWindow(outEvent->data1, outEvent->data2);
}
void ProcessMouseMoveInMenu(NSEvent* theEvent)