# sdl: unlock mouse in fullscreen mode and make it useable on another monitor

Is it possible to unlock the mouse in fullscreen mode so that you can use it on a another monitor? I read trough the SDL documentation, but I couldn't find anything related to my problem.

• It's likely you don't want to use "real" fullscreen, but "fake" fullscreen (full size borderless window). See this question on SO and maybe it'll help you: stackoverflow.com/questions/7927974/… – Tetrad Feb 27 '13 at 22:05
• I didn't need to do anything special to support this when I did exactly this, yesterday, testing on OSX using SDL version 2.0.2. Had a fullscreen window on one monitor, not set to capture the mouse, and I was able to freely move the mouse back to the other monitor and interact with windows there. What you're seeing might be platform-specific behaviour? (In which case, you should specify what platform you're working on) – Trevor Powell Apr 10 '14 at 4:36

This is for SDL 2, but have you showing the cursor cursor and seeing if it can escape?

function for creating a cursor:

int SDL_ShowCursor(int toggle)


so it would be like this

SDL_ShowCursor(1);


look more into it here:

http://wiki.libsdl.org/SDL_ShowCursor?highlight=%28%5CbCategoryMouse%5Cb%29%7C%28CategoryEnum%29%7C%28CategoryStruct%29

personally I do not have a second monitor so I cannot help you

In SDL 2 there is also SDL_Get/SetWindowGrab which returns/sets whether or not the window is grabbing the mouse. I think this is what you want.
https://wiki.libsdl.org/SDL_SetWindowGrab?highlight=%28%5CbCategoryVideo%5Cb%29%7C%28CategoryEnum%29%7C%28CategoryStruct%29

For SDL2 (don't use SDL1 anymore):

// to configure the window
SDL_SetWindowFullscreen(my_window, SDL_WINDOW_FULLSCREEN_DESKTOP);

// to unlock the mouse
SDL_SetWindowGrab(my_window, false);
SDL_SetRelativeMouseMode(false);

// to lock the mouse
SDL_SetWindowGrab(my_window, true);
SDL_SetRelativeMouseMode(true);


That first sets the window to the "fake" fullscreen that is just a resolution-sized borderless window. This is necessary on Windows and some Linux setups to have a mouse cursor that can freely enter and leave the window on a multi-monitor setup.