video: Always grab mouse when exiting main menu.

When we exit the main menu we should grab the mouse and hide the mouse
cursor, even if the cursor is currently pointing outside of the game
window.

It turned out that the logic to determine whether to grab the mouse was
trying too hard to be well-behaved. While we should release mouse grab
if the app loses focus (so the user can see their mouse cursor again and
click on whatever popup has appeared), we don't need to do the same just
because the mouse cursor is outside the game window's bounds.

This fixes #798. Thanks @CapnClever.
This commit is contained in:
Simon Howard 2017-01-18 00:46:34 +00:00
parent d6da5e3ed9
commit ce82099ff1

View file

@ -231,9 +231,6 @@ void I_DisplayFPSDots(boolean dots_on)
display_fps_dots = dots_on;
}
// Show or hide the mouse cursor. We have to use different techniques
// depending on the OS.
static void SetShowCursor(boolean show)
{
if (!screensaver_mode)
@ -351,12 +348,10 @@ static void HandleWindowEvent(SDL_WindowEvent *event)
// is removed if we lose focus (such as a popup window appearing),
// and we dont move the mouse around if we aren't focused either.
case SDL_WINDOWEVENT_ENTER:
case SDL_WINDOWEVENT_FOCUS_GAINED:
window_focused = true;
break;
case SDL_WINDOWEVENT_LEAVE:
case SDL_WINDOWEVENT_FOCUS_LOST:
window_focused = false;
break;