Using SDL_ShowCursor to hide the mouse on a timeout

I’m trying to use SDL_ShowCursor to hide the mouse cursor on inactivity.
I’m calling SDL_ShowCursor(SDL_DISABLE) in a timer and
SDL_ShowCursor(SDL_ENABLE) on a mouse movement.

As is, the above doesn’t work. If I call SDL_GetMouseState(&x, &y) and
SDL_WarpMouse(x, y) after calling SDL_ShowCursor(SDL_DISABLE) it does,
but the cursor gets warped back to the last position it held in the SDL
window if it’s outside it.

Is there a way to either detect when the cursor is outside the SDL
window, or to activate SDL_ShowCursor without SDL_WarpMouse?