Wrong GetMousePos when select UIOnly/GameAndUI input mode

So, the problem is that, if I set FInputModeGameAndUI or FInputModeUIOnly (with lock mouse to viewport and bShowMouseCursor enabled), and then if I move the mouse to left or top sides of window, then I will get mouse position == FIntPoint(-1, -1), as if i had left the viewport, but my cursor is still in the window boundaries, and this is the problem.

How to reproduce:

  1. Set InputMode like this:
FInputModeGameAndUI Mode;
Mode.SetWidgetToFocus(GEngine->GameViewport->GetGameViewportWidget());
Mode.SetLockMouseToViewportBehavior(EMouseLockMode::LockAlways);
Mode.SetHideCursorDuringCapture(false);
GetWorld()->GetFirstPlayerController()->SetInputMode(Mode);
  1. Set bShowMouseCursor = true; in the PlayerController
  2. Write somewhere in tick function (for debug current mouse position):
FIntPoint MousePos;
GetWorld()->GetFirstLocalPlayerFromController()->ViewportClient->Viewport->GetMousePos(MousePos);
UE_LOG(LogTemp, Warning, TEXT("Current mouse pos: %d %d"), MousePos.X, MousePos.Y);
  1. Launch game
  2. Move the mouse cursor to the leftmost or uppermost position.
  3. When you reach left or top side of window you will get in log:
    Current mouse pos: -1 -1

So, I think that Viewport wrongly think that mouse left the window, because the same mouse position (-1, -1) you will get if mouse cursor is really left the window.


Another things I noticed:

  • When mouse is captured by viewport (Viewport->HasMouseCapture() == true) then all is work properly (GetMousePos return FIntPoint(0,X) if touches top side, or FIntPoint(Y,0) if touched left side), but in this case viewport widgets can’t get any input information (that what I really need).
  • All work fine in FInputModeGameOnly (because it sets viewport capture), but it is not a solve because i still need input for my viewport widgets.

Maybe it’s a bug or I’m doing something wrong, hope somebody can help me.

UPDATE:

  • The problem does not exist in an standalone game.
  • If you change size of your PIE viewport and hit in some magic numbers, then the problem disappeared, too.

So, i think it is definitely a bug of PIE viewport.