Those numbers look like the result of integer overflow to me. The number 32,767 is the highest positive value of a signed 16-bit integer, which is probably how MonoGame internally stores the mouse position.
Since the mouse position reported by MonoGame is dependent on the upper-left corner of the render area of the window, it’s probably not really possible to report meaningful mouse locations when the window is minimized.
To handle this, you can just pause/disable your game when the window is minimized. You can do this by subscribing to the Window.ClientSizeChanged event. Alternately, you could subscribe to the Deactivated event of the Game class and pause when that occurs, though only if you want to pause the game whenever it loses focus and not just when it’s minimized.
@MrValentine I have 2 monitors and one Monogame GameWindow, the window is running only in the main screen an minimize into it.
From the microsoft doc, about the MapWindowPoins function, they write:
If the function fails, the return value is zero.
I tried it in a clean WinForm application, and the strange values are coming out from the MapWindowPoins function, but with a fixed {X=32000,Y=32000}.
I found here (Where did windows minimize to before the taskbar was invented? - The Old New Thing) that for historical reasons Windows moves, minimized windows, to this strange coordinates, to avoid screen overlaps.
@HopefulToad Monogame handle the point structure with int32 values, and the MapWindowPoins function uses c++ int, so should be fine with it.
I solved it by following your suggestion.
I store the last valid position, and if the game is IsActive = false, I give back the last valid position, ignoring the current Monogame mouse position, so when the game maximize the user find everything as before.
To be extra safe, I clamp the mouse values inside the window bound.
Therefore, not a clue why you were asking me or what you were asking about, this is @Probe9’s thread, so, what were you enquiring about? if it is not related to this thread, please start a new topic, and ask there.
EDIT
If it relates to this topic, please let it flow its course and follow along, that was rather confusing for me.