# HG changeset patch
# User Sam Lantinga <slouken@libsdl.org>
# Date 1146134683 0
# Node ID db7e15a99cb36a943c38a6f9ec346555d99bb5e7
# Parent  3a3e847aadb9cbe282d14dc51fa2fd1e7933d196
Fixed bug #101
If we lose focus at all, unlock the mouse.

diff -r 3a3e847aadb9 -r db7e15a99cb3 src/video/x11/SDL_x11events.c
--- a/src/video/x11/SDL_x11events.c	Thu Apr 27 10:21:54 2006 +0000
+++ b/src/video/x11/SDL_x11events.c	Thu Apr 27 10:44:43 2006 +0000
@@ -666,7 +666,7 @@
 			} else {
 				switch_time = now + 200;
 			}
-		} else if ( now >= switch_time ) {
+		} else if ( (int)(switch_time-now) <= 0 ) {
 			Uint32 go_fullscreen;
 
 			go_fullscreen = switch_waiting & SDL_FULLSCREEN;
diff -r 3a3e847aadb9 -r db7e15a99cb3 src/video/x11/SDL_x11mouse.c
--- a/src/video/x11/SDL_x11mouse.c	Thu Apr 27 10:21:54 2006 +0000
+++ b/src/video/x11/SDL_x11mouse.c	Thu Apr 27 10:44:43 2006 +0000
@@ -226,6 +226,7 @@
 /* Check to see if we need to enter or leave mouse relative mode */
 void X11_CheckMouseModeNoLock(_THIS)
 {
+	const Uint8 full_focus = (SDL_APPACTIVE|SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS);
 	char *env_override;
 	int enable_relative = 1;
 
@@ -242,7 +243,7 @@
 	if ( enable_relative &&
 	     !(SDL_cursorstate & CURSOR_VISIBLE) &&
 	     (this->input_grab != SDL_GRAB_OFF) &&
-             (SDL_GetAppState() & SDL_APPACTIVE) ) {
+             (SDL_GetAppState() & full_focus) == full_focus ) {
 		if ( ! mouse_relative ) {
 			X11_EnableDGAMouse(this);
 			if ( ! (using_dga & DGA_MOUSE) ) {