I ran across the same issue recently. You might want to read this C++ tutorial from LazyFoo: http://lazyfoo.net/SDL_tutorials/lesson26/index.php
The interesting part about this is detecting SDL_APPMOUSEMOCUS through event.active.state where event is TSDL_Event in your event loop.
There is a small bug with that though, if your mouse cursor is over the application when the application starts, the event is not recognized, but if you move the mouse away from the window and then back into the window, it works again.