keeping mouse within window, mouse moving too fast

i’m tracking the cursor within a non-fullscreen window using the recentering trick, but the mouse often moves fast enough to jump out of window…

is there an additional trick to stop this?

Some platforms allow you to set the mouse mode to M_relative, (WindowProperties.set_mouse_mode) and the mouse will be locked to the window.

Perhaps on Windows this could be done using the ClipCursor API call, but I wouldn’t know.