- fixed mouse cursor positioning in menu for Cocoa backend

With video resolution scaling enabled engine coordinates of mouse cursor were wrong
This commit is contained in:
alexey.lysiuk 2018-06-03 17:45:02 +03:00
parent b5274534d7
commit f8f1148c59

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)