You might want to use
TArray<TSharedRef<SWindow>> VisibleWindows;
FSlateApplication::Get().GetAllVisibleWindowsOrdered(VisibleWindows);
if (VisibleWindows.Num() != 0)
{
TSharedPtr<SWindow> TopLevelWindow = VisibleWindows[0];
//Rest of the coordinate getting code here
}
instead of the GetActiveTopLevelWindow call, to get the TopLevelWindow, because the TopLevelWindow turns out to actually store the focused widget once you focus on one… Instead of… you know… the top level window.
Note, the index 0 assumption only holds while the editor and all of its windows are minimized.