shithub: choc

Download patch

ref: ce82099ff17328f1be9f37d14458866e06bb4fa3
parent: d6da5e3ed9bb1c9f1626c2883c49eefa3850813c
author: Simon Howard <fraggle@soulsphere.org>
date: Tue Jan 17 19:46:34 EST 2017

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.

--- a/src/i_video.c
+++ b/src/i_video.c
@@ -231,9 +231,6 @@
     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 @@
         // 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;