[BUG] Regarding "UE-206910" Cursor input does not work properly in exclusive fullscreen mode on a secondary monitor

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;
}

Steps to Reproduce

As the subject title shows, this bug can be reproduced by

  1. Start Lyra in a Standalone Window
  2. Switch to windowed mode using Alt-Enter if needed, and move the window to a secondary monitor
  3. Enter the game Front End
  4. Select Options → Video
  5. Change “Window Mode” to “Fullscreen”
  6. Change “Resolution” to something other than what it is natively
  7. Click “Apply”

For other ways, commands like “r.SetRes xxxx” can also reproduce this bug without changing setting video option in the game.

Hi,

We still don’t have a fix for this issue, though I did a bit of investigating and we should be able to swap out CachedDisplayMetrics and use the size from the window’s FullScreenInfo instead:

FVector2f DisplaySize = Window->GetFullScreenInfo().GetSize2f();There are three places where this change will need to be made (Two in SlateApplication, one in SlateUser) but I’ll see about getting that checked in. We’ll also need to verify that there aren’t any performance implications to accessing the full screen info from the window instead of the cached display metrics, since this change does necessitate a few Win32 API calls (MonitorFromWindow, GetMonitorInfo).

Best,

Cody