Hi there,
This bug is also posted on community forum in the last month:
https://forums.unrealengine.com/t/fullscreen-on-a-second-monitor-different-rez-from-primary/2656419
This code below, will transform the cursor positon when window resolution doesn’t match platform resolution. However, PrimaryDisplayWidth and PrimaryDisplayHeight in FDisplayMetrics is always set to width and height of the primary monitor in OS, which means that when the game window is in another monitor which has different width and height from the primary monitor, the cursor position will always be wrong. Although the logic that led to this issue is not complicated, it makes impossible to create a game supporting for exclusive fullscreen and multi-monitor.
So, what is Epic Games’ plan for this issue? I hope there will be more support for multi-monitor after this issue is solved.
Thanks.
FPointerEvent FSlateApplication::TransformPointerEvent(const FPointerEvent& PointerEvent, const TSharedPtr<SWindow>& Window) const
{
FPointerEvent TransformedPointerEvent = PointerEvent;
if (Window)
{
if (TransformFullscreenMouseInput && !GIsEditor && Window->GetWindowMode() == EWindowMode::Fullscreen)
{
// Screen space mapping scales everything. When window resolution doesn't match platform resolution,
// this causes offset cursor hit-tests in fullscreen. Correct in slate since we are first window-aware slate processor.
FVector2f WindowSize = Window->GetSizeInScreen();
FVector2f DisplaySize = { (float)CachedDisplayMetrics.PrimaryDisplayWidth, (float)CachedDisplayMetrics.PrimaryDisplayHeight };
TransformedPointerEvent = FPointerEvent(PointerEvent, PointerEvent.GetScreenSpacePosition() * WindowSize / DisplaySize, PointerEvent.GetLastScreenSpacePosition() * WindowSize / DisplaySize);
}
}
return TransformedPointerEvent;
}