Can't disable relative mouse mode in fullscreen

Hey!

I’m having an issue where relative mouse mode can be toggled on and off perfectly in normal mode, but when the window is fullscreen (SDL_SetWindowFullscreen with SDL_WINDOW_FULLSCREEN_DESKTOP) it can’t really be disabled. The cursor continues to be invisible. This is what I’m doing to disable it: SDL_SetRelativeMouseMode(SDL_FALSE);. Any idea as to why it doesn’t work in desktop fullscreen? Thanks!

Welcome @freeranger!

I’m not sure if SDL_SetRelativeMouseMode() is intended to affect the cursor (might make sense though).

Maybe you also need SDL_ShowCursor(SDL_ENABLE);?

1 Like

Thanks for the reply!

Adding that line seems to be necessary in fullscreen mode, so thanks! However, there seems to be something else going on as well. When disabling relative mouse mode it almost seems like the window just loses its focus, and therefore I have to tab out and back in again (and also click on the window to give it back its focus) to get it all working. Don’t know if that’s exactly what happens tho, but it’s quite strange and I don’t really know what’s going on or how to solve it…

That sounds weird.

What operating system (and, if Linux/Unix-like, what display server and desktop environment) are you using?

I’m on windows 10, haven’t tested on other platforms yet

I’m using Win10 with VS2019 and not seeing this problem or the loss of focus strangeness. I set the screen with SDL_SetRelativeMouseMode and toggling relative mode on and off switches the mouse pointer off and on as expected.

Which version of SDL are you using? Which IDE are you using?

I’m using the latest version of SDL2 with CLion and also bgfx (but that’s a rendering library that doesn’t deal with the window management so it shouldn’t be relevant).

I could try and send a video (or even the executable) if you want?

Your best bet is to set up a bare bones test app that brings up an empty window with a basic event loop that toggles relative mouse mode with a key press. See if you can reproduce. Then add bits until you see the bug, then you’ll know what’s causing it. My best bet is it’s one of the other things you’re plugging into your app.